Peoplemon  0.1.0
Peoplemon 3 game source documentation
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
game::menu::StoreItemRow Class Reference

Menu item for an item in the store. Does both sellable and for-sale items. More...

#include <StoreItemRow.hpp>

+ Inheritance diagram for game::menu::StoreItemRow:

Public Types

using Ptr = std::shared_ptr< StoreItemRow >
 Pointer to the menu item. More...
 

Public Member Functions

virtual ~StoreItemRow ()=default
 Destroy the Store Item Row object. More...
 
void updateQty (int qty)
 Updates the text for how many items can be sold. More...
 
virtual glm::vec2 getSize () const override
 Returns the size that the row takes up. More...
 
core::item::Id getItem () const
 Returns the item that this row represents. More...
 

Static Public Member Functions

static Ptr create (int qty, core::item::Id item, int price)
 Creates a new menu item in sell mode. More...
 
static Ptr create (core::item::Id item, int price)
 Creates a new menu item in buy mode. More...
 

Static Public Attributes

static constexpr float Height = 18.f
 Height of a single item in pixels. More...
 

Protected Member Functions

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 return the transform to use. More...
 
virtual void doSceneAdd (bl::rc::Scene *overlay) override
 Called when the item should be added to the overlay. More...
 
virtual void doSceneRemove () override
 Called when the item should be removed from the overlay. More...
 
virtual bl::ecs::Entity getEntity () const override
 Returns the entity (or top level entity) of the item. More...
 
virtual void draw (bl::rc::scene::CodeScene::RenderContext &ctx) override
 Renders the item. More...
 

Detailed Description

Menu item for an item in the store. Does both sellable and for-sale items.

Definition at line 18 of file StoreItemRow.hpp.

Member Typedef Documentation

◆ Ptr

using game::menu::StoreItemRow::Ptr = std::shared_ptr<StoreItemRow>

Pointer to the menu item.

Definition at line 21 of file StoreItemRow.hpp.

Constructor & Destructor Documentation

◆ ~StoreItemRow()

virtual game::menu::StoreItemRow::~StoreItemRow ( )
virtualdefault

Destroy the Store Item Row object.

Member Function Documentation

◆ create() [1/2]

StoreItemRow::Ptr game::menu::StoreItemRow::create ( core::item::Id  item,
int  price 
)
static

Creates a new menu item in buy mode.

Parameters
itemThe item to buy
priceThe purchase price
Returns
Ptr The new menu item

Definition at line 22 of file StoreItemRow.cpp.

◆ create() [2/2]

StoreItemRow::Ptr game::menu::StoreItemRow::create ( int  qty,
core::item::Id  item,
int  price 
)
static

Creates a new menu item in sell mode.

Parameters
qtyThe number of items available to be sold
itemThe item to sell
priceThe sale price
Returns
Ptr The new menu item

Definition at line 18 of file StoreItemRow.cpp.

◆ doCreate()

void game::menu::StoreItemRow::doCreate ( bl::engine::Engine &  engine)
overrideprotectedvirtual

Called at least once when the item is added to a menu. Should create required graphics primitives and return the transform to use.

Parameters
engineThe game engine instance

Definition at line 39 of file StoreItemRow.cpp.

◆ doSceneAdd()

void game::menu::StoreItemRow::doSceneAdd ( bl::rc::Scene *  overlay)
overrideprotectedvirtual

Called when the item should be added to the overlay.

Parameters
overlayThe overlay to add to

Definition at line 69 of file StoreItemRow.cpp.

◆ doSceneRemove()

void game::menu::StoreItemRow::doSceneRemove ( )
overrideprotectedvirtual

Called when the item should be removed from the overlay.

Definition at line 75 of file StoreItemRow.cpp.

◆ draw()

void game::menu::StoreItemRow::draw ( bl::rc::scene::CodeScene::RenderContext &  ctx)
overrideprotectedvirtual

Renders the item.

Parameters
ctxThe render context

Definition at line 83 of file StoreItemRow.cpp.

◆ getEntity()

bl::ecs::Entity game::menu::StoreItemRow::getEntity ( ) const
overrideprotectedvirtual

Returns the entity (or top level entity) of the item.

Definition at line 81 of file StoreItemRow.cpp.

◆ getItem()

core::item::Id game::menu::StoreItemRow::getItem ( ) const

Returns the item that this row represents.

Definition at line 37 of file StoreItemRow.cpp.

◆ getSize()

glm::vec2 game::menu::StoreItemRow::getSize ( ) const
overridevirtual

Returns the size that the row takes up.

Definition at line 35 of file StoreItemRow.cpp.

◆ updateQty()

void game::menu::StoreItemRow::updateQty ( int  qty)

Updates the text for how many items can be sold.

Parameters
qtyThe number of items left in the bag

Definition at line 31 of file StoreItemRow.cpp.

Member Data Documentation

◆ Height

constexpr float game::menu::StoreItemRow::Height = 18.f
staticconstexpr

Height of a single item in pixels.

Definition at line 24 of file StoreItemRow.hpp.


The documentation for this class was generated from the following files: