summaryrefslogtreecommitdiffhomepage
path: root/main/editor.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-15 21:51:33 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-15 21:51:33 +0200
commit1e8d16fe10917664f9520008f224f19692c3a668 (patch)
treec966c22e3bb719754a01715778f0820aa0853dfa /main/editor.hpp
parentd8874ad6c42ec016fa931fe3e57fcd9797d06094 (diff)
a
Diffstat (limited to 'main/editor.hpp')
-rw-r--r--main/editor.hpp45
1 files changed, 43 insertions, 2 deletions
diff --git a/main/editor.hpp b/main/editor.hpp
index af3934eb..993d057a 100644
--- a/main/editor.hpp
+++ b/main/editor.hpp
@@ -1,4 +1,9 @@
#pragma once
+#include "tile-atlas.hpp"
+#include <map>
+#include <memory>
+#include <tuple>
+#include <Corrade/Containers/StringView.h>
namespace floormat {
@@ -6,10 +11,46 @@ enum class editor_mode : unsigned char {
select, floors, walls,
};
+struct tile_type final
+{
+ tile_type(Containers::StringView name);
+ std::shared_ptr<struct tile_atlas> atlas(Containers::StringView str);
+ auto begin() & { return _atlases.begin(); }
+ auto end() & { return _atlases.end(); }
+ auto begin() const&& { return _atlases.cbegin(); }
+ auto end() const&& { return _atlases.cend(); }
+ auto cbegin() const { return _atlases.cbegin(); }
+ auto cend() const { return _atlases.cend(); }
+ Containers::StringView name() const { return _name; }
+
+private:
+ std::string _name;
+ std::map<std::string, std::shared_ptr<struct tile_atlas>> _atlases;
+ void load_atlases();
+};
+
struct editor_state final
{
- editor_mode mode = {};
- bool dirty = false;
+ [[nodiscard]] bool dirty() const { return _dirty; }
+ void set_dirty(bool value) { _dirty = value; }
+ [[nodiscard]] editor_mode mode() const { return _mode; }
+ void set_mode(editor_mode mode) { _mode = mode; }
+
+ tile_type& floors() { return _floors; }
+ const tile_type& floors() const { return _floors; }
+
+ editor_state();
+
+ editor_state(const editor_state&) = delete;
+ editor_state& operator=(const editor_state&) = delete;
+
+ editor_state(editor_state&&) noexcept = default;
+ editor_state& operator=(editor_state&&) noexcept = default;
+
+private:
+ tile_type _floors{"floor"};
+ editor_mode _mode = {};
+ bool _dirty = false;
};
} // namespace floormat