add course edits, improved course editor
This commit is contained in:
@@ -402,6 +402,7 @@ void Course::Init()
|
||||
m_sSubTitleTranslit = "";
|
||||
m_sBannerPath = "";
|
||||
m_sCDTitlePath = "";
|
||||
m_LoadedFromProfile = PROFILE_SLOT_INVALID;
|
||||
m_iTrailCacheSeed = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ class Steps;
|
||||
class Profile;
|
||||
struct lua_State;
|
||||
|
||||
const int MAX_EDIT_COURSE_TITLE_LENGTH = 12;
|
||||
|
||||
enum CourseType
|
||||
{
|
||||
COURSE_TYPE_NONSTOP, // if life meter type is BAR
|
||||
@@ -180,6 +182,9 @@ public:
|
||||
|
||||
const CourseEntry *FindFixedSong( const Song *pSong ) const;
|
||||
|
||||
ProfileSlot GetLoadedFromProfileSlot() const { return m_LoadedFromProfile; }
|
||||
void SetLoadedFromProfile( ProfileSlot slot ) { m_LoadedFromProfile = slot; }
|
||||
|
||||
// Lua
|
||||
void PushSelf( lua_State *L );
|
||||
|
||||
@@ -189,6 +194,8 @@ private:
|
||||
bool GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) const;
|
||||
bool GetTrailSorted( StepsType st, CourseDifficulty cd, Trail &trail ) const;
|
||||
|
||||
ProfileSlot m_LoadedFromProfile; // PROFILE_SLOT_INVALID if wasn't loaded from a profile
|
||||
|
||||
typedef pair<StepsType,Difficulty> CacheEntry;
|
||||
struct CacheData
|
||||
{
|
||||
|
||||
@@ -1,257 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "ScreenCourseManager.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "RageLog.h"
|
||||
#include "GameState.h"
|
||||
#include "SongManager.h"
|
||||
#include "CommonMetrics.h"
|
||||
|
||||
enum CourseManagerRow
|
||||
{
|
||||
ROW_COURSE_GROUP,
|
||||
ROW_COURSE,
|
||||
ROW_ACTION,
|
||||
ROW_DONE,
|
||||
};
|
||||
|
||||
enum CourseManagerAction
|
||||
{
|
||||
ACTION_EDIT,
|
||||
ACTION_DELETE,
|
||||
ACTION_COPY_TO_NEW,
|
||||
ACTION_CREATE_NEW,
|
||||
NUM_CourseManagerAction
|
||||
};
|
||||
static const CString CourseManagerActionNames[] = {
|
||||
"Edit",
|
||||
"Delete",
|
||||
"Create New",
|
||||
"Copy to New",
|
||||
};
|
||||
XToString( CourseManagerAction, NUM_CourseManagerAction );
|
||||
|
||||
static void GetPossibleActions( vector<CourseManagerAction> &vActionsOut )
|
||||
{
|
||||
if( GAMESTATE->m_pCurCourse != NULL )
|
||||
{
|
||||
vActionsOut.push_back( ACTION_EDIT );
|
||||
vActionsOut.push_back( ACTION_DELETE );
|
||||
vActionsOut.push_back( ACTION_COPY_TO_NEW );
|
||||
}
|
||||
else
|
||||
{
|
||||
vActionsOut.push_back( ACTION_CREATE_NEW );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
REGISTER_SCREEN_CLASS( ScreenCourseManager );
|
||||
ScreenCourseManager::ScreenCourseManager( CString sName ) : ScreenOptions( sName )
|
||||
{
|
||||
LOG->Trace( "ScreenCourseManager::ScreenCourseManager()" );
|
||||
}
|
||||
|
||||
void ScreenCourseManager::Init()
|
||||
{
|
||||
ScreenOptions::Init();
|
||||
|
||||
vector<OptionRowDefinition> vDefs;
|
||||
vector<OptionRowHandler*> vHands;
|
||||
|
||||
OptionRowDefinition def;
|
||||
def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW;
|
||||
|
||||
def.m_sName = "Group";
|
||||
def.m_vsChoices.clear();
|
||||
SONGMAN->GetCourseGroupNames( def.m_vsChoices );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
def.m_sName = "Course Group";
|
||||
def.m_vsChoices.clear();
|
||||
def.m_vsChoices.push_back( "" );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
def.m_sName = "Action";
|
||||
def.m_vsChoices.clear();
|
||||
def.m_vsChoices.push_back( "" );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
ScreenOptions::InitMenu( vDefs, vHands );
|
||||
|
||||
|
||||
AfterChangeValueInRow( GAMESTATE->m_MasterPlayerNumber );
|
||||
}
|
||||
|
||||
void ScreenCourseManager::HandleScreenMessage( const ScreenMessage SM )
|
||||
{
|
||||
if( SM == SM_GoToNextScreen )
|
||||
{
|
||||
switch( m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber] )
|
||||
{
|
||||
default:
|
||||
ASSERT(0);
|
||||
case ROW_COURSE_GROUP:
|
||||
SCREENMAN->PlayInvalidSound();
|
||||
break;
|
||||
case ROW_COURSE:
|
||||
SCREENMAN->PlayInvalidSound();
|
||||
break;
|
||||
case ROW_ACTION:
|
||||
{
|
||||
OptionRow &row = *m_pRows[ROW_ACTION];
|
||||
int iChoice = row.GetChoiceInRowWithFocus( GAMESTATE->m_MasterPlayerNumber );
|
||||
|
||||
vector<CourseManagerAction> vActions;
|
||||
GetPossibleActions( vActions );
|
||||
CourseManagerAction action = vActions[iChoice];
|
||||
|
||||
switch( action )
|
||||
{
|
||||
default:
|
||||
ASSERT(0);
|
||||
case ACTION_EDIT:
|
||||
GAMESTATE->m_iEditCourseEntryIndex.Set( 0 );
|
||||
SCREENMAN->SetNewScreen( "ScreenEditCourse" );
|
||||
break;
|
||||
case ACTION_DELETE:
|
||||
SCREENMAN->PlayInvalidSound();
|
||||
break;
|
||||
case ACTION_COPY_TO_NEW:
|
||||
SCREENMAN->PlayInvalidSound();
|
||||
break;
|
||||
case ACTION_CREATE_NEW:
|
||||
SCREENMAN->PlayInvalidSound();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ROW_DONE:
|
||||
SCREENMAN->SetNewScreen( FIRST_ATTRACT_SCREEN );
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if( SM == SM_GoToPrevScreen )
|
||||
{
|
||||
SCREENMAN->SetNewScreen( FIRST_ATTRACT_SCREEN );
|
||||
return;
|
||||
}
|
||||
ScreenOptions::HandleScreenMessage( SM );
|
||||
}
|
||||
|
||||
void ScreenCourseManager::AfterChangeValueInRow( PlayerNumber pn )
|
||||
{
|
||||
ScreenOptions::AfterChangeValueInRow( pn );
|
||||
|
||||
switch( m_iCurrentRow[pn] )
|
||||
{
|
||||
default:
|
||||
ASSERT(0);
|
||||
case ROW_COURSE_GROUP:
|
||||
// export current course group
|
||||
{
|
||||
OptionRow &row = *m_pRows[ROW_COURSE_GROUP];
|
||||
int iChoice = row.GetChoiceInRowWithFocus(pn);
|
||||
CString sCourseGroup = row.GetRowDef().m_vsChoices[iChoice];
|
||||
GAMESTATE->m_sPreferredCourseGroup.Set( sCourseGroup );
|
||||
}
|
||||
// Refresh courses
|
||||
{
|
||||
OptionRow &row = *m_pRows[ROW_COURSE];
|
||||
vector<Course*> vpCourses;
|
||||
SONGMAN->GetCoursesInGroup( vpCourses, GAMESTATE->m_sPreferredCourseGroup.Get(), false );
|
||||
OptionRowDefinition def = row.GetRowDef();
|
||||
def.m_vsChoices.clear();
|
||||
FOREACH_CONST( Course*, vpCourses, c )
|
||||
def.m_vsChoices.push_back( (*c)->GetTranslitFullTitle() );
|
||||
def.m_vsChoices.push_back( NULL ); // new course
|
||||
row.Reload( def );
|
||||
}
|
||||
// fall through
|
||||
case ROW_COURSE:
|
||||
// export current course
|
||||
{
|
||||
OptionRow &row = *m_pRows[ROW_COURSE];
|
||||
int iChoice = row.GetChoiceInRowWithFocus(pn);
|
||||
vector<Course*> vpCourses;
|
||||
SONGMAN->GetCoursesInGroup( vpCourses, GAMESTATE->m_sPreferredCourseGroup.Get(), false );
|
||||
Course *pCourse = vpCourses[iChoice];
|
||||
GAMESTATE->m_pCurCourse.Set( pCourse );
|
||||
}
|
||||
// refresh actions
|
||||
{
|
||||
OptionRow &row = *m_pRows[ROW_ACTION];
|
||||
OptionRowDefinition def = row.GetRowDef();
|
||||
def.m_vsChoices.clear();
|
||||
vector<CourseManagerAction> vActions;
|
||||
GetPossibleActions( vActions );
|
||||
FOREACH_CONST( CourseManagerAction, vActions, a )
|
||||
def.m_vsChoices.push_back( CourseManagerActionToString(*a) );
|
||||
row.Reload( def );
|
||||
}
|
||||
// fall through
|
||||
case ROW_ACTION:
|
||||
// fall through
|
||||
case ROW_DONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenCourseManager::ProcessMenuStart( PlayerNumber pn, const InputEventType type )
|
||||
{
|
||||
switch( m_iCurrentRow[pn] )
|
||||
{
|
||||
default:
|
||||
ASSERT(0);
|
||||
case ROW_COURSE_GROUP:
|
||||
SCREENMAN->PlayInvalidSound();
|
||||
break;
|
||||
case ROW_COURSE:
|
||||
SCREENMAN->PlayInvalidSound();
|
||||
break;
|
||||
case ROW_ACTION:
|
||||
ScreenOptions::BeginFadingOut();
|
||||
break;
|
||||
case ROW_DONE:
|
||||
ScreenOptions::BeginFadingOut();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenCourseManager::ImportOptions( int iRow, const vector<PlayerNumber> &vpns )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ScreenCourseManager::ExportOptions( int iRow, const vector<PlayerNumber> &vpns )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2002-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
@@ -2233,7 +2233,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
|
||||
if( !pSteps->GetSavedToDisk() )
|
||||
{
|
||||
Song* pSong = GAMESTATE->m_pCurSong;
|
||||
pSong->RemoveSteps( pSteps );
|
||||
pSong->DeleteSteps( pSteps );
|
||||
m_pSteps = NULL;
|
||||
GAMESTATE->m_pCurSteps[PLAYER_1].Set( NULL );
|
||||
}
|
||||
@@ -2886,7 +2886,7 @@ void ScreenEdit::HandleStepsInformationChoice( StepsInformationChoice c, const v
|
||||
SM_None,
|
||||
"Enter a description.",
|
||||
m_pSteps->GetDescription(),
|
||||
(dc == DIFFICULTY_EDIT) ? MAX_EDIT_DESCRIPTION_LENGTH : 255,
|
||||
(dc == DIFFICULTY_EDIT) ? MAX_EDIT_STEPS_DESCRIPTION_LENGTH : 255,
|
||||
NULL,
|
||||
ChangeDescription,
|
||||
NULL
|
||||
|
||||
@@ -1,346 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "ScreenEditCourse.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "RageLog.h"
|
||||
#include "GameState.h"
|
||||
#include "SongManager.h"
|
||||
#include "CommonMetrics.h"
|
||||
#include "GameManager.h"
|
||||
#include "song.h"
|
||||
|
||||
enum EditCourseRow
|
||||
{
|
||||
ROW_TITLE,
|
||||
ROW_REPEAT,
|
||||
ROW_RANDOMIZE,
|
||||
ROW_LIVES,
|
||||
ROW_TYPE,
|
||||
ROW_TYPE_METER,
|
||||
ROW_EDIT_ENTRY,
|
||||
ROW_INSERT_ENTRY,
|
||||
ROW_DELETE_ENTRY,
|
||||
ROW_DONE,
|
||||
};
|
||||
|
||||
struct StepsTypeAndDifficulty
|
||||
{
|
||||
StepsType st;
|
||||
CourseDifficulty cd;
|
||||
};
|
||||
|
||||
static void GetStepsTypeAndDifficulty( vector<StepsTypeAndDifficulty> &vOut, vector<CString> &vsOut )
|
||||
{
|
||||
Course *pCourse = GAMESTATE->m_pCurCourse;
|
||||
|
||||
FOREACH_CONST( StepsType, STEPS_TYPES_TO_SHOW.GetValue(), st )
|
||||
{
|
||||
CString s1 = GAMEMAN->StepsTypeToString(*st);
|
||||
FOREACH_CONST( CourseDifficulty, COURSE_DIFFICULTIES_TO_SHOW.GetValue(), cd )
|
||||
{
|
||||
if( pCourse->GetTrail( *st, *cd ) == NULL )
|
||||
continue;
|
||||
|
||||
CString s2 = CourseDifficultyToThemedString(*cd);
|
||||
StepsTypeAndDifficulty stad = { *st, *cd };
|
||||
vOut.push_back( stad );
|
||||
vsOut.push_back( s1+" "+s2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_SCREEN_CLASS( ScreenEditCourse );
|
||||
ScreenEditCourse::ScreenEditCourse( CString sName ) : ScreenOptions( sName )
|
||||
{
|
||||
LOG->Trace( "ScreenEditCourse::ScreenEditCourse()" );
|
||||
}
|
||||
|
||||
void ScreenEditCourse::Init()
|
||||
{
|
||||
ScreenOptions::Init();
|
||||
|
||||
|
||||
// save a backup that we'll use if we revert.
|
||||
Course *pCourse = GAMESTATE->m_pCurCourse;
|
||||
m_Original = *pCourse;
|
||||
|
||||
|
||||
vector<OptionRowDefinition> vDefs;
|
||||
vector<OptionRowHandler*> vHands;
|
||||
|
||||
OptionRowDefinition def;
|
||||
def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW;
|
||||
|
||||
def.m_sName = "Title";
|
||||
def.m_vsChoices.clear();
|
||||
def.m_vsChoices.push_back( pCourse->GetTranslitFullTitle() );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
def.m_sName = "Repeat";
|
||||
def.m_vsChoices.clear();
|
||||
def.m_vsChoices.push_back( "NO" );
|
||||
def.m_vsChoices.push_back( "YES" );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
def.m_sName = "Randomize";
|
||||
def.m_vsChoices.clear();
|
||||
def.m_vsChoices.push_back( "NO" );
|
||||
def.m_vsChoices.push_back( "YES" );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
def.m_sName = "Lives";
|
||||
def.m_vsChoices.clear();
|
||||
def.m_vsChoices.push_back( "Use Bar Life" );
|
||||
for( int i=1; i<=10; i++ )
|
||||
def.m_vsChoices.push_back( ssprintf("%d",i) );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
def.m_sName = "Type";
|
||||
def.m_vsChoices.clear();
|
||||
FOREACH_CONST( StepsType, STEPS_TYPES_TO_SHOW.GetValue(), st )
|
||||
def.m_vsChoices.push_back( GAMEMAN->StepsTypeToString(*st) );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
def.m_sName = "Type Meter";
|
||||
def.m_vsChoices.clear();
|
||||
for( int i=MIN_METER; i<=MAX_METER; i++ )
|
||||
def.m_vsChoices.push_back( ssprintf("%d",i) );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
def.m_sName = "Edit Entry";
|
||||
def.m_vsChoices.clear();
|
||||
for( unsigned i=0; i<pCourse->m_vEntries.size(); i++ )
|
||||
def.m_vsChoices.push_back( ssprintf("%u of %u",i+1,pCourse->m_vEntries.size()) );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
def.m_sName = "Insert Entry";
|
||||
def.m_vsChoices.clear();
|
||||
for( unsigned i=0; i<=pCourse->m_vEntries.size(); i++ )
|
||||
{
|
||||
CString s;
|
||||
if( i == pCourse->m_vEntries.size() )
|
||||
s = ssprintf("After %u",i);
|
||||
else
|
||||
s = ssprintf("Before %u",i+1);
|
||||
def.m_vsChoices.push_back( s );
|
||||
}
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
def.m_sName = "Delete Entry";
|
||||
def.m_vsChoices.clear();
|
||||
for( unsigned i=0; i<pCourse->m_vEntries.size(); i++ )
|
||||
def.m_vsChoices.push_back( ssprintf("%u of %u",i+1,pCourse->m_vEntries.size()) );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
ScreenOptions::InitMenu( vDefs, vHands );
|
||||
|
||||
AfterChangeValueInRow( GAMESTATE->m_MasterPlayerNumber );
|
||||
}
|
||||
|
||||
void ScreenEditCourse::HandleScreenMessage( const ScreenMessage SM )
|
||||
{
|
||||
if( SM == SM_GoToNextScreen )
|
||||
{
|
||||
switch( m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber] )
|
||||
{
|
||||
default:
|
||||
case ROW_TITLE:
|
||||
case ROW_REPEAT:
|
||||
case ROW_RANDOMIZE:
|
||||
case ROW_LIVES:
|
||||
case ROW_TYPE:
|
||||
case ROW_TYPE_METER:
|
||||
ASSERT(0);
|
||||
case ROW_INSERT_ENTRY:
|
||||
case ROW_DELETE_ENTRY:
|
||||
SCREENMAN->SetNewScreen( "ScreenEditCourse" );
|
||||
break;
|
||||
case ROW_EDIT_ENTRY:
|
||||
SCREENMAN->SetNewScreen( "ScreenEditCourseEntry" );
|
||||
break;
|
||||
case ROW_DONE:
|
||||
SCREENMAN->SetNewScreen( "ScreenCourseManager" );
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if( SM == SM_GoToPrevScreen )
|
||||
{
|
||||
// revert
|
||||
Course *pCourse = GAMESTATE->m_pCurCourse;
|
||||
*pCourse = m_Original;
|
||||
|
||||
SCREENMAN->SetNewScreen( "ScreenCourseManager" );
|
||||
return;
|
||||
}
|
||||
|
||||
ScreenOptions::HandleScreenMessage( SM );
|
||||
}
|
||||
|
||||
void ScreenEditCourse::AfterChangeValueInRow( PlayerNumber pn )
|
||||
{
|
||||
ScreenOptions::AfterChangeValueInRow( pn );
|
||||
|
||||
Course *pCourse = GAMESTATE->m_pCurCourse;
|
||||
StepsType st = STEPS_TYPE_INVALID;
|
||||
CourseDifficulty cd = DIFFICULTY_INVALID;
|
||||
int iMeter = -1;
|
||||
|
||||
switch( m_iCurrentRow[pn] )
|
||||
{
|
||||
default:
|
||||
ASSERT(0);
|
||||
case ROW_TITLE:
|
||||
// fall through
|
||||
case ROW_REPEAT:
|
||||
// fall through
|
||||
case ROW_RANDOMIZE:
|
||||
// fall through
|
||||
case ROW_LIVES:
|
||||
// Refresh type
|
||||
{
|
||||
OptionRow &row = *m_pRows[ROW_TYPE];
|
||||
OptionRowDefinition def = row.GetRowDef();
|
||||
def.m_vsChoices.clear();
|
||||
vector<StepsTypeAndDifficulty> vThrowAway;
|
||||
GetStepsTypeAndDifficulty( vThrowAway, def.m_vsChoices );
|
||||
row.Reload( def );
|
||||
}
|
||||
// fall through
|
||||
case ROW_TYPE:
|
||||
// export StepsType and CouresDifficulty
|
||||
{
|
||||
OptionRow &row = *m_pRows[ROW_TYPE];
|
||||
int iChoice = row.GetChoiceInRowWithFocus( GAMESTATE->m_MasterPlayerNumber );
|
||||
vector<StepsTypeAndDifficulty> v;
|
||||
vector<CString> vsThrowAway;
|
||||
GetStepsTypeAndDifficulty( v, vsThrowAway );
|
||||
st = v[iChoice].st;
|
||||
cd = v[iChoice].cd;
|
||||
GAMESTATE->m_pCurTrail[GAMESTATE->m_MasterPlayerNumber].Set( pCourse->GetTrail( st, cd ) );
|
||||
}
|
||||
// refresh meter
|
||||
{
|
||||
OptionRow &row = *m_pRows[ROW_TYPE_METER];
|
||||
OptionRowDefinition def = row.GetRowDef();
|
||||
Trail *pTrail = GAMESTATE->m_pCurTrail[GAMESTATE->m_MasterPlayerNumber];
|
||||
ASSERT( pTrail );
|
||||
row.SetOneSharedSelection( pTrail->GetMeter()-MIN_METER );
|
||||
row.Reload( def );
|
||||
}
|
||||
// fall through
|
||||
case ROW_TYPE_METER:
|
||||
// export meter
|
||||
{
|
||||
OptionRow &row = *m_pRows[ROW_TYPE_METER];
|
||||
int iChoice = row.GetChoiceInRowWithFocus( GAMESTATE->m_MasterPlayerNumber );
|
||||
iMeter = 1+iChoice;
|
||||
}
|
||||
// fall through
|
||||
case ROW_EDIT_ENTRY:
|
||||
// export entry number
|
||||
{
|
||||
EditCourseRow ecr = m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber] == ROW_EDIT_ENTRY ? ROW_EDIT_ENTRY : ROW_INSERT_ENTRY;
|
||||
OptionRow &row = *m_pRows[ecr];
|
||||
int iChoice = row.GetChoiceInRowWithFocus( GAMESTATE->m_MasterPlayerNumber );
|
||||
GAMESTATE->m_iEditCourseEntryIndex.Set( iChoice );
|
||||
}
|
||||
// fall through
|
||||
case ROW_INSERT_ENTRY:
|
||||
// fall through
|
||||
case ROW_DELETE_ENTRY:
|
||||
// fall through
|
||||
case ROW_DONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenEditCourse::ImportOptions( int iRow, const vector<PlayerNumber> &vpns )
|
||||
{
|
||||
switch( iRow )
|
||||
{
|
||||
case ROW_EDIT_ENTRY:
|
||||
case ROW_INSERT_ENTRY:
|
||||
case ROW_DELETE_ENTRY:
|
||||
OptionRow &row = *m_pRows[iRow];
|
||||
row.SetChoiceInRowWithFocusShared( GAMESTATE->m_iEditCourseEntryIndex );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenEditCourse::ExportOptions( int iRow, const vector<PlayerNumber> &vpns )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ScreenEditCourse::ProcessMenuStart( PlayerNumber pn, const InputEventType type )
|
||||
{
|
||||
Course *pCourse = GAMESTATE->m_pCurCourse;
|
||||
|
||||
switch( m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber] )
|
||||
{
|
||||
default:
|
||||
ASSERT(0);
|
||||
case ROW_TITLE:
|
||||
case ROW_REPEAT:
|
||||
case ROW_RANDOMIZE:
|
||||
case ROW_LIVES:
|
||||
case ROW_TYPE:
|
||||
case ROW_TYPE_METER:
|
||||
SCREENMAN->PlayInvalidSound();
|
||||
break;
|
||||
case ROW_INSERT_ENTRY:
|
||||
{
|
||||
OptionRow &row = *m_pRows[ROW_INSERT_ENTRY];
|
||||
int iChoice = row.GetChoiceInRowWithFocus( GAMESTATE->m_MasterPlayerNumber );
|
||||
pCourse->m_vEntries.insert( pCourse->m_vEntries.begin()+iChoice, CourseEntry() );
|
||||
ScreenOptions::BeginFadingOut();
|
||||
}
|
||||
break;
|
||||
case ROW_DELETE_ENTRY:
|
||||
{
|
||||
OptionRow &row = *m_pRows[ROW_DELETE_ENTRY];
|
||||
int iChoice = row.GetChoiceInRowWithFocus( GAMESTATE->m_MasterPlayerNumber );
|
||||
pCourse->m_vEntries.erase( pCourse->m_vEntries.begin()+iChoice );
|
||||
ScreenOptions::BeginFadingOut();
|
||||
}
|
||||
break;
|
||||
case ROW_EDIT_ENTRY:
|
||||
case ROW_DONE:
|
||||
ScreenOptions::BeginFadingOut();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2002-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
@@ -128,7 +128,7 @@ void ScreenEditMenu::HandleScreenMessage( const ScreenMessage SM )
|
||||
Song* pSong = GAMESTATE->m_pCurSong;
|
||||
Steps* pStepsToDelete = GAMESTATE->m_pCurSteps[PLAYER_1];
|
||||
bool bSaveSong = !pStepsToDelete->WasLoadedFromProfile();
|
||||
pSong->RemoveSteps( pStepsToDelete );
|
||||
pSong->DeleteSteps( pStepsToDelete );
|
||||
|
||||
/* Only save to the main .SM file if the steps we're deleting were loaded
|
||||
* from it. */
|
||||
@@ -225,7 +225,7 @@ static void SetCurrentStepsDescription( const CString &s )
|
||||
|
||||
static void DeleteCurrentSteps()
|
||||
{
|
||||
GAMESTATE->m_pCurSong->RemoveSteps( GAMESTATE->m_pCurSteps[0] );
|
||||
GAMESTATE->m_pCurSong->DeleteSteps( GAMESTATE->m_pCurSteps[0] );
|
||||
GAMESTATE->m_pCurSteps[0].Set( NULL );
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn )
|
||||
SM_BackFromEditDescription,
|
||||
"Name the new edit.",
|
||||
GAMESTATE->m_pCurSteps[0]->GetDescription(),
|
||||
MAX_EDIT_DESCRIPTION_LENGTH,
|
||||
MAX_EDIT_STEPS_DESCRIPTION_LENGTH,
|
||||
ValidateCurrentStepsDescription,
|
||||
SetCurrentStepsDescription,
|
||||
DeleteCurrentSteps );
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
#include "global.h"
|
||||
#include "ScreenOptionsEditCourse.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "RageLog.h"
|
||||
#include "GameState.h"
|
||||
#include "SongManager.h"
|
||||
#include "CommonMetrics.h"
|
||||
#include "GameManager.h"
|
||||
#include "song.h"
|
||||
|
||||
enum EditCourseRow
|
||||
{
|
||||
ROW_REPEAT,
|
||||
ROW_RANDOMIZE,
|
||||
ROW_LIVES,
|
||||
ROW_METER,
|
||||
NUM_EditCourseRow
|
||||
};
|
||||
|
||||
enum CourseEntryAction
|
||||
{
|
||||
CourseEntryAction_Edit,
|
||||
CourseEntryAction_InsertEntry,
|
||||
CourseEntryAction_Delete,
|
||||
NUM_CourseEntryAction
|
||||
};
|
||||
static const CString CourseEntryActionNames[] = {
|
||||
"Edit",
|
||||
"Insert Entry",
|
||||
"Delete",
|
||||
};
|
||||
XToString( CourseEntryAction, NUM_CourseEntryAction );
|
||||
#define FOREACH_CourseEntryAction( i ) FOREACH_ENUM( CourseEntryAction, NUM_CourseEntryAction, i )
|
||||
|
||||
|
||||
REGISTER_SCREEN_CLASS( ScreenOptionsEditCourse );
|
||||
ScreenOptionsEditCourse::ScreenOptionsEditCourse( CString sName ) : ScreenOptions( sName )
|
||||
{
|
||||
LOG->Trace( "ScreenOptionsEditCourse::ScreenOptionsEditCourse()" );
|
||||
}
|
||||
|
||||
void ScreenOptionsEditCourse::Init()
|
||||
{
|
||||
ScreenOptions::Init();
|
||||
|
||||
|
||||
// save a backup that we'll use if we revert.
|
||||
ASSERT( GAMESTATE->m_pCurCourse );
|
||||
Course *pCourse = GAMESTATE->m_pCurCourse;
|
||||
m_Original = *pCourse;
|
||||
|
||||
|
||||
vector<OptionRowDefinition> vDefs;
|
||||
vector<OptionRowHandler*> vHands;
|
||||
|
||||
OptionRowDefinition def;
|
||||
def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW;
|
||||
|
||||
def.m_sName = "Repeat";
|
||||
def.m_vsChoices.clear();
|
||||
def.m_vsChoices.push_back( "NO" );
|
||||
def.m_vsChoices.push_back( "YES" );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
def.m_sName = "Randomize";
|
||||
def.m_vsChoices.clear();
|
||||
def.m_vsChoices.push_back( "NO" );
|
||||
def.m_vsChoices.push_back( "YES" );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
def.m_sName = "Lives";
|
||||
def.m_vsChoices.clear();
|
||||
def.m_vsChoices.push_back( "Use Bar Life" );
|
||||
for( int i=1; i<=10; i++ )
|
||||
def.m_vsChoices.push_back( ssprintf("%d",i) );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
def.m_sName = "Meter";
|
||||
def.m_vsChoices.clear();
|
||||
for( int i=MIN_METER; i<=MAX_METER; i++ )
|
||||
def.m_vsChoices.push_back( ssprintf("%d",i) );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
FOREACH_CONST( CourseEntry, pCourse->m_vEntries, ce )
|
||||
{
|
||||
int iEntryIndex = ce - pCourse->m_vEntries.begin();
|
||||
def.m_sName = ssprintf( "Entry %d", iEntryIndex+1 );
|
||||
def.m_vsChoices.clear();
|
||||
FOREACH_CourseEntryAction( i )
|
||||
def.m_vsChoices.push_back( CourseEntryActionToString(i) );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
}
|
||||
|
||||
def.m_sName = "Insert Entry";
|
||||
def.m_vsChoices.clear();
|
||||
def.m_vsChoices.push_back( "" );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
ScreenOptions::InitMenu( vDefs, vHands );
|
||||
}
|
||||
|
||||
void ScreenOptionsEditCourse::BeginScreen()
|
||||
{
|
||||
ScreenOptions::BeginScreen();
|
||||
|
||||
AfterChangeValueInRow( GAMESTATE->m_MasterPlayerNumber );
|
||||
}
|
||||
|
||||
void ScreenOptionsEditCourse::HandleScreenMessage( const ScreenMessage SM )
|
||||
{
|
||||
if( SM == SM_GoToNextScreen )
|
||||
{
|
||||
int iCurRow = m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber];
|
||||
if( iCurRow < NUM_EditCourseRow )
|
||||
{
|
||||
ASSERT( 0 );
|
||||
}
|
||||
else if( iCurRow == m_pRows.size() - 1 )
|
||||
{
|
||||
this->HandleScreenMessage( SM_GoToPrevScreen );
|
||||
return; // don't call base
|
||||
}
|
||||
else
|
||||
{
|
||||
int iCourseEntry = iCurRow - NUM_EditCourseRow;
|
||||
GAMESTATE->m_iEditCourseEntryIndex.Set( iCourseEntry );
|
||||
}
|
||||
}
|
||||
else if( SM == SM_GoToPrevScreen )
|
||||
{
|
||||
// revert
|
||||
//Course *pCourse = GAMESTATE->m_pCurCourse;
|
||||
//*pCourse = m_Original;
|
||||
|
||||
//SCREENMAN->SetNewScreen( "ScreenCourseManager" );
|
||||
//return;
|
||||
}
|
||||
|
||||
ScreenOptions::HandleScreenMessage( SM );
|
||||
}
|
||||
|
||||
void ScreenOptionsEditCourse::AfterChangeValueInRow( PlayerNumber pn )
|
||||
{
|
||||
ScreenOptions::AfterChangeValueInRow( pn );
|
||||
}
|
||||
|
||||
void ScreenOptionsEditCourse::ImportOptions( int iRow, const vector<PlayerNumber> &vpns )
|
||||
{
|
||||
switch( iRow )
|
||||
{
|
||||
case ROW_REPEAT:
|
||||
//row.SetChoiceInRowWithFocusShared( iEntryIndex );
|
||||
break;
|
||||
case ROW_RANDOMIZE:
|
||||
//row.SetChoiceInRowWithFocusShared( iEntryIndex );
|
||||
break;
|
||||
case ROW_LIVES:
|
||||
//row.SetChoiceInRowWithFocusShared( iEntryIndex );
|
||||
break;
|
||||
case ROW_METER:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenOptionsEditCourse::ExportOptions( int iRow, const vector<PlayerNumber> &vpns )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ScreenOptionsEditCourse::ProcessMenuStart( PlayerNumber pn, const InputEventType type )
|
||||
{
|
||||
Course *pCourse = GAMESTATE->m_pCurCourse;
|
||||
|
||||
int iCourseEntry = GetCourseEntryIndexWithFocus();
|
||||
GAMESTATE->m_iEditCourseEntryIndex.Set( iCourseEntry );
|
||||
|
||||
int iCurRow = m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber];
|
||||
OptionRow &row = *m_pRows[iCurRow];
|
||||
|
||||
if( iCourseEntry != -1 )
|
||||
{
|
||||
switch( row.GetChoiceInRowWithFocusShared() )
|
||||
{
|
||||
case CourseEntryAction_Edit:
|
||||
ScreenOptions::BeginFadingOut();
|
||||
break;
|
||||
case CourseEntryAction_InsertEntry:
|
||||
{
|
||||
pCourse->m_vEntries.erase( pCourse->m_vEntries.begin() + iCourseEntry );
|
||||
SCREENMAN->SetNewScreen( this->m_sName ); // reload
|
||||
}
|
||||
break;
|
||||
case CourseEntryAction_Delete:
|
||||
{
|
||||
pCourse->m_vEntries.erase( pCourse->m_vEntries.begin() + iCourseEntry );
|
||||
SCREENMAN->SetNewScreen( this->m_sName ); // reload
|
||||
}
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ScreenOptions::ProcessMenuStart( pn, type );
|
||||
}
|
||||
|
||||
int ScreenOptionsEditCourse::GetCourseEntryIndexWithFocus() const
|
||||
{
|
||||
int iCurRow = m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber];
|
||||
if( iCurRow < NUM_EditCourseRow ) // not a CourseEntry
|
||||
return -1;
|
||||
else if( iCurRow == m_pRows.size() - 1 ) // "done"
|
||||
return -1;
|
||||
else
|
||||
return iCurRow - NUM_EditCourseRow;
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2002-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
@@ -1,15 +1,16 @@
|
||||
#ifndef ScreenEditCourse_H
|
||||
#define ScreenEditCourse_H
|
||||
#ifndef ScreenOptionsEditCourse_H
|
||||
#define ScreenOptionsEditCourse_H
|
||||
|
||||
#include "ScreenOptions.h"
|
||||
#include "Course.h"
|
||||
|
||||
class ScreenEditCourse : public ScreenOptions
|
||||
class ScreenOptionsEditCourse : public ScreenOptions
|
||||
{
|
||||
public:
|
||||
ScreenEditCourse( CString sName );
|
||||
ScreenOptionsEditCourse( CString sName );
|
||||
|
||||
void Init();
|
||||
virtual void BeginScreen();
|
||||
|
||||
virtual void HandleScreenMessage( const ScreenMessage SM );
|
||||
|
||||
@@ -20,6 +21,8 @@ protected:
|
||||
virtual void AfterChangeValueInRow( PlayerNumber pn );
|
||||
virtual void ProcessMenuStart( PlayerNumber pn, const InputEventType type );
|
||||
|
||||
int GetCourseEntryIndexWithFocus() const;
|
||||
|
||||
Course m_Original;
|
||||
};
|
||||
|
||||
+10
-10
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "ScreenEditCourseEntry.h"
|
||||
#include "ScreenOptionsEditCourseEntry.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "RageLog.h"
|
||||
#include "GameState.h"
|
||||
@@ -24,13 +24,13 @@ enum EditCourseEntryRow
|
||||
#define FOREACH_EditCourseEntryRow( i ) FOREACH_ENUM( EditCourseEntryRow, NUM_EditCourseEntryRow, i )
|
||||
|
||||
|
||||
REGISTER_SCREEN_CLASS( ScreenEditCourseEntry );
|
||||
ScreenEditCourseEntry::ScreenEditCourseEntry( CString sName ) : ScreenOptions( sName )
|
||||
REGISTER_SCREEN_CLASS( ScreenOptionsEditCourseEntry );
|
||||
ScreenOptionsEditCourseEntry::ScreenOptionsEditCourseEntry( CString sName ) : ScreenOptions( sName )
|
||||
{
|
||||
LOG->Trace( "ScreenEditCourseEntry::ScreenEditCourseEntry()" );
|
||||
LOG->Trace( "ScreenOptionsEditCourseEntry::ScreenOptionsEditCourseEntry()" );
|
||||
}
|
||||
|
||||
void ScreenEditCourseEntry::Init()
|
||||
void ScreenOptionsEditCourseEntry::Init()
|
||||
{
|
||||
ScreenOptions::Init();
|
||||
|
||||
@@ -111,7 +111,7 @@ void ScreenEditCourseEntry::Init()
|
||||
ImportAllOptions();
|
||||
}
|
||||
|
||||
void ScreenEditCourseEntry::HandleScreenMessage( const ScreenMessage SM )
|
||||
void ScreenOptionsEditCourseEntry::HandleScreenMessage( const ScreenMessage SM )
|
||||
{
|
||||
if( SM == SM_GoToNextScreen )
|
||||
{
|
||||
@@ -146,7 +146,7 @@ void ScreenEditCourseEntry::HandleScreenMessage( const ScreenMessage SM )
|
||||
ScreenOptions::HandleScreenMessage( SM );
|
||||
}
|
||||
|
||||
void ScreenEditCourseEntry::AfterChangeValueInRow( PlayerNumber pn )
|
||||
void ScreenOptionsEditCourseEntry::AfterChangeValueInRow( PlayerNumber pn )
|
||||
{
|
||||
ScreenOptions::AfterChangeValueInRow( pn );
|
||||
Course *pCourse = GAMESTATE->m_pCurCourse;
|
||||
@@ -254,7 +254,7 @@ void ScreenEditCourseEntry::AfterChangeValueInRow( PlayerNumber pn )
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenEditCourseEntry::ImportAllOptions()
|
||||
void ScreenOptionsEditCourseEntry::ImportAllOptions()
|
||||
{
|
||||
// fill choices before importing
|
||||
AfterChangeValueInRow( GAMESTATE->m_MasterPlayerNumber );
|
||||
@@ -327,12 +327,12 @@ void ScreenEditCourseEntry::ImportAllOptions()
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenEditCourseEntry::ExportOptions( int iRow, const vector<PlayerNumber> &vpns )
|
||||
void ScreenOptionsEditCourseEntry::ExportOptions( int iRow, const vector<PlayerNumber> &vpns )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ScreenEditCourseEntry::ProcessMenuStart( PlayerNumber pn, const InputEventType type )
|
||||
void ScreenOptionsEditCourseEntry::ProcessMenuStart( PlayerNumber pn, const InputEventType type )
|
||||
{
|
||||
switch( m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber] )
|
||||
{
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
#ifndef ScreenEditCourseEntry_H
|
||||
#define ScreenEditCourseEntry_H
|
||||
#ifndef ScreenOptionsEditCourseEntry_H
|
||||
#define ScreenOptionsEditCourseEntry_H
|
||||
|
||||
#include "ScreenOptions.h"
|
||||
#include "Course.h"
|
||||
|
||||
class ScreenEditCourseEntry : public ScreenOptions
|
||||
class ScreenOptionsEditCourseEntry : public ScreenOptions
|
||||
{
|
||||
public:
|
||||
ScreenEditCourseEntry( CString sName );
|
||||
ScreenOptionsEditCourseEntry( CString sName );
|
||||
|
||||
void Init();
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
#include "global.h"
|
||||
#include "ScreenOptionsManageCourses.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "RageLog.h"
|
||||
#include "GameState.h"
|
||||
#include "SongManager.h"
|
||||
#include "CommonMetrics.h"
|
||||
#include "ScreenTextEntry.h"
|
||||
#include "ScreenPrompt.h"
|
||||
|
||||
AutoScreenMessage( SM_BackFromEnterName )
|
||||
AutoScreenMessage( SM_BackFromDeleteConfirm )
|
||||
|
||||
enum CourseAction
|
||||
{
|
||||
CourseAction_Edit,
|
||||
CourseAction_Rename,
|
||||
CourseAction_Delete,
|
||||
NUM_CourseAction
|
||||
};
|
||||
static const CString CourseActionNames[] = {
|
||||
"Edit",
|
||||
"Rename",
|
||||
"Delete",
|
||||
};
|
||||
XToString( CourseAction, NUM_CourseAction );
|
||||
#define FOREACH_CourseAction( i ) FOREACH_ENUM( CourseAction, NUM_CourseAction, i )
|
||||
|
||||
|
||||
REGISTER_SCREEN_CLASS( ScreenOptionsManageCourses );
|
||||
ScreenOptionsManageCourses::ScreenOptionsManageCourses( CString sName ) : ScreenOptions( sName )
|
||||
{
|
||||
LOG->Trace( "ScreenOptionsManageCourses::ScreenOptionsManageCourses()" );
|
||||
}
|
||||
|
||||
void ScreenOptionsManageCourses::Init()
|
||||
{
|
||||
ScreenOptions::Init();
|
||||
|
||||
vector<OptionRowDefinition> vDefs;
|
||||
vector<OptionRowHandler*> vHands;
|
||||
|
||||
OptionRowDefinition def;
|
||||
def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW;
|
||||
|
||||
def.m_sName = "Create New";
|
||||
def.m_vsChoices.clear();
|
||||
def.m_vsChoices.push_back( "" );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
|
||||
SONGMAN->GetAllCourses( m_vpCourses, false );
|
||||
FOREACH_CONST( Course*, m_vpCourses, c )
|
||||
{
|
||||
def.m_sName = (*c)->GetDisplayFullTitle();
|
||||
def.m_vsChoices.clear();
|
||||
FOREACH_CourseAction( i )
|
||||
def.m_vsChoices.push_back( CourseActionToString(i) );
|
||||
vDefs.push_back( def );
|
||||
vHands.push_back( NULL );
|
||||
}
|
||||
|
||||
ScreenOptions::InitMenu( vDefs, vHands );
|
||||
}
|
||||
|
||||
void ScreenOptionsManageCourses::BeginScreen()
|
||||
{
|
||||
ScreenOptions::BeginScreen();
|
||||
|
||||
AfterChangeValueInRow( GAMESTATE->m_MasterPlayerNumber );
|
||||
}
|
||||
|
||||
void ScreenOptionsManageCourses::HandleScreenMessage( const ScreenMessage SM )
|
||||
{
|
||||
if( SM == SM_GoToNextScreen )
|
||||
{
|
||||
int iCurRow = m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber];
|
||||
if( iCurRow == m_pRows.size() - 1 )
|
||||
{
|
||||
this->HandleScreenMessage( SM_GoToPrevScreen );
|
||||
return; // don't call base
|
||||
}
|
||||
}
|
||||
else if( SM == SM_BackFromEnterName )
|
||||
{
|
||||
if( !ScreenTextEntry::s_bCancelledLast )
|
||||
{
|
||||
ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this
|
||||
|
||||
CString sNewName = ScreenTextEntry::s_sLastAnswer;
|
||||
ASSERT( GAMESTATE->m_sLastSelectedProfileID.empty() );
|
||||
|
||||
// create
|
||||
Course *pCourse = new Course;
|
||||
pCourse->SetLoadedFromProfile( PROFILE_SLOT_MACHINE );
|
||||
SONGMAN->AddCourse( pCourse );
|
||||
GAMESTATE->m_pCurCourse.Set( pCourse );
|
||||
this->HandleScreenMessage( SM_GoToNextScreen );
|
||||
}
|
||||
}
|
||||
else if( SM == SM_BackFromDeleteConfirm )
|
||||
{
|
||||
if( ScreenPrompt::s_LastAnswer == ANSWER_YES )
|
||||
{
|
||||
SONGMAN->DeleteCourse( GetCourseWithFocus() );
|
||||
SCREENMAN->SetNewScreen( this->m_sName ); // reload
|
||||
}
|
||||
}
|
||||
|
||||
ScreenOptions::HandleScreenMessage( SM );
|
||||
}
|
||||
|
||||
void ScreenOptionsManageCourses::AfterChangeValueInRow( PlayerNumber pn )
|
||||
{
|
||||
ScreenOptions::AfterChangeValueInRow( pn );
|
||||
}
|
||||
|
||||
void ScreenOptionsManageCourses::ProcessMenuStart( PlayerNumber pn, const InputEventType type )
|
||||
{
|
||||
int iCurRow = m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber];
|
||||
OptionRow &row = *m_pRows[iCurRow];
|
||||
|
||||
if( iCurRow == 0 ) // "create new"
|
||||
{
|
||||
CString sCurrentProfileName = "New Course";
|
||||
ScreenTextEntry::TextEntry(
|
||||
SM_BackFromEnterName,
|
||||
"Enter a name for a new course.",
|
||||
sCurrentProfileName,
|
||||
MAX_EDIT_COURSE_TITLE_LENGTH,
|
||||
SongManager::ValidateEditCourseName );
|
||||
}
|
||||
else if( iCurRow == m_pRows.size()-1 ) // "done"
|
||||
{
|
||||
SCREENMAN->SetNewScreen( FIRST_ATTRACT_SCREEN );
|
||||
}
|
||||
else // a course
|
||||
{
|
||||
switch( row.GetChoiceInRowWithFocusShared() )
|
||||
{
|
||||
case CourseAction_Edit:
|
||||
GAMESTATE->m_pCurCourse.Set( GetCourseWithFocus() );
|
||||
ScreenOptions::BeginFadingOut();
|
||||
break;
|
||||
case CourseAction_Rename:
|
||||
{
|
||||
CString sCurrentProfileName = "New Course";
|
||||
ScreenTextEntry::TextEntry(
|
||||
SM_BackFromEnterName,
|
||||
"Enter a name for a new course.",
|
||||
sCurrentProfileName,
|
||||
MAX_EDIT_COURSE_TITLE_LENGTH,
|
||||
SongManager::ValidateEditCourseName );
|
||||
}
|
||||
break;
|
||||
case CourseAction_Delete:
|
||||
{
|
||||
CString sTitle = GetCourseWithFocus()->GetDisplayFullTitle();
|
||||
CString sMessage = ssprintf( "Are you sure you want to delete the course '%s'?", sTitle.c_str() );
|
||||
ScreenPrompt::Prompt( SM_BackFromDeleteConfirm, sMessage, PROMPT_YES_NO );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenOptionsManageCourses::ImportOptions( int iRow, const vector<PlayerNumber> &vpns )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ScreenOptionsManageCourses::ExportOptions( int iRow, const vector<PlayerNumber> &vpns )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Course *ScreenOptionsManageCourses::GetCourseWithFocus() const
|
||||
{
|
||||
int iCurRow = m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber];
|
||||
if( iCurRow == 0 )
|
||||
return NULL;
|
||||
else if( iCurRow == m_pRows.size()-1 ) // "done"
|
||||
return NULL;
|
||||
else // a course
|
||||
return m_vpCourses[iCurRow];
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2002-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
@@ -1,14 +1,17 @@
|
||||
#ifndef ScreenCourseManager_H
|
||||
#define ScreenCourseManager_H
|
||||
#ifndef ScreenOptionsManageCourses_H
|
||||
#define ScreenOptionsManageCourses_H
|
||||
|
||||
#include "ScreenOptions.h"
|
||||
|
||||
class ScreenCourseManager : public ScreenOptions
|
||||
class Course;
|
||||
|
||||
class ScreenOptionsManageCourses : public ScreenOptions
|
||||
{
|
||||
public:
|
||||
ScreenCourseManager( CString sName );
|
||||
ScreenOptionsManageCourses( CString sName );
|
||||
|
||||
void Init();
|
||||
virtual void BeginScreen();
|
||||
|
||||
virtual void HandleScreenMessage( const ScreenMessage SM );
|
||||
|
||||
@@ -18,6 +21,10 @@ protected:
|
||||
|
||||
virtual void AfterChangeValueInRow( PlayerNumber pn );
|
||||
virtual void ProcessMenuStart( PlayerNumber pn, const InputEventType type );
|
||||
|
||||
Course *GetCourseWithFocus() const;
|
||||
|
||||
vector<Course*> m_vpCourses;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1341,7 +1341,7 @@ void Song::AddSteps( Steps* pSteps )
|
||||
m_vpStepsByType[pSteps->m_StepsType].push_back( pSteps );
|
||||
}
|
||||
|
||||
void Song::RemoveSteps( const Steps* pSteps )
|
||||
void Song::DeleteSteps( const Steps* pSteps )
|
||||
{
|
||||
// Avoid any stale Note::parent pointers by removing all AutoGen'd Steps,
|
||||
// then adding them again.
|
||||
@@ -1409,7 +1409,7 @@ void Song::FreeAllLoadedFromProfile( ProfileSlot slot )
|
||||
}
|
||||
|
||||
for( unsigned i = 0; i < apToRemove.size(); ++i )
|
||||
this->RemoveSteps( apToRemove[i] );
|
||||
this->DeleteSteps( apToRemove[i] );
|
||||
}
|
||||
|
||||
int Song::GetNumStepsLoadedFromProfile( ProfileSlot slot ) const
|
||||
@@ -1496,7 +1496,7 @@ void Song::MakeUniqueEditDescription( StepsType st, CString &sPreferredDescripti
|
||||
{
|
||||
// make name "My Edit" -> "My Edit"
|
||||
CString sNum = ssprintf("%d", i+1);
|
||||
sTemp = sPreferredDescriptionInOut.Left( MAX_EDIT_DESCRIPTION_LENGTH - sNum.size() ) + sNum;
|
||||
sTemp = sPreferredDescriptionInOut.Left( MAX_EDIT_STEPS_DESCRIPTION_LENGTH - sNum.size() ) + sNum;
|
||||
|
||||
if( IsEditDescriptionUnique(st, sTemp, NULL) )
|
||||
{
|
||||
|
||||
@@ -254,7 +254,7 @@ void SongManager::LoadGroupSymLinks(CString sDir, CString sGroupFolder)
|
||||
{
|
||||
const vector<Steps*>& vpSteps = pNewSong->GetAllSteps();
|
||||
while( vpSteps.size() )
|
||||
pNewSong->RemoveSteps( vpSteps[0] );
|
||||
pNewSong->DeleteSteps( vpSteps[0] );
|
||||
|
||||
FOREACH_BackgroundLayer( i )
|
||||
pNewSong->GetBackgroundChanges(i).clear();
|
||||
@@ -682,6 +682,22 @@ void SongManager::FreeCourses()
|
||||
m_sCourseGroupNames.clear();
|
||||
}
|
||||
|
||||
void SongManager::AddCourse( Course *pCourse )
|
||||
{
|
||||
m_pCourses.push_back( pCourse );
|
||||
UpdateBest();
|
||||
UpdateShuffled();
|
||||
}
|
||||
|
||||
void SongManager::DeleteCourse( Course *pCourse )
|
||||
{
|
||||
vector<Course*>::iterator iter = find( m_pCourses.begin(), m_pCourses.end(), pCourse );
|
||||
ASSERT( iter != m_pCourses.end() );
|
||||
m_pCourses.erase( iter );
|
||||
UpdateBest();
|
||||
UpdateShuffled();
|
||||
}
|
||||
|
||||
/* Called periodically to wipe out cached NoteData. This is called when we change
|
||||
* screens. */
|
||||
void SongManager::Cleanup()
|
||||
@@ -1319,6 +1335,12 @@ int SongManager::GetNumStepsLoadedFromProfile()
|
||||
return iCount;
|
||||
}
|
||||
|
||||
bool SongManager::ValidateEditCourseName( const CString &sAnswer, CString &sErrorOut )
|
||||
{
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// lua start
|
||||
#include "LuaBinding.h"
|
||||
|
||||
@@ -45,6 +45,8 @@ public:
|
||||
void InitCoursesFromDisk( LoadingWindow *ld );
|
||||
void InitAutogenCourses();
|
||||
void FreeCourses();
|
||||
void AddCourse( Course *pCourse ); // transfers ownership of pCourse
|
||||
void DeleteCourse( Course *pCourse ); // transfers ownership of pCourse
|
||||
|
||||
void InitAll( LoadingWindow *ld ); // songs, courses, groups - everything.
|
||||
void Reload( LoadingWindow *ld=NULL ); // songs, courses, groups - everything.
|
||||
@@ -106,6 +108,9 @@ public:
|
||||
// Lua
|
||||
void PushSelf( lua_State *L );
|
||||
|
||||
|
||||
static bool ValidateEditCourseName( const CString &sAnswer, CString &sErrorOut );
|
||||
|
||||
protected:
|
||||
void LoadStepManiaSongDir( CString sDir, LoadingWindow *ld );
|
||||
void LoadDWISongDir( CString sDir );
|
||||
|
||||
+29
-29
@@ -1,5 +1,5 @@
|
||||
# Microsoft Developer Studio Project File - Name="StepMania" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 60000
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
@@ -59,10 +59,10 @@ LINK32=link.exe
|
||||
# SUBTRACT LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib
|
||||
# Begin Special Build Tool
|
||||
IntDir=.\../Debug6
|
||||
TargetDir=\stepmania\stepmania\Program
|
||||
TargetDir=\cvs\stepmania\Program
|
||||
TargetName=StepMania-debug
|
||||
SOURCE="$(InputPath)"
|
||||
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
|
||||
# End Special Build Tool
|
||||
|
||||
@@ -96,10 +96,10 @@ LINK32=link.exe
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
# Begin Special Build Tool
|
||||
IntDir=.\../Release6
|
||||
TargetDir=\stepmania\stepmania\Program
|
||||
TargetDir=\cvs\stepmania\Program
|
||||
TargetName=StepMania
|
||||
SOURCE="$(InputPath)"
|
||||
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
|
||||
# End Special Build Tool
|
||||
|
||||
@@ -2510,14 +2510,6 @@ SOURCE=.\ScreenCenterImage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScreenCourseManager.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScreenCourseManager.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScreenCredits.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -2550,22 +2542,6 @@ SOURCE=.\ScreenEdit.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScreenEditCourse.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScreenEditCourse.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScreenEditCourseEntry.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScreenEditCourseEntry.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScreenEditMenu.cpp
|
||||
|
||||
!IF "$(CFG)" == "StepMania - Win32 Debug"
|
||||
@@ -2760,6 +2736,22 @@ SOURCE=.\ScreenOptions.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScreenOptionsEditCourse.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScreenOptionsEditCourse.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScreenOptionsEditCourseEntry.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScreenOptionsEditCourseEntry.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScreenOptionsEditProfile.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -2768,6 +2760,14 @@ SOURCE=.\ScreenOptionsEditProfile.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScreenOptionsManageCourses.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScreenOptionsManageCourses.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScreenOptionsMaster.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -337,9 +337,9 @@ void Steps::SetDifficultyAndDescription( Difficulty dc, CString sDescription )
|
||||
|
||||
bool Steps::MakeValidEditDescription( CString &sPreferredDescription )
|
||||
{
|
||||
if( int(sPreferredDescription.size()) > MAX_EDIT_DESCRIPTION_LENGTH )
|
||||
if( int(sPreferredDescription.size()) > MAX_EDIT_STEPS_DESCRIPTION_LENGTH )
|
||||
{
|
||||
sPreferredDescription = sPreferredDescription.Left( MAX_EDIT_DESCRIPTION_LENGTH );
|
||||
sPreferredDescription = sPreferredDescription.Left( MAX_EDIT_STEPS_DESCRIPTION_LENGTH );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -13,7 +13,7 @@ class Profile;
|
||||
class NoteData;
|
||||
struct lua_State;
|
||||
|
||||
const int MAX_EDIT_DESCRIPTION_LENGTH = 12;
|
||||
const int MAX_EDIT_STEPS_DESCRIPTION_LENGTH = 12;
|
||||
|
||||
class Steps
|
||||
{
|
||||
|
||||
@@ -219,7 +219,7 @@ public:
|
||||
bool ShowInDemonstrationAndRanking() const;
|
||||
|
||||
void AddSteps( Steps* pSteps ); // we are responsible for deleting the memory pointed to by pSteps!
|
||||
void RemoveSteps( const Steps* pSteps );
|
||||
void DeleteSteps( const Steps* pSteps );
|
||||
|
||||
void FreeAllLoadedFromProfile( ProfileSlot slot = PROFILE_SLOT_INVALID );
|
||||
bool WasLoadedFromProfile() const { return m_LoadedFromProfile != PROFILE_SLOT_INVALID; }
|
||||
|
||||
Reference in New Issue
Block a user