Peoplemon  0.1.0
Peoplemon 3 game source documentation
Layers.hpp
Go to the documentation of this file.
1 #ifndef EDITOR_PAGES_SUBPAGES_LAYERS_HPP
2 #define EDITOR_PAGES_SUBPAGES_LAYERS_HPP
3 
4 #include <BLIB/Interfaces/GUI.hpp>
5 #include <Core/Maps/Map.hpp>
6 
7 namespace editor
8 {
9 namespace page
10 {
17 class Layers {
18 public:
19  using AppendCb = std::function<void(unsigned int level)>;
20  using DeleteCb = std::function<void(unsigned int level, unsigned int layer)>;
21  using ShiftCb = std::function<void(unsigned int level, unsigned int layer, bool up)>;
23  std::function<void(unsigned int level, unsigned int layer, bool visible)>;
24 
35  Layers(const AppendCb& bottomAddCb, const AppendCb& ysortAddCb, const AppendCb& topAddCb,
36  const DeleteCb& delCb, const ShiftCb& shiftCb, const RenderFilterCb& filterCb);
37 
44  void sync(const std::vector<core::map::LayerSet>& levels,
45  const std::vector<std::vector<bool>>& filter);
46 
51  bl::gui::Box::Ptr getContent();
52 
57  void pack();
58 
63  void unpack();
64 
65 private:
66  struct LayerRow {
67  using VisibleCb = std::function<void(unsigned int layer, bool visible)>;
68  using DeleteCb = std::function<void(unsigned int layer)>;
69  using ShiftCb = std::function<void(unsigned int layer, bool up)>;
70 
71  bl::gui::Box::Ptr row;
72  bl::gui::Label::Ptr name;
73  bl::gui::CheckButton::Ptr visibleToggle;
74  bl::gui::Button::Ptr upBut;
75  bl::gui::Button::Ptr downBut;
76  bl::gui::Button::Ptr delBut;
77  unsigned int index;
78 
79  LayerRow(unsigned int i, bool canUp, bool canDown, bool visible, const VisibleCb& visibleCb,
80  const DeleteCb& delCb, const ShiftCb& shiftCb);
81  };
82 
83  struct LevelTab {
84  std::vector<LayerRow> items;
85  unsigned int index;
86 
87  bl::gui::ScrollArea::Ptr page;
88  bl::gui::Box::Ptr bottomBox;
89  bl::gui::Box::Ptr ysortBox;
90  bl::gui::Box::Ptr topBox;
91 
92  LevelTab(unsigned int i, const core::map::LayerSet& level, const std::vector<bool>& filter,
93  const RenderFilterCb& visibleCb, const AppendCb& bottomAddCb,
94  const AppendCb& ysortAddCb, const AppendCb& topAddCb, const DeleteCb& delCb,
95  const ShiftCb& shiftCb);
96  };
97 
98  const AppendCb bottomAdd;
99  const AppendCb ysortAdd;
100  const AppendCb topAdd;
101  const DeleteCb delCb;
102  const ShiftCb shiftCb;
103  const RenderFilterCb filterCb;
104 
105  bl::gui::Box::Ptr contentWrapper;
106  bl::gui::Notebook::Ptr content;
107 
108  std::vector<LevelTab> pages;
109 };
110 
111 } // namespace page
112 } // namespace editor
113 
114 #endif
All classes and functionality used for implementing the game editor.
Definition: Tile.hpp:11
Encapsulates a set of layers for a given map height. Maps have one LayerSet per height level,...
Definition: LayerSet.hpp:51
Provides controls to add, move, remove, and toggle visibility for layers.
Definition: Layers.hpp:17
std::function< void(unsigned int level, unsigned int layer)> DeleteCb
Definition: Layers.hpp:20
void unpack()
Hides the GUI content. Good for saving space when not active.
Definition: Layers.cpp:44
std::function< void(unsigned int level)> AppendCb
Definition: Layers.hpp:19
void pack()
Packs the GUI content.
Definition: Layers.cpp:42
void sync(const std::vector< core::map::LayerSet > &levels, const std::vector< std::vector< bool >> &filter)
Syncs the GUI elements with the map layers that exist.
Definition: Layers.cpp:25
std::function< void(unsigned int level, unsigned int layer, bool visible)> RenderFilterCb
Definition: Layers.hpp:23
bl::gui::Box::Ptr getContent()
Returns the GUI content to pack.
Definition: Layers.cpp:40
std::function< void(unsigned int level, unsigned int layer, bool up)> ShiftCb
Definition: Layers.hpp:21
Layers(const AppendCb &bottomAddCb, const AppendCb &ysortAddCb, const AppendCb &topAddCb, const DeleteCb &delCb, const ShiftCb &shiftCb, const RenderFilterCb &filterCb)
Construct a new Layers subpage.
Definition: Layers.cpp:11