Make OptionsList inputs remappable
This commit is contained in:
@@ -461,6 +461,32 @@ function GetCodeForGame(codeName)
|
||||
return inputCode[gameName] or inputCode["default"]
|
||||
end
|
||||
|
||||
local OptionsListKeys = {
|
||||
PrevMenu = {
|
||||
pump="MenuUp",
|
||||
default="MenuLeft"
|
||||
},
|
||||
NextMenu = {
|
||||
pump="MenuDown",
|
||||
default="MenuRight"
|
||||
},
|
||||
PrevItem = {
|
||||
pump="MenuLeft",
|
||||
default="MenuUp"
|
||||
},
|
||||
NextItem = {
|
||||
pump="MenuRight",
|
||||
default="MenuDown"
|
||||
}
|
||||
};
|
||||
|
||||
function GetOptionsListMapping(name)
|
||||
local sGame = string.lower(GAMESTATE:GetCurrentGame():GetName())
|
||||
local map = OptionsListKeys[name]
|
||||
return map[sGame] or map["default"]
|
||||
end
|
||||
|
||||
|
||||
function oitg_zoom_mode_actor()
|
||||
return Def.Actor{
|
||||
OnCommand= function(self)
|
||||
|
||||
@@ -2878,8 +2878,10 @@ Fallback="ScreenOptionsServiceChild"
|
||||
[OptionsList]
|
||||
Fallback="ScreenWithMenuElements"
|
||||
|
||||
#If true, holding left and pressing right will go to the next menu, and holding right and pressing left will go to the previous menu.
|
||||
LeftAndRightSwitchesMenu=true
|
||||
PrevMenuButton=GetOptionsListMapping("PrevMenu")
|
||||
NextMenuButton=GetOptionsListMapping("NextMenu")
|
||||
PrevItemButton=GetOptionsListMapping("PrevItem")
|
||||
NextItemButton=GetOptionsListMapping("NextItem")
|
||||
CodeNames=""
|
||||
|
||||
#It takes from ScreenOptionsMaster.
|
||||
|
||||
+19
-18
@@ -188,8 +188,11 @@ void OptionsList::Load( RString sType, PlayerNumber pn )
|
||||
|
||||
m_pn = pn;
|
||||
m_bStartIsDown = false;
|
||||
m_bLeftAndRightSwitchesMenu = THEME->GetMetricB( m_sName,"LeftAndRightSwitchesMenu" );
|
||||
|
||||
m_GameButtonPreviousMenu = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric( m_sName,"PrevMenuButton" ) );
|
||||
m_GameButtonNextMenu = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric( m_sName,"NextMenuButton" ) );
|
||||
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") );
|
||||
@@ -417,18 +420,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(m_bLeftAndRightSwitchesMenu and 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();
|
||||
@@ -439,18 +435,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(m_bLeftAndRightSwitchesMenu and 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();
|
||||
@@ -461,6 +450,18 @@ bool OptionsList::Input( const InputEventPlus &input )
|
||||
MESSAGEMAN->Broadcast( lMsg );
|
||||
return true;
|
||||
}
|
||||
else if ( input.MenuI == m_GameButtonPreviousMenu )
|
||||
{
|
||||
if( input.type == IET_FIRST_PRESS )
|
||||
SwitchMenu( -1 );
|
||||
return true;
|
||||
}
|
||||
else if ( input.MenuI == m_GameButtonNextMenu )
|
||||
{
|
||||
if( input.type == IET_FIRST_PRESS )
|
||||
SwitchMenu( +1 );
|
||||
return true;
|
||||
}
|
||||
else if( input.MenuI == GAME_BUTTON_START )
|
||||
{
|
||||
if( input.type == IET_FIRST_PRESS )
|
||||
|
||||
+4
-1
@@ -102,7 +102,10 @@ private:
|
||||
vector<RString> m_asMenuStack;
|
||||
int m_iMenuStackSelection;
|
||||
protected:
|
||||
bool m_bLeftAndRightSwitchesMenu;
|
||||
GameButton m_GameButtonPreviousMenu;
|
||||
GameButton m_GameButtonNextMenu;
|
||||
GameButton m_GameButtonPreviousItem;
|
||||
GameButton m_GameButtonNextItem;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user