UI: Bold modified settings values

This commit is contained in:
Luke Street
2026-05-03 16:01:33 -06:00
parent da9b99f650
commit 5717aeef85
11 changed files with 102 additions and 11 deletions
Binary file not shown.
+4
View File
@@ -233,6 +233,10 @@ select-button value {
font-size: 20dp;
}
select-button value.modified {
font-weight: bold;
}
select-button input {
text-align: right;
font-size: 20dp;
+8 -1
View File
@@ -5,7 +5,14 @@ namespace dusk::ui {
BoolButton::BoolButton(Rml::Element* parent, Props props)
: BaseControlledSelectButton(parent, {std::move(props.key)}),
mGetValue(std::move(props.getValue)), mSetValue(std::move(props.setValue)),
mIsDisabled(std::move(props.isDisabled)) {}
mIsDisabled(std::move(props.isDisabled)), mIsModified(std::move(props.isModified)) {}
bool BoolButton::modified() const {
if (mIsModified) {
return mIsModified();
}
return BaseControlledSelectButton::modified();
}
bool BoolButton::disabled() const {
if (mIsDisabled) {
+3
View File
@@ -10,10 +10,12 @@ public:
std::function<bool()> getValue;
std::function<void(bool)> setValue;
std::function<bool()> isDisabled;
std::function<bool()> isModified;
};
BoolButton(Rml::Element* parent, Props props);
bool modified() const override;
bool disabled() const override;
protected:
@@ -24,6 +26,7 @@ private:
std::function<int()> mGetValue;
std::function<void(int)> mSetValue;
std::function<bool()> mIsDisabled;
std::function<bool()> mIsModified;
};
} // namespace dusk::ui
+10 -2
View File
@@ -8,8 +8,16 @@ namespace dusk::ui {
NumberButton::NumberButton(Rml::Element* parent, Props props)
: BaseStringButton(parent, {.key = std::move(props.key), .type = "number"}),
mGetValue(std::move(props.getValue)), mSetValue(std::move(props.setValue)),
mIsDisabled(std::move(props.isDisabled)), mMin(props.min), mMax(props.max), mStep(props.step),
mPrefix(std::move(props.prefix)), mSuffix(std::move(props.suffix)) {}
mIsDisabled(std::move(props.isDisabled)), mIsModified(std::move(props.isModified)),
mMin(props.min), mMax(props.max), mStep(props.step), mPrefix(std::move(props.prefix)),
mSuffix(std::move(props.suffix)) {}
bool NumberButton::modified() const {
if (mIsModified) {
return mIsModified();
}
return BaseStringButton::modified();
}
bool NumberButton::disabled() const {
if (mIsDisabled) {
+3
View File
@@ -11,6 +11,7 @@ public:
std::function<int()> getValue;
std::function<void(int)> setValue;
std::function<bool()> isDisabled;
std::function<bool()> isModified;
int min = 0;
int max = INT_MAX;
int step = 1;
@@ -20,6 +21,7 @@ public:
NumberButton(Rml::Element* parent, Props props);
bool modified() const override;
bool disabled() const override;
protected:
@@ -32,6 +34,7 @@ private:
std::function<int()> mGetValue;
std::function<void(int)> mSetValue;
std::function<bool()> mIsDisabled;
std::function<bool()> mIsModified;
int mMin;
int mMax;
int mStep;
+1 -1
View File
@@ -23,7 +23,7 @@ const Rml::String kDocumentSource = R"RML(
<link type="text/rcss" href="res/rml/popup.rcss" />
</head>
<body>
<popup id="popup"></div>
<popup id="popup"></popup>
</body>
</rml>
)RML";
+31 -1
View File
@@ -2,6 +2,7 @@
#include "ui.hpp"
#include <fmt/format.h>
#include <utility>
namespace dusk::ui {
@@ -23,9 +24,29 @@ SelectButton::SelectButton(Rml::Element* parent, Props props)
on_nav_command([this](Rml::Event&, NavCommand cmd) { return handle_nav_command(cmd); });
}
bool SelectButton::modified() const {
return mProps.modified;
}
void SelectButton::set_modified(bool value) {
if (mProps.modified != value) {
mValueElem->SetClass("modified", value);
if (value) {
mValueElem->SetInnerRML(fmt::format("• {}", escape(mProps.value)));
} else {
mValueElem->SetInnerRML(escape(mProps.value));
}
mProps.modified = value;
}
}
void SelectButton::set_value_label(const Rml::String& value) {
if (mProps.value != value) {
mValueElem->SetInnerRML(escape(value));
if (mProps.modified) {
mValueElem->SetInnerRML(fmt::format("• {}", escape(value)));
} else {
mValueElem->SetInnerRML(escape(value));
}
mProps.value = value;
}
}
@@ -35,6 +56,7 @@ void SelectButton::update_props(Props props) {
mKeyElem->SetInnerRML(escape(props.key));
}
set_value_label(props.value);
set_modified(props.modified);
mProps = std::move(props);
}
@@ -49,9 +71,17 @@ bool SelectButton::handle_nav_command(NavCommand cmd) {
void BaseControlledSelectButton::update() {
set_disabled(disabled());
set_value_label(format_value());
set_modified(modified());
SelectButton::update();
}
bool ControlledSelectButton::modified() const {
if (mIsModified) {
return mIsModified();
}
return BaseControlledSelectButton::modified();
}
bool ControlledSelectButton::disabled() const {
if (mIsDisabled) {
return mIsDisabled();
+8 -2
View File
@@ -10,10 +10,13 @@ public:
struct Props {
Rml::String key;
Rml::String value;
bool modified = false;
};
SelectButton(Rml::Element* parent, Props props);
virtual bool modified() const;
void set_modified(bool value);
void set_value_label(const Rml::String& value);
protected:
@@ -23,7 +26,6 @@ protected:
Props mProps;
Rml::Element* mKeyElem = nullptr;
Rml::Element* mValueElem = nullptr;
std::function<void()> mOnHover;
};
class BaseControlledSelectButton : public SelectButton {
@@ -43,12 +45,15 @@ public:
Rml::String key;
std::function<Rml::String()> getValue;
std::function<bool()> isDisabled;
std::function<bool()> isModified;
};
ControlledSelectButton(Rml::Element* parent, Props props)
: BaseControlledSelectButton(parent, {std::move(props.key)}),
mGetValue(std::move(props.getValue)), mIsDisabled(std::move(props.isDisabled)) {}
mGetValue(std::move(props.getValue)), mIsDisabled(std::move(props.isDisabled)),
mIsModified(std::move(props.isModified)) {}
bool modified() const override;
bool disabled() const override;
protected:
@@ -56,6 +61,7 @@ protected:
std::function<Rml::String()> mGetValue;
std::function<bool()> mIsDisabled;
std::function<bool()> mIsModified;
};
} // namespace dusk::ui
+33 -4
View File
@@ -81,8 +81,7 @@ struct ConfigBoolProps {
SelectButton& config_bool_select(
Pane& leftPane, Pane& rightPane, ConfigVar<bool>& var, ConfigBoolProps props) {
return leftPane
.add_child<BoolButton>(BoolButton::Props{
.key = std::move(props.key),
.add_child<BoolButton>(BoolButton::Props{.key = std::move(props.key),
.getValue = [&var] { return var.getValue(); },
.setValue =
[&var, callback = std::move(props.onChange)](bool value) {
@@ -96,7 +95,7 @@ SelectButton& config_bool_select(
}
},
.isDisabled = std::move(props.isDisabled),
})
.isModified = [&var] { return var.getValue() != var.getDefaultValue(); }})
.on_focus([&rightPane, helpText = std::move(props.helpText)](Rml::Event&) {
rightPane.clear();
rightPane.add_rml(helpText);
@@ -116,6 +115,7 @@ SelectButton& config_percent_select(Pane& leftPane, Pane& rightPane, ConfigVar<f
config::Save();
},
.isDisabled = std::move(isDisabled),
.isModified = [&var] { return var.getValue() != var.getDefaultValue(); },
.min = min,
.max = max,
.step = step,
@@ -158,6 +158,11 @@ SettingsWindow::SettingsWindow() {
config::Save();
audio::SetMasterVolume(value / 100.f);
},
.isModified =
[] {
return getSettings().audio.masterVolume.getValue() !=
getSettings().audio.masterVolume.getDefaultValue();
},
.max = 100,
.suffix = "%",
})
@@ -284,6 +289,11 @@ SettingsWindow::SettingsWindow() {
config::Save();
},
.isDisabled = [] { return getSettings().game.speedrunMode; },
.isModified =
[] {
return getSettings().game.damageMultiplier.getValue() !=
getSettings().game.damageMultiplier.getDefaultValue();
},
.min = 1,
.max = 8,
.prefix = "x",
@@ -471,6 +481,11 @@ SettingsWindow::SettingsWindow() {
return format_graphics_setting_value(GraphicsOption::InternalResolution,
getSettings().game.internalResolutionScale.getValue());
},
.isModified =
[] {
return getSettings().game.internalResolutionScale.getValue() !=
getSettings().game.internalResolutionScale.getDefaultValue();
},
})
.on_nav_command([](Rml::Event&, NavCommand cmd) {
if (cmd == NavCommand::Confirm || cmd == NavCommand::Left ||
@@ -499,6 +514,11 @@ SettingsWindow::SettingsWindow() {
return format_graphics_setting_value(GraphicsOption::ShadowResolution,
getSettings().game.shadowResolutionMultiplier.getValue());
},
.isModified =
[] {
return getSettings().game.shadowResolutionMultiplier.getValue() !=
getSettings().game.shadowResolutionMultiplier.getDefaultValue();
},
})
.on_nav_command([](Rml::Event&, NavCommand cmd) {
if (cmd == NavCommand::Confirm || cmd == NavCommand::Left ||
@@ -529,6 +549,11 @@ SettingsWindow::SettingsWindow() {
return format_graphics_setting_value(GraphicsOption::BloomMode,
static_cast<int>(getSettings().game.bloomMode.getValue()));
},
.isModified =
[] {
return getSettings().game.bloomMode.getValue() !=
getSettings().game.bloomMode.getDefaultValue();
},
})
.on_nav_command([](Rml::Event&, NavCommand cmd) {
if (cmd == NavCommand::Confirm || cmd == NavCommand::Left ||
@@ -559,6 +584,11 @@ SettingsWindow::SettingsWindow() {
},
.isDisabled =
[] { return getSettings().game.bloomMode.getValue() == BloomMode::Off; },
.isModified =
[] {
return getSettings().game.bloomMultiplier.getValue() !=
getSettings().game.bloomMultiplier.getDefaultValue();
},
})
.on_nav_command([](Rml::Event&, NavCommand cmd) {
if (cmd == NavCommand::Confirm || cmd == NavCommand::Left ||
@@ -619,7 +649,6 @@ SettingsWindow::SettingsWindow() {
"- Account Username"
});
#endif
leftPane.add_section("Advanced");
config_bool_select(leftPane, rightPane, getSettings().backend.skipPreLaunchUI,
{
.key = "Skip Pre-Launch UI",
+1
View File
@@ -33,6 +33,7 @@ bool initialize() noexcept {
}
load_font("FiraSans-Regular.ttf", true);
load_font("FiraSans-Bold.ttf");
load_font("FiraSansCondensed-Regular.ttf");
load_font("FiraSansCondensed-Bold.ttf");
load_font("AlegreyaSC-Regular.ttf");