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;
|
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 )
|
bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn )
|
||||||
{
|
{
|
||||||
UnloadProfile( pn );
|
UnloadProfile( pn );
|
||||||
@@ -139,13 +148,9 @@ bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn )
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
vector<CString> asDirsToTry;
|
vector<CString> asDirsToTry;
|
||||||
|
GetMemoryCardProfileDirectoriesToTry( asDirsToTry );
|
||||||
|
|
||||||
/* Try to load the preferred profile. */
|
int iLoadedFrom = -1;
|
||||||
asDirsToTry.push_back( PREFSMAN->m_sMemoryCardProfileSubdir );
|
|
||||||
|
|
||||||
/* If that failed, try loading from all fallback directories. */
|
|
||||||
split( g_sMemoryCardProfileImportSubdirs, ";", asDirsToTry, true );
|
|
||||||
|
|
||||||
for( unsigned i = 0; i < asDirsToTry.size(); ++i )
|
for( unsigned i = 0; i < asDirsToTry.size(); ++i )
|
||||||
{
|
{
|
||||||
const CString &sSubdir = asDirsToTry[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
|
* a directory for edits before playing, so keep searching if the directory
|
||||||
* exists with exists with no scores. */
|
* exists with exists with no scores. */
|
||||||
Profile::LoadResult res = LoadProfile( pn, sDir, true );
|
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;
|
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
|
/* If we imported a profile fallback directory, change the memory card
|
||||||
* directory back to the preferred directory: never write over imported
|
* directory back to the preferred directory: never write over imported
|
||||||
* scores. */
|
* scores. */
|
||||||
@@ -209,6 +222,7 @@ bool ProfileManager::SaveProfile( PlayerNumber pn ) const
|
|||||||
void ProfileManager::UnloadProfile( PlayerNumber pn )
|
void ProfileManager::UnloadProfile( PlayerNumber pn )
|
||||||
{
|
{
|
||||||
m_sProfileDir[pn] = "";
|
m_sProfileDir[pn] = "";
|
||||||
|
m_sProfileDirImportedFrom[pn] = "";
|
||||||
m_bWasLoadedFromMemoryCard[pn] = false;
|
m_bWasLoadedFromMemoryCard[pn] = false;
|
||||||
m_bLastLoadWasTamperedOrCorrupt[pn] = false;
|
m_bLastLoadWasTamperedOrCorrupt[pn] = false;
|
||||||
m_bLastLoadWasFromLastGood[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
|
const Profile* ProfileManager::GetProfile( ProfileSlot slot ) const
|
||||||
{
|
{
|
||||||
switch( slot )
|
switch( slot )
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public:
|
|||||||
void SaveAllProfiles() const;
|
void SaveAllProfiles() const;
|
||||||
bool SaveProfile( PlayerNumber pn ) const;
|
bool SaveProfile( PlayerNumber pn ) const;
|
||||||
void UnloadProfile( PlayerNumber pn );
|
void UnloadProfile( PlayerNumber pn );
|
||||||
|
void GetMemoryCardProfileDirectoriesToTry( vector<CString> &asDirsToTry );
|
||||||
|
|
||||||
//
|
//
|
||||||
// General data
|
// General data
|
||||||
@@ -53,6 +54,7 @@ public:
|
|||||||
const Profile* GetProfile( ProfileSlot slot ) const;
|
const Profile* GetProfile( ProfileSlot slot ) const;
|
||||||
Profile* GetProfile( ProfileSlot slot ) { return (Profile*) ((const ProfileManager *) this)->GetProfile(slot); }
|
Profile* GetProfile( ProfileSlot slot ) { return (Profile*) ((const ProfileManager *) this)->GetProfile(slot); }
|
||||||
CString GetProfileDir( ProfileSlot slot ) const;
|
CString GetProfileDir( ProfileSlot slot ) const;
|
||||||
|
CString GetProfileDirImportedFrom( ProfileSlot slot ) const;
|
||||||
|
|
||||||
Profile* GetMachineProfile() { return &m_MachineProfile; }
|
Profile* GetMachineProfile() { return &m_MachineProfile; }
|
||||||
|
|
||||||
@@ -94,6 +96,9 @@ private:
|
|||||||
// on a memory card.
|
// on a memory card.
|
||||||
CString m_sProfileDir[NUM_PLAYERS];
|
CString m_sProfileDir[NUM_PLAYERS];
|
||||||
|
|
||||||
|
// MemoryCardProfileImportSubdirs name, if the profile was imported.
|
||||||
|
CString m_sProfileDirImportedFrom[NUM_PLAYERS];
|
||||||
|
|
||||||
bool m_bWasLoadedFromMemoryCard[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_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
|
bool m_bLastLoadWasFromLastGood[NUM_PLAYERS]; // if true, then m_bLastLoadWasTamperedOrCorrupt is also true
|
||||||
|
|||||||
Reference in New Issue
Block a user