load profile from memory card, fix memory card file flushing
This commit is contained in:
@@ -215,6 +215,8 @@ void GameState::EndGame()
|
||||
pPlayerProfile->m_iNumSongsPlayedByMeter[ss.iMeter[p]]++;
|
||||
}
|
||||
}
|
||||
|
||||
MEMCARDMAN->FlushAllDisks();
|
||||
}
|
||||
|
||||
BOOKKEEPER->WriteToDisk();
|
||||
|
||||
@@ -206,4 +206,16 @@ match:
|
||||
m_soundReady.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCardManager::FlushAllDisks()
|
||||
{
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
if( !m_Device[p].IsBlank() ) // they already have an assigned card
|
||||
continue; // skip
|
||||
if( m_bWriteError[p] || m_bTooLate[p] )
|
||||
continue; // skip
|
||||
m_pDriver->Flush(&m_Device[p]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ public:
|
||||
CString GetOsMountDir( PlayerNumber pn ); // only valid when ready
|
||||
|
||||
void LockCards( bool bLock ); // prevent removing or changing of memory cards
|
||||
|
||||
void FlushAllDisks(); // force all files to be written to mounted memory cards
|
||||
|
||||
protected:
|
||||
void AssignUnassignedCards(); // do our best to assign a Device to each player
|
||||
|
||||
@@ -288,8 +288,8 @@ void ModeChoice::Apply( PlayerNumber pn ) const
|
||||
//
|
||||
if( m_style != STYLE_INVALID )
|
||||
{
|
||||
PROFILEMAN->LoadFirstAvailableProfile( pn );
|
||||
MEMCARDMAN->LockCards( true );
|
||||
PROFILEMAN->LoadFirstAvailableProfile( pn );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "ThemeManager.h"
|
||||
#include "Bookkeeper.h"
|
||||
#include <time.h>
|
||||
#include "MemoryCardManager.h"
|
||||
|
||||
|
||||
ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our program
|
||||
@@ -56,7 +57,7 @@ const int COURSE_SCORES_VERSION = 8;
|
||||
|
||||
#define STATS_TITLE THEME->GetMetric("ProfileManager","StatsTitle")
|
||||
|
||||
static const char *MemCardDirs[NUM_PLAYERS] =
|
||||
static const char *MEM_CARD_DIR[NUM_PLAYERS] =
|
||||
{
|
||||
/* @ is important; see RageFileManager LoadedDriver::GetPath */
|
||||
"@mc1/",
|
||||
@@ -68,9 +69,6 @@ ProfileManager::ProfileManager()
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
m_bUsingMemoryCard[p] = false;
|
||||
|
||||
if( PREFSMAN->m_sMemoryCardDir[p] != "" )
|
||||
FILEMAN->Mount( "dir", PREFSMAN->m_sMemoryCardDir[p], MemCardDirs[p] );
|
||||
}
|
||||
|
||||
InitMachineScoresFromDisk();
|
||||
@@ -161,14 +159,9 @@ bool ProfileManager::LoadDefaultProfileFromMachine( PlayerNumber pn )
|
||||
return LoadProfile( pn, sDir, false );
|
||||
}
|
||||
|
||||
bool ProfileManager::IsMemoryCardInserted( PlayerNumber pn )
|
||||
{
|
||||
return FILEMAN->MountpointIsReady( MemCardDirs[pn] );
|
||||
}
|
||||
|
||||
bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn )
|
||||
{
|
||||
CString sDir = MemCardDirs[pn];
|
||||
CString sDir = MEM_CARD_DIR[pn];
|
||||
if( !FILEMAN->IsMounted(sDir) )
|
||||
return false;
|
||||
|
||||
@@ -182,15 +175,14 @@ bool ProfileManager::LoadFirstAvailableProfile( PlayerNumber pn )
|
||||
{
|
||||
#ifndef _XBOX
|
||||
// mount card
|
||||
// if( !PREFSMAN->m_sMemoryCardMountCommand[pn].empty() )
|
||||
// system( PREFSMAN->m_sMemoryCardMountCommand[pn] );
|
||||
|
||||
if( IsMemoryCardInserted(pn) )
|
||||
if( MEMCARDMAN->GetCardState(pn) == MEMORY_CARD_STATE_READY )
|
||||
{
|
||||
FILEMAN->Mount( "dir", MEMCARDMAN->GetOsMountDir(pn), MEM_CARD_DIR[pn] );
|
||||
|
||||
if( LoadProfileFromMemoryCard(pn) )
|
||||
return true;
|
||||
|
||||
CString sDir = MemCardDirs[pn];
|
||||
CString sDir = MEM_CARD_DIR[pn];
|
||||
CreateProfile( sDir, NEW_MEM_CARD_NAME );
|
||||
if( LoadProfileFromMemoryCard(pn) )
|
||||
return true;
|
||||
|
||||
@@ -68,13 +68,10 @@ public:
|
||||
bool RenameLocalProfile( CString sProfileID, CString sNewName );
|
||||
bool DeleteLocalProfile( CString sProfileID );
|
||||
|
||||
bool CreateMemoryCardProfile( CString sName );
|
||||
|
||||
void GetLocalProfileIDs( vector<CString> &asProfileIDsOut );
|
||||
void GetLocalProfileNames( vector<CString> &asNamesOut );
|
||||
|
||||
bool LoadFirstAvailableProfile( PlayerNumber pn );
|
||||
bool IsMemoryCardInserted( PlayerNumber pn );
|
||||
bool SaveProfile( PlayerNumber pn );
|
||||
void UnloadProfile( PlayerNumber pn );
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ void ScreenSystemLayer::RefreshCreditsMessages()
|
||||
}
|
||||
else if( GAMESTATE->m_bIsOnSystemMenu ) // no mem card
|
||||
sPlayerInfo = "";
|
||||
else if( PREFSMAN->m_sMemoryCardDir[p]!="" )
|
||||
else
|
||||
{
|
||||
if( GAMESTATE->PlayersCanJoin() )
|
||||
sPlayerInfo = PLAYER_INFO_INSERT_CARD;
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
virtual bool StorageDevicesChanged() = 0;
|
||||
virtual void GetStorageDevices( vector<UsbStorageDevice>& vStorageDevicesOut ) = 0;
|
||||
virtual bool MountAndTestWrite( UsbStorageDevice* pDevice ) = 0; // return false if mount or write fails
|
||||
virtual void Unmount( UsbStorageDevice* pDevice ) = 0;
|
||||
virtual void Flush( UsbStorageDevice* pDevice ) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -84,10 +84,11 @@ bool MemoryCardDriver_Windows::MountAndTestWrite( UsbStorageDevice* pDevice )
|
||||
return true;
|
||||
}
|
||||
|
||||
void MemoryCardDriver_Windows::Unmount( UsbStorageDevice* pDevice )
|
||||
void MemoryCardDriver_Windows::Flush( UsbStorageDevice* pDevice )
|
||||
{
|
||||
// Do we need anything here? I don't lose data if ejecting
|
||||
// soon after a write... -Chris
|
||||
// soon after a write. From the activity LED, it looks like
|
||||
// Windows flushes automatically every ~2 seconds. -Chris
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -12,7 +12,7 @@ public:
|
||||
virtual bool StorageDevicesChanged();
|
||||
virtual void GetStorageDevices( vector<UsbStorageDevice>& vStorageDevicesOut );
|
||||
virtual bool MountAndTestWrite( UsbStorageDevice* pDevice );
|
||||
virtual void Unmount( UsbStorageDevice* pDevice );
|
||||
virtual void Flush( UsbStorageDevice* pDevice );
|
||||
protected:
|
||||
DWORD m_dwLastLogicalDrives;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user