select between multiple edit steps

This commit is contained in:
Chris Danford
2005-03-05 21:35:30 +00:00
parent afaa5e6b51
commit 2d2796148b
3 changed files with 105 additions and 78 deletions
+63 -38
View File
@@ -7,10 +7,8 @@
#include "GameManager.h" #include "GameManager.h"
#include "Steps.h" #include "Steps.h"
#include "song.h" #include "song.h"
#include "StepsUtil.h"
//
// Defines specific to EditMenu
//
#define ARROWS_X( i ) THEME->GetMetricF("EditMenu",ssprintf("Arrows%dX",i+1)) #define ARROWS_X( i ) THEME->GetMetricF("EditMenu",ssprintf("Arrows%dX",i+1))
#define SONG_BANNER_X THEME->GetMetricF("EditMenu","SongBannerX") #define SONG_BANNER_X THEME->GetMetricF("EditMenu","SongBannerX")
#define SONG_BANNER_Y THEME->GetMetricF("EditMenu","SongBannerY") #define SONG_BANNER_Y THEME->GetMetricF("EditMenu","SongBannerY")
@@ -48,8 +46,8 @@ EditMenu::EditMenu()
// start out on easy, not beginner // start out on easy, not beginner
m_iSelection[ROW_DIFFICULTY] = DIFFICULTY_EASY; m_iSelection[ROW_STEPS] = DIFFICULTY_EASY;
m_iSelection[ROW_SOURCE_DIFFICULTY] = DIFFICULTY_EASY; m_iSelection[ROW_SOURCE_STEPS] = DIFFICULTY_EASY;
@@ -123,11 +121,15 @@ EditMenu::EditMenu()
{ {
m_iSelection[ROW_STEPS_TYPE] = i; m_iSelection[ROW_STEPS_TYPE] = i;
OnRowValueChanged( ROW_STEPS_TYPE ); OnRowValueChanged( ROW_STEPS_TYPE );
m_iSelection[ROW_DIFFICULTY] = GAMESTATE->m_pCurSteps[PLAYER_1]->GetDifficulty();
OnRowValueChanged( ROW_DIFFICULTY );
break;
} }
} }
vector<Steps*>::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 ); OnRowValueChanged( ROW_SONG );
} }
@@ -169,9 +171,9 @@ bool EditMenu::CanGoRight()
m_sGroups.size(), m_sGroups.size(),
m_pSongs.size(), m_pSongs.size(),
m_StepsTypes.size(), m_StepsTypes.size(),
NUM_DIFFICULTIES, m_vpSteps.size(),
m_StepsTypes.size(), m_StepsTypes.size(),
NUM_DIFFICULTIES, m_vpSourceSteps.size(),
m_Actions.size() m_Actions.size()
}; };
@@ -182,8 +184,8 @@ void EditMenu::Up()
{ {
if( CanGoUp() ) if( CanGoUp() )
{ {
if( GetSelectedNotes() && m_SelectedRow==ROW_ACTION ) if( GetSelectedSteps() && m_SelectedRow==ROW_ACTION )
ChangeToRow( ROW_DIFFICULTY ); ChangeToRow( ROW_STEPS );
else else
ChangeToRow( Row(m_SelectedRow-1) ); ChangeToRow( Row(m_SelectedRow-1) );
m_soundChangeRow.PlayRandom(); m_soundChangeRow.PlayRandom();
@@ -194,7 +196,7 @@ void EditMenu::Down()
{ {
if( CanGoDown() ) if( CanGoDown() )
{ {
if( GetSelectedNotes() && m_SelectedRow==ROW_DIFFICULTY ) if( GetSelectedSteps() && m_SelectedRow==ROW_STEPS )
ChangeToRow( ROW_ACTION ); ChangeToRow( ROW_ACTION );
else else
ChangeToRow( Row(m_SelectedRow+1) ); ChangeToRow( Row(m_SelectedRow+1) );
@@ -259,31 +261,63 @@ void EditMenu::OnRowValueChanged( Row row )
m_SongTextBanner.LoadFromSong( GetSelectedSong() ); m_SongTextBanner.LoadFromSong( GetSelectedSong() );
// fall through // fall through
case ROW_STEPS_TYPE: 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 // fall through
case ROW_DIFFICULTY: case ROW_STEPS:
m_textValue[ROW_DIFFICULTY].SetText( DifficultyToString(GetSelectedDifficulty()) ); {
m_Meter.SetFromSteps( GetSelectedNotes() ); 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 // fall through
case ROW_SOURCE_STEPS_TYPE: case ROW_SOURCE_STEPS_TYPE:
m_textLabel[ROW_SOURCE_STEPS_TYPE].SetDiffuse( GetSelectedNotes()?RageColor(1,1,1,0):RageColor(1,1,1,1) ); m_textLabel[ROW_SOURCE_STEPS_TYPE].SetHidden( GetSelectedSteps() ? true : false );
m_textValue[ROW_SOURCE_STEPS_TYPE].SetDiffuse( GetSelectedNotes()?RageColor(1,1,1,0):RageColor(1,1,1,1) ); m_textValue[ROW_SOURCE_STEPS_TYPE].SetHidden( GetSelectedSteps() ? true : false );
m_textValue[ROW_SOURCE_STEPS_TYPE].SetText( GAMEMAN->StepsTypeToString(GetSelectedSourceStepsType()) ); 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 // fall through
case ROW_SOURCE_DIFFICULTY: case ROW_SOURCE_STEPS:
m_textLabel[ROW_SOURCE_DIFFICULTY].SetDiffuse( GetSelectedNotes()?RageColor(1,1,1,0):RageColor(1,1,1,1) ); m_textLabel[ROW_SOURCE_STEPS].SetHidden( GetSelectedSteps() ? true : false );
m_textValue[ROW_SOURCE_DIFFICULTY].SetDiffuse( GetSelectedNotes()?RageColor(1,1,1,0):RageColor(1,1,1,1) ); m_textValue[ROW_SOURCE_STEPS].SetHidden( GetSelectedSteps() ? true : false );
m_textValue[ROW_SOURCE_DIFFICULTY].SetText( DifficultyToString(GetSelectedSourceDifficulty()) ); m_textValue[ROW_SOURCE_STEPS].SetText( DifficultyToThemedString(GetSelectedSourceDifficulty()) );
m_SourceMeter.SetFromSteps( GetSelectedSourceNotes() ); m_SourceMeter.SetFromSteps( GetSelectedSourceSteps() );
m_SourceMeter.SetZoomY( GetSelectedNotes()?0.f:1.f ); m_SourceMeter.SetHidden( GetSelectedSteps() ? true : false );
m_Actions.clear(); m_Actions.clear();
if( GetSelectedNotes() ) if( GetSelectedSteps() )
{ {
m_Actions.push_back( ACTION_EDIT ); m_Actions.push_back( ACTION_EDIT );
m_Actions.push_back( ACTION_DELETE ); m_Actions.push_back( ACTION_DELETE );
} }
else if( GetSelectedSourceNotes() ) else if( GetSelectedSourceSteps() )
{ {
m_Actions.push_back( ACTION_COPY ); m_Actions.push_back( ACTION_COPY );
m_Actions.push_back( ACTION_AUTOGEN ); 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 * (c) 2001-2004 Chris Danford
+16 -14
View File
@@ -33,9 +33,9 @@ public:
ROW_GROUP, ROW_GROUP,
ROW_SONG, ROW_SONG,
ROW_STEPS_TYPE, ROW_STEPS_TYPE,
ROW_DIFFICULTY, ROW_STEPS,
ROW_SOURCE_STEPS_TYPE, ROW_SOURCE_STEPS_TYPE,
ROW_SOURCE_DIFFICULTY, ROW_SOURCE_STEPS,
ROW_ACTION, ROW_ACTION,
NUM_ROWS NUM_ROWS
} m_SelectedRow; } m_SelectedRow;
@@ -46,9 +46,9 @@ public:
"Group", "Group",
"Song", "Song",
"StepsType", "StepsType",
"Difficulty", "Steps",
"Source StepsType", "Source StepsType",
"Source Difficulty", "Source Steps",
"Action" "Action"
}; };
return s[r]; return s[r];
@@ -76,19 +76,19 @@ public:
return s[a]; 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]]; } 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]]; } 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]]; } 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]; } 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]]; } 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]; } 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]]; } Action GetSelectedAction() const { ASSERT(m_iSelection[ROW_ACTION] < (int)m_Actions.size()); return m_Actions[m_iSelection[ROW_ACTION]]; }
Steps* GetSelectedNotes(); Difficulty GetSelectedDifficulty() { int iDifficulty = m_iSelection[ROW_STEPS]; CLAMP(iDifficulty,0,NUM_DIFFICULTIES-1); return (Difficulty)iDifficulty; }
Steps* GetSelectedSourceNotes(); Difficulty GetSelectedSourceDifficulty() { int iDifficulty = m_iSelection[ROW_SOURCE_STEPS]; CLAMP(iDifficulty,0,NUM_DIFFICULTIES-1); return (Difficulty)iDifficulty; }
private: private:
Sprite m_sprArrows[2]; Sprite m_sprArrows[2];
@@ -104,8 +104,10 @@ private:
DifficultyMeter m_SourceMeter; DifficultyMeter m_SourceMeter;
CStringArray m_sGroups; CStringArray m_sGroups;
vector<StepsType> m_StepsTypes;
vector<Song*> m_pSongs; vector<Song*> m_pSongs;
vector<StepsType> m_StepsTypes;
vector<Steps*> m_vpSteps;
vector<Steps*> m_vpSourceSteps;
vector<Action> m_Actions; vector<Action> m_Actions;
void OnRowValueChanged( Row row ); void OnRowValueChanged( Row row );
+26 -26
View File
@@ -34,7 +34,7 @@ void ScreenEditMenu::Init()
ScreenWithMenuElements::Init(); ScreenWithMenuElements::Init();
m_Selector.SetXY( 0, 0 ); m_Selector.SetXY( 0, 0 );
// m_Selector.AllowNewNotes(); // m_Selector.AllowNewSteps();
this->AddChild( &m_Selector ); this->AddChild( &m_Selector );
@@ -54,7 +54,7 @@ void ScreenEditMenu::HandleScreenMessage( const ScreenMessage SM )
switch( SM ) switch( SM )
{ {
case SM_RefreshSelector: case SM_RefreshSelector:
m_Selector.RefreshNotes(); m_Selector.RefreshSteps();
break; break;
case SM_GoToPrevScreen: case SM_GoToPrevScreen:
SCREENMAN->SetNewScreen( PREV_SCREEN ); SCREENMAN->SetNewScreen( PREV_SCREEN );
@@ -87,7 +87,7 @@ void ScreenEditMenu::MenuRight( PlayerNumber pn, const InputEventType type )
// helpers for MenuStart() below // helpers for MenuStart() below
void DeleteCurNotes( void* pThrowAway ) void DeleteCurSteps( void* pThrowAway )
{ {
Song* pSong = GAMESTATE->m_pCurSong; Song* pSong = GAMESTATE->m_pCurSong;
Steps* pStepsToDelete = GAMESTATE->m_pCurSteps[PLAYER_1]; Steps* pStepsToDelete = GAMESTATE->m_pCurSteps[PLAYER_1];
@@ -104,10 +104,10 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn )
Song* pSong = m_Selector.GetSelectedSong(); Song* pSong = m_Selector.GetSelectedSong();
StepsType st = m_Selector.GetSelectedStepsType(); StepsType st = m_Selector.GetSelectedStepsType();
Difficulty dc = m_Selector.GetSelectedDifficulty(); Difficulty dc = m_Selector.GetSelectedDifficulty();
Steps* pSteps = m_Selector.GetSelectedNotes(); Steps* pSteps = m_Selector.GetSelectedSteps();
// StepsType soureNT = m_Selector.GetSelectedSourceStepsType(); // StepsType soureNT = m_Selector.GetSelectedSourceStepsType();
// Difficulty sourceDiff = m_Selector.GetSelectedSourceDifficulty(); // Difficulty sourceDiff = m_Selector.GetSelectedSourceDifficulty();
Steps* pSourceNotes = m_Selector.GetSelectedSourceNotes(); Steps* pSourceSteps = m_Selector.GetSelectedSourceSteps();
EditMenu::Action action = m_Selector.GetSelectedAction(); EditMenu::Action action = m_Selector.GetSelectedAction();
GAMESTATE->m_pCurSong.Set( pSong ); GAMESTATE->m_pCurSong.Set( pSong );
@@ -135,41 +135,41 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn )
break; break;
case EditMenu::ACTION_DELETE: case EditMenu::ACTION_DELETE:
ASSERT( pSteps ); ASSERT( pSteps );
SCREENMAN->Prompt( SM_RefreshSelector, "These notes will be lost permanently.\n\nContinue with delete?", true, false, DeleteCurNotes ); SCREENMAN->Prompt( SM_RefreshSelector, "These steps will be lost permanently.\n\nContinue with delete?", true, false, DeleteCurSteps );
m_Selector.RefreshNotes(); m_Selector.RefreshSteps();
return; return;
case EditMenu::ACTION_COPY: case EditMenu::ACTION_COPY:
ASSERT( !pSteps ); ASSERT( !pSteps );
ASSERT( pSourceNotes ); ASSERT( pSourceSteps );
{ {
// Yuck. Doing the memory allocation doesn't seem right since // Yuck. Doing the memory allocation doesn't seem right since
// Song allocates all of the other Steps. // Song allocates all of the other Steps.
Steps* pNewNotes = new Steps; Steps* pNewSteps = new Steps;
pNewNotes->CopyFrom( pSourceNotes, st ); pNewSteps->CopyFrom( pSourceSteps, st );
pNewNotes->SetDifficulty( dc ); pNewSteps->SetDifficulty( dc );
pSong->AddSteps( pNewNotes ); pSong->AddSteps( pNewSteps );
SCREENMAN->SystemMessage( "Steps created from copy." ); SCREENMAN->SystemMessage( "Steps created from copy." );
SOUND->PlayOnce( THEME->GetPathS(m_sName,"create") ); SOUND->PlayOnce( THEME->GetPathS(m_sName,"create") );
m_Selector.RefreshNotes(); m_Selector.RefreshSteps();
pSong->Save(); pSong->Save();
} }
return; return;
case EditMenu::ACTION_AUTOGEN: case EditMenu::ACTION_AUTOGEN:
ASSERT( !pSteps ); ASSERT( !pSteps );
ASSERT( pSourceNotes ); ASSERT( pSourceSteps );
{ {
// Yuck. Doing the memory allocation doesn't seem right since // Yuck. Doing the memory allocation doesn't seem right since
// Song allocates all of the other Steps. // Song allocates all of the other Steps.
Steps* pNewNotes = new Steps; Steps* pNewSteps = new Steps;
pNewNotes->AutogenFrom( pSourceNotes, st ); pNewSteps->AutogenFrom( pSourceSteps, st );
pNewNotes->DeAutogen(); pNewSteps->DeAutogen();
pNewNotes->SetDifficulty( dc ); // override difficulty with the user's choice pNewSteps->SetDifficulty( dc ); // override difficulty with the user's choice
pSong->AddSteps( pNewNotes ); pSong->AddSteps( pNewSteps );
SCREENMAN->SystemMessage( "Steps created from AutoGen." ); SCREENMAN->SystemMessage( "Steps created from AutoGen." );
SOUND->PlayOnce( THEME->GetPathS(m_sName,"create") ); SOUND->PlayOnce( THEME->GetPathS(m_sName,"create") );
m_Selector.RefreshNotes(); m_Selector.RefreshSteps();
pSong->Save(); pSong->Save();
} }
return; return;
@@ -178,15 +178,15 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn )
{ {
// Yuck. Doing the memory allocation doesn't seem right since // Yuck. Doing the memory allocation doesn't seem right since
// Song allocates all of the other Steps. // Song allocates all of the other Steps.
Steps* pNewNotes = new Steps; Steps* pNewSteps = new Steps;
pNewNotes->CreateBlank( st ); pNewSteps->CreateBlank( st );
pNewNotes->SetDifficulty( dc ); pNewSteps->SetDifficulty( dc );
pNewNotes->SetMeter( 1 ); pNewSteps->SetMeter( 1 );
pSong->AddSteps( pNewNotes ); pSong->AddSteps( pNewSteps );
SCREENMAN->SystemMessage( "Blank Steps created." ); SCREENMAN->SystemMessage( "Blank Steps created." );
SOUND->PlayOnce( THEME->GetPathS(m_sName,"create") ); SOUND->PlayOnce( THEME->GetPathS(m_sName,"create") );
m_Selector.RefreshNotes(); m_Selector.RefreshSteps();
pSong->Save(); pSong->Save();
} }
return; return;