From 93b9cc156a23eb69124a707e2056ec0c0af4b1c0 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Fri, 29 Jul 2005 23:03:43 +0000 Subject: [PATCH] working on course editor --- stepmania/src/ScreenOptionsEditCourse.cpp | 5 +- .../src/ScreenOptionsEditCourseEntry.cpp | 5 +- stepmania/src/ScreenOptionsEditProfile.cpp | 1 - stepmania/src/ScreenOptionsManageCourses.cpp | 99 ++++++++++++------- stepmania/src/ScreenOptionsManageCourses.h | 2 +- stepmania/src/ScreenOptionsSelectProfile.cpp | 1 - stepmania/src/ScreenSelectProfile.cpp | 1 - stepmania/src/SongManager.h | 2 +- 8 files changed, 75 insertions(+), 41 deletions(-) diff --git a/stepmania/src/ScreenOptionsEditCourse.cpp b/stepmania/src/ScreenOptionsEditCourse.cpp index 88ac416aee..0eecd3bb0f 100644 --- a/stepmania/src/ScreenOptionsEditCourse.cpp +++ b/stepmania/src/ScreenOptionsEditCourse.cpp @@ -7,6 +7,7 @@ #include "CommonMetrics.h" #include "GameManager.h" #include "song.h" +#include "FontCharAliases.h" enum EditCourseRow { @@ -98,7 +99,9 @@ void ScreenOptionsEditCourse::Init() def.m_sName = "Insert Entry"; def.m_vsChoices.clear(); - def.m_vsChoices.push_back( "" ); + CString sStart = "&Start;"; + FontCharAliases::ReplaceMarkers( sStart ); + def.m_vsChoices.push_back( sStart ); vDefs.push_back( def ); vHands.push_back( NULL ); diff --git a/stepmania/src/ScreenOptionsEditCourseEntry.cpp b/stepmania/src/ScreenOptionsEditCourseEntry.cpp index c2868157a2..336bb8ee01 100644 --- a/stepmania/src/ScreenOptionsEditCourseEntry.cpp +++ b/stepmania/src/ScreenOptionsEditCourseEntry.cpp @@ -7,6 +7,7 @@ #include "CommonMetrics.h" #include "GameManager.h" #include "song.h" +#include "FontCharAliases.h" enum EditCourseEntryRow { @@ -58,7 +59,9 @@ void ScreenOptionsEditCourseEntry::Init() def.m_sName = "Song"; def.m_vsChoices.clear(); - def.m_vsChoices.push_back( "" ); + CString sStart = "&Start;"; + FontCharAliases::ReplaceMarkers( sStart ); + def.m_vsChoices.push_back( sStart ); vDefs.push_back( def ); vHands.push_back( NULL ); diff --git a/stepmania/src/ScreenOptionsEditProfile.cpp b/stepmania/src/ScreenOptionsEditProfile.cpp index 96cc8ce91c..22d5968721 100644 --- a/stepmania/src/ScreenOptionsEditProfile.cpp +++ b/stepmania/src/ScreenOptionsEditProfile.cpp @@ -1,7 +1,6 @@ #include "global.h" #include "ScreenOptionsEditProfile.h" -#include "ScreenMiniMenu.h" #include "ScreenManager.h" #include "ProfileManager.h" #include "ScreenTextEntry.h" diff --git a/stepmania/src/ScreenOptionsManageCourses.cpp b/stepmania/src/ScreenOptionsManageCourses.cpp index f381e865f8..bb18aab9f3 100644 --- a/stepmania/src/ScreenOptionsManageCourses.cpp +++ b/stepmania/src/ScreenOptionsManageCourses.cpp @@ -7,9 +7,12 @@ #include "CommonMetrics.h" #include "ScreenTextEntry.h" #include "ScreenPrompt.h" +#include "FontCharAliases.h" +#include "ScreenMiniMenu.h" AutoScreenMessage( SM_BackFromEnterName ) AutoScreenMessage( SM_BackFromDeleteConfirm ) +AutoScreenMessage( SM_BackFromContextMenu ) enum CourseAction { @@ -26,6 +29,9 @@ static const CString CourseActionNames[] = { XToString( CourseAction, NUM_CourseAction ); #define FOREACH_CourseAction( i ) FOREACH_ENUM( CourseAction, NUM_CourseAction, i ) +static MenuDef g_TempMenu( + "ScreenMiniMenuContext" +); REGISTER_SCREEN_CLASS( ScreenOptionsManageCourses ); ScreenOptionsManageCourses::ScreenOptionsManageCourses( CString sName ) : ScreenOptions( sName ) @@ -43,19 +49,20 @@ void ScreenOptionsManageCourses::Init() OptionRowDefinition def; def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; - def.m_sName = "Create New"; + def.m_sName = ""; def.m_vsChoices.clear(); - def.m_vsChoices.push_back( "" ); + CString sStart = "Create New"; + FontCharAliases::ReplaceMarkers( sStart ); + def.m_vsChoices.push_back( sStart ); 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_sName = CourseTypeToThemedString( (*c)->GetCourseType() ); def.m_vsChoices.clear(); - FOREACH_CourseAction( i ) - def.m_vsChoices.push_back( CourseActionToString(i) ); + def.m_vsChoices.push_back( (*c)->GetDisplayFullTitle() ); vDefs.push_back( def ); vHands.push_back( NULL ); } @@ -66,8 +73,8 @@ void ScreenOptionsManageCourses::Init() void ScreenOptionsManageCourses::BeginScreen() { ScreenOptions::BeginScreen(); - - AfterChangeValueInRow( GAMESTATE->m_MasterPlayerNumber ); + + AfterChangeRow( PLAYER_1 ); } void ScreenOptionsManageCourses::HandleScreenMessage( const ScreenMessage SM ) @@ -106,13 +113,50 @@ void ScreenOptionsManageCourses::HandleScreenMessage( const ScreenMessage SM ) 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() ); + 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; + } + } + } ScreenOptions::HandleScreenMessage( SM ); } -void ScreenOptionsManageCourses::AfterChangeValueInRow( PlayerNumber pn ) +void ScreenOptionsManageCourses::AfterChangeRow( PlayerNumber pn ) { - ScreenOptions::AfterChangeValueInRow( pn ); + Course *pCourse = GetCourseWithFocus(); + Trail *pTrail = pCourse ? pCourse->GetTrail( STEPS_TYPE_DANCE_SINGLE ) : NULL; + + GAMESTATE->m_pCurCourse.Set( pCourse ); + GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail ); + + ScreenOptions::AfterChangeRow( pn ); } void ScreenOptionsManageCourses::ProcessMenuStart( PlayerNumber pn, const InputEventType type ) @@ -136,31 +180,16 @@ void ScreenOptionsManageCourses::ProcessMenuStart( PlayerNumber pn, const InputE } else // a course { - switch( row.GetChoiceInRowWithFocusShared() ) + g_TempMenu.rows.clear(); + FOREACH_CourseAction( i ) { - 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; + MenuRowDef mrd( i, CourseActionToString(i), true, EDIT_MODE_HOME, 0, "" ); + g_TempMenu.rows.push_back( mrd ); } + + int iWidth, iX, iY; + this->GetWidthXY( PLAYER_1, iCurRow, 0, iWidth, iX, iY ); + ScreenMiniMenu::MiniMenu( &g_TempMenu, SM_BackFromContextMenu, SM_BackFromContextMenu, iX, iY ); } } @@ -181,8 +210,10 @@ Course *ScreenOptionsManageCourses::GetCourseWithFocus() const return NULL; else if( iCurRow == m_pRows.size()-1 ) // "done" return NULL; - else // a course - return m_vpCourses[iCurRow]; + + // a course + int iCourseIndex = iCurRow - 1; + return m_vpCourses[iCourseIndex]; } /* diff --git a/stepmania/src/ScreenOptionsManageCourses.h b/stepmania/src/ScreenOptionsManageCourses.h index bf53fb34dc..cd7b9913b6 100644 --- a/stepmania/src/ScreenOptionsManageCourses.h +++ b/stepmania/src/ScreenOptionsManageCourses.h @@ -19,7 +19,7 @@ protected: virtual void ImportOptions( int iRow, const vector &vpns ); virtual void ExportOptions( int iRow, const vector &vpns ); - virtual void AfterChangeValueInRow( PlayerNumber pn ); + virtual void AfterChangeRow( PlayerNumber pn ); virtual void ProcessMenuStart( PlayerNumber pn, const InputEventType type ); Course *GetCourseWithFocus() const; diff --git a/stepmania/src/ScreenOptionsSelectProfile.cpp b/stepmania/src/ScreenOptionsSelectProfile.cpp index 8a8287fa2d..3059561dd6 100644 --- a/stepmania/src/ScreenOptionsSelectProfile.cpp +++ b/stepmania/src/ScreenOptionsSelectProfile.cpp @@ -1,7 +1,6 @@ #include "global.h" #include "ScreenOptionsSelectProfile.h" -#include "ScreenMiniMenu.h" #include "ProfileManager.h" #include "ScreenTextEntry.h" #include "ScreenPrompt.h" diff --git a/stepmania/src/ScreenSelectProfile.cpp b/stepmania/src/ScreenSelectProfile.cpp index 354b683d9c..94218b41a5 100644 --- a/stepmania/src/ScreenSelectProfile.cpp +++ b/stepmania/src/ScreenSelectProfile.cpp @@ -1,7 +1,6 @@ #include "global.h" #include "ScreenSelectProfile.h" -#include "ScreenMiniMenu.h" #include "ProfileManager.h" #include "ScreenTextEntry.h" #include "ScreenPrompt.h" diff --git a/stepmania/src/SongManager.h b/stepmania/src/SongManager.h index 47d3f61c56..dc59303ea7 100644 --- a/stepmania/src/SongManager.h +++ b/stepmania/src/SongManager.h @@ -129,7 +129,7 @@ protected: CStringArray m_sSongGroupBannerPaths; // each song group may have a banner associated with it vector m_pCourses; - vector m_pBestCourses[NUM_PROFILE_SLOTS][NUM_COURSE_TYPES]; + vector m_pBestCourses[NUM_PROFILE_SLOTS][NUM_CourseType]; vector m_pShuffledCourses; // used by GetRandomCourse CStringArray m_sCourseGroupNames; CStringArray m_sCourseGroupBannerPaths; // each course group may have a banner associated with it