Mostly functional course editor. (It's not pretty, but then I have no ability/experience with graphics/metrics.) You can create, edit, and delete courses. I'm not sure about setting mods yet.
This commit is contained in:
@@ -138,12 +138,16 @@ void ScreenOptionsEditCourse::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
int iCurRow = m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber];
|
int iCurRow = m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber];
|
||||||
if( iCurRow == (int)m_pRows.size() - 1 )
|
if( iCurRow == (int)m_pRows.size() - 1 )
|
||||||
{
|
{
|
||||||
|
m_Original = *pCourse;
|
||||||
|
WriteCourse();
|
||||||
this->HandleScreenMessage( SM_GoToPrevScreen );
|
this->HandleScreenMessage( SM_GoToPrevScreen );
|
||||||
return; // don't call base
|
return; // don't call base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( SM == SM_GoToPrevScreen )
|
else if( SM == SM_GoToPrevScreen )
|
||||||
{
|
{
|
||||||
|
*pCourse = m_Original;
|
||||||
|
GAMESTATE->m_pCurCourse.Set( pCourse );
|
||||||
GAMESTATE->m_iEditCourseEntryIndex.Set( -1 );
|
GAMESTATE->m_iEditCourseEntryIndex.Set( -1 );
|
||||||
}
|
}
|
||||||
else if( SM == SM_BackFromContextMenu )
|
else if( SM == SM_BackFromContextMenu )
|
||||||
|
|||||||
@@ -13,12 +13,21 @@
|
|||||||
#include "CourseUtil.h"
|
#include "CourseUtil.h"
|
||||||
#include "LocalizedString.h"
|
#include "LocalizedString.h"
|
||||||
#include "OptionRowHandler.h"
|
#include "OptionRowHandler.h"
|
||||||
|
#include "ProfileManager.h"
|
||||||
|
#include "Profile.h"
|
||||||
|
#include "CourseWriterCRS.h"
|
||||||
|
#include "RageFileManager.h"
|
||||||
|
|
||||||
|
static ThemeMetricEnum<EditMode> EDIT_MODE;
|
||||||
|
|
||||||
static void RefreshTrail()
|
static void RefreshTrail()
|
||||||
{
|
{
|
||||||
Course *pCourse = GAMESTATE->m_pCurCourse;
|
Course *pCourse = GAMESTATE->m_pCurCourse;
|
||||||
if( pCourse == NULL )
|
if( pCourse == NULL )
|
||||||
|
{
|
||||||
|
GAMESTATE->m_pCurTrail[PLAYER_1].Set( NULL );
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
GAMESTATE->m_pCurCourse.Set( pCourse );
|
GAMESTATE->m_pCurCourse.Set( pCourse );
|
||||||
Trail *pTrail = pCourse->GetTrail( GAMESTATE->m_stEdit, GAMESTATE->m_cdEdit );
|
Trail *pTrail = pCourse->GetTrail( GAMESTATE->m_stEdit, GAMESTATE->m_cdEdit );
|
||||||
GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail );
|
GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail );
|
||||||
@@ -77,6 +86,29 @@ void ScreenOptionsEditCourseSubMenu::MenuSelect( const InputEventPlus &input )
|
|||||||
ScreenOptions::MenuSelect( input );
|
ScreenOptions::MenuSelect( input );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LocalizedString FAILED_TO_WRITE_COURSE( "ScreenOptionsEditCourseSubMenu", "Failed to write course." );
|
||||||
|
void ScreenOptionsEditCourseSubMenu::WriteCourse()
|
||||||
|
{
|
||||||
|
Course *pCourse = GAMESTATE->m_pCurCourse;
|
||||||
|
|
||||||
|
if( pCourse->m_sPath.empty() )
|
||||||
|
{
|
||||||
|
// Write the course to the profile directory
|
||||||
|
const RString& dir = PROFILEMAN->GetProfileDir( pCourse->GetLoadedFromProfileSlot() );
|
||||||
|
|
||||||
|
ASSERT( !dir.empty() );
|
||||||
|
pCourse->m_sPath = dir + EDIT_COURSES_SUBDIR + pCourse->m_sMainTitle + ".crs";
|
||||||
|
}
|
||||||
|
if( !CourseWriterCRS::Write(*pCourse, pCourse->m_sPath, false) )
|
||||||
|
{
|
||||||
|
ScreenPrompt::Prompt( SM_None, FAILED_TO_WRITE_COURSE );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !pCourse->IsAnEdit() )
|
||||||
|
CourseWriterCRS::Write( *pCourse, pCourse->GetCacheFilePath(), true );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
AutoScreenMessage( SM_BackFromEnterNameForNew )
|
AutoScreenMessage( SM_BackFromEnterNameForNew )
|
||||||
AutoScreenMessage( SM_BackFromRename )
|
AutoScreenMessage( SM_BackFromRename )
|
||||||
@@ -134,7 +166,7 @@ void ScreenOptionsManageCourses::Init()
|
|||||||
ScreenOptionsEditCourseSubMenu::Init();
|
ScreenOptionsEditCourseSubMenu::Init();
|
||||||
|
|
||||||
EDIT_MODE.Load( m_sName,"EditMode" );
|
EDIT_MODE.Load( m_sName,"EditMode" );
|
||||||
GAMESTATE->m_MasterPlayerNumber = GetNextEnabledPlayer( PlayerNumber(-1) );
|
GAMESTATE->m_MasterPlayerNumber = GAMESTATE->GetFirstHumanPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenOptionsManageCourses::BeginScreen()
|
void ScreenOptionsManageCourses::BeginScreen()
|
||||||
@@ -235,14 +267,21 @@ void ScreenOptionsManageCourses::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
{
|
{
|
||||||
if( SM == SM_Success )
|
if( SM == SM_Success )
|
||||||
{
|
{
|
||||||
LOG->Trace( "Delete successful; deleting course from memory" );
|
LOG->Trace( "Delete succeeded; deleting course." );
|
||||||
|
Course *pCourse = GetCourseWithFocus();
|
||||||
|
|
||||||
SONGMAN->DeleteCourse( GetCourseWithFocus() );
|
GAMESTATE->m_pCurCourse.Set( NULL ); // Maybe I should just go to the next course
|
||||||
|
RefreshTrail();
|
||||||
|
SONGMAN->DeleteCourse( pCourse );
|
||||||
|
FILEMAN->Remove( pCourse->m_sPath );
|
||||||
|
if( !pCourse->IsAnEdit() )
|
||||||
|
FILEMAN->Remove( pCourse->GetCacheFilePath() );
|
||||||
|
delete pCourse;
|
||||||
SCREENMAN->SetNewScreen( this->m_sName ); // reload
|
SCREENMAN->SetNewScreen( this->m_sName ); // reload
|
||||||
}
|
}
|
||||||
else if( SM == SM_Failure )
|
else if( SM == SM_Failure )
|
||||||
{
|
{
|
||||||
LOG->Trace( "Delete failed; not deleting course" );
|
LOG->Trace( "Delete failed; not deleting course." );
|
||||||
}
|
}
|
||||||
else if( SM == SM_GoToNextScreen )
|
else if( SM == SM_GoToNextScreen )
|
||||||
{
|
{
|
||||||
@@ -259,17 +298,35 @@ void ScreenOptionsManageCourses::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
{
|
{
|
||||||
ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this
|
ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this
|
||||||
|
|
||||||
RString sNewName = ScreenTextEntry::s_sLastAnswer;
|
|
||||||
|
|
||||||
// create
|
// create
|
||||||
Course *pCourse = new Course;
|
Course *pCourse = new Course;
|
||||||
|
ProfileSlot slot;
|
||||||
|
|
||||||
pCourse->m_sMainTitle = ScreenTextEntry::s_sLastAnswer;
|
pCourse->m_sMainTitle = ScreenTextEntry::s_sLastAnswer;
|
||||||
pCourse->SetLoadedFromProfile( ProfileSlot_Machine );
|
|
||||||
|
switch( EDIT_MODE.GetValue() )
|
||||||
|
{
|
||||||
|
case EditMode_Practice:
|
||||||
|
case EditMode_Home:
|
||||||
|
slot = ProfileSlot_Machine;
|
||||||
|
break;
|
||||||
|
case EditMode_Full:
|
||||||
|
if( PROFILEMAN->IsPersistentProfile(GAMESTATE->m_MasterPlayerNumber) )
|
||||||
|
slot = (ProfileSlot)GAMESTATE->m_MasterPlayerNumber; // XXX I don't like this
|
||||||
|
else
|
||||||
|
slot = ProfileSlot_Machine;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
FAIL_M( "Invalid EditMode." );
|
||||||
|
}
|
||||||
|
|
||||||
|
pCourse->SetLoadedFromProfile( slot );
|
||||||
CourseEntry ce;
|
CourseEntry ce;
|
||||||
CourseUtil::MakeDefaultEditCourseEntry( ce );
|
CourseUtil::MakeDefaultEditCourseEntry( ce );
|
||||||
pCourse->m_vEntries.push_back( ce );
|
pCourse->m_vEntries.push_back( ce );
|
||||||
SONGMAN->AddCourse( pCourse );
|
SONGMAN->AddCourse( pCourse );
|
||||||
GAMESTATE->m_pCurCourse.Set( pCourse );
|
GAMESTATE->m_pCurCourse.Set( pCourse );
|
||||||
|
WriteCourse();
|
||||||
|
|
||||||
RefreshTrail();
|
RefreshTrail();
|
||||||
|
|
||||||
@@ -280,10 +337,20 @@ void ScreenOptionsManageCourses::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
{
|
{
|
||||||
if( !ScreenTextEntry::s_bCancelledLast )
|
if( !ScreenTextEntry::s_bCancelledLast )
|
||||||
{
|
{
|
||||||
|
Course *pCourse = GAMESTATE->m_pCurCourse;
|
||||||
|
const RString& sNewName = ScreenTextEntry::s_sLastAnswer;
|
||||||
|
RString sDir, sName, sExt;
|
||||||
|
|
||||||
ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this
|
ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this
|
||||||
|
ASSERT( !pCourse->m_sPath.empty() );
|
||||||
|
FILEMAN->Remove( pCourse->m_sPath );
|
||||||
|
if( !pCourse->IsAnEdit() )
|
||||||
|
FILEMAN->Remove( pCourse->GetCacheFilePath() );
|
||||||
|
|
||||||
GAMESTATE->m_pCurCourse->m_sMainTitle = ScreenTextEntry::s_sLastAnswer;
|
splitpath( pCourse->m_sPath, sDir, sName, sExt );
|
||||||
|
pCourse->m_sPath = sDir + sNewName + sExt;
|
||||||
|
pCourse->m_sMainTitle = sNewName;
|
||||||
|
WriteCourse();
|
||||||
SCREENMAN->SetNewScreen( this->m_sName ); // reload
|
SCREENMAN->SetNewScreen( this->m_sName ); // reload
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -296,7 +363,7 @@ void ScreenOptionsManageCourses::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
case CourseAction_Edit:
|
case CourseAction_Edit:
|
||||||
{
|
{
|
||||||
Course *pCourse = GetCourseWithFocus();
|
Course *pCourse = GetCourseWithFocus();
|
||||||
Trail *pTrail = pCourse->GetTrail( STEPS_TYPE_DANCE_SINGLE );
|
Trail *pTrail = pCourse->GetTrail( GAMESTATE->m_stEdit );
|
||||||
GAMESTATE->m_pCurCourse.Set( pCourse );
|
GAMESTATE->m_pCurCourse.Set( pCourse );
|
||||||
GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail );
|
GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail );
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void MenuSelect( const InputEventPlus &input );
|
virtual void MenuSelect( const InputEventPlus &input );
|
||||||
|
void WriteCourse();
|
||||||
};
|
};
|
||||||
|
|
||||||
class ScreenOptionsManageCourses : public ScreenOptionsEditCourseSubMenu
|
class ScreenOptionsManageCourses : public ScreenOptionsEditCourseSubMenu
|
||||||
@@ -36,8 +37,6 @@ protected:
|
|||||||
Course *GetCourseWithFocus() const;
|
Course *GetCourseWithFocus() const;
|
||||||
|
|
||||||
vector<Course*> m_vpCourses;
|
vector<Course*> m_vpCourses;
|
||||||
|
|
||||||
ThemeMetricEnum<EditMode> EDIT_MODE;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user