예제 #1
0
CString CTDLLanguageComboBox::GetLanguageFile(LPCTSTR szLanguage, LPCTSTR szExt, BOOL bRelative) // static
{
	ASSERT(szLanguage && *szLanguage);

	CString sLanguageFile(GetDefaultLanguage());

	if (GetDefaultLanguage() != szLanguage)
	{
		if (bRelative)
			FileMisc::MakePath(sLanguageFile, NULL, _T(".\\Resources\\Translations"), szLanguage, szExt);
		else
			FileMisc::MakePath(sLanguageFile, NULL, GetTranslationFolder(), szLanguage, szExt);
	}

	return sLanguageFile;
}
예제 #2
0
void ThemeManager::SwitchThemeAndLanguage( const RString &sThemeName_, const RString &sLanguage_, bool bPseudoLocalize, bool bForceThemeReload )
{
    RString sThemeName = sThemeName_;
    RString sLanguage = sLanguage_;
    // todo: if the theme isn't selectable, find the next theme that is,
    // and change to that instead of asserting/crashing since
    // SpecialFiles::BASE_THEME_NAME is _fallback now. -aj
#if !defined(SMPACKAGE)
    if( !IsThemeSelectable(sThemeName) )
        sThemeName = PREFSMAN->m_sTheme.GetDefault();

    // sm-ssc's SpecialFiles::BASE_THEME_NAME is _fallback, which you can't
    // select. This requires a preference, which allows it to be adapted for
    // other purposes (e.g. PARASTAR).
    if( !IsThemeSelectable(sThemeName) )
        sThemeName = PREFSMAN->m_sDefaultTheme;
#endif

    ASSERT( IsThemeSelectable(sThemeName) );

    /* We haven't actually loaded the theme yet, so we can't check whether
     * sLanguage exists. Just check for empty. */
    if( sLanguage.empty() )
        sLanguage = GetDefaultLanguage();
    LOG->Trace("ThemeManager::SwitchThemeAndLanguage: \"%s\", \"%s\"",
               sThemeName.c_str(), sLanguage.c_str() );

    bool bNothingChanging = sThemeName == m_sCurThemeName && sLanguage == m_sCurLanguage && m_bPseudoLocalize == bPseudoLocalize;
    if( bNothingChanging && !bForceThemeReload )
        return;

    m_bPseudoLocalize = bPseudoLocalize;

    // Load theme metrics. If only the language is changing, this is all
    // we need to reload.
    bool bThemeChanging = (sThemeName != m_sCurThemeName);
    LoadThemeMetrics( sThemeName, sLanguage );

    // Clear the theme path cache. This caches language-specific graphic paths,
    // so do this even if only the language is changing.
    ClearThemePathCache();
    if( bThemeChanging )
    {
#if !defined(SMPACKAGE)
        // reload common sounds
        if( SCREENMAN != NULL )
            SCREENMAN->ThemeChanged();
#endif

        /* Lua globals can use metrics which are cached, and vice versa.  Update Lua
         * globals first; it's Lua's job to explicitly update cached metrics that it
         * uses. */
        UpdateLuaGlobals();
    }

    // Use theme metrics for localization.
    LocalizedString::RegisterLocalizer( LocalizedStringImplThemeMetric::Create );

    ReloadSubscribers();
}
예제 #3
0
OP_STATUS MacOpDesktopResources::GetLanguageFolderName(OpString &folder_name, LanguageFolderType type, OpStringC lang_code)
{
	if (lang_code.HasContent())
	{
		RETURN_IF_ERROR(folder_name.Set(lang_code));
	}
	else
	{
		if (m_language_code.IsEmpty())
		{
			RETURN_IF_ERROR(m_language_code.Set(GetDefaultLanguage()));
		}
		RETURN_IF_ERROR(folder_name.Set(m_language_code));
	}
	if (type == LOCALE)
	{
		RETURN_IF_ERROR(folder_name.Append(UNI_L(".lproj")));
	}
	else if (type == REGION)
	{
		// strip territory/script/variant code - only language code is used
		// inside region folder (DSK-346940)
		int pos = folder_name.FindFirstOf(UNI_L('-'));
		if (pos == KNotFound)
			pos = folder_name.FindFirstOf(UNI_L('_'));
		if (pos > 0)
			folder_name.Delete(pos);
	}
	return OpStatus::OK;
}
예제 #4
0
OP_STATUS MacOpDesktopResources::GetLanguageFileName(OpString& file_name, OpStringC lang_code)
{
	if (lang_code.HasContent())
	{
		RETURN_IF_ERROR(file_name.Set(lang_code));
	}
	else
	{
		if (m_language_code.IsEmpty())
		{
			RETURN_IF_ERROR(m_language_code.Set(GetDefaultLanguage()));
		}
		RETURN_IF_ERROR(file_name.Set(m_language_code));
	}
	return file_name.Append(UNI_L(".lng"));
}
예제 #5
0
CString CTDLLanguageComboBox::GetLanguageFile(BOOL bRelative) const
{
	CString sLanguageFile(GetDefaultLanguage());

	if (GetSafeHwnd())
	{
		int nSel = GetCurSel();

		if (nSel == -1)
			m_sSelLanguage = DEFLANG;
		else
			GetLBText(nSel, m_sSelLanguage);
	}

	LPCTSTR szExt = (m_sFilter.Find(_T(".csv")) != -1) ? _T("csv") : _T("txt");
	return GetLanguageFile(m_sSelLanguage, szExt, bRelative);
}
예제 #6
0
void CTDLLanguageComboBox::SetLanguageFile(LPCTSTR szFile)
{
	if (GetDefaultLanguage() == szFile)
	{
		if (GetSafeHwnd())
			SelectLanguage(szFile);
		else
			m_sSelLanguage = szFile;
	}
	else
	{
		CString sPath = FileMisc::GetFullPath(szFile, FileMisc::GetAppFolder());
		
		if (FileMisc::FileExists(sPath))
		{
			FileMisc::SplitPath(szFile, NULL, NULL, &m_sSelLanguage, NULL);

			if (GetSafeHwnd())
				SelectLanguage(m_sSelLanguage);
		}
	}
}
예제 #7
0
void ThemeManager::SwitchThemeAndLanguage( const RString &sThemeName_, const RString &sLanguage_, bool bPseudoLocalize, bool bForceThemeReload )
{
	RString sThemeName = sThemeName_;
	RString sLanguage = sLanguage_;
	// todo: if the theme isn't selectable, find the next theme that is,
	// and change to that instead of asserting/crashing since
	// SpecialFiles::BASE_THEME_NAME is _fallback now. -aj
	if(!IsThemeSelectable(sThemeName))
	{
		RString to_try= PREFSMAN->m_sTheme.GetDefault();
		LOG->Warn("Selected theme '%s' not found.  "
			"Trying Theme preference default value '%s'.",
			sThemeName.c_str(), to_try.c_str());
		sThemeName = to_try;
		// sm-ssc's SpecialFiles::BASE_THEME_NAME is _fallback, which you can't
		// select. This requires a preference, which allows it to be adapted for
		// other purposes (e.g. PARASTAR).
		if(!IsThemeSelectable(sThemeName))
		{
			to_try= PREFSMAN->m_sDefaultTheme;
			LOG->Warn("Theme preference defaults to '%s', which cannot be used."
				"  Trying DefaultTheme preference '%s'.",
				sThemeName.c_str(), to_try.c_str());
			sThemeName = to_try;
			if(!IsThemeSelectable(sThemeName))
			{
				vector<RString> theme_names;
				GetSelectableThemeNames(theme_names);
				ASSERT_M(!theme_names.empty(), "No themes found, unable to start stepmania.");
				to_try= theme_names[0];
				LOG->Warn("DefaultTheme preference is '%s', which cannot be found."
					"  Using '%s'.",
					sThemeName.c_str(), to_try.c_str());
				sThemeName= to_try;
				PREFSMAN->m_sDefaultTheme.Set(to_try);
			}
		}
		PREFSMAN->m_sTheme.Set(sThemeName);
	}

	/* We haven't actually loaded the theme yet, so we can't check whether
	 * sLanguage exists. Just check for empty. */
	if( sLanguage.empty() )
		sLanguage = GetDefaultLanguage();
	LOG->Trace("ThemeManager::SwitchThemeAndLanguage: \"%s\", \"%s\"",
		sThemeName.c_str(), sLanguage.c_str() );

	bool bNothingChanging = sThemeName == m_sCurThemeName && sLanguage == m_sCurLanguage && m_bPseudoLocalize == bPseudoLocalize;
	if( bNothingChanging && !bForceThemeReload )
		return;

	m_bPseudoLocalize = bPseudoLocalize;

	// Load theme metrics. If only the language is changing, this is all
	// we need to reload.
	bool bThemeChanging = (sThemeName != m_sCurThemeName);
	LoadThemeMetrics( sThemeName, sLanguage );

	// Clear the theme path cache. This caches language-specific graphic paths,
	// so do this even if only the language is changing.
	ClearThemePathCache();
	if(bThemeChanging || bForceThemeReload)
	{
#if !defined(SMPACKAGE)
		// reload common sounds
		if( SCREENMAN != NULL )
			SCREENMAN->ThemeChanged();

#endif

		/* Lua globals can use metrics which are cached, and vice versa.  Update Lua
		 * globals first; it's Lua's job to explicitly update cached metrics that it
		 * uses. */
		UpdateLuaGlobals();

		// Reload MachineProfile with new theme's CustomLoadFunction
		if( PROFILEMAN != NULL )
		{
			Profile* pProfile = PROFILEMAN->GetMachineProfile();
			pProfile->LoadCustomFunction("/Save/MachineProfile/", PlayerNumber_Invalid);
		}
	}

	// Use theme metrics for localization.
	LocalizedString::RegisterLocalizer( LocalizedStringImplThemeMetric::Create );

	ReloadSubscribers();
}