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]]++;
|
pPlayerProfile->m_iNumSongsPlayedByMeter[ss.iMeter[p]]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MEMCARDMAN->FlushAllDisks();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOKKEEPER->WriteToDisk();
|
BOOKKEEPER->WriteToDisk();
|
||||||
|
|||||||
@@ -207,3 +207,15 @@ match:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ public:
|
|||||||
|
|
||||||
void LockCards( bool bLock ); // prevent removing or changing of memory cards
|
void LockCards( bool bLock ); // prevent removing or changing of memory cards
|
||||||
|
|
||||||
|
void FlushAllDisks(); // force all files to be written to mounted memory cards
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void AssignUnassignedCards(); // do our best to assign a Device to each player
|
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 )
|
if( m_style != STYLE_INVALID )
|
||||||
{
|
{
|
||||||
PROFILEMAN->LoadFirstAvailableProfile( pn );
|
|
||||||
MEMCARDMAN->LockCards( true );
|
MEMCARDMAN->LockCards( true );
|
||||||
|
PROFILEMAN->LoadFirstAvailableProfile( pn );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "ThemeManager.h"
|
#include "ThemeManager.h"
|
||||||
#include "Bookkeeper.h"
|
#include "Bookkeeper.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include "MemoryCardManager.h"
|
||||||
|
|
||||||
|
|
||||||
ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our program
|
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")
|
#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 */
|
/* @ is important; see RageFileManager LoadedDriver::GetPath */
|
||||||
"@mc1/",
|
"@mc1/",
|
||||||
@@ -68,9 +69,6 @@ ProfileManager::ProfileManager()
|
|||||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||||
{
|
{
|
||||||
m_bUsingMemoryCard[p] = false;
|
m_bUsingMemoryCard[p] = false;
|
||||||
|
|
||||||
if( PREFSMAN->m_sMemoryCardDir[p] != "" )
|
|
||||||
FILEMAN->Mount( "dir", PREFSMAN->m_sMemoryCardDir[p], MemCardDirs[p] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InitMachineScoresFromDisk();
|
InitMachineScoresFromDisk();
|
||||||
@@ -161,14 +159,9 @@ bool ProfileManager::LoadDefaultProfileFromMachine( PlayerNumber pn )
|
|||||||
return LoadProfile( pn, sDir, false );
|
return LoadProfile( pn, sDir, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProfileManager::IsMemoryCardInserted( PlayerNumber pn )
|
|
||||||
{
|
|
||||||
return FILEMAN->MountpointIsReady( MemCardDirs[pn] );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn )
|
bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn )
|
||||||
{
|
{
|
||||||
CString sDir = MemCardDirs[pn];
|
CString sDir = MEM_CARD_DIR[pn];
|
||||||
if( !FILEMAN->IsMounted(sDir) )
|
if( !FILEMAN->IsMounted(sDir) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -182,15 +175,14 @@ bool ProfileManager::LoadFirstAvailableProfile( PlayerNumber pn )
|
|||||||
{
|
{
|
||||||
#ifndef _XBOX
|
#ifndef _XBOX
|
||||||
// mount card
|
// mount card
|
||||||
// if( !PREFSMAN->m_sMemoryCardMountCommand[pn].empty() )
|
if( MEMCARDMAN->GetCardState(pn) == MEMORY_CARD_STATE_READY )
|
||||||
// system( PREFSMAN->m_sMemoryCardMountCommand[pn] );
|
|
||||||
|
|
||||||
if( IsMemoryCardInserted(pn) )
|
|
||||||
{
|
{
|
||||||
|
FILEMAN->Mount( "dir", MEMCARDMAN->GetOsMountDir(pn), MEM_CARD_DIR[pn] );
|
||||||
|
|
||||||
if( LoadProfileFromMemoryCard(pn) )
|
if( LoadProfileFromMemoryCard(pn) )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
CString sDir = MemCardDirs[pn];
|
CString sDir = MEM_CARD_DIR[pn];
|
||||||
CreateProfile( sDir, NEW_MEM_CARD_NAME );
|
CreateProfile( sDir, NEW_MEM_CARD_NAME );
|
||||||
if( LoadProfileFromMemoryCard(pn) )
|
if( LoadProfileFromMemoryCard(pn) )
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -68,13 +68,10 @@ public:
|
|||||||
bool RenameLocalProfile( CString sProfileID, CString sNewName );
|
bool RenameLocalProfile( CString sProfileID, CString sNewName );
|
||||||
bool DeleteLocalProfile( CString sProfileID );
|
bool DeleteLocalProfile( CString sProfileID );
|
||||||
|
|
||||||
bool CreateMemoryCardProfile( CString sName );
|
|
||||||
|
|
||||||
void GetLocalProfileIDs( vector<CString> &asProfileIDsOut );
|
void GetLocalProfileIDs( vector<CString> &asProfileIDsOut );
|
||||||
void GetLocalProfileNames( vector<CString> &asNamesOut );
|
void GetLocalProfileNames( vector<CString> &asNamesOut );
|
||||||
|
|
||||||
bool LoadFirstAvailableProfile( PlayerNumber pn );
|
bool LoadFirstAvailableProfile( PlayerNumber pn );
|
||||||
bool IsMemoryCardInserted( PlayerNumber pn );
|
|
||||||
bool SaveProfile( PlayerNumber pn );
|
bool SaveProfile( PlayerNumber pn );
|
||||||
void UnloadProfile( PlayerNumber pn );
|
void UnloadProfile( PlayerNumber pn );
|
||||||
|
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ void ScreenSystemLayer::RefreshCreditsMessages()
|
|||||||
}
|
}
|
||||||
else if( GAMESTATE->m_bIsOnSystemMenu ) // no mem card
|
else if( GAMESTATE->m_bIsOnSystemMenu ) // no mem card
|
||||||
sPlayerInfo = "";
|
sPlayerInfo = "";
|
||||||
else if( PREFSMAN->m_sMemoryCardDir[p]!="" )
|
else
|
||||||
{
|
{
|
||||||
if( GAMESTATE->PlayersCanJoin() )
|
if( GAMESTATE->PlayersCanJoin() )
|
||||||
sPlayerInfo = PLAYER_INFO_INSERT_CARD;
|
sPlayerInfo = PLAYER_INFO_INSERT_CARD;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
virtual bool StorageDevicesChanged() = 0;
|
virtual bool StorageDevicesChanged() = 0;
|
||||||
virtual void GetStorageDevices( vector<UsbStorageDevice>& vStorageDevicesOut ) = 0;
|
virtual void GetStorageDevices( vector<UsbStorageDevice>& vStorageDevicesOut ) = 0;
|
||||||
virtual bool MountAndTestWrite( UsbStorageDevice* pDevice ) = 0; // return false if mount or write fails
|
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
|
#endif
|
||||||
|
|||||||
@@ -84,10 +84,11 @@ bool MemoryCardDriver_Windows::MountAndTestWrite( UsbStorageDevice* pDevice )
|
|||||||
return true;
|
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
|
// 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 bool StorageDevicesChanged();
|
||||||
virtual void GetStorageDevices( vector<UsbStorageDevice>& vStorageDevicesOut );
|
virtual void GetStorageDevices( vector<UsbStorageDevice>& vStorageDevicesOut );
|
||||||
virtual bool MountAndTestWrite( UsbStorageDevice* pDevice );
|
virtual bool MountAndTestWrite( UsbStorageDevice* pDevice );
|
||||||
virtual void Unmount( UsbStorageDevice* pDevice );
|
virtual void Flush( UsbStorageDevice* pDevice );
|
||||||
protected:
|
protected:
|
||||||
DWORD m_dwLastLogicalDrives;
|
DWORD m_dwLastLogicalDrives;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user