Cavestory Mod API
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
ModeInputVector Class Reference

A helpful 2D vector class to manage mode input. More...

#include <ModeInputVector.h>

Public Member Functions

 ModeInputVector ()
 Constructor.
 
 ~ModeInputVector ()
 Deconstructor.
 
void SetMinArraySize (ModeInputOptionCoord iWidth, ModeInputOptionCoord iHeight)
 Set the minimum size for this vector. More...
 
bool AddOption (ModeInputSelectionId iSelectionId, ModeInputOptionCoord iX, ModeInputOptionCoord iY, ModeInputOptionCoord iW, ModeInputOptionCoord iH, GUI_RECT *pRect, ScrollAreaInfo *pScroll=NULL, GUI_RECT *pClipRect=NULL, const char *pTooltipText=NULL, ModeInputOptionConfig *pConfig=NULL, unsigned int iFlags=0)
 Add an option to the vector. More...
 
bool AddOption (ModeInputSelectionId iSelectionId, ModeInputOptionCoord iX, ModeInputOptionCoord iY, ModeInputOptionCoord iW, ModeInputOptionCoord iH, GuiBase *pGui, ScrollAreaInfo *pScroll=NULL, GUI_RECT *pClipRect=NULL, const char *pTooltipText=NULL, ModeInputOptionConfig *pConfig=NULL, unsigned int iFlags=0)
 Add an option to the vector. More...
 
bool AddOption (ModeInputSelectionId iSelectionId, ModeInputOptionCoord iX, ModeInputOptionCoord iY, ModeInputOptionCoord iW, ModeInputOptionCoord iH, GUI_RECT pRect, ScrollAreaInfo *pScroll=NULL, GUI_RECT *pClipRect=NULL, const char *pTooltipText=NULL, ModeInputOptionConfig *pConfig=NULL, unsigned int iFlags=0)
 Add an option to the vector. More...
 
bool AddOption (ModeInputSelectionId iSelectionId, GUI_RECT *pRect, ScrollAreaInfo *pScroll=NULL, GUI_RECT *pClipRect=NULL, const char *pTooltipText=NULL, ModeInputOptionConfig *pConfig=NULL, unsigned int iFlags=0)
 Add an unselectable option to the vector. More...
 
bool AddOption (ModeInputSelectionId iSelectionId, GuiBase *pGui, ScrollAreaInfo *pScroll=NULL, GUI_RECT *pClipRect=NULL, const char *pTooltipText=NULL, ModeInputOptionConfig *pConfig=NULL, unsigned int iFlags=0)
 Add an unselectable option to the vector. More...
 
bool AddOption (ModeInputSelectionId iSelectionId, GUI_RECT pRect, ScrollAreaInfo *pScroll=NULL, GUI_RECT *pClipRect=NULL, const char *pTooltipText=NULL, ModeInputOptionConfig *pConfig=NULL, unsigned int iFlags=0)
 Add an unselectable option to the vector. More...
 
bool RemoveOption (ModeInputSelectionId iSelectionId)
 Remove an option by ID. More...
 
bool AddScroll (ScrollAreaInfo *pScroll)
 Add a controllable scroll area. More...
 
void Reset ()
 Reset everything – Unallocates all buffers and resets all variables.
 
ModeInputButtonState GetOptionState (ModeInputSelectionId iSelectionId)
 Get the selected button's determined state. More...
 
GUI_RECT GetOptionRect (ModeInputSelectionId iSelectionId)
 Get the rect for an option. More...
 
void SetSelectionByPos (int iX, int iY, bool bUsedKeyboard, bool bOpenTooltip=true)
 Set the selected option. More...
 
void SetSelectionById (ModeInputSelectionId iSelectionId, bool bUsedKeyboard)
 Set the selected selection ID. More...
 
GUI_POINT GetSelectedPos ()
 Get the selected position. More...
 
int GetSelectedId ()
 Get the selected ID. More...
 
int GetSelectedIndex ()
 Get the selected index. More...
 
bool WasKeyboardUsed ()
 Self explanatory. More...
 
void SetModeOwner (BaseModeInstance *pMode)
 Set the mode to use for processing. More...
 
GUI_POINT GetArraySize ()
 Get the array's dimensions. More...
 
