add copy and clear machine edits

This commit is contained in:
Chris Danford
2005-04-28 06:17:17 +00:00
parent d483f208f9
commit 16971da0b3
6 changed files with 147 additions and 8 deletions
+14 -5
View File
@@ -4094,7 +4094,7 @@ Background Options,1=screen,ScreenBackgroundOptions;name,Background Options
Bookkeeping=1;together;SelectNone
BookkeepingDefault=
Bookkeeping,1=screen,ScreenBookkeeping;name,Bookkeeping
Clear Bookkeeping Data=1;together;SelectOne
Clear Bookkeeping Data=1;together;SelectNone
Clear Bookkeeping DataDefault=
Clear Bookkeeping Data,1=ClearBookkeepingData;name,Clear Bookkeeping Data
Center Image=1;together;SelectNone
@@ -4106,10 +4106,13 @@ Coin Options,1=screen,ScreenCoinOptions;name,Coin Options
Config Key/Joy Mappings=1;together;SelectNone
Config Key/Joy MappingsDefault=
Config Key/Joy Mappings,1=screen,ScreenMapControllers;name,Key Joy Mappings
Clear Machine Stats=1;together;SelectOne
Clear Machine Stats=1;together;SelectNone
Clear Machine StatsDefault=
Clear Machine Stats,1=ClearMachineStats;name,ClearMachineStats;screen,Screen Options Menu
Fill Machine Stats=1;together;SelectOne
Clear Machine Stats,1=ClearMachineStats;screen,ScreenOptionsMenu;name,Clear Machine Stats
Clear Machine Edits=1;together;SelectNone
Clear Machine EditsDefault=
Clear Machine Edits,1=ClearMachineEdits;screen,ScreenOptionsMenu;name,Clear Machine Edits
Fill Machine Stats=1;together;SelectNone
Fill Machine StatsDefault=
Fill Machine Stats,1=screen,ScreenOptionsMenu;FillMachineStats;name,Fill Machine Stats
Input Options=1;together;SelectNone
@@ -4136,7 +4139,7 @@ Profile Options,1=screen,ScreenProfileOptions;name,Profile Options
Reload Songs/Courses=1;together;SelectNone
Reload Songs/CoursesDefault=
Reload Songs/Courses,1=screen,ScreenReloadSongs;name,Reload Songs
Reset To Defaults=1;together;SelectOne
Reset To Defaults=1;together;SelectNone
Reset To DefaultsDefault=
Reset To Defaults,1=ResetToFactoryDefaults;screen,ScreenOptionsMenu;name,Reset To Defaults
Test Input=1;together;SelectNone
@@ -4151,6 +4154,12 @@ Transfer Stats From Machine,1=TransferStatsFromMachine;screen,ScreenOptionsMenu;
Transfer Stats To Machine=1;together;SelectNone
Transfer Stats To MachineDefault=
Transfer Stats To Machine,1=TransferStatsToMachine;screen,ScreenOptionsMenu;name,Transfer Stats To Machine
Copy Edits To Machine=1;together;SelectNone
Copy Edits To MachineDefault=
Copy Edits To Machine,1=CopyEditsToMachine;screen,ScreenOptionsMenu;name,Copy Edits To Machine
Copy Edits From Machine=1;together;SelectNone
Copy Edits From MachineDefault=
Copy Edits From Machine,1=CopyEditsFromMachine;screen,ScreenOptionsMenu;name,Copy Edits From Machine
Set Machine Time=1;together;SelectNone
Set Machine TimeDefault=
Set Machine Time,1=screen,ScreenSetTime;name,Set Machine Time
+125
View File
@@ -25,6 +25,7 @@
#include "ThemeManager.h"
#include "PlayerState.h"
#include "Course.h"
#include "RageFileManager.h"
void GameCommand::Init()
{
@@ -56,9 +57,12 @@ void GameCommand::Init()
m_bClearBookkeepingData = false;
m_bClearMachineStats = false;
m_bClearMachineEdits = false;
m_bFillMachineStats = false;
m_bTransferStatsFromMachine = false;
m_bTransferStatsToMachine = false;
m_bCopyEditsFromMachine = false;
m_bCopyEditsToMachine = false;
m_bInsertCredit = false;
m_bResetToFactoryDefaults = false;
m_bStopMusic = false;
@@ -357,6 +361,10 @@ void GameCommand::LoadOne( const Command& cmd )
{
m_bClearMachineStats = true;
}
else if( sName == "clearmachineedits" )
{
m_bClearMachineEdits = true;
}
else if( sName == "fillmachinestats" )
{
m_bFillMachineStats = true;
@@ -365,6 +373,14 @@ void GameCommand::LoadOne( const Command& cmd )
{
m_bTransferStatsFromMachine = true;
}
else if( sName == "copyeditstomachine" )
{
m_bCopyEditsToMachine = true;
}
else if( sName == "copyeditsfrommachine" )
{
m_bCopyEditsFromMachine = true;
}
else if( sName == "transferstatstomachine" )
{
m_bTransferStatsToMachine = true;
@@ -789,6 +805,27 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
PROFILEMAN->SaveMachineProfile();
SCREENMAN->SystemMessage( "Machine stats cleared." );
}
if( m_bClearMachineEdits )
{
int iNumAttempted = 0;
int iNumSuccessful = 0;
vector<CString> vsEditFiles;
GetDirListing( PROFILEMAN->GetProfileDir(PROFILE_SLOT_MACHINE)+EDIT_SUBDIR+"*.edit", vsEditFiles, false, true );
FOREACH_CONST( CString, vsEditFiles, i )
{
iNumAttempted++;
bool bSuccess = FILEMAN->Remove( *i );
if( bSuccess )
iNumSuccessful++;
}
// reload the machine profile
PROFILEMAN->SaveMachineProfile();
PROFILEMAN->LoadMachineProfile();
SCREENMAN->SystemMessage( ssprintf("%d edits cleared, %d errors.",iNumSuccessful,iNumAttempted-iNumSuccessful) );
}
if( m_bFillMachineStats )
{
// Choose a percent for all scores. This is useful for testing unlocks
@@ -908,6 +945,94 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
MEMCARDMAN->FlushAndReset();
}
if( m_bCopyEditsFromMachine )
{
bool bTriedToCopy = false;
FOREACH_PlayerNumber( pn )
{
if( MEMCARDMAN->GetCardState(pn) != MEMORY_CARD_STATE_READY )
continue; // skip
MEMCARDMAN->MountCard(pn);
bTriedToCopy = true;
CString sFromDir = PROFILEMAN->GetProfileDir(PROFILE_SLOT_MACHINE) + EDIT_SUBDIR;
CString sToDir = MEM_CARD_MOUNT_POINT[pn] + PREFSMAN->m_sMemoryCardProfileSubdir + "/" + EDITS_SUBDIR;
int iNumAttempted = 0;
int iNumSuccessful = 0;
int iNumOverwritten = 0;
vector<CString> vsEditFiles;
GetDirListing( sFromDir+"*.edit", vsEditFiles, false, false );
FOREACH_CONST( CString, vsEditFiles, i )
{
iNumAttempted++;
if( DoesFileExist(sToDir+*i) )
iNumOverwritten++;
bool bSuccess = FileCopy( sFromDir+*i, sToDir+*i );
if( bSuccess )
iNumSuccessful++;
}
MEMCARDMAN->UnmountCard(pn);
SCREENMAN->SystemMessage( ssprintf("Copied to P%d card:\n attempted %d copies (%d overwritten)\n %d files copied, %d errors.",pn+1,iNumAttempted,iNumOverwritten,iNumSuccessful,iNumAttempted-iNumSuccessful) );
break;
}
if( !bTriedToCopy )
SCREENMAN->SystemMessage( "Edits not copied - No memory cards ready." );
MEMCARDMAN->FlushAndReset();
}
if( m_bCopyEditsToMachine )
{
bool bTriedToCopy = false;
FOREACH_PlayerNumber( pn )
{
if( MEMCARDMAN->GetCardState(pn) != MEMORY_CARD_STATE_READY )
continue; // skip
MEMCARDMAN->MountCard(pn);
bTriedToCopy = true;
CString sFromDir = MEM_CARD_MOUNT_POINT[pn] + PREFSMAN->m_sMemoryCardProfileSubdir + "/" + EDITS_SUBDIR;
CString sToDir = PROFILEMAN->GetProfileDir(PROFILE_SLOT_MACHINE) + EDIT_SUBDIR;
int iNumAttempted = 0;
int iNumSuccessful = 0;
int iNumOverwritten = 0;
vector<CString> vsEditFiles;
GetDirListing( sFromDir+"*.edit", vsEditFiles, false, false );
FOREACH_CONST( CString, vsEditFiles, i )
{
iNumAttempted++;
if( DoesFileExist(sToDir+*i) )
iNumOverwritten++;
bool bSuccess = FileCopy( sFromDir+*i, sToDir+*i );
if( bSuccess )
iNumSuccessful++;
}
MEMCARDMAN->UnmountCard(pn);
// reload the machine profile
PROFILEMAN->SaveMachineProfile();
PROFILEMAN->LoadMachineProfile();
SCREENMAN->SystemMessage( ssprintf("Copied from P%d card:\n attempted %d copies (%d overwritten)\n %d files copied, %d errors.",pn+1,iNumAttempted,iNumOverwritten,iNumSuccessful,iNumAttempted-iNumSuccessful) );
break;
}
if( !bTriedToCopy )
SCREENMAN->SystemMessage( "Edits not copied - No memory cards ready." );
MEMCARDMAN->FlushAndReset();
}
if( m_bInsertCredit )
{
InsertCredit();
+3
View File
@@ -74,9 +74,12 @@ public:
bool m_bClearBookkeepingData;
bool m_bClearMachineStats;
bool m_bClearMachineEdits;
bool m_bFillMachineStats; // for testing
bool m_bTransferStatsFromMachine;
bool m_bTransferStatsToMachine;
bool m_bCopyEditsFromMachine;
bool m_bCopyEditsToMachine;
bool m_bInsertCredit;
bool m_bResetToFactoryDefaults;
bool m_bStopMusic;
+1
View File
@@ -369,6 +369,7 @@ void ProfileManager::LoadMachineProfile()
// If the machine name has changed, make sure we use the new name
m_MachineProfile.m_sDisplayName = PREFSMAN->m_sMachineName;
SONGMAN->FreeAllLoadedFromProfile( PROFILE_SLOT_MACHINE );
SONGMAN->LoadAllFromProfileDir( MACHINE_PROFILE_DIR, PROFILE_SLOT_MACHINE );
}
+2 -2
View File
@@ -1175,12 +1175,12 @@ void SongManager::UpdateRankingCourses()
}
}
void SongManager::LoadAllFromProfileDir( const CString &sDir, ProfileSlot slot )
void SongManager::LoadAllFromProfileDir( const CString &sProfileDir, ProfileSlot slot )
{
//
// Load all .edit files.
//
CString sEditsDir = sDir+"Edits/";
CString sEditsDir = sProfileDir + EDIT_SUBDIR;
CStringArray asEditsFilesWithPath;
GetDirListing( sEditsDir+"*.edit", asEditsFilesWithPath, false, true );
+2 -1
View File
@@ -34,7 +34,7 @@ public:
void RegenerateNonFixedCourses();
void SetPreferences();
void LoadAllFromProfileDir( const CString &sDir, ProfileSlot slot );
void LoadAllFromProfileDir( const CString &sProfileDir, ProfileSlot slot );
int GetNumStepsLoadedFromProfile();
void FreeAllLoadedFromProfile( ProfileSlot slot = PROFILE_SLOT_INVALID );
@@ -119,6 +119,7 @@ protected:
vector<Course*> m_pShuffledCourses; // used by GetRandomCourse
};
static const CString EDIT_SUBDIR = "Edits/";
extern SongManager* SONGMAN; // global and accessable from anywhere in our program