move course rename and delete into Overview

This commit is contained in:
Glenn Maynard
2009-10-31 23:26:36 +00:00
parent 18b8e88b84
commit 738a8b6895
2 changed files with 61 additions and 100 deletions
+57 -3
View File
@@ -23,6 +23,8 @@ enum CourseOverviewRow
CourseOverviewRow_Play,
CourseOverviewRow_Edit,
CourseOverviewRow_Shuffle,
CourseOverviewRow_Rename,
CourseOverviewRow_Delete,
CourseOverviewRow_Save,
NUM_CourseOverviewRow
};
@@ -32,12 +34,24 @@ static const MenuRowDef g_MenuRows[] =
MenuRowDef( -1, "Play", true, EditMode_Practice, true, false, 0, NULL ),
MenuRowDef( -1, "Edit Course", true, EditMode_Practice, true, false, 0, NULL ),
MenuRowDef( -1, "Shuffle", true, EditMode_Practice, true, false, 0, NULL ),
MenuRowDef( -1, "Rename", true, EditMode_Practice, true, false, 0, NULL ),
MenuRowDef( -1, "Delete", true, EditMode_Practice, true, false, 0, NULL ),
MenuRowDef( -1, "Save", true, EditMode_Practice, true, false, 0, NULL ),
};
REGISTER_SCREEN_CLASS( ScreenOptionsCourseOverview );
static LocalizedString ENTER_COURSE_NAME ("ScreenOptionsCourseOverview", "Enter a name for the course.");
static LocalizedString ERROR_SAVING_COURSE ("ScreenOptionsCourseOverview", "Error saving course.");
static LocalizedString COURSE_SAVED ("ScreenOptionsCourseOverview", "Course saved successfully.");
static LocalizedString ERROR_RENAMING ("ScreenOptionsCourseOverview", "Error renaming file.");
static LocalizedString ERROR_DELETING_FILE ("ScreenOptionsCourseOverview", "Error deleting the file '%s'.");
static LocalizedString COURSE_WILL_BE_LOST ("ScreenOptionsCourseOverview", "This course will be lost permanently.");
static LocalizedString CONTINUE_WITH_DELETE ("ScreenOptionsCourseOverview", "Continue with delete?");
AutoScreenMessage( SM_BackFromEnterName )
AutoScreenMessage( SM_BackFromRename )
AutoScreenMessage( SM_BackFromDelete )
void ScreenOptionsCourseOverview::Init()
{
@@ -88,8 +102,6 @@ void ScreenOptionsCourseOverview::ExportOptions( int iRow, const vector<PlayerNu
sValue = row.GetRowDef().m_vsChoices[ iIndex ];
}
static LocalizedString ERROR_SAVING_COURSE ( "ScreenOptionsCourseOverview", "Error saving course." );
static LocalizedString COURSE_SAVED ( "ScreenOptionsCourseOverview", "Course saved successfully." );
void ScreenOptionsCourseOverview::HandleScreenMessage( const ScreenMessage SM )
{
if( SM == SM_GoToPrevScreen )
@@ -124,6 +136,38 @@ void ScreenOptionsCourseOverview::HandleScreenMessage( const ScreenMessage SM )
}
}
}
else if( SM == SM_BackFromRename )
{
if( !ScreenTextEntry::s_bCancelledLast )
{
ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this
if( !EditCourseUtil::RenameAndSave(GAMESTATE->m_pCurCourse, ScreenTextEntry::s_sLastAnswer) )
{
ScreenPrompt::Prompt( SM_None, ERROR_RENAMING );
return;
}
SCREENMAN->SetNewScreen( this->m_sName ); // reload
}
}
else if( SM == SM_BackFromDelete )
{
if( ScreenPrompt::s_LastAnswer == ANSWER_YES )
{
if( !EditCourseUtil::RemoveAndDeleteFile(GAMESTATE->m_pCurCourse) )
{
ScreenPrompt::Prompt( SM_None, ssprintf(ERROR_DELETING_FILE.GetValue(), GAMESTATE->m_pCurCourse->m_sPath.c_str()) );
return;
}
GAMESTATE->m_pCurCourse.Set( NULL );
GAMESTATE->m_pCurTrail[PLAYER_1].Set( NULL );
/* Our course is gone, so back out. */
StartTransitioningScreen( SM_GoToPrevScreen );
}
}
ScreenOptions::HandleScreenMessage( SM );
}
@@ -134,7 +178,6 @@ void ScreenOptionsCourseOverview::AfterChangeValueInRow( int iRow, PlayerNumber
}
static LocalizedString ENTER_COURSE_NAME ( "ScreenOptionsCourseOverview", "Enter a name for the course." );
void ScreenOptionsCourseOverview::ProcessMenuStart( const InputEventPlus &input )
{
if( IsTransitioning() )
@@ -158,6 +201,17 @@ void ScreenOptionsCourseOverview::ProcessMenuStart( const InputEventPlus &input
MESSAGEMAN->Broadcast("CurrentCourseChanged");
}
return; // handled
case CourseOverviewRow_Rename:
ScreenTextEntry::TextEntry(
SM_BackFromRename,
ENTER_COURSE_NAME,
GAMESTATE->m_pCurCourse->GetDisplayFullTitle(),
EditCourseUtil::MAX_NAME_LENGTH,
EditCourseUtil::ValidateEditCourseName );
break;
case CourseOverviewRow_Delete:
ScreenPrompt::Prompt( SM_BackFromDelete, COURSE_WILL_BE_LOST.GetValue()+"\n\n"+CONTINUE_WITH_DELETE.GetValue(), PROMPT_YES_NO, ANSWER_NO );
break;
case CourseOverviewRow_Save:
{
bool bPromptForName = EditCourseUtil::s_bNewCourseNeedsName;
+4 -97
View File
@@ -19,29 +19,6 @@
#include "RageFileManager.h"
#include "PrefsManager.h"
AutoScreenMessage( SM_BackFromRename )
AutoScreenMessage( SM_BackFromDelete )
AutoScreenMessage( SM_BackFromContextMenu )
enum CourseAction
{
CourseAction_Edit,
CourseAction_Rename,
CourseAction_Delete,
NUM_CourseAction
};
static const char *CourseActionNames[] = {
"Edit",
"Rename",
"Delete",
};
XToString( CourseAction );
#define FOREACH_CourseAction( i ) FOREACH_ENUM( CourseAction, i )
static MenuDef g_TempMenu(
"ScreenMiniMenuContext"
);
REGISTER_SCREEN_CLASS( ScreenOptionsManageCourses );
@@ -177,11 +154,6 @@ void ScreenOptionsManageCourses::BeginScreen()
AfterChangeRow( GAMESTATE->m_MasterPlayerNumber );
}
static LocalizedString ERROR_RENAMING ("ScreenOptionsManageCourses", "Error renaming file.");
static LocalizedString ERROR_DELETING_FILE ("ScreenOptionsManageCourses", "Error deleting the file '%s'.");
static LocalizedString COURSE_WILL_BE_LOST ( "ScreenOptionsManageCourses", "This course will be lost permanently." );
static LocalizedString CONTINUE_WITH_DELETE ( "ScreenOptionsManageCourses", "Continue with delete?" );
static LocalizedString ENTER_COURSE_NAME ( "ScreenOptionsManageCourses", "Enter a name for the course." );
void ScreenOptionsManageCourses::HandleScreenMessage( const ScreenMessage SM )
{
if( SM == SM_GoToNextScreen )
@@ -212,65 +184,6 @@ void ScreenOptionsManageCourses::HandleScreenMessage( const ScreenMessage SM )
// do base behavior
}
}
else if( SM == SM_BackFromRename )
{
if( !ScreenTextEntry::s_bCancelledLast )
{
ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this
if( !EditCourseUtil::RenameAndSave(GAMESTATE->m_pCurCourse, ScreenTextEntry::s_sLastAnswer) )
{
ScreenPrompt::Prompt( SM_None, ERROR_RENAMING );
return;
}
SCREENMAN->SetNewScreen( this->m_sName ); // reload
}
}
else if( SM == SM_BackFromDelete )
{
if( ScreenPrompt::s_LastAnswer == ANSWER_YES )
{
Course *pCourse = GetCourseWithFocus();
if( !EditCourseUtil::RemoveAndDeleteFile( pCourse ) )
{
ScreenPrompt::Prompt( SM_None, ssprintf(ERROR_DELETING_FILE.GetValue(),pCourse->m_sPath.c_str()) );
return;
}
GAMESTATE->m_pCurCourse.Set( NULL );
GAMESTATE->m_pCurTrail[PLAYER_1].Set( NULL );
SCREENMAN->SetNewScreen( this->m_sName ); // reload
}
}
else if( SM == SM_BackFromContextMenu )
{
if( !ScreenMiniMenu::s_bCancelled )
{
switch( ScreenMiniMenu::s_iLastRowCode )
{
case CourseAction_Edit:
{
GAMESTATE->m_pCurCourse.Set( GetCourseWithFocus() );
EditCourseUtil::UpdateAndSetTrail();
EditCourseUtil::s_bNewCourseNeedsName = false;
ScreenOptions::BeginFadingOut();
break;
}
case CourseAction_Rename:
ScreenTextEntry::TextEntry(
SM_BackFromRename,
ENTER_COURSE_NAME,
GAMESTATE->m_pCurCourse->GetDisplayFullTitle(),
EditCourseUtil::MAX_NAME_LENGTH,
EditCourseUtil::ValidateEditCourseName );
break;
case CourseAction_Delete:
ScreenPrompt::Prompt( SM_None, COURSE_WILL_BE_LOST.GetValue()+"\n\n"+CONTINUE_WITH_DELETE.GetValue(), PROMPT_YES_NO, ANSWER_NO );
break;
}
}
}
else if( SM == SM_LoseFocus )
{
this->PlayCommand( "ScreenLoseFocus" );
@@ -332,16 +245,10 @@ void ScreenOptionsManageCourses::ProcessMenuStart( const InputEventPlus &input )
}
else // a course
{
g_TempMenu.rows.clear();
FOREACH_CourseAction( i )
{
MenuRowDef mrd( i, CourseActionToString(i), true, EditMode_Home, true, true, 0, "" );
g_TempMenu.rows.push_back( mrd );
}
int iWidth, iX, iY;
this->GetWidthXY( GAMESTATE->m_MasterPlayerNumber, iCurRow, 0, iWidth, iX, iY );
ScreenMiniMenu::MiniMenu( &g_TempMenu, SM_BackFromContextMenu, SM_BackFromContextMenu, (float)iX, (float)iY );
GAMESTATE->m_pCurCourse.Set( GetCourseWithFocus() );
EditCourseUtil::UpdateAndSetTrail();
EditCourseUtil::s_bNewCourseNeedsName = false;
ScreenOptions::BeginFadingOut();
}
}