From 424b828ff86ac49776877786bb4d83323440a757 Mon Sep 17 00:00:00 2001 From: cody glassman Date: Wed, 25 May 2022 19:17:31 -0700 Subject: [PATCH] add ability to use display names --- components/fx/technique.cpp | 5 +++ components/fx/types.hpp | 1 + components/fx/widgets.cpp | 2 +- .../source/reference/postprocessing/omwfx.rst | 34 ++++++++++--------- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/components/fx/technique.cpp b/components/fx/technique.cpp index 019744e70d..2b8f37c96f 100644 --- a/components/fx/technique.cpp +++ b/components/fx/technique.cpp @@ -600,6 +600,11 @@ namespace fx expect(); uniform->mHeader = std::get(mToken).value; } + else if (key == "display_name") + { + expect(); + uniform->mDisplayName = std::get(mToken).value; + } else error(Misc::StringUtils::format("unexpected key '%s'", std::string{key})); diff --git a/components/fx/types.hpp b/components/fx/types.hpp index 40eee003f2..ba809cdd9a 100644 --- a/components/fx/types.hpp +++ b/components/fx/types.hpp @@ -103,6 +103,7 @@ namespace fx struct UniformBase { std::string mName; + std::string mDisplayName; std::string mHeader; std::string mTechniqueName; std::string mDescription; diff --git a/components/fx/widgets.cpp b/components/fx/widgets.cpp index 2206fd8c7f..4316e8d7fe 100644 --- a/components/fx/widgets.cpp +++ b/components/fx/widgets.cpp @@ -78,7 +78,7 @@ namespace fx void UniformBase::init(const std::shared_ptr& uniform) { - mLabel->setCaption(uniform->mName); + mLabel->setCaption(uniform->mDisplayName.empty() ? uniform->mName : uniform->mDisplayName); if (uniform->mDescription.empty()) { diff --git a/docs/source/reference/postprocessing/omwfx.rst b/docs/source/reference/postprocessing/omwfx.rst index 188fc9cebb..8e8cab2c5a 100644 --- a/docs/source/reference/postprocessing/omwfx.rst +++ b/docs/source/reference/postprocessing/omwfx.rst @@ -413,24 +413,25 @@ To use the sampler, define the appropriately named `sampler2D` in any of your pa It is possible to define settings for your shaders that can be adjusted by either users or a Lua script. -+-----------------+----------+----------+----------+---------+----------+--------------+---------+ -| Block | default | min | max | static | step | description | header | -+=================+==========+==========+==========+=========+==========+==============+=========+ -|``uniform_bool`` | boolean | x | x | boolean | x | string | string | -+-----------------+----------+----------+----------+---------+----------+--------------+---------+ -|``uniform_float``| float | float | float | boolean | float | string | string | -+-----------------+----------+----------+----------+---------+----------+--------------+---------+ -|``uniform_int`` | integer | integer | integer | boolean | integer | string | string | -+-----------------+----------+----------+----------+---------+----------+--------------+---------+ -|``uniform_vec2`` | vec2 | vec2 | vec2 | boolean | vec2 | string | string | -+-----------------+----------+----------+----------+---------+----------+--------------+---------+ -|``uniform_vec3`` | vec3 | vec3 | vec3 | boolean | vec3 | string | string | -+-----------------+----------+----------+----------+---------+----------+--------------+---------+ -|``uniform_vec4`` | vec4 | vec4 | vec4 | boolean | vec4 | string | string | -+-----------------+----------+----------+----------+---------+----------+--------------+---------+ ++-----------------+----------+----------+----------+---------+----------+--------------+-------------------+---------+ +| Block | default | min | max | static | step | description | display_name | header | ++=================+==========+==========+==========+=========+==========+==============+===================+=========+ +|``uniform_bool`` | boolean | x | x | boolean | x | string | string | string | ++-----------------+----------+----------+----------+---------+----------+--------------+-------------------+---------+ +|``uniform_float``| float | float | float | boolean | float | string | string | string | ++-----------------+----------+----------+----------+---------+----------+--------------+-------------------+---------+ +|``uniform_int`` | integer | integer | integer | boolean | integer | string | string | string | ++-----------------+----------+----------+----------+---------+----------+--------------+-------------------+---------+ +|``uniform_vec2`` | vec2 | vec2 | vec2 | boolean | vec2 | string | string | string | ++-----------------+----------+----------+----------+---------+----------+--------------+-------------------+---------+ +|``uniform_vec3`` | vec3 | vec3 | vec3 | boolean | vec3 | string | string | string | ++-----------------+----------+----------+----------+---------+----------+--------------+-------------------+---------+ +|``uniform_vec4`` | vec4 | vec4 | vec4 | boolean | vec4 | string | string | string | ++-----------------+----------+----------+----------+---------+----------+--------------+-------------------+---------+ The ``description`` field is used to display a toolip when viewed in the in-game HUD. The ``header`` field -field can be used to organize uniforms into groups in the HUD. +field can be used to organize uniforms into groups in the HUD. The ``display_name`` field can be used to create a +more user friendly uniform name for display in the HUD. If you would like a uniform to be adjustable with Lua API you `must` set ``static = false;``. Doing this will also remove the uniform from the players HUD. @@ -580,6 +581,7 @@ desaturation to apply to the scene. Here we setup a new variable of type max = 1.0; step = 0.05; static = true; + display_name = "Desaturation Factor"; description = "Desaturation factor. A value of 1.0 is full grayscale."; }