Peoplemon  0.1.0
Peoplemon 3 game source documentation
BagMenu.hpp
Go to the documentation of this file.
1 #ifndef GAME_STATES_BAGMENU_HPP
2 #define GAME_STATES_BAGMENU_HPP
3 
4 #include <BLIB/Graphics.hpp>
5 #include <BLIB/Interfaces/Menu.hpp>
6 #include <BLIB/Resources.hpp>
11 #include <Game/States/State.hpp>
12 
13 namespace game
14 {
15 namespace state
16 {
22 class BagMenu
23 : public State
24 , public bl::input::Listener {
25 public:
28 
39  static bl::engine::State::Ptr create(core::system::Systems& systems, Context ctx,
40  core::item::Id* result = nullptr, int outNow = -1,
41  int* chosenPeoplemon = nullptr, bool* unpause = nullptr);
42 
46  virtual ~BagMenu() = default;
47 
51  virtual const char* name() const override;
52 
56  virtual void activate(bl::engine::Engine&) override;
57 
61  virtual void deactivate(bl::engine::Engine&) override;
62 
68  virtual void update(bl::engine::Engine&, float dt, float) override;
69 
70 private:
71  enum struct MenuState {
72  Browsing,
73  Sliding,
74  ChoosingGive,
75  ShowingMessage,
76  ChoosingItemPeoplemon,
77  ImmediatelyPop
78  };
79 
80  const Context context;
81  const int outNow;
82  core::item::Id* const result;
83  int* itemPeoplemon;
84  bool* unpause;
85 
86  MenuState state;
87  float slideVel;
88  float slideOff;
89  bl::menu::Menu* activeMenu;
90  bl::menu::Menu* slideOut;
91 
92  bl::rc::res::TextureRef bgndTxtr;
93  bl::gfx::Sprite background;
94 
95  core::input::MenuDriver inputDriver;
96  bl::menu::Menu actionMenu;
97  bl::menu::Menu regularMenu;
98  bl::menu::Menu ballMenu;
99  bl::menu::Menu keyMenu;
100  bl::menu::Menu tmMenu;
101  bl::menu::Menu* menuTabs[4];
102  bl::gfx::Text pocketLabel;
103 
104  bl::gfx::Text description;
105  bool actionOpen;
106  menu::BagItemButton* selectedItem;
107  int selectedPeoplemon;
108 
109  BagMenu(core::system::Systems& systems, Context ctx, core::item::Id* result, int outNow,
110  int* chosenPeoplemon, bool* unpause);
111 
112  void itemHighlighted(const menu::BagItemButton* but);
113  void itemSelected(const menu::BagItemButton* but);
114  void exitSelected();
115  void beginSlide(bool left);
116  void removeAndUpdateItem(int qty);
117 
118  void useItem();
119  void giveItem();
120  void dropItem();
121  void doDrop(int qty);
122  void resetAction();
123 
124  void messageDone();
125  void keyItemConfirmUse(const std::string& choice);
126 
127  // this will only get called for inputs not processed by menus
128  virtual bool observe(const bl::input::Actor&, unsigned int activatedControl,
129  bl::input::DispatchType, bool eventTriggered) override;
130 };
131 
132 } // namespace state
133 } // namespace game
134 
135 #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
Parent namespace for all functionality unique to the game.
Context
Represents how the menu should be opened.
Definition: BagMenu.hpp:18
Owns all primary systems and a reference to the engine.
Definition: Systems.hpp:47
Represents a button for a quantity of items in the bag.
State for displaying the player's inventory and selecting items.
Definition: BagMenu.hpp:24
virtual ~BagMenu()=default
Destroy the Bag Menu object.
static bl::engine::State::Ptr create(core::system::Systems &systems, Context ctx, core::item::Id *result=nullptr, int outNow=-1, int *chosenPeoplemon=nullptr, bool *unpause=nullptr)
Creates a new BagMenu.
Definition: BagMenu.cpp:73
virtual void activate(bl::engine::Engine &) override
Populates the menu with the player's inventory.
Definition: BagMenu.cpp:172
virtual const char * name() const override
Returns "BagMenu".
Definition: BagMenu.cpp:170
core::event::OpenBagMenu::Context Context
Represents how the menu was opened and affects how it may be used.
Definition: BagMenu.hpp:27
virtual void update(bl::engine::Engine &, float dt, float) override
Updates the menu.
Definition: BagMenu.cpp:247
virtual void deactivate(bl::engine::Engine &) override
Unsubscribes from event and input buses.
Definition: BagMenu.cpp:242
Parent to all game states. Provides some commonly required data like core game systems.
Definition: State.hpp:29
core::system::Systems & systems
Definition: State.hpp:66