int MoveSelection (int iXM, int iYM)
 Move the current selection. More...
 
int ProcessKeys (int *iSelectedOutTrg)
 Process key input for the vector. More...
 
int ProcessMouse (int *iSelectedOutTrg, GUI_POINT pMousePoint)
 Process mouse input. More...
 
void Lock ()
 Lock the input vector from rebuilding its array.
 
void Unlock ()
 Allow the vector to rebuild its array if necessary.
 
void DumpMap ()
 Dump the input map.
 

Public Attributes

bool m_Clicking
 Are we clicking on the selected option whilst hovering over it? Don't change this.
 
bool m_Hovering
 Are we hovering over the selected option? Don't change this.
 

Protected Member Functions

bool RebuildArray ()
 Rebuild the m_Array array. More...
 
bool IndexOptions ()
 Index all options. More...
 
ModeInputOptionAllocateOption ()
 Allocate an option. More...
 
ModeInputOptionFindOptionById (ModeInputSelectionId iSelectionId, int *pIndexPtr=NULL)
 Find an option by ID. More...
 
GUI_RECT Internal_GetOptionRect (ModeInputOption *pOption)
 Get the screen rect for an option. More...
 
ModeInputOptionInternal_AddOption (ModeInputSelectionId iSelectionId, ModeInputOptionCoord iX, ModeInputOptionCoord iY, ModeInputOptionCoord iW, ModeInputOptionCoord iH, ScrollAreaInfo *pScroll, GUI_RECT *pClipRect, char *pTooltipText, ModeInputOptionConfig *pConfig, unsigned int iFlags)
 The general internal method to add an option. More...
 
void SetTooltip (ModeInputOption *pOption)
 Open an option's tooltip. More...
 
bool IsTooltipSetTo (ModeInputOption *pOption)
 Test to see if the current tooltip is set to an option. More...
 

Detailed Description

A helpful 2D vector class to manage mode input.

A 2D vector of ModeInputOption objects that allow mode instances to manage their key & mouse input in a neat & uniform fashion.

Member Function Documentation

◆ AddOption() [1/6]

bool ModeInputVector::AddOption ( ModeInputSelectionId  iSelectionId,
GUI_RECT pRect,
ScrollAreaInfo pScroll = NULL,
GUI_RECT pClipRect = NULL,
const char *  pTooltipText = NULL,
ModeInputOptionConfig pConfig = NULL,
unsigned int  iFlags = 0 
)

Add an unselectable option to the vector.

Parameters
iSelectionIdThe ID that should be returned by ProcessMouse or ProcessKeys if this option is selected.
pRectA pointer to the on-screen rect.
pScrollThe scroll object that this rect is controlled by. Can be NULL.
pClipRectThe clip rect for this option. Can be NULL.
pTooltipTextThe tooltip text for this option. Can be NULL to disable tooltips for this option.
pConfigThe advanced configuration to use for this option. Can be NULL to use default configuration settings.
Returns
Returns true on success.
Warning
pRect should NOT be NULL and it should be a valid pointer until this ModeInputVector is reset / deleted.
iX, iY, iW and iH should not be the on-screen position & extent of the input. It's the local position & extent in the input vector.
See also
ModeInputOption::OptionFlags

◆ AddOption() [2/6]

bool ModeInputVector::AddOption ( ModeInputSelectionId  iSelectionId,
GUI_RECT  pRect,
ScrollAreaInfo pScroll = NULL,
GUI_RECT pClipRect = NULL,
const char *  pTooltipText = NULL,
ModeInputOptionConfig pConfig = NULL,
unsigned int  iFlags = 0 
)

Add an unselectable option to the vector.

Parameters
iSelectionIdThe ID that should be returned by ProcessMouse or ProcessKeys if this option is selected.
iXThe X position of the input option in the vector.
iYThe Y position of the input option in the vector.
iWThe width of the input option in the vector.
iHThe height of the input option in the vector.
pRectThe plain on-screen rect for this option.
pScrollThe scroll object that this rect is controlled by. Can be NULL.
pClipRectThe clip rect for this option. Can be NULL.
pTooltipTextThe tooltip text for this option. Can be NULL to disable tooltips for this option.
pConfigThe advanced configuration to use for this option. Can be NULL to use default configuration settings.
Returns
Returns true on success.
Warning
pGui should NOT be NULL and it should be a valid pointer until this ModeInputVector is reset / deleted.
See also
ModeInputOption::OptionFlags

