Fix defaults in the GUI to match the defaults when there is no config file
This commit is contained in:
@@ -218,19 +218,24 @@ void configuration::set_feature(feature f, bool state)
|
|||||||
save();
|
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;
|
passthrough_enabled = system.passthrough_supported() == xr::passthrough_type::color;
|
||||||
features[feature::hand_tracking] = system.hand_tracking_supported();
|
features[feature::hand_tracking] = system.hand_tracking_supported();
|
||||||
|
|
||||||
|
preferred_refresh_rate = default_refresh_rate;
|
||||||
const auto & rates = session.get_refresh_rates();
|
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
|
try
|
||||||
{
|
{
|
||||||
@@ -396,6 +401,11 @@ float configuration::get_stream_scale() const
|
|||||||
{
|
{
|
||||||
if (stream_scale)
|
if (stream_scale)
|
||||||
return *stream_scale;
|
return *stream_scale;
|
||||||
|
return get_default_stream_scale();
|
||||||
|
}
|
||||||
|
|
||||||
|
float configuration::get_default_stream_scale() const
|
||||||
|
{
|
||||||
if (check_feature(feature::eye_gaze))
|
if (check_feature(feature::eye_gaze))
|
||||||
return 0.3;
|
return 0.3;
|
||||||
return 0.5;
|
return 0.5;
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ public:
|
|||||||
|
|
||||||
void set_stream_scale(float);
|
void set_stream_scale(float);
|
||||||
float get_stream_scale() const;
|
float get_stream_scale() const;
|
||||||
|
float get_default_stream_scale() const;
|
||||||
|
|
||||||
uint32_t max_bitrate(bool extended) const
|
uint32_t max_bitrate(bool extended) const
|
||||||
{
|
{
|
||||||
@@ -149,4 +150,6 @@ public:
|
|||||||
{
|
{
|
||||||
return max_bitrate(extended_config);
|
return max_bitrate(extended_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const float default_refresh_rate = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ void set_theme(const theme & t)
|
|||||||
|
|
||||||
float & background_alpha()
|
float & background_alpha()
|
||||||
{
|
{
|
||||||
static float alpha = 0.90f; // translucent panels by default
|
static float alpha = 0.75f; // translucent panels by default
|
||||||
return alpha;
|
return alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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{};
|
const std::string disconnect_tip = ctx.in_game ? _C("tooltip for disabled settings", "Disconnect to change this setting.") : std::string{};
|
||||||
std::vector<setting> list;
|
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({
|
list.push_back({
|
||||||
.id = "##refresh",
|
.id = "##refresh",
|
||||||
.label = _("Refresh rate"),
|
.label = _("Refresh rate"),
|
||||||
@@ -245,7 +247,7 @@ void settings_performance(const settings_context & ctx)
|
|||||||
for (float r: rates)
|
for (float r: rates)
|
||||||
opts.push_back(fmt::format("{}", int(r)));
|
opts.push_back(fmt::format("{}", int(r)));
|
||||||
return opts; },
|
return opts; },
|
||||||
.default_int = 0,
|
.default_int = default_rate_index,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -859,7 +861,7 @@ void settings_theme(const settings_context & ctx)
|
|||||||
ui::row_separator();
|
ui::row_separator();
|
||||||
|
|
||||||
// Panel transparency, independent of the selected preset
|
// 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);
|
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);
|
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))
|
if (ui::slider_int("##opacity", &opacity, 20, 100, "%d%%", {control_w, 0}, &opacity_default))
|
||||||
|
|||||||
Reference in New Issue
Block a user