Add More OptionsList functionality (#1810)

* Add More OptionsList functionality

* Remove Size parameter because it's broken

* Make OptionsList inputs remappable

* Change Next/Prev OptionsList to CodeDetector
This commit is contained in:
Rhythm Lunatic
2019-03-28 16:49:46 -05:00
committed by Colby Klein
parent 3eb03feadd
commit dcb2f74c8d
8 changed files with 144 additions and 25 deletions
+38 -22
View File
@@ -181,13 +181,16 @@ OptionsList::~OptionsList()
delete hand->second;
}
//This is the initialization function.
void OptionsList::Load( RString sType, PlayerNumber pn )
{
TOP_MENU.Load( sType, "TopMenu" );
m_pn = pn;
m_bStartIsDown = false;
m_GameButtonPreviousItem = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric( m_sName,"PrevItemButton" ) );
m_GameButtonNextItem = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric( m_sName,"NextItemButton" ) );
m_Codes.Load( sType );
m_Cursor.Load( THEME->GetPathG(sType, "cursor") );
@@ -290,7 +293,8 @@ RString OptionsList::GetCurrentRow() const
return m_asMenuStack.back();
}
const OptionRowHandler *OptionsList::GetCurrentHandler()
//This can't be const because OptionRowHandler->NotifyOfSelection() will modify the OptionRow.
OptionRowHandler *OptionsList::GetCurrentHandler()
{
RString sCurrentRow = GetCurrentRow();
return m_Rows[sCurrentRow];
@@ -414,18 +418,11 @@ bool OptionsList::Input( const InputEventPlus &input )
}
}
if( input.MenuI == GAME_BUTTON_LEFT )
if( input.MenuI == m_GameButtonPreviousItem )
{
if( input.type == IET_RELEASE )
return false;
if( INPUTMAPPER->IsBeingPressed(GAME_BUTTON_RIGHT, pn) )
{
if( input.type == IET_FIRST_PRESS )
SwitchMenu( -1 );
return true;
}
--m_iMenuStackSelection;
wrap( m_iMenuStackSelection, pHandler->m_Def.m_vsChoices.size()+1 ); // +1 for exit row
PositionCursor();
@@ -436,18 +433,11 @@ bool OptionsList::Input( const InputEventPlus &input )
MESSAGEMAN->Broadcast( lMsg );
return true;
}
else if( input.MenuI == GAME_BUTTON_RIGHT )
else if( input.MenuI == m_GameButtonNextItem )
{
if( input.type == IET_RELEASE )
return false;
if( INPUTMAPPER->IsBeingPressed(GAME_BUTTON_LEFT, pn) )
{
if( input.type == IET_FIRST_PRESS )
SwitchMenu( +1 );
return true;
}
++m_iMenuStackSelection;
wrap( m_iMenuStackSelection, pHandler->m_Def.m_vsChoices.size()+1 ); // +1 for exit row
PositionCursor();
@@ -458,6 +448,18 @@ bool OptionsList::Input( const InputEventPlus &input )
MESSAGEMAN->Broadcast( lMsg );
return true;
}
else if ( CodeDetector::EnteredPrevOpList(input.GameI.controller) )
{
if( input.type == IET_FIRST_PRESS )
SwitchMenu( -1 );
return true;
}
else if ( CodeDetector::EnteredNextOpList(input.GameI.controller) )
{
if( input.type == IET_FIRST_PRESS )
SwitchMenu( +1 );
return true;
}
else if( input.MenuI == GAME_BUTTON_START )
{
if( input.type == IET_FIRST_PRESS )
@@ -662,7 +664,7 @@ void OptionsList::UpdateMenuFromSelections()
bool OptionsList::Start()
{
const OptionRowHandler *pHandler = GetCurrentHandler();
OptionRowHandler *pHandler = GetCurrentHandler();
const RString &sCurrentRow = m_asMenuStack.back();
vector<bool> &bSelections = m_bSelections[sCurrentRow];
if( m_iMenuStackSelection == (int)bSelections.size() )
@@ -717,12 +719,26 @@ bool OptionsList::Start()
SelectItem( GetCurrentRow(), m_iMenuStackSelection );
/* Move to the exit row. */
m_iMenuStackSelection = (int)bSelections.size();
PositionCursor();
/* Move to the exit row, but only if it's SelectOne. */
if (pHandler->m_Def.m_selectType == SELECT_ONE)
{
m_iMenuStackSelection = (int)bSelections.size();
PositionCursor();
}
if (pHandler->NotifyOfSelection(m_pn, m_iMenuStackSelection))
{
/* The current selections are irrelevant when we're getting them
* from NotifyOfSelection. Re import them from the OptionRow. */
ImportRow(sCurrentRow);
UpdateMenuFromSelections();
}
/* Better to include Selection as a parameter since
* the index may or may not change depending on if SelectType
* is SELECT_ONE or SELECT_MULTIPLE. */
Message msg("OptionsListStart");
msg.SetParam( "Player", m_pn );
msg.SetParam( "Selection", m_iMenuStackSelection );
MESSAGEMAN->Broadcast( msg );
return false;