Peoplemon  0.1.0
Peoplemon 3 game source documentation
LevelTransitions.cpp
Go to the documentation of this file.
2 
3 #include <BLIB/Interfaces/Utilities.hpp>
4 #include <Core/Properties.hpp>
5 #include <Core/Resources.hpp>
7 
8 namespace editor
9 {
10 namespace page
11 {
13 using namespace bl::gui;
14 namespace
15 {
16 const std::pair<std::string, LevelTransition> source[] = {
17  {"EditorResources/LevelTransitions/horUpLeft.png", LevelTransition::HorizontalRightDown},
18  {"EditorResources/LevelTransitions/horUpRight.png", LevelTransition::HorizontalRightUp},
19  {"EditorResources/LevelTransitions/vertUpDown.png", LevelTransition::VerticalTopDown},
20  {"EditorResources/LevelTransitions/vertUpUp.png", LevelTransition::VerticalTopUp}};
21 const std::size_t sourceN = std::size(source);
22 } // namespace
23 
25  content = Box::create(LinePacker::create(LinePacker::Vertical, 8.f));
26 
27  Label::Ptr help =
28  Label::create("Walking in the direction of the arrow on a transition makes the "
29  "player go up a level. Walking opposite the arrow makes the player "
30  "go down a level. Walking perpendicular has no effect.");
31  help->setTextWrapping(bl::gui::Label::WrapToAcquisition);
32  content->pack(help, true, false);
33 
34  RadioButton::Ptr noneBut = RadioButton::create("Flat", "flat");
35  noneBut->getSignal(Event::LeftClicked)
36  .willAlwaysCall(std::bind(&LevelTransitions::update, this, LevelTransition::None));
37  content->pack(noneBut);
38 
39  Box::Ptr row = Box::create(LinePacker::create(LinePacker::Horizontal, 4));
40  row->setHorizontalAlignment(RenderSettings::Left);
41 
42  RadioButton::Group* group = noneBut->getRadioGroup();
43  for (unsigned int i = 0; i < sourceN; ++i) {
44  const auto& pair = source[i];
45  auto txtr = ImageManager::load(pair.first);
46  Image::Ptr img = Image::create(txtr);
47  img->scaleToSize({64, 64});
50  but->getSignal(Event::LeftClicked)
51  .willAlwaysCall(std::bind(&LevelTransitions::update, this, pair.second));
52  row->pack(but, false, true);
53  if (i == 1) {
54  content->pack(row, true, false);
55  row = Box::create(LinePacker::create(LinePacker::Horizontal, 4));
56  row->setHorizontalAlignment(RenderSettings::Left);
57  }
58  }
59  content->pack(row, true, false);
60 }
61 
62 Element::Ptr LevelTransitions::getContent() { return content; }
63 
64 LevelTransition LevelTransitions::getActive() const { return active; }
65 
66 void LevelTransitions::update(LevelTransition lt) { active = lt; }
67 
68 } // namespace page
69 } // namespace editor
LevelTransition
Represents a level transition in a map. Level transitions are applied when an entity moves either ont...
All classes and functionality used for implementing the game editor.
Definition: Tile.hpp:11
static Ptr create(bl::gui::Element::Ptr child, bl::gui::RadioButton::Group *group=nullptr)
Creates a new HighlightRadioButton.
std::shared_ptr< HighlightRadioButton > Ptr
Pointer to a HighlightRadioButton.
LevelTransitions()
Construct a new Level Transitions GUI page.
core::map::LevelTransition getActive() const
Returns the currently selected level transition type.
bl::gui::Element::Ptr getContent()
Returns a packable GUI element to add this page to the GUI.