summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/settings_enums.h2
-rw-r--r--src/yuzu/bootmanager.cpp7
-rw-r--r--src/yuzu/configuration/configure_dialog.cpp8
-rw-r--r--src/yuzu/configuration/configure_dialog.h2
-rw-r--r--src/yuzu/configuration/configure_graphics.cpp44
-rw-r--r--src/yuzu/configuration/configure_graphics.h17
-rw-r--r--src/yuzu/configuration/configure_per_game.cpp3
-rw-r--r--src/yuzu/configuration/configure_ui.cpp113
-rw-r--r--src/yuzu/configuration/configure_ui.h8
-rw-r--r--src/yuzu/configuration/configure_ui.ui42
-rw-r--r--src/yuzu/uisettings.cpp18
-rw-r--r--src/yuzu/uisettings.h5
12 files changed, 127 insertions, 142 deletions
diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h
index 7b2e558b6..e7cb59ea5 100644
--- a/src/common/settings_enums.h
+++ b/src/common/settings_enums.h
@@ -146,8 +146,6 @@ ENUM(AntiAliasing, None, Fxaa, Smaa, MaxEnum);
146 146
147ENUM(AspectRatio, R16_9, R4_3, R21_9, R16_10, Stretch); 147ENUM(AspectRatio, R16_9, R4_3, R21_9, R16_10, Stretch);
148 148
149ENUM(ScreenshotAspectRatio, Auto, Unspecified, R16_9, R4_3, R21_9, R16_10);
150
151template <typename Type> 149template <typename Type>
152inline std::string CanonicalizeEnum(Type id) { 150inline std::string CanonicalizeEnum(Type id) {
153 const auto group = EnumMetadata<Type>::Canonicalizations(); 151 const auto group = EnumMetadata<Type>::Canonicalizations();
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index 24630e4cb..407988b8f 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -932,13 +932,8 @@ void GRenderWindow::CaptureScreenshot(const QString& screenshot_path) {
932 : Layout::ScreenUndocked::Height; 932 : Layout::ScreenUndocked::Height;
933 height *= Settings::values.resolution_info.up_factor; 933 height *= Settings::values.resolution_info.up_factor;
934 } 934 }
935 const auto selected_ratio = UISettings::values.screenshot_aspect_ratio.GetValue();
936 const u32 width = 935 const u32 width =
937 selected_ratio == Settings::ScreenshotAspectRatio::Unspecified 936 UISettings::CalculateWidth(height, Settings::values.aspect_ratio.GetValue());
938 ? UISettings::values.screenshot_width.GetValue()
939 : UISettings::CalculateWidth(
940 height, UISettings::ConvertScreenshotRatioToRatio(
941 UISettings::values.screenshot_aspect_ratio.GetValue()));
942 return Layout::DefaultFrameLayout(width, height); 937 return Layout::DefaultFrameLayout(width, height);
943 }()}; 938 }()};
944 939
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
80ConfigureGraphics::ConfigureGraphics(const Core::System& system_, 81ConfigureGraphics::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
44class ConfigureGraphics : public ConfigurationShared::Tab { 45class ConfigureGraphics : public ConfigurationShared::Tab {
45public: 46public:
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 206af81a8..8d298993a 100644
--- a/src/yuzu/configuration/configure_ui.cpp
+++ b/src/yuzu/configuration/configure_ui.cpp
@@ -24,6 +24,7 @@
24#include "common/settings.h" 24#include "common/settings.h"
25#include "common/settings_enums.h" 25#include "common/settings_enums.h"
26#include "core/core.h" 26#include "core/core.h"
27#include "core/frontend/framebuffer_layout.h"
27#include "ui_configure_ui.h" 28#include "ui_configure_ui.h"
28#include "yuzu/uisettings.h" 29#include "yuzu/uisettings.h"
29 30
@@ -66,40 +67,27 @@ QString GetTranslatedRowTextName(size_t index) {
66} 67}
67} // Anonymous namespace 68} // Anonymous namespace
68 69
69constexpr static std::array<std::pair<Settings::ScreenshotAspectRatio, std::string>, 6> 70static float GetUpFactor(Settings::ResolutionSetup res_setup) {
70 screenshot_aspect_ratio_translations = { 71 Settings::ResolutionScalingInfo info{};
71 std::pair{Settings::ScreenshotAspectRatio::Auto, "Auto"}, 72 Settings::TranslateResolutionInfo(res_setup, info);
72 std::pair{Settings::ScreenshotAspectRatio::Unspecified, "Unspecified"}, 73 return info.up_factor;
73 std::pair{Settings::ScreenshotAspectRatio::R16_9, "16:9"},
74 std::pair{Settings::ScreenshotAspectRatio::R4_3, "4:3"},
75 std::pair{Settings::ScreenshotAspectRatio::R21_9, "21:9"},
76 std::pair{Settings::ScreenshotAspectRatio::R16_10, "16:10"},
77};
78
79static void PopulateAspectRatioComboBox(QComboBox* screenshot_aspect_ratio) {
80 screenshot_aspect_ratio->clear();
81
82 for (const auto& [value, name] : screenshot_aspect_ratio_translations) {
83 screenshot_aspect_ratio->addItem(QString::fromStdString(name));
84 }
85} 74}
86 75
87static void PopulateResolutionComboBox(QComboBox* screenshot_height) { 76static void PopulateResolutionComboBox(QComboBox* screenshot_height, QWidget* parent) {
88 screenshot_height->clear(); 77 screenshot_height->clear();
89 78
90 const auto& enumeration = 79 const auto& enumeration =
91 Settings::EnumMetadata<Settings::ResolutionSetup>::Canonicalizations(); 80 Settings::EnumMetadata<Settings::ResolutionSetup>::Canonicalizations();
92 Settings::ResolutionScalingInfo info{};
93 std::set<u32> resolutions{}; 81 std::set<u32> resolutions{};
94 for (const auto& [name, value] : enumeration) { 82 for (const auto& [name, value] : enumeration) {
95 Settings::TranslateResolutionInfo(value, info); 83 const float up_factor = GetUpFactor(value);
96 u32 height_undocked = 720 * info.up_factor; 84 u32 height_undocked = Layout::ScreenUndocked::Height * up_factor;
97 u32 height_docked = 1080 * info.up_factor; 85 u32 height_docked = Layout::ScreenDocked::Height * up_factor;
98 resolutions.emplace(height_undocked); 86 resolutions.emplace(height_undocked);
99 resolutions.emplace(height_docked); 87 resolutions.emplace(height_docked);
100 } 88 }
101 89
102 screenshot_height->addItem(QStringLiteral("0")); 90 screenshot_height->addItem(parent->tr("Auto", "Screenshot height option"));
103 for (const auto res : resolutions) { 91 for (const auto res : resolutions) {
104 screenshot_height->addItem(QString::fromStdString(std::to_string(res))); 92 screenshot_height->addItem(QString::fromStdString(std::to_string(res)));
105 } 93 }
@@ -114,7 +102,9 @@ static u32 ScreenshotDimensionToInt(const QString& height) {
114} 102}
115 103
116ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent) 104ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent)
117 : 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_} {
118 ui->setupUi(this); 108 ui->setupUi(this);
119 109
120 InitializeLanguageComboBox(); 110 InitializeLanguageComboBox();
@@ -127,8 +117,7 @@ ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent)
127 InitializeIconSizeComboBox(); 117 InitializeIconSizeComboBox();
128 InitializeRowComboBoxes(); 118 InitializeRowComboBoxes();
129 119
130 PopulateAspectRatioComboBox(ui->screenshot_aspect_ratio); 120 PopulateResolutionComboBox(ui->screenshot_height, this);
131 PopulateResolutionComboBox(ui->screenshot_height);
132 121
133 SetConfiguration(); 122 SetConfiguration();
134 123
@@ -167,31 +156,9 @@ ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent)
167 } 156 }
168 }); 157 });
169 158
170 const auto update_width_text = [this]() { 159 connect(ui->screenshot_height, &QComboBox::currentTextChanged, [this]() { UpdateWidthText(); });
171 const auto index = ui->screenshot_aspect_ratio->currentIndex();
172 const auto selected_ratio = screenshot_aspect_ratio_translations[index].first;
173 if (selected_ratio == Settings::ScreenshotAspectRatio::Unspecified) {
174 ui->screenshot_width->setReadOnly(false);
175 return;
176 } else {
177 ui->screenshot_width->setReadOnly(true);
178 }
179 const Settings::AspectRatio ratio =
180 UISettings::ConvertScreenshotRatioToRatio(selected_ratio);
181 const auto height = ScreenshotDimensionToInt(ui->screenshot_height->currentText());
182 const auto width = UISettings::CalculateWidth(height, ratio);
183 if (height == 0) {
184 ui->screenshot_width->setText(QString::fromStdString(fmt::format("Auto")));
185 } else {
186 ui->screenshot_width->setText(QString::fromStdString(std::to_string(width)));
187 }
188 };
189 160
190 connect(ui->screenshot_aspect_ratio, QOverload<int>::of(&QComboBox::currentIndexChanged), 161 UpdateWidthText();
191 update_width_text);
192 connect(ui->screenshot_height, &QComboBox::currentTextChanged, update_width_text);
193
194 update_width_text();
195} 162}
196 163
197ConfigureUi::~ConfigureUi() = default; 164ConfigureUi::~ConfigureUi() = default;
@@ -212,16 +179,8 @@ void ConfigureUi::ApplyConfiguration() {
212 Common::FS::SetYuzuPath(Common::FS::YuzuPath::ScreenshotsDir, 179 Common::FS::SetYuzuPath(Common::FS::YuzuPath::ScreenshotsDir,
213 ui->screenshot_path_edit->text().toStdString()); 180 ui->screenshot_path_edit->text().toStdString());
214 181
215 const auto ratio =
216 screenshot_aspect_ratio_translations[ui->screenshot_aspect_ratio->currentIndex()].first;
217 UISettings::values.screenshot_aspect_ratio.SetValue(ratio);
218 const u32 height = ScreenshotDimensionToInt(ui->screenshot_height->currentText()); 182 const u32 height = ScreenshotDimensionToInt(ui->screenshot_height->currentText());
219 const u32 calculated_width =
220 UISettings::CalculateWidth(height, UISettings::ConvertScreenshotRatioToRatio(ratio));
221 const u32 width_readout = ScreenshotDimensionToInt(ui->screenshot_width->text());
222 UISettings::values.screenshot_height.SetValue(height); 183 UISettings::values.screenshot_height.SetValue(height);
223 UISettings::values.screenshot_width.SetValue(
224 ratio == Settings::ScreenshotAspectRatio::Unspecified ? width_readout : calculated_width);
225 184
226 system.ApplySettings(); 185 system.ApplySettings();
227} 186}
@@ -248,16 +207,12 @@ void ConfigureUi::SetConfiguration() {
248 ui->screenshot_path_edit->setText(QString::fromStdString( 207 ui->screenshot_path_edit->setText(QString::fromStdString(
249 Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir))); 208 Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir)));
250 209
251 for (u32 i = 0; i < screenshot_aspect_ratio_translations.size(); i++) { 210 const auto height = UISettings::values.screenshot_height.GetValue();
252 const auto ratio = screenshot_aspect_ratio_translations[i].first; 211 if (height == 0) {
253 if (ratio == UISettings::values.screenshot_aspect_ratio.GetValue()) { 212 ui->screenshot_height->setCurrentIndex(0);
254 ui->screenshot_aspect_ratio->setCurrentIndex(i); 213 } else {
255 } 214 ui->screenshot_height->setCurrentText(QStringLiteral("%1").arg(height));
256 } 215 }
257 ui->screenshot_height->setCurrentText(
258 QString::fromStdString(fmt::format("{}", UISettings::values.screenshot_height.GetValue())));
259 ui->screenshot_width->setText(
260 QString::fromStdString(fmt::format("{}", UISettings::values.screenshot_width.GetValue())));
261} 216}
262 217
263void ConfigureUi::changeEvent(QEvent* event) { 218void ConfigureUi::changeEvent(QEvent* event) {
@@ -428,3 +383,29 @@ void ConfigureUi::OnLanguageChanged(int index) {
428 383
429 emit LanguageChanged(ui->language_combobox->itemData(index).toString()); 384 emit LanguageChanged(ui->language_combobox->itemData(index).toString());
430} 385}
386
387void 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
406void 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
9namespace Core { 10namespace Core {
10class System; 11class 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
26private slots: 30private 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 906fdd5b3..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">
@@ -206,38 +206,15 @@
206 <property name="spacing"> 206 <property name="spacing">
207 <number>6</number> 207 <number>6</number>
208 </property> 208 </property>
209 <item row="1" column="0">
210 <widget class="QLabel" name="label_3">
211 <property name="text">
212 <string>Resolution:</string>
213 </property>
214 </widget>
215 </item>
216 <item row="0" column="1"> 209 <item row="0" column="1">
217 <widget class="QComboBox" name="screenshot_aspect_ratio"/>
218 </item>
219 <item row="0" column="0">
220 <widget class="QLabel" name="label_2">
221 <property name="text">
222 <string>Aspect Ratio:</string>
223 </property>
224 </widget>
225 </item>
226 <item row="1" column="1">
227 <layout class="QHBoxLayout" name="horizontalLayout_5"> 210 <layout class="QHBoxLayout" name="horizontalLayout_5">
228 <item> 211 <item>
229 <widget class="QLineEdit" name="screenshot_width"> 212 <widget class="QLabel" name="screenshot_width">
230 <property name="enabled"> 213 <property name="text">
231 <bool>true</bool> 214 <string>TextLabel</string>
232 </property>
233 <property name="sizePolicy">
234 <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
235 <horstretch>0</horstretch>
236 <verstretch>0</verstretch>
237 </sizepolicy>
238 </property> 215 </property>
239 <property name="readOnly"> 216 <property name="alignment">
240 <bool>true</bool> 217 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
241 </property> 218 </property>
242 </widget> 219 </widget>
243 </item> 220 </item>
@@ -250,6 +227,13 @@
250 </item> 227 </item>
251 </layout> 228 </layout>
252 </item> 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>
253 </layout> 237 </layout>
254 </item> 238 </item>
255 </layout> 239 </layout>
diff --git a/src/yuzu/uisettings.cpp b/src/yuzu/uisettings.cpp
index 606268a5f..78f927ba9 100644
--- a/src/yuzu/uisettings.cpp
+++ b/src/yuzu/uisettings.cpp
@@ -51,22 +51,4 @@ u32 CalculateWidth(u32 height, Settings::AspectRatio ratio) {
51 return height * 16 / 9; 51 return height * 16 / 9;
52} 52}
53 53
54Settings::AspectRatio ConvertScreenshotRatioToRatio(Settings::ScreenshotAspectRatio ratio) {
55 switch (ratio) {
56 case Settings::ScreenshotAspectRatio::Auto:
57 return Settings::values.aspect_ratio.GetValue();
58 case Settings::ScreenshotAspectRatio::R16_9:
59 return Settings::AspectRatio::R16_9;
60 case Settings::ScreenshotAspectRatio::R4_3:
61 return Settings::AspectRatio::R4_3;
62 case Settings::ScreenshotAspectRatio::R21_9:
63 return Settings::AspectRatio::R21_9;
64 case Settings::ScreenshotAspectRatio::R16_10:
65 return Settings::AspectRatio::R16_10;
66 case Settings::ScreenshotAspectRatio::Unspecified:
67 break;
68 }
69 return Settings::AspectRatio::R16_9;
70}
71
72} // namespace UISettings 54} // namespace UISettings
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h
index 7b5d630d7..8efd63f31 100644
--- a/src/yuzu/uisettings.h
+++ b/src/yuzu/uisettings.h
@@ -132,10 +132,6 @@ struct Values {
132 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",
133 Category::Screenshots}; 133 Category::Screenshots};
134 Setting<u32> screenshot_height{linkage, 0, "screenshot_height", Category::Screenshots}; 134 Setting<u32> screenshot_height{linkage, 0, "screenshot_height", Category::Screenshots};
135 Setting<u32> screenshot_width{linkage, 0, "screenshot_width", Category::Screenshots};
136 Setting<Settings::ScreenshotAspectRatio> screenshot_aspect_ratio{
137 linkage, Settings::ScreenshotAspectRatio::Auto, "screenshot_aspect_ratio",
138 Category::Screenshots};
139 135
140 QString roms_path; 136 QString roms_path;
141 QString symbols_path; 137 QString symbols_path;
@@ -195,7 +191,6 @@ struct Values {
195extern Values values; 191extern Values values;
196 192
197u32 CalculateWidth(u32 height, Settings::AspectRatio ratio); 193u32 CalculateWidth(u32 height, Settings::AspectRatio ratio);
198Settings::AspectRatio ConvertScreenshotRatioToRatio(Settings::ScreenshotAspectRatio ratio);
199 194
200} // namespace UISettings 195} // namespace UISettings
201 196