7 std::vector<core::item::Id> ItemSelector::idLookup;
11 ItemSelector::ItemSelector(
const ChangeCb& cb)
14 getSignal(bl::gui::Event::ValueChanged)
15 .willAlwaysCall([
this, cb](
const bl::gui::Event&, bl::gui::Element*) {
22 return getSelectedOption() >= 0 && !idLookup.empty() ? idLookup[getSelectedOption()] :
39 idLookup.push_back(item);
41 if (item == ci) { setSelectedOption(i,
false); }
Id
Represents an item in its simplist form.
All classes and functionality used for implementing the game editor.
static const std::string & getName(item::Id item)
Returns the name of the given item.
static const std::vector< Id > & validIds()
Returns the list of valid item ids.
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.