diff --git a/stepmania/src/EditMenu.cpp b/stepmania/src/EditMenu.cpp index c1d3289bea..c32305ce75 100644 --- a/stepmania/src/EditMenu.cpp +++ b/stepmania/src/EditMenu.cpp @@ -7,10 +7,8 @@ #include "GameManager.h" #include "Steps.h" #include "song.h" +#include "StepsUtil.h" -// -// Defines specific to EditMenu -// #define ARROWS_X( i ) THEME->GetMetricF("EditMenu",ssprintf("Arrows%dX",i+1)) #define SONG_BANNER_X THEME->GetMetricF("EditMenu","SongBannerX") #define SONG_BANNER_Y THEME->GetMetricF("EditMenu","SongBannerY") @@ -48,8 +46,8 @@ EditMenu::EditMenu() // start out on easy, not beginner - m_iSelection[ROW_DIFFICULTY] = DIFFICULTY_EASY; - m_iSelection[ROW_SOURCE_DIFFICULTY] = DIFFICULTY_EASY; + m_iSelection[ROW_STEPS] = DIFFICULTY_EASY; + m_iSelection[ROW_SOURCE_STEPS] = DIFFICULTY_EASY; @@ -123,11 +121,15 @@ EditMenu::EditMenu() { m_iSelection[ROW_STEPS_TYPE] = i; OnRowValueChanged( ROW_STEPS_TYPE ); - m_iSelection[ROW_DIFFICULTY] = GAMESTATE->m_pCurSteps[PLAYER_1]->GetDifficulty(); - OnRowValueChanged( ROW_DIFFICULTY ); - break; } } + + vector::const_iterator iter = find( m_vpSteps.begin(), m_vpSteps.end(), GAMESTATE->m_pCurSteps[PLAYER_1] ); + if( iter != m_vpSteps.end() ) + { + m_iSelection[ROW_STEPS] = m_vpSteps.begin() - iter; + OnRowValueChanged( ROW_STEPS ); + } } } } @@ -137,7 +139,7 @@ EditMenu::~EditMenu() } -void EditMenu::RefreshNotes() +void EditMenu::RefreshSteps() { OnRowValueChanged( ROW_SONG ); } @@ -169,9 +171,9 @@ bool EditMenu::CanGoRight() m_sGroups.size(), m_pSongs.size(), m_StepsTypes.size(), - NUM_DIFFICULTIES, + m_vpSteps.size(), m_StepsTypes.size(), - NUM_DIFFICULTIES, + m_vpSourceSteps.size(), m_Actions.size() }; @@ -182,8 +184,8 @@ void EditMenu::Up() { if( CanGoUp() ) { - if( GetSelectedNotes() && m_SelectedRow==ROW_ACTION ) - ChangeToRow( ROW_DIFFICULTY ); + if( GetSelectedSteps() && m_SelectedRow==ROW_ACTION ) + ChangeToRow( ROW_STEPS ); else ChangeToRow( Row(m_SelectedRow-1) ); m_soundChangeRow.PlayRandom(); @@ -194,7 +196,7 @@ void EditMenu::Down() { if( CanGoDown() ) { - if( GetSelectedNotes() && m_SelectedRow==ROW_DIFFICULTY ) + if( GetSelectedSteps() && m_SelectedRow==ROW_STEPS ) ChangeToRow( ROW_ACTION ); else ChangeToRow( Row(m_SelectedRow+1) ); @@ -259,31 +261,63 @@ void EditMenu::OnRowValueChanged( Row row ) m_SongTextBanner.LoadFromSong( GetSelectedSong() ); // fall through case ROW_STEPS_TYPE: - m_textValue[ROW_STEPS_TYPE].SetText( GAMEMAN->StepsTypeToString(GetSelectedStepsType()) ); + m_textValue[ROW_STEPS_TYPE].SetText( GAMEMAN->StepsTypeToThemedString(GetSelectedStepsType()) ); + CLAMP( m_iSelection[ROW_STEPS], 0, NUM_DIFFICULTIES-1 ); // jump back to the slot for DIFFICULTY_EDIT + m_vpSteps.clear(); + GetSelectedSong()->GetSteps( m_vpSteps, GetSelectedStepsType() ); + StepsUtil::SortStepsByDescription( m_vpSteps ); + StepsUtil::SortStepsByTypeAndDifficulty( m_vpSteps ); + FOREACH_Difficulty( dc ) + { + Steps *pSteps = dc < m_vpSteps.size() ? m_vpSteps[dc] : NULL; + if( pSteps == NULL || pSteps->GetDifficulty() != dc ) + m_vpSteps.insert( m_vpSteps.begin()+dc, NULL ); + } + if( GetSelectedSong()->HasEdits(GetSelectedStepsType()) ) + m_vpSteps.push_back( NULL ); // for "New Edit" // fall through - case ROW_DIFFICULTY: - m_textValue[ROW_DIFFICULTY].SetText( DifficultyToString(GetSelectedDifficulty()) ); - m_Meter.SetFromSteps( GetSelectedNotes() ); + case ROW_STEPS: + { + CString s = DifficultyToThemedString(GetSelectedDifficulty()); + Steps *pSteps = GetSelectedSteps(); + if( GetSelectedDifficulty() == DIFFICULTY_EDIT ) + s += " - " + (pSteps ? pSteps->GetDescription() : "New" ); + m_textValue[ROW_STEPS].SetText( s ); + m_Meter.SetFromSteps( GetSelectedSteps() ); + } // fall through case ROW_SOURCE_STEPS_TYPE: - m_textLabel[ROW_SOURCE_STEPS_TYPE].SetDiffuse( GetSelectedNotes()?RageColor(1,1,1,0):RageColor(1,1,1,1) ); - m_textValue[ROW_SOURCE_STEPS_TYPE].SetDiffuse( GetSelectedNotes()?RageColor(1,1,1,0):RageColor(1,1,1,1) ); - m_textValue[ROW_SOURCE_STEPS_TYPE].SetText( GAMEMAN->StepsTypeToString(GetSelectedSourceStepsType()) ); + m_textLabel[ROW_SOURCE_STEPS_TYPE].SetHidden( GetSelectedSteps() ? true : false ); + m_textValue[ROW_SOURCE_STEPS_TYPE].SetHidden( GetSelectedSteps() ? true : false ); + m_textValue[ROW_SOURCE_STEPS_TYPE].SetText( GAMEMAN->StepsTypeToThemedString(GetSelectedSourceStepsType()) ); + + CLAMP( m_iSelection[ROW_SOURCE_STEPS], 0, NUM_DIFFICULTIES-1 ); // jump back to the slot for DIFFICULTY_EDIT + m_vpSourceSteps.clear(); + GetSelectedSong()->GetSteps( m_vpSourceSteps, GetSelectedSourceStepsType() ); + StepsUtil::SortStepsByDescription( m_vpSourceSteps ); + StepsUtil::SortStepsByTypeAndDifficulty( m_vpSourceSteps ); + FOREACH_Difficulty( dc ) + { + Steps *pSteps = dc < m_vpSourceSteps.size() ? m_vpSourceSteps[dc] : NULL; + if( pSteps == NULL || pSteps->GetDifficulty() != dc ) + m_vpSourceSteps.insert( m_vpSourceSteps.begin()+dc, NULL ); + } + // fall through - case ROW_SOURCE_DIFFICULTY: - m_textLabel[ROW_SOURCE_DIFFICULTY].SetDiffuse( GetSelectedNotes()?RageColor(1,1,1,0):RageColor(1,1,1,1) ); - m_textValue[ROW_SOURCE_DIFFICULTY].SetDiffuse( GetSelectedNotes()?RageColor(1,1,1,0):RageColor(1,1,1,1) ); - m_textValue[ROW_SOURCE_DIFFICULTY].SetText( DifficultyToString(GetSelectedSourceDifficulty()) ); - m_SourceMeter.SetFromSteps( GetSelectedSourceNotes() ); - m_SourceMeter.SetZoomY( GetSelectedNotes()?0.f:1.f ); + case ROW_SOURCE_STEPS: + m_textLabel[ROW_SOURCE_STEPS].SetHidden( GetSelectedSteps() ? true : false ); + m_textValue[ROW_SOURCE_STEPS].SetHidden( GetSelectedSteps() ? true : false ); + m_textValue[ROW_SOURCE_STEPS].SetText( DifficultyToThemedString(GetSelectedSourceDifficulty()) ); + m_SourceMeter.SetFromSteps( GetSelectedSourceSteps() ); + m_SourceMeter.SetHidden( GetSelectedSteps() ? true : false ); m_Actions.clear(); - if( GetSelectedNotes() ) + if( GetSelectedSteps() ) { m_Actions.push_back( ACTION_EDIT ); m_Actions.push_back( ACTION_DELETE ); } - else if( GetSelectedSourceNotes() ) + else if( GetSelectedSourceSteps() ) { m_Actions.push_back( ACTION_COPY ); m_Actions.push_back( ACTION_AUTOGEN ); @@ -303,15 +337,6 @@ void EditMenu::OnRowValueChanged( Row row ) } } -Steps* EditMenu::GetSelectedNotes() -{ - return GetSelectedSong()->GetStepsByDifficulty(GetSelectedStepsType(),GetSelectedDifficulty(), false); -} - -Steps* EditMenu::GetSelectedSourceNotes() -{ - return GetSelectedSong()->GetStepsByDifficulty(GetSelectedSourceStepsType(),GetSelectedSourceDifficulty(), false); -} /* * (c) 2001-2004 Chris Danford diff --git a/stepmania/src/EditMenu.h b/stepmania/src/EditMenu.h index e2bde3478c..81fb89e6a5 100644 --- a/stepmania/src/EditMenu.h +++ b/stepmania/src/EditMenu.h @@ -33,9 +33,9 @@ public: ROW_GROUP, ROW_SONG, ROW_STEPS_TYPE, - ROW_DIFFICULTY, + ROW_STEPS, ROW_SOURCE_STEPS_TYPE, - ROW_SOURCE_DIFFICULTY, + ROW_SOURCE_STEPS, ROW_ACTION, NUM_ROWS } m_SelectedRow; @@ -46,9 +46,9 @@ public: "Group", "Song", "StepsType", - "Difficulty", + "Steps", "Source StepsType", - "Source Difficulty", + "Source Steps", "Action" }; return s[r]; @@ -76,19 +76,19 @@ public: return s[a]; } - void RefreshNotes(); + void RefreshSteps(); - CString GetSelectedGroup() const { ASSERT(m_iSelection[ROW_GROUP] < (int)m_sGroups.size()); return m_sGroups[m_iSelection[ROW_GROUP]]; } - Song* GetSelectedSong() const { ASSERT(m_iSelection[ROW_SONG] < (int)m_pSongs.size()); return m_pSongs[m_iSelection[ROW_SONG]]; } - StepsType GetSelectedStepsType() const { ASSERT(m_iSelection[ROW_STEPS_TYPE] < (int)m_StepsTypes.size()); return m_StepsTypes[m_iSelection[ROW_STEPS_TYPE]]; } - Difficulty GetSelectedDifficulty() const { return (Difficulty)m_iSelection[ROW_DIFFICULTY]; } + CString GetSelectedGroup() const { ASSERT(m_iSelection[ROW_GROUP] < (int)m_sGroups.size()); return m_sGroups[m_iSelection[ROW_GROUP]]; } + Song* GetSelectedSong() const { ASSERT(m_iSelection[ROW_SONG] < (int)m_pSongs.size()); return m_pSongs[m_iSelection[ROW_SONG]]; } + StepsType GetSelectedStepsType() const { ASSERT(m_iSelection[ROW_STEPS_TYPE] < (int)m_StepsTypes.size()); return m_StepsTypes[m_iSelection[ROW_STEPS_TYPE]]; } + Steps* GetSelectedSteps() const { ASSERT(m_iSelection[ROW_STEPS] < (int)m_vpSteps.size()); return m_vpSteps[m_iSelection[ROW_STEPS]]; } StepsType GetSelectedSourceStepsType() const { ASSERT(m_iSelection[ROW_SOURCE_STEPS_TYPE] < (int)m_StepsTypes.size()); return m_StepsTypes[m_iSelection[ROW_SOURCE_STEPS_TYPE]]; } - Difficulty GetSelectedSourceDifficulty() const { return (Difficulty)m_iSelection[ROW_SOURCE_DIFFICULTY]; } - Action GetSelectedAction() const { ASSERT(m_iSelection[ROW_ACTION] < (int)m_Actions.size()); return m_Actions[m_iSelection[ROW_ACTION]]; } + Steps* GetSelectedSourceSteps() const { ASSERT(m_iSelection[ROW_SOURCE_STEPS] < (int)m_vpSourceSteps.size()); return m_vpSourceSteps[m_iSelection[ROW_SOURCE_STEPS]]; } + Action GetSelectedAction() const { ASSERT(m_iSelection[ROW_ACTION] < (int)m_Actions.size()); return m_Actions[m_iSelection[ROW_ACTION]]; } - Steps* GetSelectedNotes(); - Steps* GetSelectedSourceNotes(); + Difficulty GetSelectedDifficulty() { int iDifficulty = m_iSelection[ROW_STEPS]; CLAMP(iDifficulty,0,NUM_DIFFICULTIES-1); return (Difficulty)iDifficulty; } + Difficulty GetSelectedSourceDifficulty() { int iDifficulty = m_iSelection[ROW_SOURCE_STEPS]; CLAMP(iDifficulty,0,NUM_DIFFICULTIES-1); return (Difficulty)iDifficulty; } private: Sprite m_sprArrows[2]; @@ -104,8 +104,10 @@ private: DifficultyMeter m_SourceMeter; CStringArray m_sGroups; - vector m_StepsTypes; vector m_pSongs; + vector m_StepsTypes; + vector m_vpSteps; + vector m_vpSourceSteps; vector m_Actions; void OnRowValueChanged( Row row ); diff --git a/stepmania/src/ScreenEditMenu.cpp b/stepmania/src/ScreenEditMenu.cpp index 7502b487a3..1dccc9c019 100644 --- a/stepmania/src/ScreenEditMenu.cpp +++ b/stepmania/src/ScreenEditMenu.cpp @@ -34,7 +34,7 @@ void ScreenEditMenu::Init() ScreenWithMenuElements::Init(); m_Selector.SetXY( 0, 0 ); -// m_Selector.AllowNewNotes(); +// m_Selector.AllowNewSteps(); this->AddChild( &m_Selector ); @@ -54,7 +54,7 @@ void ScreenEditMenu::HandleScreenMessage( const ScreenMessage SM ) switch( SM ) { case SM_RefreshSelector: - m_Selector.RefreshNotes(); + m_Selector.RefreshSteps(); break; case SM_GoToPrevScreen: SCREENMAN->SetNewScreen( PREV_SCREEN ); @@ -87,7 +87,7 @@ void ScreenEditMenu::MenuRight( PlayerNumber pn, const InputEventType type ) // helpers for MenuStart() below -void DeleteCurNotes( void* pThrowAway ) +void DeleteCurSteps( void* pThrowAway ) { Song* pSong = GAMESTATE->m_pCurSong; Steps* pStepsToDelete = GAMESTATE->m_pCurSteps[PLAYER_1]; @@ -104,10 +104,10 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn ) Song* pSong = m_Selector.GetSelectedSong(); StepsType st = m_Selector.GetSelectedStepsType(); Difficulty dc = m_Selector.GetSelectedDifficulty(); - Steps* pSteps = m_Selector.GetSelectedNotes(); + Steps* pSteps = m_Selector.GetSelectedSteps(); // StepsType soureNT = m_Selector.GetSelectedSourceStepsType(); // Difficulty sourceDiff = m_Selector.GetSelectedSourceDifficulty(); - Steps* pSourceNotes = m_Selector.GetSelectedSourceNotes(); + Steps* pSourceSteps = m_Selector.GetSelectedSourceSteps(); EditMenu::Action action = m_Selector.GetSelectedAction(); GAMESTATE->m_pCurSong.Set( pSong ); @@ -135,41 +135,41 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn ) break; case EditMenu::ACTION_DELETE: ASSERT( pSteps ); - SCREENMAN->Prompt( SM_RefreshSelector, "These notes will be lost permanently.\n\nContinue with delete?", true, false, DeleteCurNotes ); - m_Selector.RefreshNotes(); + SCREENMAN->Prompt( SM_RefreshSelector, "These steps will be lost permanently.\n\nContinue with delete?", true, false, DeleteCurSteps ); + m_Selector.RefreshSteps(); return; case EditMenu::ACTION_COPY: ASSERT( !pSteps ); - ASSERT( pSourceNotes ); + ASSERT( pSourceSteps ); { // Yuck. Doing the memory allocation doesn't seem right since // Song allocates all of the other Steps. - Steps* pNewNotes = new Steps; - pNewNotes->CopyFrom( pSourceNotes, st ); - pNewNotes->SetDifficulty( dc ); - pSong->AddSteps( pNewNotes ); + Steps* pNewSteps = new Steps; + pNewSteps->CopyFrom( pSourceSteps, st ); + pNewSteps->SetDifficulty( dc ); + pSong->AddSteps( pNewSteps ); SCREENMAN->SystemMessage( "Steps created from copy." ); SOUND->PlayOnce( THEME->GetPathS(m_sName,"create") ); - m_Selector.RefreshNotes(); + m_Selector.RefreshSteps(); pSong->Save(); } return; case EditMenu::ACTION_AUTOGEN: ASSERT( !pSteps ); - ASSERT( pSourceNotes ); + ASSERT( pSourceSteps ); { // Yuck. Doing the memory allocation doesn't seem right since // Song allocates all of the other Steps. - Steps* pNewNotes = new Steps; - pNewNotes->AutogenFrom( pSourceNotes, st ); - pNewNotes->DeAutogen(); - pNewNotes->SetDifficulty( dc ); // override difficulty with the user's choice - pSong->AddSteps( pNewNotes ); + Steps* pNewSteps = new Steps; + pNewSteps->AutogenFrom( pSourceSteps, st ); + pNewSteps->DeAutogen(); + pNewSteps->SetDifficulty( dc ); // override difficulty with the user's choice + pSong->AddSteps( pNewSteps ); SCREENMAN->SystemMessage( "Steps created from AutoGen." ); SOUND->PlayOnce( THEME->GetPathS(m_sName,"create") ); - m_Selector.RefreshNotes(); + m_Selector.RefreshSteps(); pSong->Save(); } return; @@ -178,15 +178,15 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn ) { // Yuck. Doing the memory allocation doesn't seem right since // Song allocates all of the other Steps. - Steps* pNewNotes = new Steps; - pNewNotes->CreateBlank( st ); - pNewNotes->SetDifficulty( dc ); - pNewNotes->SetMeter( 1 ); - pSong->AddSteps( pNewNotes ); + Steps* pNewSteps = new Steps; + pNewSteps->CreateBlank( st ); + pNewSteps->SetDifficulty( dc ); + pNewSteps->SetMeter( 1 ); + pSong->AddSteps( pNewSteps ); SCREENMAN->SystemMessage( "Blank Steps created." ); SOUND->PlayOnce( THEME->GetPathS(m_sName,"create") ); - m_Selector.RefreshNotes(); + m_Selector.RefreshSteps(); pSong->Save(); } return;