summaryrefslogtreecommitdiffhomepage
path: root/editor/wall-editor.hpp
blob: 159135a06184903914f38273ec821aead7f4eb4f (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
#pragma once
#include "editor-enums.hpp"
#include "src/rotation.hpp"
#include "src/global-coords.hpp"
#include "loader/wall-info.hpp"
#include <memory>
#include <map>

namespace floormat {

class world;
class wall_atlas;

class wall_editor
{
    std::map<StringView, const wall_info*> _atlases;
    std::shared_ptr<wall_atlas> _selected_atlas;
    enum rotation _r = rotation::N;

    void load_atlases();

public:
    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(); }

    wall_editor();
    StringView name() const;

    enum rotation rotation() const;
    void set_rotation(enum rotation r);
    void toggle_rotation();

    std::shared_ptr<wall_atlas> get_selected() const;
    void select_atlas(const std::shared_ptr<wall_atlas>& atlas);
    void clear_selection();
    bool is_atlas_selected(const std::shared_ptr<wall_atlas>& atlas) const;
    bool is_anything_selected() const;

    void place_tile(world& w, global_coords coords, const std::shared_ptr<wall_atlas>& atlas);
    editor_snap_mode check_snap(int mods) const;
};

} // namespace floormat