Peoplemon  0.1.0
Peoplemon 3 game source documentation
MoveInfoRow.cpp
Go to the documentation of this file.
2 
4 #include <Core/Properties.hpp>
5 #include <Core/Resources.hpp>
6 
7 namespace game
8 {
9 namespace menu
10 {
11 bl::menu::Item::Ptr MoveInfoRow::create(core::pplmn::MoveId move) {
12  return Ptr(new MoveInfoRow(move));
13 }
14 
15 MoveInfoRow::MoveInfoRow(core::pplmn::MoveId move)
16 : move(move) {
17  getSignal(Selected).willAlwaysCall(std::bind(&MoveInfoRow::makeActive, this));
18  getSignal(Deselected).willAlwaysCall(std::bind(&MoveInfoRow::makeInactive, this));
19 }
20 
21 glm::vec2 MoveInfoRow::getSize() const { return bgndTxtr->size(); }
22 
23 void MoveInfoRow::doCreate(bl::engine::Engine& engine) {
24  const auto& joinPath = bl::util::FileUtil::joinPath;
25  const std::string ImgPath = joinPath(core::Properties::MenuImagePath(), "PplInfo");
26 
27  bgndTxtr = engine.renderer().texturePool().getOrLoadTexture(joinPath(ImgPath, "move.png"));
28  activeBgndTxtr =
29  engine.renderer().texturePool().getOrLoadTexture(joinPath(ImgPath, "moveActive.png"));
30  background.create(engine, bgndTxtr);
31 
32  name.create(engine,
35  26,
36  bl::sfcol(sf::Color(30, 50, 65)));
37  name.getTransform().setPosition(getSize() * 0.5f);
38  name.getTransform().setOrigin(name.getLocalBounds().width * 0.5f,
39  name.getLocalBounds().height * 0.5f);
40  name.setParent(background);
41 }
42 
43 void MoveInfoRow::doSceneAdd(bl::rc::Scene* overlay) {
44  background.addToScene(overlay, bl::rc::UpdateSpeed::Static);
45  name.addToScene(overlay, bl::rc::UpdateSpeed::Static);
46 }
47 
48 void MoveInfoRow::doSceneRemove() { background.removeFromScene(); }
49 
50 bl::ecs::Entity MoveInfoRow::getEntity() const { return background.entity(); }
51 
52 void MoveInfoRow::makeActive() { background.setTexture(activeBgndTxtr); }
53 
54 void MoveInfoRow::makeInactive() { background.setTexture(bgndTxtr); }
55 
56 void MoveInfoRow::draw(bl::rc::scene::CodeScene::RenderContext& ctx) {
57  background.draw(ctx);
58  name.draw(ctx);
59 }
60 
61 } // namespace menu
62 } // namespace game
MoveId
The id of a move.
Definition: MoveId.hpp:16
Parent namespace for all functionality unique to the game.
static const std::string & name(MoveId move)
Returns the name of the given move.
Definition: Move.cpp:71
static const sf::VulkanFont & MenuFont()
Definition: Properties.cpp:363
static const std::string & MenuImagePath()
Definition: Properties.cpp:303
Menu row item for moves on the peoplemon info screen.
Definition: MoveInfoRow.hpp:17
virtual void doSceneRemove() override
Called when the item should be removed from the overlay.
Definition: MoveInfoRow.cpp:48
virtual void doSceneAdd(bl::rc::Scene *overlay) override
Called when the item should be added to the overlay.
Definition: MoveInfoRow.cpp:43
virtual glm::vec2 getSize() const override
Returns the size of the menu item.
Definition: MoveInfoRow.cpp:21
static bl::menu::Item::Ptr create(core::pplmn::MoveId move)
Create a new move row.
Definition: MoveInfoRow.cpp:11
virtual void draw(bl::rc::scene::CodeScene::RenderContext &ctx) override
Renders the item.
Definition: MoveInfoRow.cpp:56
virtual bl::ecs::Entity getEntity() const override
Returns the entity (or top level entity) of the item.
Definition: MoveInfoRow.cpp:50
virtual void doCreate(bl::engine::Engine &engine) override
Called at least once when the item is added to a menu. Should create required graphics primitives and...
Definition: MoveInfoRow.cpp:23