From e0c05a15fbcb807ea95c4a2f3b619bfd0062d6b6 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sun, 24 Jul 2022 13:18:50 +0000 Subject: [PATCH] Post processing shaders localization --- components/fx/widgets.cpp | 7 +++++-- docs/source/reference/postprocessing/overview.rst | 15 +++++++++++---- files/data/CMakeLists.txt | 2 ++ files/data/l10n/BuiltInShaders/en.yaml | 3 +++ files/data/l10n/BuiltInShaders/ru.yaml | 3 +++ files/data/l10n/PostProcessing/en.yaml | 5 +++++ files/data/l10n/PostProcessing/ru.yaml | 7 ++++++- files/data/shaders/displaydepth.omwfx | 4 +++- files/data/shaders/main.omwfx | 8 +++++--- 9 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 files/data/l10n/BuiltInShaders/en.yaml create mode 100644 files/data/l10n/BuiltInShaders/ru.yaml diff --git a/components/fx/widgets.cpp b/components/fx/widgets.cpp index 749f0a1c6a..1f9ec50d45 100644 --- a/components/fx/widgets.cpp +++ b/components/fx/widgets.cpp @@ -80,7 +80,10 @@ namespace fx void UniformBase::init(const std::shared_ptr& uniform) { - mLabel->setCaption(uniform->mDisplayName.empty() ? uniform->mName : uniform->mDisplayName); + if (uniform->mDisplayName.empty()) + mLabel->setCaption(uniform->mName); + else + mLabel->setCaptionWithReplacing(uniform->mDisplayName); if (uniform->mDescription.empty()) { @@ -163,4 +166,4 @@ namespace fx assignWidget(mClient, "Client"); } } -} \ No newline at end of file +} diff --git a/docs/source/reference/postprocessing/overview.rst b/docs/source/reference/postprocessing/overview.rst index 8262895b72..275461bfd2 100644 --- a/docs/source/reference/postprocessing/overview.rst +++ b/docs/source/reference/postprocessing/overview.rst @@ -34,12 +34,19 @@ of two ways: key by default. This is the recommended method as manual editing can be error prone. +Localization +============ + +Output text (e.g. shader description) can use the ``#{ContextName:Key}`` tags. +In this case OpenMW replaces it for value of ``Key`` key from the +``Data Files\L10n\ContextName\used_language.yaml`` file. + Hot Reloading -============== +============= It is possible to modify a shader without restarting OpenMW, :ref:`live reload` must be enabled in ``settings.cfg``. Whenever a file is modified and saved, the shader will automatically reload in game. This allows shaders to be written in a -text editor you are comfortable with. The only restriction is that new shaders -cannot be added, as the VFS will not be rebuilt and OpenMW will not be aware of -the new file. +text editor you are comfortable with. The only restriction is that the VFS is not +aware of new files or changes in non-shader files, so new shaders and localization +strings can not be used. diff --git a/files/data/CMakeLists.txt b/files/data/CMakeLists.txt index 8b1dd3a9a3..f901ef3293 100644 --- a/files/data/CMakeLists.txt +++ b/files/data/CMakeLists.txt @@ -20,6 +20,8 @@ set(BUILTIN_DATA_FILES fonts/Pelagiad.omwfont fonts/PelagiadFontLicense.txt + l10n/BuiltInShaders/en.yaml + l10n/BuiltInShaders/ru.yaml l10n/Calendar/en.yaml l10n/Calendar/ru.yaml l10n/Calendar/sv.yaml diff --git a/files/data/l10n/BuiltInShaders/en.yaml b/files/data/l10n/BuiltInShaders/en.yaml new file mode 100644 index 0000000000..f1c6112a49 --- /dev/null +++ b/files/data/l10n/BuiltInShaders/en.yaml @@ -0,0 +1,3 @@ +DisplayDepthDescription: "Visualizes the depth buffer." +DisplayDepthFactorDescription: "Determines correlation between pixel depth value and its output color. High values lead to brighter image." +DisplayDepthFactorName: "Color factor" diff --git a/files/data/l10n/BuiltInShaders/ru.yaml b/files/data/l10n/BuiltInShaders/ru.yaml new file mode 100644 index 0000000000..3c552ea301 --- /dev/null +++ b/files/data/l10n/BuiltInShaders/ru.yaml @@ -0,0 +1,3 @@ +DisplayDepthDescription: "Визуализирует буфер глубины." +DisplayDepthFactorDescription: "Определяет соотношение между значением глубины пикселя и его цветом. Чем выше значение, тем ярче будет изображение." +DisplayDepthFactorName: "Соотношение цвета" diff --git a/files/data/l10n/PostProcessing/en.yaml b/files/data/l10n/PostProcessing/en.yaml index 44cb90cacf..f40a318cca 100644 --- a/files/data/l10n/PostProcessing/en.yaml +++ b/files/data/l10n/PostProcessing/en.yaml @@ -1,7 +1,11 @@ Abovewater: "Abovewater" Author: "Author" Configuration: "Configuration" +ContrastLevelDescription: "Constrast level" +ContrastLevelName: "Constrast" Description: "Description" +GammaLevelDescription: "Gamma level" +GammaLevelName: "Gamma" InExteriors: "Exteriors" InInteriors: "Interiors" KeyboardControls: | @@ -11,6 +15,7 @@ KeyboardControls: | Shift+Left-Arrow > Deactive shader Shift+Up-Arrow > Move shader up Shift+Down-Arrow > Move shader down +MainPassDescription: "Passes scene data to post processing shaders. Can not be toggled or moved." PostProcessHUD: "Postprocess HUD" ResetShader: "Reset shader to default state" ShaderLocked: "Locked" diff --git a/files/data/l10n/PostProcessing/ru.yaml b/files/data/l10n/PostProcessing/ru.yaml index 6bbe3e1e47..fdae0947ba 100644 --- a/files/data/l10n/PostProcessing/ru.yaml +++ b/files/data/l10n/PostProcessing/ru.yaml @@ -1,7 +1,11 @@ Abovewater: "Над водой" Author: "Автор" Configuration: "Настройки" +ContrastLevelDescription: "Контрастность изображения" +ContrastLevelName: "Контрастность" Description: "Описание" +GammaLevelDescription: "Яркость изображения" +GammaLevelName: "Яркость" InExteriors: "Вне помещений" InInteriors: "В помещениях" KeyboardControls: | @@ -11,10 +15,11 @@ KeyboardControls: | Shift+Left-Arrow > Выключить шейдер Shift+Up-Arrow > Передвинуть шейдер выше Shift+Down-Arrow > Передвинуть шейдер ниже +MainPassDescription: "Передает данные сцены в шейдеры постобработки. Не может быть выключен или передвинут." PostProcessHUD: "Настройки постобработки" ResetShader: "Обнулить настройки этого шейдера" ShaderLocked: "Заблокирован" -ShaderLockedDescription: "Не может быть выключен или перемещен, управляется внешним Lua-скриптом" +ShaderLockedDescription: "Не может быть выключен или передвинут, управляется внешним Lua-скриптом" ShaderResetUniform: "x" Underwater: "Под водой" Version: "Версия" diff --git a/files/data/shaders/displaydepth.omwfx b/files/data/shaders/displaydepth.omwfx index 8b73a5abab..3ea1b4c54d 100644 --- a/files/data/shaders/displaydepth.omwfx +++ b/files/data/shaders/displaydepth.omwfx @@ -3,6 +3,8 @@ uniform_float uFactor { min = 0.01; max = 20.0; default = 1.0; + display_name = "#{BuiltInShaders:DisplayDepthFactorName}"; + description = "#{BuiltInShaders:DisplayDepthFactorDescription}"; } fragment main { @@ -20,7 +22,7 @@ fragment main { technique { passes = main; - description = "Visualizes the depth buffer."; + description = "#{BuiltInShaders:DisplayDepthDescription}"; author = "OpenMW"; version = "1.0"; } diff --git a/files/data/shaders/main.omwfx b/files/data/shaders/main.omwfx index 8d12cebf81..d42fb6c77f 100644 --- a/files/data/shaders/main.omwfx +++ b/files/data/shaders/main.omwfx @@ -11,7 +11,8 @@ uniform_float uGamma { step = 0.01; min = 0.0; max = 5.0; - description = "gamma level"; + display_name = "#{PostProcessing:GammaLevelName}"; + description = "#{PostProcessing:GammaLevelDescription}"; } uniform_float uContrast { @@ -19,7 +20,8 @@ uniform_float uContrast { step = 0.01; min = 0.0; max = 5.0; - description = "constrast level"; + display_name = "#{PostProcessing:ContrastLevelName}"; + description = "#{PostProcessing:ContrastLevelDescription}"; } fragment main { @@ -37,7 +39,7 @@ fragment main { } technique { - description = "Main pass."; + description = "#{PostProcessing:MainPassDescription}"; version = "1.0"; author = "OpenMW"; passes = main;