GuiGameListMenuCtrl Class Reference

#include <guiGameListMenuCtrl.h>

Inheritance diagram for GuiGameListMenuCtrl:

Inheritance graph
[legend]
List of all members.

Detailed Description

A base class for cross platform menu controls that are gamepad friendly.


Public Types

typedef GuiControl Parent
typedef GuiGameListMenuProfile Profile

Public Member Functions

virtual S32 getHighlighted () const
virtual S32 getSelected () const
virtual void setSelected (S32 index)
 Sets the selected row.
virtual bool isRowEnabled (S32 index) const
 Determines if the specified row is enabled or disabled.
virtual void setRowEnabled (S32 index, bool enabled)
 Sets a row's enabled status according to the given parameters.
virtual StringTableEntry getRowLabel (S32 rowIndex) const
 Gets the label displayed on the specified row.
virtual void setRowLabel (S32 rowIndex, const char *label)
 Sets the label on the given row.
virtual void addRow (const char *label, const char *callback, S32 icon=-1, S32 yPad=0, bool useHighlightIcon=true, bool enabled=true)
 Adds a row to the control.
virtual void activateRow ()
 Activates the current row.
virtual S32 getRowCount () const
 Gets the number of rows in the control.
 GuiGameListMenuCtrl ()
 ~GuiGameListMenuCtrl ()
void onRender (Point2I offset, const RectI &updateRect)
 Called when this control is to render itself.
bool onAdd ()
 Callback when the object is registered with the sim.
bool onWake ()
 Callback when the control wakes up.
bool onKeyDown (const GuiEvent &event)
 Callback when a key is pressed.
bool onKeyRepeat (const GuiEvent &event)
 Callback when a key is repeating.
void onMouseDown (const GuiEvent &event)
 Callback when the mouse button is clicked on the control.
void onMouseDragged (const GuiEvent &event)
 Callback when the mouse is dragged on the control.
void onMouseLeave (const GuiEvent &event)
 Callback when the mouse leaves the control.
void onMouseMove (const GuiEvent &event)
 Callback when the mouse is moving over this control.
void onMouseUp (const GuiEvent &event)
 Callback when the mouse button is released.
virtual bool onGamepadAxisUp (const GuiEvent &event)
 Callback when the gamepad axis is activated.
virtual bool onGamepadAxisDown (const GuiEvent &event)
 Callback when the gamepad axis is activated.
 DECLARE_CONOBJECT (GuiGameListMenuCtrl)

Static Public Member Functions

static void initPersistFields ()
 Initializes fields accessible through the console.

Static Public Attributes

static const S32 NO_ROW = -1
 Indicates a query result of no row found.
static const S32 NO_ICON = -1
 Indicates a row has no extra icon available.

Protected Member Functions

virtual void addRow (Row *row, const char *label, const char *callback, S32 icon, S32 yPad, bool useHighlightIcon, bool enabled)
 Adds a row to the control.
virtual bool isValidRowIndex (S32 index) const
 Determines if the given index is a valid row index.
virtual void setThisControl ()
 Sets the script variable $ThisControl to reflect this control.
virtual void onDebugRender (Point2I offset)
 Called to implement debug rendering which displays colored lines to provide visual feedback on extents and hit zones.
virtual S32 getRow (Point2I globalPoint)
 Looks up the row having a hit area at the given global point.
virtual bool hasValidProfile () const
 Checks to make sure our control has a profile of the correct type.
virtual void enforceConstraints ()
 Enforces the validity of the fields on this control and its profile (if the profile is valid, see: hasValidProfile).
void doScriptCommand (StringTableEntry command)
 Evaluates some script.

Protected Attributes

StringTableEntry mCallbackOnA
 Script callback when the 'A' button is pressed.
StringTableEntry mCallbackOnB
 Script callback when the 'B' button is pressed.
StringTableEntry mCallbackOnX
 Script callback when the 'X' button is pressed.
StringTableEntry mCallbackOnY
 Script callback when the 'Y' button is pressed.
bool mDebugRender
 Determines when to show debug render lines.
Vector< Row * > mRows
 Holds data wrappers on all the rows we have.

Private Member Functions

virtual Point2I getMinExtent () const
 Recalculates the height of this control based on the stored row height and and padding on the rows.
void updateHeight ()
 Makes sure the height will allow all rows to be displayed without being truncated.
void selectFirstEnabledRow ()
 Sets the first enabled row as selected.
void changeRow (S32 delta)
 Changes the currently selected row.

Private Attributes

S32 mSelected
 index of the currently selected row
S32 mHighlighted
 index of the currently highlighted row

Classes

struct  Row
 Internal data representation of a single row in the control. More...


Member Typedef Documentation

Reimplemented from GuiControl.

Reimplemented in GuiGameListOptionsCtrl.


