From 1a9b738d8b4fd41c4cb4c0cc9ff2fa7bfcb446c5 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Fri, 5 Aug 2005 10:07:49 +0000 Subject: [PATCH] new profile/course screen polish --- stepmania/Themes/default/metrics.ini | 13 ++++----- stepmania/src/ScreenOptionsEditProfile.cpp | 16 +++++++++-- stepmania/src/ScreenOptionsEditProfile.h | 7 ++++- stepmania/src/ScreenOptionsManageCourses.cpp | 28 +++++++++++++++---- stepmania/src/ScreenOptionsManageProfiles.cpp | 26 ++++++++++++++++- stepmania/src/SongManager.cpp | 14 ++++++++-- stepmania/src/SongManager.h | 5 ++++ 7 files changed, 90 insertions(+), 19 deletions(-) diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index d35d19e2a8..db4c36ad35 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -4451,15 +4451,14 @@ NextScreen=@GetGameplayNextScreen() [ScreenMiniMenuContext] Fallback=ScreenMiniMenu NumRowsShown=4 -Row1Y=0+24*-1.5 -Row2Y=0+24*-0.5 -Row3Y=0+24*0.5 -Row4Y=0+24*1.5 +Row1Y=0+24*-1 +Row2Y=0+24*0 +Row3Y=0+24*1 ItemsLongRowSharedX=0 LabelsX=0 -LabelsX=-40 +LabelsX=-54 LabelsOnCommand=zoom,0.7;horizalign,left;ShadowLength,2 -LabelGainFocusCommand=diffuseshift +LabelGainFocusCommand=diffuseshift;EffectColor1,0.3,0.3,0.3,1;EffectColor2,1.3,1.3,1.3,1 LabelLoseFocusCommand=stopeffect ItemsStartX=0 LineHighlightX=0 @@ -4526,7 +4525,7 @@ ShowExplanations=0 NewProfileDefaultName=New [ScreenOptionsEditProfile] -Class=ScreenOptionsEditCourse +Class=ScreenOptionsEditProfile Fallback=ScreenOptionsServiceChild PrevScreen=ScreenOptionsManageProfiles NextScreen=ScreenOptionsManageProfiles diff --git a/stepmania/src/ScreenOptionsEditProfile.cpp b/stepmania/src/ScreenOptionsEditProfile.cpp index 6ed2af3e38..1724411a8d 100644 --- a/stepmania/src/ScreenOptionsEditProfile.cpp +++ b/stepmania/src/ScreenOptionsEditProfile.cpp @@ -26,6 +26,7 @@ void ScreenOptionsEditProfile::Init() { ScreenOptions::Init(); + m_Original = *GAMESTATE->GetEditLocalProfile(); vector vDefs; vector vHands; @@ -36,6 +37,7 @@ void ScreenOptionsEditProfile::Init() def.m_bAllowThemeItems = false; def.m_bAllowThemeTitles = false; def.m_bAllowExplanation = false; + def.m_bExportOnChange = true; Profile &pro = PROFILEMAN->GetLocalProfile( GAMESTATE->m_sEditLocalProfileID ); @@ -90,12 +92,10 @@ void ScreenOptionsEditProfile::ExportOptions( int iRow, const vectorSetNewScreen( "ScreenOptionsService" ); } void ScreenOptionsEditProfile::GoToPrevScreen() { - SCREENMAN->SetNewScreen( "ScreenOptionsService" ); } void ScreenOptionsEditProfile::HandleScreenMessage( const ScreenMessage SM ) @@ -104,10 +104,22 @@ void ScreenOptionsEditProfile::HandleScreenMessage( const ScreenMessage SM ) { PROFILEMAN->SaveLocalProfile( GAMESTATE->m_sEditLocalProfileID ); } + else if( SM == SM_GoToPrevScreen ) + { + *GAMESTATE->GetEditLocalProfile() = m_Original; + } ScreenOptions::HandleScreenMessage( SM ); } +void ScreenOptionsEditProfile::AfterChangeValueInRow( int iRow, PlayerNumber pn ) +{ + ScreenOptions::AfterChangeValueInRow( iRow, pn ); + + // cause the overlay to reload + GAMESTATE->m_sEditLocalProfileID.Set( GAMESTATE->m_sEditLocalProfileID ); +} + void ScreenOptionsEditProfile::ProcessMenuStart( PlayerNumber pn, const InputEventType type ) { int iRow = GetCurrentRow();; diff --git a/stepmania/src/ScreenOptionsEditProfile.h b/stepmania/src/ScreenOptionsEditProfile.h index 5ed8d7f6de..1bfa095022 100644 --- a/stepmania/src/ScreenOptionsEditProfile.h +++ b/stepmania/src/ScreenOptionsEditProfile.h @@ -2,14 +2,16 @@ #define ScreenOptionsEditProfile_H #include "ScreenOptions.h" +#include "Profile.h" class ScreenOptionsEditProfile : public ScreenOptions { public: ScreenOptionsEditProfile( CString sName ); - virtual void Init(); virtual ~ScreenOptionsEditProfile(); + virtual void Init(); + protected: private: virtual void ImportOptions( int row, const vector &vpns ); @@ -19,7 +21,10 @@ private: virtual void GoToPrevScreen(); virtual void HandleScreenMessage( const ScreenMessage SM ); + virtual void AfterChangeValueInRow( int iRow, PlayerNumber pn ); virtual void ProcessMenuStart( PlayerNumber pn, const InputEventType type ); + + Profile m_Original; // restore this on revert }; #endif diff --git a/stepmania/src/ScreenOptionsManageCourses.cpp b/stepmania/src/ScreenOptionsManageCourses.cpp index 489a2c4c7b..ce0120166f 100644 --- a/stepmania/src/ScreenOptionsManageCourses.cpp +++ b/stepmania/src/ScreenOptionsManageCourses.cpp @@ -154,12 +154,17 @@ void ScreenOptionsManageCourses::Init() OptionRowDefinition def; def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; + + int iIndex = 0; - def.m_sName = ""; - def.m_vsChoices.clear(); - def.m_vsChoices.push_back( "Create New" ); - vDefs.push_back( def ); - vHands.push_back( NULL ); + { + def.m_sName = ""; + def.m_vsChoices.clear(); + def.m_vsChoices.push_back( "Create New" ); + vDefs.push_back( def ); + vHands.push_back( NULL ); + iIndex++; + } SONGMAN->GetAllCourses( m_vpCourses, false ); @@ -198,10 +203,13 @@ void ScreenOptionsManageCourses::Init() break; } + def.m_sName = ssprintf("%d",iIndex) + " " + def.m_sName; + def.m_vsChoices.clear(); def.m_vsChoices.push_back( (*c)->GetDisplayFullTitle() ); vDefs.push_back( def ); vHands.push_back( NULL ); + iIndex++; } ScreenOptions::InitMenu( vDefs, vHands ); @@ -335,6 +343,16 @@ void ScreenOptionsManageCourses::ProcessMenuStart( PlayerNumber pn, const InputE if( iCurRow == 0 ) // "create new" { + if( SONGMAN->GetNumEditCourses(PROFILE_SLOT_MACHINE) >= MAX_EDIT_COURSES_PER_PROFILE ) + { + CString s = ssprintf( + "You have %d course edits, the maximum number allowed.\n\n" + "You must delete an existing course edit before creating a new course edit.", + MAX_EDIT_COURSES_PER_PROFILE ); + ScreenPrompt::Prompt( SM_None, s ); + return; + } + CString sDefaultName; CString sThrowAway; for( int i=1; i<=9999; i++ ) diff --git a/stepmania/src/ScreenOptionsManageProfiles.cpp b/stepmania/src/ScreenOptionsManageProfiles.cpp index 14e48b8d13..64d3413687 100644 --- a/stepmania/src/ScreenOptionsManageProfiles.cpp +++ b/stepmania/src/ScreenOptionsManageProfiles.cpp @@ -119,7 +119,6 @@ void ScreenOptionsManageProfiles::Init() int iIndex = 0; { - def.m_sName = ""; def.m_vsChoices.clear(); def.m_vsChoices.push_back( "Create New" ); vDefs.push_back( def ); @@ -137,6 +136,7 @@ void ScreenOptionsManageProfiles::Init() { Profile &profile = PROFILEMAN->GetLocalProfile( *s ); + def.m_sName = ssprintf( "%d", iIndex ); def.m_vsChoices.clear(); def.m_vsChoices.push_back( profile.m_sDisplayName ); vDefs.push_back( def ); @@ -167,6 +167,11 @@ void ScreenOptionsManageProfiles::BeginScreen() this->MoveRowAbsolute( PLAYER_1, 1 + iIndex, false ); } } + else if( !m_vsLocalProfileID.empty() ) + { + // select the first item below "create new" + this->MoveRowAbsolute( PLAYER_1, 1, false ); + } AfterChangeRow( PLAYER_1 ); } @@ -215,7 +220,16 @@ void ScreenOptionsManageProfiles::HandleScreenMessage( const ScreenMessage SM ) { if( ScreenPrompt::s_LastAnswer == ANSWER_YES ) { + // Select the profile nearest to the one that was just deleted. + int iIndex = -1; + vector::const_iterator iter = find( m_vsLocalProfileID.begin(), m_vsLocalProfileID.end(), GAMESTATE->m_sEditLocalProfileID.Get() ); + if( iter != m_vsLocalProfileID.end() ) + iIndex = iter - m_vsLocalProfileID.begin(); + CLAMP( iIndex, 0, m_vsLocalProfileID.size()-1 ); + GAMESTATE->m_sEditLocalProfileID.Set( m_vsLocalProfileID[iIndex] ); + PROFILEMAN->DeleteLocalProfile( GetLocalProfileIDWithFocus() ); + SCREENMAN->SetNewScreen( this->m_sName ); // reload } } @@ -271,6 +285,16 @@ void ScreenOptionsManageProfiles::ProcessMenuStart( PlayerNumber pn, const Input if( iCurRow == 0 ) // "create new" { + if( PROFILEMAN->GetNumLocalProfiles() >= MAX_NUM_LOCAL_PROFILES ) + { + CString s = ssprintf( + "You have %d profiles, the maximum number allowed.\n\n" + "You must delete an existing profile before creating a new profile.", + MAX_NUM_LOCAL_PROFILES ); + ScreenPrompt::Prompt( SM_None, s ); + return; + } + vector vsUsedNames; PROFILEMAN->GetLocalProfileDisplayNames( vsUsedNames ); diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index f4aec2c31c..637c82bf18 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -40,9 +40,6 @@ SongManager* SONGMAN = NULL; // global and accessable from anywhere in our progr const CString SONGS_DIR = "Songs/"; const CString COURSES_DIR = "Courses/"; -const int MAX_EDIT_STEPS_PER_PROFILE = 200; -const int MAX_EDIT_COURSES_PER_PROFILE = 20; - static const ThemeMetric BEGINNER_COLOR ("SongManager","BeginnerColor"); static const ThemeMetric EASY_COLOR ("SongManager","EasyColor"); static const ThemeMetric MEDIUM_COLOR ("SongManager","MediumColor"); @@ -486,6 +483,17 @@ int SongManager::GetNumCourseGroups() const return m_mapCourseGroupToInfo.size(); } +int SongManager::GetNumEditCourses( ProfileSlot slot ) const +{ + int iNum = 0; + FOREACH_CONST( Course*, m_pCourses, p ) + { + if( (*p)->GetLoadedFromProfileSlot() == slot ) + iNum++; + } + return iNum; +} + CString SongManager::ShortenGroupName( CString sLongGroupName ) { sLongGroupName.Replace( "Dance Dance Revolution", "DDR" ); diff --git a/stepmania/src/SongManager.h b/stepmania/src/SongManager.h index a8386b1172..15e40d977e 100644 --- a/stepmania/src/SongManager.h +++ b/stepmania/src/SongManager.h @@ -20,6 +20,9 @@ struct lua_State; #include "ThemeMetric.h" #include "RageTexturePreloader.h" +const int MAX_EDIT_STEPS_PER_PROFILE = 200; +const int MAX_EDIT_COURSES_PER_PROFILE = 20; + class SongManager { public: @@ -48,6 +51,7 @@ public: 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. void PreloadSongImages(); @@ -83,6 +87,7 @@ public: int GetNumSongGroups() const; int GetNumCourses() const; int GetNumCourseGroups() const; + int GetNumEditCourses( ProfileSlot slot ) const; Song* GetRandomSong(); Course* GetRandomCourse();