localizable smpackage dialogs

This commit is contained in:
Chris Danford
2006-01-05 07:38:31 +00:00
parent f02ed66d59
commit cc922c4619
9 changed files with 73 additions and 20 deletions
+2
View File
@@ -9,6 +9,8 @@ const RString SpecialFiles::LANGUAGES_SUBDIR = "Languages/";
const RString SpecialFiles::BASE_LANGUAGE = "en";
const RString SpecialFiles::METRICS_FILE = "metrics.ini";
const RString SpecialFiles::CACHE_DIR = "Cache/";
const RString SpecialFiles::BASE_THEME_NAME = "default";
/*
* (c) 2003-2005 Chris Danford
+1
View File
@@ -12,6 +12,7 @@ namespace SpecialFiles
extern const RString BASE_LANGUAGE;
extern const RString METRICS_FILE;
extern const RString CACHE_DIR;
extern const RString BASE_THEME_NAME;
}
#endif
+37 -16
View File
@@ -15,6 +15,10 @@
#endif
#include "Foreach.h"
#include "ThemeMetric.h"
#include "SubscriptionManager.h"
template<>
set<IThemeMetric*>* SubscriptionManager<IThemeMetric>::s_pSubscribers = NULL;
#include "LuaManager.h"
#include "ScreenDimensions.h"
#include "Command.h"
@@ -36,9 +40,6 @@ XToString( ElementCategory, NUM_ElementCategory );
StringToX( ElementCategory );
const RString BASE_THEME_NAME = "default";
struct Theme
{
RString sThemeName;
@@ -224,19 +225,19 @@ void ThemeManager::LoadThemeMetrics( deque<Theme> &theme, const RString &sThemeN
if( sLanguage.CompareNoCase(SpecialFiles::BASE_LANGUAGE) )
ini.ReadFile( GetLanguageIniPath(sThemeName,sLanguage) );
bool bIsBaseTheme = !sThemeName.CompareNoCase(BASE_THEME_NAME);
bool bIsBaseTheme = !sThemeName.CompareNoCase(SpecialFiles::BASE_THEME_NAME);
ini.GetValue( "Global", "IsBaseTheme", bIsBaseTheme );
if( bIsBaseTheme )
bLoadedBase = true;
/* Read the fallback theme. If no fallback theme is specified, and we havn't
* already loaded it, fall back on BASE_THEME_NAME. That way, default theme
* already loaded it, fall back on SpecialFiles::BASE_THEME_NAME. That way, default theme
* fallbacks can be disabled with "FallbackTheme=". */
RString sFallback;
if( !ini.GetValue("Global","FallbackTheme",sFallback) )
{
if( sThemeName.CompareNoCase( BASE_THEME_NAME ) && !bLoadedBase )
sFallback = BASE_THEME_NAME;
if( sThemeName.CompareNoCase( SpecialFiles::BASE_THEME_NAME ) && !bLoadedBase )
sFallback = SpecialFiles::BASE_THEME_NAME;
}
/* We actually want to load themes bottom-to-top, loading fallback themes
@@ -281,7 +282,7 @@ void ThemeManager::SwitchThemeAndLanguage( const RString &sThemeName_, const RSt
RString sThemeName = sThemeName_;
RString sLanguage = sLanguage_;
if( !DoesThemeExist(sThemeName) )
sThemeName = BASE_THEME_NAME;
sThemeName = SpecialFiles::BASE_THEME_NAME;
/* We havn't actually loaded the theme yet, so we can't check whether sLanguage
* exists. Just check for empty. */
@@ -317,8 +318,11 @@ void ThemeManager::SwitchThemeAndLanguage( const RString &sThemeName_, const RSt
}
// reload subscribers
FOREACHS_CONST( IThemeMetric*, *g_Subscribers.m_pSubscribers, p )
(*p)->Read();
if( SubscriptionManager<IThemeMetric>::s_pSubscribers )
{
FOREACHS_CONST( IThemeMetric*, *g_Subscribers.m_pSubscribers, p )
(*p)->Read();
}
}
void ThemeManager::RunLuaScripts( const RString &sMask )
@@ -638,11 +642,11 @@ try_element_again:
sCategory.c_str(),
sFileName.c_str(),
GetThemeDirFromName(m_sCurThemeName).c_str(),
GetThemeDirFromName(BASE_THEME_NAME).c_str() );
GetThemeDirFromName(SpecialFiles::BASE_THEME_NAME).c_str() );
/* Err? */
if(sFileName == "_missing")
RageException::Throw("'_missing' isn't present in '%s%s'", GetThemeDirFromName(BASE_THEME_NAME).c_str(), sCategory.c_str() );
RageException::Throw("'_missing' isn't present in '%s%s'", GetThemeDirFromName(SpecialFiles::BASE_THEME_NAME).c_str(), sCategory.c_str() );
Cache[sFileName] = GetPath( category, "", "_missing" );
return Cache[sFileName];
@@ -651,7 +655,7 @@ try_element_again:
sCategory.c_str(),
sFileName.c_str(),
GetThemeDirFromName(m_sCurThemeName).c_str(),
GetThemeDirFromName(BASE_THEME_NAME).c_str() );
GetThemeDirFromName(SpecialFiles::BASE_THEME_NAME).c_str() );
default:
ASSERT(0);
return NULL;
@@ -694,6 +698,8 @@ bool ThemeManager::GetMetricRawRecursive( const RString &sClassName_, const RStr
ASSERT( sValueName != "" );
RString sClassName( sClassName_ );
ASSERT( g_pIniMetrics );
int n = 100;
while( n-- )
{
@@ -743,7 +749,7 @@ try_metric_again:
}
RString sCurMetricPath = GetMetricsIniPath(m_sCurThemeName);
RString sDefaultMetricPath = GetMetricsIniPath(BASE_THEME_NAME);
RString sDefaultMetricPath = GetMetricsIniPath(SpecialFiles::BASE_THEME_NAME);
RString sError = ssprintf( "Theme metric '%s : %s' could not be found in '%s' or '%s'.",
sClassName.c_str(),
@@ -900,8 +906,23 @@ void ThemeManager::GetMetric( const RString &sClassName, const RString &sValueNa
RString ThemeManager::GetString( const RString &sClassName, const RString &sValueName )
{
// TODO: Are there esacpe rules for this?
DEBUG_ASSERT( sValueName.find('=') == sValueName.npos );
// TODO: Change this to GetMetricRaw and write stubs for missing strings into every language file.
return GetMetric( sClassName, sValueName );
RString s = GetMetric( sClassName, sValueName );
// Language strings may not be empty. Empty strings are considered to need translation
if( s.empty() )
{
RString sFile = GetLanguageIniPath( m_sCurThemeName, m_sCurLanguage );
IniFile ini;
ini.ReadFile( sFile );
s = sValueName;
ini.SetValue( sClassName, sValueName, s );
ini.WriteFile( sFile );
}
return s;
}
void ThemeManager::GetMetricsThatBeginWith( const RString &sClassName_, const RString &sValueName, set<RString> &vsValueNamesOut )
@@ -935,7 +956,7 @@ void ThemeManager::GetMetricsThatBeginWith( const RString &sClassName_, const RS
RString ThemeManager::GetBlankGraphicPath()
{
return SpecialFiles::THEMES_DIR + BASE_THEME_NAME + "/" + ElementCategoryToString(EC_GRAPHICS) + "/_blank.png";
return SpecialFiles::THEMES_DIR + SpecialFiles::BASE_THEME_NAME + "/" + ElementCategoryToString(EC_GRAPHICS) + "/_blank.png";
}
// lua start
+4 -4
View File
@@ -194,9 +194,6 @@
<File
RelativePath=".\smpackage\MainMenuDlg.h">
</File>
<File
RelativePath=".\smpackage\resource.h">
</File>
<File
RelativePath=".\smpackage\ShowComment.cpp">
</File>
@@ -262,11 +259,14 @@
RelativePath="menu.bmp">
</File>
<File
RelativePath="smpackage.ICO">
RelativePath=".\smpackage\resource.h">
</File>
<File
RelativePath="res\smpackage.ico">
</File>
<File
RelativePath="smpackage.ICO">
</File>
<File
RelativePath=".\smpackage\smpackage.rc">
</File>
+2
View File
@@ -42,6 +42,8 @@ BOOL LanguagesDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SMPackageUtil::LocalizeDialogAndContents( *this );
vector<RString> vs;
GetDirListing( SpecialFiles::THEMES_DIR+"*", vs, true );
StripCvs( vs );
+2
View File
@@ -173,6 +173,8 @@ BOOL MainMenuDlg::OnInitDialog()
CDialog::OnInitDialog();
// TODO: Add extra initialization here
SMPackageUtil::LocalizeDialogAndContents( *this );
TCHAR szCurDir[MAX_PATH];
GetCurrentDirectory( ARRAYSIZE(szCurDir), szCurDir );
GetDlgItem( IDC_EDIT_INSTALLATION )->SetWindowText( szCurDir );
+18
View File
@@ -6,6 +6,7 @@
#include "ProductInfo.h"
#include "RageUtil.h"
#include "RageFileManager.h"
#include "ThemeManager.h"
void SMPackageUtil::WriteStepManiaInstallDirs( const vector<RString>& asInstallDirsToWrite )
{
@@ -210,6 +211,23 @@ RString SMPackageUtil::GetLanguageCodeFromDisplayString( const RString &sDisplay
return s;
}
void SMPackageUtil::LocalizeDialogAndContents( CDialog &dlg )
{
CString s1;
dlg.GetWindowText( s1 );
RString sGroup = "Tools-"+s1;
dlg.SetWindowText( THEME->GetString(sGroup,"DialogCaption") );
for( CWnd *pChild = dlg.GetTopWindow(); pChild != NULL; pChild = pChild->GetNextWindow() )
{
pChild->GetWindowText( s1 );
if( s1.IsEmpty() )
continue;
pChild->SetWindowText( THEME->GetString(sGroup,RString(s1)) );
}
}
static const RString TEMP_MOUNT_POINT = "/@package/";
RageFileOsAbsolute::~RageFileOsAbsolute()
+5
View File
@@ -10,6 +10,8 @@
#include "RageFileManager.h"
#include "arch/arch.h"
#include "LuaManager.h"
#include "ThemeManager.h"
#include "SpecialFiles.h"
#ifdef _DEBUG
@@ -109,6 +111,8 @@ BOOL CSmpackageApp::InitInstance()
FILEMAN = new RageFileManager( "" );
LUA = new LuaManager();
THEME = new ThemeManager();
THEME->SwitchThemeAndLanguage( SpecialFiles::BASE_THEME_NAME, SpecialFiles::BASE_LANGUAGE );
// Show the Manager Dialog
@@ -117,6 +121,7 @@ BOOL CSmpackageApp::InitInstance()
// if (nResponse == IDOK)
SAFE_DELETE( THEME );
SAFE_DELETE( LUA );
SAFE_DELETE( FILEMAN );
+2
View File
@@ -23,6 +23,8 @@ namespace SMPackageUtil
RString GetLanguageCodeFromDisplayString( const RString &sDisplayString );
bool GetFileContentsOsAbsolute( const RString &sAbsoluteOsFile, RString &sOut );
void LocalizeDialogAndContents( CDialog &dlg );
}
#include "RageFile.h"