add CourseNameValidation

This commit is contained in:
Chris Danford
2006-07-03 00:04:44 +00:00
parent 66d25f70ec
commit d743fc5a65
2 changed files with 26 additions and 0 deletions
+24
View File
@@ -10,6 +10,7 @@
#include "Style.h"
#include "Foreach.h"
#include "GameState.h"
#include "LocalizedString.h"
//
@@ -292,6 +293,29 @@ void CourseUtil::AutogenOniFromArtist( const RString &sArtistName, RString sArti
}
}
static LocalizedString EDIT_NAME_CONFLICTS ( "ScreenOptionsManageCourses", "The name you chose conflicts with another edit. Please use a different name." );
bool CourseUtil::ValidateEditCourseName( const RString &sAnswer, RString &sErrorOut )
{
if( sAnswer.empty() )
return false;
// Course name must be unique
vector<Course*> v;
SONGMAN->GetAllCourses( v, false );
FOREACH_CONST( Course*, v, c )
{
if( GAMESTATE->m_pCurCourse.Get() == *c )
continue; // don't compare name against ourself
if( (*c)->GetDisplayFullTitle() == sAnswer )
{
sErrorOut = EDIT_NAME_CONFLICTS;
return false;
}
}
return true;
}
//////////////////////////////////
+2
View File
@@ -31,6 +31,8 @@ namespace CourseUtil
void AutogenEndlessFromGroup( const RString &sGroupName, Difficulty dc, Course &out );
void AutogenNonstopFromGroup( const RString &sGroupName, Difficulty dc, Course &out );
void AutogenOniFromArtist( const RString &sArtistName, RString sArtistNameTranslit, vector<Song*> aSongs, Difficulty dc, Course &out );
bool ValidateEditCourseName( const RString &sAnswer, RString &sErrorOut );
};
class CourseID