◆ AddOption() [3/6]

bool ModeInputVector::AddOption ( ModeInputSelectionId  iSelectionId,
GuiBase pGui,
ScrollAreaInfo pScroll = NULL,
GUI_RECT pClipRect = NULL,
const char *  pTooltipText = NULL,
ModeInputOptionConfig pConfig = NULL,
unsigned int  iFlags = 0 
)

Add an unselectable option to the vector.

Parameters
iSelectionIdThe ID that should be returned by ProcessMouse or ProcessKeys if this option is selected.
iXThe X position of the input option in the vector.
iYThe Y position of the input option in the vector.
iWThe width of the input option in the vector.
iHThe height of the input option in the vector.
pGuiA pointer to the guibase that controls this option.
pScrollThe scroll object that this rect is controlled by. Can be NULL.
pClipRectThe clip rect for this option. Can be NULL.
pTooltipTextThe tooltip text for this option. Can be NULL to disable tooltips for this option.
pConfigThe advanced configuration to use for this option. Can be NULL to use default configuration settings.
Returns
Returns true on success.
Warning
pGui should NOT be NULL and it should be a valid pointer until this ModeInputVector is reset / deleted.
See also
ModeInputOption::OptionFlags

◆ AddOption() [4/6]

bool ModeInputVector::AddOption ( ModeInputSelectionId  iSelectionId,
ModeInputOptionCoord  iX,
ModeInputOptionCoord  iY,
ModeInputOptionCoord  iW,
ModeInputOptionCoord  iH,
GUI_RECT pRect,
ScrollAreaInfo pScroll = NULL,
GUI_RECT pClipRect = NULL,
const char *  pTooltipText = NULL,
ModeInputOptionConfig pConfig = NULL,
unsigned int  iFlags = 0 
)

Add an option to the vector.

Parameters
iSelectionIdThe ID that should be returned by ProcessMouse or ProcessKeys if this option is selected.
iXThe X position of the input option in the vector.
iYThe Y position of the input option in the vector.
iWThe width of the input option in the vector.
iHThe height of the input option in the vector.
pRectA pointer to the on-screen rect.
pScrollThe scroll object that this rect is controlled by. Can be NULL.
pClipRectThe clip rect for this option. Can be NULL.
pTooltipTextThe tooltip text for this option. Can be NULL to disable tooltips for this option.
pConfigThe advanced configuration to use for this option. Can be NULL to use default configuration settings.
Returns
Returns true on success.
Warning
pRect should NOT be NULL and it should be a valid pointer until this ModeInputVector is reset / deleted.
iX, iY, iW and iH should not be the on-screen position & extent of the input. It's the local position & extent in the input vector.
See also
ModeInputOption::OptionFlags

◆ AddOption() [5/6]

bool ModeInputVector::AddOption ( ModeInputSelectionId  iSelectionId,
ModeInputOptionCoord  iX,
ModeInputOptionCoord  iY,
ModeInputOptionCoord  iW,
ModeInputOptionCoord  iH,
GUI_RECT  pRect,
ScrollAreaInfo pScroll = NULL,
GUI_RECT pClipRect = NULL,
const char *  pTooltipText = NULL,
ModeInputOptionConfig pConfig = NULL,
unsigned int  iFlags = 0 
)

Add an option to the vector.

Parameters
iSelectionIdThe ID that should be returned by ProcessMouse or ProcessKeys if this option is selected.
iXThe X position of the input option in the vector.
iYThe Y position of the input option in the vector.
iWThe width of the input option in the vector.
iHThe height of the input option in the vector.
pRectThe plain on-screen rect for this option.
pScrollThe scroll object that this rect is controlled by. Can be NULL.
pClipRectThe clip rect for this option. Can be NULL.
pTooltipTextThe tooltip text for this option. Can be NULL to disable tooltips for this option.
pConfigThe advanced configuration to use for this option. Can be NULL to use default configuration settings.
Returns
Returns true on success.
Warning
pGui should NOT be NULL and it should be a valid pointer until this ModeInputVector is reset / deleted.
See also
ModeInputOption::OptionFlags

