Peoplemon  0.1.0
Peoplemon 3 game source documentation
ItemSelector.hpp
Go to the documentation of this file.
1 #ifndef EDITOR_COMPONENTS_ITEMSELECTOR_HPP
2 #define EDITOR_COMPONENTS_ITEMSELECTOR_HPP
3 
4 #include <BLIB/Interfaces/GUI.hpp>
5 #include <Core/Items/Item.hpp>
6 
7 namespace editor
8 {
9 namespace component
10 {
17 class ItemSelector : public bl::gui::ComboBox {
18 public:
20  using Ptr = std::shared_ptr<ItemSelector>;
21 
23  using ChangeCb = std::function<void(core::item::Id)>;
24 
31  static Ptr create(const ChangeCb& cb = [](core::item::Id) {});
32 
39 
44  void setItem(core::item::Id item);
45 
50  void refresh();
51 
52 private:
53  static std::vector<core::item::Id> idLookup;
54 
55  ItemSelector(const ChangeCb& cb = {});
56 };
57 
58 } // namespace component
59 } // namespace editor
60 
61 #endif
Id
Represents an item in its simplist form.
Definition: Id.hpp:24
All classes and functionality used for implementing the game editor.
Definition: Tile.hpp:11
Wrapper over ComboBox that allows selection of any item in the item database.
void setItem(core::item::Id item)
Set the current item.
core::item::Id currentItem() const
Returns the current selected item.
void refresh()
Refreshes the items from the item database.
std::function< void(core::item::Id)> ChangeCb
Called when the item changes.
std::shared_ptr< ItemSelector > Ptr
Pointer to this component.
static Ptr create(const ChangeCb &cb=[](core::item::Id) {})
Creates a new ItemSelector.
Definition: ItemSelector.cpp:9