forked from suyu/suyu
yuzu-qt: Implement unspecified screenshot ratio
This commit is contained in:
parent
76a03e99b6
commit
96c98d09cb
4 changed files with 30 additions and 11 deletions
|
@ -146,7 +146,7 @@ ENUM(AntiAliasing, None, Fxaa, Smaa, MaxEnum);
|
|||
|
||||
ENUM(AspectRatio, R16_9, R4_3, R21_9, R16_10, Stretch);
|
||||
|
||||
ENUM(ScreenshotAspectRatio, Auto, R16_9, R4_3, R21_9, R16_10);
|
||||
ENUM(ScreenshotAspectRatio, Auto, Unspecified, R16_9, R4_3, R21_9, R16_10);
|
||||
|
||||
template <typename Type>
|
||||
inline std::string CanonicalizeEnum(Type id) {
|
||||
|
|
|
@ -932,9 +932,13 @@ void GRenderWindow::CaptureScreenshot(const QString& screenshot_path) {
|
|||
: Layout::ScreenUndocked::Height;
|
||||
height *= Settings::values.resolution_info.up_factor;
|
||||
}
|
||||
const u32 width = UISettings::CalculateWidth(
|
||||
height, UISettings::ConvertScreenshotRatioToRatio(
|
||||
UISettings::values.screenshot_aspect_ratio.GetValue()));
|
||||
const auto selected_ratio = UISettings::values.screenshot_aspect_ratio.GetValue();
|
||||
const u32 width =
|
||||
selected_ratio == Settings::ScreenshotAspectRatio::Unspecified
|
||||
? UISettings::values.screenshot_width.GetValue()
|
||||
: UISettings::CalculateWidth(
|
||||
height, UISettings::ConvertScreenshotRatioToRatio(
|
||||
UISettings::values.screenshot_aspect_ratio.GetValue()));
|
||||
return Layout::DefaultFrameLayout(width, height);
|
||||
}()};
|
||||
|
||||
|
|
|
@ -66,9 +66,10 @@ QString GetTranslatedRowTextName(size_t index) {
|
|||
}
|
||||
} // Anonymous namespace
|
||||
|
||||
constexpr static std::array<std::pair<Settings::ScreenshotAspectRatio, std::string>, 5>
|
||||
constexpr static std::array<std::pair<Settings::ScreenshotAspectRatio, std::string>, 6>
|
||||
screenshot_aspect_ratio_translations = {
|
||||
std::pair{Settings::ScreenshotAspectRatio::Auto, "Auto"},
|
||||
std::pair{Settings::ScreenshotAspectRatio::Unspecified, "Unspecified"},
|
||||
std::pair{Settings::ScreenshotAspectRatio::R16_9, "16:9"},
|
||||
std::pair{Settings::ScreenshotAspectRatio::R4_3, "4:3"},
|
||||
std::pair{Settings::ScreenshotAspectRatio::R21_9, "21:9"},
|
||||
|
@ -104,7 +105,7 @@ static void PopulateResolutionComboBox(QComboBox* screenshot_height) {
|
|||
}
|
||||
}
|
||||
|
||||
static u32 HeightToInt(const QString& height) {
|
||||
static u32 ScreenshotDimensionToInt(const QString& height) {
|
||||
try {
|
||||
return std::stoi(height.toStdString());
|
||||
} catch (std::invalid_argument& e) {
|
||||
|
@ -168,9 +169,16 @@ ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent)
|
|||
|
||||
const auto update_width_text = [this]() {
|
||||
const auto index = ui->screenshot_aspect_ratio->currentIndex();
|
||||
const Settings::AspectRatio ratio = UISettings::ConvertScreenshotRatioToRatio(
|
||||
screenshot_aspect_ratio_translations[index].first);
|
||||
const auto height = HeightToInt(ui->screenshot_height->currentText());
|
||||
const auto selected_ratio = screenshot_aspect_ratio_translations[index].first;
|
||||
if (selected_ratio == Settings::ScreenshotAspectRatio::Unspecified) {
|
||||
ui->screenshot_width->setReadOnly(false);
|
||||
return;
|
||||
} else {
|
||||
ui->screenshot_width->setReadOnly(true);
|
||||
}
|
||||
const Settings::AspectRatio ratio =
|
||||
UISettings::ConvertScreenshotRatioToRatio(selected_ratio);
|
||||
const auto height = ScreenshotDimensionToInt(ui->screenshot_height->currentText());
|
||||
const auto width = UISettings::CalculateWidth(height, ratio);
|
||||
if (height == 0) {
|
||||
ui->screenshot_width->setText(QString::fromStdString(fmt::format("Auto")));
|
||||
|
@ -207,10 +215,13 @@ void ConfigureUi::ApplyConfiguration() {
|
|||
const auto ratio =
|
||||
screenshot_aspect_ratio_translations[ui->screenshot_aspect_ratio->currentIndex()].first;
|
||||
UISettings::values.screenshot_aspect_ratio.SetValue(ratio);
|
||||
const u32 height = HeightToInt(ui->screenshot_height->currentText());
|
||||
const u32 height = ScreenshotDimensionToInt(ui->screenshot_height->currentText());
|
||||
const u32 calculated_width =
|
||||
UISettings::CalculateWidth(height, UISettings::ConvertScreenshotRatioToRatio(ratio));
|
||||
const u32 width_readout = ScreenshotDimensionToInt(ui->screenshot_width->text());
|
||||
UISettings::values.screenshot_height.SetValue(height);
|
||||
UISettings::values.screenshot_width.SetValue(
|
||||
UISettings::CalculateWidth(height, UISettings::ConvertScreenshotRatioToRatio(ratio)));
|
||||
ratio == Settings::ScreenshotAspectRatio::Unspecified ? width_readout : calculated_width);
|
||||
|
||||
system.ApplySettings();
|
||||
}
|
||||
|
@ -245,6 +256,8 @@ void ConfigureUi::SetConfiguration() {
|
|||
}
|
||||
ui->screenshot_height->setCurrentText(
|
||||
QString::fromStdString(fmt::format("{}", UISettings::values.screenshot_height.GetValue())));
|
||||
ui->screenshot_width->setText(
|
||||
QString::fromStdString(fmt::format("{}", UISettings::values.screenshot_width.GetValue())));
|
||||
}
|
||||
|
||||
void ConfigureUi::changeEvent(QEvent* event) {
|
||||
|
|
|
@ -63,6 +63,8 @@ Settings::AspectRatio ConvertScreenshotRatioToRatio(Settings::ScreenshotAspectRa
|
|||
return Settings::AspectRatio::R21_9;
|
||||
case Settings::ScreenshotAspectRatio::R16_10:
|
||||
return Settings::AspectRatio::R16_10;
|
||||
case Settings::ScreenshotAspectRatio::Unspecified:
|
||||
break;
|
||||
}
|
||||
return Settings::AspectRatio::R16_9;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue