From d8e1296b5b6cc5f5203e4283ba894da2bf17e5b5 Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Mon, 13 Jun 2011 13:32:28 -0500 Subject: [PATCH 1/2] [LifeMeterBattery] Added ChangeLives(int) Lua binding. --- Docs/Changelog_sm5.txt | 1 + src/LifeMeterBattery.cpp | 11 ++++++++++- src/LifeMeterBattery.h | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Docs/Changelog_sm5.txt b/Docs/Changelog_sm5.txt index 264971b4ca..cbfd608628 100644 --- a/Docs/Changelog_sm5.txt +++ b/Docs/Changelog_sm5.txt @@ -10,6 +10,7 @@ StepMania 5.0 Preview 2 | 20110??? 2011/06/13 ---------- +* [LifeMeterBattery] Added ChangeLives(int) Lua binding. [AJ] * [LifeMeterBattery] Added DangerThreshold metric. [AJ] * [LifeMeterBattery] Added some important metrics. [AJ] * MinScoreToKeepLife='TapNoteScore_*' - any score below this = loss of life. diff --git a/src/LifeMeterBattery.cpp b/src/LifeMeterBattery.cpp index a638420fbf..20f42ff4e7 100644 --- a/src/LifeMeterBattery.cpp +++ b/src/LifeMeterBattery.cpp @@ -137,6 +137,14 @@ void LifeMeterBattery::AddLives( int iLives ) m_fBatteryBlinkTime = 0; } +void LifeMeterBattery::ChangeLives(int iLifeDiff) +{ + if( iLifeDiff < 0 ) + SubtractLives( abs(iLifeDiff) ); + else if( iLifeDiff > 0 ) + AddLives(iLifeDiff); +} + void LifeMeterBattery::ChangeLife( TapNoteScore score ) { if( m_iLivesLeft == 0 ) @@ -254,13 +262,14 @@ class LunaLifeMeterBattery: public Luna { public: static int GetLivesLeft( T* p, lua_State *L ) { lua_pushnumber( L, p->GetLivesLeft() ); return 1; } - // is this right? wtf -q2x static int GetTotalLives( T* p, lua_State *L ) { lua_pushnumber( L, GAMESTATE->m_SongOptions.GetSong().m_iBatteryLives ); return 1; } + static int ChangeLives( T* p, lua_State *L ) { p->ChangeLives(IArg(1)); return 0; } LunaLifeMeterBattery() { ADD_METHOD( GetLivesLeft ); ADD_METHOD( GetTotalLives ); + ADD_METHOD( ChangeLives ); } }; diff --git a/src/LifeMeterBattery.h b/src/LifeMeterBattery.h index a6d50a0319..648811a9fc 100644 --- a/src/LifeMeterBattery.h +++ b/src/LifeMeterBattery.h @@ -32,6 +32,7 @@ public: void Refresh(); int GetLivesLeft() { return m_iLivesLeft; } + void ChangeLives(int iLifeDiff); // Lua virtual void PushSelf( lua_State *L ); From 6e19262e2929e81037cb50f798f07438782080f3 Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Mon, 13 Jun 2011 13:39:37 -0500 Subject: [PATCH 2/2] fix this ScreenString debacle once and for all --- Themes/_fallback/Scripts/01 alias.lua | 10 +--------- Themes/_fallback/Scripts/01 compat.lua | 9 --------- Themes/_fallback/Scripts/02 Other.lua | 2 ++ 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/Themes/_fallback/Scripts/01 alias.lua b/Themes/_fallback/Scripts/01 alias.lua index e0e3841f07..05935425bf 100644 --- a/Themes/_fallback/Scripts/01 alias.lua +++ b/Themes/_fallback/Scripts/01 alias.lua @@ -20,12 +20,4 @@ local _screen = { h = SCREEN_HEIGHT, cx = SCREEN_CENTER_X, cy = SCREEN_CENTER_Y -} - -if Screen.String then - ScreenString = Screen.String -end - -if Screen.Metric then - ScreenMetric = Screen.Metric -end \ No newline at end of file +} \ No newline at end of file diff --git a/Themes/_fallback/Scripts/01 compat.lua b/Themes/_fallback/Scripts/01 compat.lua index 36b5327aa2..4103cc9dbc 100644 --- a/Themes/_fallback/Scripts/01 compat.lua +++ b/Themes/_fallback/Scripts/01 compat.lua @@ -56,15 +56,6 @@ function ActorScroller:setfastcatchup(bFastCatchup) self:SetFastCatchup(bFastCatchup) end --- renaming various StepMania functions to sm-ssc ones: -if ScreenString then - ScreenString = Screen.String -end - -if ScreenMetric then - ScreenMetric = Screen.Metric -end - --[[ GameState ]] --Aliases for old GAMESTATE timing functions. --These have been converted to SongPosition, but most themes still use these old functions. diff --git a/Themes/_fallback/Scripts/02 Other.lua b/Themes/_fallback/Scripts/02 Other.lua index ea544d1dd4..91f81f06e1 100644 --- a/Themes/_fallback/Scripts/02 Other.lua +++ b/Themes/_fallback/Scripts/02 Other.lua @@ -102,11 +102,13 @@ Screen.Metric = function ( sName ) local sClass = Var "LoadingScreen" return THEME:GetMetric( sClass, sName ) end +ScreenMetric = Screen.Metric Screen.String = function ( sName ) local sClass = Var "LoadingScreen"; return THEME:GetString( sClass, sName ) end +ScreenString = Screen.String function TextBannerAfterSet(self,param) local Title=self:GetChild("Title");