Peoplemon  0.1.0
Peoplemon 3 game source documentation
StorageSystem.hpp
Go to the documentation of this file.
1 #ifndef GAME_STATES_STORAGESYSTEM_HPP
2 #define GAME_STATES_STORAGESYSTEM_HPP
3 
4 #include <BLIB/Interfaces/Menu.hpp>
8 #include <Game/States/State.hpp>
9 
10 namespace game
11 {
12 namespace state
13 {
20 : public State
21 , public bl::input::Listener {
22 public:
29  static bl::engine::State::Ptr create(core::system::Systems& systems);
30 
34  virtual ~StorageSystem() = default;
35 
39  virtual const char* name() const override;
40 
46  virtual void activate(bl::engine::Engine& engine) override;
47 
53  virtual void deactivate(bl::engine::Engine& engine) override;
54 
61  virtual void update(bl::engine::Engine& engine, float dt, float) override;
62 
63 private:
64  enum struct MenuState {
65  // entry states
66  ChooseAction,
67  PlacingPeoplemon,
68  WaitingHudMessage,
69 
70  // browse states
71  BrowsingBox,
72  BoxSliding,
73  CursorMoving,
74 
75  // context menu states
76  BrowseMenuOpen,
77  MovingPeoplemon,
78  WaitingContextMessage,
79  WaitingReleaseConfirm,
80 
81  // Waiting on other states
82  WaitingDeposit
83  };
84 
85  MenuState state;
86  MenuState prevState;
87  int currentBox;
89  sf::Vector2i selectPos;
90  bool closeMenuAfterMessage;
91  bl::rc::Scene* overlay;
92 
93  bl::rc::res::TextureRef backgroundTxtr;
94  bl::gfx::Sprite background;
95 
96  core::input::MenuDriver menuDriver;
97  menu::StorageGrid grids[2];
98  menu::StorageGrid* activeGrid;
99  menu::StorageGrid* slidingOutGrid;
100  menu::StorageCursor cursor;
101  float slideOffset;
102  float slideVel;
103 
104  bl::audio::AudioSystem::Handle cursorMoveSound;
105  bl::audio::AudioSystem::Handle pageSlideSound;
106  bl::audio::AudioSystem::Handle pageSlideFailSound;
107 
108  bl::rc::res::TextureRef leftArrowTxtr;
109  bl::rc::res::TextureRef rightArrowTxtr;
110  bl::gfx::Sprite leftArrow;
111  bl::gfx::Sprite rightArrow;
112  bl::gfx::Text boxTitle;
113 
114  bl::rc::res::TextureRef thumbTxtr;
115  bl::gfx::Sprite thumbnail;
116  bl::gfx::Text nickname;
117  bl::gfx::Text level;
118  bl::gfx::Text itemLabel;
119 
120  bl::menu::Menu actionMenu;
121  bl::menu::Item::Ptr withdrawActionItem;
122  bl::menu::Menu contextMenu;
123 
124  int depositedPeoplemon;
125  sf::Vector2i ogMovePos;
126 
128 
129  // entry actions
130  void startDeposit();
131  void startBrowse();
132  void close();
133 
134  // browse actions
135  void onCursor(const sf::Vector2i& pos);
136  void onHover(core::pplmn::StoredPeoplemon* peoplemon);
137  void onSelect(const sf::Vector2i& position);
138  void boxLeft();
139  void boxRight();
140 
141  // context actions
142  void onWithdraw();
143  void onStartMove();
144  void onTakeItem();
145  void onRelease();
146  void onCloseContextMenu();
147 
148  virtual bool observe(const bl::input::Actor&, unsigned int activatedControl,
149  bl::input::DispatchType, bool eventTriggered) override;
150 
151  void enterState(MenuState state);
152  void finishBoxChange();
153  void onReleaseConfirm(const std::string& choice);
154  void onMessageDone();
155  void updatePeoplemonInfo(const core::pplmn::OwnedPeoplemon& ppl);
156  void showPeoplemonInfo(bool show);
157  void updateThumbnail(const std::string& src);
158  void showContextMessage(const std::string& msg, bool closeMenu = true);
159  void positionContextMenu();
160 };
161 
162 } // namespace state
163 } // namespace game
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
Parent namespace for all functionality unique to the game.
Represents an instance of a peoplemon. Can be a wild peoplemon, trainer, or player peoplemon....
Represents a Peoplemon in storage.
Owns all primary systems and a reference to the engine.
Definition: Systems.hpp:47
Cursor that is used to navigate the storage system boxes.
Renderer for the grid of peoplemon in a storage box.
Definition: StorageGrid.hpp:20
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
Game state for the peoplemon storage system menu.
virtual ~StorageSystem()=default
Destroy the Storage System object.
virtual const char * name() const override
Returns "StorageSystem".
virtual void update(bl::engine::Engine &engine, float dt, float) override
Updates the menu state.
virtual void activate(bl::engine::Engine &engine) override
Initializes the menu and subscribes to event buses.
virtual void deactivate(bl::engine::Engine &engine) override
Unsubscribes from event buses and fires a StorageSystemClosed event.
static bl::engine::State::Ptr create(core::system::Systems &systems)
Create a new storage system menu.