diff options
| -rw-r--r-- | src/common/settings.cpp | 10 | ||||
| -rw-r--r-- | src/common/settings.h | 1 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.cpp | 16 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 3 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_dialog.cpp | 8 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_dialog.h | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics.cpp | 44 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics.h | 17 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_per_game.cpp | 3 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_ui.cpp | 98 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_ui.h | 8 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_ui.ui | 37 | ||||
| -rw-r--r-- | src/yuzu/uisettings.cpp | 16 | ||||
| -rw-r--r-- | src/yuzu/uisettings.h | 5 |
14 files changed, 241 insertions, 27 deletions
diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 15fd2e222..16a58a750 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp | |||
| @@ -207,9 +207,7 @@ const char* TranslateCategory(Category category) { | |||
| 207 | return "Miscellaneous"; | 207 | return "Miscellaneous"; |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | void UpdateRescalingInfo() { | 210 | void TranslateResolutionInfo(ResolutionSetup setup, ResolutionScalingInfo& info) { |
| 211 | const auto setup = values.resolution_setup.GetValue(); | ||
| 212 | auto& info = values.resolution_info; | ||
| 213 | info.downscale = false; | 211 | info.downscale = false; |
| 214 | switch (setup) { | 212 | switch (setup) { |
| 215 | case ResolutionSetup::Res1_2X: | 213 | case ResolutionSetup::Res1_2X: |
| @@ -269,6 +267,12 @@ void UpdateRescalingInfo() { | |||
| 269 | info.active = info.up_scale != 1 || info.down_shift != 0; | 267 | info.active = info.up_scale != 1 || info.down_shift != 0; |
| 270 | } | 268 | } |
| 271 | 269 | ||
| 270 | void UpdateRescalingInfo() { | ||
| 271 | const auto setup = values.resolution_setup.GetValue(); | ||
| 272 | auto& info = values.resolution_info; | ||
| 273 | TranslateResolutionInfo(setup, info); | ||
| 274 | } | ||
| 275 | |||
| 272 | void RestoreGlobalState(bool is_powered_on) { | 276 | void RestoreGlobalState(bool is_powered_on) { |
| 273 | // If a game is running, DO NOT restore the global settings state | 277 | // If a game is running, DO NOT restore the global settings state |
| 274 | if (is_powered_on) { | 278 | if (is_powered_on) { |
diff --git a/src/common/settings.h b/src/common/settings.h index b0bc6519a..4407c1e6d 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -525,6 +525,7 @@ std::string GetTimeZoneString(TimeZone time_zone); | |||
| 525 | 525 | ||
| 526 | void LogSettings(); | 526 | void LogSettings(); |
| 527 | 527 | ||
| 528 | void TranslateResolutionInfo(ResolutionSetup setup, ResolutionScalingInfo& info); | ||
| 528 | void UpdateRescalingInfo(); | 529 | void UpdateRescalingInfo(); |
| 529 | 530 | ||
| 530 | // Restore the global state of all applicable settings in the Values struct | 531 | // Restore the global state of all applicable settings in the Values struct |
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index bdd1497b5..407988b8f 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -11,6 +11,8 @@ | |||
| 11 | #include <glad/glad.h> | 11 | #include <glad/glad.h> |
| 12 | 12 | ||
| 13 | #include <QtCore/qglobal.h> | 13 | #include <QtCore/qglobal.h> |
| 14 | #include "common/settings_enums.h" | ||
| 15 | #include "uisettings.h" | ||
| 14 | #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA | 16 | #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA |
| 15 | #include <QCamera> | 17 | #include <QCamera> |
| 16 | #include <QCameraImageCapture> | 18 | #include <QCameraImageCapture> |
| @@ -916,7 +918,6 @@ void GRenderWindow::ReleaseRenderTarget() { | |||
| 916 | 918 | ||
| 917 | void GRenderWindow::CaptureScreenshot(const QString& screenshot_path) { | 919 | void GRenderWindow::CaptureScreenshot(const QString& screenshot_path) { |
| 918 | auto& renderer = system.Renderer(); | 920 | auto& renderer = system.Renderer(); |
| 919 | const f32 res_scale = Settings::values.resolution_info.up_factor; | ||
| 920 | 921 | ||
| 921 | if (renderer.IsScreenshotPending()) { | 922 | if (renderer.IsScreenshotPending()) { |
| 922 | LOG_WARNING(Render, | 923 | LOG_WARNING(Render, |
| @@ -924,7 +925,18 @@ void GRenderWindow::CaptureScreenshot(const QString& screenshot_path) { | |||
| 924 | return; | 925 | return; |
| 925 | } | 926 | } |
| 926 | 927 | ||
| 927 | const Layout::FramebufferLayout layout{Layout::FrameLayoutFromResolutionScale(res_scale)}; | 928 | const Layout::FramebufferLayout layout{[]() { |
| 929 | u32 height = UISettings::values.screenshot_height.GetValue(); | ||
| 930 | if (height == 0) { | ||
| 931 | height = Settings::values.use_docked_mode.GetValue() ? Layout::ScreenDocked::Height | ||
| 932 | : Layout::ScreenUndocked::Height; | ||
| 933 | height *= Settings::values.resolution_info.up_factor; | ||
| 934 | } | ||
| 935 | const u32 width = | ||
| 936 | UISettings::CalculateWidth(height, Settings::values.aspect_ratio.GetValue()); | ||
| 937 | return Layout::DefaultFrameLayout(width, height); | ||
| 938 | }()}; | ||
| 939 | |||
| 928 | screenshot_image = QImage(QSize(layout.width, layout.height), QImage::Format_RGB32); | 940 | screenshot_image = QImage(QSize(layout.width, layout.height), QImage::Format_RGB32); |
| 929 | renderer.RequestScreenshot( | 941 | renderer.RequestScreenshot( |
| 930 | screenshot_image.bits(), | 942 | screenshot_image.bits(), |
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index b2405f9b8..b22c83303 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -592,8 +592,7 @@ void Config::ReadRendererValues() { | |||
| 592 | void Config::ReadScreenshotValues() { | 592 | void Config::ReadScreenshotValues() { |
| 593 | qt_config->beginGroup(QStringLiteral("Screenshots")); | 593 | qt_config->beginGroup(QStringLiteral("Screenshots")); |
| 594 | 594 | ||
| 595 | UISettings::values.enable_screenshot_save_as = | 595 | ReadCategory(Settings::Category::Screenshots); |
| 596 | ReadSetting(QStringLiteral("enable_screenshot_save_as"), true).toBool(); | ||
| 597 | FS::SetYuzuPath( | 596 | FS::SetYuzuPath( |
| 598 | FS::YuzuPath::ScreenshotsDir, | 597 | FS::YuzuPath::ScreenshotsDir, |
| 599 | qt_config | 598 | qt_config |
diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index 3c6bb3eb1..0ad95cc02 100644 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #include <memory> | 4 | #include <memory> |
| 5 | #include "common/logging/log.h" | 5 | #include "common/logging/log.h" |
| 6 | #include "common/settings.h" | 6 | #include "common/settings.h" |
| 7 | #include "common/settings_enums.h" | ||
| 7 | #include "core/core.h" | 8 | #include "core/core.h" |
| 8 | #include "ui_configure.h" | 9 | #include "ui_configure.h" |
| 9 | #include "vk_device_info.h" | 10 | #include "vk_device_info.h" |
| @@ -41,16 +42,19 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, | |||
| 41 | general_tab{std::make_unique<ConfigureGeneral>(system_, nullptr, *builder, this)}, | 42 | general_tab{std::make_unique<ConfigureGeneral>(system_, nullptr, *builder, this)}, |
| 42 | graphics_advanced_tab{ | 43 | graphics_advanced_tab{ |
| 43 | std::make_unique<ConfigureGraphicsAdvanced>(system_, nullptr, *builder, this)}, | 44 | std::make_unique<ConfigureGraphicsAdvanced>(system_, nullptr, *builder, this)}, |
| 45 | ui_tab{std::make_unique<ConfigureUi>(system_, this)}, | ||
| 44 | graphics_tab{std::make_unique<ConfigureGraphics>( | 46 | graphics_tab{std::make_unique<ConfigureGraphics>( |
| 45 | system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, | 47 | system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, |
| 48 | [this](Settings::AspectRatio ratio, Settings::ResolutionSetup setup) { | ||
| 49 | ui_tab->UpdateScreenshotInfo(ratio, setup); | ||
| 50 | }, | ||
| 46 | nullptr, *builder, this)}, | 51 | nullptr, *builder, this)}, |
| 47 | hotkeys_tab{std::make_unique<ConfigureHotkeys>(system_.HIDCore(), this)}, | 52 | hotkeys_tab{std::make_unique<ConfigureHotkeys>(system_.HIDCore(), this)}, |
| 48 | input_tab{std::make_unique<ConfigureInput>(system_, this)}, | 53 | input_tab{std::make_unique<ConfigureInput>(system_, this)}, |
| 49 | network_tab{std::make_unique<ConfigureNetwork>(system_, this)}, | 54 | network_tab{std::make_unique<ConfigureNetwork>(system_, this)}, |
| 50 | profile_tab{std::make_unique<ConfigureProfileManager>(system_, this)}, | 55 | profile_tab{std::make_unique<ConfigureProfileManager>(system_, this)}, |
| 51 | system_tab{std::make_unique<ConfigureSystem>(system_, nullptr, *builder, this)}, | 56 | system_tab{std::make_unique<ConfigureSystem>(system_, nullptr, *builder, this)}, |
| 52 | ui_tab{std::make_unique<ConfigureUi>(system_, this)}, web_tab{std::make_unique<ConfigureWeb>( | 57 | web_tab{std::make_unique<ConfigureWeb>(this)} { |
| 53 | this)} { | ||
| 54 | Settings::SetConfiguringGlobal(true); | 58 | Settings::SetConfiguringGlobal(true); |
| 55 | 59 | ||
| 56 | ui->setupUi(this); | 60 | ui->setupUi(this); |
diff --git a/src/yuzu/configuration/configure_dialog.h b/src/yuzu/configuration/configure_dialog.h index 96e9a8c3e..b28ce288c 100644 --- a/src/yuzu/configuration/configure_dialog.h +++ b/src/yuzu/configuration/configure_dialog.h | |||
| @@ -81,12 +81,12 @@ private: | |||
| 81 | std::unique_ptr<ConfigureFilesystem> filesystem_tab; | 81 | std::unique_ptr<ConfigureFilesystem> filesystem_tab; |
| 82 | std::unique_ptr<ConfigureGeneral> general_tab; | 82 | std::unique_ptr<ConfigureGeneral> general_tab; |
| 83 | std::unique_ptr<ConfigureGraphicsAdvanced> graphics_advanced_tab; | 83 | std::unique_ptr<ConfigureGraphicsAdvanced> graphics_advanced_tab; |
| 84 | std::unique_ptr<ConfigureUi> ui_tab; | ||
| 84 | std::unique_ptr<ConfigureGraphics> graphics_tab; | 85 | std::unique_ptr<ConfigureGraphics> graphics_tab; |
| 85 | std::unique_ptr<ConfigureHotkeys> hotkeys_tab; | 86 | std::unique_ptr<ConfigureHotkeys> hotkeys_tab; |
| 86 | std::unique_ptr<ConfigureInput> input_tab; | 87 | std::unique_ptr<ConfigureInput> input_tab; |
| 87 | std::unique_ptr<ConfigureNetwork> network_tab; | 88 | std::unique_ptr<ConfigureNetwork> network_tab; |
| 88 | std::unique_ptr<ConfigureProfileManager> profile_tab; | 89 | std::unique_ptr<ConfigureProfileManager> profile_tab; |
| 89 | std::unique_ptr<ConfigureSystem> system_tab; | 90 | std::unique_ptr<ConfigureSystem> system_tab; |
| 90 | std::unique_ptr<ConfigureUi> ui_tab; | ||
| 91 | std::unique_ptr<ConfigureWeb> web_tab; | 91 | std::unique_ptr<ConfigureWeb> web_tab; |
| 92 | }; | 92 | }; |
diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index a94fbc89a..8622dc184 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <QtCore/qobjectdefs.h> | 24 | #include <QtCore/qobjectdefs.h> |
| 25 | #include <qabstractbutton.h> | 25 | #include <qabstractbutton.h> |
| 26 | #include <qboxlayout.h> | 26 | #include <qboxlayout.h> |
| 27 | #include <qcombobox.h> | ||
| 27 | #include <qcoreevent.h> | 28 | #include <qcoreevent.h> |
| 28 | #include <qglobal.h> | 29 | #include <qglobal.h> |
| 29 | #include <qgridlayout.h> | 30 | #include <qgridlayout.h> |
| @@ -77,13 +78,16 @@ static constexpr Settings::VSyncMode PresentModeToSetting(VkPresentModeKHR mode) | |||
| 77 | } | 78 | } |
| 78 | } | 79 | } |
| 79 | 80 | ||
| 80 | ConfigureGraphics::ConfigureGraphics(const Core::System& system_, | 81 | ConfigureGraphics::ConfigureGraphics( |
| 81 | std::vector<VkDeviceInfo::Record>& records_, | 82 | const Core::System& system_, std::vector<VkDeviceInfo::Record>& records_, |
| 82 | const std::function<void()>& expose_compute_option_, | 83 | const std::function<void()>& expose_compute_option_, |
| 83 | std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_, | 84 | const std::function<void(Settings::AspectRatio, Settings::ResolutionSetup)>& |
| 84 | const ConfigurationShared::Builder& builder, QWidget* parent) | 85 | update_aspect_ratio_, |
| 86 | std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_, | ||
| 87 | const ConfigurationShared::Builder& builder, QWidget* parent) | ||
| 85 | : ConfigurationShared::Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphics>()}, | 88 | : ConfigurationShared::Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphics>()}, |
| 86 | records{records_}, expose_compute_option{expose_compute_option_}, system{system_}, | 89 | records{records_}, expose_compute_option{expose_compute_option_}, |
| 90 | update_aspect_ratio{update_aspect_ratio_}, system{system_}, | ||
| 87 | combobox_translations{builder.ComboboxTranslations()}, | 91 | combobox_translations{builder.ComboboxTranslations()}, |
| 88 | shader_mapping{ | 92 | shader_mapping{ |
| 89 | combobox_translations.at(Settings::EnumMetadata<Settings::ShaderBackend>::Index())} { | 93 | combobox_translations.at(Settings::EnumMetadata<Settings::ShaderBackend>::Index())} { |
| @@ -140,6 +144,26 @@ ConfigureGraphics::ConfigureGraphics(const Core::System& system_, | |||
| 140 | UpdateBackgroundColorButton(new_bg_color); | 144 | UpdateBackgroundColorButton(new_bg_color); |
| 141 | }); | 145 | }); |
| 142 | 146 | ||
| 147 | const auto& update_screenshot_info = [this, &builder]() { | ||
| 148 | const auto& combobox_enumerations = builder.ComboboxTranslations().at( | ||
| 149 | Settings::EnumMetadata<Settings::AspectRatio>::Index()); | ||
| 150 | const auto index = aspect_ratio_combobox->currentIndex(); | ||
| 151 | const auto ratio = static_cast<Settings::AspectRatio>(combobox_enumerations[index].first); | ||
| 152 | |||
| 153 | const auto& combobox_enumerations_resolution = builder.ComboboxTranslations().at( | ||
| 154 | Settings::EnumMetadata<Settings::ResolutionSetup>::Index()); | ||
| 155 | const auto res_index = resolution_combobox->currentIndex(); | ||
| 156 | const auto setup = static_cast<Settings::ResolutionSetup>( | ||
| 157 | combobox_enumerations_resolution[res_index].first); | ||
| 158 | |||
| 159 | update_aspect_ratio(ratio, setup); | ||
| 160 | }; | ||
| 161 | |||
| 162 | connect(aspect_ratio_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), | ||
| 163 | update_screenshot_info); | ||
| 164 | connect(resolution_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), | ||
| 165 | update_screenshot_info); | ||
| 166 | |||
| 143 | api_combobox->setEnabled(!UISettings::values.has_broken_vulkan && api_combobox->isEnabled()); | 167 | api_combobox->setEnabled(!UISettings::values.has_broken_vulkan && api_combobox->isEnabled()); |
| 144 | ui->api_widget->setEnabled( | 168 | ui->api_widget->setEnabled( |
| 145 | (!UISettings::values.has_broken_vulkan || Settings::IsConfiguringGlobal()) && | 169 | (!UISettings::values.has_broken_vulkan || Settings::IsConfiguringGlobal()) && |
| @@ -280,6 +304,14 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) { | |||
| 280 | // Keep track of vsync_mode's combobox so we can populate it | 304 | // Keep track of vsync_mode's combobox so we can populate it |
| 281 | vsync_mode_combobox = widget->combobox; | 305 | vsync_mode_combobox = widget->combobox; |
| 282 | hold_graphics.emplace(setting->Id(), widget); | 306 | hold_graphics.emplace(setting->Id(), widget); |
| 307 | } else if (setting->Id() == Settings::values.aspect_ratio.Id()) { | ||
| 308 | // Keep track of the aspect ratio combobox to update other UI tabs that need it | ||
| 309 | aspect_ratio_combobox = widget->combobox; | ||
| 310 | hold_graphics.emplace(setting->Id(), widget); | ||
| 311 | } else if (setting->Id() == Settings::values.resolution_setup.Id()) { | ||
| 312 | // Keep track of the resolution combobox to update other UI tabs that need it | ||
| 313 | resolution_combobox = widget->combobox; | ||
| 314 | hold_graphics.emplace(setting->Id(), widget); | ||
| 283 | } else { | 315 | } else { |
| 284 | hold_graphics.emplace(setting->Id(), widget); | 316 | hold_graphics.emplace(setting->Id(), widget); |
| 285 | } | 317 | } |
diff --git a/src/yuzu/configuration/configure_graphics.h b/src/yuzu/configuration/configure_graphics.h index 02d9b00f1..9c24a56db 100644 --- a/src/yuzu/configuration/configure_graphics.h +++ b/src/yuzu/configuration/configure_graphics.h | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include <qobjectdefs.h> | 14 | #include <qobjectdefs.h> |
| 15 | #include <vulkan/vulkan_core.h> | 15 | #include <vulkan/vulkan_core.h> |
| 16 | #include "common/common_types.h" | 16 | #include "common/common_types.h" |
| 17 | #include "common/settings_enums.h" | ||
| 17 | #include "configuration/shared_translation.h" | 18 | #include "configuration/shared_translation.h" |
| 18 | #include "vk_device_info.h" | 19 | #include "vk_device_info.h" |
| 19 | #include "yuzu/configuration/configuration_shared.h" | 20 | #include "yuzu/configuration/configuration_shared.h" |
| @@ -43,12 +44,13 @@ class Builder; | |||
| 43 | 44 | ||
| 44 | class ConfigureGraphics : public ConfigurationShared::Tab { | 45 | class ConfigureGraphics : public ConfigurationShared::Tab { |
| 45 | public: | 46 | public: |
| 46 | explicit ConfigureGraphics(const Core::System& system_, | 47 | explicit ConfigureGraphics( |
| 47 | std::vector<VkDeviceInfo::Record>& records, | 48 | const Core::System& system_, std::vector<VkDeviceInfo::Record>& records, |
| 48 | const std::function<void()>& expose_compute_option_, | 49 | const std::function<void()>& expose_compute_option, |
| 49 | std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group, | 50 | const std::function<void(Settings::AspectRatio, Settings::ResolutionSetup)>& |
| 50 | const ConfigurationShared::Builder& builder, | 51 | update_aspect_ratio, |
| 51 | QWidget* parent = nullptr); | 52 | std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group, |
| 53 | const ConfigurationShared::Builder& builder, QWidget* parent = nullptr); | ||
| 52 | ~ConfigureGraphics() override; | 54 | ~ConfigureGraphics() override; |
| 53 | 55 | ||
| 54 | void ApplyConfiguration() override; | 56 | void ApplyConfiguration() override; |
| @@ -91,6 +93,7 @@ private: | |||
| 91 | u32 vulkan_device{}; | 93 | u32 vulkan_device{}; |
| 92 | Settings::ShaderBackend shader_backend{}; | 94 | Settings::ShaderBackend shader_backend{}; |
| 93 | const std::function<void()>& expose_compute_option; | 95 | const std::function<void()>& expose_compute_option; |
| 96 | const std::function<void(Settings::AspectRatio, Settings::ResolutionSetup)> update_aspect_ratio; | ||
| 94 | 97 | ||
| 95 | const Core::System& system; | 98 | const Core::System& system; |
| 96 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations; | 99 | const ConfigurationShared::ComboboxTranslationMap& combobox_translations; |
| @@ -104,4 +107,6 @@ private: | |||
| 104 | QWidget* vulkan_device_widget; | 107 | QWidget* vulkan_device_widget; |
| 105 | QWidget* api_widget; | 108 | QWidget* api_widget; |
| 106 | QWidget* shader_backend_widget; | 109 | QWidget* shader_backend_widget; |
| 110 | QComboBox* aspect_ratio_combobox; | ||
| 111 | QComboBox* resolution_combobox; | ||
| 107 | }; | 112 | }; |
diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index cd8b3012e..4f9e8db08 100644 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <QTimer> | 17 | #include <QTimer> |
| 18 | 18 | ||
| 19 | #include "common/fs/fs_util.h" | 19 | #include "common/fs/fs_util.h" |
| 20 | #include "common/settings_enums.h" | ||
| 20 | #include "configuration/shared_widget.h" | 21 | #include "configuration/shared_widget.h" |
| 21 | #include "core/core.h" | 22 | #include "core/core.h" |
| 22 | #include "core/file_sys/control_metadata.h" | 23 | #include "core/file_sys/control_metadata.h" |
| @@ -57,7 +58,7 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st | |||
| 57 | std::make_unique<ConfigureGraphicsAdvanced>(system_, tab_group, *builder, this); | 58 | std::make_unique<ConfigureGraphicsAdvanced>(system_, tab_group, *builder, this); |
| 58 | graphics_tab = std::make_unique<ConfigureGraphics>( | 59 | graphics_tab = std::make_unique<ConfigureGraphics>( |
| 59 | system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, | 60 | system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, |
| 60 | tab_group, *builder, this); | 61 | [](Settings::AspectRatio, Settings::ResolutionSetup) {}, tab_group, *builder, this); |
| 61 | input_tab = std::make_unique<ConfigureInputPerGame>(system_, game_config.get(), this); | 62 | input_tab = std::make_unique<ConfigureInputPerGame>(system_, game_config.get(), this); |
| 62 | system_tab = std::make_unique<ConfigureSystem>(system_, tab_group, *builder, this); | 63 | system_tab = std::make_unique<ConfigureSystem>(system_, tab_group, *builder, this); |
| 63 | 64 | ||
diff --git a/src/yuzu/configuration/configure_ui.cpp b/src/yuzu/configuration/configure_ui.cpp index 2ebb80302..34ab01617 100644 --- a/src/yuzu/configuration/configure_ui.cpp +++ b/src/yuzu/configuration/configure_ui.cpp | |||
| @@ -1,18 +1,31 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2016 Citra Emulator Project | 1 | // SPDX-FileCopyrightText: 2016 Citra Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "yuzu/configuration/configure_ui.h" | ||
| 5 | |||
| 4 | #include <array> | 6 | #include <array> |
| 7 | #include <set> | ||
| 8 | #include <stdexcept> | ||
| 9 | #include <string> | ||
| 5 | #include <utility> | 10 | #include <utility> |
| 6 | #include <QFileDialog> | ||
| 7 | 11 | ||
| 12 | #include <QCheckBox> | ||
| 13 | #include <QComboBox> | ||
| 14 | #include <QCoreApplication> | ||
| 8 | #include <QDirIterator> | 15 | #include <QDirIterator> |
| 16 | #include <QFileDialog> | ||
| 17 | #include <QString> | ||
| 18 | #include <QToolButton> | ||
| 19 | #include <QVariant> | ||
| 20 | |||
| 9 | #include "common/common_types.h" | 21 | #include "common/common_types.h" |
| 10 | #include "common/fs/path_util.h" | 22 | #include "common/fs/path_util.h" |
| 11 | #include "common/logging/log.h" | 23 | #include "common/logging/log.h" |
| 12 | #include "common/settings.h" | 24 | #include "common/settings.h" |
| 25 | #include "common/settings_enums.h" | ||
| 13 | #include "core/core.h" | 26 | #include "core/core.h" |
| 27 | #include "core/frontend/framebuffer_layout.h" | ||
| 14 | #include "ui_configure_ui.h" | 28 | #include "ui_configure_ui.h" |
| 15 | #include "yuzu/configuration/configure_ui.h" | ||
| 16 | #include "yuzu/uisettings.h" | 29 | #include "yuzu/uisettings.h" |
| 17 | 30 | ||
| 18 | namespace { | 31 | namespace { |
| @@ -54,8 +67,44 @@ QString GetTranslatedRowTextName(size_t index) { | |||
| 54 | } | 67 | } |
| 55 | } // Anonymous namespace | 68 | } // Anonymous namespace |
| 56 | 69 | ||
| 70 | static float GetUpFactor(Settings::ResolutionSetup res_setup) { | ||
| 71 | Settings::ResolutionScalingInfo info{}; | ||
| 72 | Settings::TranslateResolutionInfo(res_setup, info); | ||
| 73 | return info.up_factor; | ||
| 74 | } | ||
| 75 | |||
| 76 | static void PopulateResolutionComboBox(QComboBox* screenshot_height, QWidget* parent) { | ||
| 77 | screenshot_height->clear(); | ||
| 78 | |||
| 79 | const auto& enumeration = | ||
| 80 | Settings::EnumMetadata<Settings::ResolutionSetup>::Canonicalizations(); | ||
| 81 | std::set<u32> resolutions{}; | ||
| 82 | for (const auto& [name, value] : enumeration) { | ||
| 83 | const float up_factor = GetUpFactor(value); | ||
| 84 | u32 height_undocked = Layout::ScreenUndocked::Height * up_factor; | ||
| 85 | u32 height_docked = Layout::ScreenDocked::Height * up_factor; | ||
| 86 | resolutions.emplace(height_undocked); | ||
| 87 | resolutions.emplace(height_docked); | ||
| 88 | } | ||
| 89 | |||
| 90 | screenshot_height->addItem(parent->tr("Auto", "Screenshot height option")); | ||
| 91 | for (const auto res : resolutions) { | ||
| 92 | screenshot_height->addItem(QString::fromStdString(std::to_string(res))); | ||
| 93 | } | ||
| 94 | } | ||
| 95 | |||
| 96 | static u32 ScreenshotDimensionToInt(const QString& height) { | ||
| 97 | try { | ||
| 98 | return std::stoi(height.toStdString()); | ||
| 99 | } catch (std::invalid_argument&) { | ||
| 100 | return 0; | ||
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 57 | ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent) | 104 | ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent) |
| 58 | : QWidget(parent), ui{std::make_unique<Ui::ConfigureUi>()}, system{system_} { | 105 | : QWidget(parent), ui{std::make_unique<Ui::ConfigureUi>()}, |
| 106 | ratio{Settings::values.aspect_ratio.GetValue()}, | ||
| 107 | resolution_setting{Settings::values.resolution_setup.GetValue()}, system{system_} { | ||
| 59 | ui->setupUi(this); | 108 | ui->setupUi(this); |
| 60 | 109 | ||
| 61 | InitializeLanguageComboBox(); | 110 | InitializeLanguageComboBox(); |
| @@ -68,6 +117,8 @@ ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent) | |||
| 68 | InitializeIconSizeComboBox(); | 117 | InitializeIconSizeComboBox(); |
| 69 | InitializeRowComboBoxes(); | 118 | InitializeRowComboBoxes(); |
| 70 | 119 | ||
| 120 | PopulateResolutionComboBox(ui->screenshot_height, this); | ||
| 121 | |||
| 71 | SetConfiguration(); | 122 | SetConfiguration(); |
| 72 | 123 | ||
| 73 | // Force game list reload if any of the relevant settings are changed. | 124 | // Force game list reload if any of the relevant settings are changed. |
| @@ -104,6 +155,10 @@ ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent) | |||
| 104 | ui->screenshot_path_edit->setText(dir); | 155 | ui->screenshot_path_edit->setText(dir); |
| 105 | } | 156 | } |
| 106 | }); | 157 | }); |
| 158 | |||
| 159 | connect(ui->screenshot_height, &QComboBox::currentTextChanged, [this]() { UpdateWidthText(); }); | ||
| 160 | |||
| 161 | UpdateWidthText(); | ||
| 107 | } | 162 | } |
| 108 | 163 | ||
| 109 | ConfigureUi::~ConfigureUi() = default; | 164 | ConfigureUi::~ConfigureUi() = default; |
| @@ -123,6 +178,10 @@ void ConfigureUi::ApplyConfiguration() { | |||
| 123 | UISettings::values.enable_screenshot_save_as = ui->enable_screenshot_save_as->isChecked(); | 178 | UISettings::values.enable_screenshot_save_as = ui->enable_screenshot_save_as->isChecked(); |
| 124 | Common::FS::SetYuzuPath(Common::FS::YuzuPath::ScreenshotsDir, | 179 | Common::FS::SetYuzuPath(Common::FS::YuzuPath::ScreenshotsDir, |
| 125 | ui->screenshot_path_edit->text().toStdString()); | 180 | ui->screenshot_path_edit->text().toStdString()); |
| 181 | |||
| 182 | const u32 height = ScreenshotDimensionToInt(ui->screenshot_height->currentText()); | ||
| 183 | UISettings::values.screenshot_height.SetValue(height); | ||
| 184 | |||
| 126 | system.ApplySettings(); | 185 | system.ApplySettings(); |
| 127 | } | 186 | } |
| 128 | 187 | ||
| @@ -147,6 +206,13 @@ void ConfigureUi::SetConfiguration() { | |||
| 147 | UISettings::values.enable_screenshot_save_as.GetValue()); | 206 | UISettings::values.enable_screenshot_save_as.GetValue()); |
| 148 | ui->screenshot_path_edit->setText(QString::fromStdString( | 207 | ui->screenshot_path_edit->setText(QString::fromStdString( |
| 149 | Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir))); | 208 | Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir))); |
| 209 | |||
| 210 | const auto height = UISettings::values.screenshot_height.GetValue(); | ||
| 211 | if (height == 0) { | ||
| 212 | ui->screenshot_height->setCurrentIndex(0); | ||
| 213 | } else { | ||
| 214 | ui->screenshot_height->setCurrentText(QStringLiteral("%1").arg(height)); | ||
| 215 | } | ||
| 150 | } | 216 | } |
| 151 | 217 | ||
| 152 | void ConfigureUi::changeEvent(QEvent* event) { | 218 | void ConfigureUi::changeEvent(QEvent* event) { |
| @@ -317,3 +383,29 @@ void ConfigureUi::OnLanguageChanged(int index) { | |||
| 317 | 383 | ||
| 318 | emit LanguageChanged(ui->language_combobox->itemData(index).toString()); | 384 | emit LanguageChanged(ui->language_combobox->itemData(index).toString()); |
| 319 | } | 385 | } |
| 386 | |||
| 387 | void ConfigureUi::UpdateWidthText() { | ||
| 388 | const u32 height = ScreenshotDimensionToInt(ui->screenshot_height->currentText()); | ||
| 389 | const u32 width = UISettings::CalculateWidth(height, ratio); | ||
| 390 | if (height == 0) { | ||
| 391 | const auto up_factor = GetUpFactor(resolution_setting); | ||
| 392 | const u32 height_docked = Layout::ScreenDocked::Height * up_factor; | ||
| 393 | const u32 width_docked = UISettings::CalculateWidth(height_docked, ratio); | ||
| 394 | const u32 height_undocked = Layout::ScreenUndocked::Height * up_factor; | ||
| 395 | const u32 width_undocked = UISettings::CalculateWidth(height_undocked, ratio); | ||
| 396 | ui->screenshot_width->setText(tr("Auto (%1 x %2, %3 x %4)", "Screenshot width value") | ||
| 397 | .arg(width_undocked) | ||
| 398 | .arg(height_undocked) | ||
| 399 | .arg(width_docked) | ||
| 400 | .arg(height_docked)); | ||
| 401 | } else { | ||
| 402 | ui->screenshot_width->setText(QStringLiteral("%1 x").arg(width)); | ||
| 403 | } | ||
| 404 | } | ||
| 405 | |||
| 406 | void ConfigureUi::UpdateScreenshotInfo(Settings::AspectRatio ratio_, | ||
| 407 | Settings::ResolutionSetup resolution_setting_) { | ||
| 408 | ratio = ratio_; | ||
| 409 | resolution_setting = resolution_setting_; | ||
| 410 | UpdateWidthText(); | ||
| 411 | } | ||
diff --git a/src/yuzu/configuration/configure_ui.h b/src/yuzu/configuration/configure_ui.h index 95af8370e..2a2563a13 100644 --- a/src/yuzu/configuration/configure_ui.h +++ b/src/yuzu/configuration/configure_ui.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include <QWidget> | 7 | #include <QWidget> |
| 8 | #include "common/settings_enums.h" | ||
| 8 | 9 | ||
| 9 | namespace Core { | 10 | namespace Core { |
| 10 | class System; | 11 | class System; |
| @@ -23,6 +24,9 @@ public: | |||
| 23 | 24 | ||
| 24 | void ApplyConfiguration(); | 25 | void ApplyConfiguration(); |
| 25 | 26 | ||
| 27 | void UpdateScreenshotInfo(Settings::AspectRatio ratio, | ||
| 28 | Settings::ResolutionSetup resolution_info); | ||
| 29 | |||
| 26 | private slots: | 30 | private slots: |
| 27 | void OnLanguageChanged(int index); | 31 | void OnLanguageChanged(int index); |
| 28 | 32 | ||
| @@ -44,7 +48,11 @@ private: | |||
| 44 | void UpdateFirstRowComboBox(bool init = false); | 48 | void UpdateFirstRowComboBox(bool init = false); |
| 45 | void UpdateSecondRowComboBox(bool init = false); | 49 | void UpdateSecondRowComboBox(bool init = false); |
| 46 | 50 | ||
| 51 | void UpdateWidthText(); | ||
| 52 | |||
| 47 | std::unique_ptr<Ui::ConfigureUi> ui; | 53 | std::unique_ptr<Ui::ConfigureUi> ui; |
| 48 | 54 | ||
| 55 | Settings::AspectRatio ratio; | ||
| 56 | Settings::ResolutionSetup resolution_setting; | ||
| 49 | Core::System& system; | 57 | Core::System& system; |
| 50 | }; | 58 | }; |
diff --git a/src/yuzu/configuration/configure_ui.ui b/src/yuzu/configuration/configure_ui.ui index 10bb27312..cb66ef104 100644 --- a/src/yuzu/configuration/configure_ui.ui +++ b/src/yuzu/configuration/configure_ui.ui | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | <x>0</x> | 7 | <x>0</x> |
| 8 | <y>0</y> | 8 | <y>0</y> |
| 9 | <width>363</width> | 9 | <width>363</width> |
| 10 | <height>562</height> | 10 | <height>603</height> |
| 11 | </rect> | 11 | </rect> |
| 12 | </property> | 12 | </property> |
| 13 | <property name="windowTitle"> | 13 | <property name="windowTitle"> |
| @@ -201,6 +201,41 @@ | |||
| 201 | </item> | 201 | </item> |
| 202 | </layout> | 202 | </layout> |
| 203 | </item> | 203 | </item> |
| 204 | <item> | ||
| 205 | <layout class="QGridLayout" name="gridLayout"> | ||
| 206 | <property name="spacing"> | ||
| 207 | <number>6</number> | ||
| 208 | </property> | ||
| 209 | <item row="0" column="1"> | ||
| 210 | <layout class="QHBoxLayout" name="horizontalLayout_5"> | ||
| 211 | <item> | ||
| 212 | <widget class="QLabel" name="screenshot_width"> | ||
| 213 | <property name="text"> | ||
| 214 | <string>TextLabel</string> | ||
| 215 | </property> | ||
| 216 | <property name="alignment"> | ||
| 217 | <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> | ||
| 218 | </property> | ||
| 219 | </widget> | ||
| 220 | </item> | ||
| 221 | <item> | ||
| 222 | <widget class="QComboBox" name="screenshot_height"> | ||
| 223 | <property name="editable"> | ||
| 224 | <bool>true</bool> | ||
| 225 | </property> | ||
| 226 | </widget> | ||
| 227 | </item> | ||
| 228 | </layout> | ||
| 229 | </item> | ||
| 230 | <item row="0" column="0"> | ||
| 231 | <widget class="QLabel" name="label_3"> | ||
| 232 | <property name="text"> | ||
| 233 | <string>Resolution:</string> | ||
| 234 | </property> | ||
| 235 | </widget> | ||
| 236 | </item> | ||
| 237 | </layout> | ||
| 238 | </item> | ||
| 204 | </layout> | 239 | </layout> |
| 205 | </item> | 240 | </item> |
| 206 | </layout> | 241 | </layout> |
diff --git a/src/yuzu/uisettings.cpp b/src/yuzu/uisettings.cpp index f03dc01dd..1c833767b 100644 --- a/src/yuzu/uisettings.cpp +++ b/src/yuzu/uisettings.cpp | |||
| @@ -36,4 +36,20 @@ bool IsDarkTheme() { | |||
| 36 | 36 | ||
| 37 | Values values = {}; | 37 | Values values = {}; |
| 38 | 38 | ||
| 39 | u32 CalculateWidth(u32 height, Settings::AspectRatio ratio) { | ||
| 40 | switch (ratio) { | ||
| 41 | case Settings::AspectRatio::R4_3: | ||
| 42 | return height * 4 / 3; | ||
| 43 | case Settings::AspectRatio::R21_9: | ||
| 44 | return height * 21 / 9; | ||
| 45 | case Settings::AspectRatio::R16_10: | ||
| 46 | return height * 16 / 10; | ||
| 47 | case Settings::AspectRatio::R16_9: | ||
| 48 | case Settings::AspectRatio::Stretch: | ||
| 49 | // TODO: Move this function wherever appropriate to implement Stretched aspect | ||
| 50 | break; | ||
| 51 | } | ||
| 52 | return height * 16 / 9; | ||
| 53 | } | ||
| 54 | |||
| 39 | } // namespace UISettings | 55 | } // namespace UISettings |
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index c9c89cee4..8efd63f31 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include <QVector> | 13 | #include <QVector> |
| 14 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 15 | #include "common/settings.h" | 15 | #include "common/settings.h" |
| 16 | #include "common/settings_enums.h" | ||
| 16 | 17 | ||
| 17 | using Settings::Category; | 18 | using Settings::Category; |
| 18 | using Settings::Setting; | 19 | using Settings::Setting; |
| @@ -127,8 +128,10 @@ struct Values { | |||
| 127 | // logging | 128 | // logging |
| 128 | Setting<bool> show_console{linkage, false, "showConsole", Category::Ui}; | 129 | Setting<bool> show_console{linkage, false, "showConsole", Category::Ui}; |
| 129 | 130 | ||
| 131 | // Screenshots | ||
| 130 | Setting<bool> enable_screenshot_save_as{linkage, true, "enable_screenshot_save_as", | 132 | Setting<bool> enable_screenshot_save_as{linkage, true, "enable_screenshot_save_as", |
| 131 | Category::Screenshots}; | 133 | Category::Screenshots}; |
| 134 | Setting<u32> screenshot_height{linkage, 0, "screenshot_height", Category::Screenshots}; | ||
| 132 | 135 | ||
| 133 | QString roms_path; | 136 | QString roms_path; |
| 134 | QString symbols_path; | 137 | QString symbols_path; |
| @@ -187,6 +190,8 @@ struct Values { | |||
| 187 | 190 | ||
| 188 | extern Values values; | 191 | extern Values values; |
| 189 | 192 | ||
| 193 | u32 CalculateWidth(u32 height, Settings::AspectRatio ratio); | ||
| 194 | |||
| 190 | } // namespace UISettings | 195 | } // namespace UISettings |
| 191 | 196 | ||
| 192 | Q_DECLARE_METATYPE(UISettings::GameDir*); | 197 | Q_DECLARE_METATYPE(UISettings::GameDir*); |