1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-10 03:39:55 +00:00

Merge branch 'postprocess_hud' into 'master'

[Postprocessing] Improve HUD

See merge request OpenMW/openmw!1933
This commit is contained in:
psi29a 2022-05-26 06:24:36 +00:00
commit d74ee0f3fe
9 changed files with 46 additions and 58 deletions

View File

@ -59,7 +59,6 @@ namespace MWGui
getWidget(mTabConfiguration, "TabConfiguration"); getWidget(mTabConfiguration, "TabConfiguration");
getWidget(mActiveList, "ActiveList"); getWidget(mActiveList, "ActiveList");
getWidget(mInactiveList, "InactiveList"); getWidget(mInactiveList, "InactiveList");
getWidget(mModeToggle, "ModeToggle");
getWidget(mConfigLayout, "ConfigLayout"); getWidget(mConfigLayout, "ConfigLayout");
getWidget(mFilter, "Filter"); getWidget(mFilter, "Filter");
getWidget(mButtonActivate, "ButtonActivate"); getWidget(mButtonActivate, "ButtonActivate");
@ -78,8 +77,6 @@ namespace MWGui
mActiveList->eventListChangePosition += MyGUI::newDelegate(this, &PostProcessorHud::notifyListChangePosition); mActiveList->eventListChangePosition += MyGUI::newDelegate(this, &PostProcessorHud::notifyListChangePosition);
mInactiveList->eventListChangePosition += MyGUI::newDelegate(this, &PostProcessorHud::notifyListChangePosition); mInactiveList->eventListChangePosition += MyGUI::newDelegate(this, &PostProcessorHud::notifyListChangePosition);
mModeToggle->eventMouseButtonClick += MyGUI::newDelegate(this, &PostProcessorHud::notifyModeToggle);
mFilter->eventEditTextChange += MyGUI::newDelegate(this, &PostProcessorHud::notifyFilterChanged); mFilter->eventEditTextChange += MyGUI::newDelegate(this, &PostProcessorHud::notifyFilterChanged);
mMainWidget->castType<MyGUI::Window>()->eventWindowChangeCoord += MyGUI::newDelegate(this, &PostProcessorHud::notifyWindowResize); mMainWidget->castType<MyGUI::Window>()->eventWindowChangeCoord += MyGUI::newDelegate(this, &PostProcessorHud::notifyWindowResize);
@ -91,10 +88,14 @@ namespace MWGui
mShaderInfo->setEditReadOnly(true); mShaderInfo->setEditReadOnly(true);
mShaderInfo->setEditWordWrap(true); mShaderInfo->setEditWordWrap(true);
mShaderInfo->setEditMultiLine(true); mShaderInfo->setEditMultiLine(true);
mShaderInfo->setNeedMouseFocus(false);
mConfigLayout->setVisibleVScroll(true); mConfigLayout->setVisibleVScroll(true);
mConfigArea = mConfigLayout->createWidget<MyGUI::Widget>("", {}, MyGUI::Align::Default); mConfigArea = mConfigLayout->createWidget<MyGUI::Widget>("", {}, MyGUI::Align::Default);
mConfigLayout->eventMouseWheel += MyGUI::newDelegate(this, &PostProcessorHud::notifyMouseWheel);
mConfigArea->eventMouseWheel += MyGUI::newDelegate(this, &PostProcessorHud::notifyMouseWheel);
} }
void PostProcessorHud::notifyFilterChanged(MyGUI::EditBox* sender) void PostProcessorHud::notifyFilterChanged(MyGUI::EditBox* sender)
@ -225,12 +226,6 @@ namespace MWGui
} }
} }
void PostProcessorHud::notifyModeToggle(MyGUI::Widget* sender)
{
Settings::ShaderManager::Mode prev = Settings::ShaderManager::get().getMode();
toggleMode(prev == Settings::ShaderManager::Mode::Debug ? Settings::ShaderManager::Mode::Normal : Settings::ShaderManager::Mode::Debug);
}
void PostProcessorHud::onOpen() void PostProcessorHud::onOpen()
{ {
toggleMode(Settings::ShaderManager::Mode::Debug); toggleMode(Settings::ShaderManager::Mode::Debug);
@ -267,6 +262,15 @@ namespace MWGui
mConfigLayout->setSize(mConfigLayout->getWidth(), mConfigLayout->getParentSize().height - padding2); mConfigLayout->setSize(mConfigLayout->getWidth(), mConfigLayout->getParentSize().height - padding2);
} }
void PostProcessorHud::notifyMouseWheel(MyGUI::Widget *sender, int rel)
{
int offset = mConfigLayout->getViewOffset().top + rel * 0.3;
if (offset > 0)
mConfigLayout->setViewOffset(MyGUI::IntPoint(0, 0));
else
mConfigLayout->setViewOffset(MyGUI::IntPoint(0, static_cast<int>(offset)));
}
void PostProcessorHud::select(ListWrapper* list, size_t index) void PostProcessorHud::select(ListWrapper* list, size_t index)
{ {
list->setIndexSelected(index); list->setIndexSelected(index);
@ -277,8 +281,6 @@ namespace MWGui
{ {
Settings::ShaderManager::get().setMode(mode); Settings::ShaderManager::get().setMode(mode);
mModeToggle->setCaptionWithReplacing(mode == Settings::ShaderManager::Mode::Debug ? "#{sOn}" :"#{sOff}");
MWBase::Environment::get().getWorld()->getPostProcessor()->toggleMode(); MWBase::Environment::get().getWorld()->getPostProcessor()->toggleMode();
if (!isVisible()) if (!isVisible())
@ -353,6 +355,7 @@ namespace MWGui
MyGUI::Button* resetButton = mConfigArea->createWidget<MyGUI::Button>("MW_Button", {0,0,0,24}, MyGUI::Align::Default); MyGUI::Button* resetButton = mConfigArea->createWidget<MyGUI::Button>("MW_Button", {0,0,0,24}, MyGUI::Align::Default);
resetButton->setCaption("Reset all to default"); resetButton->setCaption("Reset all to default");
resetButton->setTextAlign(MyGUI::Align::Center); resetButton->setTextAlign(MyGUI::Align::Center);
resetButton->eventMouseWheel += MyGUI::newDelegate(this, &PostProcessorHud::notifyMouseWheel);
resetButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PostProcessorHud::notifyResetButtonClicked); resetButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PostProcessorHud::notifyResetButtonClicked);
} }
@ -366,6 +369,7 @@ namespace MWGui
fx::Widgets::UniformBase* uwidget = mConfigArea->createWidget<fx::Widgets::UniformBase>("MW_UniformEdit", {0,0,0,22}, MyGUI::Align::Default); fx::Widgets::UniformBase* uwidget = mConfigArea->createWidget<fx::Widgets::UniformBase>("MW_UniformEdit", {0,0,0,22}, MyGUI::Align::Default);
uwidget->init(uniform); uwidget->init(uniform);
uwidget->getLabel()->eventMouseWheel += MyGUI::newDelegate(this, &PostProcessorHud::notifyMouseWheel);
} }
} }

