From e27e971b9425aff6fc9fe9962fb973dcda95272d Mon Sep 17 00:00:00 2001 From: Andrew Livy Date: Mon, 18 May 2009 20:14:33 +0000 Subject: [PATCH] Adds metric options to flash the lifebar when a note is hit and a function for sprite to set all the delays in all of the states in one shot. --- stepmania/Themes/default/metrics.ini | 2 ++ stepmania/src/LifeMeterBar.cpp | 9 +++++++++ stepmania/src/LifeMeterBar.h | 3 +++ stepmania/src/Sprite.cpp | 8 ++++++++ stepmania/src/Sprite.h | 2 ++ stepmania/src/StreamDisplay.cpp | 10 ++++++++-- 6 files changed, 32 insertions(+), 2 deletions(-) diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 6b9af8528e..a8fad0aced 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -1792,6 +1792,8 @@ InitialValue=0.5 HotValue=1.0 LifeMultiplier=1.0 MinStayAlive="TapNoteScore_W3" +FlashHotOnNoteHit=false +MinScoreToFlash="TapNoteScore_W3" LifePercentChangeW1=0.008 LifePercentChangeW2=0.008 LifePercentChangeW3=0.004 diff --git a/stepmania/src/LifeMeterBar.cpp b/stepmania/src/LifeMeterBar.cpp index 495ba479ba..f89de5009c 100644 --- a/stepmania/src/LifeMeterBar.cpp +++ b/stepmania/src/LifeMeterBar.cpp @@ -27,8 +27,12 @@ LifeMeterBar::LifeMeterBar() MIN_STAY_ALIVE.Load ("LifeMeterBar","MinStayAlive"); m_fLifePercentChange.Load( "LifeMeterBar", LIFE_PERCENT_CHANGE_NAME, NUM_ScoreEvent ); + FLASH_HOT_ON_NOTE_HIT.Load("LifeMeterBar","FlashHotOnNoteHit"); + MIN_SCORE_TO_FLASH.Load("LifeMeterBar","MinScoreToFlash"); + m_pPlayerState = NULL; + switch( GAMESTATE->m_SongOptions.GetStage().m_DrainType ) { case SongOptions::DRAIN_NORMAL: @@ -125,6 +129,11 @@ void LifeMeterBar::ChangeLife( TapNoteScore score ) case TNS_CheckpointHit: fDeltaLife = m_fLifePercentChange.GetValue(SE_CheckpointHit); break; case TNS_CheckpointMiss:fDeltaLife = m_fLifePercentChange.GetValue(SE_CheckpointMiss); break; } + + if(FLASH_HOT_ON_NOTE_HIT) + if(score >= MIN_SCORE_TO_FLASH) + m_fHotAlpha = 1.0f; // flash the hot temporarily + if( IsHot() && fDeltaLife < 0 ) fDeltaLife = min( fDeltaLife, -0.10f ); // make it take a while to get back to "hot" diff --git a/stepmania/src/LifeMeterBar.h b/stepmania/src/LifeMeterBar.h index f1ed08ea50..244078b3af 100644 --- a/stepmania/src/LifeMeterBar.h +++ b/stepmania/src/LifeMeterBar.h @@ -59,6 +59,9 @@ private: int m_iMissCombo; // current number of progressive W5/miss int m_iComboToRegainLife; // combo needed before lifebar starts filling up after fail + + ThemeMetric MIN_SCORE_TO_FLASH; + ThemeMetric FLASH_HOT_ON_NOTE_HIT; }; #endif diff --git a/stepmania/src/Sprite.cpp b/stepmania/src/Sprite.cpp index 66ab354f91..8ff407244e 100644 --- a/stepmania/src/Sprite.cpp +++ b/stepmania/src/Sprite.cpp @@ -70,6 +70,14 @@ void Sprite::InitState() m_bSkipNextUpdate = true; } +void Sprite::SetAllStateDelays(float fDelay) +{ + for(unsigned int i=0;iLoad( THEME->GetPathG(sMetricsGroup,ssprintf("%s part%d",StreamTypeToString(st).c_str(),i) ) ); + + if(pSpr->GetNumStates() > 1) + { + pSpr->SetAllStateDelays(THEME->GetMetricF(sMetricsGroup,ssprintf("%spart%ddelay",StreamTypeToString(st).c_str(),i))); + } + } else pSpr->Load( THEME->GetPathG(sMetricsGroup,StreamTypeToString(st)) ); m_vpSprPill[st].push_back( pSpr ); @@ -67,9 +74,8 @@ void StreamDisplay::Load( const RString &_sMetricsGroup ) if(m_bUsingThreePart) { m_fThreePartWidth = THEME->GetMetricF(sMetricsGroup,"ThreePartWidth"); - float fCroppedWidthRight = (1-m_vpSprPill[st][0]->GetCropRight())*m_vpSprPill[st][0]->GetZoomedWidth(); // first element positioned depending on metric width specified - m_vpSprPill[st][0]->AddX(-(m_fThreePartWidth/2 + m_vpSprPill[st][0]->GetZoomedWidth()/2) + fCroppedWidthRight); + m_vpSprPill[st][0]->AddX(-(m_fThreePartWidth/2 + m_vpSprPill[st][0]->GetZoomedWidth()/2)); } } }