split GetMemoryCardProfileDirectoriesToTry
store directory imported from
This commit is contained in:
@@ -130,6 +130,15 @@ bool ProfileManager::LoadLocalProfileFromMachine( PlayerNumber pn )
|
||||
return LoadProfile( pn, sDir, false ) == Profile::success;
|
||||
}
|
||||
|
||||
void ProfileManager::GetMemoryCardProfileDirectoriesToTry( vector<CString> &asDirsToTry )
|
||||
{
|
||||
/* Try to load the preferred profile. */
|
||||
asDirsToTry.push_back( PREFSMAN->m_sMemoryCardProfileSubdir );
|
||||
|
||||
/* If that failed, try loading from all fallback directories. */
|
||||
split( g_sMemoryCardProfileImportSubdirs, ";", asDirsToTry, true );
|
||||
}
|
||||
|
||||
bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn )
|
||||
{
|
||||
UnloadProfile( pn );
|
||||
@@ -139,13 +148,9 @@ bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn )
|
||||
return false;
|
||||
|
||||
vector<CString> asDirsToTry;
|
||||
GetMemoryCardProfileDirectoriesToTry( asDirsToTry );
|
||||
|
||||
/* Try to load the preferred profile. */
|
||||
asDirsToTry.push_back( PREFSMAN->m_sMemoryCardProfileSubdir );
|
||||
|
||||
/* If that failed, try loading from all fallback directories. */
|
||||
split( g_sMemoryCardProfileImportSubdirs, ";", asDirsToTry, true );
|
||||
|
||||
int iLoadedFrom = -1;
|
||||
for( unsigned i = 0; i < asDirsToTry.size(); ++i )
|
||||
{
|
||||
const CString &sSubdir = asDirsToTry[i];
|
||||
@@ -160,10 +165,18 @@ bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn )
|
||||
* a directory for edits before playing, so keep searching if the directory
|
||||
* exists with exists with no scores. */
|
||||
Profile::LoadResult res = LoadProfile( pn, sDir, true );
|
||||
if( res != Profile::failed_no_profile )
|
||||
if( res == Profile::success )
|
||||
iLoadedFrom = i;
|
||||
else if( res != Profile::failed_no_profile )
|
||||
break;
|
||||
}
|
||||
|
||||
/* Store the directory we imported from, for display purposes. */
|
||||
if( iLoadedFrom > 0 )
|
||||
{
|
||||
m_sProfileDirImportedFrom[pn] = asDirsToTry[iLoadedFrom];
|
||||
}
|
||||
|
||||
/* If we imported a profile fallback directory, change the memory card
|
||||
* directory back to the preferred directory: never write over imported
|
||||
* scores. */
|
||||
@@ -209,6 +222,7 @@ bool ProfileManager::SaveProfile( PlayerNumber pn ) const
|
||||
void ProfileManager::UnloadProfile( PlayerNumber pn )
|
||||
{
|
||||
m_sProfileDir[pn] = "";
|
||||
m_sProfileDirImportedFrom[pn] = "";
|
||||
m_bWasLoadedFromMemoryCard[pn] = false;
|
||||
m_bLastLoadWasTamperedOrCorrupt[pn] = false;
|
||||
m_bLastLoadWasFromLastGood[pn] = false;
|
||||
@@ -353,6 +367,20 @@ CString ProfileManager::GetProfileDir( ProfileSlot slot ) const
|
||||
}
|
||||
}
|
||||
|
||||
CString ProfileManager::GetProfileDirImportedFrom( ProfileSlot slot ) const
|
||||
{
|
||||
switch( slot )
|
||||
{
|
||||
case PROFILE_SLOT_PLAYER_1:
|
||||
case PROFILE_SLOT_PLAYER_2:
|
||||
return m_sProfileDirImportedFrom[slot];
|
||||
case PROFILE_SLOT_MACHINE:
|
||||
return "";
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
const Profile* ProfileManager::GetProfile( ProfileSlot slot ) const
|
||||
{
|
||||
switch( slot )
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
void SaveAllProfiles() const;
|
||||
bool SaveProfile( PlayerNumber pn ) const;
|
||||
void UnloadProfile( PlayerNumber pn );
|
||||
void GetMemoryCardProfileDirectoriesToTry( vector<CString> &asDirsToTry );
|
||||
|
||||
//
|
||||
// General data
|
||||
@@ -53,6 +54,7 @@ public:
|
||||
const Profile* GetProfile( ProfileSlot slot ) const;
|
||||
Profile* GetProfile( ProfileSlot slot ) { return (Profile*) ((const ProfileManager *) this)->GetProfile(slot); }
|
||||
CString GetProfileDir( ProfileSlot slot ) const;
|
||||
CString GetProfileDirImportedFrom( ProfileSlot slot ) const;
|
||||
|
||||
Profile* GetMachineProfile() { return &m_MachineProfile; }
|
||||
|
||||
@@ -94,6 +96,9 @@ private:
|
||||
// on a memory card.
|
||||
CString m_sProfileDir[NUM_PLAYERS];
|
||||
|
||||
// MemoryCardProfileImportSubdirs name, if the profile was imported.
|
||||
CString m_sProfileDirImportedFrom[NUM_PLAYERS];
|
||||
|
||||
bool m_bWasLoadedFromMemoryCard[NUM_PLAYERS];
|
||||
bool m_bLastLoadWasTamperedOrCorrupt[NUM_PLAYERS]; // true if Stats.xml was present, but failed to load (probably because of a signature failure)
|
||||
bool m_bLastLoadWasFromLastGood[NUM_PLAYERS]; // if true, then m_bLastLoadWasTamperedOrCorrupt is also true
|
||||
|
||||
Reference in New Issue
Block a user