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:
committed by
Colby Klein
parent
3eb03feadd
commit
dcb2f74c8d
@@ -331,6 +331,13 @@ local CodeDetectorCodes = {
|
|||||||
CloseCurrentFolder = {
|
CloseCurrentFolder = {
|
||||||
default = "MenuUp-MenuDown",
|
default = "MenuUp-MenuDown",
|
||||||
},
|
},
|
||||||
|
-- OptionsList
|
||||||
|
PrevOptionsList = {
|
||||||
|
default = "@MenuUp-MenuDown",
|
||||||
|
},
|
||||||
|
NextOptionsList = {
|
||||||
|
default = "@MenuDown-MenuUp",
|
||||||
|
},
|
||||||
-- sorts
|
-- sorts
|
||||||
NextSort1 = {
|
NextSort1 = {
|
||||||
default = "@MenuLeft-@MenuRight-Start",
|
default = "@MenuLeft-@MenuRight-Start",
|
||||||
@@ -461,6 +468,24 @@ function GetCodeForGame(codeName)
|
|||||||
return inputCode[gameName] or inputCode["default"]
|
return inputCode[gameName] or inputCode["default"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local OptionsListKeys = {
|
||||||
|
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()
|
function oitg_zoom_mode_actor()
|
||||||
return Def.Actor{
|
return Def.Actor{
|
||||||
OnCommand= function(self)
|
OnCommand= function(self)
|
||||||
|
|||||||
@@ -368,6 +368,10 @@ PrevGroup=GetCodeForGame("PrevGroup")
|
|||||||
CloseCurrentFolder=GetCodeForGame("CloseCurrentFolder")
|
CloseCurrentFolder=GetCodeForGame("CloseCurrentFolder")
|
||||||
Hidden=GetCodeForGame("Hidden")
|
Hidden=GetCodeForGame("Hidden")
|
||||||
RandomVanish=GetCodeForGame("RandomVanish")
|
RandomVanish=GetCodeForGame("RandomVanish")
|
||||||
|
# OptionsList (if enabled)
|
||||||
|
PrevOptionsList=GetCodeForGame("PrevOptionsList")
|
||||||
|
NextOptionsList=GetCodeForGame("NextOptionsList")
|
||||||
|
# Evaluation screen
|
||||||
SaveScreenshot1=GetCodeForGame("SaveScreenshot1")
|
SaveScreenshot1=GetCodeForGame("SaveScreenshot1")
|
||||||
SaveScreenshot2=GetCodeForGame("SaveScreenshot2")
|
SaveScreenshot2=GetCodeForGame("SaveScreenshot2")
|
||||||
# on the player options menu.
|
# on the player options menu.
|
||||||
@@ -2875,6 +2879,62 @@ ExplanationTogetherOffCommand=stoptweening
|
|||||||
[ScreenOptionsServiceExtendedChild]
|
[ScreenOptionsServiceExtendedChild]
|
||||||
Fallback="ScreenOptionsServiceChild"
|
Fallback="ScreenOptionsServiceChild"
|
||||||
|
|
||||||
|
[OptionsList]
|
||||||
|
Fallback="ScreenWithMenuElements"
|
||||||
|
|
||||||
|
PrevMenuButton=GetOptionsListMapping("PrevMenu")
|
||||||
|
NextMenuButton=GetOptionsListMapping("NextMenu")
|
||||||
|
PrevItemButton=GetOptionsListMapping("PrevItem")
|
||||||
|
NextItemButton=GetOptionsListMapping("NextItem")
|
||||||
|
CodeNames=""
|
||||||
|
|
||||||
|
#It takes from ScreenOptionsMaster.
|
||||||
|
#This is the equivalent to LineNames
|
||||||
|
TopMenus=""
|
||||||
|
TopMenu=""
|
||||||
|
|
||||||
|
DirectLines=""
|
||||||
|
ItemsSpacingY=
|
||||||
|
MaxItemsBeforeSplit=
|
||||||
|
ItemsSplitWidth=
|
||||||
|
|
||||||
|
TextOnCommand=
|
||||||
|
TextOffCommand=
|
||||||
|
TextTweenOffCommand=
|
||||||
|
TextTweenOnCommand=
|
||||||
|
TextResetCommand=
|
||||||
|
|
||||||
|
UnderlineOnCommand=
|
||||||
|
UnderlineOffCommand=
|
||||||
|
UnderlineSetTwoRowsCommand=
|
||||||
|
UnderlineSetOneRowCommand=
|
||||||
|
UnderlineShowCommand=
|
||||||
|
UnderlineHideCommand=
|
||||||
|
UnderlineTweenOnCommand=
|
||||||
|
UnderlineTweenOffCommand=
|
||||||
|
UnderlineResetCommand=
|
||||||
|
|
||||||
|
CursorOnCommand=
|
||||||
|
CursorPositionTwoRowsCommand=
|
||||||
|
CursorPositionOneRowCommand=
|
||||||
|
CursorTweenOnCommand=
|
||||||
|
CursorTweenOffCommand=
|
||||||
|
CursorResetCommand=
|
||||||
|
|
||||||
|
OptionsListOnCommand=
|
||||||
|
OptionsListOffCommand=
|
||||||
|
OptionsListTweenOffCommand=
|
||||||
|
OptionsListTweenOnCommand=
|
||||||
|
OptionsListResetCommand=
|
||||||
|
|
||||||
|
OptionsListTweenOutForwardCommand=
|
||||||
|
OptionsListTweenOutBackwardCommand=
|
||||||
|
OptionsListTweenInForwardCommand=
|
||||||
|
OptionsListTweenInBackwardCommand=
|
||||||
|
|
||||||
|
OptionsListFadeOffCommand=
|
||||||
|
OptionsListFadeOnCommand=
|
||||||
|
|
||||||
[ScreenMiniMenu]
|
[ScreenMiniMenu]
|
||||||
Class="ScreenMiniMenu"
|
Class="ScreenMiniMenu"
|
||||||
Fallback="ScreenOptions"
|
Fallback="ScreenOptions"
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ const char *CodeNames[] = {
|
|||||||
"CancelAllPlayerOptions",
|
"CancelAllPlayerOptions",
|
||||||
"BackInEventMode",
|
"BackInEventMode",
|
||||||
"CloseCurrentFolder",
|
"CloseCurrentFolder",
|
||||||
|
"PrevOptionsList",
|
||||||
|
"NextOptionsList"
|
||||||
};
|
};
|
||||||
XToString( Code );
|
XToString( Code );
|
||||||
|
|
||||||
@@ -116,6 +118,15 @@ bool CodeDetector::EnteredModeMenu( GameController controller )
|
|||||||
return EnteredCode(controller,CODE_MODE_MENU1) || EnteredCode(controller,CODE_MODE_MENU2);
|
return EnteredCode(controller,CODE_MODE_MENU1) || EnteredCode(controller,CODE_MODE_MENU2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CodeDetector::EnteredPrevOpList( GameController controller )
|
||||||
|
{
|
||||||
|
return EnteredCode(controller,CODE_PREV_OPLIST);
|
||||||
|
}
|
||||||
|
bool CodeDetector::EnteredNextOpList( GameController controller )
|
||||||
|
{
|
||||||
|
return EnteredCode(controller,CODE_NEXT_OPLIST);
|
||||||
|
}
|
||||||
|
|
||||||
#define TOGGLE(v,a,b) if(v!=a) v=a; else v=b;
|
#define TOGGLE(v,a,b) if(v!=a) v=a; else v=b;
|
||||||
#define FLOAT_TOGGLE(v) if(v!=1.f) v=1.f; else v=0.f;
|
#define FLOAT_TOGGLE(v) if(v!=1.f) v=1.f; else v=0.f;
|
||||||
// XXX: Read the metrics file instead!
|
// XXX: Read the metrics file instead!
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ enum Code {
|
|||||||
CODE_CANCEL_ALL_PLAYER_OPTIONS,
|
CODE_CANCEL_ALL_PLAYER_OPTIONS,
|
||||||
CODE_BACK_IN_EVENT_MODE,
|
CODE_BACK_IN_EVENT_MODE,
|
||||||
CODE_CLOSE_CURRENT_FOLDER,
|
CODE_CLOSE_CURRENT_FOLDER,
|
||||||
|
CODE_NEXT_OPLIST,
|
||||||
|
CODE_PREV_OPLIST,
|
||||||
NUM_Code // leave this at the end
|
NUM_Code // leave this at the end
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -63,6 +65,8 @@ public:
|
|||||||
static bool EnteredPrevGroup( GameController controller );
|
static bool EnteredPrevGroup( GameController controller );
|
||||||
static bool EnteredNextGroup( GameController controller );
|
static bool EnteredNextGroup( GameController controller );
|
||||||
static bool EnteredCloseFolder( GameController controller );
|
static bool EnteredCloseFolder( GameController controller );
|
||||||
|
static bool EnteredPrevOpList( GameController controller );
|
||||||
|
static bool EnteredNextOpList( GameController controller );
|
||||||
|
|
||||||
// todo: move to PlayerOptions.h -aj
|
// todo: move to PlayerOptions.h -aj
|
||||||
void ChangeScrollSpeed( GameController controller, bool bIncrement );
|
void ChangeScrollSpeed( GameController controller, bool bIncrement );
|
||||||
|
|||||||
@@ -1326,7 +1326,7 @@ public:
|
|||||||
LUA->Release(L);
|
LUA->Release(L);
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
virtual bool GoToFirstOnStart()
|
virtual bool GoToFirstOnStart() const
|
||||||
{
|
{
|
||||||
return m_GoToFirstOnStart;
|
return m_GoToFirstOnStart;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ public:
|
|||||||
virtual RString GetScreen( int /* iChoice */ ) const { return RString(); }
|
virtual RString GetScreen( int /* iChoice */ ) const { return RString(); }
|
||||||
// Exists so that a lua function can act on the selection. Returns true if the choices should be reloaded.
|
// Exists so that a lua function can act on the selection. Returns true if the choices should be reloaded.
|
||||||
virtual bool NotifyOfSelection(PlayerNumber pn, int choice) { return false; }
|
virtual bool NotifyOfSelection(PlayerNumber pn, int choice) { return false; }
|
||||||
virtual bool GoToFirstOnStart() { return true; }
|
virtual bool GoToFirstOnStart() const { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @brief Utilities for the OptionRowHandlers. */
|
/** @brief Utilities for the OptionRowHandlers. */
|
||||||
|
|||||||
+37
-21
@@ -181,12 +181,15 @@ OptionsList::~OptionsList()
|
|||||||
delete hand->second;
|
delete hand->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//This is the initialization function.
|
||||||
void OptionsList::Load( RString sType, PlayerNumber pn )
|
void OptionsList::Load( RString sType, PlayerNumber pn )
|
||||||
{
|
{
|
||||||
TOP_MENU.Load( sType, "TopMenu" );
|
TOP_MENU.Load( sType, "TopMenu" );
|
||||||
|
|
||||||
m_pn = pn;
|
m_pn = pn;
|
||||||
m_bStartIsDown = false;
|
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_Codes.Load( sType );
|
||||||
|
|
||||||
@@ -290,7 +293,8 @@ RString OptionsList::GetCurrentRow() const
|
|||||||
return m_asMenuStack.back();
|
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();
|
RString sCurrentRow = GetCurrentRow();
|
||||||
return m_Rows[sCurrentRow];
|
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 )
|
if( input.type == IET_RELEASE )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( INPUTMAPPER->IsBeingPressed(GAME_BUTTON_RIGHT, pn) )
|
|
||||||
{
|
|
||||||
if( input.type == IET_FIRST_PRESS )
|
|
||||||
SwitchMenu( -1 );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
--m_iMenuStackSelection;
|
--m_iMenuStackSelection;
|
||||||
wrap( m_iMenuStackSelection, pHandler->m_Def.m_vsChoices.size()+1 ); // +1 for exit row
|
wrap( m_iMenuStackSelection, pHandler->m_Def.m_vsChoices.size()+1 ); // +1 for exit row
|
||||||
PositionCursor();
|
PositionCursor();
|
||||||
@@ -436,18 +433,11 @@ bool OptionsList::Input( const InputEventPlus &input )
|
|||||||
MESSAGEMAN->Broadcast( lMsg );
|
MESSAGEMAN->Broadcast( lMsg );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if( input.MenuI == GAME_BUTTON_RIGHT )
|
else if( input.MenuI == m_GameButtonNextItem )
|
||||||
{
|
{
|
||||||
if( input.type == IET_RELEASE )
|
if( input.type == IET_RELEASE )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( INPUTMAPPER->IsBeingPressed(GAME_BUTTON_LEFT, pn) )
|
|
||||||
{
|
|
||||||
if( input.type == IET_FIRST_PRESS )
|
|
||||||
SwitchMenu( +1 );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
++m_iMenuStackSelection;
|
++m_iMenuStackSelection;
|
||||||
wrap( m_iMenuStackSelection, pHandler->m_Def.m_vsChoices.size()+1 ); // +1 for exit row
|
wrap( m_iMenuStackSelection, pHandler->m_Def.m_vsChoices.size()+1 ); // +1 for exit row
|
||||||
PositionCursor();
|
PositionCursor();
|
||||||
@@ -458,6 +448,18 @@ bool OptionsList::Input( const InputEventPlus &input )
|
|||||||
MESSAGEMAN->Broadcast( lMsg );
|
MESSAGEMAN->Broadcast( lMsg );
|
||||||
return true;
|
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 )
|
else if( input.MenuI == GAME_BUTTON_START )
|
||||||
{
|
{
|
||||||
if( input.type == IET_FIRST_PRESS )
|
if( input.type == IET_FIRST_PRESS )
|
||||||
@@ -662,7 +664,7 @@ void OptionsList::UpdateMenuFromSelections()
|
|||||||
|
|
||||||
bool OptionsList::Start()
|
bool OptionsList::Start()
|
||||||
{
|
{
|
||||||
const OptionRowHandler *pHandler = GetCurrentHandler();
|
OptionRowHandler *pHandler = GetCurrentHandler();
|
||||||
const RString &sCurrentRow = m_asMenuStack.back();
|
const RString &sCurrentRow = m_asMenuStack.back();
|
||||||
vector<bool> &bSelections = m_bSelections[sCurrentRow];
|
vector<bool> &bSelections = m_bSelections[sCurrentRow];
|
||||||
if( m_iMenuStackSelection == (int)bSelections.size() )
|
if( m_iMenuStackSelection == (int)bSelections.size() )
|
||||||
@@ -717,12 +719,26 @@ bool OptionsList::Start()
|
|||||||
|
|
||||||
SelectItem( GetCurrentRow(), m_iMenuStackSelection );
|
SelectItem( GetCurrentRow(), m_iMenuStackSelection );
|
||||||
|
|
||||||
/* Move to the exit row. */
|
/* Move to the exit row, but only if it's SelectOne. */
|
||||||
m_iMenuStackSelection = (int)bSelections.size();
|
if (pHandler->m_Def.m_selectType == SELECT_ONE)
|
||||||
PositionCursor();
|
{
|
||||||
|
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");
|
Message msg("OptionsListStart");
|
||||||
msg.SetParam( "Player", m_pn );
|
msg.SetParam( "Player", m_pn );
|
||||||
|
msg.SetParam( "Selection", m_iMenuStackSelection );
|
||||||
MESSAGEMAN->Broadcast( msg );
|
MESSAGEMAN->Broadcast( msg );
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+4
-1
@@ -70,7 +70,7 @@ private:
|
|||||||
void SelectionsChanged( const RString &sRowName );
|
void SelectionsChanged( const RString &sRowName );
|
||||||
void UpdateMenuFromSelections();
|
void UpdateMenuFromSelections();
|
||||||
RString GetCurrentRow() const;
|
RString GetCurrentRow() const;
|
||||||
const OptionRowHandler *GetCurrentHandler();
|
OptionRowHandler *GetCurrentHandler();
|
||||||
int GetOneSelection( RString sRow, bool bAllowFail=false ) const;
|
int GetOneSelection( RString sRow, bool bAllowFail=false ) const;
|
||||||
void SwitchToCurrentRow();
|
void SwitchToCurrentRow();
|
||||||
void TweenOnCurrentRow( bool bForward );
|
void TweenOnCurrentRow( bool bForward );
|
||||||
@@ -101,6 +101,9 @@ private:
|
|||||||
|
|
||||||
vector<RString> m_asMenuStack;
|
vector<RString> m_asMenuStack;
|
||||||
int m_iMenuStackSelection;
|
int m_iMenuStackSelection;
|
||||||
|
protected:
|
||||||
|
GameButton m_GameButtonPreviousItem;
|
||||||
|
GameButton m_GameButtonNextItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user