working on profiles stored on machine (intermediate step toward memory card support)

This commit is contained in:
Chris Danford
2003-09-08 03:26:58 +00:00
parent a7e3700ab2
commit 3736845d3e
13 changed files with 287 additions and 4 deletions
+8 -1
View File
@@ -1953,6 +1953,13 @@ HelpText=&UP; &DOWN; to change line &LEFT; &RIGHT; to select between options::
AutogenMissingTypes=Show steps for songs that were created by Autogen. AutogenMissingTypes=Show steps for songs that were created by Autogen.
AutogenGroupCourses=Show group Nonstop and Endless courses that::were created by Autogen. AutogenGroupCourses=Show group Nonstop and Endless courses that::were created by Autogen.
[ScreenProfileOptions]
HelpText=&UP; &DOWN; to change line &LEFT; &RIGHT; to select between options::START to accept changes BACK to discard changes
Player1Profile=
Player2Profile=
CreateNew=
Delete=
[ScreenUnlock] [ScreenUnlock]
UseUnlocksDat=1 UseUnlocksDat=1
TypeOfPointsToDisplay=DP TypeOfPointsToDisplay=DP
@@ -2265,7 +2272,7 @@ AppearanceOptions=
SoundOptions= SoundOptions=
AutogenOptions= AutogenOptions=
BackgroundOptions= BackgroundOptions=
AutoAdjustGraphicDetail= ProfileOptions=
ReloadSongs/Courses= ReloadSongs/Courses=
[TextBanner] [TextBanner]
+4
View File
@@ -27,6 +27,7 @@
#include "Character.h" #include "Character.h"
#include "UnlockSystem.h" #include "UnlockSystem.h"
#include "AnnouncerManager.h" #include "AnnouncerManager.h"
#include "ProfileManager.h"
#include "arch/arch.h" #include "arch/arch.h"
@@ -118,6 +119,9 @@ void GameState::Reset()
m_fSuperMeterGrowthScale[p] = 1; m_fSuperMeterGrowthScale[p] = 1;
m_iCpuSkill[p] = 5; m_iCpuSkill[p] = 5;
} }
for( p=0; p<NUM_PLAYERS; p++ )
PROFILEMAN->UnloadProfile( (PlayerNumber)p );
} }
void GameState::Update( float fDelta ) void GameState::Update( float fDelta )
+6 -2
View File
@@ -6,6 +6,7 @@
#include "GameState.h" #include "GameState.h"
#include "RageDisplay.h" #include "RageDisplay.h"
#include "AnnouncerManager.h" #include "AnnouncerManager.h"
#include "ProfileManager.h"
#include "arch/ArchHooks/ArchHooks.h" #include "arch/ArchHooks/ArchHooks.h"
void ModeChoice::Init() void ModeChoice::Init()
@@ -137,8 +138,11 @@ void ModeChoice::Apply( PlayerNumber pn )
if( sAnnouncer != "" ) if( sAnnouncer != "" )
ANNOUNCER->SwitchAnnouncer( sAnnouncer ); ANNOUNCER->SwitchAnnouncer( sAnnouncer );
// HACK: Set life type to BATTERY just once here so we don't // HACK: Set life type to BATTERY just once here so it happens once and
// override the user's changes if they back out. // we don't override the user's changes if they back out.
if( GAMESTATE->m_PlayMode == PLAY_MODE_ONI ) if( GAMESTATE->m_PlayMode == PLAY_MODE_ONI )
GAMESTATE->m_SongOptions.m_LifeType = SongOptions::LIFE_BATTERY; GAMESTATE->m_SongOptions.m_LifeType = SongOptions::LIFE_BATTERY;
PROFILEMAN->TryLoadProfile( pn );
} }
+5
View File
@@ -136,6 +136,7 @@ PrefsManager::PrefsManager()
m_bVsync = true; m_bVsync = true;
m_sLanguage = ""; // ThemeManager will deal with this invalid language m_sLanguage = ""; // ThemeManager will deal with this invalid language
/* XXX: Set these defaults for individual consoles using VideoCardDefaults.ini. */ /* XXX: Set these defaults for individual consoles using VideoCardDefaults.ini. */
#ifdef _XBOX #ifdef _XBOX
m_bInterlaced = true; m_bInterlaced = true;
@@ -274,6 +275,8 @@ void PrefsManager::ReadGlobalPrefsFromDisk( bool bSwitchToLastPlayedGame )
ini.GetValueB( "Options", "ShowLogWindow", m_bShowLogWindow ); ini.GetValueB( "Options", "ShowLogWindow", m_bShowLogWindow );
ini.GetValueB( "Options", "ShowBeginnerHelper", m_bShowBeginnerHelper ); ini.GetValueB( "Options", "ShowBeginnerHelper", m_bShowBeginnerHelper );
ini.GetValue ( "Options", "Language", m_sLanguage ); ini.GetValue ( "Options", "Language", m_sLanguage );
for( int p=0; p<NUM_PLAYERS; p++ )
ini.GetValue ( "Options", ssprintf("DefaultProfileP%d",p+1), m_sDefaultProfile[p] );
m_asAdditionalSongFolders.clear(); m_asAdditionalSongFolders.clear();
@@ -389,6 +392,8 @@ void PrefsManager::SaveGlobalPrefsToDisk()
ini.SetValueI( "Options", "ProgressiveNonstopLifebar", m_iProgressiveNonstopLifebar ); ini.SetValueI( "Options", "ProgressiveNonstopLifebar", m_iProgressiveNonstopLifebar );
ini.SetValueB( "Options", "ShowBeginnerHelper", m_bShowBeginnerHelper ); ini.SetValueB( "Options", "ShowBeginnerHelper", m_bShowBeginnerHelper );
ini.SetValue ( "Options", "Language", m_sLanguage ); ini.SetValue ( "Options", "Language", m_sLanguage );
for( int p=0; p<NUM_PLAYERS; p++ )
ini.SetValue ( "Options", ssprintf("DefaultProfileP%d",p+1), m_sDefaultProfile[p] );
/* Only write these if they aren't the default. This ensures that we can change /* Only write these if they aren't the default. This ensures that we can change
* the default and have it take effect for everyone (except people who * the default and have it take effect for everyone (except people who
+2
View File
@@ -11,6 +11,7 @@
Chris Gomez Chris Gomez
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
*/ */
#include "PlayerNumber.h"
class PrefsManager class PrefsManager
{ {
@@ -96,6 +97,7 @@ public:
int m_iProgressiveNonstopLifebar; int m_iProgressiveNonstopLifebar;
bool m_bShowBeginnerHelper; bool m_bShowBeginnerHelper;
CString m_sLanguage; CString m_sLanguage;
CString m_sDefaultProfile[NUM_PLAYERS]; // directory name of profile on HD
// course ranking // course ranking
enum { COURSE_SORT_SONGS, COURSE_SORT_METER, COURSE_SORT_METER_SUM, COURSE_SORT_RANK } m_iCourseSortOrder; enum { COURSE_SORT_SONGS, COURSE_SORT_METER, COURSE_SORT_METER_SUM, COURSE_SORT_RANK } m_iCourseSortOrder;
+78
View File
@@ -0,0 +1,78 @@
#include "global.h"
/*
-----------------------------------------------------------------------------
Class: ProfileManager
Desc: See header.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "ProfileManager.h"
#include "RageUtil.h"
#include "arch/arch.h"
#include "PrefsManager.h"
#include "RageLog.h"
#include "IniFile.h"
ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our program
#define PROFILES_DIR BASE_PATH "Data" SLASH "Profiles" SLASH
#define PROFILE_FILE "Profile.ini"
ProfileManager::ProfileManager()
{
for( int p=0; p<NUM_PLAYERS; p++ )
m_bUsingMemoryCard[p] = false;
}
ProfileManager::~ProfileManager()
{
}
void ProfileManager::GetProfileNames( vector<CString> &asNamesOut )
{
// don't pick up the profile named "Machine"
GetDirListing( PROFILES_DIR "0*", asNamesOut, true, false );
}
void ProfileManager::TryLoadProfile( PlayerNumber pn )
{
CString sProfile = PREFSMAN->m_sDefaultProfile[pn];
if( sProfile.empty() )
return;
vector<CString> vsProfiles;
GetProfileNames( vsProfiles );
if( find(vsProfiles.begin(), vsProfiles.end(), "sProfile") == vsProfiles.end() )
{
LOG->Warn( "Default profile '%s' does not exist", sProfile.c_str() );
return;
}
m_sProfileDir[pn] = PROFILES_DIR + sProfile + SLASH;
IniFile ini( m_sProfileDir[pn]+PROFILE_FILE );
ini.ReadFile();
m_sDisplayName[pn] = ssprintf("No Name");
ini.GetValue( "Profile", "DisplayName", m_sDisplayName[pn] );
}
void ProfileManager::UnloadProfile( PlayerNumber pn )
{
if( m_sProfileDir[pn].empty() )
return;
IniFile ini( m_sProfileDir[pn]+PROFILE_FILE );
ini.SetValue( "Profile", "DisplayName", m_sDisplayName[pn] );
ini.WriteFile();
}
+48
View File
@@ -0,0 +1,48 @@
#ifndef ProfileManager_H
#define ProfileManager_H
/*
-----------------------------------------------------------------------------
Class: ProfileManager
Desc: Interface to profiles that exist on the machine or a memory card
plugged into the machine.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "PlayerNumber.h"
class ProfileManager
{
public:
ProfileManager();
~ProfileManager();
void GetProfileNames( vector<CString> &asNamesOut );
void TryLoadProfile( PlayerNumber pn );
void UnloadProfile( PlayerNumber pn );
CString sGetDisplayName( PlayerNumber pn ) { ASSERT(!m_sProfileDir[pn].empty()); return m_sProfileDir[pn]; }
bool IsUsingProfile( PlayerNumber pn ) { return !m_sProfileDir[pn].empty(); }
bool IsMemoryCardInserted( PlayerNumber pn ) { return false; }
bool IsMemoryCardValid( PlayerNumber pn ) { return false; }
bool IsUsingMemoryCard( PlayerNumber pn ) { return m_bUsingMemoryCard[pn]; }
private:
CString m_sProfileDir[NUM_PLAYERS];
bool m_bUsingMemoryCard[NUM_PLAYERS];
// cached from profile.ini
CString m_sDisplayName[NUM_PLAYERS];
};
extern ProfileManager* PROFILEMAN; // global and accessable from anywhere in our program
#endif
+2
View File
@@ -298,6 +298,7 @@ void Screen::ClearMessageQueue( const ScreenMessage SM )
#include "ScreenBackgroundOptions.h" #include "ScreenBackgroundOptions.h"
#include "ScreenSelectMaster.h" #include "ScreenSelectMaster.h"
#include "ScreenEditCoursesMenu.h" #include "ScreenEditCoursesMenu.h"
#include "ScreenProfileOptions.h"
Screen* Screen::Create( CString sClassName ) Screen* Screen::Create( CString sClassName )
{ {
@@ -365,6 +366,7 @@ Screen* Screen::Create( CString sClassName )
IF_RETURN( ScreenBackgroundOptions ); IF_RETURN( ScreenBackgroundOptions );
IF_RETURN( ScreenSelectMaster ); IF_RETURN( ScreenSelectMaster );
IF_RETURN( ScreenEditCoursesMenu ); IF_RETURN( ScreenEditCoursesMenu );
IF_RETURN( ScreenProfileOptions );
RageException::Throw( "Invalid Screen class name '%s'", sClassName.c_str() ); RageException::Throw( "Invalid Screen class name '%s'", sClassName.c_str() );
} }
+3
View File
@@ -37,6 +37,7 @@ enum {
OM_GRAPHIC, OM_GRAPHIC,
OM_MACHINE, OM_MACHINE,
// OM_SOUND, // OM_SOUND,
OM_PROFILE,
OM_RELOAD, OM_RELOAD,
NUM_OPTIONS_MENU_LINES NUM_OPTIONS_MENU_LINES
}; };
@@ -50,6 +51,7 @@ OptionRow g_OptionsMenuLines[NUM_OPTIONS_MENU_LINES] = {
OptionRow( "", true, "Gameplay Options" ), OptionRow( "", true, "Gameplay Options" ),
OptionRow( "", true, "Graphic Options" ), OptionRow( "", true, "Graphic Options" ),
OptionRow( "", true, "Machine Options" ), OptionRow( "", true, "Machine Options" ),
OptionRow( "", true, "Profile Options" ),
// OptionRow( "", true, "Sound Options" ), // OptionRow( "", true, "Sound Options" ),
OptionRow( "", true, "Reload Songs/Courses" ), OptionRow( "", true, "Reload Songs/Courses" ),
}; };
@@ -106,6 +108,7 @@ void ScreenOptionsMenu::GoToNextState()
case OM_GRAPHIC: SCREENMAN->SetNewScreen("ScreenGraphicOptions"); break; case OM_GRAPHIC: SCREENMAN->SetNewScreen("ScreenGraphicOptions"); break;
case OM_INPUT: SCREENMAN->SetNewScreen("ScreenInputOptions"); break; case OM_INPUT: SCREENMAN->SetNewScreen("ScreenInputOptions"); break;
case OM_MACHINE: SCREENMAN->SetNewScreen("ScreenMachineOptions"); break; case OM_MACHINE: SCREENMAN->SetNewScreen("ScreenMachineOptions"); break;
case OM_PROFILE: SCREENMAN->SetNewScreen("ScreenProfileOptions"); break;
// case OM_SOUND: SCREENMAN->SetNewScreen("ScreenSoundOptions"); break; // case OM_SOUND: SCREENMAN->SetNewScreen("ScreenSoundOptions"); break;
case OM_RELOAD: case OM_RELOAD:
SONGMAN->Reload(); SONGMAN->Reload();
+102
View File
@@ -0,0 +1,102 @@
#include "global.h"
/*
-----------------------------------------------------------------------------
Class: ScreenProfileOptions
Desc: See header.
Copyright (c) 2001-2003 by the person(s) listed below. All rights reserved.
Chris Danford
Chris POmez
-----------------------------------------------------------------------------
*/
#include "ScreenProfileOptions.h"
#include "RageLog.h"
#include "ProfileManager.h"
#include "RageSounds.h"
#include "ThemeManager.h"
#include "PrefsManager.h"
#include "ScreenManager.h"
enum {
PO_PLAYER1,
PO_PLAYER2,
PO_CREATE_NEW,
PO_DELETE_,
NUM_GAMEPLAY_OPTIONS_LINES
};
OptionRow g_ProfileOptionsLines[NUM_GAMEPLAY_OPTIONS_LINES] = {
OptionRow( "Player1\nProfile", true ),
OptionRow( "Player2\nProfile", true ),
OptionRow( "Create\nNew", true, "PRESS START" ),
OptionRow( "Delete", true ),
};
ScreenProfileOptions::ScreenProfileOptions() :
ScreenOptions("ScreenProfileOptions",false)
{
LOG->Trace( "ScreenProfileOptions::ScreenProfileOptions()" );
g_ProfileOptionsLines[PO_PLAYER1].choices.clear();
PROFILEMAN->GetProfileNames( g_ProfileOptionsLines[PO_PLAYER1].choices );
if( g_ProfileOptionsLines[PO_PLAYER1].choices.empty() )
g_ProfileOptionsLines[PO_PLAYER1].choices.push_back( "-NONE-" );
g_ProfileOptionsLines[PO_PLAYER2].choices.clear();
PROFILEMAN->GetProfileNames( g_ProfileOptionsLines[PO_PLAYER2].choices );
if( g_ProfileOptionsLines[PO_PLAYER2].choices.empty() )
g_ProfileOptionsLines[PO_PLAYER2].choices.push_back( "-NONE-" );
g_ProfileOptionsLines[PO_DELETE_].choices.clear();
PROFILEMAN->GetProfileNames( g_ProfileOptionsLines[PO_DELETE_].choices );
if( g_ProfileOptionsLines[PO_DELETE_].choices.empty() )
g_ProfileOptionsLines[PO_DELETE_].choices.push_back( "-NONE-" );
Init(
INPUTMODE_TOGETHER,
g_ProfileOptionsLines,
NUM_GAMEPLAY_OPTIONS_LINES,
true );
m_Menu.m_MenuTimer.Disable();
SOUND->PlayMusic( THEME->GetPathToS("ScreenMachineOptions music") );
}
void ScreenProfileOptions::ImportOptions()
{
CStringArray::iterator iter;
iter = find(
g_ProfileOptionsLines[PO_PLAYER1].choices.begin(),
g_ProfileOptionsLines[PO_PLAYER1].choices.end(),
PREFSMAN->m_sDefaultProfile[PLAYER_1] );
if( iter != g_ProfileOptionsLines[PO_PLAYER1].choices.end() )
m_iSelectedOption[0][PO_PLAYER1] = iter - g_ProfileOptionsLines[PO_PLAYER1].choices.begin();
iter = find(
g_ProfileOptionsLines[PO_PLAYER2].choices.begin(),
g_ProfileOptionsLines[PO_PLAYER2].choices.end(),
PREFSMAN->m_sDefaultProfile[PLAYER_2] );
if( iter != g_ProfileOptionsLines[PO_PLAYER2].choices.end() )
m_iSelectedOption[0][PO_PLAYER2] = iter - g_ProfileOptionsLines[PO_PLAYER2].choices.begin();
}
void ScreenProfileOptions::ExportOptions()
{
PREFSMAN->m_sDefaultProfile[PLAYER_1] = g_ProfileOptionsLines[PO_PLAYER1].choices[m_iSelectedOption[0][PO_PLAYER1]];
PREFSMAN->m_sDefaultProfile[PLAYER_2] = g_ProfileOptionsLines[PO_PLAYER2].choices[m_iSelectedOption[0][PO_PLAYER2]];
}
void ScreenProfileOptions::GoToPrevState()
{
SCREENMAN->SetNewScreen( "ScreenOptionsMenu" );
}
void ScreenProfileOptions::GoToNextState()
{
PREFSMAN->SaveGlobalPrefsToDisk();
GoToPrevState();
}
+26
View File
@@ -0,0 +1,26 @@
/*
-----------------------------------------------------------------------------
File: ScreenProfileOptions
Desc: Select a song.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "ScreenOptions.h"
class ScreenProfileOptions : public ScreenOptions
{
public:
ScreenProfileOptions();
private:
void ImportOptions();
void ExportOptions();
void GoToNextState();
void GoToPrevState();
};
-1
View File
@@ -468,7 +468,6 @@ void SongManager::ReadCourseRankingsFromFile( CString fn )
void SongManager::InitMachineScoresFromDisk() void SongManager::InitMachineScoresFromDisk()
{ {
// Init category ranking // Init category ranking
{ {
for( int i=0; i<NUM_STEPS_TYPES; i++ ) for( int i=0; i<NUM_STEPS_TYPES; i++ )
+3
View File
@@ -41,6 +41,7 @@
#include "SongManager.h" #include "SongManager.h"
#include "GameState.h" #include "GameState.h"
#include "AnnouncerManager.h" #include "AnnouncerManager.h"
#include "ProfileManager.h"
#include "ScreenManager.h" #include "ScreenManager.h"
#include "GameManager.h" #include "GameManager.h"
#include "FontManager.h" #include "FontManager.h"
@@ -549,6 +550,7 @@ int main(int argc, char* argv[])
SOUNDMAN->SetPrefs(PREFSMAN->m_fSoundVolume); SOUNDMAN->SetPrefs(PREFSMAN->m_fSoundVolume);
SOUND = new RageSounds; SOUND = new RageSounds;
ANNOUNCER = new AnnouncerManager; ANNOUNCER = new AnnouncerManager;
PROFILEMAN = new ProfileManager;
INPUTFILTER = new InputFilter; INPUTFILTER = new InputFilter;
INPUTMAPPER = new InputMapper; INPUTMAPPER = new InputMapper;
INPUTQUEUE = new InputQueue; INPUTQUEUE = new InputQueue;
@@ -668,6 +670,7 @@ int main(int argc, char* argv[])
SAFE_DELETE( NOTESKIN ); SAFE_DELETE( NOTESKIN );
SAFE_DELETE( THEME ); SAFE_DELETE( THEME );
SAFE_DELETE( ANNOUNCER ); SAFE_DELETE( ANNOUNCER );
SAFE_DELETE( PROFILEMAN );
SAFE_DELETE( SOUND ); SAFE_DELETE( SOUND );
SAFE_DELETE( SOUNDMAN ); SAFE_DELETE( SOUNDMAN );
SAFE_DELETE( FONT ); SAFE_DELETE( FONT );