From 18f7dea5f9c4667d03da4eaee480a5d1d9d1214c Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Sun, 27 Feb 2011 18:36:05 -0600 Subject: [PATCH 1/5] [PlayerState] The old GetPlayerOptions() binding is now GetPlayerOptionsString(). There is a new GetPlayerOptions() binding that gets the PlayerOptions object, which has a GetNoteSkin() binding (and hopefully more in the future). --- Docs/Changelog_sm-ssc.txt | 6 ++++++ src/PlayerOptions.cpp | 18 ++++++++++++++++++ src/PlayerOptions.h | 5 ++++- src/PlayerState.cpp | 12 ++++++++++-- src/PlayerState.h | 6 +++++- 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/Docs/Changelog_sm-ssc.txt b/Docs/Changelog_sm-ssc.txt index 9f28860874..37608ac651 100644 --- a/Docs/Changelog_sm-ssc.txt +++ b/Docs/Changelog_sm-ssc.txt @@ -13,6 +13,12 @@ _____________________________________________________________________________ sm-ssc v1.2.3 | 2011022? -------------------------------------------------------------------------------- +20110227 +-------- +* [PlayerState] The old GetPlayerOptions() binding is now GetPlayerOptionsString(). + There is a new GetPlayerOptions() binding that gets the PlayerOptions object, + which has a GetNoteSkin() binding (and hopefully more in the future). [AJ] + 20110226 -------- * [ScreenOptionsToggleSongs] The structure of this screen has now changed. diff --git a/src/PlayerOptions.cpp b/src/PlayerOptions.cpp index 87352f4233..d55d068249 100644 --- a/src/PlayerOptions.cpp +++ b/src/PlayerOptions.cpp @@ -823,6 +823,24 @@ void PlayerOptions::ResetPrefs( ResetPrefsType type ) #undef CPY } +// lua start +#include "LuaBinding.h" + +/** @brief Allow Lua to have access to PlayerOptions. */ +class LunaPlayerOptions: public Luna +{ +public: + DEFINE_METHOD( GetNoteSkin, m_sNoteSkin ) + + LunaPlayerOptions() + { + ADD_METHOD( GetNoteSkin ); + } +}; + +LUA_REGISTER_CLASS( PlayerOptions ) +// lua end + /* * (c) 2001-2004 Chris Danford, Glenn Maynard * All rights reserved. diff --git a/src/PlayerOptions.h b/src/PlayerOptions.h index f6df9e2eff..b7a9ee7957 100644 --- a/src/PlayerOptions.h +++ b/src/PlayerOptions.h @@ -5,6 +5,7 @@ class Course; class Song; class Steps; class Trail; +struct lua_State; #include "GameConstantsAndTypes.h" #include "PlayerNumber.h" @@ -32,6 +33,9 @@ public: void ChooseRandomModifiers(); bool ContainsTransformOrTurn() const; + // Lua + void PushSelf( lua_State *L ); + bool operator==( const PlayerOptions &other ) const; bool operator!=( const PlayerOptions &other ) const { return !operator==(other); } @@ -188,7 +192,6 @@ public: void SetOneScroll( Scroll s ); void ToggleOneTurn( Turn t ); - // return true if any mods being used will make the song(s) easier bool IsEasierForSongAndSteps( Song* pSong, Steps* pSteps, PlayerNumber pn ) const; bool IsEasierForCourseAndTrail( Course* pCourse, Trail* pTrail ) const; diff --git a/src/PlayerState.cpp b/src/PlayerState.cpp index aa512ecbaf..2525c60872 100644 --- a/src/PlayerState.cpp +++ b/src/PlayerState.cpp @@ -210,8 +210,8 @@ public: static int GetPlayerOptions( T* p, lua_State *L ) { ModsLevel m = Enum::Check( L, 1 ); - RString s = p->m_PlayerOptions.Get(m).GetString(); - LuaHelpers::Push( L, s ); + PlayerOptions po = p->m_PlayerOptions.Get(m); + po.PushSelf(L); return 1; } static int GetPlayerOptionsArray( T* p, lua_State *L ) @@ -222,6 +222,13 @@ public: LuaHelpers::CreateTableFromArray( s, L ); return 1; } + static int GetPlayerOptionsString( T* p, lua_State *L ) + { + ModsLevel m = Enum::Check( L, 1 ); + RString s = p->m_PlayerOptions.Get(m).GetString(); + LuaHelpers::Push( L, s ); + return 1; + } DEFINE_METHOD( GetHealthState, m_HealthState ); LunaPlayerState() @@ -231,6 +238,7 @@ public: ADD_METHOD( SetPlayerOptions ); ADD_METHOD( GetPlayerOptions ); ADD_METHOD( GetPlayerOptionsArray ); + ADD_METHOD( GetPlayerOptionsString ); ADD_METHOD( GetHealthState ); } }; diff --git a/src/PlayerState.h b/src/PlayerState.h index e023bb7df0..06bd6acb35 100644 --- a/src/PlayerState.h +++ b/src/PlayerState.h @@ -31,7 +31,11 @@ public: * in PlayerState and callers should not use PlayerNumber to index into * GameState. */ PlayerNumber m_PlayerNumber; - + /** + * @brief The MultiPlayer number assigned to this Player, typically 1-32. + * + * This is only used if GAMESTATE->m_bMultiplayer is true. + */ MultiPlayer m_mp; /** From 6061d5c08e360a6156774b05f5b9e649881aac46 Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Sun, 27 Feb 2011 18:36:41 -0600 Subject: [PATCH 2/5] commenting --- src/ArrowEffects.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ArrowEffects.cpp b/src/ArrowEffects.cpp index f19cf6f40f..81fed4db5d 100644 --- a/src/ArrowEffects.cpp +++ b/src/ArrowEffects.cpp @@ -15,7 +15,10 @@ #include static ThemeMetric ARROW_SPACING( "ArrowEffects", "ArrowSpacing" ); +static ThemeMetric QUANTIZE_ARROW_Y( "ArrowEffects", "QuantizeArrowYPosition"); static ThemeMetric HIDDEN_SUDDEN_PAST_RECEPTOR( "ArrowEffects", "DrawHiddenNotesAfterReceptor"); + +// Allow themes to modify effects. (Is this a good idea? -aj) static ThemeMetric BLINK_MOD_FREQUENCY( "ArrowEffects", "BlinkModFrequency" ); static ThemeMetric BOOST_MOD_MIN_CLAMP( "ArrowEffects", "BoostModMinClamp" ); static ThemeMetric BOOST_MOD_MAX_CLAMP( "ArrowEffects", "BoostModMaxClamp" ); @@ -50,7 +53,6 @@ static ThemeMetric BEAT_OFFSET_HEIGHT( "ArrowEffects", "BeatOffsetHeight" static ThemeMetric BEAT_PI_HEIGHT( "ArrowEffects", "BeatPIHeight" ); static ThemeMetric MINI_PERCENT_BASE( "ArrowEffects", "MiniPercentBase" ); static ThemeMetric MINI_PERCENT_GATE( "ArrowEffects", "MiniPercentGate" ); -static ThemeMetric QUANTIZE_ARROW_Y( "ArrowEffects", "QuantizeArrowYPosition"); static float GetNoteFieldHeight( const PlayerState* pPlayerState ) { @@ -231,6 +233,8 @@ float ArrowEffects::GetYOffset( const PlayerState* pPlayerState, int iCol, float fYOffset += fYOffsetTimeSpacing * pPlayerState->m_PlayerOptions.GetCurrent().m_fTimeSpacing; } + // TODO: If we allow noteskins to have metricable row spacing + // (per issue 24), edit this to reflect that. -aj fYOffset *= ARROW_SPACING; // don't mess with the arrows after they've crossed 0 @@ -287,8 +291,8 @@ float ArrowEffects::GetYOffset( const PlayerState* pPlayerState, int iCol, float seed = ((seed * 1664525u) + 1013904223u) & 0xFFFFFFFF; float fRandom = seed / 4294967296.0f; - /* Random speed always increases speed: a random speed of 10 indicates [1,11]. - * This keeps it consistent with other mods: 0 means no effect. */ + /* Random speed always increases speed: a random speed of 10 indicates + * [1,11]. This keeps it consistent with other mods: 0 means no effect. */ fScrollSpeed *= SCALE( fRandom, 0.0f, 1.0f, From 77a57d5db32eac575e4852a7c839d34c2f3225e2 Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Sun, 27 Feb 2011 18:37:00 -0600 Subject: [PATCH 3/5] update comment --- src/PlayerStageStats.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PlayerStageStats.cpp b/src/PlayerStageStats.cpp index d1b0e08d4a..bf3e5baba9 100644 --- a/src/PlayerStageStats.cpp +++ b/src/PlayerStageStats.cpp @@ -187,7 +187,7 @@ Grade PlayerStageStats::GetGrade() const //LOG->Trace( "GetGrade: Grade: %s, %i", GradeToString(grade).c_str(), GRADE_TIER02_IS_ALL_W2S ); - // todo: move all these conditions to Lua. -aj + // TODO: Change these conditions to use Lua instead. -aj if( GRADE_TIER02_IS_ALL_W2S ) { if( FullComboOfScore(TNS_W1) ) From b0e0097bbc59090abde25ab890ad055dd21992c0 Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Sun, 27 Feb 2011 18:37:40 -0600 Subject: [PATCH 4/5] cleanup/comment stuff --- src/GameState.h | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/GameState.h b/src/GameState.h index 89de4c05dc..8c404da28b 100644 --- a/src/GameState.h +++ b/src/GameState.h @@ -78,9 +78,9 @@ public: * the three credits needed to begin the game. */ BroadcastOnChange m_iCoins; /** @brief The player number used with Styles where one player controls both sides. */ - PlayerNumber m_MasterPlayerNumber; - bool m_bMultiplayer; - int m_iNumMultiplayerNoteFields; + PlayerNumber m_MasterPlayerNumber; + bool m_bMultiplayer; + int m_iNumMultiplayerNoteFields; bool DifficultiesLocked() const; bool ChangePreferredDifficultyAndStepsType( PlayerNumber pn, Difficulty dc, StepsType st ); bool ChangePreferredDifficulty( PlayerNumber pn, int dir ); @@ -90,24 +90,24 @@ public: Difficulty GetClosestShownDifficulty( PlayerNumber pn ) const; Difficulty GetEasiestStepsDifficulty() const; Difficulty GetHardestStepsDifficulty() const; - RageTimer m_timeGameStarted; // from the moment the first player pressed Start - LuaTable *m_Environment; + RageTimer m_timeGameStarted; // from the moment the first player pressed Start + LuaTable *m_Environment; // This is set to a random number per-game/round; it can be used for a random seed. - int m_iGameSeed, m_iStageSeed; - RString m_sStageGUID; + int m_iGameSeed, m_iStageSeed; + RString m_sStageGUID; /** * @brief Determine if a second player can join in at this time. * @return true if a player can still enter the game, false otherwise. */ - bool PlayersCanJoin() const; - int GetCoinsNeededToJoin() const; - bool EnoughCreditsToJoin() const { return m_iCoins >= GetCoinsNeededToJoin(); } + bool PlayersCanJoin() const; + int GetCoinsNeededToJoin() const; + bool EnoughCreditsToJoin() const { return m_iCoins >= GetCoinsNeededToJoin(); } int GetNumSidesJoined() const; const Game* GetCurrentGame(); const Style* GetCurrentStyle() const; - void SetCurrentStyle( const Style *pStyle ); + void SetCurrentStyle( const Style *pStyle ); void GetPlayerInfo( PlayerNumber pn, bool& bIsEnabledOut, bool& bIsHumanOut ); bool IsPlayerEnabled( PlayerNumber pn ) const; @@ -129,17 +129,17 @@ public: BroadcastOnChange m_sPreferredSongGroup; // GROUP_ALL denotes no preferred group BroadcastOnChange m_sPreferredCourseGroup; // GROUP_ALL denotes no preferred group - bool m_bChangedFailTypeOnScreenSongOptions; // true if FailType was changed in the song options screen + bool m_bChangedFailTypeOnScreenSongOptions; // true if FailType was changed in the song options screen BroadcastOnChange m_PreferredStepsType; BroadcastOnChange1D m_PreferredDifficulty; BroadcastOnChange1D m_PreferredCourseDifficulty;// used in nonstop BroadcastOnChange m_SortOrder; // set by MusicWheel - SortOrder m_PreferredSortOrder; // used by MusicWheel - EditMode m_EditMode; - bool IsEditing() const { return m_EditMode != EditMode_Invalid; } - bool m_bDemonstrationOrJukebox; // ScreenGameplay does special stuff when this is true - bool m_bJukeboxUsesModifiers; - int m_iNumStagesOfThisSong; + SortOrder m_PreferredSortOrder; // used by MusicWheel + EditMode m_EditMode; + bool IsEditing() const { return m_EditMode != EditMode_Invalid; } + bool m_bDemonstrationOrJukebox; // ScreenGameplay does special stuff when this is true + bool m_bJukeboxUsesModifiers; + int m_iNumStagesOfThisSong; /** * @brief Increase this every stage while not resetting on a continue. * @@ -159,8 +159,8 @@ public: void CancelStage(); void CommitStageStats(); void FinishStage(); - int GetNumStagesLeft( PlayerNumber pn ) const; - int GetSmallestNumStagesLeftForAnyHumanPlayer() const; + int GetNumStagesLeft( PlayerNumber pn ) const; + int GetSmallestNumStagesLeftForAnyHumanPlayer() const; bool IsFinalStageForAnyHumanPlayer() const; bool IsAnExtraStage() const; bool IsAnExtraStageAndSelectionLocked() const; @@ -173,7 +173,6 @@ public: bool m_bLoadingNextSong; int GetLoadingCourseSongIndex() const; - // State Info used during gameplay // NULL on ScreenSelectMusic if the currently selected wheel item isn't a Song. @@ -212,17 +211,14 @@ public: BroadcastOnChange m_bGameplayLeadIn; // Metricable noteskin things + //void LoadNoteSkinMetrics( PlayerNumber pn ); /* - void LoadNoteSkinMetrics( PlayerNumber pn ); int m_iNoteSkinColSpacing[NUM_PLAYERS]; int m_iNoteSkinArrowSize[NUM_PLAYERS]; */ // not sure I want to let noteskins change row spacing, as that changes how // the speed mods work... -aj //int m_iNoteSkinRowSpacing[NUM_PLAYERS]; - // what are these for, exactly? -aj - //bool m_bNoteSkinOverrideDim[NUM_PLAYERS]; - //bool m_bNoteSkinOverrideBright[NUM_PLAYERS]; float m_fMusicSecondsVisible; float m_fSongBeatVisible; From d404736c338df97c7fa85cc6e7a8474e7319bf6a Mon Sep 17 00:00:00 2001 From: Jonathan Payne Date: Sun, 27 Feb 2011 16:47:20 -0800 Subject: [PATCH 5/5] fixing stuff. --- Themes/_fallback/Languages/en.ini | 6 ++- Themes/_fallback/Scripts/02 Utilities.lua | 16 ++++++ .../Scripts/03 ThemeAndGamePrefs.lua | 53 ++++++++++++++++++- Themes/_fallback/metrics.ini | 3 +- .../ScreenEvaluation overlay/default.lua | 12 ++++- 5 files changed, 84 insertions(+), 6 deletions(-) diff --git a/Themes/_fallback/Languages/en.ini b/Themes/_fallback/Languages/en.ini index 735d4cca65..f7c61ddf24 100644 --- a/Themes/_fallback/Languages/en.ini +++ b/Themes/_fallback/Languages/en.ini @@ -476,7 +476,8 @@ Play=Play the course. Save=Save the course. Edit Course=Edit Course contents. Shuffle=Shuffle the songs around. - +# +GamePrefDefaultFail=Immediate fail causes a player to die when their life bar reaches 0. ImmediateContinue allows you to continue playing afterwards. [OptionNames] 0=0 0.25x=0.25x @@ -1036,7 +1037,8 @@ Max Minutes=Max Minutes Play=Play Edit Course=Edit Course Shuffle=Shuffle - +# +GamePrefDefaultFail=Default Fail Type [PaneDisplay] Steps=Steps Holds=Holds diff --git a/Themes/_fallback/Scripts/02 Utilities.lua b/Themes/_fallback/Scripts/02 Utilities.lua index 31f5384db0..616b14ea21 100644 --- a/Themes/_fallback/Scripts/02 Utilities.lua +++ b/Themes/_fallback/Scripts/02 Utilities.lua @@ -123,6 +123,22 @@ function table.deviation( t ) end return offset end +-- See if this exists +function table.search( t, sFind ) + for i=1,#t do + if t[i] == sFind then + return true + end + end +end +-- Retreive the entry that has this +function table.find( t, sFind ) + for i=1,#t do + if t[i] == sFind then + return i + end + end +end function round(val, decimal) if (decimal) then diff --git a/Themes/_fallback/Scripts/03 ThemeAndGamePrefs.lua b/Themes/_fallback/Scripts/03 ThemeAndGamePrefs.lua index 7d20bef84f..6c5cddd245 100644 --- a/Themes/_fallback/Scripts/03 ThemeAndGamePrefs.lua +++ b/Themes/_fallback/Scripts/03 ThemeAndGamePrefs.lua @@ -1,6 +1,11 @@ -- sm-ssc Default Theme Preferences Handler function InitGamePrefs() - local Prefs = + local Prefs = + { + { "DefaultFail", "Immediate" }, + }; + + local BPrefs = { { "AutoSetStyle", false }, { "NotePosition", true }, @@ -9,6 +14,12 @@ function InitGamePrefs() }; for idx,pref in ipairs(Prefs) do + if GetGamePref( pref[1] ) == nil then + SetGamePref( pref[1], pref[2] ); + end; + end; + + for idx,pref in ipairs(BPrefs) do if GetGamePrefB( pref[1] ) == nil then SetGamePref( pref[1], pref[2] ); end; @@ -456,3 +467,43 @@ function GamePrefNotePosition() setmetatable( t, t ); return t; end + +function GamePrefDefaultFail() + local t = { + Name = "GamePrefDefaultFail"; + LayoutType = "ShowAllInRow"; + SelectType = "SelectOne"; + OneChoiceForAllPlayers = true; + ExportOnChange = false; + Choices = { "Immediate","ImmediateContinue", "AtEnd", "Off" }; + LoadSelections = function(self, list, pn) + if ReadGamePrefFromFile("DefaultFail") ~= nil then + if GetGamePref("DefaultFail") then + list[table.find( list, GetGamePref("DefaultFail") )] = true; + else + list[1] = true; + end; + else + WriteGamePrefToFile("DefaultFail","Immediate"); + list[1] = true; + end; + end; + SaveSelections = function(self, list, pn) + -- This is so stupid. + local tChoices = { "Immediate","ImmediateContinue", "AtEnd", "Off" }; + local val; + for i=1,#list do + if list[i] then + val = i; + else + val = 1; + end + end + WriteGamePrefToFile("DefaultFail",tChoices[val]); + MESSAGEMAN:Broadcast("PreferenceSet", { Message == "Set Preference" } ); + THEME:ReloadMetrics(); + end; + }; + setmetatable( t, t ); + return t; +end diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index bfc0d6b4b6..0fbff822c0 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -2732,7 +2732,8 @@ LineNames="2,3,4,8,11,13,14,15,16,28,29,30" Line2="conf,ScoringType" Line3="conf,TimingWindowScale" Line4="conf,LifeDifficulty" -Line8="conf,DefaultFailType" +Line8="lua,GamePrefDefaultFail()" +# Line8="conf,DefaultFailType" Line11="conf,AllowW1" Line13="conf,HiddenSongs" Line14="conf,EasterEggs" diff --git a/Themes/default/BGAnimations/ScreenEvaluation overlay/default.lua b/Themes/default/BGAnimations/ScreenEvaluation overlay/default.lua index 8bf1f85bb4..a8620aed20 100644 --- a/Themes/default/BGAnimations/ScreenEvaluation overlay/default.lua +++ b/Themes/default/BGAnimations/ScreenEvaluation overlay/default.lua @@ -33,7 +33,7 @@ local function CreateStats( pnPlayer ) -- local t = Def.ActorFrame {}; t[#t+1] = Def.ActorFrame { - InitCommand=cmd(y,-16); + InitCommand=cmd(y,-32); LoadActor(THEME:GetPathG("ScreenTitleMenu","PreferenceFrame")) .. { InitCommand=cmd(zoom,0.875;diffuse,PlayerColor( pnPlayer )); }; @@ -43,7 +43,7 @@ local function CreateStats( pnPlayer ) aText .. { Text=string.format("%04i",tValues["ITG_MAX"]); InitCommand=cmd(x,32;y,5;vertalign,bottom;zoom,0.5); }; }; t[#t+1] = Def.ActorFrame { - InitCommand=cmd(y,16); + InitCommand=cmd(y,-16); LoadActor(THEME:GetPathG("ScreenTitleMenu","PreferenceFrame")) .. { InitCommand=cmd(zoom,0.875;diffuse,PlayerColor( pnPlayer )); }; @@ -52,6 +52,14 @@ local function CreateStats( pnPlayer ) aText .. { Text="/"; InitCommand=cmd(x,28;y,5;vertalign,bottom;zoom,0.5;diffusealpha,0.5); }; aText .. { Text=string.format("%04i",tValues["MIGS_MAX"]); InitCommand=cmd(x,32;y,5;vertalign,bottom;zoom,0.5); }; }; + t[#t+1] = Def.ActorFrame { + InitCommand=cmd(y,0); + LoadActor(THEME:GetPathG("ScreenTitleMenu","PreferenceFrame")) .. { + InitCommand=cmd(zoom,0.875;diffuse,PlayerColor( pnPlayer )); + }; + aLabel .. { Text="Signed:"; InitCommand=cmd(x,-64) }; + aText .. { Text=string.format( #(tPlayerData[PLAYER_1].SignedJudgments) ); InitCommand=cmd(x,-8;y,5;vertalign,bottom;zoom,0.675); }; + }; return t end; local t = Def.ActorFrame {};