Constructor & Destructor Documentation

GuiGameListMenuCtrl::GuiGameListMenuCtrl (  ) 

GuiGameListMenuCtrl::~GuiGameListMenuCtrl (  ) 


Member Function Documentation

virtual S32 GuiGameListMenuCtrl::getHighlighted (  )  const [inline, virtual]

Returns:
The index of the highlighted row or NO_ROW if none of the rows are currently highlighted.

virtual S32 GuiGameListMenuCtrl::getSelected (  )  const [inline, virtual]

Returns:
The index of the selected row or NO_ROW if none of the rows are currently selected.

virtual void GuiGameListMenuCtrl::setSelected ( S32  index  )  [virtual]

Sets the selected row.

Only rows that are enabled can be selected. Input is clamped to [0, mRows.size())

Parameters:
index The index to set as selected.

virtual bool GuiGameListMenuCtrl::isRowEnabled ( S32  index  )  const [virtual]

Determines if the specified row is enabled or disabled.

Parameters:
index Index of the row to check.
Returns:
True if the specified row is enabled. False if the row is not enabled or the given index was not valid.

virtual void GuiGameListMenuCtrl::setRowEnabled ( S32  index,
bool  enabled 
) [virtual]

Sets a row's enabled status according to the given parameters.

Parameters:
index The row to set the enabled status of.
enabled Indicate true to enable the row or false to disable it.

virtual StringTableEntry GuiGameListMenuCtrl::getRowLabel ( S32  rowIndex  )  const [virtual]

Gets the label displayed on the specified row.

Parameters:
rowIndex Index of the row to get the label of.
Returns:
The label for the row.

virtual void GuiGameListMenuCtrl::setRowLabel ( S32  rowIndex,
const char *  label 
) [virtual]

Sets the label on the given row.

Parameters:
rowIndex Index of the row to set the label on.
label Text to set as the label of the row.

virtual void GuiGameListMenuCtrl::addRow ( const char *  label,
const char *  callback,
S32  icon = -1,
S32  yPad = 0,
bool  useHighlightIcon = true,
bool  enabled = true 
) [virtual]

Adds a row to the control.

Parameters:
label The text to display on the row as a label.
callback Name of a script function to use as a callback when this row is activated.
icon [optional] Index of the icon to use as a marker. Default -1 means no icon will be shown on this row.
yPad [optional] An extra amount of height padding before the row.
enabled [optional] If this row is initially enabled. Default true.

virtual void GuiGameListMenuCtrl::activateRow (  )  [virtual]

Activates the current row.

The script callback of the current row will be called (if it has one).

virtual S32 GuiGameListMenuCtrl::getRowCount (  )  const [inline, virtual]

Gets the number of rows in the control.

Returns:
The number of rows in this control.

void GuiGameListMenuCtrl::onRender ( Point2I  offset,
const RectI updateRect 
) [virtual]

Called when this control is to render itself.

Parameters:
offset The location this control is to begin rendering
updateRect The screen area this control has drawing access to

Reimplemented from GuiControl.

Reimplemented in GuiGameListOptionsCtrl.

bool GuiGameListMenuCtrl::onAdd (  )  [virtual]

Callback when the object is registered with the sim.

Returns:
True if the profile was successfully added, false otherwise.

Reimplemented from GuiControl.

bool GuiGameListMenuCtrl::onWake (  )  [virtual]

Callback when the control wakes up.

Reimplemented from GuiControl.

bool GuiGameListMenuCtrl::onKeyDown ( const GuiEvent event  )  [virtual]

Callback when a key is pressed.

Parameters:
event The event that triggered this callback.

Reimplemented from GuiControl.

Reimplemented in GuiGameListOptionsCtrl.

bool GuiGameListMenuCtrl::onKeyRepeat ( const GuiEvent event  )  [inline, virtual]

Callback when a key is repeating.

Parameters:
event The event that triggered this callback.

Reimplemented from GuiControl.

Reimplemented in GuiGameListOptionsCtrl.

void GuiGameListMenuCtrl::onMouseDown ( const GuiEvent event  )  [virtual]

Callback when the mouse button is clicked on the control.

Parameters:
event A reference to the event that triggered the callback.

Reimplemented from GuiControl.

void GuiGameListMenuCtrl::onMouseDragged ( const GuiEvent event  )  [inline, virtual]

Callback when the mouse is dragged on the control.

Parameters:
event A reference to the event that triggered the callback.

Reimplemented from GuiControl.

void GuiGameListMenuCtrl::onMouseLeave ( const GuiEvent event  )  [virtual]

Callback when the mouse leaves the control.

Parameters:
event A reference to the event that triggered the callback.

Reimplemented from GuiControl.

void GuiGameListMenuCtrl::onMouseMove ( const GuiEvent event  )  [virtual]

Callback when the mouse is moving over this control.

