From e5c1f09fa0849b70d7a70f4f6c3ed70a778f7d4e Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 30 Jul 2005 23:40:26 +0000 Subject: [PATCH] don't allow more than 50 entries per course --- stepmania/src/Course.h | 2 ++ stepmania/src/ScreenOptionsEditCourse.cpp | 33 ++++++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index ed89e3081b..baa541441c 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -99,6 +99,8 @@ public: int GetNumModChanges() const; }; +const int MAX_ENTRIES_PER_COURSE = 50; + class Course { public: diff --git a/stepmania/src/ScreenOptionsEditCourse.cpp b/stepmania/src/ScreenOptionsEditCourse.cpp index 44b26a3b80..c8f2a9ecb8 100644 --- a/stepmania/src/ScreenOptionsEditCourse.cpp +++ b/stepmania/src/ScreenOptionsEditCourse.cpp @@ -8,6 +8,7 @@ #include "GameManager.h" #include "song.h" #include "ScreenMiniMenu.h" +#include "ScreenPrompt.h" enum EditCourseRow { @@ -115,12 +116,15 @@ void ScreenOptionsEditCourse::BeginScreen() { ScreenOptions::BeginScreen(); - this->MoveRowAbsolute( PLAYER_1, NUM_EditCourseRow + GAMESTATE->m_iEditCourseEntryIndex, false ); + if( GAMESTATE->m_iEditCourseEntryIndex > -1 ) + this->MoveRowAbsolute( PLAYER_1, NUM_EditCourseRow + GAMESTATE->m_iEditCourseEntryIndex, false ); AfterChangeRow( GAMESTATE->m_MasterPlayerNumber ); } void ScreenOptionsEditCourse::HandleScreenMessage( const ScreenMessage SM ) { + Course *pCourse = GAMESTATE->m_pCurCourse; + if( SM == SM_GoToNextScreen ) { int iCurRow = m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber]; @@ -130,6 +134,10 @@ void ScreenOptionsEditCourse::HandleScreenMessage( const ScreenMessage SM ) return; // don't call base } } + else if( SM == SM_GoToPrevScreen ) + { + GAMESTATE->m_iEditCourseEntryIndex.Set( -1 ); + } else if( SM == SM_BackFromContextMenu ) { if( !ScreenMiniMenu::s_bCancelled ) @@ -141,16 +149,20 @@ void ScreenOptionsEditCourse::HandleScreenMessage( const ScreenMessage SM ) break; case CourseEntryAction_InsertEntry: { - Course *pCourse = GAMESTATE->m_pCurCourse; + if( pCourse->m_vEntries.size() >= MAX_ENTRIES_PER_COURSE ) + { + CString sError = "The maximum number of entries per course is %d. This course already has %d entries."; + ScreenPrompt::Prompt( SM_None, sError ); + return; + } pCourse->m_vEntries.insert( pCourse->m_vEntries.begin() + GetCourseEntryIndexWithFocus(), CourseEntry() ); 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 ); + GAMESTATE->m_iEditCourseEntryIndex.Set( GAMESTATE->m_iEditCourseEntryIndex ); SCREENMAN->SetNewScreen( this->m_sName ); // reload } break; @@ -196,6 +208,7 @@ void ScreenOptionsEditCourse::ProcessMenuStart( PlayerNumber pn, const InputEven { int iCurRow = m_iCurrentRow[PLAYER_1]; OptionRow &row = *m_pRows[iCurRow]; + Course *pCourse = GAMESTATE->m_pCurCourse; if( iCurRow < NUM_EditCourseRow ) { @@ -203,9 +216,15 @@ void ScreenOptionsEditCourse::ProcessMenuStart( PlayerNumber pn, const InputEven } else if( iCurRow == m_pRows.size()-2 ) // "create entry" { - SCREENMAN->PlayInvalidSound(); - - // ASSERT( 0 ); + if( pCourse->m_vEntries.size() >= MAX_ENTRIES_PER_COURSE ) + { + CString sError = "The maximum number of entries per course is %d. This course already has %d entries."; + ScreenPrompt::Prompt( SM_None, sError ); + return; + } + pCourse->m_vEntries.push_back( CourseEntry() ); + GAMESTATE->m_iEditCourseEntryIndex.Set( pCourse->m_vEntries.size()-1 ); + SCREENMAN->SetNewScreen( this->m_sName ); // reload } else if( iCurRow == m_pRows.size()-1 ) // "done" {