more work on course editor
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "GameState.h"
|
||||
#include "Style.h"
|
||||
#include "Foreach.h"
|
||||
#include "GameState.h"
|
||||
|
||||
|
||||
//
|
||||
@@ -188,6 +189,11 @@ void CourseUtil::SortByMostRecentlyPlayedForMachine( vector<Course*> &vpCoursesI
|
||||
course_sort_val.clear();
|
||||
}
|
||||
|
||||
void CourseUtil::MakeDefaultEditCourseEntry( CourseEntry& out )
|
||||
{
|
||||
out.pSong = GAMESTATE->GetDefaultSong();
|
||||
out.baseDifficulty = DIFFICULTY_MEDIUM;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
class Course;
|
||||
class Profile;
|
||||
struct XNode;
|
||||
class CourseEntry;
|
||||
|
||||
namespace CourseUtil
|
||||
{
|
||||
@@ -22,6 +23,8 @@ namespace CourseUtil
|
||||
void SortByMostRecentlyPlayedForMachine( vector<Course*> &vpCoursesInOut );
|
||||
|
||||
void MoveRandomToEnd( vector<Course*> &vpCoursesInOut );
|
||||
|
||||
void MakeDefaultEditCourseEntry( CourseEntry &out );
|
||||
};
|
||||
|
||||
class CourseID
|
||||
|
||||
@@ -57,7 +57,7 @@ SortOrder GetDefaultSort()
|
||||
return StringToSortOrder( DEFAULT_SORT );
|
||||
}
|
||||
ThemeMetric<CString> DEFAULT_SONG ("GameState","DefaultSong");
|
||||
Song* GetDefaultSong()
|
||||
Song* GameState::GetDefaultSong() const
|
||||
{
|
||||
SongID sid;
|
||||
sid.LoadFromDir( DEFAULT_SONG );
|
||||
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
void PlayersFinalized(); // called after a style is chosen, which means the number of players is finalized
|
||||
void EndGame(); // called on ScreenGameOver, ScreenMusicScroll, ScreenCredits
|
||||
void SaveCurrentSettingsToProfile( PlayerNumber pn ); // called at the beginning of each stage
|
||||
Song* GetDefaultSong() const;
|
||||
|
||||
void Update( float fDelta );
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "song.h"
|
||||
#include "ScreenMiniMenu.h"
|
||||
#include "ScreenPrompt.h"
|
||||
#include "CourseUtil.h"
|
||||
|
||||
enum EditCourseRow
|
||||
{
|
||||
@@ -140,7 +141,9 @@ void ScreenOptionsEditCourse::HandleScreenMessage( const ScreenMessage SM )
|
||||
ScreenPrompt::Prompt( SM_None, sError );
|
||||
return;
|
||||
}
|
||||
pCourse->m_vEntries.insert( pCourse->m_vEntries.begin() + GetCourseEntryIndexWithFocus(), CourseEntry() );
|
||||
CourseEntry ce;
|
||||
CourseUtil::MakeDefaultEditCourseEntry( ce );
|
||||
pCourse->m_vEntries.insert( pCourse->m_vEntries.begin() + GetCourseEntryIndexWithFocus(), ce );
|
||||
SCREENMAN->SetNewScreen( this->m_sName ); // reload
|
||||
}
|
||||
break;
|
||||
@@ -252,7 +255,9 @@ void ScreenOptionsEditCourse::ProcessMenuStart( PlayerNumber pn, const InputEven
|
||||
ScreenPrompt::Prompt( SM_None, sError );
|
||||
return;
|
||||
}
|
||||
pCourse->m_vEntries.push_back( CourseEntry() );
|
||||
CourseEntry ce;
|
||||
CourseUtil::MakeDefaultEditCourseEntry( ce );
|
||||
pCourse->m_vEntries.push_back( ce );
|
||||
GAMESTATE->m_iEditCourseEntryIndex.Set( pCourse->m_vEntries.size()-1 );
|
||||
SCREENMAN->SetNewScreen( this->m_sName ); // reload
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "ScreenMiniMenu.h"
|
||||
#include "GameManager.h"
|
||||
#include "Difficulty.h"
|
||||
#include "CourseUtil.h"
|
||||
|
||||
static void RefreshTrail()
|
||||
{
|
||||
@@ -82,7 +83,8 @@ void ScreenOptionsEditCourseSubMenu::MenuSelect( PlayerNumber pn, const InputEve
|
||||
|
||||
|
||||
|
||||
AutoScreenMessage( SM_BackFromEnterName )
|
||||
AutoScreenMessage( SM_BackFromEnterNameForNew )
|
||||
AutoScreenMessage( SM_BackFromRename )
|
||||
AutoScreenMessage( SM_BackFromDeleteConfirm )
|
||||
AutoScreenMessage( SM_BackFromContextMenu )
|
||||
|
||||
@@ -105,6 +107,28 @@ static MenuDef g_TempMenu(
|
||||
"ScreenMiniMenuContext"
|
||||
);
|
||||
|
||||
|
||||
static bool ValidateEditCourseName( const CString &sAnswer, CString &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 comepare name against ourself
|
||||
|
||||
if( (*c)->GetDisplayFullTitle() == sAnswer )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
REGISTER_SCREEN_CLASS( ScreenOptionsManageCourses );
|
||||
ScreenOptionsManageCourses::ScreenOptionsManageCourses( CString sName ) : ScreenOptionsEditCourseSubMenu( sName )
|
||||
{
|
||||
@@ -212,7 +236,7 @@ void ScreenOptionsManageCourses::HandleScreenMessage( const ScreenMessage SM )
|
||||
return; // don't call base
|
||||
}
|
||||
}
|
||||
else if( SM == SM_BackFromEnterName )
|
||||
else if( SM == SM_BackFromEnterNameForNew )
|
||||
{
|
||||
if( !ScreenTextEntry::s_bCancelledLast )
|
||||
{
|
||||
@@ -225,8 +249,9 @@ void ScreenOptionsManageCourses::HandleScreenMessage( const ScreenMessage SM )
|
||||
Course *pCourse = new Course;
|
||||
pCourse->m_sMainTitle = ScreenTextEntry::s_sLastAnswer;
|
||||
pCourse->SetLoadedFromProfile( PROFILE_SLOT_MACHINE );
|
||||
pCourse->m_vEntries.push_back( CourseEntry() ); // one blank entry
|
||||
pCourse->m_vEntries[0].baseDifficulty = DIFFICULTY_MEDIUM;
|
||||
CourseEntry ce;
|
||||
CourseUtil::MakeDefaultEditCourseEntry( ce );
|
||||
pCourse->m_vEntries.push_back( ce );
|
||||
SONGMAN->AddCourse( pCourse );
|
||||
GAMESTATE->m_pCurCourse.Set( pCourse );
|
||||
|
||||
@@ -235,6 +260,17 @@ void ScreenOptionsManageCourses::HandleScreenMessage( const ScreenMessage SM )
|
||||
this->HandleScreenMessage( SM_GoToNextScreen );
|
||||
}
|
||||
}
|
||||
else if( SM == SM_BackFromRename )
|
||||
{
|
||||
if( !ScreenTextEntry::s_bCancelledLast )
|
||||
{
|
||||
ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this
|
||||
|
||||
GAMESTATE->m_pCurCourse->m_sMainTitle = ScreenTextEntry::s_sLastAnswer;
|
||||
|
||||
SCREENMAN->SetNewScreen( this->m_sName ); // reload
|
||||
}
|
||||
}
|
||||
else if( SM == SM_BackFromDeleteConfirm )
|
||||
{
|
||||
if( ScreenPrompt::s_LastAnswer == ANSWER_YES )
|
||||
@@ -261,13 +297,12 @@ void ScreenOptionsManageCourses::HandleScreenMessage( const ScreenMessage SM )
|
||||
break;
|
||||
case CourseAction_Rename:
|
||||
{
|
||||
CString sCurrentProfileName = "New Course";
|
||||
ScreenTextEntry::TextEntry(
|
||||
SM_BackFromEnterName,
|
||||
"Enter a name for a new course.",
|
||||
sCurrentProfileName,
|
||||
SM_BackFromRename,
|
||||
"Enter a name for the course.",
|
||||
GAMESTATE->m_pCurCourse->GetDisplayFullTitle(),
|
||||
MAX_EDIT_COURSE_TITLE_LENGTH,
|
||||
SongManager::ValidateEditCourseName );
|
||||
ValidateEditCourseName );
|
||||
}
|
||||
break;
|
||||
case CourseAction_Delete:
|
||||
@@ -301,13 +336,20 @@ void ScreenOptionsManageCourses::ProcessMenuStart( PlayerNumber pn, const InputE
|
||||
|
||||
if( iCurRow == 0 ) // "create new"
|
||||
{
|
||||
CString sCurrentProfileName = "New Course";
|
||||
CString sDefaultName;
|
||||
CString sThrowAway;
|
||||
for( int i=1; i<=9999; i++ )
|
||||
{
|
||||
sDefaultName = ssprintf( "NewCourse%04d", i );
|
||||
if( ValidateEditCourseName(sDefaultName,sThrowAway) )
|
||||
break;
|
||||
}
|
||||
ScreenTextEntry::TextEntry(
|
||||
SM_BackFromEnterName,
|
||||
SM_BackFromEnterNameForNew,
|
||||
"Enter a name for a new course.",
|
||||
sCurrentProfileName,
|
||||
sDefaultName,
|
||||
MAX_EDIT_COURSE_TITLE_LENGTH,
|
||||
SongManager::ValidateEditCourseName );
|
||||
ValidateEditCourseName );
|
||||
}
|
||||
else if( iCurRow == (int)m_pRows.size()-1 ) // "done"
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user