From 38ea269a10037597d9ca4a061e3296b9f54fbbdc Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Mon, 13 Jun 2011 01:39:23 -0500 Subject: [PATCH] [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;