add metric to show only edits and hide the regular difficulties

This commit is contained in:
Chris Danford
2005-03-07 05:25:28 +00:00
parent e65362e3f5
commit 6e5ea68fbf
3 changed files with 104 additions and 45 deletions
+2
View File
@@ -2146,6 +2146,7 @@ TextZoom=0.8
NextScreen=ScreenRanking NextScreen=ScreenRanking
[EditMenu] [EditMenu]
OnlyAllowEdits=0
Arrows1X=190 Arrows1X=190
Arrows2X=590 Arrows2X=590
SongBannerX=490 SongBannerX=490
@@ -2180,6 +2181,7 @@ Row7Y=340
[ScreenEditMenu] [ScreenEditMenu]
Fallback=ScreenWithMenuElements Fallback=ScreenWithMenuElements
PrevScreen=@ScreenTitleBranch()
Class=ScreenEditMenu Class=ScreenEditMenu
ExplanationX=320 ExplanationX=320
ExplanationY=410 ExplanationY=410
+89 -36
View File
@@ -8,7 +8,9 @@
#include "Steps.h" #include "Steps.h"
#include "song.h" #include "song.h"
#include "StepsUtil.h" #include "StepsUtil.h"
#include "Foreach.h"
#define ONLY_ALLOW_EDITS THEME->GetMetricF("EditMenu","OnlyAllowEdits")
#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")
@@ -95,7 +97,29 @@ EditMenu::EditMenu()
// fill in data structures // fill in data structures
SONGMAN->GetGroupNames( m_sGroups ); SONGMAN->GetGroupNames( m_sGroups );
GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, m_StepsTypes ); GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, m_StepsTypes );
if( ONLY_ALLOW_EDITS )
{
m_vDifficulties.push_back( DIFFICULTY_EDIT );
}
else
{
FOREACH_Difficulty( dc )
m_vDifficulties.push_back( dc );
}
FOREACH_Difficulty( dc )
m_vSourceDifficulties.push_back( dc );
RefreshAll();
}
EditMenu::~EditMenu()
{
}
void EditMenu::RefreshAll()
{
ChangeToRow( (Row)0 ); ChangeToRow( (Row)0 );
OnRowValueChanged( (Row)0 ); OnRowValueChanged( (Row)0 );
@@ -124,26 +148,19 @@ EditMenu::EditMenu()
} }
} }
vector<Steps*>::const_iterator iter = find( m_vpSteps.begin(), m_vpSteps.end(), GAMESTATE->m_pCurSteps[PLAYER_1] ); for( int i=0; i<m_vpSteps.size(); i++ )
if( iter != m_vpSteps.end() )
{ {
m_iSelection[ROW_STEPS] = iter - m_vpSteps.begin(); const Steps *pSteps = m_vpSteps[i];
OnRowValueChanged( ROW_STEPS ); if( pSteps == GAMESTATE->m_pCurSteps[PLAYER_1] )
{
m_iSelection[ROW_STEPS] = i;
OnRowValueChanged( ROW_STEPS );
}
} }
} }
} }
} }
EditMenu::~EditMenu()
{
}
void EditMenu::RefreshAll()
{
OnRowValueChanged( ROW_SONG );
}
void EditMenu::DrawPrimitives() void EditMenu::DrawPrimitives()
{ {
ActorFrame::DrawPrimitives(); ActorFrame::DrawPrimitives();
@@ -262,28 +279,45 @@ void EditMenu::OnRowValueChanged( Row row )
// fall through // fall through
case ROW_STEPS_TYPE: case ROW_STEPS_TYPE:
m_textValue[ROW_STEPS_TYPE].SetText( GAMEMAN->StepsTypeToThemedString(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 CLAMP( m_iSelection[ROW_STEPS], 0, m_vDifficulties.size()-1 ); // jump back to the slot for DIFFICULTY_EDIT
m_vpSteps.clear(); m_vpSteps.clear();
GetSelectedSong()->GetSteps( m_vpSteps, GetSelectedStepsType() ); FOREACH( Difficulty, m_vDifficulties, dc )
StepsUtil::SortStepsByDescription( m_vpSteps );
StepsUtil::SortStepsByTypeAndDifficulty( m_vpSteps );
FOREACH_Difficulty( dc )
{ {
Steps *pSteps = dc < m_vpSteps.size() ? m_vpSteps[dc] : NULL; if( *dc == DIFFICULTY_EDIT )
if( pSteps == NULL || pSteps->GetDifficulty() != dc ) {
m_vpSteps.insert( m_vpSteps.begin()+dc, NULL ); vector<Steps*> v;
GetSelectedSong()->GetSteps( v, GetSelectedStepsType(), DIFFICULTY_EDIT );
StepsUtil::SortStepsByDescription( v );
m_vpSteps.insert( m_vpSteps.end(), v.begin(), v.end() );
m_vpSteps.push_back( NULL ); // "New Edit"
}
else
{
Steps *pSteps = GetSelectedSong()->GetStepsByDifficulty( GetSelectedStepsType(), *dc );
m_vpSteps.push_back( pSteps );
}
} }
if( GetSelectedSong()->HasEdits(GetSelectedStepsType()) )
m_vpSteps.push_back( NULL ); // for "New Edit"
// fall through // fall through
case ROW_STEPS: case ROW_STEPS:
{ {
CString s; CString s;
Steps *pSteps = GetSelectedSteps(); Steps *pSteps = GetSelectedSteps();
if( pSteps && GetSelectedDifficulty() == DIFFICULTY_EDIT ) if( pSteps && GetSelectedDifficulty() == DIFFICULTY_EDIT )
s = pSteps->GetDescription() + " (" + DifficultyToThemedString(DIFFICULTY_EDIT) + ")"; {
if( pSteps->GetDescription().empty() )
s += "-no name-";
else
s += pSteps->GetDescription();
s += " (" + DifficultyToThemedString(DIFFICULTY_EDIT) + ")";
}
else else
{
s = DifficultyToThemedString(GetSelectedDifficulty()); s = DifficultyToThemedString(GetSelectedDifficulty());
// UGLY. "Edit" -> "New Edit"
if( ONLY_ALLOW_EDITS )
s = "New " + s;
}
m_textValue[ROW_STEPS].SetText( s ); m_textValue[ROW_STEPS].SetText( s );
} }
if( GetSelectedSteps() ) if( GetSelectedSteps() )
@@ -296,18 +330,24 @@ void EditMenu::OnRowValueChanged( Row row )
m_textValue[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()) ); 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 CLAMP( m_iSelection[ROW_SOURCE_STEPS], 0, m_vSourceDifficulties.size()-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 );
}
m_vpSourceSteps.clear();
FOREACH( Difficulty, m_vSourceDifficulties, dc )
{
if( *dc == DIFFICULTY_EDIT )
{
vector<Steps*> v;
GetSelectedSong()->GetSteps( v, GetSelectedStepsType(), DIFFICULTY_EDIT );
StepsUtil::SortStepsByDescription( v );
m_vpSourceSteps.insert( m_vpSourceSteps.end(), v.begin(), v.end() );
}
else
{
Steps *pSteps = GetSelectedSong()->GetStepsByDifficulty( GetSelectedStepsType(), *dc );
m_vpSourceSteps.push_back( pSteps );
}
}
// fall through // fall through
case ROW_SOURCE_STEPS: case ROW_SOURCE_STEPS:
m_textLabel[ROW_SOURCE_STEPS].SetHidden( GetSelectedSteps() ? true : false ); m_textLabel[ROW_SOURCE_STEPS].SetHidden( GetSelectedSteps() ? true : false );
@@ -353,6 +393,19 @@ void EditMenu::OnRowValueChanged( Row row )
} }
} }
Difficulty EditMenu::GetSelectedDifficulty()
{
int i = m_iSelection[ROW_STEPS];
CLAMP( i, 0, m_vDifficulties.size()-1 );
return m_vDifficulties[i];
}
Difficulty EditMenu::GetSelectedSourceDifficulty()
{
int i = m_iSelection[ROW_SOURCE_STEPS];
CLAMP( i, 0, m_vSourceDifficulties.size()-1 );
return m_vSourceDifficulties[i];
}
/* /*
* (c) 2001-2004 Chris Danford * (c) 2001-2004 Chris Danford
+15 -11
View File
@@ -69,9 +69,9 @@ public:
{ {
"Edit Existing", "Edit Existing",
"Delete Existing", "Delete Existing",
"Create from Source by Copy", "Create new from Source by Copy",
"Create from Souce by AutoGen", "Create new from Source by AutoGen",
"Create with Blank" "Create new empty"
}; };
return s[a]; return s[a];
} }
@@ -87,8 +87,8 @@ public:
Steps* GetSelectedSourceSteps() const { ASSERT(m_iSelection[ROW_SOURCE_STEPS] < (int)m_vpSourceSteps.size()); return m_vpSourceSteps[m_iSelection[ROW_SOURCE_STEPS]]; } 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]]; }
Difficulty GetSelectedDifficulty() { int iDifficulty = m_iSelection[ROW_STEPS]; CLAMP(iDifficulty,0,NUM_DIFFICULTIES-1); return (Difficulty)iDifficulty; } Difficulty GetSelectedDifficulty();
Difficulty GetSelectedSourceDifficulty() { int iDifficulty = m_iSelection[ROW_SOURCE_STEPS]; CLAMP(iDifficulty,0,NUM_DIFFICULTIES-1); return (Difficulty)iDifficulty; } Difficulty GetSelectedSourceDifficulty();
private: private:
Sprite m_sprArrows[2]; Sprite m_sprArrows[2];
@@ -103,12 +103,16 @@ private:
DifficultyMeter m_Meter; DifficultyMeter m_Meter;
DifficultyMeter m_SourceMeter; DifficultyMeter m_SourceMeter;
CStringArray m_sGroups;
vector<Song*> m_pSongs; vector<Difficulty> m_vDifficulties;
vector<StepsType> m_StepsTypes; vector<Difficulty> m_vSourceDifficulties;
vector<Steps*> m_vpSteps;
vector<Steps*> m_vpSourceSteps; CStringArray m_sGroups;
vector<Action> m_Actions; vector<Song*> m_pSongs;
vector<StepsType> m_StepsTypes;
vector<Steps*> m_vpSteps;
vector<Steps*> m_vpSourceSteps;
vector<Action> m_Actions;
void OnRowValueChanged( Row row ); void OnRowValueChanged( Row row );
void ChangeToRow( Row newRow ); void ChangeToRow( Row newRow );