summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/common/settings_enums.h2
-rw-r--r--src/yuzu/bootmanager.cpp10
-rw-r--r--src/yuzu/configuration/configure_ui.cpp27
-rw-r--r--src/yuzu/uisettings.cpp2
4 files changed, 30 insertions, 11 deletions
diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h
index 4edfd2bfb..7b2e558b6 100644
--- a/src/common/settings_enums.h
+++ b/src/common/settings_enums.h
@@ -146,7 +146,7 @@ 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, R16_9, R4_3, R21_9, R16_10); 149ENUM(ScreenshotAspectRatio, Auto, Unspecified, R16_9, R4_3, R21_9, R16_10);
150 150
151template <typename Type> 151template <typename Type>
152inline std::string CanonicalizeEnum(Type id) { 152inline std::string CanonicalizeEnum(Type id) {
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index 2a9f423a0..24630e4cb 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -932,9 +932,13 @@ 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 u32 width = UISettings::CalculateWidth( 935 const auto selected_ratio = UISettings::values.screenshot_aspect_ratio.GetValue();
936 height, UISettings::ConvertScreenshotRatioToRatio( 936 const u32 width =
937 UISettings::values.screenshot_aspect_ratio.GetValue())); 937 selected_ratio == Settings::ScreenshotAspectRatio::Unspecified
938 ? UISettings::values.screenshot_width.GetValue()
939 : UISettings::CalculateWidth(
940 height, UISettings::ConvertScreenshotRatioToRatio(
941 UISettings::values.screenshot_aspect_ratio.GetValue()));
938 return Layout::DefaultFrameLayout(width, height); 942 return Layout::DefaultFrameLayout(width, height);
939 }()}; 943 }()};
940 944
diff --git a/src/yuzu/configuration/configure_ui.cpp b/src/yuzu/configuration/configure_ui.cpp
index 77aff01b7..206af81a8 100644
--- a/src/yuzu/configuration/configure_ui.cpp
+++ b/src/yuzu/configuration/configure_ui.cpp
@@ -66,9 +66,10 @@ QString GetTranslatedRowTextName(size_t index) {
66} 66}
67} // Anonymous namespace 67} // Anonymous namespace
68 68
69constexpr static std::array<std::pair<Settings::ScreenshotAspectRatio, std::string>, 5> 69constexpr static std::array<std::pair<Settings::ScreenshotAspectRatio, std::string>, 6>
70 screenshot_aspect_ratio_translations = { 70 screenshot_aspect_ratio_translations = {
71 std::pair{Settings::ScreenshotAspectRatio::Auto, "Auto"}, 71 std::pair{Settings::ScreenshotAspectRatio::Auto, "Auto"},
72 std::pair{Settings::ScreenshotAspectRatio::Unspecified, "Unspecified"},
72 std::pair{Settings::ScreenshotAspectRatio::R16_9, "16:9"}, 73 std::pair{Settings::ScreenshotAspectRatio::R16_9, "16:9"},
73 std::pair{Settings::ScreenshotAspectRatio::R4_3, "4:3"}, 74 std::pair{Settings::ScreenshotAspectRatio::R4_3, "4:3"},
74 std::pair{Settings::ScreenshotAspectRatio::R21_9, "21:9"}, 75 std::pair{Settings::ScreenshotAspectRatio::R21_9, "21:9"},
@@ -104,7 +105,7 @@ static void PopulateResolutionComboBox(QComboBox* screenshot_height) {
104 } 105 }
105} 106}
106 107
107static u32 HeightToInt(const QString& height) { 108static u32 ScreenshotDimensionToInt(const QString& height) {
108 try { 109 try {
109 return std::stoi(height.toStdString()); 110 return std::stoi(height.toStdString());
110 } catch (std::invalid_argument& e) { 111 } catch (std::invalid_argument& e) {
@@ -168,9 +169,16 @@ ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent)
168 169
169 const auto update_width_text = [this]() { 170 const auto update_width_text = [this]() {
170 const auto index = ui->screenshot_aspect_ratio->currentIndex(); 171 const auto index = ui->screenshot_aspect_ratio->currentIndex();
171 const Settings::AspectRatio ratio = UISettings::ConvertScreenshotRatioToRatio( 172 const auto selected_ratio = screenshot_aspect_ratio_translations[index].first;
172 screenshot_aspect_ratio_translations[index].first); 173 if (selected_ratio == Settings::ScreenshotAspectRatio::Unspecified) {
173 const auto height = HeightToInt(ui->screenshot_height->currentText()); 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());
174 const auto width = UISettings::CalculateWidth(height, ratio); 182 const auto width = UISettings::CalculateWidth(height, ratio);
175 if (height == 0) { 183 if (height == 0) {
176 ui->screenshot_width->setText(QString::fromStdString(fmt::format("Auto"))); 184 ui->screenshot_width->setText(QString::fromStdString(fmt::format("Auto")));
@@ -207,10 +215,13 @@ void ConfigureUi::ApplyConfiguration() {
207 const auto ratio = 215 const auto ratio =
208 screenshot_aspect_ratio_translations[ui->screenshot_aspect_ratio->currentIndex()].first; 216 screenshot_aspect_ratio_translations[ui->screenshot_aspect_ratio->currentIndex()].first;
209 UISettings::values.screenshot_aspect_ratio.SetValue(ratio); 217 UISettings::values.screenshot_aspect_ratio.SetValue(ratio);
210 const u32 height = HeightToInt(ui->screenshot_height->currentText()); 218 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());
211 UISettings::values.screenshot_height.SetValue(height); 222 UISettings::values.screenshot_height.SetValue(height);
212 UISettings::values.screenshot_width.SetValue( 223 UISettings::values.screenshot_width.SetValue(
213 UISettings::CalculateWidth(height, UISettings::ConvertScreenshotRatioToRatio(ratio))); 224 ratio == Settings::ScreenshotAspectRatio::Unspecified ? width_readout : calculated_width);
214 225
215 system.ApplySettings(); 226 system.ApplySettings();
216} 227}
@@ -245,6 +256,8 @@ void ConfigureUi::SetConfiguration() {
245 } 256 }
246 ui->screenshot_height->setCurrentText( 257 ui->screenshot_height->setCurrentText(
247 QString::fromStdString(fmt::format("{}", UISettings::values.screenshot_height.GetValue()))); 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())));
248} 261}
249 262
250void ConfigureUi::changeEvent(QEvent* event) { 263void ConfigureUi::changeEvent(QEvent* event) {
diff --git a/src/yuzu/uisettings.cpp b/src/yuzu/uisettings.cpp
index 3ab0d1b45..606268a5f 100644
--- a/src/yuzu/uisettings.cpp
+++ b/src/yuzu/uisettings.cpp
@@ -63,6 +63,8 @@ Settings::AspectRatio ConvertScreenshotRatioToRatio(Settings::ScreenshotAspectRa
63 return Settings::AspectRatio::R21_9; 63 return Settings::AspectRatio::R21_9;
64 case Settings::ScreenshotAspectRatio::R16_10: 64 case Settings::ScreenshotAspectRatio::R16_10:
65 return Settings::AspectRatio::R16_10; 65 return Settings::AspectRatio::R16_10;
66 case Settings::ScreenshotAspectRatio::Unspecified:
67 break;
66 } 68 }
67 return Settings::AspectRatio::R16_9; 69 return Settings::AspectRatio::R16_9;
68} 70}