set default profile ID when creating profiles
This commit is contained in:
@@ -113,10 +113,10 @@ private:
|
|||||||
template <class T>
|
template <class T>
|
||||||
class Preference1D
|
class Preference1D
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
typedef Preference<T> PreferenceT;
|
typedef Preference<T> PreferenceT;
|
||||||
vector<PreferenceT*> m_v;
|
vector<PreferenceT*> m_v;
|
||||||
|
|
||||||
public:
|
|
||||||
Preference1D( void pfn(size_t i, RString &sNameOut, T &defaultValueOut ), size_t N )
|
Preference1D( void pfn(size_t i, RString &sNameOut, T &defaultValueOut ), size_t N )
|
||||||
{
|
{
|
||||||
for( size_t i=0; i<N; ++i )
|
for( size_t i=0; i<N; ++i )
|
||||||
|
|||||||
@@ -486,6 +486,14 @@ bool ProfileManager::DeleteLocalProfile( RString sProfileID )
|
|||||||
if( DeleteRecursive(sProfileDir) )
|
if( DeleteRecursive(sProfileDir) )
|
||||||
{
|
{
|
||||||
g_vLocalProfile.erase( i );
|
g_vLocalProfile.erase( i );
|
||||||
|
|
||||||
|
// Delete all references to this profileID
|
||||||
|
FOREACH_CONST( Preference<RString>*, PROFILEMAN->m_sDefaultLocalProfileID.m_v, i )
|
||||||
|
{
|
||||||
|
if( (*i)->Get() == sProfileID )
|
||||||
|
(*i)->Set( "" );
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -495,6 +503,8 @@ bool ProfileManager::DeleteLocalProfile( RString sProfileID )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LOG->Warn( "DeleteLocalProfile: ProfileID '%s' doesn't exist", sProfileID.c_str() );
|
LOG->Warn( "DeleteLocalProfile: ProfileID '%s' doesn't exist", sProfileID.c_str() );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,11 +183,31 @@ void ScreenOptionsManageProfiles::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
RString sNewName = ScreenTextEntry::s_sLastAnswer;
|
RString sNewName = ScreenTextEntry::s_sLastAnswer;
|
||||||
ASSERT( GAMESTATE->m_sEditLocalProfileID.Get().empty() );
|
ASSERT( GAMESTATE->m_sEditLocalProfileID.Get().empty() );
|
||||||
|
|
||||||
|
int iNumProfiles = PROFILEMAN->GetNumLocalProfiles();
|
||||||
|
|
||||||
// create
|
// create
|
||||||
RString sProfileID;
|
RString sProfileID;
|
||||||
PROFILEMAN->CreateLocalProfile( ScreenTextEntry::s_sLastAnswer, sProfileID );
|
PROFILEMAN->CreateLocalProfile( ScreenTextEntry::s_sLastAnswer, sProfileID ); // TODO: Check return value
|
||||||
GAMESTATE->m_sEditLocalProfileID.Set( sProfileID );
|
GAMESTATE->m_sEditLocalProfileID.Set( sProfileID );
|
||||||
|
|
||||||
|
if( iNumProfiles < NUM_PLAYERS )
|
||||||
|
{
|
||||||
|
int iFirstUnused = -1;
|
||||||
|
FOREACH_CONST( Preference<RString>*, PROFILEMAN->m_sDefaultLocalProfileID.m_v, i )
|
||||||
|
{
|
||||||
|
RString sLocalProfileID = (*i)->Get();
|
||||||
|
if( sLocalProfileID.empty() )
|
||||||
|
{
|
||||||
|
iFirstUnused = i - PROFILEMAN->m_sDefaultLocalProfileID.m_v.begin();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( iFirstUnused != -1 )
|
||||||
|
{
|
||||||
|
PROFILEMAN->m_sDefaultLocalProfileID.m_v[iFirstUnused]->Set( sProfileID );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SCREENMAN->SetNewScreen( this->m_sName ); // reload
|
SCREENMAN->SetNewScreen( this->m_sName ); // reload
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user