re-add the ability to reload a theme's Lua scripts, this time via Ctrl+F2.

This commit is contained in:
AJ Kelly
2010-03-11 13:44:51 -06:00
parent cd17227872
commit f38037b7a8
2 changed files with 56 additions and 51 deletions
+1
View File
@@ -1640,6 +1640,7 @@ W5=Boo
[ThemeManager] [ThemeManager]
Reloaded metrics=Reloaded metrics Reloaded metrics=Reloaded metrics
Reloaded metrics and textures=Reloaded metrics and textures Reloaded metrics and textures=Reloaded metrics and textures
Reloaded scripts=Reloaded scripts
[WorkoutManager] [WorkoutManager]
You must supply a name for your workout.=You must supply a name for your workout. You must supply a name for your workout.=You must supply a name for your workout.
+52 -48
View File
@@ -206,7 +206,6 @@ static void StartDisplay()
DISPLAY = CreateDisplay(); DISPLAY = CreateDisplay();
DISPLAY->ChangeCentering( DISPLAY->ChangeCentering(
PREFSMAN->m_iCenterImageTranslateX, PREFSMAN->m_iCenterImageTranslateX,
PREFSMAN->m_iCenterImageTranslateY, PREFSMAN->m_iCenterImageTranslateY,
@@ -273,7 +272,7 @@ void StepMania::ApplyGraphicOptions()
if( SCREENMAN ) if( SCREENMAN )
SCREENMAN->SystemMessage( GetActualGraphicOptionsString() ); SCREENMAN->SystemMessage( GetActualGraphicOptionsString() );
/* Give the input handlers a chance to re-open devices as necessary. */ // Give the input handlers a chance to re-open devices as necessary.
INPUTMAN->WindowReset(); INPUTMAN->WindowReset();
} }
@@ -287,12 +286,12 @@ void StepMania::ResetPreferences()
ApplyGraphicOptions(); ApplyGraphicOptions();
} }
/* Shutdown all global singletons. Note that this may be called partway through /* Shutdown all global singletons. Note that this may be called partway through
* initialization, due to an object failing to initialize, in which case some of * initialization, due to an object failing to initialize, in which case some of
* these may still be NULL. */ * these may still be NULL. */
void ShutdownGame() void ShutdownGame()
{ {
/* First, tell SOUNDMAN that we're shutting down. This signals sound drivers to /* First, tell SOUNDMAN that we're shutting down. This signals sound drivers to
* stop sounds, which we want to do before any threads that may have started sounds * stop sounds, which we want to do before any threads that may have started sounds
* are closed; this prevents annoying DirectSound glitches and delays. */ * are closed; this prevents annoying DirectSound glitches and delays. */
if( SOUNDMAN ) if( SOUNDMAN )
@@ -309,7 +308,7 @@ void ShutdownGame()
SAFE_DELETE( INPUTMAPPER ); SAFE_DELETE( INPUTMAPPER );
SAFE_DELETE( INPUTFILTER ); SAFE_DELETE( INPUTFILTER );
SAFE_DELETE( MODELMAN ); SAFE_DELETE( MODELMAN );
SAFE_DELETE( PROFILEMAN ); // PROFILEMAN needs the songs still loaded SAFE_DELETE( PROFILEMAN ); // PROFILEMAN needs the songs still loaded
SAFE_DELETE( CHARMAN ); SAFE_DELETE( CHARMAN );
SAFE_DELETE( UNLOCKMAN ); SAFE_DELETE( UNLOCKMAN );
SAFE_DELETE( CRYPTMAN ); SAFE_DELETE( CRYPTMAN );
@@ -318,7 +317,7 @@ void ShutdownGame()
SAFE_DELETE( BANNERCACHE ); SAFE_DELETE( BANNERCACHE );
//SAFE_DELETE( BACKGROUNDCACHE ); //SAFE_DELETE( BACKGROUNDCACHE );
SAFE_DELETE( SONGINDEX ); SAFE_DELETE( SONGINDEX );
SAFE_DELETE( SOUND ); /* uses GAMESTATE, PREFSMAN */ SAFE_DELETE( SOUND ); // uses GAMESTATE, PREFSMAN
SAFE_DELETE( PREFSMAN ); SAFE_DELETE( PREFSMAN );
SAFE_DELETE( GAMESTATE ); SAFE_DELETE( GAMESTATE );
SAFE_DELETE( GAMEMAN ); SAFE_DELETE( GAMEMAN );
@@ -343,10 +342,10 @@ static void HandleException( const RString &sError )
if( g_bAutoRestart ) if( g_bAutoRestart )
HOOKS->RestartProgram(); HOOKS->RestartProgram();
/* Shut down first, so we exit graphics mode before trying to open a dialog. */ // Shut down first, so we exit graphics mode before trying to open a dialog.
ShutdownGame(); ShutdownGame();
/* Throw up a pretty error dialog. */ // Throw up a pretty error dialog.
Dialog::Error( sError ); Dialog::Error( sError );
Dialog::Shutdown(); // Shut it back down. Dialog::Shutdown(); // Shut it back down.
} }
@@ -359,7 +358,7 @@ void StepMania::ResetGame()
{ {
RString sGameName = GAMESTATE->GetCurrentGame()->m_szName; RString sGameName = GAMESTATE->GetCurrentGame()->m_szName;
if( !THEME->DoesThemeExist(sGameName) ) if( !THEME->DoesThemeExist(sGameName) )
sGameName = PREFSMAN->m_sDefaultTheme; // was "default" sGameName = PREFSMAN->m_sDefaultTheme; // was previously "default" -aj
THEME->SwitchThemeAndLanguage( sGameName, THEME->GetCurLanguage(), PREFSMAN->m_bPseudoLocalize ); THEME->SwitchThemeAndLanguage( sGameName, THEME->GetCurLanguage(), PREFSMAN->m_bPseudoLocalize );
TEXTUREMAN->DoDelayedDelete(); TEXTUREMAN->DoDelayedDelete();
} }
@@ -382,7 +381,7 @@ static Preference<int> g_iLastSeenMemory( "LastSeenMemory", 0 );
static void AdjustForChangedSystemCapabilities() static void AdjustForChangedSystemCapabilities()
{ {
#if defined(WIN32) #if defined(WIN32)
/* Has the amount of memory changed? */ // Has the amount of memory changed?
MEMORYSTATUS mem; MEMORYSTATUS mem;
GlobalMemoryStatus(&mem); GlobalMemoryStatus(&mem);
@@ -396,7 +395,7 @@ static void AdjustForChangedSystemCapabilities()
// is this assumption outdated? -aj // is this assumption outdated? -aj
/* Let's consider 128-meg systems low-memory, and 256-meg systems high-memory. /* Let's consider 128-meg systems low-memory, and 256-meg systems high-memory.
* Cut off at 192. This is somewhat conservative; many 128-meg systems can * Cut off at 192. This is somewhat conservative; many 128-meg systems can
* deal with higher memory profile settings, but some can't. * deal with higher memory profile settings, but some can't.
* *
* Actually, Windows lops off a meg or two; cut off a little lower to treat * Actually, Windows lops off a meg or two; cut off a little lower to treat
@@ -405,15 +404,15 @@ static void AdjustForChangedSystemCapabilities()
const bool LowMemory = (Memory < 100); /* 64 and 96-meg systems */ const bool LowMemory = (Memory < 100); /* 64 and 96-meg systems */
/* Two memory-consuming features that we can disable are texture caching and /* Two memory-consuming features that we can disable are texture caching and
* preloaded banners. Texture caching can use a lot of memory; disable it for * preloaded banners. Texture caching can use a lot of memory; disable it for
* low-memory systems. */ * low-memory systems. */
PREFSMAN->m_bDelayedTextureDelete.Set( HighMemory ); PREFSMAN->m_bDelayedTextureDelete.Set( HighMemory );
/* Preloaded banners takes about 9k per song. Although it's smaller than the /* Preloaded banners takes about 9k per song. Although it's smaller than the
* actual song data, it still adds up with a lot of songs. Disable it for 64-meg * actual song data, it still adds up with a lot of songs.
* systems. */ * Disable it for 64-meg systems. */
PREFSMAN->m_BannerCache.Set( LowMemory ? BNCACHE_OFF:BNCACHE_LOW_RES_PRELOAD ); PREFSMAN->m_BannerCache.Set( LowMemory ? BNCACHE_OFF:BNCACHE_LOW_RES_PRELOAD );
// might wanna do this for backgrounds, too... // might wanna do this for backgrounds, too... -aj
//PREFSMAN->m_BackgroundCache.Set( LowMemory ? BGCACHE_OFF:BGCACHE_LOW_RES_PRELOAD ); //PREFSMAN->m_BackgroundCache.Set( LowMemory ? BGCACHE_OFF:BGCACHE_LOW_RES_PRELOAD );
PREFSMAN->SavePrefsToDisk(); PREFSMAN->SavePrefsToDisk();
@@ -486,7 +485,7 @@ struct VideoCardDefaults
true // accelerated true // accelerated
), ),
VideoCardDefaults( VideoCardDefaults(
"Voodoo|3dfx", /* all other Voodoos: some drivers don't identify which one */ "Voodoo|3dfx", // all other Voodoos: some drivers don't identify which one
"d3d,opengl", "d3d,opengl",
640,480, 640,480,
16,16,16, 16,16,16,
@@ -529,8 +528,8 @@ struct VideoCardDefaults
"Savage", "Savage",
"d3d", "d3d",
// OpenGL is unusable on my Savage IV with even the latest drivers. // OpenGL is unusable on my Savage IV with even the latest drivers.
// It draws 30 frames of gibberish then crashes. This happens even with // It draws 30 frames of gibberish then crashes. This happens even with
// simple NeHe demos. -Chris // simple NeHe demos. -Chris
640,480, 640,480,
16,16,16, 16,16,16,
2048, 2048,
@@ -541,9 +540,9 @@ struct VideoCardDefaults
"d3d", "d3d",
// OpenGL is not hardware accelerated, despite the fact that the // OpenGL is not hardware accelerated, despite the fact that the
// drivers come with an ICD. Also, the WinXP driver performance // drivers come with an ICD. Also, the WinXP driver performance
// is terrible and supports only 640. The ATI driver is usable. // is terrible and supports only 640. The ATI driver is usable.
// -Chris // -Chris
320,240, // lower resolution for 60fps. In-box WinXP driver doesn't support 400x300. 320,240, // lower resolution for 60fps. In-box WinXP driver doesn't support 400x300.
16,16,16, 16,16,16,
256, 256,
false false
@@ -602,8 +601,8 @@ struct VideoCardDefaults
false false
), ),
VideoCardDefaults( VideoCardDefaults(
/* Unconfirmed texture problems on this; let's try D3D, since it's a VIA/S3 /* Unconfirmed texture problems on this; let's try D3D, since it's
* chipset. */ * a VIA/S3 chipset. */
"VIA/S3G KM400/KN400", "VIA/S3G KM400/KN400",
"d3d,opengl", "d3d,opengl",
640,480, 640,480,
@@ -617,7 +616,7 @@ struct VideoCardDefaults
640,480, 640,480,
16,16,16, 16,16,16,
2048, 2048,
true // Right now, they've got to have NVidia or ATi Cards anyway.. true // Right now, they've got to have NVidia or ATi Cards anyway..
), ),
VideoCardDefaults( VideoCardDefaults(
// Default graphics settings used for all cards that don't match above. // Default graphics settings used for all cards that don't match above.
@@ -664,7 +663,7 @@ bool CheckVideoDefaultSettings()
goto found_defaults; goto found_defaults;
} }
} }
ASSERT( 0 ); // we must have matched at least one above ASSERT( 0 ); // we must have matched at least one above
found_defaults: found_defaults:
@@ -725,16 +724,16 @@ RageDisplay *CreateDisplay()
* *
* If we try to load OpenGL and we're missing acceleration, it may mean: * If we try to load OpenGL and we're missing acceleration, it may mean:
* 1. We're missing drivers, and they just need upgrading. * 1. We're missing drivers, and they just need upgrading.
* 2. The card doesn't have drivers, and it should be using D3D8. In other words, * 2. The card doesn't have drivers, and it should be using D3D8.
* it needs an entry in this table. * In other words, it needs an entry in this table.
* 3. The card doesn't have drivers for either. (Sorry, no S3 868s.) Can't play. * 3. The card doesn't have drivers for either. (Sorry, no S3 868s.)
* * Can't play.
* In this case, fail to load; don't silently fall back on D3D. We don't want * In this case, fail to load; don't silently fall back on D3D. We don't want
* people unknowingly using D3D8 with old drivers (and reporting obscure bugs * people unknowingly using D3D8 with old drivers (and reporting obscure bugs
* due to driver problems). We'll probably get bug reports for all three types. * due to driver problems). We'll probably get bug reports for all three types.
* #2 is the only case that's actually a bug. * #2 is the only case that's actually a bug.
* *
* Actually, right now we're falling back. I'm not sure which behavior is better. * Actually, right now we're falling back. I'm not sure which behavior is better.
*/ */
//bool bAppliedDefaults = CheckVideoDefaultSettings(); //bool bAppliedDefaults = CheckVideoDefaultSettings();
@@ -792,7 +791,7 @@ RageDisplay *CreateDisplay()
continue; continue;
} }
break; // the display is ready to go break; // the display is ready to go
} }
if( pRet == NULL) if( pRet == NULL)
@@ -805,7 +804,7 @@ static void SwitchToLastPlayedGame()
{ {
const Game *pGame = GAMEMAN->StringToGame( PREFSMAN->GetCurrentGame() ); const Game *pGame = GAMEMAN->StringToGame( PREFSMAN->GetCurrentGame() );
/* If the active game type isn't actually available, revert to the default. */ // If the active game type isn't actually available, revert to the default.
if( pGame == NULL ) if( pGame == NULL )
pGame = GAMEMAN->GetDefaultGame(); pGame = GAMEMAN->GetDefaultGame();
@@ -917,7 +916,7 @@ static void WriteLogHeader()
#endif #endif
// this code should only be enabled in distributed builds // this code should only be enabled in distributed builds
LOG->Info("sm-ssc is Copyright ©2009 the spinal shark collective, all rights reserved. Commercial use of this binary is prohibited by law and will be prosecuted to the fullest extent of the law."); //LOG->Info("sm-ssc is Copyright ©2009 the spinal shark collective, all rights reserved. Commercial use of this binary is prohibited by law and will be prosecuted to the fullest extent of the law.");
// end limited code // end limited code
time_t cur_time; time_t cur_time;
@@ -998,7 +997,7 @@ int main(int argc, char* argv[])
FILEMAN->MountUserFilesystems(); FILEMAN->MountUserFilesystems();
/* Set this up next. Do this early, since it's needed for RageException::Throw. */ // Set this up next. Do this early, since it's needed for RageException::Throw.
LOG = new RageLog; LOG = new RageLog;
// Whew--we should be able to crash safely now! // Whew--we should be able to crash safely now!
@@ -1050,8 +1049,8 @@ int main(int argc, char* argv[])
MountTreeOfZips( SpecialFiles::PACKAGES_DIR ); MountTreeOfZips( SpecialFiles::PACKAGES_DIR );
MountTreeOfZips( SpecialFiles::USER_PACKAGES_DIR ); MountTreeOfZips( SpecialFiles::USER_PACKAGES_DIR );
/* One of the above filesystems might contain files that affect preferences, eg Data/Static.ini. /* One of the above filesystems might contain files that affect preferences
* Re-read preferences. */ * (e.g. Data/Static.ini). Re-read preferences. */
PREFSMAN->ReadPrefsFromDisk(); PREFSMAN->ReadPrefsFromDisk();
ApplyLogPreferences(); ApplyLogPreferences();
@@ -1075,10 +1074,10 @@ int main(int argc, char* argv[])
; // no loading window for other RunModes ; // no loading window for other RunModes
} }
srand( time(NULL) ); // seed number generator srand( time(NULL) ); // seed number generator
/* Do this early, so we have debugging output if anything else fails. LOG and /* Do this early, so we have debugging output if anything else fails. LOG and
* Dialog must be set up first. It shouldn't take long, but it might take a * Dialog must be set up first. It shouldn't take long, but it might take a
* little time; do this after the LoadingWindow is shown, since we don't want * little time; do this after the LoadingWindow is shown, since we don't want
* that to appear delayed. */ * that to appear delayed. */
HOOKS->DumpDebugInfo(); HOOKS->DumpDebugInfo();
@@ -1094,10 +1093,9 @@ int main(int argc, char* argv[])
ANNOUNCER = new AnnouncerManager; ANNOUNCER = new AnnouncerManager;
NOTESKIN = new NoteSkinManager; NOTESKIN = new NoteSkinManager;
/* Switch to the last used game type, and set up the theme and announcer. */ // Switch to the last used game type, and set up the theme and announcer.
SwitchToLastPlayedGame(); SwitchToLastPlayedGame();
// Handle special RunModes. Some of these depend on ThemeManager being loaded above in SwitchToLastPlayedGame. // Handle special RunModes. Some of these depend on ThemeManager being loaded above in SwitchToLastPlayedGame.
switch( runmode ) switch( runmode )
{ {
@@ -1108,7 +1106,6 @@ int main(int argc, char* argv[])
case RunMode_ExportNsisStrings: case RunMode_ExportNsisStrings:
case RunMode_ExportLuaInformation: case RunMode_ExportLuaInformation:
case RunMode_DisplayVersion: case RunMode_DisplayVersion:
// possible change: phase out "default"? -aj
THEME->SwitchThemeAndLanguage( "default", PREFSMAN->m_sLanguage, PREFSMAN->m_bPseudoLocalize ); THEME->SwitchThemeAndLanguage( "default", PREFSMAN->m_sLanguage, PREFSMAN->m_bPseudoLocalize );
switch( runmode ) switch( runmode )
{ {
@@ -1130,10 +1127,9 @@ int main(int argc, char* argv[])
} }
{ {
/* Now that THEME is loaded, load the icon for the current theme into the /* Now that THEME is loaded, load the icon for the current theme into
* loading window. */ * the loading window. */
RString sError; RString sError;
RageSurface *pIcon = RageSurfaceUtils::LoadFile( THEME->GetPathG( "Common", "window icon" ), sError ); RageSurface *pIcon = RageSurfaceUtils::LoadFile( THEME->GetPathG( "Common", "window icon" ), sError );
if( pIcon ) if( pIcon )
@@ -1179,8 +1175,8 @@ int main(int argc, char* argv[])
SAFE_DELETE( pLoadingWindow ); // destroy this before init'ing Display SAFE_DELETE( pLoadingWindow ); // destroy this before init'ing Display
/* If the user has tried to quit during the loading, do it before creating the /* If the user has tried to quit during the loading, do it before creating
* main window. This prevents going to full screen just to quit. */ * the main window. This prevents going to full screen just to quit. */
if( ArchHooks::UserQuit() ) if( ArchHooks::UserQuit() )
{ {
ShutdownGame(); ShutdownGame();
@@ -1332,12 +1328,13 @@ void StepMania::ClearCredits()
/* Returns true if the key has been handled and should be discarded, false if /* Returns true if the key has been handled and should be discarded, false if
* the key should be sent on to screens. */ * the key should be sent on to screens. */
static LocalizedString SERVICE_SWITCH_PRESSED ( "StepMania", "Service switch pressed" ); static LocalizedString SERVICE_SWITCH_PRESSED ( "StepMania", "Service switch pressed" );
// xxx: okay these probably shouldn't be here, but I wanted them to be // xxx: Okay, these probably shouldn't be here, but I wanted them to be
// localized and this was the place to do it since this is where the control // localized and this was the place to do it since this is where the control
// structure is placed... apologies to those who like properly structured // structure is placed... apologies to those who like properly structured
// metrics. I like compatibility. -aj // language files. I like compatibility. -aj
static LocalizedString RELOADED_METRICS( "ThemeManager", "Reloaded metrics" ); static LocalizedString RELOADED_METRICS( "ThemeManager", "Reloaded metrics" );
static LocalizedString RELOADED_METRICS_AND_TEXTURES( "ThemeManager", "Reloaded metrics and textures" ); static LocalizedString RELOADED_METRICS_AND_TEXTURES( "ThemeManager", "Reloaded metrics and textures" );
static LocalizedString RELOADED_SCRIPTS( "ThemeManager", "Reloaded scripts" );
bool HandleGlobalInputs( const InputEventPlus &input ) bool HandleGlobalInputs( const InputEventPlus &input )
{ {
// None of the globals keys act on types other than FIRST_PRESS // None of the globals keys act on types other than FIRST_PRESS
@@ -1384,6 +1381,13 @@ bool HandleGlobalInputs( const InputEventPlus &input )
CodeDetector::RefreshCacheItems(); CodeDetector::RefreshCacheItems();
SCREENMAN->SystemMessage( RELOADED_METRICS ); SCREENMAN->SystemMessage( RELOADED_METRICS );
} }
else if(INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, KEY_LCTRL), &input.InputList) ||
INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, KEY_RCTRL), &input.InputList))
{
// Ctrl+F2: reload scripts only
THEME->UpdateLuaGlobals();
SCREENMAN->SystemMessage( RELOADED_SCRIPTS );
}
else else
{ {
// F2 alone: refresh metrics, textures, noteskins, codedetector cache // F2 alone: refresh metrics, textures, noteskins, codedetector cache