From 38ea269a10037597d9ca4a061e3296b9f54fbbdc Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Mon, 13 Jun 2011 01:39:23 -0500 Subject: [PATCH 1/3] [LifeMeterBattery] Added some metrics that allow anyone to change how the battery meter handles lives. * MinScoreToKeepLife='TapNoteScore_*' - any score below this = loss of life. * SubtractLives=1 - how many lives are lost when going below MinScoreToKeepLife. * MinesSubtractLives=1 - how many lives are lost when hitting a mine. * HeldAddLives=0 - how many lives are gained when a hold is completed. * LetGoSubtractLives=1 - how many lives are lost on a dropped hold. --- Docs/Changelog_sm5.txt | 9 ++++ Themes/_fallback/metrics.ini | 13 +++++- src/LifeMeterBattery.cpp | 88 +++++++++++++++++++----------------- src/LifeMeterBattery.h | 10 +++- 4 files changed, 77 insertions(+), 43 deletions(-) diff --git a/Docs/Changelog_sm5.txt b/Docs/Changelog_sm5.txt index f7ae75008c..26f97b8b44 100644 --- a/Docs/Changelog_sm5.txt +++ b/Docs/Changelog_sm5.txt @@ -8,6 +8,15 @@ ________________________________________________________________________________ StepMania 5.0 Preview 2 | 20110??? -------------------------------------------------------------------------------- +2011/06/13 +---------- +* [LifeMeterBattery] Added some important metrics. [AJ] + * MinScoreToKeepLife='TapNoteScore_*' - any score below this = loss of life. + * SubtractLives=1 - how many lives are lost when going below MinScoreToKeepLife. + * MinesSubtractLives=1 - how many lives are lost when hitting a mine. + * HeldAddLives=0 - how many lives are gained when a hold is completed. + * LetGoSubtractLives=1 - how many lives are lost on a dropped hold. + 2011/06/12 ---------- * [ScreenNetSelectMusic] Add PlayerOptionsScreen metric. [AJ] diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index e7a253f235..d7f2f0cf9a 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -606,6 +606,16 @@ OverY=0 [LifeMeterBattery] # The bar that shows up in Oni mode. +# any score below this one will cause you to lose a life. +MinScoreToKeepLife='TapNoteScore_W3' +# how many lives you'll lose upon doing so. +SubtractLives=1 +# how many lives you'll lose hitting a mine +MinesSubtractLives=1 +# how many lives a successful hold will net you. +HeldAddLives=0 +# how many lives an unsuccessful hold will cost you. +LetGoSubtractLives=1 # How long it flashes when you lose a life. BatteryBlinkTime=1.2 @@ -614,7 +624,8 @@ BatteryP1X=-92 BatteryP1Y=2 BatteryP2X=92 BatteryP2Y=2 -# Where your live count is +# Where your life count is +NumLivesFormat="x%d" NumLivesP1X=-92 NumLivesP1Y=0 NumLivesP2X=92 diff --git a/src/LifeMeterBattery.cpp b/src/LifeMeterBattery.cpp index 009d920e50..92049ee2cc 100644 --- a/src/LifeMeterBattery.cpp +++ b/src/LifeMeterBattery.cpp @@ -26,6 +26,13 @@ void LifeMeterBattery::Load( const PlayerState *pPlayerState, PlayerStageStats * const RString sType = "LifeMeterBattery"; PlayerNumber pn = pPlayerState->m_PlayerNumber; + MIN_SCORE_TO_KEEP_LIFE.Load(sType, "MinScoreToKeepLife"); + SUBTRACT_LIVES.Load(sType, "SubtractLives"); + MINES_SUBTRACT_LIVES.Load(sType, "MinesSubtractLives"); + HELD_ADD_LIVES.Load(sType, "HeldAddLives"); + LET_GO_SUBTRACT_LIVES.Load(sType, "LetGoSubtractLives"); + + LIVES_FORMAT.Load(sType, "NumLivesFormat"); BATTERY_BLINK_TIME.Load(sType, "BatteryBlinkTime"); // 1.2f by default bool bPlayerEnabled = GAMESTATE->IsPlayerEnabled( pPlayerState ); @@ -101,42 +108,46 @@ void LifeMeterBattery::OnSongEnded() Refresh(); } +void LifeMeterBattery::SubtractLives( int iLives ) +{ + m_iTrailingLivesLeft = m_iLivesLeft; + m_iLivesLeft -= iLives; + m_soundLoseLife.Play(); + + m_textNumLives.PlayCommand("LoseLife"); + /* + m_textNumLives.SetZoom( 1.5f ); + m_textNumLives.BeginTweening( 0.15f ); + m_textNumLives.SetZoom( 1.0f ); + */ + + Refresh(); + m_fBatteryBlinkTime = BATTERY_BLINK_TIME; +} + +void LifeMeterBattery::AddLives( int iLives ) +{ + m_iTrailingLivesLeft = m_iLivesLeft; + m_iLivesLeft += iLives; + m_soundGainLife.Play(); + m_textNumLives.PlayCommand("GainLife"); + + Refresh(); + m_fBatteryBlinkTime = 0; +} + void LifeMeterBattery::ChangeLife( TapNoteScore score ) { if( m_iLivesLeft == 0 ) return; - // todo: let the themer decide how this is handled. -aj - switch( score ) + // this probably doesn't handle hold checkpoints. -aj + if( score == TNS_HitMine && MINES_SUBTRACT_LIVES > 0 ) + SubtractLives(MINES_SUBTRACT_LIVES); + else { - case TNS_W1: - case TNS_W2: - case TNS_W3: - break; - case TNS_W4: - case TNS_W5: - case TNS_Miss: - case TNS_HitMine: - m_iTrailingLivesLeft = m_iLivesLeft; - m_iLivesLeft--; - m_soundLoseLife.Play(); - - m_textNumLives.PlayCommand("LoseLife"); - /* - m_textNumLives.SetZoom( 1.5f ); - m_textNumLives.BeginTweening( 0.15f ); - m_textNumLives.SetZoom( 1.0f ); - */ - - Refresh(); - m_fBatteryBlinkTime = BATTERY_BLINK_TIME; - break; - default: - break; - /* - // xxx: this doesn't handle hold checkpoints. - ASSERT(0); - */ + if( score < MIN_SCORE_TO_KEEP_LIFE && SUBTRACT_LIVES > 0 ) + SubtractLives(SUBTRACT_LIVES); } Message msg( "LifeChanged" ); @@ -148,16 +159,10 @@ void LifeMeterBattery::ChangeLife( TapNoteScore score ) void LifeMeterBattery::ChangeLife( HoldNoteScore score, TapNoteScore tscore ) { - switch( score ) - { - case HNS_Held: - break; - case HNS_LetGo: - ChangeLife( TNS_Miss ); // LetGo is the same as a miss - break; - default: - ASSERT(0); - } + if( score == HNS_Held && HELD_ADD_LIVES > 0 ) + AddLives(HELD_ADD_LIVES); + if( score == HNS_LetGo && LET_GO_SUBTRACT_LIVES > 0 ) + SubtractLives(LET_GO_SUBTRACT_LIVES); } void LifeMeterBattery::HandleTapScoreNone() @@ -208,7 +213,8 @@ void LifeMeterBattery::Refresh() } else { - m_textNumLives.SetText( ssprintf("x%d", m_iLivesLeft-1) ); + //m_textNumLives.SetText( ssprintf("x%d", m_iLivesLeft-1) ); + m_textNumLives.SetText( ssprintf(LIVES_FORMAT.GetValue(), m_iLivesLeft-1) ); m_sprBattery.SetState( 3 ); } } diff --git a/src/LifeMeterBattery.h b/src/LifeMeterBattery.h index d7b4a90a1d..30ddad877d 100644 --- a/src/LifeMeterBattery.h +++ b/src/LifeMeterBattery.h @@ -37,13 +37,21 @@ public: virtual void PushSelf( lua_State *L ); private: + void SubtractLives( int iLives ); + void AddLives( int iLives ); + int m_iLivesLeft; // dead when 0 int m_iTrailingLivesLeft; // lags m_iLivesLeft float m_fBatteryBlinkTime; // if > 0 battery is blinking - // theme metrics added for sm-ssc ThemeMetric BATTERY_BLINK_TIME; + ThemeMetric MIN_SCORE_TO_KEEP_LIFE; + ThemeMetric SUBTRACT_LIVES; + ThemeMetric MINES_SUBTRACT_LIVES; + ThemeMetric HELD_ADD_LIVES; + ThemeMetric LET_GO_SUBTRACT_LIVES; + ThemeMetric LIVES_FORMAT; AutoActor m_sprFrame; Sprite m_sprBattery; From 24644f3f231a3da1fb9e434b1dc09cb803f8601c Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Mon, 13 Jun 2011 01:56:23 -0500 Subject: [PATCH 2/3] add GainLife/LoseLife commands. --- Themes/_fallback/metrics.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index d7f2f0cf9a..fb6c138ac1 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -628,8 +628,12 @@ BatteryP2Y=2 NumLivesFormat="x%d" NumLivesP1X=-92 NumLivesP1Y=0 +NumLivesP1GainLifeCommand= +NumLivesP1LoseLifeCommand=zoom,1.5;linear,0.15;zoom,1 NumLivesP2X=92 NumLivesP2Y=0 +NumLivesP2GainLifeCommand= +NumLivesP2LoseLifeCommand=zoom,1.5;linear,0.15;zoom,1 [LifeMeterBattery Percent] # The percentage on the bar. I wouldn't even bother changing this, because I From 11c84f8c50e10e3aa746e43171239e791918b646 Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Mon, 13 Jun 2011 02:00:09 -0500 Subject: [PATCH 3/3] [LifeMeterBattery] Added DangerThreshold metric. --- Docs/Changelog_sm5.txt | 1 + Themes/_fallback/metrics.ini | 2 ++ src/LifeMeterBattery.cpp | 20 ++++++++++++-------- src/LifeMeterBattery.h | 1 + 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Docs/Changelog_sm5.txt b/Docs/Changelog_sm5.txt index 26f97b8b44..264971b4ca 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 DangerThreshold metric. [AJ] * [LifeMeterBattery] Added some important metrics. [AJ] * MinScoreToKeepLife='TapNoteScore_*' - any score below this = loss of life. * SubtractLives=1 - how many lives are lost when going below MinScoreToKeepLife. diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index fb6c138ac1..1a9b00cb5a 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -617,6 +617,8 @@ HeldAddLives=0 # how many lives an unsuccessful hold will cost you. LetGoSubtractLives=1 +# How many lives trigger the "Danger" state. +DangerThreshold=1 # How long it flashes when you lose a life. BatteryBlinkTime=1.2 # Where the batteries are diff --git a/src/LifeMeterBattery.cpp b/src/LifeMeterBattery.cpp index 92049ee2cc..a638420fbf 100644 --- a/src/LifeMeterBattery.cpp +++ b/src/LifeMeterBattery.cpp @@ -27,6 +27,7 @@ void LifeMeterBattery::Load( const PlayerState *pPlayerState, PlayerStageStats * PlayerNumber pn = pPlayerState->m_PlayerNumber; MIN_SCORE_TO_KEEP_LIFE.Load(sType, "MinScoreToKeepLife"); + DANGER_THRESHOLD.Load(sType, "DangerThreshold"); SUBTRACT_LIVES.Load(sType, "SubtractLives"); MINES_SUBTRACT_LIVES.Load(sType, "MinesSubtractLives"); HELD_ADD_LIVES.Load(sType, "HeldAddLives"); @@ -110,16 +111,13 @@ void LifeMeterBattery::OnSongEnded() void LifeMeterBattery::SubtractLives( int iLives ) { + if( iLives <= 0 ) + return; + m_iTrailingLivesLeft = m_iLivesLeft; m_iLivesLeft -= iLives; m_soundLoseLife.Play(); - m_textNumLives.PlayCommand("LoseLife"); - /* - m_textNumLives.SetZoom( 1.5f ); - m_textNumLives.BeginTweening( 0.15f ); - m_textNumLives.SetZoom( 1.0f ); - */ Refresh(); m_fBatteryBlinkTime = BATTERY_BLINK_TIME; @@ -127,6 +125,9 @@ void LifeMeterBattery::SubtractLives( int iLives ) void LifeMeterBattery::AddLives( int iLives ) { + if( iLives <= 0 ) + return; + m_iTrailingLivesLeft = m_iLivesLeft; m_iLivesLeft += iLives; m_soundGainLife.Play(); @@ -159,6 +160,9 @@ void LifeMeterBattery::ChangeLife( TapNoteScore score ) void LifeMeterBattery::ChangeLife( HoldNoteScore score, TapNoteScore tscore ) { + if( m_iLivesLeft == 0 ) + return; + if( score == HNS_Held && HELD_ADD_LIVES > 0 ) AddLives(HELD_ADD_LIVES); if( score == HNS_LetGo && LET_GO_SUBTRACT_LIVES > 0 ) @@ -176,12 +180,12 @@ void LifeMeterBattery::ChangeLife( float fDeltaLifePercent ) bool LifeMeterBattery::IsInDanger() const { - return false; + return m_iLivesLeft < DANGER_THRESHOLD; } bool LifeMeterBattery::IsHot() const { - return false; + return m_iLivesLeft == GAMESTATE->m_SongOptions.GetSong().m_iBatteryLives; } bool LifeMeterBattery::IsFailing() const diff --git a/src/LifeMeterBattery.h b/src/LifeMeterBattery.h index 30ddad877d..a6d50a0319 100644 --- a/src/LifeMeterBattery.h +++ b/src/LifeMeterBattery.h @@ -47,6 +47,7 @@ private: ThemeMetric BATTERY_BLINK_TIME; ThemeMetric MIN_SCORE_TO_KEEP_LIFE; + ThemeMetric DANGER_THRESHOLD; ThemeMetric SUBTRACT_LIVES; ThemeMetric MINES_SUBTRACT_LIVES; ThemeMetric HELD_ADD_LIVES;