move some service menu actions from GameCommand into ScreenServiceAction

This commit is contained in:
Chris Danford
2005-11-29 23:15:11 +00:00
parent 749a8468a9
commit cd9cf4c1e2
20 changed files with 534 additions and 418 deletions
+2 -2
View File
@@ -12,8 +12,8 @@
#include "EnumHelper.h"
#include "RageTypes.h"
struct PlayerOptions;
struct SongOptions;
class PlayerOptions;
class SongOptions;
class Song;
class Steps;
class Profile;
+6 -390
View File
@@ -4,29 +4,22 @@
#include "RageLog.h"
#include "GameManager.h"
#include "GameState.h"
#include "RageDisplay.h"
#include "AnnouncerManager.h"
#include "PlayerOptions.h"
#include "ProfileManager.h"
#include "Profile.h"
#include "StepMania.h"
#include "ScreenManager.h"
#include "SongManager.h"
#include "PrefsManager.h"
#include "arch/ArchHooks/ArchHooks.h"
#include "MemoryCardManager.h"
#include "song.h"
#include "Game.h"
#include "Style.h"
#include "Foreach.h"
#include "Command.h"
#include "arch/Dialog/Dialog.h"
#include "Bookkeeper.h"
#include "UnlockManager.h"
#include "GameSoundManager.h"
#include "ThemeManager.h"
#include "PlayerState.h"
#include "Course.h"
#include "RageFileManager.h"
#include "SongManager.h"
#include "song.h"
#include "UnlockManager.h"
void GameCommand::Init()
{
@@ -58,20 +51,11 @@ void GameCommand::Init()
m_GoalType = GOAL_INVALID;
m_sProfileID = "";
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;
m_bApplyDefaultOptions = false;
}
class SongOptions;
bool CompareSongOptions( const SongOptions &so1, const SongOptions &so2 );
bool GameCommand::DescribesCurrentModeForAllPlayers() const
@@ -363,54 +347,15 @@ void GameCommand::LoadOne( const Command& cmd )
m_vsScreensToPrepare.push_back( sValue );
}
else if( sName == "clearbookkeepingdata" )
{
m_bClearBookkeepingData = true;
}
else if( sName == "clearmachinestats" )
{
m_bClearMachineStats = true;
}
else if( sName == "clearmachineedits" )
{
m_bClearMachineEdits = true;
}
else if( sName == "fillmachinestats" )
{
m_bFillMachineStats = true;
}
else if( sName == "transferstatsfrommachine" )
{
m_bTransferStatsFromMachine = true;
}
else if( sName == "copyeditstomachine" )
{
m_bCopyEditsToMachine = true;
}
else if( sName == "copyeditsfrommachine" )
{
m_bCopyEditsFromMachine = true;
}
else if( sName == "transferstatstomachine" )
{
m_bTransferStatsToMachine = true;
}
else if( sName == "insertcredit" )
{
m_bInsertCredit = true;
}
else if( sName == "resettofactorydefaults" )
{
m_bResetToFactoryDefaults = true;
}
else if( sName == "stopmusic" )
{
m_bStopMusic = true;
}
else if( sName == "applydefaultoptions" )
{
m_bApplyDefaultOptions = true;
}
else
{
@@ -609,77 +554,6 @@ void GameCommand::Apply( PlayerNumber pn ) const
Apply( vpns );
}
static HighScore MakeRandomHighScore( float fPercentDP )
{
HighScore hs;
hs.SetName( "FAKE" );
hs.SetGrade( (Grade)SCALE( rand()%5, 0, 4, Grade_Tier01, Grade_Tier05 ) );
hs.SetScore( rand()%100*1000 );
hs.SetPercentDP( fPercentDP );
hs.SetSurviveSeconds( randomf(30.0f, 100.0f) );
PlayerOptions po;
po.ChooseRandomModifiers();
hs.SetModifiers( po.GetString() );
hs.SetDateTime( DateTime::GetNowDateTime() );
hs.SetPlayerGuid( Profile::MakeGuid() );
hs.SetMachineGuid( Profile::MakeGuid() );
hs.SetProductID( rand()%10 );
FOREACH_TapNoteScore( tns )
hs.SetTapNoteScore( tns, rand() % 100 );
FOREACH_HoldNoteScore( hns )
hs.SetHoldNoteScore( hns, rand() % 100 );
RadarValues rv;
FOREACH_RadarCategory( rc )
rv.m_Values.f[rc] = randomf( 0, 1 );
hs.SetRadarValues( rv );
return hs;
}
static void FillProfile( Profile *pProfile )
{
// Choose a percent for all scores. This is useful for testing unlocks
// where some elements are unlocked at a certain percent complete
float fPercentDP = randomf( 0.6f, 1.2f );
CLAMP( fPercentDP, 0.0f, 1.0f );
int iCount = pProfile->IsMachine()?
PREFSMAN->m_iMaxHighScoresPerListForMachine.Get():
PREFSMAN->m_iMaxHighScoresPerListForPlayer.Get();
vector<Song*> vpAllSongs = SONGMAN->GetAllSongs();
FOREACH( Song*, vpAllSongs, pSong )
{
vector<Steps*> vpAllSteps = (*pSong)->GetAllSteps();
FOREACH( Steps*, vpAllSteps, pSteps )
{
pProfile->IncrementStepsPlayCount( *pSong, *pSteps );
for( int i=0; i<iCount; i++ )
{
int iIndex = 0;
pProfile->AddStepsHighScore( *pSong, *pSteps, MakeRandomHighScore(fPercentDP), iIndex );
}
}
}
vector<Course*> vpAllCourses;
SONGMAN->GetAllCourses( vpAllCourses, true );
FOREACH( Course*, vpAllCourses, pCourse )
{
vector<Trail*> vpAllTrails;
(*pCourse)->GetAllTrails( vpAllTrails );
FOREACH( Trail*, vpAllTrails, pTrail )
{
pProfile->IncrementCoursePlayCount( *pCourse, *pTrail );
for( int i=0; i<iCount; i++ )
{
int iIndex = 0;
pProfile->AddCourseHighScore( *pCourse, *pTrail, MakeRandomHighScore(fPercentDP), iIndex );
}
}
}
}
/* Hack: if this GameCommand would set the screen, clear the setting and return
* the screen that would have been set. */
@@ -844,268 +718,10 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
FOREACH_CONST( CString, m_vsScreensToPrepare, s )
SCREENMAN->PrepareScreen( *s );
if( m_bClearBookkeepingData )
{
BOOKKEEPER->ClearAll();
BOOKKEEPER->WriteToDisk();
SCREENMAN->SystemMessage( "Bookkeeping data cleared." );
}
if( m_bClearMachineStats )
{
Profile* pProfile = PROFILEMAN->GetMachineProfile();
// don't reset the Guid
CString sGuid = pProfile->m_sGuid;
pProfile->InitAll();
pProfile->m_sGuid = sGuid;
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_STEPS_SUBDIR+"*.edit", vsEditFiles, false, true );
GetDirListing( PROFILEMAN->GetProfileDir(PROFILE_SLOT_MACHINE)+EDIT_COURSES_SUBDIR+"*.crs", 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 )
{
Profile* pProfile = PROFILEMAN->GetMachineProfile();
FillProfile( pProfile );
PROFILEMAN->SaveMachineProfile();
SCREENMAN->SystemMessage( "Machine stats filled." );
}
if( m_bTransferStatsFromMachine )
{
bool bTriedToSave = false;
FOREACH_PlayerNumber( pn )
{
if( MEMCARDMAN->GetCardState(pn) != MEMORY_CARD_STATE_READY )
continue; // skip
MEMCARDMAN->MountCard(pn);
bTriedToSave = true;
CString sDir = MEM_CARD_MOUNT_POINT[pn];
sDir += "MachineProfile/";
bool bSaved = PROFILEMAN->GetMachineProfile()->SaveAllToDir( sDir, PREFSMAN->m_bSignProfileData );
MEMCARDMAN->UnmountCard(pn);
if( bSaved )
SCREENMAN->SystemMessage( ssprintf("Machine stats saved to P%d card.",pn+1) );
else
SCREENMAN->SystemMessage( ssprintf("Error saving machine stats to P%d card.",pn+1) );
break;
}
if( !bTriedToSave )
SCREENMAN->SystemMessage( "Stats not saved - No memory cards ready." );
MEMCARDMAN->FlushAndReset();
}
if( m_bTransferStatsToMachine )
{
bool bTriedToLoad = false;
FOREACH_PlayerNumber( pn )
{
if( MEMCARDMAN->GetCardState(pn) != MEMORY_CARD_STATE_READY )
continue; // skip
MEMCARDMAN->MountCard(pn);
bTriedToLoad = true;
CString sDir = MEM_CARD_MOUNT_POINT[pn];
sDir += "MachineProfile/";
Profile backup = *PROFILEMAN->GetMachineProfile();
ProfileLoadResult lr = PROFILEMAN->GetMachineProfile()->LoadAllFromDir( sDir, PREFSMAN->m_bSignProfileData );
switch( lr )
{
case ProfileLoadResult_Success:
SCREENMAN->SystemMessage( ssprintf("Machine stats loaded from P%d card.",pn+1) );
break;
case ProfileLoadResult_FailedNoProfile:
SCREENMAN->SystemMessage( ssprintf("There is no machine profile on P%d card.",pn+1) );
*PROFILEMAN->GetMachineProfile() = backup;
break;
case ProfileLoadResult_FailedTampered:
SCREENMAN->SystemMessage( ssprintf("The profile on P%d card contains corrupt or tampered data.",pn+1) );
*PROFILEMAN->GetMachineProfile() = backup;
break;
default:
ASSERT(0);
}
MEMCARDMAN->UnmountCard(pn);
break;
}
if( !bTriedToLoad )
SCREENMAN->SystemMessage( "Stats not loaded - No memory cards ready." );
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;
int iNumAttempted = 0;
int iNumSuccessful = 0;
int iNumOverwritten = 0;
{
CString sFromDir = PROFILEMAN->GetProfileDir(PROFILE_SLOT_MACHINE) + EDIT_STEPS_SUBDIR;
CString sToDir = MEM_CARD_MOUNT_POINT[pn] + (CString)PREFSMAN->m_sMemoryCardProfileSubdir + "/" + EDIT_STEPS_SUBDIR;
vector<CString> vsFiles;
GetDirListing( sFromDir+"*.edit", vsFiles, false, false );
FOREACH_CONST( CString, vsFiles, i )
{
iNumAttempted++;
if( DoesFileExist(sToDir+*i) )
iNumOverwritten++;
bool bSuccess = FileCopy( sFromDir+*i, sToDir+*i );
if( bSuccess )
iNumSuccessful++;
}
}
{
CString sFromDir = PROFILEMAN->GetProfileDir(PROFILE_SLOT_MACHINE) + EDIT_COURSES_SUBDIR;
CString sToDir = MEM_CARD_MOUNT_POINT[pn] + (CString)PREFSMAN->m_sMemoryCardProfileSubdir + "/" + EDIT_COURSES_SUBDIR;
vector<CString> vsFiles;
GetDirListing( sFromDir+"*.crs", vsFiles, false, false );
FOREACH_CONST( CString, vsFiles, 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: %d/%d copies OK (%d overwritten).",pn+1,iNumSuccessful,iNumAttempted,iNumOverwritten) );
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;
int iNumAttempted = 0;
int iNumSuccessful = 0;
int iNumOverwritten = 0;
{
CString sFromDir = MEM_CARD_MOUNT_POINT[pn] + (CString)PREFSMAN->m_sMemoryCardProfileSubdir + "/" + EDIT_STEPS_SUBDIR;
CString sToDir = PROFILEMAN->GetProfileDir(PROFILE_SLOT_MACHINE) + EDIT_STEPS_SUBDIR;
vector<CString> vsFiles;
GetDirListing( sFromDir+"*.edit", vsFiles, false, false );
FOREACH_CONST( CString, vsFiles, i )
{
iNumAttempted++;
if( DoesFileExist(sToDir+*i) )
iNumOverwritten++;
bool bSuccess = FileCopy( sFromDir+*i, sToDir+*i );
if( bSuccess )
iNumSuccessful++;
}
}
{
CString sFromDir = MEM_CARD_MOUNT_POINT[pn] + (CString)PREFSMAN->m_sMemoryCardProfileSubdir + "/" + EDIT_COURSES_SUBDIR;
CString sToDir = PROFILEMAN->GetProfileDir(PROFILE_SLOT_MACHINE) + EDIT_COURSES_SUBDIR;
vector<CString> vsFiles;
GetDirListing( sFromDir+"*.crs", vsFiles, false, false );
FOREACH_CONST( CString, vsFiles, 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: %d/%d copies OK (%d overwritten).",pn+1,iNumSuccessful,iNumAttempted,iNumOverwritten) );
break;
}
if( !bTriedToCopy )
SCREENMAN->SystemMessage( "Edits not copied - No memory cards ready." );
MEMCARDMAN->FlushAndReset();
}
if( m_bInsertCredit )
{
InsertCredit();
}
if( m_bResetToFactoryDefaults )
{
PREFSMAN->ResetToFactoryDefaults();
SCREENMAN->SystemMessage( "All options reset to factory defaults." );
}
if( m_bApplyDefaultOptions )
{
FOREACH_PlayerNumber( p )
GAMESTATE->GetDefaultPlayerOptions( GAMESTATE->m_pPlayerState[p]->m_PlayerOptions );
GAMESTATE->GetDefaultSongOptions( GAMESTATE->m_SongOptions );
}
// 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 &&
-10
View File
@@ -76,18 +76,8 @@ public:
GoalType m_GoalType;
CString m_sProfileID;
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;
bool m_bApplyDefaultOptions;
// Lua
void PushSelf( lua_State *L );
+1 -1
View File
@@ -29,7 +29,7 @@ class PlayerState;
struct lua_State;
class LuaTable;
class Profile;
struct PlayerOptions;
class PlayerOptions;
class GameState
{
+1
View File
@@ -60,6 +60,7 @@ ScreenPrompt.cpp ScreenPrompt.h ScreenRanking.cpp ScreenRanking.h \
ScreenReloadSongs.cpp ScreenReloadSongs.h \
ScreenSandbox.cpp ScreenSandbox.h \
ScreenSaveSync.cpp ScreenSaveSync.h \
ScreenServiceAction.cpp ScreenServiceAction.h \
ScreenStatsOverlay.cpp ScreenStatsOverlay.h \
ScreenSelect.cpp ScreenSelect.h ScreenSelectCharacter.cpp ScreenSelectCharacter.h \
ScreenSelectDifficulty.cpp ScreenSelectDifficulty.h ScreenSelectGroup.cpp ScreenSelectGroup.h \
+1
View File
@@ -64,6 +64,7 @@ static const CString MessageNames[] = {
"LessonTry3",
"LessonCleared",
"LessonFailed",
"StorageDevicesChanged",
};
XToString( Message, NUM_Message );
+1
View File
@@ -79,6 +79,7 @@ enum Message
Message_LessonTry3,
Message_LessonCleared,
Message_LessonFailed,
Message_StorageDevicesChanged,
NUM_Message, // leave this at the end
Message_Invalud
};
+1 -1
View File
@@ -7,7 +7,7 @@
#include "NoteTypes.h"
#include "NoteData.h"
struct PlayerOptions;
class PlayerOptions;
struct RadarValues;
/* Utils for NoteData. Things should go in here if they can be (cleanly and
+1 -1
View File
@@ -6,7 +6,7 @@
#include "ActorFrame.h"
#include "OptionIcon.h"
struct PlayerOptions;
class PlayerOptions;
struct lua_State;
const unsigned NUM_OPTION_COLS = 8;
+2 -1
View File
@@ -10,8 +10,9 @@ class Trail;
#include "GameConstantsAndTypes.h"
struct PlayerOptions
class PlayerOptions
{
public:
PlayerOptions() { Init(); };
void Init();
void Approach( const PlayerOptions& other, float fDeltaSeconds );
-1
View File
@@ -1,7 +1,6 @@
#include "global.h"
#include "ScreenCredits.h"
#include "GameSoundManager.h"
#include "RageLog.h"
#include "AnnouncerManager.h"
+9 -5
View File
@@ -4,6 +4,7 @@
#include "arch/MemoryCard/MemoryCardDriver.h"
#include "MemoryCardManager.h"
#include "GameState.h"
#include "ScreenManager.h"
REGISTER_SCREEN_CLASS( ScreenOptionsMemoryCard );
@@ -25,7 +26,7 @@ void ScreenOptionsMemoryCard::Init()
if( sVolumeLabel.empty() )
sVolumeLabel = "(no label)";
CString sDescription = ssprintf( "%s %s", sOsMountDir.c_str(), sVolumeLabel.c_str() );
OptionRowDefinition def( sDescription, true, "Enable", "Disable" );
OptionRowDefinition def( sDescription, true, "" );
def.m_bAllowThemeTitles = false;
def.m_bAllowExplanation = false;
m_vDefs.push_back( def );
@@ -57,13 +58,16 @@ void ScreenOptionsMemoryCard::BeginScreen()
void ScreenOptionsMemoryCard::HandleScreenMessage( const ScreenMessage SM )
{
if( SM == SM_GoToNextScreen )
{
MEMCARDMAN->Update(0, true);
}
ScreenOptions::HandleScreenMessage( SM );
}
void ScreenOptionsMemoryCard::HandleMessage( const CString& sMessage )
{
if( sMessage == MessageToString(Message_StorageDevicesChanged) )
{
SCREENMAN->SetNewScreen( this->m_sName ); // reload
}
}
void ScreenOptionsMemoryCard::MenuStart( const InputEventPlus &input )
{
+2
View File
@@ -18,6 +18,8 @@ private:
void ImportOptions( int iRow, const vector<PlayerNumber> &vpns );
void ExportOptions( int iRow, const vector<PlayerNumber> &vpns );
void HandleMessage( const CString& sMessage );
vector<OptionRowDefinition> m_vDefs;
};
-1
View File
@@ -3,7 +3,6 @@
#include "GameState.h"
#include "song.h"
#include "PrefsManager.h"
#include "ScreenPrompt.h"
static CString GetPromptText()
+447
View File
@@ -0,0 +1,447 @@
#include "global.h"
#include "ScreenServiceAction.h"
#include "ThemeManager.h"
#include "Bookkeeper.h"
#include "Profile.h"
#include "ProfileManager.h"
#include "ScreenManager.h"
#include "RageFileManager.h"
#include "PrefsManager.h"
#include "SongManager.h"
#include "song.h"
#include "MemoryCardManager.h"
#include "GameState.h"
#include "PlayerState.h"
static CString ClearBookkeepingData()
{
BOOKKEEPER->ClearAll();
BOOKKEEPER->WriteToDisk();
return "Bookkeeping data cleared.";
}
static CString ClearMachineStats()
{
Profile* pProfile = PROFILEMAN->GetMachineProfile();
// don't reset the Guid
CString sGuid = pProfile->m_sGuid;
pProfile->InitAll();
pProfile->m_sGuid = sGuid;
PROFILEMAN->SaveMachineProfile();
return "Machine stats cleared.";
}
static CString ClearMachineEdits()
{
int iNumAttempted = 0;
int iNumSuccessful = 0;
vector<CString> vsEditFiles;
GetDirListing( PROFILEMAN->GetProfileDir(PROFILE_SLOT_MACHINE)+EDIT_STEPS_SUBDIR+"*.edit", vsEditFiles, false, true );
GetDirListing( PROFILEMAN->GetProfileDir(PROFILE_SLOT_MACHINE)+EDIT_COURSES_SUBDIR+"*.crs", 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();
return ssprintf("%d edits cleared, %d errors.",iNumSuccessful,iNumAttempted-iNumSuccessful);
}
static CString ClearMemoryCardEdits()
{
int iNumAttempted = 0;
int iNumSuccessful = 0;
bool bTriedToLoad = false;
FOREACH_PlayerNumber( pn )
{
if( MEMCARDMAN->GetCardState(pn) != MEMORY_CARD_STATE_READY )
continue; // skip
MEMCARDMAN->MountCard(pn);
bTriedToLoad = true;
CString sDir = MEM_CARD_MOUNT_POINT[pn];
vector<CString> vsEditFiles;
GetDirListing( sDir+EDIT_STEPS_SUBDIR+"*.edit", vsEditFiles, false, true );
GetDirListing( sDir+EDIT_COURSES_SUBDIR+"*.crs", vsEditFiles, false, true );
FOREACH_CONST( CString, vsEditFiles, i )
{
iNumAttempted++;
bool bSuccess = FILEMAN->Remove( *i );
if( bSuccess )
iNumSuccessful++;
}
MEMCARDMAN->UnmountCard(pn);
break;
}
if( !bTriedToLoad )
return "Stats not loaded - No memory cards ready.";
MEMCARDMAN->FlushAndReset();
return ssprintf("%d edits cleared, %d errors.",iNumSuccessful,iNumAttempted-iNumSuccessful);
}
static HighScore MakeRandomHighScore( float fPercentDP )
{
HighScore hs;
hs.SetName( "FAKE" );
hs.SetGrade( (Grade)SCALE( rand()%5, 0, 4, Grade_Tier01, Grade_Tier05 ) );
hs.SetScore( rand()%100*1000 );
hs.SetPercentDP( fPercentDP );
hs.SetSurviveSeconds( randomf(30.0f, 100.0f) );
PlayerOptions po;
po.ChooseRandomModifiers();
hs.SetModifiers( po.GetString() );
hs.SetDateTime( DateTime::GetNowDateTime() );
hs.SetPlayerGuid( Profile::MakeGuid() );
hs.SetMachineGuid( Profile::MakeGuid() );
hs.SetProductID( rand()%10 );
FOREACH_TapNoteScore( tns )
hs.SetTapNoteScore( tns, rand() % 100 );
FOREACH_HoldNoteScore( hns )
hs.SetHoldNoteScore( hns, rand() % 100 );
RadarValues rv;
FOREACH_RadarCategory( rc )
rv.m_Values.f[rc] = randomf( 0, 1 );
hs.SetRadarValues( rv );
return hs;
}
static void FillProfile( Profile *pProfile )
{
// Choose a percent for all scores. This is useful for testing unlocks
// where some elements are unlocked at a certain percent complete
float fPercentDP = randomf( 0.6f, 1.2f );
CLAMP( fPercentDP, 0.0f, 1.0f );
int iCount = pProfile->IsMachine()?
PREFSMAN->m_iMaxHighScoresPerListForMachine.Get():
PREFSMAN->m_iMaxHighScoresPerListForPlayer.Get();
vector<Song*> vpAllSongs = SONGMAN->GetAllSongs();
FOREACH( Song*, vpAllSongs, pSong )
{
vector<Steps*> vpAllSteps = (*pSong)->GetAllSteps();
FOREACH( Steps*, vpAllSteps, pSteps )
{
pProfile->IncrementStepsPlayCount( *pSong, *pSteps );
for( int i=0; i<iCount; i++ )
{
int iIndex = 0;
pProfile->AddStepsHighScore( *pSong, *pSteps, MakeRandomHighScore(fPercentDP), iIndex );
}
}
}
vector<Course*> vpAllCourses;
SONGMAN->GetAllCourses( vpAllCourses, true );
FOREACH( Course*, vpAllCourses, pCourse )
{
vector<Trail*> vpAllTrails;
(*pCourse)->GetAllTrails( vpAllTrails );
FOREACH( Trail*, vpAllTrails, pTrail )
{
pProfile->IncrementCoursePlayCount( *pCourse, *pTrail );
for( int i=0; i<iCount; i++ )
{
int iIndex = 0;
pProfile->AddCourseHighScore( *pCourse, *pTrail, MakeRandomHighScore(fPercentDP), iIndex );
}
}
}
}
static CString FillMachineStats()
{
Profile* pProfile = PROFILEMAN->GetMachineProfile();
FillProfile( pProfile );
PROFILEMAN->SaveMachineProfile();
return "Machine stats filled.";
}
static CString TransferStatsMachineToMemoryCard()
{
bool bTriedToSave = false;
FOREACH_PlayerNumber( pn )
{
if( MEMCARDMAN->GetCardState(pn) != MEMORY_CARD_STATE_READY )
continue; // skip
MEMCARDMAN->MountCard(pn);
bTriedToSave = true;
CString sDir = MEM_CARD_MOUNT_POINT[pn];
sDir += "MachineProfile/";
bool bSaved = PROFILEMAN->GetMachineProfile()->SaveAllToDir( sDir, PREFSMAN->m_bSignProfileData );
MEMCARDMAN->UnmountCard(pn);
if( bSaved )
return ssprintf("Machine stats saved to P%d card.",pn+1);
else
return ssprintf("Error saving machine stats to P%d card.",pn+1);
break;
}
if( !bTriedToSave )
return "Stats not saved - No memory cards ready.";
MEMCARDMAN->FlushAndReset();
return "Stats transferred to Memory Card";
}
static CString TransferStatsMemoryCardToMachine()
{
bool bTriedToLoad = false;
FOREACH_PlayerNumber( pn )
{
if( MEMCARDMAN->GetCardState(pn) != MEMORY_CARD_STATE_READY )
continue; // skip
MEMCARDMAN->MountCard(pn);
bTriedToLoad = true;
CString sDir = MEM_CARD_MOUNT_POINT[pn];
sDir += "MachineProfile/";
Profile backup = *PROFILEMAN->GetMachineProfile();
ProfileLoadResult lr = PROFILEMAN->GetMachineProfile()->LoadAllFromDir( sDir, PREFSMAN->m_bSignProfileData );
switch( lr )
{
case ProfileLoadResult_Success:
return ssprintf("Machine stats loaded from P%d card.",pn+1);
break;
case ProfileLoadResult_FailedNoProfile:
return ssprintf("There is no machine profile on P%d card.",pn+1);
*PROFILEMAN->GetMachineProfile() = backup;
break;
case ProfileLoadResult_FailedTampered:
return ssprintf("The profile on P%d card contains corrupt or tampered data.",pn+1);
*PROFILEMAN->GetMachineProfile() = backup;
break;
default:
ASSERT(0);
}
MEMCARDMAN->UnmountCard(pn);
break;
}
if( !bTriedToLoad )
return "Stats not loaded - No memory cards ready.";
MEMCARDMAN->FlushAndReset();
return "Stats transferred to machine.";
}
static CString CopyEditsMachineToMemoryCard()
{
bool bTriedToCopy = false;
FOREACH_PlayerNumber( pn )
{
if( MEMCARDMAN->GetCardState(pn) != MEMORY_CARD_STATE_READY )
continue; // skip
MEMCARDMAN->MountCard(pn);
bTriedToCopy = true;
int iNumAttempted = 0;
int iNumSuccessful = 0;
int iNumOverwritten = 0;
{
CString sFromDir = PROFILEMAN->GetProfileDir(PROFILE_SLOT_MACHINE) + EDIT_STEPS_SUBDIR;
CString sToDir = MEM_CARD_MOUNT_POINT[pn] + (CString)PREFSMAN->m_sMemoryCardProfileSubdir + "/" + EDIT_STEPS_SUBDIR;
vector<CString> vsFiles;
GetDirListing( sFromDir+"*.edit", vsFiles, false, false );
FOREACH_CONST( CString, vsFiles, i )
{
iNumAttempted++;
if( DoesFileExist(sToDir+*i) )
iNumOverwritten++;
bool bSuccess = FileCopy( sFromDir+*i, sToDir+*i );
if( bSuccess )
iNumSuccessful++;
}
}
{
CString sFromDir = PROFILEMAN->GetProfileDir(PROFILE_SLOT_MACHINE) + EDIT_COURSES_SUBDIR;
CString sToDir = MEM_CARD_MOUNT_POINT[pn] + (CString)PREFSMAN->m_sMemoryCardProfileSubdir + "/" + EDIT_COURSES_SUBDIR;
vector<CString> vsFiles;
GetDirListing( sFromDir+"*.crs", vsFiles, false, false );
FOREACH_CONST( CString, vsFiles, i )
{
iNumAttempted++;
if( DoesFileExist(sToDir+*i) )
iNumOverwritten++;
bool bSuccess = FileCopy( sFromDir+*i, sToDir+*i );
if( bSuccess )
iNumSuccessful++;
}
}
MEMCARDMAN->UnmountCard(pn);
return ssprintf("Copied to P%d card: %d/%d copies OK (%d overwritten).",pn+1,iNumSuccessful,iNumAttempted,iNumOverwritten);
break;
}
if( !bTriedToCopy )
return "Edits not copied - No memory cards ready.";
MEMCARDMAN->FlushAndReset();
return "Edits copied to machine.";
}
static CString CopyEditsMemoryCardToMachine()
{
bool bTriedToCopy = false;
FOREACH_PlayerNumber( pn )
{
if( MEMCARDMAN->GetCardState(pn) != MEMORY_CARD_STATE_READY )
continue; // skip
MEMCARDMAN->MountCard(pn);
bTriedToCopy = true;
int iNumAttempted = 0;
int iNumSuccessful = 0;
int iNumOverwritten = 0;
{
CString sFromDir = MEM_CARD_MOUNT_POINT[pn] + (CString)PREFSMAN->m_sMemoryCardProfileSubdir + "/" + EDIT_STEPS_SUBDIR;
CString sToDir = PROFILEMAN->GetProfileDir(PROFILE_SLOT_MACHINE) + EDIT_STEPS_SUBDIR;
vector<CString> vsFiles;
GetDirListing( sFromDir+"*.edit", vsFiles, false, false );
FOREACH_CONST( CString, vsFiles, i )
{
iNumAttempted++;
if( DoesFileExist(sToDir+*i) )
iNumOverwritten++;
bool bSuccess = FileCopy( sFromDir+*i, sToDir+*i );
if( bSuccess )
iNumSuccessful++;
}
}
{
CString sFromDir = MEM_CARD_MOUNT_POINT[pn] + (CString)PREFSMAN->m_sMemoryCardProfileSubdir + "/" + EDIT_COURSES_SUBDIR;
CString sToDir = PROFILEMAN->GetProfileDir(PROFILE_SLOT_MACHINE) + EDIT_COURSES_SUBDIR;
vector<CString> vsFiles;
GetDirListing( sFromDir+"*.crs", vsFiles, false, false );
FOREACH_CONST( CString, vsFiles, 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();
return ssprintf("Copied from P%d card: %d/%d copies OK (%d overwritten).",pn+1,iNumSuccessful,iNumAttempted,iNumOverwritten);
break;
}
if( !bTriedToCopy )
return "Edits not copied - No memory cards ready.";
MEMCARDMAN->FlushAndReset();
return "Edits copied to memory card.";
}
static CString ResetPreferences()
{
PREFSMAN->ResetToFactoryDefaults();
return "Preferences reset.";
}
REGISTER_SCREEN_CLASS( ScreenServiceAction );
ScreenServiceAction::ScreenServiceAction( CString sClassName ) : ScreenPrompt( sClassName )
{
CString sAction = THEME->GetMetric(m_sName,"Action");
CString (*pfn)() = NULL;
if( sAction == "ClearBookkeepingData" ) pfn = ClearBookkeepingData;
else if( sAction == "ClearMachineStats" ) pfn = ClearMachineStats;
else if( sAction == "ClearMachineEdits" ) pfn = ClearMachineEdits;
else if( sAction == "ClearMemoryCardEdits" ) pfn = ClearMemoryCardEdits;
else if( sAction == "FillMachineStats" ) pfn = FillMachineStats;
else if( sAction == "TransferStatsMachineToMemoryCard" ) pfn = TransferStatsMachineToMemoryCard;
else if( sAction == "TransferStatsMemoryCardToMachine" ) pfn = TransferStatsMemoryCardToMachine;
else if( sAction == "CopyEditsMachineToMemoryCard" ) pfn = CopyEditsMachineToMemoryCard;
else if( sAction == "CopyEditsMemoryCardToMachine" ) pfn = CopyEditsMemoryCardToMachine;
else if( sAction == "ResetPreferences" ) pfn = ResetPreferences;
ASSERT_M( pfn, sAction );
CString s = pfn();
ScreenPrompt::SetPromptSettings( s, PROMPT_OK );
}
/*
* (c) 2001-2005 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+40
View File
@@ -0,0 +1,40 @@
/* ScreenServiceAction - */
#ifndef ScreenServiceAction_H
#define ScreenServiceAction_H
#include "ScreenPrompt.h"
class ScreenServiceAction : public ScreenPrompt
{
public:
ScreenServiceAction( CString sName );
};
#endif
/*
* (c) 2001-2005 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+1 -1
View File
@@ -7,7 +7,7 @@ class LoadingWindow;
class Song;
class Style;
class Steps;
struct PlayerOptions;
class PlayerOptions;
struct lua_State;
#include "RageTypes.h"
+2 -1
View File
@@ -3,8 +3,9 @@
#ifndef SONG_OPTIONS_H
#define SONG_OPTIONS_H
struct SongOptions
class SongOptions
{
public:
enum LifeType
{
LIFE_BAR=0,
+6
View File
@@ -610,6 +610,12 @@ cl /Zl /nologo /c verstub.cpp /Fo&quot;$(IntDir)&quot;\
<File
RelativePath="ScreenSelectStyle.h">
</File>
<File
RelativePath=".\ScreenServiceAction.cpp">
</File>
<File
RelativePath=".\ScreenServiceAction.h">
</File>
<File
RelativePath="ScreenSetTime.cpp">
</File>
+11 -3
View File
@@ -1,5 +1,5 @@
# Microsoft Developer Studio Project File - Name="StepMania" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 60000
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
@@ -62,7 +62,7 @@ IntDir=.\../Debug6
TargetDir=\cvs\stepmania\Program
TargetName=StepMania-debug
SOURCE="$(InputPath)"
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
# End Special Build Tool
@@ -99,7 +99,7 @@ IntDir=.\../Release6
TargetDir=\cvs\stepmania\Program
TargetName=StepMania
SOURCE="$(InputPath)"
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
# End Special Build Tool
@@ -3008,6 +3008,14 @@ SOURCE=.\ScreenSelectStyle.h
# End Source File
# Begin Source File
SOURCE=.\ScreenServiceAction.cpp
# End Source File
# Begin Source File
SOURCE=.\ScreenServiceAction.h
# End Source File
# Begin Source File
SOURCE=.\ScreenSetTime.cpp
# End Source File
# Begin Source File