From 47ada4d79844d9a98d9689d0de0c92864e0fc372 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 20 Jan 2025 23:11:00 +0100 Subject: Add option to save replay with controller (double-click share button), allow prime-run on wayland --- src/gui/GlobalSettingsPage.cpp | 108 +++++++++++++++++++++++++++++++---------- 1 file changed, 83 insertions(+), 25 deletions(-) (limited to 'src/gui') diff --git a/src/gui/GlobalSettingsPage.cpp b/src/gui/GlobalSettingsPage.cpp index d3d440d..8a2a162 100644 --- a/src/gui/GlobalSettingsPage.cpp +++ b/src/gui/GlobalSettingsPage.cpp @@ -9,6 +9,15 @@ #include "../../include/gui/List.hpp" #include "../../include/gui/Label.hpp" #include "../../include/gui/RadioButton.hpp" +#include "../../include/gui/LineSeparator.hpp" + +#ifndef GSR_UI_VERSION +#define GSR_UI_VERSION "unknown" +#endif + +#ifndef GSR_FLATPAK_VERSION +#define GSR_FLATPAK_VERSION "unknown" +#endif namespace gsr { static const char* gpu_vendor_to_color_name(GpuVendor vendor) { @@ -21,6 +30,16 @@ namespace gsr { return "amd"; } + static const char* gpu_vendor_to_string(GpuVendor vendor) { + switch(vendor) { + case GpuVendor::UNKNOWN: return "Unknown"; + case GpuVendor::AMD: return "AMD"; + case GpuVendor::INTEL: return "Intel"; + case GpuVendor::NVIDIA: return "NVIDIA"; + } + return "unknown"; + } + GlobalSettingsPage::GlobalSettingsPage(const GsrInfo *gsr_info, Config &config, PageStack *page_stack) : StaticPage(mgl::vec2f(get_theme().window_width, get_theme().window_height).floor()), config(config), @@ -88,29 +107,45 @@ namespace gsr { return std::make_unique("Startup", std::move(list), mgl::vec2f(parent_page->get_inner_size().x, 0.0f)); } - std::unique_ptr GlobalSettingsPage::create_hotkey_subsection(ScrollablePage *parent_page) { - const bool inside_flatpak = getenv("FLATPAK_ID") != NULL; - - auto enable_hotkeys_radio_button = std::make_unique(&get_theme().body_font, RadioButton::Orientation::VERTICAL); - enable_hotkeys_radio_button_ptr = enable_hotkeys_radio_button.get(); - enable_hotkeys_radio_button->add_item("Enable hotkeys", "enable_hotkeys"); - if(!inside_flatpak) - enable_hotkeys_radio_button->add_item("Disable hotkeys", "disable_hotkeys"); + std::unique_ptr GlobalSettingsPage::create_enable_keyboard_hotkeys_button() { + auto enable_hotkeys_radio_button = std::make_unique(&get_theme().body_font, RadioButton::Orientation::HORIZONTAL); + enable_keyboard_hotkeys_radio_button_ptr = enable_hotkeys_radio_button.get(); + enable_hotkeys_radio_button->add_item("Yes", "enable_hotkeys"); + enable_hotkeys_radio_button->add_item("No", "disable_hotkeys"); enable_hotkeys_radio_button->add_item("Only grab virtual devices (supports input remapping software)", "enable_hotkeys_virtual_devices"); enable_hotkeys_radio_button->on_selection_changed = [&](const std::string&, const std::string &id) { - if(!on_click_exit_program_button) - return true; - - if(id == "enable_hotkeys") - on_click_exit_program_button("restart"); - else if(id == "disable_hotkeys") - on_click_exit_program_button("restart"); - else if(id == "enable_hotkeys_virtual_devices") - on_click_exit_program_button("restart"); + if(on_keyboard_hotkey_changed) + on_keyboard_hotkey_changed(id.c_str()); + return true; + }; + return enable_hotkeys_radio_button; + } + std::unique_ptr GlobalSettingsPage::create_enable_joystick_hotkeys_button() { + auto enable_hotkeys_radio_button = std::make_unique(&get_theme().body_font, RadioButton::Orientation::HORIZONTAL); + enable_joystick_hotkeys_radio_button_ptr = enable_hotkeys_radio_button.get(); + enable_hotkeys_radio_button->add_item("Yes", "enable_hotkeys"); + enable_hotkeys_radio_button->add_item("No", "disable_hotkeys"); + enable_hotkeys_radio_button->on_selection_changed = [&](const std::string&, const std::string &id) { + if(on_joystick_hotkey_changed) + on_joystick_hotkey_changed(id.c_str()); return true; }; - return std::make_unique("Hotkeys", std::move(enable_hotkeys_radio_button), mgl::vec2f(parent_page->get_inner_size().x, 0.0f)); + return enable_hotkeys_radio_button; + } + + std::unique_ptr GlobalSettingsPage::create_hotkey_subsection(ScrollablePage *parent_page) { + auto list = std::make_unique(List::Orientation::VERTICAL); + List *list_ptr = list.get(); + auto subsection = std::make_unique("Hotkeys", std::move(list), mgl::vec2f(parent_page->get_inner_size().x, 0.0f)); + + list_ptr->add_widget(std::make_unique