1 #ifndef GAME_STATES_STOREMENU_HPP
2 #define GAME_STATES_STOREMENU_HPP
4 #include <BLIB/Graphics.hpp>
5 #include <BLIB/Interfaces/Menu.hpp>
11 #include <unordered_map>
25 ,
public bl::input::Listener {
46 virtual const char*
name()
const override;
53 virtual void activate(bl::engine::Engine& engine)
override;
60 virtual void deactivate(bl::engine::Engine& engine)
override;
68 virtual void update(bl::engine::Engine& engine,
float dt,
float)
override;
77 enum struct MenuState {
90 std::vector<Item> items;
91 std::unordered_map<core::item::Id, int> sellPrices;
92 bl::audio::AudioSystem::Handle dingSound;
94 unsigned int buyingItemIndex;
99 bl::rc::res::TextureRef bgndTxtr;
100 bl::gfx::Sprite background;
102 bl::menu::Menu* renderMenu;
103 bl::menu::Menu actionMenu;
104 bl::menu::Menu buyMenu;
105 bl::menu::Menu sellMenus[3];
107 bl::gfx::Text actionText;
108 bl::gfx::Text boxText;
109 bl::gfx::Text moneyText;
110 bl::gfx::Text catText;
111 bl::gfx::Triangle leftArrow;
112 bl::gfx::Triangle rightArrow;
116 void enterState(MenuState state);
117 void setBoxText(
const std::string& text);
122 void selectBuyItem(
unsigned int i);
130 virtual bool observe(
const bl::input::Actor&,
unsigned int activatedControl,
131 bl::input::DispatchType,
bool eventTriggered)
override;
133 bl::menu::Item::Ptr makeItemRow(
core::item::Id item,
int price,
unsigned int i);
134 bl::menu::Item::Ptr makeSellItemRow(
core::item::Id item,
int qty);
135 bl::menu::Item::Ptr makeCloseItem();
bl::menu::TriggerDriver< Control::MoveUp, Control::MoveRight, Control::MoveDown, Control::MoveLeft, Control::Interact > MenuDriver
Helper typedef for Peoplemon specific menu driving.
Id
Represents an item in its simplist form.
Parent namespace for all functionality unique to the game.
Event that is fired by the Core module to signal to the game to open a store.
Helper class to render a number selector.
Owns all primary systems and a reference to the engine.
Menu item for an item in the store. Does both sellable and for-sale items.
Parent to all game states. Provides some commonly required data like core game systems.
core::system::Systems & systems
State that renders and implements a store menu to buy and sell items.
virtual ~StoreMenu()=default
Destroy the Store State object.
virtual void activate(bl::engine::Engine &engine) override
Subscribes to event buses.
virtual void deactivate(bl::engine::Engine &engine) override
Unsubscribes from event buses.
virtual void update(bl::engine::Engine &engine, float dt, float) override
Updates the store menu.
virtual const char * name() const override
Returns "StoreMenu".
static bl::engine::State::Ptr create(core::system::Systems &systems, const core::event::StoreOpened &data)
Create a new StoreMenu.