Fix defaults in the GUI to match the defaults when there is no config file

This commit is contained in:
Guillaume Meunier
2026-07-27 23:28:47 +02:00
parent 7e93d25ce0
commit 2d2f064576
4 changed files with 28 additions and 13 deletions
+18 -8
View File
@@ -218,19 +218,24 @@ void configuration::set_feature(feature f, bool state)
save();
}
configuration::configuration(xr::system & system, xr::session & session)
configuration::configuration(xr::system & system, xr::session & session) :
default_refresh_rate([&session]() {
const auto & rates = session.get_refresh_rates();
float default_rate = rates.empty() ? 0 : rates[0];
for (auto rate: rates)
{
if (rate >= max_default_rate)
break;
default_rate = rate;
}
return default_rate;
}())
{
passthrough_enabled = system.passthrough_supported() == xr::passthrough_type::color;
features[feature::hand_tracking] = system.hand_tracking_supported();
preferred_refresh_rate = default_refresh_rate;
const auto & rates = session.get_refresh_rates();
for (auto rate: rates)
{
if (rate >= max_default_rate)
break;
preferred_refresh_rate = rate;
}
const float default_refresh_rate = preferred_refresh_rate;
try
{
@@ -396,6 +401,11 @@ float configuration::get_stream_scale() const
{
if (stream_scale)
return *stream_scale;
return get_default_stream_scale();
}
float configuration::get_default_stream_scale() const
{
if (check_feature(feature::eye_gaze))
return 0.3;
return 0.5;
+3
View File
@@ -139,6 +139,7 @@ public:
void set_stream_scale(float);
float get_stream_scale() const;
float get_default_stream_scale() const;
uint32_t max_bitrate(bool extended) const
{
@@ -149,4 +150,6 @@ public:
{
return max_bitrate(extended_config);
}
const float default_refresh_rate = 0;
};
+1 -1
View File
@@ -187,7 +187,7 @@ void set_theme(const theme & t)
float & background_alpha()
{
static float alpha = 0.90f; // translucent panels by default
static float alpha = 0.75f; // translucent panels by default
return alpha;
}
+6 -4
View File
@@ -212,9 +212,11 @@ void settings_performance(const settings_context & ctx)
const std::string disconnect_tip = ctx.in_game ? _C("tooltip for disabled settings", "Disconnect to change this setting.") : std::string{};
std::vector<setting> list;
if (ctx.instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME) and not ctx.session.get_refresh_rates().empty())
if (const auto rates = ctx.session.get_refresh_rates(); not rates.empty())
{
const auto rates = ctx.session.get_refresh_rates();
auto it = std::ranges::find(rates, config.default_refresh_rate);
int default_rate_index = it == rates.end() ? 0 : (it - rates.begin() + 1);
list.push_back({
.id = "##refresh",
.label = _("Refresh rate"),
@@ -245,7 +247,7 @@ void settings_performance(const settings_context & ctx)
for (float r: rates)
opts.push_back(fmt::format("{}", int(r)));
return opts; },
.default_int = 0,
.default_int = default_rate_index,
});
}
@@ -859,7 +861,7 @@ void settings_theme(const settings_context & ctx)
ui::row_separator();
// Panel transparency, independent of the selected preset
static const int opacity_default = 90;
static const int opacity_default = 75;
int opacity = int(ui::background_alpha() * 100);
ui::setting_label(_cS("setting name", "Panel opacity"), _cS("setting description", "Opacity of the panel and card backgrounds"), control_w);
if (ui::slider_int("##opacity", &opacity, 20, 100, "%d%%", {control_w, 0}, &opacity_default))