View File

@ -52,8 +52,6 @@ namespace MWGui
void updateConfigView(const std::string& name); void updateConfigView(const std::string& name);
void notifyModeToggle(MyGUI::Widget* sender);
void notifyResetButtonClicked(MyGUI::Widget* sender); void notifyResetButtonClicked(MyGUI::Widget* sender);
void notifyListChangePosition(MyGUI::ListBox* sender, size_t index); void notifyListChangePosition(MyGUI::ListBox* sender, size_t index);
@ -68,6 +66,8 @@ namespace MWGui
void notifyShaderDownPressed(MyGUI::Widget* sender); void notifyShaderDownPressed(MyGUI::Widget* sender);
void notifyMouseWheel(MyGUI::Widget *sender, int rel);
enum class Direction enum class Direction
{ {
Up, Up,
@ -97,7 +97,6 @@ namespace MWGui
MyGUI::Widget* mConfigArea; MyGUI::Widget* mConfigArea;
MyGUI::EditBox* mFilter; MyGUI::EditBox* mFilter;
Gui::AutoSizedButton* mModeToggle;
Gui::AutoSizedEditBox* mShaderInfo; Gui::AutoSizedEditBox* mShaderInfo;
std::string mOverrideHint; std::string mOverrideHint;

View File

@ -600,6 +600,11 @@ namespace fx
expect<Lexer::String>(); expect<Lexer::String>();
uniform->mHeader = std::get<Lexer::String>(mToken).value; uniform->mHeader = std::get<Lexer::String>(mToken).value;
} }
else if (key == "display_name")
{
expect<Lexer::String>();
uniform->mDisplayName = std::get<Lexer::String>(mToken).value;
}
else else
error(Misc::StringUtils::format("unexpected key '%s'", std::string{key})); error(Misc::StringUtils::format("unexpected key '%s'", std::string{key}));

View File

