Peoplemon  0.1.0
Peoplemon 3 game source documentation
PlayerMenu.hpp
Go to the documentation of this file.
1 #ifndef CORE_BATTLES_VIEW_PLAYERMENU_HPP
2 #define CORE_BATTLES_VIEW_PLAYERMENU_HPP
3 
4 #include <BLIB/Events.hpp>
5 #include <BLIB/Graphics.hpp>
6 #include <BLIB/Interfaces/Menu.hpp>
7 #include <BLIB/Render/Scenes/CodeScene.hpp>
8 #include <BLIB/Resources.hpp>
12 #include <Core/Items/Id.hpp>
16 
17 namespace core
18 {
19 namespace battle
20 {
21 namespace view
22 {
29 class PlayerMenu {
30 public:
37  PlayerMenu(bl::engine::Engine& engine, bool canRun);
38 
44  void init(bl::rc::scene::CodeScene* scene);
45 
49  void refresh();
50 
57  void setPeoplemon(int i, const pplmn::BattlePeoplemon& ppl);
58 
62  void beginTurn();
63 
70  void choosePeoplemonMidTurn(bool fromFaint, bool fromRevive);
71 
75  void chooseMoveToForget();
76 
80  bool ready() const;
81 
85  TurnAction selectedAction() const;
86 
90  int selectedMove() const;
91 
95  item::Id selectedItem() const;
96 
100  int selectedPeoplemon() const;
101 
108  void handleInput(input::EntityControl input, bool ignoreDebounce);
109 
115  void render(bl::rc::scene::CodeScene::RenderContext& ctx);
116 
117 private:
118  enum struct State {
119  Hidden,
120  PickingAction,
121  PickingMove,
122  PickingItem,
123  PickingPeoplemon,
124  ChoosingMoveToForget
125  };
126 
127  bl::engine::Engine& engine;
128  const bool canRun;
129  State state;
130  bool stateLoopGuard;
131  input::MenuDriver menuDriver;
132  TurnAction chosenAction;
133  int chosenMoveOrPeoplemon;
134  item::Id chosenItem;
135  int currentPeoplemon;
136 
137  bl::menu::Menu actionMenu;
138  bl::menu::TextItem::Ptr fightItem;
139  bl::menu::TextItem::Ptr switchItem;
140  bl::menu::TextItem::Ptr bagItem;
141  bl::menu::TextItem::Ptr runItem;
142 
143  bl::menu::Menu moveMenu;
144  bl::menu::TextItem::Ptr moveItems[4];
145  const pplmn::OwnedMove* moves;
146 
147  bl::rc::res::TextureRef moveTxtr;
148  bl::gfx::Sprite moveBox;
149  bl::gfx::Text movePP;
150  bl::gfx::Text movePwr;
151  bl::gfx::Text moveAcc;
152 
153  void fightChosen();
154  void switchChosen();
155  void itemChosen();
156  void runChosen();
157  void moveChosen(int i);
158  void syncMove(int i);
159 };
160 
161 } // namespace view
162 } // namespace battle
163 } // namespace core
164 
165 #endif
bl::menu::TriggerDriver< Control::MoveUp, Control::MoveRight, Control::MoveDown, Control::MoveLeft, Control::Interact > MenuDriver
Helper typedef for Peoplemon specific menu driving.
Definition: MenuDriver.hpp:18
Id
Represents an item in its simplist form.
Definition: Id.hpp:24
Core classes and functionality for both the editor and game.
TurnAction
Represents an action that a battler may take on their turn.
Definition: TurnAction.hpp:16
std::underlying_type_t< Control::EntityControl > EntityControl
Helper typedef to avoid too much casting boilerplate.
Definition: Control.hpp:44
The player menu for battles.
Definition: PlayerMenu.hpp:29
void handleInput(input::EntityControl input, bool ignoreDebounce)
Processes player input to update the menu state.
Definition: PlayerMenu.cpp:198
TurnAction selectedAction() const
The selected turn action.
Definition: PlayerMenu.cpp:190
void chooseMoveToForget()
Initiates the process of choosing the move to forget.
Definition: PlayerMenu.cpp:183
int selectedPeoplemon() const
Returns the selected peoplemon index.
Definition: PlayerMenu.cpp:196
PlayerMenu(bl::engine::Engine &engine, bool canRun)
Construct a new Player Menu.
Definition: PlayerMenu.cpp:21
void setPeoplemon(int i, const pplmn::BattlePeoplemon &ppl)
Updates the menu for the given peoplemon.
Definition: PlayerMenu.cpp:93
void render(bl::rc::scene::CodeScene::RenderContext &ctx)
Renders the menu.
Definition: PlayerMenu.cpp:213
void choosePeoplemonMidTurn(bool fromFaint, bool fromRevive)
Opens the menu to select a peoplemon to send out.
Definition: PlayerMenu.cpp:159
item::Id selectedItem() const
Returns the selected item.
Definition: PlayerMenu.cpp:194
void beginTurn()
Resets the menu to the turn start state.
Definition: PlayerMenu.cpp:154
int selectedMove() const
Returns the selected move index.
Definition: PlayerMenu.cpp:192
void init(bl::rc::scene::CodeScene *scene)
Creates UI elements and adds them to the scene.
Definition: PlayerMenu.cpp:31
void refresh()
Polls state from opened peoplemon or bag menu.
Definition: PlayerMenu.cpp:132
bool ready() const
Returns true when the player's choice has been made.
Definition: PlayerMenu.cpp:188
Represents a Peoplemon in battle. Stores some extra state that only exists in battle....
Represents a move owned by a peoplemon.
Definition: OwnedMove.hpp:17