CreateLocalProfileByID -> AddLocalProfileByID (to allow code to set up
a local profile on its own)
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
#include "StepsUtil.h"
|
#include "StepsUtil.h"
|
||||||
#include "Style.h"
|
#include "Style.h"
|
||||||
#include "HighScore.h"
|
#include "HighScore.h"
|
||||||
|
#include "Character.h"
|
||||||
|
|
||||||
|
|
||||||
ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our program
|
ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our program
|
||||||
@@ -365,29 +366,37 @@ bool ProfileManager::CreateLocalProfile( CString sName, CString &sProfileIDOut )
|
|||||||
int iProfileNumber = iMaxProfileNumber + 1;
|
int iProfileNumber = iMaxProfileNumber + 1;
|
||||||
CString sProfileID = ssprintf( "%08d", iProfileNumber );
|
CString sProfileID = ssprintf( "%08d", iProfileNumber );
|
||||||
|
|
||||||
if( !CreateLocalProfileByID(sName, sProfileID) )
|
//
|
||||||
|
// Create the new profile.
|
||||||
|
//
|
||||||
|
Profile *pProfile = new Profile;
|
||||||
|
pProfile->m_sDisplayName = sName;
|
||||||
|
pProfile->m_sCharacter = GAMESTATE->GetRandomCharacter()->m_sName;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Save it to disk.
|
||||||
|
//
|
||||||
|
CString sProfileDir = LocalProfileIdToDir( sProfileID );
|
||||||
|
if( !pProfile->SaveAllToDir(sProfileDir, PREFSMAN->m_bSignProfileData) )
|
||||||
{
|
{
|
||||||
|
delete pProfile;
|
||||||
sProfileIDOut = "";
|
sProfileIDOut = "";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AddLocalProfileByID( pProfile, sProfileID );
|
||||||
|
|
||||||
sProfileIDOut = sProfileID;
|
sProfileIDOut = sProfileID;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProfileManager::CreateLocalProfileByID( CString sName, CString sProfileID )
|
void ProfileManager::AddLocalProfileByID( Profile *pProfile, CString sProfileID )
|
||||||
{
|
{
|
||||||
ASSERT_M( g_mapLocalProfileIdToProfile.find(sProfileID) == g_mapLocalProfileIdToProfile.end(),
|
ASSERT_M( g_mapLocalProfileIdToProfile.find(sProfileID) == g_mapLocalProfileIdToProfile.end(),
|
||||||
ssprintf("creating \"%s\" \"%s\" that already exists",
|
ssprintf("creating \"%s\" \"%s\" that already exists",
|
||||||
sName.c_str(), sProfileID.c_str()) );
|
pProfile->m_sDisplayName.c_str(), sProfileID.c_str()) );
|
||||||
|
|
||||||
CString sProfileDir = LocalProfileIdToDir( sProfileID );
|
|
||||||
Profile *pProfile = Profile::CreateNewProfile( sProfileDir, sName, true );
|
|
||||||
if( pProfile == NULL )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
g_mapLocalProfileIdToProfile[sProfileID] = pProfile;
|
g_mapLocalProfileIdToProfile[sProfileID] = pProfile;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Profile* ProfileManager::GetLocalProfileByID( const CString &sProfileID ) const
|
const Profile* ProfileManager::GetLocalProfileByID( const CString &sProfileID ) const
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public:
|
|||||||
Profile &GetLocalProfile( const CString &sProfileID );
|
Profile &GetLocalProfile( const CString &sProfileID );
|
||||||
|
|
||||||
bool CreateLocalProfile( CString sName, CString &sProfileIDOut );
|
bool CreateLocalProfile( CString sName, CString &sProfileIDOut );
|
||||||
bool CreateLocalProfileByID( CString sName, CString sProfileID );
|
void AddLocalProfileByID( Profile *pProfile, CString sProfileID ); // transfers ownership of pProfile
|
||||||
bool RenameLocalProfile( CString sProfileID, CString sNewName );
|
bool RenameLocalProfile( CString sProfileID, CString sNewName );
|
||||||
bool DeleteLocalProfile( CString sProfileID );
|
bool DeleteLocalProfile( CString sProfileID );
|
||||||
void GetLocalProfileIDs( vector<CString> &vsProfileIDsOut ) const;
|
void GetLocalProfileIDs( vector<CString> &vsProfileIDsOut ) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user