Add new ScreenOptionsManageProfiles

This commit is contained in:
Chris Danford
2005-08-04 21:13:29 +00:00
parent 7bd90e4f1a
commit 68f8e632f0
17 changed files with 416 additions and 561 deletions
+4 -7
View File
@@ -106,9 +106,8 @@ void Banner::LoadFromCourse( Course* pCourse ) // NULL means no course
void Banner::LoadCardFromCharacter( Character* pCharacter )
{
ASSERT( pCharacter );
if( pCharacter->GetCardPath() != "" ) Load( pCharacter->GetCardPath() );
if( pCharacter == NULL ) LoadFallback();
else if( pCharacter->GetCardPath() != "" ) Load( pCharacter->GetCardPath() );
else LoadFallback();
m_bScrolling = false;
@@ -116,10 +115,8 @@ void Banner::LoadCardFromCharacter( Character* pCharacter )
void Banner::LoadIconFromCharacter( Character* pCharacter )
{
ASSERT( pCharacter );
if( pCharacter->GetIconPath() != "" ) Load( pCharacter->GetIconPath() );
else if( pCharacter->GetCardPath() != "" ) Load( pCharacter->GetCardPath() );
if( pCharacter == NULL ) LoadFallback();
else if( pCharacter->GetIconPath() != "" ) Load( pCharacter->GetIconPath() );
else LoadFallback();
m_bScrolling = false;
+1 -1
View File
@@ -18,7 +18,7 @@ class Steps;
class Profile;
struct lua_State;
const int MAX_EDIT_COURSE_TITLE_LENGTH = 20;
const int MAX_EDIT_COURSE_TITLE_LENGTH = 12;
enum CourseType
{
+20 -5
View File
@@ -79,7 +79,8 @@ GameState::GameState() :
m_stEdit( MESSAGE_EDIT_STEPS_TYPE_CHANGED ),
m_pEditSourceSteps( MESSAGE_EDIT_SOURCE_STEPS_CHANGED ),
m_stEditSource( MESSAGE_EDIT_SOURCE_STEPS_TYPE_CHANGED ),
m_iEditCourseEntryIndex(MESSAGE_EDIT_COURSE_ENTRY_INDEX_CHANGED )
m_iEditCourseEntryIndex(MESSAGE_EDIT_COURSE_ENTRY_INDEX_CHANGED ),
m_sEditLocalProfileID( Message_EditLocalProfileIDChanged )
{
m_pCurStyle.Set( NULL );
@@ -258,11 +259,10 @@ void GameState::Reset()
m_pEditSourceSteps.Set( NULL );
m_stEditSource.Set( STEPS_TYPE_INVALID );
m_iEditCourseEntryIndex.Set( -1 );
m_sEditLocalProfileID.Set( "" );
m_bBackedOutOfFinalStage = false;
m_sLastSelectedProfileID = "";
ApplyCmdline();
}
@@ -1872,6 +1872,13 @@ bool GameState::PlayerIsUsingModifier( PlayerNumber pn, const CString &sModifier
return po == GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions && so == GAMESTATE->m_SongOptions;
}
Profile* GameState::GetEditLocalProfile()
{
if( m_sEditLocalProfileID.Get().empty() )
return NULL;
return &PROFILEMAN->GetLocalProfile( m_sEditLocalProfileID );
}
void GameState::ResetOriginalSyncData()
{
if( m_pCurSong )
@@ -2038,8 +2045,16 @@ public:
lua_pushboolean(L, p->GetStageResult(pn)==RESULT_WIN); return 1;
}
static int GetCurrentGame( T* p, lua_State *L ) { const_cast<Game*>(p->GetCurrentGame())->PushSelf( L ); return 1; }
static int GetLastSelectedProfileID( T* p, lua_State *L ) { lua_pushstring(L, p->m_sLastSelectedProfileID ); return 1; }
static int GetEditCourseEntryIndex( T* p, lua_State *L ) { lua_pushnumber(L, p->m_iEditCourseEntryIndex ); return 1; }
static int GetEditLocalProfile( T* p, lua_State *L )
{
Profile *pProfile = p->GetEditLocalProfile();
if( pProfile )
pProfile->PushSelf(L);
else
lua_pushnil( L );
return 1;
}
static void Register(lua_State *L)
{
@@ -2093,8 +2108,8 @@ public:
ADD_METHOD( IsSyncDataChanged )
ADD_METHOD( IsWinner )
ADD_METHOD( GetCurrentGame )
ADD_METHOD( GetLastSelectedProfileID )
ADD_METHOD( GetEditCourseEntryIndex )
ADD_METHOD( GetEditLocalProfile )
Luna<T>::Register( L );
+3 -3
View File
@@ -28,6 +28,7 @@ struct StageStats;
struct PlayerState;
struct lua_State;
class LuaTable;
class Profile;
class GameState
{
@@ -300,6 +301,8 @@ public:
BroadcastOnChangePtr<Steps> m_pEditSourceSteps;
BroadcastOnChange<StepsType> m_stEditSource;
BroadcastOnChange<int> m_iEditCourseEntryIndex;
BroadcastOnChange<CString> m_sEditLocalProfileID;
Profile* GetEditLocalProfile();
// Workout stuff
float GetGoalPercentComplete( PlayerNumber pn );
@@ -313,9 +316,6 @@ public:
void SaveSyncChanges();
void RevertSyncChanges();
// profile stuff
CString m_sLastSelectedProfileID;
// Lua
void PushSelf( lua_State *L );
};
+1 -2
View File
@@ -44,9 +44,9 @@ ScreenOptionsEditCourse.cpp ScreenOptionsEditCourse.h \
ScreenOptionsEditCourseEntry.cpp ScreenOptionsEditCourseEntry.h \
ScreenOptionsEditProfile.cpp ScreenOptionsEditProfile.h \
ScreenOptionsManageCourses.cpp ScreenOptionsManageCourses.h \
ScreenOptionsManageProfiles.cpp ScreenOptionsManageProfiles.h \
ScreenOptionsMaster.cpp ScreenOptionsMaster.h \
ScreenOptionsMasterPrefs.cpp ScreenOptionsMasterPrefs.h ScreenPackages.cpp ScreenPackages.h \
ScreenOptionsSelectProfile.cpp ScreenOptionsSelectProfile.h \
ScreenPlayerOptions.cpp ScreenPlayerOptions.h \
ScreenNetworkOptions.h ScreenNetworkOptions.cpp \
ScreenPrompt.cpp ScreenPrompt.h ScreenRanking.cpp ScreenRanking.h \
@@ -57,7 +57,6 @@ ScreenSelect.cpp ScreenSelect.h ScreenSelectCharacter.cpp ScreenSelectCharacter.
ScreenSelectDifficulty.cpp ScreenSelectDifficulty.h ScreenSelectGroup.cpp ScreenSelectGroup.h \
ScreenSelectMaster.cpp ScreenSelectMaster.h ScreenSelectMode.cpp ScreenSelectMode.h \
ScreenSelectMusic.cpp ScreenSelectMusic.h \
ScreenSelectProfile.cpp ScreenSelectProfile.h \
ScreenSelectStyle.cpp ScreenSelectStyle.h \
ScreenSyncOverlay.cpp ScreenSyncOverlay.h \
ScreenSystemLayer.cpp ScreenSystemLayer.h ScreenSetTime.cpp ScreenSetTime.h \
+1
View File
@@ -28,6 +28,7 @@ static const CString MessageNames[] = {
"EditPreferredCourseDifficutyP1Changed",
"EditPreferredCourseDifficutyP2Changed",
"EditCourseEntryIndexChanged",
"EditLocalProfileIDChanged",
"GoalCompleteP1",
"GoalCompleteP2",
"NoteCrossed",
+1
View File
@@ -45,6 +45,7 @@ enum Message
MESSAGE_EDIT_PREFERRED_COURSE_DIFFICULTY_P1_CHANGED,
MESSAGE_EDIT_PREFERRED_COURSE_DIFFICULTY_P2_CHANGED,
MESSAGE_EDIT_COURSE_ENTRY_INDEX_CHANGED,
Message_EditLocalProfileIDChanged,
MESSAGE_GOAL_COMPLETE_P1,
MESSAGE_GOAL_COMPLETE_P2,
MESSAGE_NOTE_CROSSED,
-43
View File
@@ -31,8 +31,6 @@ ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our
#define MACHINE_PROFILE_DIR "Data/MachineProfile/"
const CString LAST_GOOD_DIR = "LastGood/";
static ThemeMetric<CString> NEW_PROFILE_DEFAULT_NAME( "ProfileManager", "NewProfileDefaultName" );
// Directories to search for a profile if m_sMemoryCardProfileSubdir doesn't
// exist, separated by ";":
@@ -659,22 +657,6 @@ bool ProfileManager::IsPersistentProfile( ProfileSlot slot ) const
}
}
CString ProfileManager::GetNewLocalProfileDefaultName() const
{
vector<CString> vsUsedNames;
PROFILEMAN->GetLocalProfileDisplayNames( vsUsedNames );
CString sPotentialName;
for( int i=1; i<1000; i++ )
{
sPotentialName = ssprintf( "%s%04d", NEW_PROFILE_DEFAULT_NAME.GetValue().c_str(), i );
bool bNameIsUsed = find( vsUsedNames.begin(), vsUsedNames.end(), sPotentialName ) != vsUsedNames.end();
if( !bNameIsUsed )
return sPotentialName;
}
return sPotentialName;
}
void ProfileManager::GetLocalProfileIDs( vector<CString> &vsProfileIDsOut ) const
{
vsProfileIDsOut.clear();
@@ -689,31 +671,6 @@ void ProfileManager::GetLocalProfileDisplayNames( vector<CString> &vsProfileDisp
vsProfileDisplayNamesOut.push_back( iter->second->m_sDisplayName );
}
bool ProfileManager::ValidateLocalProfileName( const CString &sAnswer, CString &sErrorOut )
{
CString sCurrentProfileOldName = PROFILEMAN->GetLocalProfile( GAMESTATE->m_sLastSelectedProfileID ).m_sDisplayName;
vector<CString> vsProfileNames;
PROFILEMAN->GetLocalProfileDisplayNames( vsProfileNames );
bool bAlreadyAProfileWithThisName = find( vsProfileNames.begin(), vsProfileNames.end(), sAnswer ) != vsProfileNames.end();
if( sAnswer == "" )
{
sErrorOut = "Profile name cannot be blank.";
return false;
}
else if( sAnswer == sCurrentProfileOldName )
{
return true;
}
else if( bAlreadyAProfileWithThisName )
{
sErrorOut = "There is already another profile with this name. Please choose a different name.";
return false;
}
return true;
}
// lua start
#include "LuaBinding.h"
-5
View File
@@ -33,7 +33,6 @@ public:
bool CreateLocalProfile( CString sName, CString &sProfileIDOut );
bool RenameLocalProfile( CString sProfileID, CString sNewName );
bool DeleteLocalProfile( CString sProfileID );
CString GetNewLocalProfileDefaultName() const;
void GetLocalProfileIDs( vector<CString> &vsProfileIDsOut ) const;
void GetLocalProfileDisplayNames( vector<CString> &vsProfileDisplayNamesOut ) const;
@@ -104,10 +103,6 @@ public:
// Lua
void PushSelf( lua_State *L );
static bool ValidateLocalProfileName( const CString &sAnswer, CString &sErrorOut );
private:
// returns Profile::LoadResult, but we don't want to depend on Profile
int LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIsMemCard );
+3 -66
View File
@@ -10,14 +10,9 @@
#include "Profile.h"
#include "Character.h"
AutoScreenMessage( SM_BackFromEnterName )
AutoScreenMessage( SM_BackFromDelete )
enum EditProfileRow
{
ROW_NAME,
ROW_CHARACTER,
ROW_DELETE
};
REGISTER_SCREEN_CLASS( ScreenOptionsEditProfile );
@@ -42,16 +37,7 @@ void ScreenOptionsEditProfile::Init()
def.m_bAllowThemeTitles = false;
def.m_bAllowExplanation = false;
Profile &pro = PROFILEMAN->GetLocalProfile( GAMESTATE->m_sLastSelectedProfileID );
{
def.m_sName = "Name";
def.m_vsChoices.clear();
CString s = pro.m_sDisplayName;
def.m_vsChoices.push_back( s );
vDefs.push_back( def );
vHands.push_back( NULL );
}
Profile &pro = PROFILEMAN->GetLocalProfile( GAMESTATE->m_sEditLocalProfileID );
{
def.m_sName = "Character";
@@ -64,13 +50,6 @@ void ScreenOptionsEditProfile::Init()
vHands.push_back( NULL );
}
{
def.m_sName = "Delete";
def.m_vsChoices.clear();
vDefs.push_back( def );
vHands.push_back( NULL );
}
InitMenu( vDefs, vHands );
}
@@ -81,7 +60,7 @@ ScreenOptionsEditProfile::~ScreenOptionsEditProfile()
void ScreenOptionsEditProfile::ImportOptions( int iRow, const vector<PlayerNumber> &vpns )
{
Profile &pro = PROFILEMAN->GetLocalProfile( GAMESTATE->m_sLastSelectedProfileID );
Profile &pro = PROFILEMAN->GetLocalProfile( GAMESTATE->m_sEditLocalProfileID );
OptionRow &row = *m_pRows[iRow];
switch( iRow )
@@ -94,7 +73,7 @@ void ScreenOptionsEditProfile::ImportOptions( int iRow, const vector<PlayerNumbe
void ScreenOptionsEditProfile::ExportOptions( int iRow, const vector<PlayerNumber> &vpns )
{
Profile &pro = PROFILEMAN->GetLocalProfile( GAMESTATE->m_sLastSelectedProfileID );
Profile &pro = PROFILEMAN->GetLocalProfile( GAMESTATE->m_sEditLocalProfileID );
OptionRow &row = *m_pRows[iRow];
int iIndex = row.GetOneSharedSelection( true );
CString sValue;
@@ -103,9 +82,6 @@ void ScreenOptionsEditProfile::ExportOptions( int iRow, const vector<PlayerNumbe
switch( iRow )
{
case ROW_NAME:
pro.m_sDisplayName = sValue;
break;
case ROW_CHARACTER:
pro.m_sCharacter = sValue;
break;
@@ -124,32 +100,6 @@ void ScreenOptionsEditProfile::GoToPrevScreen()
void ScreenOptionsEditProfile::HandleScreenMessage( const ScreenMessage SM )
{
if( SM == SM_BackFromEnterName )
{
if( !ScreenTextEntry::s_bCancelledLast )
{
ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this
CString sNewName = ScreenTextEntry::s_sLastAnswer;
ASSERT( !GAMESTATE->m_sLastSelectedProfileID.empty() )
// rename
bool bResult = PROFILEMAN->RenameLocalProfile( GAMESTATE->m_sLastSelectedProfileID, sNewName );
if( bResult )
SCREENMAN->SetNewScreen( m_sName ); // reload
else
ScreenPrompt::Prompt( SM_None, ssprintf("Error renaming profile '%s'.", sNewName.c_str()) );
}
}
else if( SM == SM_BackFromDelete )
{
if( ScreenPrompt::s_LastAnswer == ANSWER_YES )
{
PROFILEMAN->DeleteLocalProfile( GAMESTATE->m_sLastSelectedProfileID );
HandleScreenMessage( SM_GoToPrevScreen );
}
}
ScreenOptions::HandleScreenMessage( SM );
}
@@ -160,23 +110,10 @@ void ScreenOptionsEditProfile::ProcessMenuStart( PlayerNumber pn, const InputEve
switch( iRow )
{
case ROW_NAME:
{
CString sCurrentProfileName = PROFILEMAN->GetLocalProfile( GAMESTATE->m_sLastSelectedProfileID ).m_sDisplayName;
ScreenTextEntry::TextEntry( SM_BackFromEnterName, "Enter a name for a new profile.", sCurrentProfileName, PROFILE_MAX_DISPLAY_NAME_LENGTH, ProfileManager::ValidateLocalProfileName );
}
break;
case ROW_CHARACTER:
{
}
break;
case ROW_DELETE:
{
CString sCurrentProfileName = PROFILEMAN->GetLocalProfile( GAMESTATE->m_sLastSelectedProfileID ).m_sDisplayName;
CString sMessage = ssprintf( "Are you sure you want to delete the profile '%s'?", sCurrentProfileName.c_str() );
ScreenPrompt::Prompt( SM_BackFromDelete, sMessage, PROMPT_YES_NO );
}
break;
default:
ScreenOptions::ProcessMenuStart( pn, type );
break;
@@ -243,7 +243,6 @@ void ScreenOptionsManageCourses::HandleScreenMessage( const ScreenMessage SM )
ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this
CString sNewName = ScreenTextEntry::s_sLastAnswer;
ASSERT( GAMESTATE->m_sLastSelectedProfileID.empty() );
// create
Course *pCourse = new Course;
@@ -0,0 +1,357 @@
#include "global.h"
#include "ScreenOptionsManageProfiles.h"
#include "ScreenManager.h"
#include "RageLog.h"
#include "GameState.h"
#include "CommonMetrics.h"
#include "ScreenTextEntry.h"
#include "ScreenPrompt.h"
#include "ScreenMiniMenu.h"
#include "ProfileManager.h"
#include "Profile.h"
#include "OptionRowHandler.h"
static ThemeMetric<CString> NEW_PROFILE_DEFAULT_NAME( "ScreenOptionsManageProfiles", "NewProfileDefaultName" );
AutoScreenMessage( SM_BackFromEnterNameForNew )
AutoScreenMessage( SM_BackFromRename )
AutoScreenMessage( SM_BackFromDeleteConfirm )
AutoScreenMessage( SM_BackFromContextMenu )
enum ProfileAction
{
ProfileAction_Edit,
ProfileAction_Rename,
ProfileAction_Delete,
NUM_ProfileAction
};
static const CString ProfileActionNames[] = {
"Edit",
"Rename",
"Delete",
};
XToString( ProfileAction, NUM_ProfileAction );
#define FOREACH_ProfileAction( i ) FOREACH_ENUM( ProfileAction, NUM_ProfileAction, i )
static MenuDef g_TempMenu(
"ScreenMiniMenuContext"
);
static bool ValidateLocalProfileName( const CString &sAnswer, CString &sErrorOut )
{
CString sCurrentProfileOldName = PROFILEMAN->GetLocalProfile( GAMESTATE->m_sEditLocalProfileID ).m_sDisplayName;
vector<CString> vsProfileNames;
PROFILEMAN->GetLocalProfileDisplayNames( vsProfileNames );
bool bAlreadyAProfileWithThisName = find( vsProfileNames.begin(), vsProfileNames.end(), sAnswer ) != vsProfileNames.end();
if( sAnswer == "" )
{
sErrorOut = "Profile name cannot be blank.";
return false;
}
else if( sAnswer == sCurrentProfileOldName )
{
return true;
}
else if( bAlreadyAProfileWithThisName )
{
sErrorOut = "There is already another profile with this name. Please choose a different name.";
return false;
}
return true;
}
class OptionRowHandlerSimple : public OptionRowHandler
{
public:
GameCommand m_gc;
virtual void Load( OptionRowDefinition &defOut, CString sParam )
{
}
virtual void ImportOption( const OptionRowDefinition &row, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const
{
}
virtual int ExportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, const vector<bool> vbSelected[NUM_PLAYERS] ) const
{
if( vbSelected[PLAYER_1][0] )
m_gc.ApplyToAllPlayers();
return 0;
}
virtual void GetIconTextAndGameCommand( const OptionRowDefinition &def, int iFirstSelection, CString &sIconTextOut, GameCommand &gcOut ) const
{
sIconTextOut = "";
gcOut = m_gc;
}
};
REGISTER_SCREEN_CLASS( ScreenOptionsManageProfiles );
ScreenOptionsManageProfiles::ScreenOptionsManageProfiles( CString sName ) : ScreenOptions( sName )
{
LOG->Trace( "ScreenOptionsManageProfiles::ScreenOptionsManageProfiles()" );
}
ScreenOptionsManageProfiles::~ScreenOptionsManageProfiles()
{
FOREACH( OptionRow*, m_pRows, r )
(*r)->DetachHandler();
FOREACH( OptionRowHandler*, m_OptionRowHandlers, h )
SAFE_DELETE( *h );
m_OptionRowHandlers.clear();
}
void ScreenOptionsManageProfiles::Init()
{
ScreenOptions::Init();
vector<OptionRowDefinition> vDefs;
OptionRowDefinition def;
def.m_layoutType = LAYOUT_SHOW_ALL_IN_ROW;
def.m_bAllowThemeTitles = false;
def.m_bAllowThemeItems = false;
int iIndex = 0;
{
def.m_sName = "";
def.m_vsChoices.clear();
def.m_vsChoices.push_back( "Create New" );
vDefs.push_back( def );
OptionRowHandlerSimple *pHand = new OptionRowHandlerSimple;
m_OptionRowHandlers.push_back( pHand );
GameCommand &gc = pHand->m_gc;
CString sCommand = "screen,ScreenOptionsEditProfile";
gc.Load( iIndex++, ParseCommands(sCommand) );
}
PROFILEMAN->GetLocalProfileIDs( m_vsLocalProfileID );
FOREACH_CONST( CString, m_vsLocalProfileID, s )
{
Profile &profile = PROFILEMAN->GetLocalProfile( *s );
def.m_vsChoices.clear();
def.m_vsChoices.push_back( profile.m_sDisplayName );
vDefs.push_back( def );
OptionRowHandlerSimple *pHand = new OptionRowHandlerSimple;
m_OptionRowHandlers.push_back( pHand );
GameCommand &gc = pHand->m_gc;
CString sCommand = "screen,ScreenOptionsEditProfile";
gc.Load( iIndex++, ParseCommands(sCommand) );
}
ScreenOptions::InitMenu( vDefs, m_OptionRowHandlers );
SetInputMode( INPUTMODE_SHARE_CURSOR );
}
void ScreenOptionsManageProfiles::BeginScreen()
{
ScreenOptions::BeginScreen();
// select the last chosen profile
if( !GAMESTATE->m_sEditLocalProfileID.Get().empty() )
{
vector<CString>::const_iterator iter = find( m_vsLocalProfileID.begin(), m_vsLocalProfileID.end(), GAMESTATE->m_sEditLocalProfileID.Get() );
if( iter != m_vsLocalProfileID.end() )
{
int iIndex = iter - m_vsLocalProfileID.begin();
this->MoveRowAbsolute( PLAYER_1, 1 + iIndex, false );
}
}
AfterChangeRow( PLAYER_1 );
}
void ScreenOptionsManageProfiles::HandleScreenMessage( const ScreenMessage SM )
{
if( SM == SM_GoToNextScreen )
{
int iCurRow = m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber];
if( iCurRow == (int)m_pRows.size() - 1 )
{
this->HandleScreenMessage( SM_GoToPrevScreen );
return; // don't call base
}
}
else if( SM == SM_BackFromEnterNameForNew )
{
if( !ScreenTextEntry::s_bCancelledLast )
{
ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this
CString sNewName = ScreenTextEntry::s_sLastAnswer;
ASSERT( GAMESTATE->m_sEditLocalProfileID.Get().empty() );
// create
CString sProfileID;
PROFILEMAN->CreateLocalProfile( ScreenTextEntry::s_sLastAnswer, sProfileID );
GAMESTATE->m_sEditLocalProfileID.Set( sProfileID );
this->HandleScreenMessage( SM_GoToNextScreen );
}
}
else if( SM == SM_BackFromRename )
{
if( !ScreenTextEntry::s_bCancelledLast )
{
ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this
Profile &profile = PROFILEMAN->GetLocalProfile( GAMESTATE->m_sEditLocalProfileID );
profile.m_sDisplayName = ScreenTextEntry::s_sLastAnswer;
SCREENMAN->SetNewScreen( this->m_sName ); // reload
}
}
else if( SM == SM_BackFromDeleteConfirm )
{
if( ScreenPrompt::s_LastAnswer == ANSWER_YES )
{
PROFILEMAN->DeleteLocalProfile( GetLocalProfileIDWithFocus() );
SCREENMAN->SetNewScreen( this->m_sName ); // reload
}
}
else if( SM == SM_BackFromContextMenu )
{
if( !ScreenMiniMenu::s_bCancelled )
{
switch( ScreenMiniMenu::s_iLastRowCode )
{
case ProfileAction_Edit:
{
GAMESTATE->m_sEditLocalProfileID.Set( GetLocalProfileIDWithFocus() );
ScreenOptions::BeginFadingOut();
}
break;
case ProfileAction_Rename:
{
Profile &profile = PROFILEMAN->GetLocalProfile( GAMESTATE->m_sEditLocalProfileID );
ScreenTextEntry::TextEntry(
SM_BackFromRename,
"Enter a name for the profile.",
profile.m_sDisplayName,
PROFILE_MAX_DISPLAY_NAME_LENGTH,
ValidateLocalProfileName );
}
break;
case ProfileAction_Delete:
{
Profile &profile = PROFILEMAN->GetLocalProfile( GetLocalProfileIDWithFocus() );
CString sTitle = profile.m_sDisplayName;
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 ScreenOptionsManageProfiles::AfterChangeRow( PlayerNumber pn )
{
GAMESTATE->m_sEditLocalProfileID.Set( GetLocalProfileIDWithFocus() );
ScreenOptions::AfterChangeRow( pn );
}
void ScreenOptionsManageProfiles::ProcessMenuStart( PlayerNumber pn, const InputEventType type )
{
int iCurRow = m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber];
if( iCurRow == 0 ) // "create new"
{
vector<CString> vsUsedNames;
PROFILEMAN->GetLocalProfileDisplayNames( vsUsedNames );
CString sPotentialName;
for( int i=1; i<1000; i++ )
{
sPotentialName = ssprintf( "%s%04d", NEW_PROFILE_DEFAULT_NAME.GetValue().c_str(), i );
bool bNameIsUsed = find( vsUsedNames.begin(), vsUsedNames.end(), sPotentialName ) != vsUsedNames.end();
if( !bNameIsUsed )
break;
}
ScreenTextEntry::TextEntry(
SM_BackFromEnterNameForNew,
"Enter a name for a new course.",
sPotentialName,
PROFILE_MAX_DISPLAY_NAME_LENGTH,
ValidateLocalProfileName );
}
else if( iCurRow == (int)m_pRows.size()-1 ) // "done"
{
this->BeginFadingOut();
}
else // a course
{
g_TempMenu.rows.clear();
FOREACH_ProfileAction( i )
{
MenuRowDef mrd( i, ProfileActionToString(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, (float)iX, (float)iY );
}
}
void ScreenOptionsManageProfiles::ImportOptions( int iRow, const vector<PlayerNumber> &vpns )
{
}
void ScreenOptionsManageProfiles::ExportOptions( int iRow, const vector<PlayerNumber> &vpns )
{
}
CString ScreenOptionsManageProfiles::GetLocalProfileIDWithFocus() const
{
int iCurRow = m_iCurrentRow[GAMESTATE->m_MasterPlayerNumber];
if( iCurRow == 0 )
return NULL;
else if( iCurRow == (int)m_pRows.size()-1 ) // "done"
return NULL;
// a profile
int iIndex = iCurRow - 1;
return m_vsLocalProfileID[iIndex];
}
/*
* (c) 2002-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
@@ -1,26 +1,32 @@
#ifndef ScreenOptionsSelectProfile_H
#define ScreenOptionsSelectProfile_H
#ifndef ScreenOptionsManageProfiles_H
#define ScreenOptionsManageProfiles_H
#include "ScreenOptions.h"
class ScreenOptionsSelectProfile : public ScreenOptions
class Course;
class ScreenOptionsManageProfiles : public ScreenOptions
{
public:
ScreenOptionsSelectProfile( CString sName );
virtual void Init();
virtual ~ScreenOptionsSelectProfile();
ScreenOptionsManageProfiles( CString sName );
~ScreenOptionsManageProfiles();
void Init();
virtual void BeginScreen();
virtual void HandleScreenMessage( const ScreenMessage SM );
protected:
private:
virtual void ImportOptions( int row, const vector<PlayerNumber> &vpns );
virtual void ExportOptions( int row, const vector<PlayerNumber> &vpns );
virtual void GoToNextScreen();
virtual void GoToPrevScreen();
virtual void ImportOptions( int iRow, const vector<PlayerNumber> &vpns );
virtual void ExportOptions( int iRow, const vector<PlayerNumber> &vpns );
virtual void HandleScreenMessage( const ScreenMessage SM );
virtual void AfterChangeRow( PlayerNumber pn );
virtual void ProcessMenuStart( PlayerNumber pn, const InputEventType type );
CString GetLocalProfileIDWithFocus() const;
vector<CString> m_vsLocalProfileID;
vector<OptionRowHandler*> m_OptionRowHandlers;
};
@@ -1,223 +0,0 @@
#include "global.h"
#include "ScreenOptionsSelectProfile.h"
#include "ProfileManager.h"
#include "ScreenTextEntry.h"
#include "ScreenPrompt.h"
#include "RageUtil.h"
#include "GameState.h"
#include "Profile.h"
#include "Character.h"
#include "OptionRowHandler.h"
#include "ScreenManager.h"
AutoScreenMessage( SM_BackFromEnterName )
AutoScreenMessage( SM_BackFromDelete )
class OptionRowHandlerSimple : public OptionRowHandler
{
public:
GameCommand m_gc;
virtual void Load( OptionRowDefinition &defOut, CString sParam )
{
}
virtual void ImportOption( const OptionRowDefinition &row, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const
{
}
virtual int ExportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, const vector<bool> vbSelected[NUM_PLAYERS] ) const
{
if( vbSelected[PLAYER_1][0] )
m_gc.ApplyToAllPlayers();
return 0;
}
virtual void GetIconTextAndGameCommand( const OptionRowDefinition &def, int iFirstSelection, CString &sIconTextOut, GameCommand &gcOut ) const
{
sIconTextOut = "";
gcOut = m_gc;
}
};
REGISTER_SCREEN_CLASS( ScreenOptionsSelectProfile );
ScreenOptionsSelectProfile::ScreenOptionsSelectProfile( CString sName ) :
ScreenOptions( sName )
{
}
void ScreenOptionsSelectProfile::Init()
{
ScreenOptions::Init();
vector<OptionRowDefinition> vDefs;
OptionRowDefinition def;
def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW;
def.m_selectType = SELECT_NONE;
def.m_bOneChoiceForAllPlayers = true;
def.m_bAllowThemeItems = false;
def.m_bAllowThemeTitles = false;
def.m_bAllowExplanation = false;
int iIndex = 0;
int iRowToSelect = -1;
{
def.m_sName = "";
def.m_vsChoices.clear();
def.m_vsChoices.push_back( "Create New" );
vDefs.push_back( def );
OptionRowHandlerSimple *pHand = new OptionRowHandlerSimple;
m_OptionRowHandlers.push_back( pHand );
GameCommand &gc = pHand->m_gc;
CString sCommand = "screen,ScreenOptionsEditProfile";
gc.Load( iIndex++, ParseCommands(sCommand) );
}
vector<CString> vsProfileID;
PROFILEMAN->GetLocalProfileIDs( vsProfileID );
FOREACH_CONST( CString, vsProfileID, s )
{
if( *s == GAMESTATE->m_sLastSelectedProfileID )
iRowToSelect = iIndex;
Profile &pro = PROFILEMAN->GetLocalProfile( *s );
def.m_sName = "";
def.m_vsChoices.clear();
def.m_vsChoices.push_back( pro.m_sDisplayName );
vDefs.push_back( def );
OptionRowHandlerSimple *pHand = new OptionRowHandlerSimple;
m_OptionRowHandlers.push_back( pHand );
GameCommand &gc = pHand->m_gc;
CString sCommand = "profileid," + *s;
gc.Load( iIndex++, ParseCommands(sCommand) );
}
InitMenu( vDefs, m_OptionRowHandlers );
if( iRowToSelect != -1 )
MoveRowAbsolute( PLAYER_1, iRowToSelect, false );
GAMESTATE->m_sLastSelectedProfileID = "";
}
ScreenOptionsSelectProfile::~ScreenOptionsSelectProfile()
{
FOREACH( OptionRow*, m_pRows, r )
(*r)->DetachHandler();
FOREACH( OptionRowHandler*, m_OptionRowHandlers, h )
SAFE_DELETE( *h );
m_OptionRowHandlers.clear();
}
void ScreenOptionsSelectProfile::ImportOptions( int iRow, const vector<PlayerNumber> &vpns )
{
OptionRow &row = *m_pRows[iRow];
}
void ScreenOptionsSelectProfile::ExportOptions( int iRow, const vector<PlayerNumber> &vpns )
{
int iCurRow = m_iCurrentRow[0];
if( iRow == iCurRow )
{
OptionRow &row = *m_pRows[iRow];
bool bRowHasFocus[NUM_PLAYERS];
ZERO( bRowHasFocus );
row.ExportOptions( vpns, bRowHasFocus );
}
}
void ScreenOptionsSelectProfile::GoToNextScreen()
{
SCREENMAN->SetNewScreen( "ScreenOptionsService" );
}
void ScreenOptionsSelectProfile::GoToPrevScreen()
{
SCREENMAN->SetNewScreen( "ScreenOptionsService" );
}
void ScreenOptionsSelectProfile::HandleScreenMessage( const ScreenMessage SM )
{
if( SM == SM_BackFromEnterName )
{
if( !ScreenTextEntry::s_bCancelledLast )
{
ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this
CString sNewName = ScreenTextEntry::s_sLastAnswer;
ASSERT( GAMESTATE->m_sLastSelectedProfileID.empty() )
// create
bool bResult = PROFILEMAN->CreateLocalProfile( sNewName, GAMESTATE->m_sLastSelectedProfileID );
if( bResult )
SCREENMAN->SetNewScreen( "ScreenOptionsEditProfile" );
else
ScreenPrompt::Prompt( SM_None, ssprintf("Error creating profile '%s'.", sNewName.c_str()) );
}
}
ScreenOptions::HandleScreenMessage( SM );
}
void ScreenOptionsSelectProfile::ProcessMenuStart( PlayerNumber pn, const InputEventType type )
{
int iRow = GetCurrentRow();;
OptionRow &row = *m_pRows[iRow];
if( iRow == 0 )
{
vector<CString> vProfileIDs;
PROFILEMAN->GetLocalProfileIDs( vProfileIDs );
if( vProfileIDs.size() >= MAX_NUM_LOCAL_PROFILES )
{
CString sError = ssprintf( "You may only create up to %d profiles. You must delete an existing profile before creating a new one.", MAX_NUM_LOCAL_PROFILES );
ScreenPrompt::Prompt( SM_None, sError );
}
else
{
ScreenTextEntry::TextEntry( SM_BackFromEnterName, "Enter a name for a new profile.", PROFILEMAN->GetNewLocalProfileDefaultName(), PROFILE_MAX_DISPLAY_NAME_LENGTH, ProfileManager::ValidateLocalProfileName );
}
}
else if( row.GetRowType() == OptionRow::ROW_EXIT )
{
ScreenOptions::ProcessMenuStart( pn, type );
}
else
{
// a profile row
ScreenOptions::BeginFadingOut();
}
}
/*
* (c) 2003-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-141
View File
@@ -1,141 +0,0 @@
#include "global.h"
#include "ScreenSelectProfile.h"
#include "ProfileManager.h"
#include "ScreenTextEntry.h"
#include "ScreenPrompt.h"
#include "ScreenManager.h"
#include "RageUtil.h"
#include "GameState.h"
#include "Profile.h"
AutoScreenMessage( SM_BackFromEnterName )
AutoScreenMessage( SM_BackFromDelete )
REGISTER_SCREEN_CLASS( ScreenSelectProfile );
ScreenSelectProfile::ScreenSelectProfile( CString sName ) :
ScreenSelectMaster( sName ),
NEXT_SCREEN( sName, "NextScreen" )
{
}
void ScreenSelectProfile::Init()
{
// Fill m_aGameCommands overriding whatever is in metrics
GameCommand gc;
int iIndex = 0;
m_aGameCommands.clear();
gc.Load( iIndex++, ParseCommands("name,Create") );
m_aGameCommands.push_back( gc );
vector<CString> vsProfileID;
PROFILEMAN->GetLocalProfileIDs( vsProfileID );
FOREACH_CONST( CString, vsProfileID, s )
{
CString sCommand = ssprintf( "name,Profile;profileid,%s;screen,%s", s->c_str(), NEXT_SCREEN.GetValue().c_str() );
gc.Load( iIndex++, ParseCommands(sCommand) );
m_aGameCommands.push_back( gc );
}
gc.Load( iIndex++, ParseCommands("name,Exit") );
m_aGameCommands.push_back( gc );
ScreenSelectMaster::Init();
}
ScreenSelectProfile::~ScreenSelectProfile()
{
}
bool ScreenSelectProfile::ProcessMenuStart( PlayerNumber pn )
{
int iChoice = m_iChoice[GetSharedPlayer()];
if( iChoice == 0 ) // "create"
{
vector<CString> vProfileIDs;
PROFILEMAN->GetLocalProfileIDs( vProfileIDs );
if( (int) vProfileIDs.size() >= MAX_NUM_LOCAL_PROFILES )
{
CString sError = ssprintf( "You may only create up to %d profiles. You must delete an existing profile before creating a new one.", MAX_NUM_LOCAL_PROFILES );
ScreenPrompt::Prompt( SM_None, sError );
}
else
{
ScreenTextEntry::TextEntry( SM_BackFromEnterName, "Enter a name for a new profile.", PROFILEMAN->GetNewLocalProfileDefaultName(), PROFILE_MAX_DISPLAY_NAME_LENGTH, ProfileManager::ValidateLocalProfileName );
}
return false;
}
return true;
}
void ScreenSelectProfile::HandleScreenMessage( const ScreenMessage SM )
{
if( SM == SM_BackFromEnterName )
{
if( !ScreenTextEntry::s_bCancelledLast )
{
ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this
CString sNewName = ScreenTextEntry::s_sLastAnswer;
ASSERT( GAMESTATE->m_sLastSelectedProfileID.empty() )
// create
bool bResult = PROFILEMAN->CreateLocalProfile( sNewName, GAMESTATE->m_sLastSelectedProfileID );
if( bResult )
SCREENMAN->SetNewScreen( NEXT_SCREEN );
else
ScreenPrompt::Prompt( SM_None, ssprintf("Error creating profile '%s'.", sNewName.c_str()) );
}
}
else if( SM == SM_GoToNextScreen )
{
int iSelection = GetSelectionIndex( PLAYER_1 );
vector<CString> vsProfileID;
PROFILEMAN->GetLocalProfileIDs( vsProfileID );
if( iSelection == 0 || iSelection == (int) vsProfileID.size()+1 )
{
GAMESTATE->m_sLastSelectedProfileID = "";
}
else
{
GAMESTATE->m_sLastSelectedProfileID = m_aGameCommands[iSelection].m_sProfileID;
ASSERT( !GAMESTATE->m_sLastSelectedProfileID.empty() );
}
}
ScreenSelectMaster::HandleScreenMessage( SM );
}
/*
* (c) 2003-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-45
View File
@@ -1,45 +0,0 @@
#ifndef ScreenSelectProfile_H
#define ScreenSelectProfile_H
#include "ScreenSelectMaster.h"
class ScreenSelectProfile : public ScreenSelectMaster
{
public:
ScreenSelectProfile( CString sName );
virtual void Init();
virtual ~ScreenSelectProfile();
protected:
virtual void HandleScreenMessage( const ScreenMessage SM );
virtual bool ProcessMenuStart( PlayerNumber pn );
ThemeMetric<CString> NEXT_SCREEN;
};
#endif
/*
* (c) 2003-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+6 -6
View File
@@ -465,6 +465,12 @@ cl /Zl /nologo /c verstub.cpp /Fo&quot;$(IntDir)&quot;\
<File
RelativePath=".\ScreenOptionsManageCourses.h">
</File>
<File
RelativePath=".\ScreenOptionsManageProfiles.cpp">
</File>
<File
RelativePath=".\ScreenOptionsManageProfiles.h">
</File>
<File
RelativePath="ScreenOptionsMaster.cpp">
</File>
@@ -567,12 +573,6 @@ cl /Zl /nologo /c verstub.cpp /Fo&quot;$(IntDir)&quot;\
<File
RelativePath="ScreenSelectMusic.h">
</File>
<File
RelativePath=".\ScreenSelectProfile.cpp">
</File>
<File
RelativePath=".\ScreenSelectProfile.h">
</File>
<File
RelativePath="ScreenSelectStyle.cpp">
</File>