mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 21:39:41 +00:00
Allow to configure locales via settings menu
This commit is contained in:
parent
8ff64ca176
commit
cb64f49ba1
7 changed files with 117 additions and 4 deletions
|
@ -5,6 +5,8 @@
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
#include <unicode/locid.h>
|
||||||
|
|
||||||
#include <MyGUI_ScrollBar.h>
|
#include <MyGUI_ScrollBar.h>
|
||||||
#include <MyGUI_Window.h>
|
#include <MyGUI_Window.h>
|
||||||
#include <MyGUI_ComboBox.h>
|
#include <MyGUI_ComboBox.h>
|
||||||
|
@ -18,12 +20,14 @@
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
#include <components/misc/stringops.hpp>
|
#include <components/misc/stringops.hpp>
|
||||||
#include <components/misc/constants.hpp>
|
#include <components/misc/constants.hpp>
|
||||||
|
#include <components/misc/pathhelpers.hpp>
|
||||||
#include <components/widgets/sharedstatebutton.hpp>
|
#include <components/widgets/sharedstatebutton.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/settings.hpp>
|
||||||
#include <components/resource/resourcesystem.hpp>
|
#include <components/resource/resourcesystem.hpp>
|
||||||
#include <components/resource/scenemanager.hpp>
|
#include <components/resource/scenemanager.hpp>
|
||||||
#include <components/sceneutil/lightmanager.hpp>
|
#include <components/sceneutil/lightmanager.hpp>
|
||||||
#include <components/lua_ui/scriptsettings.hpp>
|
#include <components/lua_ui/scriptsettings.hpp>
|
||||||
|
#include <components/vfs/manager.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
@ -254,6 +258,8 @@ namespace MWGui
|
||||||
getWidget(mWaterTextureSize, "WaterTextureSize");
|
getWidget(mWaterTextureSize, "WaterTextureSize");
|
||||||
getWidget(mWaterReflectionDetail, "WaterReflectionDetail");
|
getWidget(mWaterReflectionDetail, "WaterReflectionDetail");
|
||||||
getWidget(mWaterRainRippleDetail, "WaterRainRippleDetail");
|
getWidget(mWaterRainRippleDetail, "WaterRainRippleDetail");
|
||||||
|
getWidget(mPrimaryLanguage, "PrimaryLanguage");
|
||||||
|
getWidget(mSecondaryLanguage, "SecondaryLanguage");
|
||||||
getWidget(mLightingMethodButton, "LightingMethodButton");
|
getWidget(mLightingMethodButton, "LightingMethodButton");
|
||||||
getWidget(mLightsResetButton, "LightsResetButton");
|
getWidget(mLightsResetButton, "LightsResetButton");
|
||||||
getWidget(mMaxLights, "MaxLights");
|
getWidget(mMaxLights, "MaxLights");
|
||||||
|
@ -297,6 +303,9 @@ namespace MWGui
|
||||||
mKeyboardSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onKeyboardSwitchClicked);
|
mKeyboardSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onKeyboardSwitchClicked);
|
||||||
mControllerSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onControllerSwitchClicked);
|
mControllerSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onControllerSwitchClicked);
|
||||||
|
|
||||||
|
mPrimaryLanguage->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onPrimaryLanguageChanged);
|
||||||
|
mSecondaryLanguage->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSecondaryLanguageChanged);
|
||||||
|
|
||||||
computeMinimumWindowSize();
|
computeMinimumWindowSize();
|
||||||
|
|
||||||
center();
|
center();
|
||||||
|
@ -353,6 +362,55 @@ namespace MWGui
|
||||||
|
|
||||||
mScriptFilter->eventEditTextChange += MyGUI::newDelegate(this, &SettingsWindow::onScriptFilterChange);
|
mScriptFilter->eventEditTextChange += MyGUI::newDelegate(this, &SettingsWindow::onScriptFilterChange);
|
||||||
mScriptList->eventListMouseItemActivate += MyGUI::newDelegate(this, &SettingsWindow::onScriptListSelection);
|
mScriptList->eventListMouseItemActivate += MyGUI::newDelegate(this, &SettingsWindow::onScriptListSelection);
|
||||||
|
|
||||||
|
std::vector<std::string> availableLanguages;
|
||||||
|
const VFS::Manager* vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
for (const auto& path : vfs->getRecursiveDirectoryIterator("l10n/"))
|
||||||
|
{
|
||||||
|
if (Misc::getFileExtension(path) == "yaml")
|
||||||
|
{
|
||||||
|
std::string localeName(Misc::stemFile(path));
|
||||||
|
if (std::find(availableLanguages.begin(), availableLanguages.end(), localeName) == availableLanguages.end())
|
||||||
|
availableLanguages.push_back(localeName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort (availableLanguages.begin(), availableLanguages.end());
|
||||||
|
|
||||||
|
std::vector<std::string> currentLocales = Settings::Manager::getStringArray("preferred locales", "General");
|
||||||
|
if (currentLocales.empty())
|
||||||
|
currentLocales.push_back("en");
|
||||||
|
|
||||||
|
icu::Locale primaryLocale(currentLocales[0].c_str());
|
||||||
|
|
||||||
|
mPrimaryLanguage->removeAllItems();
|
||||||
|
mSecondaryLanguage->removeAllItems();
|
||||||
|
|
||||||
|
size_t i = 0, primaryLocaleIndex = MyGUI::ITEM_NONE, secondaryLocaleIndex = MyGUI::ITEM_NONE;
|
||||||
|
for (const auto& language : availableLanguages)
|
||||||
|
{
|
||||||
|
icu::Locale locale(language.c_str());
|
||||||
|
|
||||||
|
icu::UnicodeString str(language.c_str());
|
||||||
|
locale.getDisplayName(primaryLocale, str);
|
||||||
|
std::string localeString;
|
||||||
|
str.toUTF8String(localeString);
|
||||||
|
mPrimaryLanguage->addItem(localeString);
|
||||||
|
mSecondaryLanguage->addItem(localeString);
|
||||||
|
|
||||||
|
if (language == currentLocales[0])
|
||||||
|
primaryLocaleIndex = i;
|
||||||
|
if (currentLocales.size() > 1 && language == currentLocales[1])
|
||||||
|
secondaryLocaleIndex = i;
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
mPrimaryLanguage->setUserData(availableLanguages);
|
||||||
|
mSecondaryLanguage->setUserData(availableLanguages);
|
||||||
|
|
||||||
|
mPrimaryLanguage->setIndexSelected(primaryLocaleIndex);
|
||||||
|
mSecondaryLanguage->setIndexSelected(secondaryLocaleIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsWindow::onTabChanged(MyGUI::TabControl* /*_sender*/, size_t /*index*/)
|
void SettingsWindow::onTabChanged(MyGUI::TabControl* /*_sender*/, size_t /*index*/)
|
||||||
|
@ -454,6 +512,22 @@ namespace MWGui
|
||||||
apply();
|
apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsWindow::onLanguageChanged(size_t langPriority, MyGUI::ComboBox* _sender, size_t pos)
|
||||||
|
{
|
||||||
|
if (pos == MyGUI::ITEM_NONE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
MWBase::Environment::get().getWindowManager()->interactiveMessageBox("#{SettingsMenu:ChangeRequiresRestart}", {"#{sOK}"}, true);
|
||||||
|
const auto languageNames = _sender->getUserData<std::vector<std::string>>();
|
||||||
|
|
||||||
|
std::vector<std::string> currentLocales = Settings::Manager::getStringArray("preferred locales", "General");
|
||||||
|
if (currentLocales.size() <= langPriority)
|
||||||
|
currentLocales.resize(langPriority + 1, "en");
|
||||||
|
currentLocales[langPriority] = languageNames->at(pos);
|
||||||
|
|
||||||
|
Settings::Manager::setStringArray("preferred locales", "General", currentLocales);
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsWindow::onWindowModeChanged(MyGUI::ComboBox* _sender, size_t pos)
|
void SettingsWindow::onWindowModeChanged(MyGUI::ComboBox* _sender, size_t pos)
|
||||||
{
|
{
|
||||||
if (pos == MyGUI::ITEM_NONE)
|
if (pos == MyGUI::ITEM_NONE)
|
||||||
|
|
|
@ -40,6 +40,9 @@ namespace MWGui
|
||||||
MyGUI::ComboBox* mLightingMethodButton;
|
MyGUI::ComboBox* mLightingMethodButton;
|
||||||
MyGUI::Button* mLightsResetButton;
|
MyGUI::Button* mLightsResetButton;
|
||||||
|
|
||||||
|
MyGUI::ComboBox* mPrimaryLanguage;
|
||||||
|
MyGUI::ComboBox* mSecondaryLanguage;
|
||||||
|
|
||||||
// controls
|
// controls
|
||||||
MyGUI::ScrollView* mControlsBox;
|
MyGUI::ScrollView* mControlsBox;
|
||||||
MyGUI::Button* mResetControlsButton;
|
MyGUI::Button* mResetControlsButton;
|
||||||
|
@ -72,6 +75,10 @@ namespace MWGui
|
||||||
void onLightsResetButtonClicked(MyGUI::Widget* _sender);
|
void onLightsResetButtonClicked(MyGUI::Widget* _sender);
|
||||||
void onMaxLightsChanged(MyGUI::ComboBox* _sender, size_t pos);
|
void onMaxLightsChanged(MyGUI::ComboBox* _sender, size_t pos);
|
||||||
|
|
||||||
|
void onPrimaryLanguageChanged(MyGUI::ComboBox* _sender, size_t pos) { onLanguageChanged(0, _sender, pos); }
|
||||||
|
void onSecondaryLanguageChanged(MyGUI::ComboBox* _sender, size_t pos) { onLanguageChanged(1, _sender, pos); }
|
||||||
|
void onLanguageChanged(size_t langPriority, MyGUI::ComboBox* _sender, size_t pos);
|
||||||
|
|
||||||
void onWindowModeChanged(MyGUI::ComboBox* _sender, size_t pos);
|
void onWindowModeChanged(MyGUI::ComboBox* _sender, size_t pos);
|
||||||
|
|
||||||
void onRebindAction(MyGUI::Widget* _sender);
|
void onRebindAction(MyGUI::Widget* _sender);
|
||||||
|
|
|
@ -58,9 +58,7 @@ namespace MWLua
|
||||||
void LuaManager::initL10n()
|
void LuaManager::initL10n()
|
||||||
{
|
{
|
||||||
mL10n.init();
|
mL10n.init();
|
||||||
std::vector<std::string> preferredLocales;
|
mL10n.setPreferredLocales(Settings::Manager::getStringArray("preferred locales", "General"));
|
||||||
Misc::StringUtils::split(Settings::Manager::getString("preferred locales", "General"), preferredLocales, ", ");
|
|
||||||
mL10n.setPreferredLocales(preferredLocales);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaManager::init()
|
void LuaManager::init()
|
||||||
|
|
|
@ -85,7 +85,7 @@ will match "en"), so is recommended that you include the country codes where pos
|
||||||
since if the country code isn't specified the generic language-code only locale might
|
since if the country code isn't specified the generic language-code only locale might
|
||||||
refer to any of the country-specific variants.
|
refer to any of the country-specific variants.
|
||||||
|
|
||||||
This setting can only be configured by editing the settings configuration file.
|
Two highest priority locales may be assigned via the Localization tab of the in-game options.
|
||||||
|
|
||||||
log buffer size
|
log buffer size
|
||||||
---------------
|
---------------
|
||||||
|
|
|
@ -8,6 +8,8 @@ Controller: "Controller"
|
||||||
FieldOfView: "Field of View"
|
FieldOfView: "Field of View"
|
||||||
FrameRateHint: "Hint: press F3 to show\nthe current frame rate."
|
FrameRateHint: "Hint: press F3 to show\nthe current frame rate."
|
||||||
InvertXAxis: "Invert X Axis"
|
InvertXAxis: "Invert X Axis"
|
||||||
|
Language: "Language"
|
||||||
|
LanguageNote: "Note: these settings do not affect strings from ESM files."
|
||||||
LightingMethod: "Lighting Method"
|
LightingMethod: "Lighting Method"
|
||||||
LightingMethodLegacy: "Legacy"
|
LightingMethodLegacy: "Legacy"
|
||||||
LightingMethodShaders: "Shaders"
|
LightingMethodShaders: "Shaders"
|
||||||
|
@ -27,6 +29,8 @@ MaxLightsTooltip: "Default: 8\nMaximum number of lights per object.\n\nA low num
|
||||||
MouseAndKeyboard: "Mouse/Keyboard"
|
MouseAndKeyboard: "Mouse/Keyboard"
|
||||||
PostProcessing: "Post Processing"
|
PostProcessing: "Post Processing"
|
||||||
PostProcessingTooltip: "Tweaked via Post Processor HUD, see input bindings."
|
PostProcessingTooltip: "Tweaked via Post Processor HUD, see input bindings."
|
||||||
|
PrimaryLanguage: "Primary Language"
|
||||||
|
PrimaryLanguageTooltip: "Localization files for this language have the highest priority."
|
||||||
RainRippleDetail: "Rain ripple detail"
|
RainRippleDetail: "Rain ripple detail"
|
||||||
RainRippleDetailDense: "Dense"
|
RainRippleDetailDense: "Dense"
|
||||||
RainRippleDetailSimple: "Simple"
|
RainRippleDetailSimple: "Simple"
|
||||||
|
@ -41,6 +45,8 @@ ReflectionShaderDetailWorld: "World"
|
||||||
Refraction: "Refraction"
|
Refraction: "Refraction"
|
||||||
Screenshot: "Screenshot"
|
Screenshot: "Screenshot"
|
||||||
Scripts: "Scripts"
|
Scripts: "Scripts"
|
||||||
|
SecondaryLanguage: "Secondary Language"
|
||||||
|
SecondaryLanguageTooltip: "Localization files for this language may be used if the primary language files lack the necessary lines."
|
||||||
TextureFiltering: "Texture Filtering"
|
TextureFiltering: "Texture Filtering"
|
||||||
TextureFilteringBilinear: "Bilinear"
|
TextureFilteringBilinear: "Bilinear"
|
||||||
TextureFilteringDisabled: "None"
|
TextureFilteringDisabled: "None"
|
||||||
|
|
|
@ -8,6 +8,8 @@ Controller: "Геймпад"
|
||||||
FieldOfView: "Поле зрения"
|
FieldOfView: "Поле зрения"
|
||||||
FrameRateHint: "Подсказка: нажмите F3, чтобы показать\nтекущую частоту смены кадров."
|
FrameRateHint: "Подсказка: нажмите F3, чтобы показать\nтекущую частоту смены кадров."
|
||||||
InvertXAxis: "Инвертировать ось X"
|
InvertXAxis: "Инвертировать ось X"
|
||||||
|
Language: "Язык"
|
||||||
|
LanguageNote: "Примечание: эти настройки не затрагивают строки из ESM-файлов."
|
||||||
LightingMethod: "Способ освещения"
|
LightingMethod: "Способ освещения"
|
||||||
LightingMethodLegacy: "Устаревший"
|
LightingMethodLegacy: "Устаревший"
|
||||||
LightingMethodShaders: "Шейдеры"
|
LightingMethodShaders: "Шейдеры"
|
||||||
|
@ -27,6 +29,8 @@ MaxLightsTooltip: "Значение по умолчанию: 8\nМаксимал
|
||||||
MouseAndKeyboard: "Мышь/Клавиатура"
|
MouseAndKeyboard: "Мышь/Клавиатура"
|
||||||
PostProcessing: "Постобработка"
|
PostProcessing: "Постобработка"
|
||||||
PostProcessingTooltip: "Настраивается через меню настроек постобработки, см. привязки клавиш."
|
PostProcessingTooltip: "Настраивается через меню настроек постобработки, см. привязки клавиш."
|
||||||
|
PrimaryLanguage: "Основной язык"
|
||||||
|
PrimaryLanguageTooltip: "Язык, строки на котором будут использоваться в первую очередь."
|
||||||
RainRippleDetail: "Капли дождя на воде"
|
RainRippleDetail: "Капли дождя на воде"
|
||||||
RainRippleDetailDense: "Плотные"
|
RainRippleDetailDense: "Плотные"
|
||||||
RainRippleDetailSimple: "Упрощенные"
|
RainRippleDetailSimple: "Упрощенные"
|
||||||
|
@ -41,6 +45,8 @@ ReflectionShaderDetailWorld: "Мир"
|
||||||
Refraction: "Рефракция"
|
Refraction: "Рефракция"
|
||||||
Screenshot: "Снимок экрана"
|
Screenshot: "Снимок экрана"
|
||||||
Scripts: "Скрипты"
|
Scripts: "Скрипты"
|
||||||
|
SecondaryLanguage: "Дополнительный язык"
|
||||||
|
SecondaryLanguageTooltip: "Язык, строки на котором будут использоваться, если соответствующие строки на основном языке не найдены."
|
||||||
TextureFiltering: "Фильтрация текстур"
|
TextureFiltering: "Фильтрация текстур"
|
||||||
TextureFilteringBilinear: "Билинейная"
|
TextureFilteringBilinear: "Билинейная"
|
||||||
TextureFilteringDisabled: "Отключена"
|
TextureFilteringDisabled: "Отключена"
|
||||||
|
|
|
@ -670,6 +670,28 @@
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
</Widget>
|
</Widget>
|
||||||
|
<Widget type="TabItem">
|
||||||
|
<Property key="Caption" value=" #{SettingsMenu:Language} "/>
|
||||||
|
<Widget type="AutoSizedTextBox" skin="SandText" position="4 4 300 32" align="Left Top">
|
||||||
|
<Property key="Caption" value="#{SettingsMenu:LanguageNote}"/>
|
||||||
|
</Widget>
|
||||||
|
<!-- Primary Language -->
|
||||||
|
<Widget type="TextBox" skin="NormalText" position="4 28 250 18" align="Left Top">
|
||||||
|
<Property key="Caption" value="#{SettingsMenu:PrimaryLanguage}"/>
|
||||||
|
<UserString key="ToolTipType" value="Layout"/>
|
||||||
|
<UserString key="ToolTipLayout" value="TextToolTip"/>
|
||||||
|
<UserString key="Caption_Text" value="#{SettingsMenu:PrimaryLanguageTooltip}"/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="ComboBox" skin="MW_ComboBox" position="4 52 250 24" align="Left Top" name="PrimaryLanguage" />
|
||||||
|
<!-- Secondary Language -->
|
||||||
|
<Widget type="TextBox" skin="NormalText" position="262 28 250 18" align="Left Top">
|
||||||
|
<Property key="Caption" value="#{SettingsMenu:SecondaryLanguage}"/>
|
||||||
|
<UserString key="ToolTipType" value="Layout"/>
|
||||||
|
<UserString key="ToolTipLayout" value="TextToolTip"/>
|
||||||
|
<UserString key="Caption_Text" value="#{SettingsMenu:SecondaryLanguageTooltip}"/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="ComboBox" skin="MW_ComboBox" position="262 52 250 24" align="Left Top" name="SecondaryLanguage" />
|
||||||
|
</Widget>
|
||||||
</Widget>
|
</Widget>
|
||||||
<Widget type="AutoSizedButton" skin="MW_Button" position="320 420 56 24" align="Right Bottom" name="OkButton">
|
<Widget type="AutoSizedButton" skin="MW_Button" position="320 420 56 24" align="Right Bottom" name="OkButton">
|
||||||
<Property key="ExpandDirection" value="Left"/>
|
<Property key="ExpandDirection" value="Left"/>
|
||||||
|
|
Loading…
Reference in a new issue