blob: 321b75c63e9cc60b2ae9809fb41301d2863f4fe7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#pragma once
#include "editor-enums.hpp"
#include "src/tile-image.hpp"
#include "global-coords.hpp"
#include <vector>
#include <map>
#include <memory>
#include <Corrade/Containers/String.h>
namespace floormat {
struct world;
struct tile_editor final
{
private:
enum selection_mode : unsigned char {
sel_none, sel_tile, sel_perm,
};
struct tuple final {
std::shared_ptr<tile_atlas> atlas;
std::vector<decltype(tile_image_proto::variant)> variant;
};
String _name;
std::map<StringView, std::shared_ptr<tile_atlas>> _atlases;
tile_image_proto _selected_tile;
tuple _permutation;
selection_mode _selection_mode = sel_none;
editor_mode _mode;
editor_wall_rotation _rotation = editor_wall_rotation::N;
void load_atlases();
tile_image_proto get_selected_perm();
public:
tile_editor(editor_mode mode, StringView name);
std::shared_ptr<tile_atlas> maybe_atlas(StringView str);
std::shared_ptr<tile_atlas> atlas(StringView str);
auto cbegin() const noexcept { return _atlases.cbegin(); }
auto cend() const noexcept { return _atlases.cend(); }
auto begin() const noexcept { return _atlases.cbegin(); }
auto end() const noexcept { return _atlases.cend(); }
StringView name() const noexcept;
editor_mode mode() const noexcept { return _mode; }
editor_wall_rotation rotation() const noexcept { return _rotation; }
void clear_selection();
void select_tile(const std::shared_ptr<tile_atlas>& atlas, 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, 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;
bool is_anything_selected() const;
tile_image_proto get_selected();
void place_tile(world& world, global_coords pos, const tile_image_proto& img);
void toggle_rotation();
void set_rotation(editor_wall_rotation r);
editor_snap_mode check_snap(int mods) const;
bool can_rotate() const;
};
} // namespace floormat
|