fix deleting, renaming profiles
This commit is contained in:
@@ -251,7 +251,7 @@ void ModeChoice::Apply( PlayerNumber pn ) const
|
||||
//
|
||||
if( m_style != STYLE_INVALID )
|
||||
{
|
||||
PROFILEMAN->TryLoadProfile( pn );
|
||||
PROFILEMAN->LoadDefaultProfileFromMachine( pn );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,83 +38,85 @@ ProfileManager::~ProfileManager()
|
||||
|
||||
}
|
||||
|
||||
void ProfileManager::GetProfiles( vector<CString> &asNamesOut )
|
||||
void ProfileManager::GetMachineProfileIDs( vector<CString> &asProfileIDsOut )
|
||||
{
|
||||
// don't pick up the profile named "Machine"
|
||||
GetDirListing( PROFILES_DIR "0*", asNamesOut, true, false );
|
||||
GetDirListing( PROFILES_DIR "*", asProfileIDsOut, true, false );
|
||||
}
|
||||
|
||||
void ProfileManager::GetProfileDisplayNames( vector<CString> &asNamesOut )
|
||||
void ProfileManager::GetMachineProfileNames( vector<CString> &asNamesOut )
|
||||
{
|
||||
CStringArray vsProfiles;
|
||||
GetProfiles( vsProfiles );
|
||||
for( unsigned i=0; i<vsProfiles.size(); i++ )
|
||||
CStringArray vsProfileIDs;
|
||||
GetMachineProfileIDs( vsProfileIDs );
|
||||
for( unsigned i=0; i<vsProfileIDs.size(); i++ )
|
||||
{
|
||||
CString sProfile = vsProfiles[i];
|
||||
CString sProfileID = vsProfileIDs[i];
|
||||
|
||||
Profile pro;
|
||||
pro.LoadFromIni( PROFILES_DIR + sProfile + SLASH + PROFILE_FILE );
|
||||
asNamesOut.push_back( pro.m_sDisplayName );
|
||||
pro.LoadFromIni( PROFILES_DIR + sProfileID + SLASH + PROFILE_FILE );
|
||||
asNamesOut.push_back( pro.m_sName );
|
||||
}
|
||||
}
|
||||
|
||||
bool ProfileManager::DoesProfileExist( CString sProfile )
|
||||
|
||||
bool ProfileManager::LoadDefaultProfileFromMachine( PlayerNumber pn )
|
||||
{
|
||||
vector<CString> vsProfiles;
|
||||
GetProfiles( vsProfiles );
|
||||
|
||||
return find(vsProfiles.begin(), vsProfiles.end(), sProfile) != vsProfiles.end();
|
||||
}
|
||||
|
||||
|
||||
void ProfileManager::TryLoadProfile( PlayerNumber pn )
|
||||
{
|
||||
CString sProfile = PREFSMAN->m_sDefaultProfile[pn];
|
||||
if( sProfile.empty() )
|
||||
m_bUsingMemoryCard[pn] = false;
|
||||
CString sProfileID = PREFSMAN->m_sDefaultProfile[pn];
|
||||
if( sProfileID.empty() )
|
||||
{
|
||||
m_sProfileDir[pn] = "";
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !DoesProfileExist(sProfile) )
|
||||
m_sProfileDir[pn] = PROFILES_DIR + sProfileID + SLASH;
|
||||
|
||||
bool bResult = m_Profile[pn].LoadFromIni( m_sProfileDir[pn]+PROFILE_FILE );
|
||||
if( !bResult )
|
||||
{
|
||||
LOG->Warn( "Default profile '%s' does not exist", sProfile.c_str() );
|
||||
return;
|
||||
LOG->Warn( "Default profile '%s' does not exist", sProfileID.c_str() );
|
||||
UnloadProfile( pn );
|
||||
return false;
|
||||
}
|
||||
|
||||
m_sProfileDir[pn] = PROFILES_DIR + sProfile + SLASH;
|
||||
|
||||
m_Profile[pn].LoadFromIni( m_sProfileDir[pn]+PROFILE_FILE );
|
||||
|
||||
|
||||
//
|
||||
// Load scores into SONGMAN
|
||||
//
|
||||
SONGMAN->ReadStepsMemCardDataFromFile( m_sProfileDir[pn]+STEPS_MEM_CARD_DATA_FILE, (MemoryCard)pn );
|
||||
SONGMAN->ReadCourseMemCardDataFromFile( m_sProfileDir[pn]+COURSE_MEM_CARD_DATA_FILE, (MemoryCard)pn );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ProfileManager::UnloadProfile( PlayerNumber pn )
|
||||
bool ProfileManager::SaveProfile( PlayerNumber pn )
|
||||
{
|
||||
if( m_sProfileDir[pn].empty() )
|
||||
return;
|
||||
return false;
|
||||
|
||||
m_Profile[pn].WriteToIni( m_sProfileDir[pn]+PROFILE_FILE );
|
||||
m_Profile[pn].SaveToIni( m_sProfileDir[pn]+PROFILE_FILE );
|
||||
|
||||
//
|
||||
// Save scores into SONGMAN
|
||||
//
|
||||
// TODO: move record data to this class
|
||||
SONGMAN->SaveStepsMemCardDataToFile( m_sProfileDir[pn]+STEPS_MEM_CARD_DATA_FILE, (MemoryCard)pn );
|
||||
SONGMAN->SaveCourseMemCardDataToFile( m_sProfileDir[pn]+COURSE_MEM_CARD_DATA_FILE, (MemoryCard)pn );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// clear out the displayname and highscore name when we unload the profile.
|
||||
void ProfileManager::UnloadProfile( PlayerNumber pn )
|
||||
{
|
||||
m_sProfileDir[pn] = "";
|
||||
m_bUsingMemoryCard[pn] = false;
|
||||
m_Profile[pn].Init();
|
||||
}
|
||||
|
||||
CString ProfileManager::GetDisplayName( PlayerNumber pn )
|
||||
Profile* ProfileManager::GetProfile( PlayerNumber pn )
|
||||
{
|
||||
ASSERT(!m_sProfileDir[pn].empty());
|
||||
return m_Profile[pn].m_sDisplayName;
|
||||
if( m_sProfileDir[pn].empty() )
|
||||
return NULL;
|
||||
else
|
||||
return &m_Profile[pn];
|
||||
}
|
||||
|
||||
bool Profile::LoadFromIni( CString sIniPath )
|
||||
@@ -126,7 +128,7 @@ bool Profile::LoadFromIni( CString sIniPath )
|
||||
CString sLastDir = asBits.back(); // this is a number name, e.g. "0000001"
|
||||
|
||||
// Fill in a default value in case ini doesn't have it.
|
||||
m_sDisplayName = ssprintf("Profile%d", atoi(sLastDir));
|
||||
m_sName = "NewProfile";
|
||||
|
||||
|
||||
//
|
||||
@@ -136,42 +138,85 @@ bool Profile::LoadFromIni( CString sIniPath )
|
||||
if( !ini.ReadFile() )
|
||||
return false;
|
||||
|
||||
ini.GetValue( "Profile", "DisplayName", m_sDisplayName );
|
||||
ini.GetValue( "Profile", "DisplayName", m_sName );
|
||||
ini.GetValue( "Profile", "LastUsedHighScoreName", m_sLastUsedHighScoreName );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Profile::WriteToIni( CString sIniPath )
|
||||
bool Profile::SaveToIni( CString sIniPath )
|
||||
{
|
||||
IniFile ini( sIniPath );
|
||||
ini.SetValue( "Profile", "DisplayName", m_sDisplayName );
|
||||
ini.SetValue( "Profile", "DisplayName", m_sName );
|
||||
ini.SetValue( "Profile", "LastUsedHighScoreName", m_sLastUsedHighScoreName );
|
||||
ini.WriteFile();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ProfileManager::CreateProfile( CString sDisplayName )
|
||||
bool ProfileManager::CreateMachineProfile( CString sName )
|
||||
{
|
||||
//
|
||||
// Find a free directory name in the profiles directory
|
||||
//
|
||||
CString sProfile, sDir;
|
||||
for( int i=0; i<1000; i++ )
|
||||
CString sProfileID, sProfileDir;
|
||||
const int MAX_TRIES = 1000;
|
||||
for( int i=0; i<MAX_TRIES; i++ )
|
||||
{
|
||||
sProfile = ssprintf("%08d",i);
|
||||
sDir = PROFILES_DIR + sProfile;
|
||||
if( !DoesFileExist(sDir) )
|
||||
sProfileID = ssprintf("%08d",i);
|
||||
sProfileDir = PROFILES_DIR + sProfileID;
|
||||
if( !DoesFileExist(sProfileDir) )
|
||||
break;
|
||||
}
|
||||
if( i == MAX_TRIES )
|
||||
return false;
|
||||
|
||||
CreateDirectories( sProfileDir );
|
||||
|
||||
CreateDirectories( sDir );
|
||||
|
||||
sDir += SLASH;
|
||||
sProfileDir += SLASH;
|
||||
|
||||
Profile pro;
|
||||
pro.m_sDisplayName = sDisplayName;
|
||||
pro.WriteToIni( sDir + PROFILE_FILE );
|
||||
pro.m_sName = sName;
|
||||
pro.SaveToIni( sProfileDir + PROFILE_FILE );
|
||||
|
||||
FlushDirCache();
|
||||
return true;
|
||||
// TODO: Handle error cases
|
||||
}
|
||||
|
||||
bool ProfileManager::RenameMachineProfile( CString sProfileID, CString sNewName )
|
||||
{
|
||||
ASSERT( !sProfileID.empty() );
|
||||
|
||||
CString sProfileDir = PROFILES_DIR + sProfileID;
|
||||
CString sProfileFile = sProfileDir + SLASH PROFILE_FILE;
|
||||
|
||||
Profile pro;
|
||||
bool bResult;
|
||||
bResult = pro.LoadFromIni( sProfileFile );
|
||||
if( !bResult )
|
||||
return false;
|
||||
pro.m_sName = sNewName;
|
||||
bResult = pro.SaveToIni( sProfileFile );
|
||||
if( !bResult )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProfileManager::DeleteMachineProfile( CString sProfileID )
|
||||
{
|
||||
// delete all files in profile dir
|
||||
CString sProfileDir = PROFILES_DIR + sProfileID;
|
||||
CStringArray asFilesToDelete;
|
||||
GetDirListing( sProfileDir + SLASH "*", asFilesToDelete, false, true );
|
||||
for( unsigned i=0; i<asFilesToDelete.size(); i++ )
|
||||
remove( asFilesToDelete[i] );
|
||||
|
||||
// remove profile dir
|
||||
// FIXME for non Win32 platforms
|
||||
int ret = rmdir( sProfileDir );
|
||||
FlushDirCache();
|
||||
if( ret != 0 )
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
@@ -20,13 +20,13 @@ struct Profile
|
||||
Profile() { Init(); }
|
||||
void Init()
|
||||
{
|
||||
m_sDisplayName = "";
|
||||
m_sName = "";
|
||||
m_sLastUsedHighScoreName = "";
|
||||
}
|
||||
|
||||
bool LoadFromIni( CString sIniPath );
|
||||
bool WriteToIni( CString sIniPath );
|
||||
CString m_sDisplayName;
|
||||
bool SaveToIni( CString sIniPath );
|
||||
CString m_sName;
|
||||
CString m_sLastUsedHighScoreName;
|
||||
};
|
||||
|
||||
@@ -36,29 +36,34 @@ public:
|
||||
ProfileManager();
|
||||
~ProfileManager();
|
||||
|
||||
void CreateProfile( CString sDisplayName );
|
||||
bool CreateMachineProfile( CString sName );
|
||||
bool RenameMachineProfile( CString sProfileID, CString sNewName );
|
||||
bool DeleteMachineProfile( CString sProfileID );
|
||||
|
||||
bool DoesProfileExist( CString sProfile );
|
||||
void GetMachineProfileIDs( vector<CString> &asProfileIDsOut );
|
||||
void GetMachineProfileNames( vector<CString> &asNamesOut );
|
||||
|
||||
void GetProfiles( vector<CString> &asProfilesOut );
|
||||
void GetProfileDisplayNames( vector<CString> &asNamesOut );
|
||||
|
||||
void TryLoadProfile( PlayerNumber pn );
|
||||
bool LoadDefaultProfileFromMachine( PlayerNumber pn );
|
||||
bool LoadProfileFromMemoryCard( PlayerNumber pn );
|
||||
bool SaveProfile( PlayerNumber pn );
|
||||
void UnloadProfile( PlayerNumber pn );
|
||||
|
||||
CString GetDisplayName( PlayerNumber pn );
|
||||
|
||||
bool IsUsingProfile( PlayerNumber pn ) { return !m_sProfileDir[pn].empty(); }
|
||||
Profile* GetProfile( PlayerNumber pn );
|
||||
|
||||
bool IsMemoryCardInserted( PlayerNumber pn ) { return false; }
|
||||
bool IsMemoryCardValid( PlayerNumber pn ) { return false; }
|
||||
|
||||
bool IsMemoryCardInserted( PlayerNumber pn );
|
||||
bool IsUsingMemoryCard( PlayerNumber pn ) { return m_bUsingMemoryCard[pn]; }
|
||||
|
||||
private:
|
||||
// Directory that contains the profile. Either on local machine or
|
||||
// on a memory card.
|
||||
CString m_sProfileDir[NUM_PLAYERS];
|
||||
bool m_bUsingMemoryCard[NUM_PLAYERS];
|
||||
|
||||
Profile m_Profile[NUM_PLAYERS];
|
||||
bool m_bUsingMemoryCard[NUM_PLAYERS];
|
||||
|
||||
// actual loaded profile data
|
||||
Profile m_Profile[NUM_PLAYERS];
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -183,8 +183,10 @@ void ScreenSystemLayer::RefreshCreditsMessages()
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if( PROFILEMAN->IsUsingProfile((PlayerNumber)p) )
|
||||
sText += " " + PROFILEMAN->GetDisplayName((PlayerNumber)p);
|
||||
Profile* pProfile = PROFILEMAN->GetProfile( (PlayerNumber)p );
|
||||
if( pProfile )
|
||||
sText += " " + pProfile->m_sName;
|
||||
|
||||
m_textCreditInfo[p].SetText( sText );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,9 @@ protected:
|
||||
MenuElements m_Menu;
|
||||
OptionRow* m_OptionRow;
|
||||
|
||||
protected: // derived classes need access to these
|
||||
int m_iSelectedOption[NUM_PLAYERS][MAX_OPTION_LINES];
|
||||
int m_iCurrentRow[NUM_PLAYERS];
|
||||
|
||||
private:
|
||||
InputMode m_InputMode;
|
||||
@@ -115,7 +117,6 @@ private:
|
||||
bool m_bRowIsHidden[MAX_OPTION_LINES];
|
||||
float m_fRowY[MAX_OPTION_LINES];
|
||||
|
||||
int m_iCurrentRow[NUM_PLAYERS];
|
||||
|
||||
OptionsCursor m_Underline[NUM_PLAYERS][MAX_OPTION_LINES];
|
||||
OptionIcon m_OptionIcons[NUM_PLAYERS][MAX_OPTION_LINES];
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "ThemeManager.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "ScreenTextEntry.h"
|
||||
#include "ScreenPrompt.h"
|
||||
|
||||
|
||||
enum {
|
||||
@@ -37,25 +39,29 @@ OptionRow g_ProfileOptionsLines[NUM_PROFILE_OPTIONS_LINES] = {
|
||||
OptionRow( "Rename", true ),
|
||||
};
|
||||
|
||||
const ScreenMessage SM_DoneCreating = ScreenMessage(SM_User+1);
|
||||
const ScreenMessage SM_DoneRenaming = ScreenMessage(SM_User+2);
|
||||
const ScreenMessage SM_DoneDeleting = ScreenMessage(SM_User+3);
|
||||
|
||||
ScreenProfileOptions::ScreenProfileOptions( CString sClassName ) : ScreenOptions( sClassName )
|
||||
{
|
||||
LOG->Trace( "ScreenProfileOptions::ScreenProfileOptions()" );
|
||||
|
||||
g_ProfileOptionsLines[PO_PLAYER1].choices.clear();
|
||||
g_ProfileOptionsLines[PO_PLAYER1].choices.push_back( "-NONE-" );
|
||||
PROFILEMAN->GetProfileDisplayNames( g_ProfileOptionsLines[PO_PLAYER1].choices );
|
||||
PROFILEMAN->GetMachineProfileNames( g_ProfileOptionsLines[PO_PLAYER1].choices );
|
||||
|
||||
g_ProfileOptionsLines[PO_PLAYER2].choices.clear();
|
||||
g_ProfileOptionsLines[PO_PLAYER2].choices.push_back( "-NONE-" );
|
||||
PROFILEMAN->GetProfileDisplayNames( g_ProfileOptionsLines[PO_PLAYER2].choices );
|
||||
PROFILEMAN->GetMachineProfileNames( g_ProfileOptionsLines[PO_PLAYER2].choices );
|
||||
|
||||
g_ProfileOptionsLines[PO_DELETE_].choices.clear();
|
||||
g_ProfileOptionsLines[PO_DELETE_].choices.push_back( "-NONE-" );
|
||||
PROFILEMAN->GetProfileDisplayNames( g_ProfileOptionsLines[PO_DELETE_].choices );
|
||||
PROFILEMAN->GetMachineProfileNames( g_ProfileOptionsLines[PO_DELETE_].choices );
|
||||
|
||||
g_ProfileOptionsLines[PO_RENAME_].choices.clear();
|
||||
g_ProfileOptionsLines[PO_RENAME_].choices.push_back( "-NONE-" );
|
||||
PROFILEMAN->GetProfileDisplayNames( g_ProfileOptionsLines[PO_RENAME_].choices );
|
||||
PROFILEMAN->GetMachineProfileNames( g_ProfileOptionsLines[PO_RENAME_].choices );
|
||||
|
||||
Init(
|
||||
INPUTMODE_TOGETHER,
|
||||
@@ -70,7 +76,7 @@ ScreenProfileOptions::ScreenProfileOptions( CString sClassName ) : ScreenOptions
|
||||
void ScreenProfileOptions::ImportOptions()
|
||||
{
|
||||
vector<CString> vsProfiles;
|
||||
PROFILEMAN->GetProfiles( vsProfiles );
|
||||
PROFILEMAN->GetMachineProfileIDs( vsProfiles );
|
||||
|
||||
CStringArray::iterator iter;
|
||||
|
||||
@@ -84,7 +90,7 @@ void ScreenProfileOptions::ImportOptions()
|
||||
iter = find(
|
||||
vsProfiles.begin(),
|
||||
vsProfiles.end(),
|
||||
PREFSMAN->m_sDefaultProfile[PO_PLAYER2] );
|
||||
PREFSMAN->m_sDefaultProfile[PLAYER_2] );
|
||||
if( iter != vsProfiles.end() )
|
||||
m_iSelectedOption[0][PO_PLAYER2] = iter - vsProfiles.begin() + 1;
|
||||
}
|
||||
@@ -92,7 +98,7 @@ void ScreenProfileOptions::ImportOptions()
|
||||
void ScreenProfileOptions::ExportOptions()
|
||||
{
|
||||
vector<CString> vsProfiles;
|
||||
PROFILEMAN->GetProfiles( vsProfiles );
|
||||
PROFILEMAN->GetMachineProfileIDs( vsProfiles );
|
||||
|
||||
if( m_iSelectedOption[0][PO_PLAYER1] > 0 )
|
||||
PREFSMAN->m_sDefaultProfile[PLAYER_1] = vsProfiles[m_iSelectedOption[0][PO_PLAYER1]-1];
|
||||
@@ -110,49 +116,100 @@ void ScreenProfileOptions::GoToPrevState()
|
||||
SCREENMAN->SetNewScreen( "ScreenOptionsMenu" );
|
||||
}
|
||||
|
||||
void CreateProfile( CString sDisplayName )
|
||||
{
|
||||
PROFILEMAN->CreateProfile( sDisplayName );
|
||||
SCREENMAN->SetNewScreen( "ScreenProfileOptions" );
|
||||
}
|
||||
|
||||
void ScreenProfileOptions::GoToNextState()
|
||||
{
|
||||
PREFSMAN->SaveGlobalPrefsToDisk();
|
||||
GoToPrevState();
|
||||
}
|
||||
|
||||
void ScreenProfileOptions::HandleScreenMessage( const ScreenMessage SM )
|
||||
{
|
||||
CString sProfileID = GetSelectedProfileID();
|
||||
CString sName = GetSelectedProfileName();
|
||||
|
||||
switch( SM )
|
||||
{
|
||||
case SM_DoneCreating:
|
||||
if( !ScreenTextEntry::s_bCancelledLast )
|
||||
{
|
||||
CString sNewProfileID = ScreenTextEntry::s_sLastAnswer;
|
||||
bool bResult = PROFILEMAN->CreateMachineProfile( sNewProfileID );
|
||||
if( bResult )
|
||||
SCREENMAN->SetNewScreen( "ScreenProfileOptions" ); // reload
|
||||
else
|
||||
SCREENMAN->Prompt( SM_None, ssprintf("Error creating profile '%s'.", sNewProfileID.c_str()) );
|
||||
}
|
||||
break;
|
||||
case SM_DoneRenaming:
|
||||
if( !ScreenTextEntry::s_bCancelledLast )
|
||||
{
|
||||
CString sNewName = ScreenTextEntry::s_sLastAnswer;
|
||||
bool bResult = PROFILEMAN->RenameMachineProfile( sProfileID, sNewName );
|
||||
if( bResult )
|
||||
SCREENMAN->SetNewScreen( "ScreenProfileOptions" ); // reload
|
||||
else
|
||||
SCREENMAN->Prompt( SM_None, ssprintf("Error renaming profile %s '%s'\nto '%s'.", sProfileID.c_str(), sName.c_str(), sNewName.c_str()) );
|
||||
}
|
||||
break;
|
||||
case SM_DoneDeleting:
|
||||
if( ScreenPrompt::s_bLastAnswer )
|
||||
{
|
||||
bool bResult = PROFILEMAN->DeleteMachineProfile( sProfileID );
|
||||
if( bResult )
|
||||
SCREENMAN->SetNewScreen( "ScreenProfileOptions" ); // reload
|
||||
else
|
||||
SCREENMAN->Prompt( SM_None, ssprintf("Error deleting profile %s '%s'.", sName.c_str(), sProfileID.c_str()) );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ScreenOptions::HandleScreenMessage( SM );
|
||||
}
|
||||
|
||||
|
||||
void ScreenProfileOptions::MenuStart( PlayerNumber pn )
|
||||
{
|
||||
vector<CString> vsProfiles;
|
||||
PROFILEMAN->GetProfiles( vsProfiles );
|
||||
CString sProfileID = GetSelectedProfileID();
|
||||
CString sName = GetSelectedProfileName();
|
||||
|
||||
switch( GetCurrentRow() )
|
||||
{
|
||||
case PO_CREATE_NEW:
|
||||
SCREENMAN->TextEntry( SM_None, "Enter a profile name", "", CreateProfile );
|
||||
return;
|
||||
SCREENMAN->TextEntry( SM_DoneCreating, "Enter a profile name", "", NULL );
|
||||
break;
|
||||
case PO_DELETE_:
|
||||
{
|
||||
CString sProfile;
|
||||
if( m_iSelectedOption[0][PO_DELETE_] > 0 )
|
||||
sProfile = vsProfiles[m_iSelectedOption[0][PO_DELETE_]-1];
|
||||
else
|
||||
sProfile = "";
|
||||
}
|
||||
if( sProfileID=="" )
|
||||
SOUND->PlayOnce( THEME->GetPathToS("common invalid") );
|
||||
else
|
||||
SCREENMAN->Prompt( SM_DoneDeleting, ssprintf("Delete profile %s '%s'?",sProfileID.c_str(),sName.c_str()), true );
|
||||
break;
|
||||
case PO_RENAME_:
|
||||
{
|
||||
CString sProfile;
|
||||
if( m_iSelectedOption[0][PO_RENAME_] > 0 )
|
||||
sProfile = vsProfiles[m_iSelectedOption[0][PO_RENAME_]-1];
|
||||
else
|
||||
sProfile = "";
|
||||
|
||||
// SCREENMAN->TextEntry( SM_None, "Enter a profile name", "NewProfile", SetProfile );
|
||||
}
|
||||
if( sProfileID=="" )
|
||||
SOUND->PlayOnce( THEME->GetPathToS("common invalid") );
|
||||
else
|
||||
SCREENMAN->TextEntry( SM_DoneRenaming, ssprintf("Rename profile %s '%s'",sProfileID.c_str(),sName.c_str()), sName, NULL );
|
||||
break;
|
||||
default:
|
||||
ScreenOptions::MenuStart( pn );
|
||||
}
|
||||
}
|
||||
|
||||
CString ScreenProfileOptions::GetSelectedProfileID()
|
||||
{
|
||||
vector<CString> vsProfiles;
|
||||
PROFILEMAN->GetMachineProfileIDs( vsProfiles );
|
||||
|
||||
if( m_iSelectedOption[0][m_iCurrentRow[0]]==0 )
|
||||
return "";
|
||||
else
|
||||
return vsProfiles[m_iSelectedOption[0][m_iCurrentRow[0]]-1];
|
||||
}
|
||||
|
||||
CString ScreenProfileOptions::GetSelectedProfileName()
|
||||
{
|
||||
if( m_iSelectedOption[0][m_iCurrentRow[0]]==0 )
|
||||
return "";
|
||||
else
|
||||
return g_ProfileOptionsLines[PO_PLAYER1].choices[ m_iSelectedOption[0][m_iCurrentRow[0]] ];
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ class ScreenProfileOptions : public ScreenOptions
|
||||
public:
|
||||
ScreenProfileOptions( CString sName );
|
||||
|
||||
virtual void HandleScreenMessage( const ScreenMessage SM );
|
||||
|
||||
virtual void MenuStart( PlayerNumber pn );
|
||||
|
||||
private:
|
||||
@@ -24,5 +26,8 @@ private:
|
||||
|
||||
void GoToNextState();
|
||||
void GoToPrevState();
|
||||
|
||||
CString GetSelectedProfileID();
|
||||
CString GetSelectedProfileName();
|
||||
};
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ const float QUESTION_Y = CENTER_Y - 60;
|
||||
const float PROMPT_X = CENTER_X;
|
||||
const float PROMPT_Y = CENTER_Y + 120;
|
||||
|
||||
bool ScreenPrompt::s_bLastAnswer = false;
|
||||
|
||||
ScreenPrompt::ScreenPrompt( ScreenMessage SM_SendWhenDone, CString sText, bool bYesNoPrompt, bool bDefaultAnswer, void(*OnYes)(void*), void(*OnNo)(void*), void* pCallbackData ) :
|
||||
Screen("ScreenPrompt")
|
||||
@@ -180,10 +181,14 @@ void ScreenPrompt::MenuStart( PlayerNumber pn )
|
||||
{
|
||||
if( m_pOnYes )
|
||||
m_pOnYes(m_pCallbackData);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_pOnNo )
|
||||
m_pOnNo(m_pCallbackData);
|
||||
}
|
||||
|
||||
s_bLastAnswer = m_bAnswer;
|
||||
}
|
||||
|
||||
void ScreenPrompt::MenuBack( PlayerNumber pn )
|
||||
|
||||
@@ -28,6 +28,8 @@ public:
|
||||
virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
|
||||
virtual void HandleScreenMessage( const ScreenMessage SM );
|
||||
|
||||
static bool s_bLastAnswer;
|
||||
|
||||
protected:
|
||||
void MenuLeft( PlayerNumber pn );
|
||||
void MenuRight( PlayerNumber pn );
|
||||
|
||||
@@ -28,6 +28,11 @@ const float ANSWER_Y = CENTER_Y + 120;
|
||||
const float ANSWER_WIDTH = 440;
|
||||
const float ANSWER_HEIGHT = 30;
|
||||
|
||||
|
||||
CString ScreenTextEntry::s_sLastAnswer = "";
|
||||
bool ScreenTextEntry::s_bCancelledLast = false;
|
||||
|
||||
|
||||
/* XXX: Don't let the user use internal-use codepoints (those
|
||||
* that resolve to Unicode codepoints above 0xFFFF); those are
|
||||
* subject to change and shouldn't be written to .SMs.
|
||||
@@ -204,9 +209,14 @@ void ScreenTextEntry::MenuStart( PlayerNumber pn )
|
||||
|
||||
SOUND->PlayOnce( THEME->GetPathToS("Common start") );
|
||||
|
||||
if( m_bCancelled ) {
|
||||
if( m_pOnCancel ) m_pOnCancel();
|
||||
} else {
|
||||
if( m_bCancelled )
|
||||
{
|
||||
if( m_pOnCancel )
|
||||
m_pOnCancel();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_pOnOK )
|
||||
{
|
||||
CString ret = WStringToCString(m_sAnswer);
|
||||
@@ -214,6 +224,9 @@ void ScreenTextEntry::MenuStart( PlayerNumber pn )
|
||||
m_pOnOK( ret );
|
||||
}
|
||||
}
|
||||
|
||||
s_bCancelledLast = m_bCancelled;
|
||||
s_sLastAnswer = m_bCancelled ? "" : WStringToCString(m_sAnswer);
|
||||
}
|
||||
|
||||
void ScreenTextEntry::MenuBack( PlayerNumber pn )
|
||||
|
||||
@@ -29,6 +29,9 @@ public:
|
||||
virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
|
||||
virtual void HandleScreenMessage( const ScreenMessage SM );
|
||||
|
||||
static CString s_sLastAnswer;
|
||||
static bool s_bCancelledLast;
|
||||
|
||||
protected:
|
||||
virtual void MenuLeft( PlayerNumber pn );
|
||||
virtual void MenuRight( PlayerNumber pn );
|
||||
@@ -37,7 +40,7 @@ protected:
|
||||
|
||||
void UpdateText();
|
||||
|
||||
BGAnimation m_Background;
|
||||
BGAnimation m_Background;
|
||||
BitmapText m_textQuestion;
|
||||
Quad m_rectAnswerBox;
|
||||
wstring m_sAnswer;
|
||||
|
||||
Reference in New Issue
Block a user