Fixed bug that caused global fail setting to override setting the fail type from song options. Added GAMESTATE:SetFailTypeExplicitlySet so that a theme with a custom song options screen can protect its fail setting from being overridden the same way the engine ScreenSongOptions does.
This commit is contained in:
@@ -823,6 +823,7 @@
|
|||||||
<Function name='SetCurrentSong'/>
|
<Function name='SetCurrentSong'/>
|
||||||
<Function name='SetCurrentSteps'/>
|
<Function name='SetCurrentSteps'/>
|
||||||
<Function name='SetCurrentTrail'/>
|
<Function name='SetCurrentTrail'/>
|
||||||
|
<Function name='SetFailTypeExplicitlySet'/>
|
||||||
<Function name='SetJukeboxUsesModifiers'/>
|
<Function name='SetJukeboxUsesModifiers'/>
|
||||||
<Function name='SetMultiplayer'/>
|
<Function name='SetMultiplayer'/>
|
||||||
<Function name='SetNumMultiplayerNoteFields'/>
|
<Function name='SetNumMultiplayerNoteFields'/>
|
||||||
|
|||||||
@@ -2466,6 +2466,9 @@ save yourself some time, copy this for undocumented things:
|
|||||||
<Function name='SetCurrentTrail' return='void' arguments='Trail trail'>
|
<Function name='SetCurrentTrail' return='void' arguments='Trail trail'>
|
||||||
Sets the current Trail to <code>trail</code>.
|
Sets the current Trail to <code>trail</code>.
|
||||||
</Function>
|
</Function>
|
||||||
|
<Function name='SetFailTypeExplicitlySet' return='void' arguments=''>
|
||||||
|
Tells the engine that the theme explicitly set the fail type for the players so that it won't override it with the easier settings for beginner or easy.
|
||||||
|
</Function>
|
||||||
<Function name='SetJukeboxUsesModifiers' return='void' arguments='bool bUseMods'>
|
<Function name='SetJukeboxUsesModifiers' return='void' arguments='bool bUseMods'>
|
||||||
Sets if the Jukebox should use modifiers.
|
Sets if the Jukebox should use modifiers.
|
||||||
</Function>
|
</Function>
|
||||||
|
|||||||
@@ -10,23 +10,26 @@ function AreStageSongModsForced()
|
|||||||
return GAMESTATE:IsAnExtraStage() or bOni or bBattle or bRave
|
return GAMESTATE:IsAnExtraStage() or bOni or bBattle or bRave
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local default_fail_applied= {}
|
||||||
|
|
||||||
|
function ResetDefaultFail()
|
||||||
|
default_fail_applied= {}
|
||||||
|
end
|
||||||
|
|
||||||
function SetFail()
|
function SetFail()
|
||||||
local sFail = ""
|
local sFail = ""
|
||||||
|
|
||||||
if GetGamePref("DefaultFail") then
|
if GetGamePref("DefaultFail") then
|
||||||
sFail = string.format("Fail%s", GetGamePref("DefaultFail"))
|
sFail = string.format("FailType_%s", GetGamePref("DefaultFail"))
|
||||||
else
|
else
|
||||||
sFail = "FailOff"
|
sFail = "FailType_Off"
|
||||||
end
|
end
|
||||||
|
|
||||||
sFail = tostring(sFail)
|
|
||||||
|
|
||||||
for pn in ivalues(GAMESTATE:GetHumanPlayers()) do
|
for pn in ivalues(GAMESTATE:GetHumanPlayers()) do
|
||||||
|
if not default_fail_applied[pn] then
|
||||||
|
GAMESTATE:GetPlayerState(pn):GetPlayerOptions("ModsLevel_Preferred"):FailSetting(sFail)
|
||||||
|
default_fail_applied[pn]= true
|
||||||
MESSAGEMAN:Broadcast( "PlayerOptionsChanged", {PlayerNumber = pn} )
|
MESSAGEMAN:Broadcast( "PlayerOptionsChanged", {PlayerNumber = pn} )
|
||||||
end
|
end
|
||||||
|
end
|
||||||
GAMESTATE:ApplyGameCommand( "mod," .. sFail)
|
|
||||||
MESSAGEMAN:Broadcast( "SongOptionsChanged" )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function ScreenSelectMusic:setupmusicstagemods()
|
function ScreenSelectMusic:setupmusicstagemods()
|
||||||
|
|||||||
@@ -151,57 +151,82 @@ end;
|
|||||||
--[[ end themeoption rows ]]
|
--[[ end themeoption rows ]]
|
||||||
|
|
||||||
--[[ game option rows ]]
|
--[[ game option rows ]]
|
||||||
|
local fail_choices= { "Immediate","ImmediateContinue", "EndOfSong", "Off" }
|
||||||
function GamePrefDefaultFail()
|
function GamePrefDefaultFail()
|
||||||
local t = {
|
return {
|
||||||
Name = "GamePrefDefaultFail";
|
Name = "GamePrefDefaultFail";
|
||||||
LayoutType = "ShowAllInRow";
|
LayoutType = "ShowAllInRow";
|
||||||
SelectType = "SelectOne";
|
SelectType = "SelectOne";
|
||||||
OneChoiceForAllPlayers = true;
|
OneChoiceForAllPlayers = true;
|
||||||
ExportOnChange = false;
|
ExportOnChange = false;
|
||||||
Choices = { "Immediate","ImmediateContinue", "AtEnd", "Off" };
|
Choices = fail_choices;
|
||||||
LoadSelections = function(self, list, pn)
|
LoadSelections = function(self, list, pn)
|
||||||
if ReadGamePrefFromFile("DefaultFail") ~= nil then
|
if ReadGamePrefFromFile("DefaultFail") ~= nil then
|
||||||
if GetGamePref("DefaultFail") then
|
local default= GetGamePref("DefaultFail")
|
||||||
if GetGamePref("DefaultFail") == "Immediate" then
|
if default then
|
||||||
list[1] = true;
|
if default == "Immediate" then
|
||||||
elseif GetGamePref("DefaultFail") == "ImmediateContinue" then
|
list[1] = true
|
||||||
list[2] = true;
|
elseif default == "ImmediateContinue" then
|
||||||
elseif GetGamePref("DefaultFail") == "AtEnd" then
|
list[2] = true
|
||||||
list[3] = true;
|
elseif default == "EndOfSong" or default == "AtEnd" then
|
||||||
elseif GetGamePref("DefaultFail") == "Off" then
|
list[3] = true
|
||||||
list[4] = true;
|
elseif default == "Off" then
|
||||||
|
list[4] = true
|
||||||
else
|
else
|
||||||
list[1] = true;
|
list[1] = true
|
||||||
end
|
end
|
||||||
-- list[table.find( list, GetGamePref("DefaultFail") )] = true;
|
|
||||||
else
|
else
|
||||||
list[1] = true;
|
list[1] = true
|
||||||
end;
|
end
|
||||||
else
|
else
|
||||||
WriteGamePrefToFile("DefaultFail","Immediate");
|
WriteGamePrefToFile("DefaultFail","Immediate")
|
||||||
list[1] = true;
|
list[1] = true
|
||||||
end;
|
end
|
||||||
end;
|
end;
|
||||||
SaveSelections = function(self, list, pn)
|
SaveSelections = function(self, list, pn)
|
||||||
-- This is so stupid.
|
local val
|
||||||
local tChoices = { "Immediate","ImmediateContinue", "AtEnd", "Off" };
|
|
||||||
local val;
|
|
||||||
if list[1] then
|
if list[1] then
|
||||||
val = tChoices[1];
|
val = fail_choices[1]
|
||||||
elseif list[2] then
|
elseif list[2] then
|
||||||
val = tChoices[2];
|
val = fail_choices[2]
|
||||||
elseif list[3] then
|
elseif list[3] then
|
||||||
val = tChoices[3];
|
val = fail_choices[3]
|
||||||
elseif list[4] then
|
elseif list[4] then
|
||||||
val = tChoices[4];
|
val = fail_choices[4]
|
||||||
else
|
else
|
||||||
val = tChoices[1];
|
val = fail_choices[1]
|
||||||
end
|
end
|
||||||
WriteGamePrefToFile("DefaultFail",val);
|
WriteGamePrefToFile("DefaultFail",val)
|
||||||
MESSAGEMAN:Broadcast("PreferenceSet", { Message == "Set Preference" } );
|
MESSAGEMAN:Broadcast("PreferenceSet", { Message == "Set Preference" } )
|
||||||
THEME:ReloadMetrics();
|
THEME:ReloadMetrics()
|
||||||
end;
|
end;
|
||||||
};
|
}
|
||||||
setmetatable( t, t );
|
end
|
||||||
return t;
|
|
||||||
|
function SongPrefFail()
|
||||||
|
-- Apply the default fail type to any players that haven't had it applied.
|
||||||
|
SetFail()
|
||||||
|
return {
|
||||||
|
Name= "Fail",
|
||||||
|
LayoutType= "ShowAllInRow",
|
||||||
|
SelectType= "SelectOne",
|
||||||
|
OneChoiceForAllPlayers= false,
|
||||||
|
ExportOnChange= false,
|
||||||
|
Choices= fail_choices,
|
||||||
|
LoadSelections= function(self, list, pn)
|
||||||
|
local fail= GAMESTATE:GetPlayerState(pn):GetPlayerOptions("ModsLevel_Preferred"):FailSetting():sub(10)
|
||||||
|
for i, c in ipairs(self.Choices) do
|
||||||
|
if c == fail then
|
||||||
|
list[i]= true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
SaveSelections= function(self, list, pn)
|
||||||
|
for i, c in ipairs(self.Choices) do
|
||||||
|
if list[i] then
|
||||||
|
GAMESTATE:GetPlayerState(pn):GetPlayerOptions("ModsLevel_Preferred"):FailSetting("FailType_" .. c)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1809,6 +1809,7 @@ Fallback="ScreenSelectMaster"
|
|||||||
PrevScreen="ScreenInit"
|
PrevScreen="ScreenInit"
|
||||||
NextScreen="ScreenInit"
|
NextScreen="ScreenInit"
|
||||||
#
|
#
|
||||||
|
ScreenBeginCommand=%ResetDefaultFail
|
||||||
StopMusicOnBack=true
|
StopMusicOnBack=true
|
||||||
#
|
#
|
||||||
CoinModeChangeScreen=Branch.TitleMenu()
|
CoinModeChangeScreen=Branch.TitleMenu()
|
||||||
@@ -2222,7 +2223,7 @@ TimerMetricsGroup="MenuTimerNoSound"
|
|||||||
WaitForChildrenBeforeTweeningOut=true
|
WaitForChildrenBeforeTweeningOut=true
|
||||||
TimerSeconds=1
|
TimerSeconds=1
|
||||||
#
|
#
|
||||||
ScreenBeginCommand=%SetFail
|
ScreenBeginCommand=
|
||||||
|
|
||||||
[ScreenOptions]
|
[ScreenOptions]
|
||||||
Fallback="ScreenWithMenuElements"
|
Fallback="ScreenWithMenuElements"
|
||||||
@@ -3130,7 +3131,7 @@ Line8="list,AutoAdjust"
|
|||||||
Line9="list,Background"
|
Line9="list,Background"
|
||||||
Line10="list,SaveScores"
|
Line10="list,SaveScores"
|
||||||
Line11="list,SaveReplays"
|
Line11="list,SaveReplays"
|
||||||
Line4="list,Fail"
|
Line4="lua,SongPrefFail()"
|
||||||
|
|
||||||
[ScreenSplash]
|
[ScreenSplash]
|
||||||
Class="ScreenSplash"
|
Class="ScreenSplash"
|
||||||
|
|||||||
+9
-2
@@ -292,7 +292,7 @@ void GameState::Reset()
|
|||||||
*m_Environment = LuaTable();
|
*m_Environment = LuaTable();
|
||||||
m_sPreferredSongGroup.Set( GROUP_ALL );
|
m_sPreferredSongGroup.Set( GROUP_ALL );
|
||||||
m_sPreferredCourseGroup.Set( GROUP_ALL );
|
m_sPreferredCourseGroup.Set( GROUP_ALL );
|
||||||
m_bChangedFailTypeOnScreenSongOptions = false;
|
m_bFailTypeWasExplicitlySet = false;
|
||||||
m_SortOrder.Set( SortOrder_Invalid );
|
m_SortOrder.Set( SortOrder_Invalid );
|
||||||
m_PreferredSortOrder = GetDefaultSort();
|
m_PreferredSortOrder = GetDefaultSort();
|
||||||
m_PlayMode.Set( PlayMode_Invalid );
|
m_PlayMode.Set( PlayMode_Invalid );
|
||||||
@@ -1540,7 +1540,7 @@ FailType GameState::GetPlayerFailType( const PlayerState *pPlayerState ) const
|
|||||||
FailType ft = pPlayerState->m_PlayerOptions.GetCurrent().m_FailType;
|
FailType ft = pPlayerState->m_PlayerOptions.GetCurrent().m_FailType;
|
||||||
|
|
||||||
// If the player changed the fail mode explicitly, leave it alone.
|
// If the player changed the fail mode explicitly, leave it alone.
|
||||||
if( m_bChangedFailTypeOnScreenSongOptions )
|
if( m_bFailTypeWasExplicitlySet )
|
||||||
return ft;
|
return ft;
|
||||||
|
|
||||||
if( IsCourseMode() )
|
if( IsCourseMode() )
|
||||||
@@ -2579,6 +2579,12 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int SetFailTypeExplicitlySet(T* p, lua_State* L)
|
||||||
|
{
|
||||||
|
p->m_bFailTypeWasExplicitlySet= true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int StoreRankingName( T* p, lua_State *L )
|
static int StoreRankingName( T* p, lua_State *L )
|
||||||
{
|
{
|
||||||
p->StoreRankingName(Enum::Check<PlayerNumber>(L, 1), SArg(2));
|
p->StoreRankingName(Enum::Check<PlayerNumber>(L, 1), SArg(2));
|
||||||
@@ -2703,6 +2709,7 @@ public:
|
|||||||
ADD_METHOD( SaveProfiles );
|
ADD_METHOD( SaveProfiles );
|
||||||
ADD_METHOD( HaveProfileToLoad );
|
ADD_METHOD( HaveProfileToLoad );
|
||||||
ADD_METHOD( HaveProfileToSave );
|
ADD_METHOD( HaveProfileToSave );
|
||||||
|
ADD_METHOD( SetFailTypeExplicitlySet );
|
||||||
ADD_METHOD( StoreRankingName );
|
ADD_METHOD( StoreRankingName );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -176,7 +176,7 @@ public:
|
|||||||
|
|
||||||
BroadcastOnChange<RString> m_sPreferredSongGroup; // GROUP_ALL denotes no preferred group
|
BroadcastOnChange<RString> m_sPreferredSongGroup; // GROUP_ALL denotes no preferred group
|
||||||
BroadcastOnChange<RString> m_sPreferredCourseGroup; // GROUP_ALL denotes no preferred group
|
BroadcastOnChange<RString> m_sPreferredCourseGroup; // GROUP_ALL denotes no preferred group
|
||||||
bool m_bChangedFailTypeOnScreenSongOptions; // true if FailType was changed in the song options screen
|
bool m_bFailTypeWasExplicitlySet; // true if FailType was changed in the song options screen
|
||||||
BroadcastOnChange<StepsType> m_PreferredStepsType;
|
BroadcastOnChange<StepsType> m_PreferredStepsType;
|
||||||
BroadcastOnChange1D<Difficulty,NUM_PLAYERS> m_PreferredDifficulty;
|
BroadcastOnChange1D<Difficulty,NUM_PLAYERS> m_PreferredDifficulty;
|
||||||
BroadcastOnChange1D<CourseDifficulty,NUM_PLAYERS> m_PreferredCourseDifficulty;// used in nonstop
|
BroadcastOnChange1D<CourseDifficulty,NUM_PLAYERS> m_PreferredCourseDifficulty;// used in nonstop
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ void ScreenSongOptions::ExportOptions( int iRow, const vector<PlayerNumber> &vpn
|
|||||||
ScreenOptionsMaster::ExportOptions( iRow, vpns );
|
ScreenOptionsMaster::ExportOptions( iRow, vpns );
|
||||||
|
|
||||||
if( ft != pPS->m_PlayerOptions.GetPreferred().m_FailType )
|
if( ft != pPS->m_PlayerOptions.GetPreferred().m_FailType )
|
||||||
GAMESTATE->m_bChangedFailTypeOnScreenSongOptions = true;
|
{
|
||||||
|
GAMESTATE->m_bFailTypeWasExplicitlySet = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user