@ -103,6 +103,7 @@ namespace fx
struct UniformBase struct UniformBase
{ {
std::string mName; std::string mName;
std::string mDisplayName;
std::string mHeader; std::string mHeader;
std::string mTechniqueName; std::string mTechniqueName;
std::string mDescription; std::string mDescription;

View File

@ -78,7 +78,7 @@ namespace fx
void UniformBase::init(const std::shared_ptr<fx::Types::UniformBase>& uniform) void UniformBase::init(const std::shared_ptr<fx::Types::UniformBase>& uniform)
{ {
mLabel->setCaption(uniform->mName); mLabel->setCaption(uniform->mDisplayName.empty() ? uniform->mName : uniform->mDisplayName);
if (uniform->mDescription.empty()) if (uniform->mDescription.empty())
{ {

View File

@ -249,6 +249,8 @@ namespace fx
void addItem(EditBase* item); void addItem(EditBase* item);
Gui::AutoSizedTextBox* getLabel() { return mLabel; }
private: private:
void notifyResetClicked(MyGUI::Widget* sender); void notifyResetClicked(MyGUI::Widget* sender);

View File

@ -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. 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 | | Block | default | min | max | static | step | description | display_name | header |
+=================+==========+==========+==========+=========+==========+==============+=========+ +=================+==========+==========+==========+=========+==========+==============+===================+=========+
|``uniform_bool`` | boolean | x | x | boolean | x | string | string | |``uniform_bool`` | boolean | x | x | boolean | x | string | string | string |
+-----------------+----------+----------+----------+---------+----------+--------------+---------+ +-----------------+----------+----------+----------+---------+----------+--------------+-------------------+---------+
|``uniform_float``| float | float | float | boolean | float | string | string | |``uniform_float``| float | float | float | boolean | float | string | string | string |
+-----------------+----------+----------+----------+---------+----------+--------------+---------+ +-----------------+----------+----------+----------+---------+----------+--------------+-------------------+---------+
|``uniform_int`` | integer | integer | integer | boolean | integer | string | string | |``uniform_int`` | integer | integer | integer | boolean | integer | string | string | string |
+-----------------+----------+----------+----------+---------+----------+--------------+---------+ +-----------------+----------+----------+----------+---------+----------+--------------+-------------------+---------+
|``uniform_vec2`` | vec2 | vec2 | vec2 | boolean | vec2 | string | string | |``uniform_vec2`` | vec2 | vec2 | vec2 | boolean | vec2 | string | string | string |
+-----------------+----------+----------+----------+---------+----------+--------------+---------+ +-----------------+----------+----------+----------+---------+----------+--------------+-------------------+---------+
|``uniform_vec3`` | vec3 | vec3 | vec3 | boolean | vec3 | string | string | |``uniform_vec3`` | vec3 | vec3 | vec3 | boolean | vec3 | string | string | string |
+-----------------+----------+----------+----------+---------+----------+--------------+---------+ +-----------------+----------+----------+----------+---------+----------+--------------+-------------------+---------+
|``uniform_vec4`` | vec4 | vec4 | vec4 | boolean | vec4 | 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 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 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. 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; max = 1.0;
step = 0.05; step = 0.05;
static = true; static = true;
display_name = "Desaturation Factor";
description = "Desaturation factor. A value of 1.0 is full grayscale."; description = "Desaturation factor. A value of 1.0 is full grayscale.";
} }

View File

@ -28,7 +28,7 @@
<Property key="Padding" value="0"/> <Property key="Padding" value="0"/>
<Property key="Spacing" value="8"/> <Property key="Spacing" value="8"/>
<Widget type="Widget" position ="0 0 0 400"> <Widget type="Widget" position ="0 0 0 300">
<UserString key="HStretch" value="true"/> <UserString key="HStretch" value="true"/>
<UserString key="VStretch" value="false"/> <UserString key="VStretch" value="false"/>
@ -103,31 +103,6 @@
</Widget> </Widget>
</Widget> </Widget>
<Widget type="Widget" position="0 0 230 28" align="Bottom Left">
<UserString key="HStretch" value="false"/>
<UserString key="VStretch" value="false"/>
<Widget type="HBox" position_real="0 0 1 1" align="Stretch">
<UserString key="HStretch" value="true"/>
<Property key="Spacing" value="4"/>
<Widget type="AutoSizedTextBox" skin="SandText">
<UserString key="HStretch" value="true"/>
<UserString key="VStretch" value="true"/>
<Property key="Caption" value="Enable Config Mode"/>
<Property key="TextAlign" value="Left VCenter"/>
</Widget>
<Widget type="AutoSizedButton" skin="MW_Button" name="ModeToggle">
<UserString key="VStretch" value="true"/>
<Property key="Caption" value="#{sOff}"/>
</Widget>
</Widget>
</Widget>
<Widget type="Widget" />
</Widget> </Widget>
</Widget> </Widget>

View File

@ -59,7 +59,7 @@
<Widget type="AutoSizedTextBox" skin="SandText" name="Label" align="Top Right"> <Widget type="AutoSizedTextBox" skin="SandText" name="Label" align="Top Right">
<UserString key="HStretch" value="true"/> <UserString key="HStretch" value="true"/>
<UserString key="VStretch" value="true"/> <UserString key="VStretch" value="true"/>
<Property key="Padding" value="8"/> <Property key="Padding" value="8"/>
<Property key="TextAlign" value="Left Top"/> <Property key="TextAlign" value="Left Top"/>
<Property key="NeedMouse" value="true"/> <Property key="NeedMouse" value="true"/>
</Widget> </Widget>