Parameters:
event A reference to the event that triggered the callback.

Reimplemented from GuiControl.

void GuiGameListMenuCtrl::onMouseUp ( const GuiEvent event  )  [virtual]

Callback when the mouse button is released.

Parameters:
event A reference to the event that triggered the callback.

Reimplemented from GuiControl.

Reimplemented in GuiGameListOptionsCtrl.

virtual bool GuiGameListMenuCtrl::onGamepadAxisUp ( const GuiEvent event  )  [virtual]

Callback when the gamepad axis is activated.

Parameters:
event A reference to the event that triggered the callback.

Reimplemented from GuiControl.

virtual bool GuiGameListMenuCtrl::onGamepadAxisDown ( const GuiEvent event  )  [virtual]

Callback when the gamepad axis is activated.

Parameters:
event A reference to the event that triggered the callback.

Reimplemented from GuiControl.

GuiGameListMenuCtrl::DECLARE_CONOBJECT ( GuiGameListMenuCtrl   ) 

static void GuiGameListMenuCtrl::initPersistFields (  )  [static]

Initializes fields accessible through the console.

Reimplemented from GuiControl.

Reimplemented in GuiGameListOptionsCtrl.

virtual void GuiGameListMenuCtrl::addRow ( Row row,
const char *  label,
const char *  callback,
S32  icon,
S32  yPad,
bool  useHighlightIcon,
bool  enabled 
) [protected, virtual]

Adds a row to the control.

Parameters:
row A reference to the row object to fill.
label The text to display on the row as a label.
callback Name of a script function to use as a callback when this row is activated.
icon [optional] Index of the icon to use as a marker. Default -1 means no icon will be shown on this row.
yPad [optional] An extra amount of height padding before the row.
enabled [optional] If this row is initially enabled. Default true.

virtual bool GuiGameListMenuCtrl::isValidRowIndex ( S32  index  )  const [protected, virtual]

Determines if the given index is a valid row index.

Any index pointing at an existing row is valid.

Parameters:
index The index to check for validity.
Returns:
True if the index points at a valid row, false otherwise.

virtual void GuiGameListMenuCtrl::setThisControl (  )  [protected, virtual]

Sets the script variable $ThisControl to reflect this control.

virtual void GuiGameListMenuCtrl::onDebugRender ( Point2I  offset  )  [protected, virtual]

Called to implement debug rendering which displays colored lines to provide visual feedback on extents and hit zones.

Reimplemented in GuiGameListOptionsCtrl.

virtual S32 GuiGameListMenuCtrl::getRow ( Point2I  globalPoint  )  [protected, virtual]

Looks up the row having a hit area at the given global point.

Parameters:
globalPoint The point we want to check for hitting a row.
Returns:
The index of the hit row or NO_ROW if no row was hit.

virtual bool GuiGameListMenuCtrl::hasValidProfile (  )  const [protected, virtual]

Checks to make sure our control has a profile of the correct type.

Returns:
True if the profile is of type GuiGameListMenuProfile or false if the profile is of any other type.

Reimplemented in GuiGameListOptionsCtrl.

virtual void GuiGameListMenuCtrl::enforceConstraints (  )  [protected, virtual]

Enforces the validity of the fields on this control and its profile (if the profile is valid, see: hasValidProfile).

Reimplemented in GuiGameListOptionsCtrl.

void GuiGameListMenuCtrl::doScriptCommand ( StringTableEntry  command  )  [protected]

Evaluates some script.

If the command is empty then nothing is evaluated.

Parameters:
command The script to evaluate.

virtual Point2I GuiGameListMenuCtrl::getMinExtent (  )  const [private, virtual]

Recalculates the height of this control based on the stored row height and and padding on the rows.

Reimplemented from GuiControl.

void GuiGameListMenuCtrl::updateHeight (  )  [private]

Makes sure the height will allow all rows to be displayed without being truncated.

void GuiGameListMenuCtrl::selectFirstEnabledRow (  )  [private]

Sets the first enabled row as selected.

If there are no enabled rows then selected will be set to NO_ROW.

void GuiGameListMenuCtrl::changeRow ( S32  delta  )  [private]

Changes the currently selected row.

Parameters:
delta The amount to change the row selection by. Typically this will be 1 or -1.


Member Data Documentation

const S32 GuiGameListMenuCtrl::NO_ROW = -1 [static]

Indicates a query result of no row found.

const S32 GuiGameListMenuCtrl::NO_ICON = -1 [static]

Indicates a row has no extra icon available.

Script callback when the 'A' button is pressed.

Script callback when the 'B' button is pressed.

Script callback when the 'X' button is pressed.

Script callback when the 'Y' button is pressed.

Determines when to show debug render lines.

Holds data wrappers on all the rows we have.

index of the currently selected row

index of the currently highlighted row