Validate changes to edit descriptions. Ignore attempts to clear
descriptions for edits (that'd be like renaming a file to not have a filename).
This commit is contained in:
@@ -2435,9 +2435,44 @@ void ScreenEdit::OnSnapModeChange()
|
|||||||
static void ChangeDescription( const CString &sNew )
|
static void ChangeDescription( const CString &sNew )
|
||||||
{
|
{
|
||||||
Steps* pSteps = GAMESTATE->m_pCurSteps[PLAYER_1];
|
Steps* pSteps = GAMESTATE->m_pCurSteps[PLAYER_1];
|
||||||
|
|
||||||
|
/* Don't erase edit descriptions. */
|
||||||
|
if( sNew.empty() && pSteps->GetDifficulty() == DIFFICULTY_EDIT )
|
||||||
|
return;
|
||||||
|
|
||||||
pSteps->SetDescription(sNew);
|
pSteps->SetDescription(sNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool ValidateDescription( const CString &sAnswer, CString &sErrorOut )
|
||||||
|
{
|
||||||
|
if( sAnswer.empty() )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/* Don't allow duplicate edit names within the same StepsType; edit names uniquely
|
||||||
|
* identify the edit. */
|
||||||
|
Steps *pSteps = GAMESTATE->m_pCurSteps[PLAYER_1];
|
||||||
|
Song *pSong = GAMESTATE->m_pCurSong;
|
||||||
|
if( pSteps->GetDifficulty() != DIFFICULTY_EDIT )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/* If unchanged: */
|
||||||
|
if( pSteps->GetDescription() == sAnswer )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
vector<Steps*> apSteps;
|
||||||
|
pSong->GetSteps( apSteps, pSteps->m_StepsType, DIFFICULTY_EDIT, -1, -1, sAnswer );
|
||||||
|
|
||||||
|
if( apSteps.size() == 0 )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/* The name is already used, */
|
||||||
|
if( apSteps.size() > 1 )
|
||||||
|
LOG->Warn( "Multiple edits for song \"%s\" named \"%s\"", pSong->GetSongDir().c_str(), sAnswer.c_str() );
|
||||||
|
|
||||||
|
sErrorOut = "The supplied name supplied conflicts with another edit.\n\nPlease use a different name.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static void ChangeMainTitle( const CString &sNew )
|
static void ChangeMainTitle( const CString &sNew )
|
||||||
{
|
{
|
||||||
Song* pSong = GAMESTATE->m_pCurSong;
|
Song* pSong = GAMESTATE->m_pCurSong;
|
||||||
@@ -3031,7 +3066,7 @@ void ScreenEdit::HandleStepsInformationChoice( StepsInformationChoice c, const v
|
|||||||
ENTER_NEW_DESCRIPTION,
|
ENTER_NEW_DESCRIPTION,
|
||||||
m_pSteps->GetDescription(),
|
m_pSteps->GetDescription(),
|
||||||
(dc == DIFFICULTY_EDIT) ? MAX_EDIT_STEPS_DESCRIPTION_LENGTH : 255,
|
(dc == DIFFICULTY_EDIT) ? MAX_EDIT_STEPS_DESCRIPTION_LENGTH : 255,
|
||||||
NULL,
|
ValidateDescription,
|
||||||
ChangeDescription,
|
ChangeDescription,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user