◆ AddOption() [6/6]

bool ModeInputVector::AddOption ( ModeInputSelectionId  iSelectionId,
ModeInputOptionCoord  iX,
ModeInputOptionCoord  iY,
ModeInputOptionCoord  iW,
ModeInputOptionCoord  iH,
GuiBase pGui,
ScrollAreaInfo pScroll = NULL,
GUI_RECT pClipRect = NULL,
const char *  pTooltipText = NULL,
ModeInputOptionConfig pConfig = NULL,
unsigned int  iFlags = 0 
)

Add an option to the vector.

Parameters
iSelectionIdThe ID that should be returned by ProcessMouse or ProcessKeys if this option is selected.
iXThe X position of the input option in the vector.
iYThe Y position of the input option in the vector.
iWThe width of the input option in the vector.
iHThe height of the input option in the vector.
pGuiA pointer to the guibase that controls this option.
pScrollThe scroll object that this rect is controlled by. Can be NULL.
pClipRectThe clip rect for this option. Can be NULL.
pTooltipTextThe tooltip text for this option. Can be NULL to disable tooltips for this option.
pConfigThe advanced configuration to use for this option. Can be NULL to use default configuration settings.
Returns
Returns true on success.
Warning
pGui should NOT be NULL and it should be a valid pointer until this ModeInputVector is reset / deleted.
See also
ModeInputOption::OptionFlags

◆ AddScroll()

bool ModeInputVector::AddScroll ( ScrollAreaInfo pScroll)

Add a controllable scroll area.

Parameters
pScrollA pointer to the ScrollAreaInfo element.
Returns
Returns true on success.

◆ AllocateOption()

ModeInputOption* ModeInputVector::AllocateOption ( )
protected

Allocate an option.

Returns
Returns a newly allocated ModeInputOption .

◆ FindOptionById()

ModeInputOption* ModeInputVector::FindOptionById ( ModeInputSelectionId  iSelectionId,
int *  pIndexPtr = NULL 
)
protected

Find an option by ID.

Parameters
iSelectionIdThe ID of the option.
pIndexPtrA pointer to an int that will store the index that the option was found at. Can be NULL.
Returns
Returns a pointer to the option, otherwise returns NULL if it couldn't be found.

◆ GetArraySize()

GUI_POINT ModeInputVector::GetArraySize ( )

Get the array's dimensions.

Returns
Returns the array's dimensions.

◆ GetOptionRect()

GUI_RECT ModeInputVector::GetOptionRect ( ModeInputSelectionId  iSelectionId)

Get the rect for an option.

Parameters
iSelectionIdThe ID of the option.
Returns
Returns the rect for the option.

◆ GetOptionState()

ModeInputButtonState ModeInputVector::GetOptionState ( ModeInputSelectionId  iSelectionId)

Get the selected button's determined state.

Parameters
iSelectionIdThe ID of the option to get the state of.
Returns
Returns the option's state.

◆ GetSelectedId()

int ModeInputVector::GetSelectedId ( )

Get the selected ID.

Returns
Returns the current selected option ID. Returns -1 if no option is selected.

◆ GetSelectedIndex()

int ModeInputVector::GetSelectedIndex ( )

Get the selected index.

Returns
Returns the current selected option index. Returns -1 if no option is selected.

◆ GetSelectedPos()

GUI_POINT ModeInputVector::GetSelectedPos ( )

Get the selected position.

Returns
Returns the current selected coordinates.

◆ IndexOptions()

bool ModeInputVector::IndexOptions ( )
protected

Index all options.

Returns
Returns true on success.

◆ Internal_AddOption()

ModeInputOption* ModeInputVector::Internal_AddOption ( ModeInputSelectionId  iSelectionId,
ModeInputOptionCoord  iX,
ModeInputOptionCoord  iY,
ModeInputOptionCoord  iW,
ModeInputOptionCoord  iH,
ScrollAreaInfo pScroll,
GUI_RECT pClipRect,
char *  pTooltipText,
ModeInputOptionConfig pConfig,
unsigned int  iFlags 
)
protected

The general internal method to add an option.

All AddOption methods call this method.

