clean up presisting of settings to Profile
persist PreferredCourseDifficulty
This commit is contained in:
@@ -51,7 +51,7 @@ PlayMode Course::GetPlayMode() const
|
||||
|
||||
float Course::GetMeterForPlayer( PlayerNumber pn ) const
|
||||
{
|
||||
return GetMeter( GAMESTATE->m_CourseDifficulty[pn] );
|
||||
return GetMeter( GAMESTATE->m_PreferredCourseDifficulty[pn] );
|
||||
}
|
||||
|
||||
float Course::GetMeter( CourseDifficulty cd ) const
|
||||
|
||||
@@ -59,7 +59,7 @@ void CourseContentsList::SetFromCourse( const Course* pCourse )
|
||||
|
||||
vector<Course::Info> ci[NUM_PLAYERS];
|
||||
for( int pn = 0; pn < NUM_PLAYERS; ++pn )
|
||||
pCourse->GetCourseInfo( GAMESTATE->GetCurrentStyleDef()->m_StepsType, ci[pn], GAMESTATE->m_CourseDifficulty[pn] );
|
||||
pCourse->GetCourseInfo( GAMESTATE->GetCurrentStyleDef()->m_StepsType, ci[pn], GAMESTATE->m_PreferredCourseDifficulty[pn] );
|
||||
|
||||
m_iNumContents = 0;
|
||||
for( int i=0; i<min((int)ci[0].size(), MAX_TOTAL_CONTENTS); i++ )
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <time.h>
|
||||
#include "MemoryCardManager.h"
|
||||
#include "StageStats.h"
|
||||
#include "GameConstantsAndTypes.h"
|
||||
|
||||
#define DEFAULT_MODIFIERS THEME->GetMetric( "Common","DefaultModifiers" )
|
||||
|
||||
@@ -91,7 +92,7 @@ void GameState::Reset()
|
||||
for( p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
m_PreferredDifficulty[p] = DIFFICULTY_INVALID;
|
||||
m_CourseDifficulty[p] = COURSE_DIFFICULTY_REGULAR;
|
||||
m_PreferredCourseDifficulty[p] = COURSE_DIFFICULTY_REGULAR;
|
||||
}
|
||||
m_SortOrder = SORT_INVALID;
|
||||
m_PlayMode = PLAY_MODE_INVALID;
|
||||
@@ -208,8 +209,13 @@ void GameState::PlayersFinalized()
|
||||
GAMESTATE->m_PlayerOptions[pn].Init();
|
||||
GAMESTATE->ApplyModifiers( pn, pProfile->m_sDefaultModifiers );
|
||||
}
|
||||
// Only set the sort order if it wasn't already set by a ModeChoice
|
||||
if( m_SortOrder == SORT_INVALID )
|
||||
m_SortOrder = pProfile->m_SortOrder;
|
||||
if( pProfile->m_PreferredDifficulty != DIFFICULTY_INVALID )
|
||||
GAMESTATE->m_PreferredDifficulty[pn] = pProfile->m_PreferredDifficulty;
|
||||
if( pProfile->m_PreferredCourseDifficulty != COURSE_DIFFICULTY_INVALID )
|
||||
GAMESTATE->m_PreferredCourseDifficulty[pn] = pProfile->m_PreferredCourseDifficulty;
|
||||
}
|
||||
|
||||
|
||||
@@ -301,8 +307,15 @@ void GameState::EndGame()
|
||||
|
||||
Profile* pProfile = PROFILEMAN->GetProfile(pn);
|
||||
|
||||
// persist current settings
|
||||
pProfile->m_PreferredDifficulty = m_PreferredDifficulty[pn];
|
||||
// persist settings
|
||||
pProfile->m_bUsingProfileDefaultModifiers = true;
|
||||
pProfile->m_sDefaultModifiers = m_PlayerOptions[pn].GetString();
|
||||
if( IsSongSort(m_SortOrder) )
|
||||
pProfile->m_SortOrder = m_SortOrder;
|
||||
if( m_PreferredDifficulty[pn] != DIFFICULTY_INVALID )
|
||||
pProfile->m_PreferredDifficulty = m_PreferredDifficulty[pn];
|
||||
if( m_PreferredCourseDifficulty[pn] != COURSE_DIFFICULTY_INVALID )
|
||||
pProfile->m_PreferredCourseDifficulty = m_PreferredCourseDifficulty[pn];
|
||||
|
||||
PROFILEMAN->SaveProfile( pn );
|
||||
PROFILEMAN->UnloadProfile( pn );
|
||||
@@ -1305,7 +1318,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
|
||||
StepsType nt = this->GetCurrentStyleDef()->m_StepsType;
|
||||
Course* pCourse = this->m_pCurCourse;
|
||||
ASSERT( pCourse );
|
||||
CourseDifficulty cd = this->m_CourseDifficulty[pn];
|
||||
CourseDifficulty cd = this->m_PreferredCourseDifficulty[pn];
|
||||
|
||||
// Find Machine Records
|
||||
{
|
||||
@@ -1445,14 +1458,14 @@ bool GameState::IsTimeToPlayAttractSounds()
|
||||
|
||||
bool GameState::ChangeCourseDifficulty( PlayerNumber pn, int dir )
|
||||
{
|
||||
CourseDifficulty diff = (CourseDifficulty)(m_CourseDifficulty[pn]+dir);
|
||||
CourseDifficulty diff = (CourseDifficulty)(m_PreferredCourseDifficulty[pn]+dir);
|
||||
if( diff < 0 || diff >= NUM_COURSE_DIFFICULTIES )
|
||||
return false;
|
||||
|
||||
this->m_CourseDifficulty[pn] = diff;
|
||||
this->m_PreferredCourseDifficulty[pn] = diff;
|
||||
if( PREFSMAN->m_bLockCourseDifficulties )
|
||||
for( int p = 0; p < NUM_PLAYERS; ++p )
|
||||
m_CourseDifficulty[p] = m_CourseDifficulty[pn];
|
||||
m_PreferredCourseDifficulty[p] = m_PreferredCourseDifficulty[pn];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -49,16 +49,16 @@ public:
|
||||
//
|
||||
// Main state info
|
||||
//
|
||||
Game m_CurGame;
|
||||
Style m_CurStyle;
|
||||
bool m_bSideIsJoined[NUM_PLAYERS]; // left side, right side
|
||||
PlayMode m_PlayMode; // many screens display different info depending on this value
|
||||
int m_iCoins; // not "credits"
|
||||
PlayerNumber m_MasterPlayerNumber; // used in Styles where one player controls both sides
|
||||
bool m_bIsOnSystemMenu; // system screens will not be effected by the operator key -- Miryokuteki
|
||||
CourseDifficulty m_CourseDifficulty[NUM_PLAYERS]; // used in nonstop
|
||||
Game m_CurGame;
|
||||
Style m_CurStyle;
|
||||
bool m_bSideIsJoined[NUM_PLAYERS]; // left side, right side
|
||||
PlayMode m_PlayMode; // many screens display different info depending on this value
|
||||
int m_iCoins; // not "credits"
|
||||
PlayerNumber m_MasterPlayerNumber; // used in Styles where one player controls both sides
|
||||
bool m_bIsOnSystemMenu; // system screens will not be effected by the operator key -- Miryokuteki
|
||||
CourseDifficulty m_PreferredCourseDifficulty[NUM_PLAYERS]; // used in nonstop
|
||||
bool ChangeCourseDifficulty( PlayerNumber pn, int dir );
|
||||
RageTimer m_timeGameStarted; // from the moment the first player pressed Start
|
||||
RageTimer m_timeGameStarted; // from the moment the first player pressed Start
|
||||
|
||||
/* This is set to a random number per-game/round; it can be used for a random seed. */
|
||||
int m_iGameSeed, m_iRoundSeed;
|
||||
|
||||
@@ -86,7 +86,7 @@ bool ModeChoice::DescribesCurrentMode( PlayerNumber pn ) const
|
||||
return false;
|
||||
if( m_pCharacter && GAMESTATE->m_pCurCharacters[pn] != m_pCharacter )
|
||||
return false;
|
||||
if( m_CourseDifficulty != COURSE_DIFFICULTY_INVALID && GAMESTATE->m_CourseDifficulty[pn] != m_CourseDifficulty )
|
||||
if( m_CourseDifficulty != COURSE_DIFFICULTY_INVALID && GAMESTATE->m_PreferredCourseDifficulty[pn] != m_CourseDifficulty )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -322,10 +322,10 @@ void ModeChoice::Apply( PlayerNumber pn ) const
|
||||
GAMESTATE->m_pCurCharacters[pn] = m_pCharacter;
|
||||
if( m_CourseDifficulty != COURSE_DIFFICULTY_INVALID )
|
||||
{
|
||||
GAMESTATE->m_CourseDifficulty[pn] = m_CourseDifficulty;
|
||||
GAMESTATE->m_PreferredCourseDifficulty[pn] = m_CourseDifficulty;
|
||||
if( PREFSMAN->m_bLockCourseDifficulties )
|
||||
for( int p = 0; p < NUM_PLAYERS; ++p )
|
||||
GAMESTATE->m_CourseDifficulty[p] = GAMESTATE->m_CourseDifficulty[pn];
|
||||
GAMESTATE->m_PreferredCourseDifficulty[p] = GAMESTATE->m_PreferredCourseDifficulty[pn];
|
||||
}
|
||||
|
||||
// HACK: Set life type to BATTERY just once here so it happens once and
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "UnlockSystem.h"
|
||||
#include "ModeChoice.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "ProfileManager.h"
|
||||
|
||||
|
||||
#define FADE_SECONDS THEME->GetMetricF("MusicWheel","FadeSeconds")
|
||||
@@ -173,34 +172,21 @@ void MusicWheel::Load()
|
||||
GAMESTATE->m_SongOptions = so;
|
||||
}
|
||||
|
||||
if( GAMESTATE->m_SortOrder == SORT_INVALID )
|
||||
switch( GAMESTATE->m_PlayMode )
|
||||
{
|
||||
switch( GAMESTATE->m_PlayMode )
|
||||
// in course modes, force a particular sort
|
||||
case PLAY_MODE_ONI: GAMESTATE->m_SortOrder = SORT_ONI_COURSES; break;
|
||||
case PLAY_MODE_NONSTOP: GAMESTATE->m_SortOrder = SORT_NONSTOP_COURSES; break;
|
||||
case PLAY_MODE_ENDLESS: GAMESTATE->m_SortOrder = SORT_ENDLESS_COURSES; break;
|
||||
default:
|
||||
// if no player preferred sort, fall back to theme default
|
||||
if( GAMESTATE->m_SortOrder == SORT_INVALID )
|
||||
{
|
||||
case PLAY_MODE_ONI: GAMESTATE->m_SortOrder = SORT_ONI_COURSES; break;
|
||||
case PLAY_MODE_NONSTOP: GAMESTATE->m_SortOrder = SORT_NONSTOP_COURSES; break;
|
||||
case PLAY_MODE_ENDLESS: GAMESTATE->m_SortOrder = SORT_ENDLESS_COURSES; break;
|
||||
default:
|
||||
// look for a player's saved sort
|
||||
FOREACH_HumanPlayer( pn )
|
||||
{
|
||||
if( PROFILEMAN->IsUsingProfile(pn) )
|
||||
{
|
||||
GAMESTATE->m_SortOrder = PROFILEMAN->GetProfile(pn)->m_SortOrder;
|
||||
if( GAMESTATE->m_SortOrder != SORT_INVALID ) // we found one
|
||||
break; // stop searching
|
||||
}
|
||||
}
|
||||
|
||||
// if no player preferred sort, fall back to theme default
|
||||
if( GAMESTATE->m_SortOrder == SORT_INVALID )
|
||||
{
|
||||
GAMESTATE->m_SortOrder = StringToSortOrder( DEFAULT_SORT );
|
||||
ASSERT( GAMESTATE->m_SortOrder != SORT_INVALID );
|
||||
}
|
||||
|
||||
break;
|
||||
GAMESTATE->m_SortOrder = StringToSortOrder( DEFAULT_SORT );
|
||||
ASSERT( GAMESTATE->m_SortOrder != SORT_INVALID );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update for SORT_MOST_PLAYED. */
|
||||
@@ -1171,17 +1157,6 @@ bool MusicWheel::ChangeSort( SortOrder new_so ) // return true if change success
|
||||
m_LastSortOrder = GAMESTATE->m_SortOrder;
|
||||
GAMESTATE->m_SortOrder = new_so;
|
||||
|
||||
// Save the new sort to all profiles
|
||||
// HACK: Don't save course sorts
|
||||
if( IsSongSort(new_so) )
|
||||
{
|
||||
FOREACH_HumanPlayer( pn )
|
||||
{
|
||||
if( PROFILEMAN->IsUsingProfile(pn) )
|
||||
PROFILEMAN->GetProfile(pn)->m_SortOrder = new_so;
|
||||
}
|
||||
}
|
||||
|
||||
m_WheelState = STATE_FLYING_OFF_BEFORE_NEXT_SORT;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ void PaneDisplay::SetContent( PaneContents c )
|
||||
else if( g_Contents[c].req&NEED_COURSE )
|
||||
{
|
||||
vector<Course::Info> ci;
|
||||
CourseDifficulty cd = GAMESTATE->m_CourseDifficulty[m_PlayerNumber];
|
||||
CourseDifficulty cd = GAMESTATE->m_PreferredCourseDifficulty[m_PlayerNumber];
|
||||
StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType;
|
||||
rv = GAMESTATE->m_pCurCourse->GetRadarValues( st, cd );
|
||||
}
|
||||
@@ -167,7 +167,7 @@ void PaneDisplay::SetContent( PaneContents c )
|
||||
const Steps *pSteps = GAMESTATE->m_pCurNotes[m_PlayerNumber];
|
||||
StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType;
|
||||
const Course *pCourse = GAMESTATE->m_pCurCourse;
|
||||
const CourseDifficulty cd = GAMESTATE->m_CourseDifficulty[m_PlayerNumber];
|
||||
const CourseDifficulty cd = GAMESTATE->m_PreferredCourseDifficulty[m_PlayerNumber];
|
||||
|
||||
float val = 0;
|
||||
CString str;
|
||||
|
||||
@@ -70,6 +70,7 @@ void Profile::InitGeneralData()
|
||||
m_sDefaultModifiers = "";
|
||||
m_SortOrder = SORT_INVALID;
|
||||
m_PreferredDifficulty = DIFFICULTY_INVALID;
|
||||
m_PreferredCourseDifficulty = COURSE_DIFFICULTY_INVALID;
|
||||
m_iTotalPlays = 0;
|
||||
m_iTotalPlaySeconds = 0;
|
||||
m_iTotalGameplaySeconds = 0;
|
||||
@@ -570,6 +571,7 @@ XNode* Profile::SaveGeneralDataCreateNode() const
|
||||
pGeneralDataNode->AppendChild( "DefaultModifiers", m_sDefaultModifiers );
|
||||
pGeneralDataNode->AppendChild( "SortOrder", SortOrderToString(m_SortOrder) );
|
||||
pGeneralDataNode->AppendChild( "PreferredDifficulty", DifficultyToString(m_PreferredDifficulty) );
|
||||
pGeneralDataNode->AppendChild( "PreferredCourseDifficulty", CourseDifficultyToString(m_PreferredCourseDifficulty) );
|
||||
pGeneralDataNode->AppendChild( "TotalPlays", m_iTotalPlays );
|
||||
pGeneralDataNode->AppendChild( "TotalPlaySeconds", m_iTotalPlaySeconds );
|
||||
pGeneralDataNode->AppendChild( "TotalGameplaySeconds", m_iTotalGameplaySeconds );
|
||||
@@ -702,13 +704,13 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode )
|
||||
{
|
||||
ASSERT( pNode->name == "GeneralData" );
|
||||
|
||||
CString s;
|
||||
|
||||
pNode->GetChildValue( "UsingProfileDefaultModifiers", m_bUsingProfileDefaultModifiers );
|
||||
pNode->GetChildValue( "DefaultModifiers", m_sDefaultModifiers );
|
||||
CString s;
|
||||
pNode->GetChildValue( "SortOrder", s );
|
||||
m_SortOrder = StringToSortOrder( s );
|
||||
pNode->GetChildValue( "PreferredDifficulty", s );
|
||||
m_PreferredDifficulty = StringToDifficulty( s );
|
||||
pNode->GetChildValue( "SortOrder", s ); m_SortOrder = StringToSortOrder( s );
|
||||
pNode->GetChildValue( "PreferredDifficulty", s ); m_PreferredDifficulty = StringToDifficulty( s );
|
||||
pNode->GetChildValue( "PreferredCourseDifficulty", s ); m_PreferredCourseDifficulty = StringToCourseDifficulty( s );
|
||||
pNode->GetChildValue( "TotalPlays", m_iTotalPlays );
|
||||
pNode->GetChildValue( "TotalPlaySeconds", m_iTotalPlaySeconds );
|
||||
pNode->GetChildValue( "TotalGameplaySeconds", m_iTotalGameplaySeconds );
|
||||
|
||||
@@ -90,6 +90,7 @@ public:
|
||||
CString m_sDefaultModifiers;
|
||||
SortOrder m_SortOrder;
|
||||
Difficulty m_PreferredDifficulty;
|
||||
CourseDifficulty m_PreferredCourseDifficulty;
|
||||
int m_iTotalPlays;
|
||||
int m_iTotalPlaySeconds;
|
||||
int m_iTotalGameplaySeconds;
|
||||
|
||||
@@ -912,7 +912,7 @@ void ScreenEvaluation::CommitScores( const StageStats &stageStats, int iPersonal
|
||||
case course:
|
||||
{
|
||||
Course* pCourse = GAMESTATE->m_pCurCourse;
|
||||
CourseDifficulty cd = GAMESTATE->m_CourseDifficulty[p];
|
||||
CourseDifficulty cd = GAMESTATE->m_PreferredCourseDifficulty[p];
|
||||
ASSERT( pCourse );
|
||||
|
||||
// don't save scores for a failed Nonstop
|
||||
|
||||
@@ -176,12 +176,12 @@ void ScreenGameplay::Init()
|
||||
if( !m_bDemonstration )
|
||||
for( p=0; p<NUM_PLAYERS; p++ )
|
||||
if( GAMESTATE->IsPlayerEnabled(p) )
|
||||
PROFILEMAN->IncrementCoursePlayCount( GAMESTATE->m_pCurCourse, st, GAMESTATE->m_CourseDifficulty[p], (PlayerNumber)p );
|
||||
PROFILEMAN->IncrementCoursePlayCount( GAMESTATE->m_pCurCourse, st, GAMESTATE->m_PreferredCourseDifficulty[p], (PlayerNumber)p );
|
||||
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
vector<Course::Info> ci;
|
||||
GAMESTATE->m_pCurCourse->GetCourseInfo( GAMESTATE->GetCurrentStyleDef()->m_StepsType, ci, GAMESTATE->m_CourseDifficulty[p] );
|
||||
GAMESTATE->m_pCurCourse->GetCourseInfo( GAMESTATE->GetCurrentStyleDef()->m_StepsType, ci, GAMESTATE->m_PreferredCourseDifficulty[p] );
|
||||
|
||||
m_apNotesQueue[p].clear();
|
||||
m_asModifiersQueue[p].clear();
|
||||
|
||||
@@ -322,7 +322,7 @@ ScreenNameEntryTraditional::ScreenNameEntryTraditional( CString sClassName ) : S
|
||||
|
||||
const HighScoreList& hsl =
|
||||
GAMESTATE->IsCourseMode() ?
|
||||
PROFILEMAN->GetMachineProfile()->GetCourseHighScoreList(pCourse, GAMESTATE->GetCurrentStyleDef()->m_StepsType, GAMESTATE->m_CourseDifficulty[p]) :
|
||||
PROFILEMAN->GetMachineProfile()->GetCourseHighScoreList(pCourse, GAMESTATE->GetCurrentStyleDef()->m_StepsType, GAMESTATE->m_PreferredCourseDifficulty[p]) :
|
||||
PROFILEMAN->GetMachineProfile()->GetStepsHighScoreList(pSteps);
|
||||
|
||||
for( unsigned h=0; h<hsl.vHighScores.size(); h++ )
|
||||
@@ -367,7 +367,7 @@ ScreenNameEntryTraditional::ScreenNameEntryTraditional( CString sClassName ) : S
|
||||
m_FeatDisplay[p][i].m_Difficulty.SetName( ssprintf("DifficultyP%i",p+1) );
|
||||
m_FeatDisplay[p][i].m_Difficulty.Load( THEME->GetPathToG(ssprintf("ScreenNameEntryTraditional difficulty icons 1x%d",NUM_DIFFICULTIES)) );
|
||||
if( GAMESTATE->IsCourseMode() )
|
||||
m_FeatDisplay[p][i].m_Difficulty.SetFromCourseDifficulty( (PlayerNumber)p, GAMESTATE->m_CourseDifficulty[p] );
|
||||
m_FeatDisplay[p][i].m_Difficulty.SetFromCourseDifficulty( (PlayerNumber)p, GAMESTATE->m_PreferredCourseDifficulty[p] );
|
||||
else
|
||||
m_FeatDisplay[p][i].m_Difficulty.SetFromNotes( (PlayerNumber)p, pSteps );
|
||||
SET_ON( m_FeatDisplay[p][i].m_Difficulty );
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "ScreenSongOptions.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "CodeDetector.h"
|
||||
#include "ProfileManager.h"
|
||||
|
||||
|
||||
#define PREV_SCREEN( play_mode ) THEME->GetMetric ("ScreenPlayerOptions","PrevScreen"+Capitalize(PlayModeToString(play_mode)))
|
||||
@@ -171,22 +170,6 @@ void ScreenPlayerOptions::HandleScreenMessage( const ScreenMessage SM )
|
||||
ScreenOptionsMaster::HandleScreenMessage( SM );
|
||||
}
|
||||
|
||||
void ScreenPlayerOptions::ExportOptions()
|
||||
{
|
||||
ScreenOptionsMaster::ExportOptions();
|
||||
|
||||
// automatically save all options to profile
|
||||
FOREACH_HumanPlayer( pn )
|
||||
{
|
||||
if( PROFILEMAN->IsUsingProfile(pn) )
|
||||
{
|
||||
Profile* pProfile = PROFILEMAN->GetProfile(pn);
|
||||
pProfile->m_bUsingProfileDefaultModifiers = true;
|
||||
pProfile->m_sDefaultModifiers = GAMESTATE->m_PlayerOptions[pn].GetString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenPlayerOptions::UpdateDisqualified()
|
||||
{
|
||||
// save current player options
|
||||
|
||||
@@ -25,8 +25,6 @@ private:
|
||||
void GoToNextState();
|
||||
void GoToPrevState();
|
||||
|
||||
virtual void ExportOptions();
|
||||
|
||||
void UpdateDisqualified();
|
||||
|
||||
bool m_bAcceptedChoices;
|
||||
|
||||
@@ -415,7 +415,7 @@ void ScreenSelectCourse::AfterCourseChange()
|
||||
ASSERT(pCourse);
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
CourseDifficulty cd = GAMESTATE->m_CourseDifficulty[p];
|
||||
CourseDifficulty cd = GAMESTATE->m_PreferredCourseDifficulty[p];
|
||||
|
||||
Profile* pProfile;
|
||||
if( PROFILEMAN->IsUsingProfile( (PlayerNumber)p ) )
|
||||
|
||||
Reference in New Issue
Block a user