working on new course editor

This commit is contained in:
Chris Danford
2005-07-30 04:50:17 +00:00
parent 00b65ce3bc
commit e6df021062
7 changed files with 113 additions and 61 deletions
+33
View File
@@ -54,6 +54,39 @@ const int MAX_BOTTOM_RANGE = 10;
#define SORT_LEVEL5_COLOR THEME->GetMetricC("Course","SortLevel5Color") #define SORT_LEVEL5_COLOR THEME->GetMetricC("Course","SortLevel5Color")
CString CourseEntry::GetTextDescription() const
{
vector<CString> vsEntryDescription;
if( pSong )
vsEntryDescription.push_back( pSong->GetTranslitFullTitle() );
else
vsEntryDescription.push_back( "Random" );
if( !sSongGroup.empty() )
vsEntryDescription.push_back( sSongGroup );
if( baseDifficulty != DIFFICULTY_INVALID )
vsEntryDescription.push_back( DifficultyToThemedString(baseDifficulty) );
if( iLowMeter != -1 )
vsEntryDescription.push_back( ssprintf("Low meter: %d", iLowMeter) );
if( iHighMeter != -1 )
vsEntryDescription.push_back( ssprintf("High meter: %d", iHighMeter) );
if( songSort != SongSort_Randomize )
vsEntryDescription.push_back( "Sort: %d" + SongSortToThemedString(songSort) );
if( songSort != SongSort_Randomize && iChooseIndex != 0 )
vsEntryDescription.push_back( "Choose " + FormatNumberAndSuffix(iChooseIndex) + " match" );
int iNumModChanges = 0;
if( !sModifiers.empty() )
iNumModChanges++;
iNumModChanges += attacks.size();
if( iNumModChanges != 0 )
vsEntryDescription.push_back( ssprintf("%d mod changes", iNumModChanges) );
if( fGainSeconds != 0 )
vsEntryDescription.push_back( ssprintf("Low meter: %.0f", fGainSeconds) );
CString s = join( ",", vsEntryDescription );
return s;
}
Course::Course() Course::Course()
{ {
Init(); Init();
+4 -1
View File
@@ -43,7 +43,7 @@ enum SongSort
SongSort_FewestPlays, SongSort_FewestPlays,
SongSort_TopGrades, SongSort_TopGrades,
SongSort_LowestGrades, SongSort_LowestGrades,
NUM_SongSort NUM_SongSort,
}; };
#define FOREACH_SongSort( i ) FOREACH_ENUM( SongSort, NUM_SongSort, i ) #define FOREACH_SongSort( i ) FOREACH_ENUM( SongSort, NUM_SongSort, i )
const CString& SongSortToString( SongSort ss ); const CString& SongSortToString( SongSort ss );
@@ -55,6 +55,7 @@ public:
bool bSecret; // show "??????" instead of an exact song bool bSecret; // show "??????" instead of an exact song
// filter criteria, applied from top to bottom // filter criteria, applied from top to bottom
// TODO: change this to be a SongID
Song* pSong; // don't filter if NULL Song* pSong; // don't filter if NULL
CString sSongGroup; // don't filter if empty CString sSongGroup; // don't filter if empty
Difficulty baseDifficulty; // don't filter if DIFFICULTY_INVALID Difficulty baseDifficulty; // don't filter if DIFFICULTY_INVALID
@@ -93,6 +94,8 @@ public:
iChooseIndex == -1 && iChooseIndex == -1 &&
pSong == NULL; pSong == NULL;
} }
CString GetTextDescription() const;
}; };
class Course class Course
+65 -52
View File
@@ -7,7 +7,7 @@
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include "GameManager.h" #include "GameManager.h"
#include "song.h" #include "song.h"
#include "FontCharAliases.h" #include "ScreenMiniMenu.h"
enum EditCourseRow enum EditCourseRow
{ {
@@ -18,6 +18,8 @@ enum EditCourseRow
NUM_EditCourseRow NUM_EditCourseRow
}; };
AutoScreenMessage( SM_BackFromContextMenu )
enum CourseEntryAction enum CourseEntryAction
{ {
CourseEntryAction_Edit, CourseEntryAction_Edit,
@@ -33,6 +35,9 @@ static const CString CourseEntryActionNames[] = {
XToString( CourseEntryAction, NUM_CourseEntryAction ); XToString( CourseEntryAction, NUM_CourseEntryAction );
#define FOREACH_CourseEntryAction( i ) FOREACH_ENUM( CourseEntryAction, NUM_CourseEntryAction, i ) #define FOREACH_CourseEntryAction( i ) FOREACH_ENUM( CourseEntryAction, NUM_CourseEntryAction, i )
static MenuDef g_TempMenu(
"ScreenMiniMenuContext"
);
REGISTER_SCREEN_CLASS( ScreenOptionsEditCourse ); REGISTER_SCREEN_CLASS( ScreenOptionsEditCourse );
ScreenOptionsEditCourse::ScreenOptionsEditCourse( CString sName ) : ScreenOptions( sName ) ScreenOptionsEditCourse::ScreenOptionsEditCourse( CString sName ) : ScreenOptions( sName )
@@ -89,19 +94,17 @@ void ScreenOptionsEditCourse::Init()
FOREACH_CONST( CourseEntry, pCourse->m_vEntries, ce ) FOREACH_CONST( CourseEntry, pCourse->m_vEntries, ce )
{ {
int iEntryIndex = ce - pCourse->m_vEntries.begin(); int iEntryIndex = ce - pCourse->m_vEntries.begin();
CourseEntry &ce = pCourse->m_vEntries[iEntryIndex];
def.m_sName = ssprintf( "Entry %d", iEntryIndex+1 ); def.m_sName = ssprintf( "Entry %d", iEntryIndex+1 );
def.m_vsChoices.clear(); def.m_vsChoices.clear();
FOREACH_CourseEntryAction( i ) def.m_vsChoices.push_back( ce.GetTextDescription() );
def.m_vsChoices.push_back( CourseEntryActionToString(i) );
vDefs.push_back( def ); vDefs.push_back( def );
vHands.push_back( NULL ); vHands.push_back( NULL );
} }
def.m_sName = "Insert Entry"; def.m_sName = "";
def.m_vsChoices.clear(); def.m_vsChoices.clear();
CString sStart = "&Start;"; def.m_vsChoices.push_back( "Insert Entry" );
FontCharAliases::ReplaceMarkers( sStart );
def.m_vsChoices.push_back( sStart );
vDefs.push_back( def ); vDefs.push_back( def );
vHands.push_back( NULL ); vHands.push_back( NULL );
@@ -112,7 +115,8 @@ void ScreenOptionsEditCourse::BeginScreen()
{ {
ScreenOptions::BeginScreen(); ScreenOptions::BeginScreen();
AfterChangeValueInRow( GAMESTATE->m_MasterPlayerNumber ); this->MoveRowAbsolute( PLAYER_1, NUM_EditCourseRow + GAMESTATE->m_iEditCourseEntryIndex, false );
AfterChangeRow( GAMESTATE->m_MasterPlayerNumber );
} }
void ScreenOptionsEditCourse::HandleScreenMessage( const ScreenMessage SM ) void ScreenOptionsEditCourse::HandleScreenMessage( const ScreenMessage SM )
@@ -120,37 +124,49 @@ void ScreenOptionsEditCourse::HandleScreenMessage( const ScreenMessage SM )
if( SM == SM_GoToNextScreen ) if( SM == SM_GoToNextScreen )
{ {
int iCurRow = m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber]; int iCurRow = m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber];
if( iCurRow < NUM_EditCourseRow ) if( iCurRow == m_pRows.size() - 1 )
{
ASSERT( 0 );
}
else if( iCurRow == m_pRows.size() - 1 )
{ {
this->HandleScreenMessage( SM_GoToPrevScreen ); this->HandleScreenMessage( SM_GoToPrevScreen );
return; // don't call base return; // don't call base
} }
else
{
int iCourseEntry = iCurRow - NUM_EditCourseRow;
GAMESTATE->m_iEditCourseEntryIndex.Set( iCourseEntry );
}
} }
else if( SM == SM_GoToPrevScreen ) else if( SM == SM_BackFromContextMenu )
{ {
// revert if( !ScreenMiniMenu::s_bCancelled )
//Course *pCourse = GAMESTATE->m_pCurCourse; {
//*pCourse = m_Original; switch( ScreenMiniMenu::s_iLastRowCode )
{
//SCREENMAN->SetNewScreen( "ScreenCourseManager" ); case CourseEntryAction_Edit:
//return; ScreenOptions::BeginFadingOut();
break;
case CourseEntryAction_InsertEntry:
{
Course *pCourse = GAMESTATE->m_pCurCourse;
pCourse->m_vEntries.insert( pCourse->m_vEntries.begin() + GetCourseEntryIndexWithFocus() );
SCREENMAN->SetNewScreen( this->m_sName ); // reload
}
break;
case CourseEntryAction_Delete:
{
Course *pCourse = GAMESTATE->m_pCurCourse;
pCourse->m_vEntries.erase( pCourse->m_vEntries.begin() + GetCourseEntryIndexWithFocus() );
GAMESTATE->m_iEditCourseEntryIndex.Set( GAMESTATE->m_iEditCourseEntryIndex-1 );
SCREENMAN->SetNewScreen( this->m_sName ); // reload
}
break;
}
}
} }
ScreenOptions::HandleScreenMessage( SM ); ScreenOptions::HandleScreenMessage( SM );
} }
void ScreenOptionsEditCourse::AfterChangeValueInRow( PlayerNumber pn ) void ScreenOptionsEditCourse::AfterChangeRow( PlayerNumber pn )
{ {
ScreenOptions::AfterChangeValueInRow( pn ); ScreenOptions::AfterChangeRow( pn );
int iCourseEntry = GetCourseEntryIndexWithFocus();
GAMESTATE->m_iEditCourseEntryIndex.Set( iCourseEntry );
} }
void ScreenOptionsEditCourse::ImportOptions( int iRow, const vector<PlayerNumber> &vpns ) void ScreenOptionsEditCourse::ImportOptions( int iRow, const vector<PlayerNumber> &vpns )
@@ -178,38 +194,35 @@ void ScreenOptionsEditCourse::ExportOptions( int iRow, const vector<PlayerNumber
void ScreenOptionsEditCourse::ProcessMenuStart( PlayerNumber pn, const InputEventType type ) void ScreenOptionsEditCourse::ProcessMenuStart( PlayerNumber pn, const InputEventType type )
{ {
Course *pCourse = GAMESTATE->m_pCurCourse; int iCurRow = m_iCurrentRow[PLAYER_1];
int iCourseEntry = GetCourseEntryIndexWithFocus();
GAMESTATE->m_iEditCourseEntryIndex.Set( iCourseEntry );
int iCurRow = m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber];
OptionRow &row = *m_pRows[iCurRow]; OptionRow &row = *m_pRows[iCurRow];
if( iCourseEntry != -1 ) if( iCurRow < NUM_EditCourseRow )
{ {
switch( row.GetChoiceInRowWithFocusShared() ) // ignore
}
else if( iCurRow == m_pRows.size()-2 ) // "create entry"
{
ASSERT( 0 );
}
else if( iCurRow == m_pRows.size()-1 ) // "done"
{
this->BeginFadingOut();
}
else // a course entry
{
g_TempMenu.rows.clear();
FOREACH_CourseEntryAction( i )
{ {
case CourseEntryAction_Edit: MenuRowDef mrd( i, CourseEntryActionToString(i), true, EDIT_MODE_HOME, 0, "" );
ScreenOptions::BeginFadingOut(); g_TempMenu.rows.push_back( mrd );
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;
int iWidth, iX, iY;
this->GetWidthXY( PLAYER_1, iCurRow, 0, iWidth, iX, iY );
ScreenMiniMenu::MiniMenu( &g_TempMenu, SM_BackFromContextMenu, SM_BackFromContextMenu, iX, iY );
} }
ScreenOptions::ProcessMenuStart( pn, type );
} }
int ScreenOptionsEditCourse::GetCourseEntryIndexWithFocus() const int ScreenOptionsEditCourse::GetCourseEntryIndexWithFocus() const
+1 -1
View File
@@ -18,7 +18,7 @@ protected:
virtual void ImportOptions( int iRow, const vector<PlayerNumber> &vpns ); virtual void ImportOptions( int iRow, const vector<PlayerNumber> &vpns );
virtual void ExportOptions( int iRow, const vector<PlayerNumber> &vpns ); virtual void ExportOptions( int iRow, const vector<PlayerNumber> &vpns );
virtual void AfterChangeValueInRow( PlayerNumber pn ); virtual void AfterChangeRow( PlayerNumber pn );
virtual void ProcessMenuStart( PlayerNumber pn, const InputEventType type ); virtual void ProcessMenuStart( PlayerNumber pn, const InputEventType type );
int GetCourseEntryIndexWithFocus() const; int GetCourseEntryIndexWithFocus() const;
@@ -110,6 +110,11 @@ void ScreenOptionsEditCourseEntry::Init()
vHands.push_back( NULL ); vHands.push_back( NULL );
ScreenOptions::InitMenu( vDefs, vHands ); ScreenOptions::InitMenu( vDefs, vHands );
}
void ScreenOptionsEditCourseEntry::BeginScreen()
{
ScreenOptions::BeginScreen();
ImportAllOptions(); ImportAllOptions();
} }
@@ -131,7 +136,7 @@ void ScreenOptionsEditCourseEntry::HandleScreenMessage( const ScreenMessage SM )
SCREENMAN->SetNewScreen( "ScreenEditCourseMods" ); SCREENMAN->SetNewScreen( "ScreenEditCourseMods" );
break; break;
case ROW_DONE: case ROW_DONE:
SCREENMAN->SetNewScreen( "ScreenEditCourse" ); SCREENMAN->SetNewScreen( "ScreenOptionsEditCourse" );
break; break;
} }
return; return;
@@ -142,7 +147,7 @@ void ScreenOptionsEditCourseEntry::HandleScreenMessage( const ScreenMessage SM )
Course *pCourse = GAMESTATE->m_pCurCourse; Course *pCourse = GAMESTATE->m_pCurCourse;
pCourse->m_vEntries[ GAMESTATE->m_iEditCourseEntryIndex ] = m_Original; pCourse->m_vEntries[ GAMESTATE->m_iEditCourseEntryIndex ] = m_Original;
SCREENMAN->SetNewScreen( "ScreenEditCourse" ); SCREENMAN->SetNewScreen( "ScreenOptionsEditCourse" );
return; return;
} }
@@ -10,6 +10,7 @@ public:
ScreenOptionsEditCourseEntry( CString sName ); ScreenOptionsEditCourseEntry( CString sName );
void Init(); void Init();
void BeginScreen();
virtual void HandleScreenMessage( const ScreenMessage SM ); virtual void HandleScreenMessage( const ScreenMessage SM );
+2 -5
View File
@@ -7,7 +7,6 @@
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include "ScreenTextEntry.h" #include "ScreenTextEntry.h"
#include "ScreenPrompt.h" #include "ScreenPrompt.h"
#include "FontCharAliases.h"
#include "ScreenMiniMenu.h" #include "ScreenMiniMenu.h"
AutoScreenMessage( SM_BackFromEnterName ) AutoScreenMessage( SM_BackFromEnterName )
@@ -51,9 +50,7 @@ void ScreenOptionsManageCourses::Init()
def.m_sName = ""; def.m_sName = "";
def.m_vsChoices.clear(); def.m_vsChoices.clear();
CString sStart = "Create New"; def.m_vsChoices.push_back( "Create New" );
FontCharAliases::ReplaceMarkers( sStart );
def.m_vsChoices.push_back( sStart );
vDefs.push_back( def ); vDefs.push_back( def );
vHands.push_back( NULL ); vHands.push_back( NULL );
@@ -176,7 +173,7 @@ void ScreenOptionsManageCourses::ProcessMenuStart( PlayerNumber pn, const InputE
} }
else if( iCurRow == m_pRows.size()-1 ) // "done" else if( iCurRow == m_pRows.size()-1 ) // "done"
{ {
SCREENMAN->SetNewScreen( FIRST_ATTRACT_SCREEN ); this->BeginFadingOut();
} }
else // a course else // a course
{ {