summaryrefslogtreecommitdiffhomepage
path: root/main/editor.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-23 17:31:31 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-23 17:31:31 +0200
commitcce1f768e7399b838a2b865511915bdd576dbbf4 (patch)
tree4c6a8f2dc9112394fd329d56c0f628ce66b16467 /main/editor.hpp
parent6b875a0919b9932eca9ed877552c34ecb220b7d8 (diff)
a
Diffstat (limited to 'main/editor.hpp')
-rw-r--r--main/editor.hpp93
1 files changed, 0 insertions, 93 deletions
diff --git a/main/editor.hpp b/main/editor.hpp
deleted file mode 100644
index 28ba153c..00000000
--- a/main/editor.hpp
+++ /dev/null
@@ -1,93 +0,0 @@
-#pragma once
-#include "compat/defs.hpp"
-#include "tile-atlas.hpp"
-#include "global-coords.hpp"
-#include "tile.hpp"
-
-#include <cstdint>
-#include <tuple>
-#include <optional>
-#include <vector>
-#include <map>
-#include <memory>
-#include <Corrade/Containers/StringView.h>
-
-namespace floormat {
-
-enum class editor_mode : unsigned char {
- select, floor, walls,
-};
-
-struct world;
-
-struct tile_type final
-{
- tile_type(editor_mode mode, Containers::StringView name);
- std::shared_ptr<tile_atlas> maybe_atlas(Containers::StringView str);
- std::shared_ptr<tile_atlas> atlas(Containers::StringView str);
- auto cbegin() const { return _atlases.cbegin(); }
- auto cend() const { return _atlases.cend(); }
- auto begin() const { return _atlases.cbegin(); }
- auto end() const { return _atlases.cend(); }
- Containers::StringView name() const { return _name; }
- editor_mode mode() const { return _mode; }
-
- void clear_selection();
- void select_tile(const std::shared_ptr<tile_atlas>& atlas, std::size_t variant);
- void select_tile_permutation(const std::shared_ptr<tile_atlas>& atlas);
- bool is_tile_selected(const std::shared_ptr<const tile_atlas>& atlas, std::size_t variant) const;
- bool is_permutation_selected(const std::shared_ptr<const tile_atlas>& atlas) const;
- bool is_atlas_selected(const std::shared_ptr<const tile_atlas>& atlas) const;
- tile_image get_selected();
- void place_tile(world& world, global_coords pos, tile_image& img);
-
-private:
- enum selection_mode : std::uint8_t {
- sel_none, sel_tile, sel_perm,
- };
- enum rotation : std::uint8_t {
- rot_N, rot_W,
- };
-
- std::string _name;
- std::map<std::string, std::shared_ptr<tile_atlas>> _atlases;
- tile_image _selected_tile;
- std::tuple<std::shared_ptr<tile_atlas>, std::vector<std::size_t>> _permutation;
- selection_mode _selection_mode = sel_none;
- editor_mode _mode;
- rotation _rotation{};
-
- void load_atlases();
- tile_image get_selected_perm();
-};
-
-struct editor final
-{
- [[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);
-
- tile_type& floor() { return _floor; }
- const tile_type& floor() const { return _floor; }
-
- tile_type* current();
- const tile_type* current() const;
-
- void on_click(world& world, global_coords pos);
- void on_mouse_move(world& world, const global_coords pos);
- void on_release();
-
- editor();
- editor(editor&&) noexcept = default;
- editor& operator=(editor&&) noexcept = default;
- fm_DECLARE_DELETED_COPY_ASSIGNMENT(editor);
-
-private:
- tile_type _floor{editor_mode::floor, "floor"};
- std::optional<global_coords> _last_pos;
- editor_mode _mode = editor_mode::select;
- bool _dirty = false;
-};
-
-} // namespace floormat