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")
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()
{
Init();
+4 -1
View File
@@ -43,7 +43,7 @@ enum SongSort
SongSort_FewestPlays,
SongSort_TopGrades,
SongSort_LowestGrades,
NUM_SongSort
NUM_SongSort,
};
#define FOREACH_SongSort( i ) FOREACH_ENUM( SongSort, NUM_SongSort, i )
const CString& SongSortToString( SongSort ss );
@@ -55,6 +55,7 @@ public:
bool bSecret; // show "??????" instead of an exact song
// filter criteria, applied from top to bottom
// TODO: change this to be a SongID
Song* pSong; // don't filter if NULL
CString sSongGroup; // don't filter if empty
Difficulty baseDifficulty; // don't filter if DIFFICULTY_INVALID
@@ -93,6 +94,8 @@ public:
iChooseIndex == -1 &&
pSong == NULL;
}
CString GetTextDescription() const;
};
class Course
+65 -52
View File
@@ -7,7 +7,7 @@
#include "CommonMetrics.h"
#include "GameManager.h"
#include "song.h"
#include "FontCharAliases.h"
#include "ScreenMiniMenu.h"
enum EditCourseRow
{
@@ -18,6 +18,8 @@ enum EditCourseRow
NUM_EditCourseRow
};
AutoScreenMessage( SM_BackFromContextMenu )
enum CourseEntryAction
{
CourseEntryAction_Edit,
@@ -33,6 +35,9 @@ static const CString CourseEntryActionNames[] = {
XToString( CourseEntryAction, NUM_CourseEntryAction );
#define FOREACH_CourseEntryAction( i ) FOREACH_ENUM( CourseEntryAction, NUM_CourseEntryAction, i )
static MenuDef g_TempMenu(
"ScreenMiniMenuContext"
);
REGISTER_SCREEN_CLASS( ScreenOptionsEditCourse );
ScreenOptionsEditCourse::ScreenOptionsEditCourse( CString sName ) : ScreenOptions( sName )
@@ -89,19 +94,17 @@ void ScreenOptionsEditCourse::Init()
FOREACH_CONST( CourseEntry, pCourse->m_vEntries, ce )
{
int iEntryIndex = ce - pCourse->m_vEntries.begin();
CourseEntry &ce = pCourse->m_vEntries[iEntryIndex];
def.m_sName = ssprintf( "Entry %d", iEntryIndex+1 );
def.m_vsChoices.clear();
FOREACH_CourseEntryAction( i )
def.m_vsChoices.push_back( CourseEntryActionToString(i) );
def.m_vsChoices.push_back( ce.GetTextDescription() );
vDefs.push_back( def );
vHands.push_back( NULL );
}
def.m_sName = "Insert Entry";
def.m_sName = "";
def.m_vsChoices.clear();
CString sStart = "&Start;";
FontCharAliases::ReplaceMarkers( sStart );
def.m_vsChoices.push_back( sStart );
def.m_vsChoices.push_back( "Insert Entry" );
vDefs.push_back( def );
vHands.push_back( NULL );
@@ -112,7 +115,8 @@ void ScreenOptionsEditCourse::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 )
@@ -120,37 +124,49 @@ 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 )
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 )
else if( SM == SM_BackFromContextMenu )
{
// revert
//Course *pCourse = GAMESTATE->m_pCurCourse;
//*pCourse = m_Original;
//SCREENMAN->SetNewScreen( "ScreenCourseManager" );
//return;
if( !ScreenMiniMenu::s_bCancelled )
{
switch( ScreenMiniMenu::s_iLastRowCode )
{
case CourseEntryAction_Edit:
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 );
}
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 )
@@ -178,38 +194,35 @@ void ScreenOptionsEditCourse::ExportOptions( int iRow, const vector<PlayerNumber
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];
int iCurRow = m_iCurrentRow[PLAYER_1];
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:
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;
MenuRowDef mrd( i, CourseEntryActionToString(i), true, EDIT_MODE_HOME, 0, "" );
g_TempMenu.rows.push_back( mrd );
}
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
+1 -1
View File
@@ -18,7 +18,7 @@ protected:
virtual void ImportOptions( 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 );
int GetCourseEntryIndexWithFocus() const;
@@ -110,7 +110,12 @@ void ScreenOptionsEditCourseEntry::Init()
vHands.push_back( NULL );
ScreenOptions::InitMenu( vDefs, vHands );
}
void ScreenOptionsEditCourseEntry::BeginScreen()
{
ScreenOptions::BeginScreen();
ImportAllOptions();
}
@@ -131,7 +136,7 @@ void ScreenOptionsEditCourseEntry::HandleScreenMessage( const ScreenMessage SM )
SCREENMAN->SetNewScreen( "ScreenEditCourseMods" );
break;
case ROW_DONE:
SCREENMAN->SetNewScreen( "ScreenEditCourse" );
SCREENMAN->SetNewScreen( "ScreenOptionsEditCourse" );
break;
}
return;
@@ -142,7 +147,7 @@ void ScreenOptionsEditCourseEntry::HandleScreenMessage( const ScreenMessage SM )
Course *pCourse = GAMESTATE->m_pCurCourse;
pCourse->m_vEntries[ GAMESTATE->m_iEditCourseEntryIndex ] = m_Original;
SCREENMAN->SetNewScreen( "ScreenEditCourse" );
SCREENMAN->SetNewScreen( "ScreenOptionsEditCourse" );
return;
}
@@ -10,6 +10,7 @@ public:
ScreenOptionsEditCourseEntry( CString sName );
void Init();
void BeginScreen();
virtual void HandleScreenMessage( const ScreenMessage SM );
+2 -5
View File
@@ -7,7 +7,6 @@
#include "CommonMetrics.h"
#include "ScreenTextEntry.h"
#include "ScreenPrompt.h"
#include "FontCharAliases.h"
#include "ScreenMiniMenu.h"
AutoScreenMessage( SM_BackFromEnterName )
@@ -51,9 +50,7 @@ void ScreenOptionsManageCourses::Init()
def.m_sName = "";
def.m_vsChoices.clear();
CString sStart = "Create New";
FontCharAliases::ReplaceMarkers( sStart );
def.m_vsChoices.push_back( sStart );
def.m_vsChoices.push_back( "Create New" );
vDefs.push_back( def );
vHands.push_back( NULL );
@@ -176,7 +173,7 @@ void ScreenOptionsManageCourses::ProcessMenuStart( PlayerNumber pn, const InputE
}
else if( iCurRow == m_pRows.size()-1 ) // "done"
{
SCREENMAN->SetNewScreen( FIRST_ATTRACT_SCREEN );
this->BeginFadingOut();
}
else // a course
{