theme edit menu row string

This commit is contained in:
Chris Danford
2005-03-07 23:55:18 +00:00
parent bf5d7435c4
commit 7904959f4f
3 changed files with 91 additions and 108 deletions
+42 -28
View File
@@ -11,6 +11,20 @@
#include "Foreach.h"
#include "CommonMetrics.h"
static const CString EditMenuRowNames[NUM_EDIT_MENU_ROWS] = {
"Group",
"Song",
"StepsType",
"Steps",
"SourceStepsType",
"SourceSteps",
"Action"
};
XToString( EditMenuRow, NUM_EDIT_MENU_ROWS );
XToThemedString( EditMenuRow, NUM_EDIT_MENU_ROWS );
#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")
@@ -44,7 +58,7 @@ EditMenu::EditMenu()
this->AddChild( &m_sprArrows[i] );
}
m_SelectedRow = (Row)0;
m_SelectedRow = (EditMenuRow)0;
ZERO( m_iSelection );
@@ -55,20 +69,20 @@ EditMenu::EditMenu()
for( int i=0; i<NUM_ROWS; i++ )
FOREACH_EditMenuRow( r )
{
m_textLabel[i].LoadFromFont( THEME->GetPathF("EditMenu","title") );
m_textLabel[i].SetXY( ROW_LABELS_X, ROW_Y(i) );
m_textLabel[i].SetText( RowToString((Row)i) );
m_textLabel[i].RunCommands( ROW_LABEL_ON_COMMAND );
m_textLabel[i].SetHorizAlign( Actor::align_left );
this->AddChild( &m_textLabel[i] );
m_textLabel[r].LoadFromFont( THEME->GetPathF("EditMenu","title") );
m_textLabel[r].SetXY( ROW_LABELS_X, ROW_Y(r) );
m_textLabel[r].SetText( EditMenuRowToThemedString(r) );
m_textLabel[r].RunCommands( ROW_LABEL_ON_COMMAND );
m_textLabel[r].SetHorizAlign( Actor::align_left );
this->AddChild( &m_textLabel[r] );
m_textValue[i].LoadFromFont( THEME->GetPathF("EditMenu","value") );
m_textValue[i].SetXY( ROW_VALUE_X(i), ROW_Y(i) );
m_textValue[i].SetText( "blah" );
m_textValue[i].RunCommands( ROW_VALUE_ON_COMMAND );
this->AddChild( &m_textValue[i] );
m_textValue[r].LoadFromFont( THEME->GetPathF("EditMenu","value") );
m_textValue[r].SetXY( ROW_VALUE_X(r), ROW_Y(r) );
m_textValue[r].SetText( "blah" );
m_textValue[r].RunCommands( ROW_VALUE_ON_COMMAND );
this->AddChild( &m_textValue[r] );
}
m_GroupBanner.SetXY( GROUP_BANNER_X, GROUP_BANNER_Y );
@@ -122,8 +136,8 @@ EditMenu::~EditMenu()
void EditMenu::RefreshAll()
{
ChangeToRow( (Row)0 );
OnRowValueChanged( (Row)0 );
ChangeToRow( (EditMenuRow)0 );
OnRowValueChanged( (EditMenuRow)0 );
// Select the current song if any
if( GAMESTATE->m_pCurSong )
@@ -175,7 +189,7 @@ bool EditMenu::CanGoUp()
bool EditMenu::CanGoDown()
{
return m_SelectedRow != NUM_ROWS-1;
return m_SelectedRow != NUM_EDIT_MENU_ROWS-1;
}
bool EditMenu::CanGoLeft()
@@ -185,7 +199,7 @@ bool EditMenu::CanGoLeft()
bool EditMenu::CanGoRight()
{
int num_values[NUM_ROWS] =
int num_values[NUM_EDIT_MENU_ROWS] =
{
m_sGroups.size(),
m_pSongs.size(),
@@ -206,7 +220,7 @@ void EditMenu::Up()
if( GetSelectedSteps() && m_SelectedRow==ROW_ACTION )
ChangeToRow( ROW_STEPS );
else
ChangeToRow( Row(m_SelectedRow-1) );
ChangeToRow( EditMenuRow(m_SelectedRow-1) );
m_soundChangeRow.PlayRandom();
}
}
@@ -218,7 +232,7 @@ void EditMenu::Down()
if( GetSelectedSteps() && m_SelectedRow==ROW_STEPS )
ChangeToRow( ROW_ACTION );
else
ChangeToRow( Row(m_SelectedRow+1) );
ChangeToRow( EditMenuRow(m_SelectedRow+1) );
m_soundChangeRow.PlayRandom();
}
}
@@ -244,7 +258,7 @@ void EditMenu::Right()
}
void EditMenu::ChangeToRow( Row newRow )
void EditMenu::ChangeToRow( EditMenuRow newRow )
{
m_SelectedRow = newRow;
@@ -256,7 +270,7 @@ void EditMenu::ChangeToRow( Row newRow )
m_sprArrows[1].EnableAnimation( CanGoRight() );
}
void EditMenu::OnRowValueChanged( Row row )
void EditMenu::OnRowValueChanged( EditMenuRow row )
{
m_sprArrows[0].SetDiffuse( CanGoLeft()?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) );
m_sprArrows[1].SetDiffuse( CanGoRight()?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) );
@@ -376,23 +390,23 @@ void EditMenu::OnRowValueChanged( Row row )
m_Actions.clear();
if( GetSelectedSteps() )
{
m_Actions.push_back( ACTION_EDIT );
m_Actions.push_back( ACTION_DELETE );
m_Actions.push_back( EDIT_MENU_ACTION_EDIT );
m_Actions.push_back( EDIT_MENU_ACTION_DELETE );
}
else if( GetSelectedSourceSteps() )
{
m_Actions.push_back( ACTION_COPY );
m_Actions.push_back( ACTION_AUTOGEN );
m_Actions.push_back( ACTION_BLANK );
m_Actions.push_back( EDIT_MENU_ACTION_COPY );
m_Actions.push_back( EDIT_MENU_ACTION_AUTOGEN );
m_Actions.push_back( EDIT_MENU_ACTION_BLANK );
}
else
{
m_Actions.push_back( ACTION_BLANK );
m_Actions.push_back( EDIT_MENU_ACTION_BLANK );
}
m_iSelection[ROW_ACTION] = 0;
// fall through
case ROW_ACTION:
m_textValue[ROW_ACTION].SetText( ActionToString(GetSelectedAction()) );
m_textValue[ROW_ACTION].SetText( EditMenuActionToThemedString(GetSelectedAction()) );
break;
default:
ASSERT(0); // invalid row
+31 -62
View File
@@ -9,6 +9,23 @@
#include "GameConstantsAndTypes.h"
#include "DifficultyMeter.h"
#include "RandomSample.h"
#include "EnumHelper.h"
enum EditMenuRow
{
ROW_GROUP,
ROW_SONG,
ROW_STEPS_TYPE,
ROW_STEPS,
ROW_SOURCE_STEPS_TYPE,
ROW_SOURCE_STEPS,
ROW_ACTION,
NUM_EDIT_MENU_ROWS
};
#define FOREACH_EditMenuRow( emr ) FOREACH_ENUM( EditMenuRow, NUM_EDIT_MENU_ROWS, emr )
const CString& RadarCategoryToString( RadarCategory cat );
const CString& RadarCategoryToThemedString( RadarCategory cat );
class EditMenu: public ActorFrame
@@ -28,64 +45,15 @@ public:
void Left();
void Right();
enum Row
{
ROW_GROUP,
ROW_SONG,
ROW_STEPS_TYPE,
ROW_STEPS,
ROW_SOURCE_STEPS_TYPE,
ROW_SOURCE_STEPS,
ROW_ACTION,
NUM_ROWS
} m_SelectedRow;
CString RowToString( Row r )
{
const CString s[NUM_ROWS] =
{
"Group",
"Song",
"StepsType",
"Steps",
"Source StepsType",
"Source Steps",
"Action"
};
return s[r];
}
enum Action
{
ACTION_EDIT,
ACTION_DELETE,
ACTION_COPY,
ACTION_AUTOGEN,
ACTION_BLANK,
NUM_ACTIONS
};
CString ActionToString( Action a )
{
const CString s[NUM_ACTIONS] =
{
"Edit Existing",
"Delete Existing",
"Create new from Source by Copy",
"Create new from Source by AutoGen",
"Create new empty"
};
return s[a];
}
void RefreshAll();
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]]; }
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]]; }
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]]; }
Steps* GetSelectedSourceSteps() const { ASSERT(m_iSelection[ROW_SOURCE_STEPS] < (int)m_vpSourceSteps.size()); return m_vpSourceSteps[m_iSelection[ROW_SOURCE_STEPS]]; }
EditMenuAction GetSelectedAction() const { ASSERT(m_iSelection[ROW_ACTION] < (int)m_Actions.size()); return m_Actions[m_iSelection[ROW_ACTION]]; }
Difficulty GetSelectedDifficulty();
Difficulty GetSelectedSourceDifficulty();
@@ -93,9 +61,10 @@ public:
private:
Sprite m_sprArrows[2];
int m_iSelection[NUM_ROWS];
BitmapText m_textLabel[NUM_ROWS];
BitmapText m_textValue[NUM_ROWS];
EditMenuRow m_SelectedRow;
int m_iSelection[NUM_EDIT_MENU_ROWS];
BitmapText m_textLabel[NUM_EDIT_MENU_ROWS];
BitmapText m_textValue[NUM_EDIT_MENU_ROWS];
FadingBanner m_GroupBanner;
FadingBanner m_SongBanner;
@@ -112,10 +81,10 @@ private:
vector<StepsType> m_StepsTypes;
vector<Steps*> m_vpSteps;
vector<Steps*> m_vpSourceSteps;
vector<Action> m_Actions;
vector<EditMenuAction> m_Actions;
void OnRowValueChanged( Row row );
void ChangeToRow( Row newRow );
void OnRowValueChanged( EditMenuRow row );
void ChangeToRow( EditMenuRow newRow );
RandomSample m_soundChangeRow;
RandomSample m_soundChangeValue;
+18 -18
View File
@@ -13,9 +13,9 @@
#include "Steps.h"
#include "song.h"
#define PREV_SCREEN THEME->GetMetric(m_sName,"PrevScreen")
#define EXPLANATION_TEXT THEME->GetMetric(m_sName,"ExplanationText")
#define HELP_TEXT THEME->GetMetric(m_sName,"HelpText")
#define PREV_SCREEN THEME->GetMetric(m_sName,"PrevScreen")
#define EXPLANATION_TEXT THEME->GetMetric(m_sName,"ExplanationText")
#define HELP_TEXT THEME->GetMetric(m_sName,"HelpText")
const ScreenMessage SM_RefreshSelector = (ScreenMessage)(SM_User+1);
@@ -111,14 +111,14 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn )
if( IsTransitioning() )
return;
Song* pSong = m_Selector.GetSelectedSong();
StepsType st = m_Selector.GetSelectedStepsType();
Difficulty dc = m_Selector.GetSelectedDifficulty();
Steps* pSteps = m_Selector.GetSelectedSteps();
// StepsType soureNT = m_Selector.GetSelectedSourceStepsType();
// Difficulty sourceDiff = m_Selector.GetSelectedSourceDifficulty();
Steps* pSourceSteps = m_Selector.GetSelectedSourceSteps();
EditMenu::Action action = m_Selector.GetSelectedAction();
Song* pSong = m_Selector.GetSelectedSong();
StepsType st = m_Selector.GetSelectedStepsType();
Difficulty dc = m_Selector.GetSelectedDifficulty();
Steps* pSteps = m_Selector.GetSelectedSteps();
// StepsType soureNT = m_Selector.GetSelectedSourceStepsType();
// Difficulty sourceDiff = m_Selector.GetSelectedSourceDifficulty();
Steps* pSourceSteps = m_Selector.GetSelectedSourceSteps();
EditMenuAction action = m_Selector.GetSelectedAction();
GAMESTATE->m_pCurSong.Set( pSong );
GAMESTATE->m_pCurStyle = GAMEMAN->GetEditorStyleForStepsType( st );
@@ -136,20 +136,20 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn )
switch( action )
{
case EditMenu::ACTION_EDIT:
case EDIT_MENU_ACTION_EDIT:
// Prepare prepare for ScreenEdit
ASSERT( pSteps );
SOUND->StopMusic();
SCREENMAN->PlayStartSound();
StartTransitioning( SM_GoToNextScreen );
break;
case EditMenu::ACTION_DELETE:
case EDIT_MENU_ACTION_DELETE:
ASSERT( pSteps );
SCREENMAN->Prompt( SM_RefreshSelector, "These steps will be lost permanently.\n\nContinue with delete?", true, false, DeleteCurSteps );
m_Selector.RefreshAll();
return;
case EditMenu::ACTION_COPY:
case EditMenu::ACTION_AUTOGEN:
case EDIT_MENU_ACTION_COPY:
case EDIT_MENU_ACTION_AUTOGEN:
ASSERT( !pSteps );
ASSERT( pSourceSteps );
{
@@ -158,10 +158,10 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn )
Steps* pNewSteps = new Steps;
switch( action )
{
case EditMenu::ACTION_COPY:
case EDIT_MENU_ACTION_COPY:
pNewSteps->CopyFrom( pSourceSteps, st );
break;
case EditMenu::ACTION_AUTOGEN:
case EDIT_MENU_ACTION_AUTOGEN:
pNewSteps->AutogenFrom( pSourceSteps, st );
pNewSteps->DeAutogen();
break;
@@ -184,7 +184,7 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn )
m_Selector.RefreshAll();
}
return;
case EditMenu::ACTION_BLANK:
case EDIT_MENU_ACTION_BLANK:
ASSERT( !pSteps );
{
// Yuck. Doing the memory allocation doesn't seem right since