Save profile modifiers per gametype. Only reset saved modifiers when
loading profile modifiers, so we don't wipe out modifiers that aren't saved. UsingProfileDefaultModifiers is gone; if an entry exists in the DefaultModifiers list at all, UsingProfileDefaultModifiers is true.
This commit is contained in:
@@ -246,10 +246,15 @@ void GameState::PlayersFinalized()
|
|||||||
|
|
||||||
Profile* pProfile = PROFILEMAN->GetProfile(pn);
|
Profile* pProfile = PROFILEMAN->GetProfile(pn);
|
||||||
|
|
||||||
if( pProfile->m_bUsingProfileDefaultModifiers )
|
CString sModifiers;
|
||||||
|
if( pProfile->GetDefaultModifiers( this->m_pCurGame, sModifiers ) )
|
||||||
{
|
{
|
||||||
GAMESTATE->m_PlayerOptions[pn].Init();
|
/* We don't save negative preferences (eg. "no reverse"). If the theme
|
||||||
GAMESTATE->ApplyModifiers( pn, pProfile->m_sDefaultModifiers );
|
* sets a default of "reverse", and the player turns it off, we should
|
||||||
|
* set it off. However, don't reset modifiers that aren't saved by the
|
||||||
|
* profile, so we don't ignore unsaved modifiers when a profile is in use. */
|
||||||
|
GAMESTATE->m_PlayerOptions[pn].ResetSavedPrefs();
|
||||||
|
GAMESTATE->ApplyModifiers( pn, sModifiers );
|
||||||
}
|
}
|
||||||
// Only set the sort order if it wasn't already set by a ModeChoice (or by an earlier profile)
|
// Only set the sort order if it wasn't already set by a ModeChoice (or by an earlier profile)
|
||||||
if( m_SortOrder == SORT_INVALID && pProfile->m_SortOrder != SORT_INVALID )
|
if( m_SortOrder == SORT_INVALID && pProfile->m_SortOrder != SORT_INVALID )
|
||||||
@@ -386,8 +391,7 @@ void GameState::SaveCurrentSettingsToProfile( PlayerNumber pn )
|
|||||||
|
|
||||||
Profile* pProfile = PROFILEMAN->GetProfile(pn);
|
Profile* pProfile = PROFILEMAN->GetProfile(pn);
|
||||||
|
|
||||||
pProfile->m_bUsingProfileDefaultModifiers = true;
|
pProfile->SetDefaultModifiers( this->m_pCurGame, m_PlayerOptions[pn].GetSavedPrefsString() );
|
||||||
pProfile->m_sDefaultModifiers = m_PlayerOptions[pn].GetSavedPrefsString();
|
|
||||||
if( IsSongSort(m_SortOrder) )
|
if( IsSongSort(m_SortOrder) )
|
||||||
pProfile->m_SortOrder = m_SortOrder;
|
pProfile->m_SortOrder = m_SortOrder;
|
||||||
if( m_PreferredDifficulty[pn] != DIFFICULTY_INVALID )
|
if( m_PreferredDifficulty[pn] != DIFFICULTY_INVALID )
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "Foreach.h"
|
#include "Foreach.h"
|
||||||
#include "CatalogXml.h"
|
#include "CatalogXml.h"
|
||||||
#include "Bookkeeper.h"
|
#include "Bookkeeper.h"
|
||||||
|
#include "Game.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Old file versions for backward compatibility
|
// Old file versions for backward compatibility
|
||||||
@@ -72,8 +73,6 @@ void Profile::InitGeneralData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_bUsingProfileDefaultModifiers = false;
|
|
||||||
m_sDefaultModifiers = "";
|
|
||||||
m_SortOrder = SORT_INVALID;
|
m_SortOrder = SORT_INVALID;
|
||||||
m_LastDifficulty = DIFFICULTY_INVALID;
|
m_LastDifficulty = DIFFICULTY_INVALID;
|
||||||
m_LastCourseDifficulty = DIFFICULTY_INVALID;
|
m_LastCourseDifficulty = DIFFICULTY_INVALID;
|
||||||
@@ -393,6 +392,33 @@ int Profile::GetSongNumTimesPlayed( const SongID& songID ) const
|
|||||||
return iTotalNumTimesPlayed;
|
return iTotalNumTimesPlayed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the profile default modifiers. Return true if set, in which case sModifiersOut
|
||||||
|
* will be set. Return false if no modifier string is set, in which case the theme
|
||||||
|
* defaults should be used. Note that the null string means "no modifiers are active",
|
||||||
|
* which is distinct from no modifier string being set at all.
|
||||||
|
*
|
||||||
|
* In practice, we get the default modifiers from the theme the first time a game
|
||||||
|
* is played, and from the profile every time thereafter.
|
||||||
|
*/
|
||||||
|
bool Profile::GetDefaultModifiers( const Game* pGameType, CString &sModifiersOut ) const
|
||||||
|
{
|
||||||
|
map<CString,CString>::const_iterator it;
|
||||||
|
it = m_sDefaultModifiers.find( pGameType->m_szName );
|
||||||
|
if( it == m_sDefaultModifiers.end() )
|
||||||
|
return false;
|
||||||
|
sModifiersOut = it->second;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Profile::SetDefaultModifiers( const Game* pGameType, const CString &sModifiers )
|
||||||
|
{
|
||||||
|
if( sModifiers == "" )
|
||||||
|
m_sDefaultModifiers.erase( pGameType->m_szName );
|
||||||
|
else
|
||||||
|
m_sDefaultModifiers[pGameType->m_szName] = sModifiers;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Steps high scores
|
// Steps high scores
|
||||||
//
|
//
|
||||||
@@ -733,8 +759,6 @@ XNode* Profile::SaveGeneralDataCreateNode() const
|
|||||||
pGeneralDataNode->AppendChild( "IsMachine", IsMachine() );
|
pGeneralDataNode->AppendChild( "IsMachine", IsMachine() );
|
||||||
|
|
||||||
pGeneralDataNode->AppendChild( "Guid", m_sGuid );
|
pGeneralDataNode->AppendChild( "Guid", m_sGuid );
|
||||||
pGeneralDataNode->AppendChild( "UsingProfileDefaultModifiers", m_bUsingProfileDefaultModifiers );
|
|
||||||
pGeneralDataNode->AppendChild( "DefaultModifiers", m_sDefaultModifiers );
|
|
||||||
pGeneralDataNode->AppendChild( "SortOrder", SortOrderToString(m_SortOrder) );
|
pGeneralDataNode->AppendChild( "SortOrder", SortOrderToString(m_SortOrder) );
|
||||||
pGeneralDataNode->AppendChild( "LastDifficulty", DifficultyToString(m_LastDifficulty) );
|
pGeneralDataNode->AppendChild( "LastDifficulty", DifficultyToString(m_LastDifficulty) );
|
||||||
pGeneralDataNode->AppendChild( "LastCourseDifficulty", CourseDifficultyToString(m_LastCourseDifficulty) );
|
pGeneralDataNode->AppendChild( "LastCourseDifficulty", CourseDifficultyToString(m_LastCourseDifficulty) );
|
||||||
@@ -761,6 +785,12 @@ XNode* Profile::SaveGeneralDataCreateNode() const
|
|||||||
// accidentally used where they're not intended. There's a lot of
|
// accidentally used where they're not intended. There's a lot of
|
||||||
// copying and pasting in this code.
|
// copying and pasting in this code.
|
||||||
|
|
||||||
|
{
|
||||||
|
XNode* pDefaultModifiers = pGeneralDataNode->AppendChild("DefaultModifiers");
|
||||||
|
for( map<CString,CString>::const_iterator it = m_sDefaultModifiers.begin(); it != m_sDefaultModifiers.end(); ++it )
|
||||||
|
pDefaultModifiers->AppendChild( it->first, it->second );
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
XNode* pUnlockedSongs = pGeneralDataNode->AppendChild("UnlockedSongs");
|
XNode* pUnlockedSongs = pGeneralDataNode->AppendChild("UnlockedSongs");
|
||||||
for( set<int>::const_iterator it = m_UnlockedSongs.begin(); it != m_UnlockedSongs.end(); ++it )
|
for( set<int>::const_iterator it = m_UnlockedSongs.begin(); it != m_UnlockedSongs.end(); ++it )
|
||||||
@@ -878,8 +908,6 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode )
|
|||||||
const XNode* pTemp;
|
const XNode* pTemp;
|
||||||
|
|
||||||
pNode->GetChildValue( "Guid", m_sGuid );
|
pNode->GetChildValue( "Guid", m_sGuid );
|
||||||
pNode->GetChildValue( "UsingProfileDefaultModifiers", m_bUsingProfileDefaultModifiers );
|
|
||||||
pNode->GetChildValue( "DefaultModifiers", m_sDefaultModifiers );
|
|
||||||
pNode->GetChildValue( "SortOrder", s ); m_SortOrder = StringToSortOrder( s );
|
pNode->GetChildValue( "SortOrder", s ); m_SortOrder = StringToSortOrder( s );
|
||||||
pNode->GetChildValue( "LastDifficulty", s ); m_LastDifficulty = StringToDifficulty( s );
|
pNode->GetChildValue( "LastDifficulty", s ); m_LastDifficulty = StringToDifficulty( s );
|
||||||
pNode->GetChildValue( "LastCourseDifficulty", s ); m_LastCourseDifficulty = StringToCourseDifficulty( s );
|
pNode->GetChildValue( "LastCourseDifficulty", s ); m_LastCourseDifficulty = StringToCourseDifficulty( s );
|
||||||
@@ -902,6 +930,17 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode )
|
|||||||
pNode->GetChildValue( "TotalMines", m_iTotalMines );
|
pNode->GetChildValue( "TotalMines", m_iTotalMines );
|
||||||
pNode->GetChildValue( "TotalHands", m_iTotalHands );
|
pNode->GetChildValue( "TotalHands", m_iTotalHands );
|
||||||
|
|
||||||
|
{
|
||||||
|
const XNode* pDefaultModifiers = pNode->GetChild("DefaultModifiers");
|
||||||
|
if( pDefaultModifiers )
|
||||||
|
{
|
||||||
|
FOREACH_Node( pDefaultModifiers, game_type )
|
||||||
|
{
|
||||||
|
m_sDefaultModifiers[game_type->name] = game_type->value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const XNode* pUnlockedSongs = pNode->GetChild("UnlockedSongs");
|
const XNode* pUnlockedSongs = pNode->GetChild("UnlockedSongs");
|
||||||
if( pUnlockedSongs )
|
if( pUnlockedSongs )
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ class Style;
|
|||||||
class Song;
|
class Song;
|
||||||
class Steps;
|
class Steps;
|
||||||
class Course;
|
class Course;
|
||||||
|
class Game;
|
||||||
|
|
||||||
class Profile
|
class Profile
|
||||||
{
|
{
|
||||||
@@ -72,6 +73,8 @@ public:
|
|||||||
static CString GetProfileDisplayNameFromDir( CString sDir );
|
static CString GetProfileDisplayNameFromDir( CString sDir );
|
||||||
int GetSongNumTimesPlayed( const Song* pSong ) const;
|
int GetSongNumTimesPlayed( const Song* pSong ) const;
|
||||||
int GetSongNumTimesPlayed( const SongID& songID ) const;
|
int GetSongNumTimesPlayed( const SongID& songID ) const;
|
||||||
|
bool GetDefaultModifiers( const Game* pGameType, CString &sModifiersOut ) const;
|
||||||
|
void SetDefaultModifiers( const Game* pGameType, const CString &sModifiers );
|
||||||
|
|
||||||
void AddStepTotals( int iNumTapsAndHolds, int iNumJumps, int iNumHolds, int iNumMines, int iNumHands );
|
void AddStepTotals( int iNumTapsAndHolds, int iNumJumps, int iNumHolds, int iNumMines, int iNumHands );
|
||||||
|
|
||||||
@@ -88,8 +91,7 @@ public:
|
|||||||
// General data
|
// General data
|
||||||
//
|
//
|
||||||
CString m_sGuid;
|
CString m_sGuid;
|
||||||
bool m_bUsingProfileDefaultModifiers;
|
map<CString,CString> m_sDefaultModifiers;
|
||||||
CString m_sDefaultModifiers;
|
|
||||||
SortOrder m_SortOrder;
|
SortOrder m_SortOrder;
|
||||||
Difficulty m_LastDifficulty;
|
Difficulty m_LastDifficulty;
|
||||||
CourseDifficulty m_LastCourseDifficulty;
|
CourseDifficulty m_LastCourseDifficulty;
|
||||||
|
|||||||
Reference in New Issue
Block a user