diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 5da7e37a64..3e7a45a4b2 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -512,7 +512,7 @@ void GameState::Update( float fDelta ) { FOREACH_PlayerNumber( p ) { - m_pPlayerState[p]->m_CurrentPlayerOptions.Approach( m_pPlayerState[p]->m_PlayerOptions, fDelta ); + m_pPlayerState[p]->Update( fDelta ); // TRICKY: GAMESTATE->Update is run before any of the Screen update's, // so we'll clear these flags here and let them get turned on later @@ -1069,8 +1069,7 @@ void GameState::ResetNoteSkins() void GameState::ResetNoteSkinsForPlayer( PlayerNumber pn ) { - m_pPlayerState[pn]->m_BeatToNoteSkin.clear(); - m_pPlayerState[pn]->m_BeatToNoteSkin[-1000] = m_pPlayerState[pn]->m_PlayerOptions.m_sNoteSkin; + m_pPlayerState[pn]->ResetNoteSkins(); ++m_BeatToNoteSkinRev; } diff --git a/stepmania/src/PlayerState.cpp b/stepmania/src/PlayerState.cpp index 53b43ce3fe..1fe73b51a1 100644 --- a/stepmania/src/PlayerState.cpp +++ b/stepmania/src/PlayerState.cpp @@ -1,6 +1,16 @@ #include "global.h" #include "PlayerState.h" +void PlayerState::ResetNoteSkins() +{ + m_BeatToNoteSkin.clear(); + m_BeatToNoteSkin[-1000] = m_PlayerOptions.m_sNoteSkin; +} + +void PlayerState::Update( float fDelta ) +{ + m_CurrentPlayerOptions.Approach( m_PlayerOptions, fDelta ); +} /* * (c) 2001-2004 Chris Danford, Chris Gomez diff --git a/stepmania/src/PlayerState.h b/stepmania/src/PlayerState.h index c1c61a03ad..318a0d354a 100644 --- a/stepmania/src/PlayerState.h +++ b/stepmania/src/PlayerState.h @@ -44,6 +44,8 @@ struct PlayerState m_Inventory[i].MakeBlank(); } + void ResetNoteSkins(); + void Update( float fDelta ); // TODO: Remove use of PlayerNumber. All data about the player should live // in PlayerState and callers should not use PlayerNumber to index into diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 4fb68723eb..576207703e 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -511,11 +511,10 @@ void ScreenEdit::Init() /* Not all games have a noteskin named "note" ... */ if( NOTESKIN->DoesNoteSkinExist("note") ) - GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.m_sNoteSkin = "note"; // change noteskin before loading all of the edit Actors - // Reset player options, but don't reset the current NoteSkin - CString sNoteSkin = GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.m_sNoteSkin; - GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.Init(); // don't allow weird options in editor. It doesn't handle reverse well. - GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.m_sNoteSkin = sNoteSkin; + m_PlayerStateEdit.m_PlayerOptions.m_sNoteSkin = "note"; // change noteskin before loading all of the edit Actors + m_PlayerStateEdit.m_PlayerNumber = PLAYER_1; + m_PlayerStateEdit.m_PlayerOptions.m_sNoteSkin = GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.m_sNoteSkin; + m_PlayerStateEdit.ResetNoteSkins(); GAMESTATE->ResetNoteSkins(); GAMESTATE->StoreSelectedOptions(); @@ -538,7 +537,7 @@ void ScreenEdit::Init() m_NoteFieldEdit.SetXY( EDIT_X, PLAYER_Y ); m_NoteFieldEdit.SetZoom( 0.5f ); - m_NoteFieldEdit.Init( GAMESTATE->m_pPlayerState[PLAYER_1], PLAYER_HEIGHT*2 ); + m_NoteFieldEdit.Init( &m_PlayerStateEdit, PLAYER_HEIGHT*2 ); m_NoteFieldEdit.Load( &m_NoteDataEdit, -240, 800 ); this->AddChild( &m_NoteFieldEdit ); @@ -661,6 +660,8 @@ void ScreenEdit::PlayPreviewMusic() void ScreenEdit::Update( float fDeltaTime ) { + m_PlayerStateEdit.Update( fDeltaTime ); + if( m_soundMusic.IsPlaying() ) { RageTimer tm; @@ -715,7 +716,7 @@ void ScreenEdit::Update( float fDeltaTime ) float fDelta = GAMESTATE->m_fSongBeat - m_fTrailingBeat; if( fabsf(fDelta) < 10 ) fapproach( m_fTrailingBeat, GAMESTATE->m_fSongBeat, - fDeltaTime*40 / GAMESTATE->m_pPlayerState[PLAYER_1]->m_CurrentPlayerOptions.m_fScrollSpeed ); + fDeltaTime*40 / m_PlayerStateEdit.m_CurrentPlayerOptions.m_fScrollSpeed ); else fapproach( m_fTrailingBeat, GAMESTATE->m_fSongBeat, fabsf(fDelta) * fDeltaTime*5 ); @@ -909,7 +910,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ case EDIT_BUTTON_SCROLL_SPEED_UP: case EDIT_BUTTON_SCROLL_SPEED_DOWN: { - float& fScrollSpeed = GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.m_fScrollSpeed; + float& fScrollSpeed = m_PlayerStateEdit.m_PlayerOptions.m_fScrollSpeed; float fNewScrollSpeed = fScrollSpeed; if( EditB == EDIT_BUTTON_SCROLL_SPEED_DOWN ) @@ -1473,14 +1474,10 @@ void ScreenEdit::TransitionEditMode( EditMode em ) CheckNumberOfNotesAndUndo(); } - - GAMESTATE->ResetCurrentOptions(); break; case MODE_RECORDING: - GAMESTATE->RestoreSelectedOptions(); break; case MODE_PLAYING: - GAMESTATE->RestoreSelectedOptions(); break; default: ASSERT(0); @@ -1579,8 +1576,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM ) SM == SM_BackFromPlayerOptions || SM == SM_BackFromSongOptions ) { - GAMESTATE->StoreSelectedOptions(); - GAMESTATE->ResetCurrentOptions(); + GAMESTATE->StoreSelectedOptions(); // so that the options stick when we reset Course attacks // stop any music that screen may have been playing SOUND->StopMusic(); @@ -1589,8 +1585,6 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM ) { int iDurationChoice = ScreenMiniMenu::s_viLastAnswers[0]; g_fLastInsertAttackDurationSeconds = strtof( g_InsertAttack.rows[0].choices[iDurationChoice], NULL ); - GAMESTATE->StoreSelectedOptions(); // save so that we don't lose the options chosen for edit and playback - GAMESTATE->ResetCurrentOptions(); // XXX: Fix me //SCREENMAN->AddNewScreenToTop( "ScreenPlayerOptions", SM_BackFromInsertAttackPlayerOptions ); @@ -1611,8 +1605,6 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM ) SaveUndo(); m_NoteDataEdit.SetTapNote( g_iLastInsertAttackTrack, row, tn ); CheckNumberOfNotesAndUndo(); - - GAMESTATE->RestoreSelectedOptions(); // restore the edit and playback options } else if( SM == SM_DoRevertToLastSave ) { diff --git a/stepmania/src/ScreenEdit.h b/stepmania/src/ScreenEdit.h index 124150f353..a9bdf8570f 100644 --- a/stepmania/src/ScreenEdit.h +++ b/stepmania/src/ScreenEdit.h @@ -17,6 +17,7 @@ #include "song.h" #include "Steps.h" #include "ThemeMetric.h" +#include "PlayerState.h" const int NUM_EDIT_BUTTON_COLUMNS = 10; @@ -164,6 +165,7 @@ protected: Song* m_pSong; Steps* m_pSteps; + PlayerState m_PlayerStateEdit; NoteField m_NoteFieldEdit; NoteData m_NoteDataEdit; SnapDisplay m_SnapDisplay; diff --git a/stepmania/src/Style.cpp b/stepmania/src/Style.cpp index aef20a7815..a3845cc264 100644 --- a/stepmania/src/Style.cpp +++ b/stepmania/src/Style.cpp @@ -96,6 +96,8 @@ bool Style::MatchesStepsType( StepsType type ) const void Style::GetMinAndMaxColX( PlayerNumber pn, float& fMixXOut, float& fMaxXOut ) const { + ASSERT( pn != PLAYER_INVALID ); + fMixXOut = FLT_MAX; fMaxXOut = FLT_MIN; for( int i=0; i