change metrics reload logic to check only during screen loads

This commit is contained in:
Chris Danford
2003-11-05 04:56:41 +00:00
parent 2c6df65bd0
commit 6047da8efd
3 changed files with 27 additions and 25 deletions
+2
View File
@@ -28,6 +28,7 @@
#include "Quad.h" #include "Quad.h"
#include "RageTextureManager.h" #include "RageTextureManager.h"
#include "ProfileManager.h" #include "ProfileManager.h"
#include "ThemeManager.h"
ScreenManager* SCREENMAN = NULL; // global and accessable from anywhere in our program ScreenManager* SCREENMAN = NULL; // global and accessable from anywhere in our program
@@ -467,6 +468,7 @@ void ScreenManager::DeletePreppedScreen()
void ScreenManager::SetNewScreen( Screen *pNewScreen ) void ScreenManager::SetNewScreen( Screen *pNewScreen )
{ {
RefreshCreditsMessages(); RefreshCreditsMessages();
THEME->ReloadMetricsIfNecessary();
// move current screen(s) to ScreenToDelete // move current screen(s) to ScreenToDelete
m_ScreensToDelete.insert(m_ScreensToDelete.end(), m_ScreenStack.begin(), m_ScreenStack.end()); m_ScreensToDelete.insert(m_ScreensToDelete.end(), m_ScreenStack.begin(), m_ScreenStack.end());
+24 -23
View File
@@ -25,6 +25,7 @@
#include "arch/ArchHooks/ArchHooks.h" #include "arch/ArchHooks/ArchHooks.h"
#include "arch/arch.h" #include "arch/arch.h"
#include "RageFile.h" #include "RageFile.h"
#include "ScreenManager.h"
ThemeManager* THEME = NULL; // global object accessable from anywhere in the program ThemeManager* THEME = NULL; // global object accessable from anywhere in the program
@@ -306,13 +307,6 @@ try_element_again:
CString ThemeManager::GetPathTo( ElementCategory category, CString sFileName, bool bOptional ) CString ThemeManager::GetPathTo( ElementCategory category, CString sFileName, bool bOptional )
{ {
if ( m_ThemePathCacheTimer.PeekDeltaTime() >= 5 )
{
m_ThemePathCacheTimer.GetDeltaTime();
for( int i = 0; i < NUM_ELEMENT_CATEGORIES; ++i )
g_ThemePathCache[i].clear();
}
map<CString, CString> &Cache = g_ThemePathCache[category]; map<CString, CString> &Cache = g_ThemePathCache[category];
{ {
map<CString, CString>::const_iterator i; map<CString, CString>::const_iterator i;
@@ -394,6 +388,29 @@ bool ThemeManager::HasMetric( CString sClassName, CString sValueName )
return m_pIniMetrics->GetValue(sClassName,sValueName,sThrowAway); return m_pIniMetrics->GetValue(sClassName,sValueName,sThrowAway);
} }
void ThemeManager::ReloadMetricsIfNecessary()
{
//
// reload metrics if file has changed
//
CString sCurMetricPath = GetMetricsIniPath(m_sCurThemeName);
CString sDefaultMetricPath = GetMetricsIniPath(BASE_THEME_NAME);
if( m_uHashForCurThemeMetrics != GetHashForFile(sCurMetricPath) ||
m_uHashForBaseThemeMetrics != GetHashForFile(sDefaultMetricPath) )
{
SCREENMAN->SystemMessage( "Reloading metrics" );
SwitchThemeAndLanguage(m_sCurThemeName, m_sCurLanguage); // force a reload of the metrics cache
}
//
// clear theme path cache
//
for( int i = 0; i < NUM_ELEMENT_CATEGORIES; ++i )
g_ThemePathCache[i].clear();
}
CString ThemeManager::GetMetricRaw( CString sClassName, CString sValueName ) CString ThemeManager::GetMetricRaw( CString sClassName, CString sValueName )
{ {
#if defined(DEBUG) && defined(WIN32) #if defined(DEBUG) && defined(WIN32)
@@ -402,22 +419,6 @@ try_metric_again:
CString sCurMetricPath = GetMetricsIniPath(m_sCurThemeName); CString sCurMetricPath = GetMetricsIniPath(m_sCurThemeName);
CString sDefaultMetricPath = GetMetricsIniPath(BASE_THEME_NAME); CString sDefaultMetricPath = GetMetricsIniPath(BASE_THEME_NAME);
// Is our metric cache out of date?
if ( !m_uHashForBaseThemeMetrics || m_ReloadTimer.PeekDeltaTime() >= 1 )
{
m_ReloadTimer.GetDeltaTime();
if( m_uHashForCurThemeMetrics != GetHashForFile(sCurMetricPath) ||
m_uHashForBaseThemeMetrics != GetHashForFile(sDefaultMetricPath) )
{
if(m_uHashForBaseThemeMetrics)
{
LOG->Warn( "Metrics file is out of date. Reloading..." );
// MessageBeep( MB_OK );
}
SwitchThemeAndLanguage(m_sCurThemeName, m_sCurLanguage); // force a reload of the metrics cache
}
}
CString sValue; CString sValue;
if( m_pIniMetrics->GetValue(sClassName,sValueName,sValue) ) if( m_pIniMetrics->GetValue(sClassName,sValueName,sValue) )
+1 -2
View File
@@ -34,6 +34,7 @@ public:
CString GetCurLanguage() { return m_sCurLanguage; }; CString GetCurLanguage() { return m_sCurLanguage; };
CString GetCurThemeDir() { return GetThemeDirFromName(m_sCurThemeName); }; CString GetCurThemeDir() { return GetThemeDirFromName(m_sCurThemeName); };
void NextTheme(); void NextTheme();
void ReloadMetricsIfNecessary();
CString GetPathTo( ElementCategory category, CString sFileName, bool bOptional=false ); CString GetPathTo( ElementCategory category, CString sFileName, bool bOptional=false );
CString GetPathToB( CString sFileName, bool bOptional=false ) { return GetPathTo(BGAnimations,sFileName,bOptional); }; CString GetPathToB( CString sFileName, bool bOptional=false ) { return GetPathTo(BGAnimations,sFileName,bOptional); };
@@ -69,8 +70,6 @@ protected:
unsigned m_uHashForBaseThemeCurLanguage; unsigned m_uHashForBaseThemeCurLanguage;
unsigned m_uHashForCurThemeBaseLanguage; unsigned m_uHashForCurThemeBaseLanguage;
unsigned m_uHashForBaseThemeBaseLanguage; unsigned m_uHashForBaseThemeBaseLanguage;
RageTimer m_ReloadTimer;
RageTimer m_ThemePathCacheTimer;
}; };
extern ThemeManager* THEME; // global and accessable from anywhere in our program extern ThemeManager* THEME; // global and accessable from anywhere in our program