summaryrefslogtreecommitdiff
path: root/src/editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/editor.cpp')
-rw-r--r--src/editor.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/editor.cpp b/src/editor.cpp
index 198620c..97979fb 100644
--- a/src/editor.cpp
+++ b/src/editor.cpp
@@ -2,6 +2,8 @@
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Vector2.hpp>
+#include <SFML/Window/Event.hpp>
+#include <SFML/Window/Keyboard.hpp>
#include <memory>
#include <optional>
#include <string>
@@ -13,6 +15,17 @@
#include "tileset.hpp"
namespace silly::editor {
+ void Editor::update(const sf::Event &event) {
+ if (const auto *e = event.getIf<sf::Event::KeyPressed>()) {
+ if (e->code == sf::Keyboard::Key::R) {
+ this->rotation += 90.0f;
+ if (this->rotation >= 360.0f) {
+ this->rotation = 0.0f;
+ }
+ }
+ }
+ }
+
void Editor::update(const sf::RenderWindow &window) {
if (sf::Mouse::isButtonPressed(sf::Mouse::Button::Left) ||
sf::Mouse::isButtonPressed(sf::Mouse::Button::Right)) {
@@ -28,7 +41,8 @@ namespace silly::editor {
if (sf::Mouse::isButtonPressed(sf::Mouse::Button::Left) &&
this->selectedTile.has_value()) {
- this->floor.place_tile(this->selectedTile.value(), pos);
+ this->floor.place_tile(this->selectedTile.value(), pos,
+ this->rotation);
} else if (sf::Mouse::isButtonPressed(sf::Mouse::Button::Right)) {
this->floor.remove_tile(pos);
}
@@ -54,6 +68,7 @@ namespace silly::editor {
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar);
// --- SELECTED TILE ---
+ ImGui::BeginChild("SelectedTileRegion", ImVec2(200, 100));
if (this->selectedTile.has_value()) {
TilesetTile *t = this->selectedTile->get();
@@ -70,6 +85,14 @@ namespace silly::editor {
ImGui::Text("NO TILE SELECTED!");
ImGui::Dummy(ImVec2(64, 64));
}
+ ImGui::EndChild();
+
+ ImGui::SameLine();
+
+ // --- EDITOR SETTINGS ---
+ ImGui::BeginChild("EditorSettingsRegion", ImVec2(170, 100));
+ ImGui::Text("Rotation is %.0f degrees", this->rotation);
+ ImGui::EndChild();
// --- TILE SELECTION ---
ImGui::BeginChild("TileSelectionRegion", ImVec2(0, 400),