From a9038f82dd610896ee5c09d122831090ebed80d0 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 27 Oct 2005 17:37:59 +0000 Subject: [PATCH] move memory card prefs into MemoryCardManager --- stepmania/src/MemoryCardManager.cpp | 47 +++++++++++++++++++++----- stepmania/src/MemoryCardManager.h | 6 ++++ stepmania/src/PrefsManager.cpp | 28 --------------- stepmania/src/PrefsManager.h | 4 --- stepmania/src/ScreenProfileOptions.cpp | 15 ++++---- 5 files changed, 53 insertions(+), 47 deletions(-) diff --git a/stepmania/src/MemoryCardManager.cpp b/stepmania/src/MemoryCardManager.cpp index da963ded89..2441bc7cd7 100644 --- a/stepmania/src/MemoryCardManager.cpp +++ b/stepmania/src/MemoryCardManager.cpp @@ -18,6 +18,37 @@ MemoryCardManager* MEMCARDMAN = NULL; // global and accessable from anywhere in our program +static void MemoryCardOsMountPointInit( size_t /*PlayerNumber*/ i, CString &sNameOut, CString &defaultValueOut ) +{ + sNameOut = "MemoryCardOsMountPoint" + PlayerNumberToString( (PlayerNumber)i ); + defaultValueOut = ""; +} + +static void MemoryCardUsbBusInit( size_t /*PlayerNumber*/ i, CString &sNameOut, int &defaultValueOut ) +{ + sNameOut = "MemoryCardUsbBus" + PlayerNumberToString( (PlayerNumber)i ); + defaultValueOut = -1; +} + +static void MemoryCardUsbPortInit( size_t /*PlayerNumber*/ i, CString &sNameOut, int &defaultValueOut ) +{ + sNameOut = "MemoryCardUsbPort" + PlayerNumberToString( (PlayerNumber)i ); + defaultValueOut = -1; +} + +static void MemoryCardUsbLevelInit( size_t /*PlayerNumber*/ i, CString &sNameOut, int &defaultValueOut ) +{ + sNameOut = "MemoryCardUsbLevel" + PlayerNumberToString( (PlayerNumber)i ); + defaultValueOut = -1; +} + +// if set, always use the device that mounts to this point +Preference1D MemoryCardManager::m_sMemoryCardOsMountPoint( MemoryCardOsMountPointInit, NUM_PLAYERS ); +// Look for this level, bus, port when assigning cards. -1 = match any +Preference1D MemoryCardManager::m_iMemoryCardUsbBus( MemoryCardUsbBusInit, NUM_PLAYERS ); +Preference1D MemoryCardManager::m_iMemoryCardUsbPort( MemoryCardUsbPortInit, NUM_PLAYERS ); +Preference1D MemoryCardManager::m_iMemoryCardUsbLevel( MemoryCardUsbLevelInit, NUM_PLAYERS ); + const CString MEM_CARD_MOUNT_POINT[NUM_PLAYERS] = { /* @ is importast; see RageFileManager LoadedDriver::GetPath */ @@ -386,21 +417,21 @@ void MemoryCardManager::Update( float fDelta ) FOREACH( UsbStorageDevice, vUnassignedDevices, d ) { // search for card dir match - if( !PREFSMAN->m_sMemoryCardOsMountPoint[p].Get().empty() && - d->sOsMountDir.CompareNoCase(PREFSMAN->m_sMemoryCardOsMountPoint[p].Get()) ) + if( !m_sMemoryCardOsMountPoint[p].Get().empty() && + d->sOsMountDir.CompareNoCase(m_sMemoryCardOsMountPoint[p].Get()) ) continue; // not a match // search for USB bus match - if( PREFSMAN->m_iMemoryCardUsbBus[p] != -1 && - PREFSMAN->m_iMemoryCardUsbBus[p] != d->iBus ) + if( m_iMemoryCardUsbBus[p] != -1 && + m_iMemoryCardUsbBus[p] != d->iBus ) continue; // not a match - if( PREFSMAN->m_iMemoryCardUsbPort[p] != -1 && - PREFSMAN->m_iMemoryCardUsbPort[p] != d->iPort ) + if( m_iMemoryCardUsbPort[p] != -1 && + m_iMemoryCardUsbPort[p] != d->iPort ) continue; // not a match - if( PREFSMAN->m_iMemoryCardUsbLevel[p] != -1 && - PREFSMAN->m_iMemoryCardUsbLevel[p] != d->iLevel ) + if( m_iMemoryCardUsbLevel[p] != -1 && + m_iMemoryCardUsbLevel[p] != d->iLevel ) continue; // not a match LOG->Trace( "Player %i: matched %s", p+1, d->sDevice.c_str() ); diff --git a/stepmania/src/MemoryCardManager.h b/stepmania/src/MemoryCardManager.h index 1f9057de56..86ad71b9cd 100644 --- a/stepmania/src/MemoryCardManager.h +++ b/stepmania/src/MemoryCardManager.h @@ -5,6 +5,7 @@ #include "PlayerNumber.h" #include "RageSound.h" #include "arch/MemoryCard/MemoryCardDriver.h" +#include "Preference.h" extern const CString MEM_CARD_MOUNT_POINT[NUM_PLAYERS]; @@ -38,6 +39,11 @@ public: bool IsNameAvailable( PlayerNumber pn ) const; CString GetName( PlayerNumber pn ) const; + static Preference1D m_sMemoryCardOsMountPoint; + static Preference1D m_iMemoryCardUsbBus; + static Preference1D m_iMemoryCardUsbPort; + static Preference1D m_iMemoryCardUsbLevel; + protected: void CheckStateChanges(); diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index 5e6c1faf14..72b390aa74 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -214,30 +214,6 @@ void DefaultLocalProfileIDInit( size_t /*PlayerNumber*/ i, CString &sNameOut, CS defaultValueOut = ""; } -void MemoryCardOsMountPointInit( size_t /*PlayerNumber*/ i, CString &sNameOut, CString &defaultValueOut ) -{ - sNameOut = "MemoryCardOsMountPoint" + PlayerNumberToString( (PlayerNumber)i ); - defaultValueOut = ""; -} - -void MemoryCardUsbBusInit( size_t /*PlayerNumber*/ i, CString &sNameOut, int &defaultValueOut ) -{ - sNameOut = "MemoryCardUsbBus" + PlayerNumberToString( (PlayerNumber)i ); - defaultValueOut = -1; -} - -void MemoryCardUsbPortInit( size_t /*PlayerNumber*/ i, CString &sNameOut, int &defaultValueOut ) -{ - sNameOut = "MemoryCardUsbPort" + PlayerNumberToString( (PlayerNumber)i ); - defaultValueOut = -1; -} - -void MemoryCardUsbLevelInit( size_t /*PlayerNumber*/ i, CString &sNameOut, int &defaultValueOut ) -{ - sNameOut = "MemoryCardUsbLevel" + PlayerNumberToString( (PlayerNumber)i ); - defaultValueOut = -1; -} - PrefsManager::PrefsManager() : m_sCurrentGame ( "CurrentGame", "" ), @@ -351,10 +327,6 @@ PrefsManager::PrefsManager() : m_iProductID ( "ProductID", 1 ), m_sDefaultLocalProfileID ( DefaultLocalProfileIDInit, NUM_PLAYERS ), m_bMemoryCards ( "MemoryCards", false ), - m_sMemoryCardOsMountPoint ( MemoryCardOsMountPointInit, NUM_PLAYERS ), - m_iMemoryCardUsbBus ( MemoryCardUsbBusInit, NUM_PLAYERS ), - m_iMemoryCardUsbPort ( MemoryCardUsbPortInit, NUM_PLAYERS ), - m_iMemoryCardUsbLevel ( MemoryCardUsbLevelInit, NUM_PLAYERS ), m_iCenterImageTranslateX ( "CenterImageTranslateX", 0 ), m_iCenterImageTranslateY ( "CenterImageTranslateY", 0 ), m_fCenterImageAddWidth ( "CenterImageAddWidth", 0 ), diff --git a/stepmania/src/PrefsManager.h b/stepmania/src/PrefsManager.h index 9d8343e8fe..3ac6433b95 100644 --- a/stepmania/src/PrefsManager.h +++ b/stepmania/src/PrefsManager.h @@ -148,10 +148,6 @@ public: Preference m_iProductID; // Saved in HighScore to track what software version a score came from. Preference1D m_sDefaultLocalProfileID; Preference m_bMemoryCards; - Preference1D m_sMemoryCardOsMountPoint; // if set, always use the device that mounts to this point - Preference1D m_iMemoryCardUsbBus; // look for this bus when assigning cards. -1 = match any - Preference1D m_iMemoryCardUsbPort; // look for this port when assigning cards. -1 = match any - Preference1D m_iMemoryCardUsbLevel; // look for this level when assigning cards. -1 = match any Preference m_iCenterImageTranslateX; Preference m_iCenterImageTranslateY; Preference m_fCenterImageAddWidth; diff --git a/stepmania/src/ScreenProfileOptions.cpp b/stepmania/src/ScreenProfileOptions.cpp index b1e4045581..d54e4f4c99 100644 --- a/stepmania/src/ScreenProfileOptions.cpp +++ b/stepmania/src/ScreenProfileOptions.cpp @@ -10,6 +10,7 @@ #include "ScreenPrompt.h" #include "GameState.h" #include "Profile.h" +#include "MemoryCardManager.h" enum { @@ -63,15 +64,15 @@ void ScreenProfileOptions::Init() g_ProfileOptionsLines[PO_RENAME_].m_vsChoices.push_back( "-NONE-" ); PROFILEMAN->GetLocalProfileDisplayNames( g_ProfileOptionsLines[PO_RENAME_].m_vsChoices ); - if( PREFSMAN->m_sMemoryCardOsMountPoint[PLAYER_1].Get().empty() ) + if( MemoryCardManager::m_sMemoryCardOsMountPoint[PLAYER_1].Get().empty() ) g_ProfileOptionsLines[PO_OS_MOUNT_1].m_vsChoices[0] = "-NOT SET IN INI-"; else - g_ProfileOptionsLines[PO_OS_MOUNT_1].m_vsChoices[0] = PREFSMAN->m_sMemoryCardOsMountPoint[PLAYER_1].Get(); + g_ProfileOptionsLines[PO_OS_MOUNT_1].m_vsChoices[0] = MemoryCardManager::m_sMemoryCardOsMountPoint[PLAYER_1].Get(); - if( PREFSMAN->m_sMemoryCardOsMountPoint[PLAYER_2].Get().empty() ) + if( MemoryCardManager::m_sMemoryCardOsMountPoint[PLAYER_2].Get().empty() ) g_ProfileOptionsLines[PO_OS_MOUNT_2].m_vsChoices[0] = "-NOT SET IN INI-"; else - g_ProfileOptionsLines[PO_OS_MOUNT_2].m_vsChoices[0] = PREFSMAN->m_sMemoryCardOsMountPoint[PLAYER_2].Get(); + g_ProfileOptionsLines[PO_OS_MOUNT_2].m_vsChoices[0] = MemoryCardManager::m_sMemoryCardOsMountPoint[PLAYER_2].Get(); //Enable all lines for all players for ( unsigned int i = 0; i < NUM_PROFILE_OPTIONS_LINES; i++ ) @@ -97,7 +98,7 @@ void ScreenProfileOptions::ImportOptions( int iRow, const vector & CStringArray::iterator iter = find( vsProfiles.begin(), vsProfiles.end(), - PREFSMAN->m_sMemoryCardOsMountPoint[pn].Get() ); + MemoryCardManager::m_sMemoryCardOsMountPoint[pn].Get() ); if( iter != vsProfiles.end() ) m_pRows[iRow]->SetOneSharedSelection( iter - vsProfiles.begin() + 1 ); } @@ -117,9 +118,9 @@ void ScreenProfileOptions::ExportOptions( int iRow, const vector & PROFILEMAN->GetLocalProfileIDs( vsProfiles ); if( m_pRows[iRow]->GetOneSharedSelection() > 0 ) - PREFSMAN->m_sMemoryCardOsMountPoint[pn].Set( vsProfiles[m_pRows[iRow]->GetOneSharedSelection()-1] ); + MemoryCardManager::m_sMemoryCardOsMountPoint[pn].Set( vsProfiles[m_pRows[iRow]->GetOneSharedSelection()-1] ); else - PREFSMAN->m_sMemoryCardOsMountPoint[pn].Set( "" ); + MemoryCardManager::m_sMemoryCardOsMountPoint[pn].Set( "" ); } break; }