diff --git a/client/scenes/lobby.cpp b/client/scenes/lobby.cpp index ef9eeba6..bffdca2b 100644 --- a/client/scenes/lobby.cpp +++ b/client/scenes/lobby.cpp @@ -212,6 +212,13 @@ scenes::lobby::lobby() auto json_show_plots = root["show_performance_metrics"]; if (json_show_plots.is_bool()) show_performance_metrics = json_show_plots.get_bool(); + + auto rate = root["preferred_refresh_rate"]; + if (rate.is_double()) + { + preferred_refresh_rate = rate.get_double(); + session.set_refresh_rate(preferred_refresh_rate); + } } catch(std::exception& e) { @@ -277,8 +284,10 @@ void scenes::lobby::save_config() std::ofstream json(application::get_config_path() / "client.json"); json << "{\"servers\":[" << servers_str << "]," - << "\"show_performance_metrics\":" << std::boolalpha << show_performance_metrics - << "}"; + << "\"show_performance_metrics\":" << std::boolalpha << show_performance_metrics; + if (preferred_refresh_rate != 0.) + json << ",\"preferred_refresh_rate\":" << preferred_refresh_rate ; + json << "}"; } static std::string ip_address_to_string(const in_addr& addr) diff --git a/client/scenes/lobby.h b/client/scenes/lobby.h index 291d8dcb..a2461468 100644 --- a/client/scenes/lobby.h +++ b/client/scenes/lobby.h @@ -111,6 +111,7 @@ class lobby : public scene_impl tab last_current_tab = tab::server_list; ImTextureID about_picture; + float preferred_refresh_rate = 0; bool show_performance_metrics = false; void gui_connecting(); diff --git a/client/scenes/lobby_gui.cpp b/client/scenes/lobby_gui.cpp index 3866fcb1..2ed7ec6e 100644 --- a/client/scenes/lobby_gui.cpp +++ b/client/scenes/lobby_gui.cpp @@ -330,6 +330,27 @@ void scenes::lobby::gui_settings() { ImGuiStyle & style = ImGui::GetStyle(); + { + const auto & refresh_rates = session.get_refresh_rates(); + float current = session.get_current_refresh_rate(); + if (not refresh_rates.empty()) + { + if (ImGui::BeginCombo("Refresh rate", fmt::format("{}", current).c_str())) + { + for (float rate: refresh_rates) + { + if (ImGui::Selectable(fmt::format("{}", rate).c_str(), rate == current) and rate != current) + { + session.set_refresh_rate(rate); + preferred_refresh_rate = rate; + save_config(); + } + } + ImGui::EndCombo(); + } + } + } + if (ImGui::Checkbox("Show performance metrics", &show_performance_metrics)) save_config(); vibrate_on_hover();