From 0f6d4cd813646e4844e4d4cc2e04b085c354dfb9 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Thu, 30 Jun 2011 13:35:25 -0400 Subject: [PATCH] Adjust attacks on offset change. Should we ever store the other timing segments in seconds and not beats in the future, we may want to use this. --- src/Attack.cpp | 8 ++++++++ src/Attack.h | 5 +++++ src/ScreenEdit.cpp | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/src/Attack.cpp b/src/Attack.cpp index 568b83ec4c..25a19415c9 100644 --- a/src/Attack.cpp +++ b/src/Attack.cpp @@ -104,6 +104,14 @@ vector AttackArray::ToVectorString() const return ret; } +void AttackArray::UpdateStartTimes(float delta) +{ + FOREACH(Attack, *this, a) + { + a->fStartSecond += delta; + } +} + /* * (c) 2003-2004 Chris Danford * All rights reserved. diff --git a/src/Attack.h b/src/Attack.h index 9e3ae45310..fe61a48723 100644 --- a/src/Attack.h +++ b/src/Attack.h @@ -76,6 +76,11 @@ struct AttackArray : public vector * @brief Return a string representation used for simfiles. * @return the string representation. */ vector ToVectorString() const; + + /** + * @brief Adjust the starting time of all attacks. + * @param delta the amount to change. */ + void UpdateStartTimes(float delta); }; #endif diff --git a/src/ScreenEdit.cpp b/src/ScreenEdit.cpp index 08e53a6aea..ed8bebe2d4 100644 --- a/src/ScreenEdit.cpp +++ b/src/ScreenEdit.cpp @@ -1936,6 +1936,14 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB ) } GetAppropriateTiming().m_fBeat0OffsetInSeconds += fDelta; (fDelta>0 ? m_soundValueIncrease : m_soundValueDecrease).Play(); + if (GAMESTATE->m_bIsUsingStepTiming) + { + GAMESTATE->m_pCurSteps[PLAYER_1]->m_Attacks.UpdateStartTimes(fDelta); + } + else + { + GAMESTATE->m_pCurSong->m_Attacks.UpdateStartTimes(fDelta); + } SetDirty( true ); } break; @@ -3430,7 +3438,17 @@ static void ChangeBeat0Offset( const RString &sNew ) TimingData &timing = (GAMESTATE->m_bIsUsingStepTiming ? GAMESTATE->m_pCurSteps[PLAYER_1]->m_Timing : GAMESTATE->m_pCurSong->m_SongTiming); + float old = timing.m_fBeat0OffsetInSeconds; timing.m_fBeat0OffsetInSeconds = StringToFloat( sNew ); + float delta = timing.m_fBeat0OffsetInSeconds - old; + if (GAMESTATE->m_bIsUsingStepTiming) + { + GAMESTATE->m_pCurSteps[PLAYER_1]->m_Attacks.UpdateStartTimes(delta); + } + else + { + GAMESTATE->m_pCurSong->m_Attacks.UpdateStartTimes(delta); + } } static void ChangeLastSecondHint( const RString &sNew )