Peoplemon  0.1.0
Peoplemon 3 game source documentation
TypeSelector.cpp
Go to the documentation of this file.
2 
3 namespace editor
4 {
5 namespace component
6 {
7 namespace
8 {
9 constexpr core::pplmn::Type indexToType[] = {core::pplmn::Type::None,
17 constexpr std::size_t typeCount = sizeof(indexToType) / sizeof(indexToType[0]);
18 } // namespace
19 
21 
22 TypeSelector::TypeSelector()
23 : ComboBox() {
24  addOption("None");
25  addOption("Normal");
26  addOption("Intelligent");
27  addOption("Funny");
28  addOption("Athletic");
29  addOption("Quiet");
30  addOption("Awkward");
31  addOption("PartyAnimal");
32 
33  setSelectedOption(0);
34 }
35 
36 core::pplmn::Type TypeSelector::currentType() const { return indexToType[getSelectedOption()]; }
37 
39  for (std::size_t i = 0; i < typeCount; ++i) {
40  if (type == indexToType[i]) {
41  setSelectedOption(i);
42  return;
43  }
44  }
45  BL_LOG_WARN << "Received bad peoplemon type: " << type;
46  setSelectedOption(0);
47 }
48 
49 } // namespace component
50 } // namespace editor
Type
Represents a type that a move or Peoplemon can be. Types may be combined.
Definition: Type.hpp:18
All classes and functionality used for implementing the game editor.
Definition: Tile.hpp:11
Wrapper around ComboBox for Peoplemon types.
void setCurrentType(core::pplmn::Type type)
Sets the currently selected type.
static Ptr create()
Create a new TypeSelector.
core::pplmn::Type currentType() const
Returns the type that is currently selected.
std::shared_ptr< TypeSelector > Ptr
Pointer to a TypeSelector component.