diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 8f200c0d76..db4fc67508 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -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. 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] UseUnlocksDat=1 TypeOfPointsToDisplay=DP @@ -2265,7 +2272,7 @@ AppearanceOptions= SoundOptions= AutogenOptions= BackgroundOptions= -AutoAdjustGraphicDetail= +ProfileOptions= ReloadSongs/Courses= [TextBanner] diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 4c3208bbff..93bd2fd238 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -27,6 +27,7 @@ #include "Character.h" #include "UnlockSystem.h" #include "AnnouncerManager.h" +#include "ProfileManager.h" #include "arch/arch.h" @@ -118,6 +119,9 @@ void GameState::Reset() m_fSuperMeterGrowthScale[p] = 1; m_iCpuSkill[p] = 5; } + + for( p=0; pUnloadProfile( (PlayerNumber)p ); } void GameState::Update( float fDelta ) diff --git a/stepmania/src/ModeChoice.cpp b/stepmania/src/ModeChoice.cpp index 15c27a1768..9f9ff4cb40 100644 --- a/stepmania/src/ModeChoice.cpp +++ b/stepmania/src/ModeChoice.cpp @@ -6,6 +6,7 @@ #include "GameState.h" #include "RageDisplay.h" #include "AnnouncerManager.h" +#include "ProfileManager.h" #include "arch/ArchHooks/ArchHooks.h" void ModeChoice::Init() @@ -137,8 +138,11 @@ void ModeChoice::Apply( PlayerNumber pn ) if( sAnnouncer != "" ) ANNOUNCER->SwitchAnnouncer( sAnnouncer ); - // HACK: Set life type to BATTERY just once here so we don't - // override the user's changes if they back out. + // HACK: Set life type to BATTERY just once here so it happens once and + // we don't override the user's changes if they back out. if( GAMESTATE->m_PlayMode == PLAY_MODE_ONI ) GAMESTATE->m_SongOptions.m_LifeType = SongOptions::LIFE_BATTERY; + + + PROFILEMAN->TryLoadProfile( pn ); } diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index 49e81e7a51..57cc329216 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -136,6 +136,7 @@ PrefsManager::PrefsManager() m_bVsync = true; m_sLanguage = ""; // ThemeManager will deal with this invalid language + /* XXX: Set these defaults for individual consoles using VideoCardDefaults.ini. */ #ifdef _XBOX m_bInterlaced = true; @@ -274,6 +275,8 @@ void PrefsManager::ReadGlobalPrefsFromDisk( bool bSwitchToLastPlayedGame ) ini.GetValueB( "Options", "ShowLogWindow", m_bShowLogWindow ); ini.GetValueB( "Options", "ShowBeginnerHelper", m_bShowBeginnerHelper ); ini.GetValue ( "Options", "Language", m_sLanguage ); + for( int p=0; p &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 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(); +} diff --git a/stepmania/src/ProfileManager.h b/stepmania/src/ProfileManager.h new file mode 100644 index 0000000000..429d5e71c5 --- /dev/null +++ b/stepmania/src/ProfileManager.h @@ -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 &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 diff --git a/stepmania/src/Screen.cpp b/stepmania/src/Screen.cpp index 613247f8f2..e96ee4f9ef 100644 --- a/stepmania/src/Screen.cpp +++ b/stepmania/src/Screen.cpp @@ -298,6 +298,7 @@ void Screen::ClearMessageQueue( const ScreenMessage SM ) #include "ScreenBackgroundOptions.h" #include "ScreenSelectMaster.h" #include "ScreenEditCoursesMenu.h" +#include "ScreenProfileOptions.h" Screen* Screen::Create( CString sClassName ) { @@ -365,6 +366,7 @@ Screen* Screen::Create( CString sClassName ) IF_RETURN( ScreenBackgroundOptions ); IF_RETURN( ScreenSelectMaster ); IF_RETURN( ScreenEditCoursesMenu ); + IF_RETURN( ScreenProfileOptions ); RageException::Throw( "Invalid Screen class name '%s'", sClassName.c_str() ); } diff --git a/stepmania/src/ScreenOptionsMenu.cpp b/stepmania/src/ScreenOptionsMenu.cpp index 836f97af7b..106028cbe6 100644 --- a/stepmania/src/ScreenOptionsMenu.cpp +++ b/stepmania/src/ScreenOptionsMenu.cpp @@ -37,6 +37,7 @@ enum { OM_GRAPHIC, OM_MACHINE, // OM_SOUND, + OM_PROFILE, OM_RELOAD, NUM_OPTIONS_MENU_LINES }; @@ -50,6 +51,7 @@ OptionRow g_OptionsMenuLines[NUM_OPTIONS_MENU_LINES] = { OptionRow( "", true, "Gameplay Options" ), OptionRow( "", true, "Graphic Options" ), OptionRow( "", true, "Machine Options" ), + OptionRow( "", true, "Profile Options" ), // OptionRow( "", true, "Sound Options" ), OptionRow( "", true, "Reload Songs/Courses" ), }; @@ -106,6 +108,7 @@ void ScreenOptionsMenu::GoToNextState() case OM_GRAPHIC: SCREENMAN->SetNewScreen("ScreenGraphicOptions"); break; case OM_INPUT: SCREENMAN->SetNewScreen("ScreenInputOptions"); break; case OM_MACHINE: SCREENMAN->SetNewScreen("ScreenMachineOptions"); break; + case OM_PROFILE: SCREENMAN->SetNewScreen("ScreenProfileOptions"); break; // case OM_SOUND: SCREENMAN->SetNewScreen("ScreenSoundOptions"); break; case OM_RELOAD: SONGMAN->Reload(); diff --git a/stepmania/src/ScreenProfileOptions.cpp b/stepmania/src/ScreenProfileOptions.cpp new file mode 100644 index 0000000000..7aa3cb3a97 --- /dev/null +++ b/stepmania/src/ScreenProfileOptions.cpp @@ -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(); +} diff --git a/stepmania/src/ScreenProfileOptions.h b/stepmania/src/ScreenProfileOptions.h new file mode 100644 index 0000000000..ff06107696 --- /dev/null +++ b/stepmania/src/ScreenProfileOptions.h @@ -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(); +}; + diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index ab773e551c..685222f0d1 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -468,7 +468,6 @@ void SongManager::ReadCourseRankingsFromFile( CString fn ) void SongManager::InitMachineScoresFromDisk() { - // Init category ranking { for( int i=0; iSetPrefs(PREFSMAN->m_fSoundVolume); SOUND = new RageSounds; ANNOUNCER = new AnnouncerManager; + PROFILEMAN = new ProfileManager; INPUTFILTER = new InputFilter; INPUTMAPPER = new InputMapper; INPUTQUEUE = new InputQueue; @@ -668,6 +670,7 @@ int main(int argc, char* argv[]) SAFE_DELETE( NOTESKIN ); SAFE_DELETE( THEME ); SAFE_DELETE( ANNOUNCER ); + SAFE_DELETE( PROFILEMAN ); SAFE_DELETE( SOUND ); SAFE_DELETE( SOUNDMAN ); SAFE_DELETE( FONT );