add option to save modifiers to profile

This commit is contained in:
Chris Danford
2003-11-10 04:32:12 +00:00
parent dd55bbf4b1
commit 0dfed02a29
6 changed files with 65 additions and 10 deletions
+3 -2
View File
@@ -1993,7 +1993,7 @@ BannerWidth=564
BannerHeight=184 BannerHeight=184
[LyricDisplay] [LyricDisplay]
InCommand=shadowlength,0;diffusealpha,0;linear,0.2;diffusealpha,0.5 InCommand=shadowlength,0;diffusealpha,0;linear,0.2;diffusealpha,0.6
OutCommand=linear,0.2;diffusealpha,0 OutCommand=linear,0.2;diffusealpha,0
WipeDimFactor=0.5,0.5,0.5,0.5 WipeDimFactor=0.5,0.5,0.5,0.5
@@ -2725,7 +2725,7 @@ StyleIcon=0
PrevScreen= PrevScreen=
NextScreen= NextScreen=
OptionMenuFlags=rows,14 OptionMenuFlags=rows,15
Line1=list,Speed Line1=list,Speed
Line2=list,Accel Line2=list,Accel
@@ -2741,6 +2741,7 @@ Line11=list,Hide
Line12=list,Persp Line12=list,Persp
Line13=Steps Line13=Steps
Line14=Characters Line14=Characters
Line15=SaveToProfile
[ScreenRaveOptions] [ScreenRaveOptions]
PrevScreen=ScreenSelectMusic PrevScreen=ScreenSelectMusic
+12 -2
View File
@@ -18,6 +18,7 @@
#include "IniFile.h" #include "IniFile.h"
#include "GameConstantsAndTypes.h" #include "GameConstantsAndTypes.h"
#include "SongManager.h" #include "SongManager.h"
#include "GameState.h"
ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our program ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our program
@@ -76,12 +77,17 @@ bool ProfileManager::LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIs
return false; return false;
} }
//
// Load scores into SONGMAN // Load scores into SONGMAN
//
SONGMAN->ReadStepsMemCardDataFromFile( m_sProfileDir[pn]+STEPS_MEM_CARD_DATA_FILE, (MemoryCard)pn ); SONGMAN->ReadStepsMemCardDataFromFile( m_sProfileDir[pn]+STEPS_MEM_CARD_DATA_FILE, (MemoryCard)pn );
SONGMAN->ReadCourseMemCardDataFromFile( m_sProfileDir[pn]+COURSE_MEM_CARD_DATA_FILE, (MemoryCard)pn ); SONGMAN->ReadCourseMemCardDataFromFile( m_sProfileDir[pn]+COURSE_MEM_CARD_DATA_FILE, (MemoryCard)pn );
// apply saved default modifiers if any
if( m_Profile[pn].m_bUsingProfileDefaultModifiers )
{
GAMESTATE->m_PlayerOptions[pn].Init();
GAMESTATE->ApplyModifiers( pn, m_Profile[pn].m_sDefaultModifiers );
}
return true; return true;
} }
@@ -272,6 +278,8 @@ bool Profile::LoadFromIni( CString sIniPath )
ini.GetValue( "Profile", "DisplayName", m_sName ); ini.GetValue( "Profile", "DisplayName", m_sName );
ini.GetValue( "Profile", "LastUsedHighScoreName", m_sLastUsedHighScoreName ); ini.GetValue( "Profile", "LastUsedHighScoreName", m_sLastUsedHighScoreName );
ini.GetValue( "Profile", "UsingProfileDefaultModifiers", m_bUsingProfileDefaultModifiers );
ini.GetValue( "Profile", "DefaultModifiers", m_sDefaultModifiers );
return true; return true;
} }
@@ -280,6 +288,8 @@ bool Profile::SaveToIni( CString sIniPath )
IniFile ini( sIniPath ); IniFile ini( sIniPath );
ini.SetValue( "Profile", "DisplayName", m_sName ); ini.SetValue( "Profile", "DisplayName", m_sName );
ini.SetValue( "Profile", "LastUsedHighScoreName", m_sLastUsedHighScoreName ); ini.SetValue( "Profile", "LastUsedHighScoreName", m_sLastUsedHighScoreName );
ini.SetValue( "Profile", "UsingProfileDefaultModifiers", m_bUsingProfileDefaultModifiers );
ini.SetValue( "Profile", "DefaultModifiers", m_sDefaultModifiers );
ini.WriteFile(); ini.WriteFile();
return true; return true;
} }
+4
View File
@@ -22,12 +22,16 @@ struct Profile
{ {
m_sName = ""; m_sName = "";
m_sLastUsedHighScoreName = ""; m_sLastUsedHighScoreName = "";
m_bUsingProfileDefaultModifiers = false;
m_sDefaultModifiers = "";
} }
bool LoadFromIni( CString sIniPath ); bool LoadFromIni( CString sIniPath );
bool SaveToIni( CString sIniPath ); bool SaveToIni( CString sIniPath );
CString m_sName; CString m_sName;
CString m_sLastUsedHighScoreName; CString m_sLastUsedHighScoreName;
bool m_bUsingProfileDefaultModifiers;
CString m_sDefaultModifiers;
}; };
class ProfileManager class ProfileManager
+37
View File
@@ -19,6 +19,7 @@
#include "RageSounds.h" #include "RageSounds.h"
#include "StepMania.h" #include "StepMania.h"
#include "RageSoundManager.h" #include "RageSoundManager.h"
#include "ProfileManager.h"
#define OPTION_MENU_FLAGS THEME->GetMetric (m_sName,"OptionMenuFlags") #define OPTION_MENU_FLAGS THEME->GetMetric (m_sName,"OptionMenuFlags")
#define ROW_LINE(i) THEME->GetMetric (m_sName,ssprintf("Line%i",(i+1))) #define ROW_LINE(i) THEME->GetMetric (m_sName,ssprintf("Line%i",(i+1)))
@@ -39,6 +40,7 @@
#define HARD_DESCRIPTION THEME->GetMetric ("ScreenOptionsMaster","Hard") #define HARD_DESCRIPTION THEME->GetMetric ("ScreenOptionsMaster","Hard")
#define CHALLENGE_DESCRIPTION THEME->GetMetric ("ScreenOptionsMaster","Challenge") #define CHALLENGE_DESCRIPTION THEME->GetMetric ("ScreenOptionsMaster","Challenge")
CString ScreenOptionsMaster::ConvertParamToThemeDifficulty( const CString &in ) const CString ScreenOptionsMaster::ConvertParamToThemeDifficulty( const CString &in ) const
{ {
switch( StringToDifficulty(in) ) switch( StringToDifficulty(in) )
@@ -176,6 +178,15 @@ void ScreenOptionsMaster::SetCharacter( OptionRow &row, OptionRowHandler &hand )
} }
} }
/* Add a list of available characters to the given row/handler. */
void ScreenOptionsMaster::SetSaveToProfile( OptionRow &row, OptionRowHandler &hand )
{
hand.type = ROW_SAVE_TO_PROFILE;
row.bOneChoiceForAllPlayers = false;
row.choices.push_back( "DON'T SAVE" );
row.choices.push_back( "SAVE TO PROFILE" );
}
ScreenOptionsMaster::ScreenOptionsMaster( CString sClassName ): ScreenOptionsMaster::ScreenOptionsMaster( CString sClassName ):
ScreenOptions( sClassName ) ScreenOptions( sClassName )
{ {
@@ -257,6 +268,11 @@ ScreenOptionsMaster::ScreenOptionsMaster( CString sClassName ):
SetCharacter( row, hand ); SetCharacter( row, hand );
row.name = "Characters"; row.name = "Characters";
} }
else if( !name.CompareNoCase("SaveToProfile") )
{
SetSaveToProfile( row, hand );
row.name = "Save To\nProfile";
}
else else
RageException::Throw( "Unexpected type '%s' in %s::Line%i", name.c_str(), m_sName.c_str(), i ); RageException::Throw( "Unexpected type '%s' in %s::Line%i", name.c_str(), m_sName.c_str(), i );
} }
@@ -350,6 +366,9 @@ int ScreenOptionsMaster::ImportOption( const OptionRow &row, const OptionRowHand
case ROW_CONFIG: case ROW_CONFIG:
return hand.opt->Get( row.choices ); return hand.opt->Get( row.choices );
case ROW_SAVE_TO_PROFILE:
return 0;
default: default:
ASSERT(0); ASSERT(0);
return 0; return 0;
@@ -451,6 +470,19 @@ int ScreenOptionsMaster::ExportOption( const OptionRow &row, const OptionRowHand
} }
break; break;
case ROW_SAVE_TO_PROFILE:
if( sel == 1 )
{
if( PROFILEMAN->IsUsingProfile((PlayerNumber)pn) )
{
Profile* pProfile = PROFILEMAN->GetProfile((PlayerNumber)pn);
pProfile->m_bUsingProfileDefaultModifiers = true;
pProfile->m_sDefaultModifiers = GAMESTATE->m_PlayerOptions[pn].GetString();
}
}
break;
default: default:
ASSERT(0); ASSERT(0);
break; break;
@@ -527,6 +559,11 @@ void ScreenOptionsMaster::ExportOptions()
{ {
SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume ); SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume );
} }
if( ChangeMask & OPT_SAVE_MODIFIERS_TO_PROFILE )
{
SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume );
}
} }
void ScreenOptionsMaster::MenuStart( PlayerNumber pn ) void ScreenOptionsMaster::MenuStart( PlayerNumber pn )
+3 -1
View File
@@ -19,7 +19,8 @@ private:
ROW_LIST, /* list of custom settings */ ROW_LIST, /* list of custom settings */
ROW_STEP, /* list of steps for the current song or course */ ROW_STEP, /* list of steps for the current song or course */
ROW_CHARACTER, /* list of characters */ ROW_CHARACTER, /* list of characters */
ROW_CONFIG, ROW_CONFIG, /* global pref */
ROW_SAVE_TO_PROFILE, /* save new options to profile? */
NUM_OPTION_ROW_TYPES NUM_OPTION_ROW_TYPES
}; };
@@ -48,6 +49,7 @@ private:
void SetStep( OptionRow &row, OptionRowHandler &hand ); void SetStep( OptionRow &row, OptionRowHandler &hand );
void SetConf( OptionRow &row, OptionRowHandler &hand, CString param, CString &TitleOut ); void SetConf( OptionRow &row, OptionRowHandler &hand, CString param, CString &TitleOut );
void SetCharacter( OptionRow &row, OptionRowHandler &hand ); void SetCharacter( OptionRow &row, OptionRowHandler &hand );
void SetSaveToProfile( OptionRow &row, OptionRowHandler &hand );
protected: protected:
virtual void MenuStart( PlayerNumber pn ); virtual void MenuStart( PlayerNumber pn );
+1
View File
@@ -7,6 +7,7 @@ static const int MAX_OPTIONS=16;
#define OPT_APPLY_THEME 0x4 #define OPT_APPLY_THEME 0x4
#define OPT_RESET_GAME 0x8 #define OPT_RESET_GAME 0x8
#define OPT_APPLY_SOUND 0x16 #define OPT_APPLY_SOUND 0x16
#define OPT_SAVE_MODIFIERS_TO_PROFILE 0x32
struct ConfOption struct ConfOption
{ {