diff --git a/stepmania/src/CourseUtil.cpp b/stepmania/src/CourseUtil.cpp index 9756f26bf0..5c55d47a74 100644 --- a/stepmania/src/CourseUtil.cpp +++ b/stepmania/src/CourseUtil.cpp @@ -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 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; +} ////////////////////////////////// diff --git a/stepmania/src/CourseUtil.h b/stepmania/src/CourseUtil.h index c216fbb266..9d715f4da1 100644 --- a/stepmania/src/CourseUtil.h +++ b/stepmania/src/CourseUtil.h @@ -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 aSongs, Difficulty dc, Course &out ); + + bool ValidateEditCourseName( const RString &sAnswer, RString &sErrorOut ); }; class CourseID