Parameters
iSelectionIdThe ID that should be returned by ProcessMouse or ProcessKeys if this option is selected.
iXThe X position of the input option in the vector.
iYThe Y position of the input option in the vector.
iWThe width of the input option in the vector.
iHThe height of the input option in the vector.
pRectA pointer to the on-screen rect.
pScrollThe scroll object that this rect is controlled by. Can be NULL.
pClipRectThe clip rect for this option. Can be NULL.
pTooltipTextThe tooltip text for this option. Can be NULL to disable tooltips for this option.
iFlagsThe flags for this option.
pConfigThe advanced configuration to use for this option. Can be NULL to use default configuration settings.
Returns
Returns the newly allocated option.
See also
ModeInputOption::OptionFlags

◆ Internal_GetOptionRect()

GUI_RECT ModeInputVector::Internal_GetOptionRect ( ModeInputOption pOption)
inlineprotected

Get the screen rect for an option.

Parameters
pOptionThe option to get the rect of.
Returns
Returns the rect for the option.

◆ IsTooltipSetTo()

bool ModeInputVector::IsTooltipSetTo ( ModeInputOption pOption)
protected

Test to see if the current tooltip is set to an option.

Parameters
pOptionThe option to compare against.
Returns
Returns true if the option's tooltip is open, otherwise returns false.

◆ MoveSelection()

int ModeInputVector::MoveSelection ( int  iXM,
int  iYM 
)

Move the current selection.

Parameters
iXMThe amount to move X by.
iYMThe amount to move Y by.
Returns
Returns GuiBase::ProcessReturnType flags.

◆ ProcessKeys()

int ModeInputVector::ProcessKeys ( int *  iSelectedOutTrg)

Process key input for the vector.

Parameters
iSelectedOutTrgA pointer to an int that will store the selected option's ID for one frame if it is selected.
Returns
Returns GuiBase::ProcessReturnType flags.

◆ ProcessMouse()

int ModeInputVector::ProcessMouse ( int *  iSelectedOutTrg,
GUI_POINT  pMousePoint 
)

Process mouse input.

Parameters
iSelectedOutTrgA pointer to an int that will store the selected option's ID for one frame if it is selected.
pMousePointThe mouse position.
Returns
Returns GuiBase::ProcessReturnType flags.

◆ RebuildArray()

bool ModeInputVector::RebuildArray ( )
protected

Rebuild the m_Array array.

Returns
Returns true on success.

◆ RemoveOption()

bool ModeInputVector::RemoveOption ( ModeInputSelectionId  iSelectionId)

Remove an option by ID.

Parameters
iSelectionIdThe ID that should be removed.
Returns
Returns true on success.

◆ SetMinArraySize()

void ModeInputVector::SetMinArraySize ( ModeInputOptionCoord  iWidth,
ModeInputOptionCoord  iHeight 
)

Set the minimum size for this vector.

Parameters
iWidthThe minimum width.
iHeightThe minimum height.

◆ SetModeOwner()

void ModeInputVector::SetModeOwner ( BaseModeInstance pMode)
inline

Set the mode to use for processing.

Parameters
pModeThe mode to use.

◆ SetSelectionById()

void ModeInputVector::SetSelectionById ( ModeInputSelectionId  iSelectionId,
bool  bUsedKeyboard 
)

Set the selected selection ID.

Parameters
iSelectionIdThe ID that should be selected.
bUsedKeyboardWhether this should be considered as "We used the keyboard to get to this position" or "we used the mouse to get to this position".
Note
This sets the selection position to the top-left of the option's input rect.

◆ SetSelectionByPos()

void ModeInputVector::SetSelectionByPos ( int  iX,
int  iY,
bool  bUsedKeyboard,
bool  bOpenTooltip = true 
)

Set the selected option.

Parameters
iXThe desired X position.
iYThe desired Y position.
bUsedKeyboardWhether this should be considered as "We used the keyboard to get to this position" or "we used the mouse to get to this position".
bOpenTooltipWhether to open the tooltip for this option as well.

◆ SetTooltip()

void ModeInputVector::SetTooltip ( ModeInputOption pOption)
protected

Open an option's tooltip.

Parameters
pOptionThe option to use.

◆ WasKeyboardUsed()

bool ModeInputVector::WasKeyboardUsed ( )
inline

Self explanatory.

Returns
Returns true if the keyboard was used to get to the current selection, false otherwise.

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