Arcade Shooter
Public Member Functions | Protected Member Functions | Friends | List of all members
KatanaEngine::MenuItem Class Reference

Class for menu items contained in a MenuScreen. More...

#include <MenuItem.h>

Public Member Functions

 MenuItem ()
 Instantiate a menu item.
 
 MenuItem (std::string text)
 Instantiate a menu item. More...
 
virtual void Update (const GameTime *pGameTime)
 Called when the game has determined that screen logic needs to be processed. More...
 
virtual void Draw (SpriteBatch *pSpriteBatch)
 Called when the game determines it is time to draw a frame. More...
 
virtual void Select (MenuScreen *pMenuScreen)
 Called when the picks this menu option. More...
 
virtual void SetText (const std::string text)
 Sets the text of the menu item. More...
 
virtual void SetTextOffset (const Vector2 offset)
 Sets the offset from the items normal position. Usually used to animate the currently selected menu item. More...
 
virtual bool IsSelected () const
 Determines whether or not this menu item is the one that is currently selected. More...
 
virtual void SetSelected (const bool isSelected)
 Sets whether or not this menu item is the one that is currently selected. More...
 
virtual bool IsDisplayed () const
 Determines whether or not this menu item is currently displayed. More...
 
virtual void SetDisplayed (const bool isDisplayed)
 Sets whether or not this menu item is currently displayed. More...
 
virtual void SetFont (Font *pFont)
 Sets the font of the menu item. More...
 
virtual void SetPosition (const Vector2 position)
 Sets the screen position of the menu item. More...
 
virtual void SetColor (const Color color)
 Sets the color of the menu item. More...
 
virtual void SetAlpha (const float alpha)
 Sets the alpha value (opacity) of the menu item. More...
 
virtual void SetTextAlign (TextAlign textAlign)
 Sets the text alignment for the menu item. More...
 
virtual void SetMenuScreen (MenuScreen *pMenuScreen)
 Sets containing menu screen. More...
 
virtual void SetSelectCallback (OnSelect callback)
 Sets the callback function for when the menu item is selected. More...
 
virtual int GetIndex () const
 Gets the index of the menu item. More...
 

Protected Member Functions

virtual void SetIndex (const int index)
 Sets the index of the menu item. More...
 
virtual MenuScreenGetMenuScreen () const
 Gets the menu screen that contains this item. More...
 
virtual Vector2 GetPosition () const
 Gets the position of the menu item. More...
 
virtual std::string GetText () const
 Gets the text of the menu item. More...
 

Friends

class MenuScreen
 

Detailed Description

Class for menu items contained in a MenuScreen.

Constructor & Destructor Documentation

◆ MenuItem()

KatanaEngine::MenuItem::MenuItem ( std::string  text)

Instantiate a menu item.

Parameters
textThe text that the item will display.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Member Function Documentation

◆ Draw()

void KatanaEngine::MenuItem::Draw ( SpriteBatch pSpriteBatch)
virtual

Called when the game determines it is time to draw a frame.

Parameters
pSpriteBatchThe game's sprite batch, used for rendering.

◆ GetIndex()

virtual int KatanaEngine::MenuItem::GetIndex ( ) const
inlinevirtual

Gets the index of the menu item.

Returns
Returns the menu item's index.

◆ GetMenuScreen()

virtual MenuScreen* KatanaEngine::MenuItem::GetMenuScreen ( ) const
inlineprotectedvirtual

Gets the menu screen that contains this item.

Returns
Returns a pointer to the menu screen.

◆ GetPosition()

virtual Vector2 KatanaEngine::MenuItem::GetPosition ( ) const
inlineprotectedvirtual

Gets the position of the menu item.

Returns
Returns the menu item's position on the screen.

◆ GetText()

virtual std::string KatanaEngine::MenuItem::GetText ( ) const
inlineprotectedvirtual

Gets the text of the menu item.

Returns
Returns the menu item's text.

◆ IsDisplayed()

virtual bool KatanaEngine::MenuItem::IsDisplayed ( ) const
inlinevirtual

Determines whether or not this menu item is currently displayed.

Returns
Returns true if this item is currently displayed, false otherwise.

◆ IsSelected()

virtual bool KatanaEngine::MenuItem::IsSelected ( ) const
inlinevirtual

Determines whether or not this menu item is the one that is currently selected.

Returns
Returns true if this item is the currently selected one, false otherwise.

◆ Select()

void KatanaEngine::MenuItem::Select ( MenuScreen pMenuScreen)
virtual

Called when the picks this menu option.

Parameters
pMenuScreenA pointer to the menu screen.

◆ SetAlpha()

virtual void KatanaEngine::MenuItem::SetAlpha ( const float  alpha)
inlinevirtual

Sets the alpha value (opacity) of the menu item.

Parameters
alphaThe alpha value.

◆ SetColor()

virtual void KatanaEngine::MenuItem::SetColor ( const Color  color)
inlinevirtual

Sets the color of the menu item.

Parameters
colorThe color.

◆ SetDisplayed()

virtual void KatanaEngine::MenuItem::SetDisplayed ( const bool  isDisplayed)
inlinevirtual

Sets whether or not this menu item is currently displayed.

Parameters
isDisplayedPass true to display this item, and false to hide it.

◆ SetFont()

virtual void KatanaEngine::MenuItem::SetFont ( Font pFont)
inlinevirtual

Sets the font of the menu item.

Parameters
pFontA pointer to the font.

◆ SetIndex()

virtual void KatanaEngine::MenuItem::SetIndex ( const int  index)
inlineprotectedvirtual

Sets the index of the menu item.

Parameters
indexThe index value.

◆ SetMenuScreen()

virtual void KatanaEngine::MenuItem::SetMenuScreen ( MenuScreen pMenuScreen)
inlinevirtual

Sets containing menu screen.

Parameters
pMenuScreenA pointer to the menu screen.
Remarks
This should not be called manually. It is called automatically when an item is added to a menu screen via MenuScreen::AddMenuItem().
See also
MenuScreen::AddMenuItem()

◆ SetPosition()

virtual void KatanaEngine::MenuItem::SetPosition ( const Vector2  position)
inlinevirtual

Sets the screen position of the menu item.

Parameters
positionThe new position.

◆ SetSelectCallback()

virtual void KatanaEngine::MenuItem::SetSelectCallback ( OnSelect  callback)
inlinevirtual

Sets the callback function for when the menu item is selected.

Parameters
callbackThe callback function.

◆ SetSelected()

virtual void KatanaEngine::MenuItem::SetSelected ( const bool  isSelected)
inlinevirtual

Sets whether or not this menu item is the one that is currently selected.

Parameters
isSelectedPass true to make this item the selected one, and false to when you no longer want it selected.

◆ SetText()

virtual void KatanaEngine::MenuItem::SetText ( const std::string  text)
inlinevirtual

Sets the text of the menu item.

Parameters
textThe text.

◆ SetTextAlign()

virtual void KatanaEngine::MenuItem::SetTextAlign ( TextAlign  textAlign)
inlinevirtual

Sets the text alignment for the menu item.

Parameters
textAlignThe text alignment.

◆ SetTextOffset()

virtual void KatanaEngine::MenuItem::SetTextOffset ( const Vector2  offset)
inlinevirtual

Sets the offset from the items normal position. Usually used to animate the currently selected menu item.

Parameters
offsetThe offset.

◆ Update()

virtual void KatanaEngine::MenuItem::Update ( const GameTime pGameTime)
inlinevirtual

Called when the game has determined that screen logic needs to be processed.

Parameters
pGameTimeTiming values including time since last update.

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