allow dynamically generated rows to override theming
remove unused EditAction row type
This commit is contained in:
@@ -31,7 +31,7 @@ StringToX( LayoutType );
|
||||
#define FOREACH_OptionsPlayer( pn ) \
|
||||
for( PlayerNumber pn=GetNextHumanPlayer((PlayerNumber)-1); pn!=PLAYER_INVALID && (!m_RowDef.bOneChoiceForAllPlayers || pn==0); pn=GetNextHumanPlayer(pn) )
|
||||
|
||||
#define PREPARE_ITEM_TEXT( s ) if( s!= "" ) { if( THEME_ITEMS ) s = THEME_OPTION_ITEM( s, false ); if( CAPITALIZE_ALL_OPTION_NAMES ) s.MakeUpper(); }
|
||||
#define PREPARE_ITEM_TEXT( s ) if( s!= "" ) { if( m_RowDef.m_bAllowThemeItems && THEME_ITEMS ) s = THEME_OPTION_ITEM( s, false ); if( CAPITALIZE_ALL_OPTION_NAMES ) s.MakeUpper(); }
|
||||
|
||||
static CString OPTION_TITLE( CString s ) { return THEME->GetMetric("OptionTitles",s); }
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ struct OptionRowDefinition
|
||||
vector<CString> choices;
|
||||
set<PlayerNumber> m_vEnabledForPlayers; // only players in this set may change focus to this row
|
||||
bool m_bExportOnChange;
|
||||
bool m_bAllowThemeItems; // if false, ignores ScreenOptions::THEME_ITEMS
|
||||
|
||||
bool IsEnabledForPlayer( PlayerNumber pn ) const
|
||||
{
|
||||
@@ -59,6 +60,7 @@ struct OptionRowDefinition
|
||||
FOREACH_PlayerNumber( pn )
|
||||
m_vEnabledForPlayers.insert( pn );
|
||||
m_bExportOnChange = false;
|
||||
m_bAllowThemeItems = true;
|
||||
}
|
||||
|
||||
OptionRowDefinition( const char *n, bool b, const char *c0=NULL, const char *c1=NULL, const char *c2=NULL, const char *c3=NULL, const char *c4=NULL, const char *c5=NULL, const char *c6=NULL, const char *c7=NULL, const char *c8=NULL, const char *c9=NULL, const char *c10=NULL, const char *c11=NULL, const char *c12=NULL, const char *c13=NULL, const char *c14=NULL, const char *c15=NULL, const char *c16=NULL, const char *c17=NULL, const char *c18=NULL, const char *c19=NULL )
|
||||
|
||||
@@ -248,6 +248,7 @@ public:
|
||||
|
||||
defOut.name = "NoteSkins";
|
||||
defOut.bOneChoiceForAllPlayers = false;
|
||||
defOut.m_bAllowThemeItems = false; // we theme the text ourself
|
||||
|
||||
CStringArray arraySkinNames;
|
||||
NOTESKIN->GetNoteSkinNames( arraySkinNames );
|
||||
@@ -272,6 +273,7 @@ public:
|
||||
|
||||
defOut.name = "Steps";
|
||||
defOut.bOneChoiceForAllPlayers = false;
|
||||
defOut.m_bAllowThemeItems = false; // we theme the text ourself
|
||||
|
||||
// fill in difficulty names
|
||||
if( GAMESTATE->m_bEditing )
|
||||
@@ -365,7 +367,7 @@ public:
|
||||
|
||||
defOut.bOneChoiceForAllPlayers = true;
|
||||
defOut.name = "Style";
|
||||
defOut.bOneChoiceForAllPlayers = true;
|
||||
defOut.m_bAllowThemeItems = false; // we theme the text ourself
|
||||
|
||||
vector<const Style*> vStyles;
|
||||
GAMEMAN->GetStylesForGame( GAMESTATE->m_pCurGame, vStyles );
|
||||
@@ -426,6 +428,7 @@ public:
|
||||
defOut.bOneChoiceForAllPlayers = true;
|
||||
defOut.name = "Difficulty";
|
||||
Default.m_dc = DIFFICULTY_INVALID;
|
||||
defOut.m_bAllowThemeItems = false; // we theme the text ourself
|
||||
|
||||
{
|
||||
defOut.choices.push_back( "AllDifficulties" );
|
||||
@@ -852,6 +855,7 @@ public:
|
||||
defOut.bOneChoiceForAllPlayers = true;
|
||||
defOut.layoutType = LAYOUT_SHOW_ONE_IN_ROW;
|
||||
defOut.m_bExportOnChange = true;
|
||||
defOut.m_bAllowThemeItems = false; // we theme the text ourself
|
||||
|
||||
// calculate which StepsTypes to show
|
||||
GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, m_vStepsTypesToShow );
|
||||
@@ -954,6 +958,7 @@ public:
|
||||
defOut.bOneChoiceForAllPlayers = true;
|
||||
defOut.layoutType = LAYOUT_SHOW_ONE_IN_ROW;
|
||||
defOut.m_bExportOnChange = true;
|
||||
defOut.m_bAllowThemeItems = false; // we theme the text ourself
|
||||
m_vsReloadRowMessages.push_back( MessageToString(MESSAGE_CURRENT_SONG_CHANGED) );
|
||||
|
||||
if( GAMESTATE->m_pCurSong )
|
||||
@@ -1047,167 +1052,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// helpers for MenuStart() below
|
||||
static void DeleteCurNotes( void* pThrowAway )
|
||||
{
|
||||
Song* pSong = GAMESTATE->m_pCurSong;
|
||||
Steps* pStepsToDelete = GAMESTATE->m_pCurSteps[PLAYER_1];
|
||||
pSong->RemoveSteps( pStepsToDelete );
|
||||
pSong->Save();
|
||||
|
||||
// refresh the list
|
||||
MESSAGEMAN->Broadcast( MESSAGE_CURRENT_SONG_CHANGED );
|
||||
}
|
||||
|
||||
|
||||
class OptionRowHandlerEditMenuAction : public OptionRowHandler
|
||||
{
|
||||
public:
|
||||
vector<EditMenuAction> m_vEditMenuActions;
|
||||
|
||||
OptionRowHandlerEditMenuAction::OptionRowHandlerEditMenuAction() { Init(); }
|
||||
void Init()
|
||||
{
|
||||
OptionRowHandler::Init();
|
||||
m_vEditMenuActions.clear();
|
||||
}
|
||||
|
||||
virtual void Load( OptionRowDefinition &defOut, CString sParam )
|
||||
{
|
||||
ASSERT( sParam.size() );
|
||||
|
||||
Init();
|
||||
defOut.Init();
|
||||
|
||||
m_sName = sParam;
|
||||
defOut.name = sParam;
|
||||
defOut.bOneChoiceForAllPlayers = true;
|
||||
defOut.layoutType = LAYOUT_SHOW_ONE_IN_ROW;
|
||||
m_vsReloadRowMessages.push_back( MessageToString(MESSAGE_CURRENT_STEPS_P1_CHANGED) );
|
||||
m_vsReloadRowMessages.push_back( MessageToString(MESSAGE_EDIT_SOURCE_STEPS_CHANGED) );
|
||||
|
||||
bool bHasSteps = GAMESTATE->m_pCurSteps[0] != NULL;
|
||||
bool bHasSourceSteps = GAMESTATE->m_pEditSourceSteps != NULL;
|
||||
FOREACH_EditMenuAction( ema )
|
||||
{
|
||||
switch( ema )
|
||||
{
|
||||
case EDIT_MENU_ACTION_EDIT:
|
||||
case EDIT_MENU_ACTION_DELETE:
|
||||
if( !bHasSteps )
|
||||
continue; // skip
|
||||
break;
|
||||
case EDIT_MENU_ACTION_COPY:
|
||||
case EDIT_MENU_ACTION_AUTOGEN:
|
||||
if( bHasSteps || !bHasSourceSteps )
|
||||
continue; // skip
|
||||
break;
|
||||
case EDIT_MENU_ACTION_BLANK:
|
||||
if( bHasSteps )
|
||||
continue; // skip
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
m_vEditMenuActions.push_back( ema );
|
||||
CString s = EditMenuActionToThemedString( ema );
|
||||
defOut.choices.push_back( s );
|
||||
}
|
||||
}
|
||||
virtual void ImportOption( const OptionRowDefinition &def, PlayerNumber pn, vector<bool> &vbSelectedOut ) const
|
||||
{
|
||||
vbSelectedOut[0] = true;
|
||||
}
|
||||
virtual int ExportOption( const OptionRowDefinition &def, PlayerNumber pn, const vector<bool> &vbSelected ) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
virtual CString GetAndEraseScreen( int iChoice )
|
||||
{
|
||||
Song* pSong = GAMESTATE->m_pCurSong;
|
||||
Steps *pSteps = GAMESTATE->m_pCurSteps[0];
|
||||
Difficulty dc = GAMESTATE->m_PreferredDifficulty[0];
|
||||
StepsType st = GAMESTATE->m_stEdit;
|
||||
Steps *pSourceNotes = GAMESTATE->m_pEditSourceSteps;
|
||||
|
||||
EditMenuAction ema = m_vEditMenuActions[iChoice];
|
||||
switch( ema )
|
||||
{
|
||||
case EDIT_MENU_ACTION_EDIT:
|
||||
// Prepare prepare for ScreenEdit
|
||||
ASSERT( pSong );
|
||||
ASSERT( pSteps );
|
||||
GAMESTATE->m_pCurStyle = GAMEMAN->GetEditorStyleForStepsType( st );
|
||||
return "ScreenEdit";
|
||||
break;
|
||||
case EDIT_MENU_ACTION_DELETE:
|
||||
ASSERT( pSteps );
|
||||
SCREENMAN->Prompt( SM_None, "These notes will be lost permanently.\n\nContinue with delete?", PROMPT_YES_NO, ANSWER_NO, DeleteCurNotes );
|
||||
break;
|
||||
case EDIT_MENU_ACTION_COPY:
|
||||
ASSERT( !pSteps );
|
||||
ASSERT( pSourceNotes );
|
||||
{
|
||||
// Yuck. Doing the memory allocation doesn't seem right since
|
||||
// Song allocates all of the other Steps.
|
||||
Steps* pNewSteps = new Steps;
|
||||
pNewSteps->CopyFrom( pSourceNotes, st );
|
||||
pNewSteps->SetDifficulty( dc );
|
||||
pSong->AddSteps( pNewSteps );
|
||||
|
||||
SCREENMAN->SystemMessage( "Steps created from copy." );
|
||||
SOUND->PlayOnce( THEME->GetPathS("ScreenEditMenu","create") );
|
||||
pSong->Save();
|
||||
}
|
||||
break;
|
||||
case EDIT_MENU_ACTION_AUTOGEN:
|
||||
ASSERT( !pSteps );
|
||||
ASSERT( pSourceNotes );
|
||||
{
|
||||
// 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 );
|
||||
|
||||
SCREENMAN->SystemMessage( "Steps created from AutoGen." );
|
||||
SOUND->PlayOnce( THEME->GetPathS("ScreenEditMenu","create") );
|
||||
pSong->Save();
|
||||
}
|
||||
break;
|
||||
case EDIT_MENU_ACTION_BLANK:
|
||||
ASSERT( !pSteps );
|
||||
{
|
||||
// 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 );
|
||||
|
||||
SCREENMAN->SystemMessage( "Blank Steps created." );
|
||||
SOUND->PlayOnce( THEME->GetPathS("ScreenEditMenu","create") );
|
||||
pSong->Save();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
// refresh the screen since we deleted or added steps
|
||||
MESSAGEMAN->Broadcast( MESSAGE_CURRENT_SONG_CHANGED );
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
OptionRowHandler* OptionRowHandlerUtil::Make( const Command &command, OptionRowDefinition &defOut )
|
||||
{
|
||||
OptionRowHandler* pHand = NULL;
|
||||
@@ -1223,7 +1069,6 @@ OptionRowHandler* OptionRowHandlerUtil::Make( const Command &command, OptionRowD
|
||||
else if( name == "conf" ) MAKE( OptionRowHandlerConfig )
|
||||
else if( name == "stepstype" ) MAKE( OptionRowHandlerStepsType )
|
||||
else if( name == "steps" ) MAKE( OptionRowHandlerSteps )
|
||||
else if( name == "editmenuaction" ) MAKE( OptionRowHandlerEditMenuAction )
|
||||
|
||||
EndHandleArgs;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user