summaryrefslogtreecommitdiffhomepage
path: root/editor
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-11-06 19:20:03 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-11-06 19:20:11 +0100
commitb82ebb0339a15cc05e26f9cdca646022e6b71ef4 (patch)
tree1e8bb27a0f5d0c84de4790465cf280d77c785a33 /editor
parentedc3ad8c86cb1a042134f82c738029004b116d86 (diff)
a
Diffstat (limited to 'editor')
-rw-r--r--editor/editor.hpp25
-rw-r--r--editor/precomp.hpp5
-rw-r--r--editor/scenery-editor.cpp40
-rw-r--r--editor/scenery-editor.hpp37
4 files changed, 81 insertions, 26 deletions
diff --git a/editor/editor.hpp b/editor/editor.hpp
index 94cb7709..b25e6900 100644
--- a/editor/editor.hpp
+++ b/editor/editor.hpp
@@ -6,6 +6,7 @@
#include "scenery.hpp"
#include "editor-enums.hpp"
#include "tile-editor.hpp"
+#include "scenery-editor.hpp"
#include <optional>
#include <map>
@@ -18,30 +19,6 @@ struct world;
struct anim_atlas;
struct tile_atlas;
-struct scenery_editor final
-{
- struct pair final {
- std::shared_ptr<anim_atlas> atlas;
- scenery s;
- };
-
- scenery_editor() noexcept;
-
- void set_rotation(rotation r);
- void rotation() const;
- void next_rotation();
- void prev_rotation();
-
- void select_tile(const std::shared_ptr<anim_atlas>& atlas, enum rotation r, std::uint16_t frame);
- void clear_selection();
-
-private:
- void load_atlases();
-
- std::map<StringView, std::shared_ptr<anim_atlas>> _atlases;
- pair _selected_frame;
-};
-
struct editor final
{
[[nodiscard]] bool dirty() const noexcept { return _dirty; }
diff --git a/editor/precomp.hpp b/editor/precomp.hpp
index f309133a..93ff8164 100644
--- a/editor/precomp.hpp
+++ b/editor/precomp.hpp
@@ -8,6 +8,7 @@
#include <Magnum/Math/Color.h>
#include <Magnum/GL/DebugOutput.h>
#include <Magnum/GL/Renderer.h>
-#include <Magnum/Platform/Sdl2Application.h>
#include <Magnum/ImGuiIntegration/Context.h>
-
+#if __has_include(<SDL.h>)
+#include <Magnum/Platform/Sdl2Application.h>
+#endif
diff --git a/editor/scenery-editor.cpp b/editor/scenery-editor.cpp
new file mode 100644
index 00000000..c3b29c9d
--- /dev/null
+++ b/editor/scenery-editor.cpp
@@ -0,0 +1,40 @@
+#include "scenery-editor.hpp"
+#include "src/anim-atlas.hpp"
+
+namespace floormat {
+
+using rotation_ = enum rotation;
+using rotation_t = std::underlying_type_t<rotation_>;
+
+scenery_editor::scenery_editor() noexcept
+{
+}
+
+void scenery_editor::set_rotation(enum rotation r)
+{
+ _selected.s.r = r;
+}
+
+rotation scenery_editor::rotation() const
+{
+ return _selected.s.r;
+}
+
+void scenery_editor::next_rotation()
+{
+ auto r_1 = (rotation_t)_selected.s.r + 1;
+ auto rot = (rotation_)r_1;
+ if (rot >= rotation_::COUNT)
+ rot = (rotation_)0;
+ _selected.s.r = rot;
+}
+
+void scenery_editor::prev_rotation()
+{
+ if (_selected.s.r == (rotation_)0)
+ _selected.s.r = (rotation_)((rotation_t)rotation_::COUNT - 1);
+ else
+ _selected.s.r = (rotation_)((rotation_t)_selected.s.r - 1);
+}
+
+} // namespace floormat
diff --git a/editor/scenery-editor.hpp b/editor/scenery-editor.hpp
new file mode 100644
index 00000000..f4b40c66
--- /dev/null
+++ b/editor/scenery-editor.hpp
@@ -0,0 +1,37 @@
+#pragma once
+#include "src/scenery.hpp"
+#include <map>
+#include <memory>
+#include <Corrade/Containers/StringView.h>
+
+namespace floormat {
+
+struct anim_atlas;
+
+struct scenery_editor final
+{
+ struct pair final {
+ std::shared_ptr<anim_atlas> atlas;
+ scenery s;
+ };
+
+ scenery_editor() noexcept;
+
+ void set_rotation(enum rotation r);
+ enum rotation rotation() const;
+ void next_rotation();
+ void prev_rotation();
+
+ void select_tile(const std::shared_ptr<anim_atlas>& atlas, enum rotation r, std::uint16_t frame);
+ void clear_selection();
+ bool is_atlas_selected() const;
+ bool is_item_selected(const std::shared_ptr<anim_atlas>& atlas, enum rotation r, std::uint16_t frame) const;
+
+private:
+ void load_atlases();
+
+ std::map<StringView, std::shared_ptr<anim_atlas>> _atlases;
+ pair _selected;
+};
+
+} // namespace floormat