System: Add option to automatically resize window

This commit is contained in:
Stenzek 2024-09-07 22:05:54 +10:00
parent fe18e2be77
commit f4e8470502
No known key found for this signature in database
6 changed files with 28 additions and 0 deletions

View file

@ -4435,6 +4435,10 @@ void FullscreenUI::DrawDisplaySettingsPage()
FSUI_CSTR("Stretches the display to match the aspect ratio by multiplying vertically instead of horizontally."),
"Display", "StretchVertically", false);
DrawToggleSetting(bsi, FSUI_CSTR("Automatically Resize Window"),
FSUI_CSTR("Automatically resizes the window to match the internal resolution."), "Display",
"AutoResizeWindow", false);
DrawToggleSetting(
bsi, FSUI_CSTR("Disable Mailbox Presentation"),
FSUI_CSTR("Forces the use of FIFO over Mailbox presentation, i.e. double buffering instead of triple buffering. "
@ -7239,8 +7243,10 @@ TRANSLATE_NOOP("FullscreenUI", "Automatic based on window size");
TRANSLATE_NOOP("FullscreenUI", "Automatic mapping completed for {}.");
TRANSLATE_NOOP("FullscreenUI", "Automatic mapping failed for {}.");
TRANSLATE_NOOP("FullscreenUI", "Automatic mapping failed, no devices are available.");
TRANSLATE_NOOP("FullscreenUI", "Automatically Resize Window");
TRANSLATE_NOOP("FullscreenUI", "Automatically applies patches to disc images when they are present, currently only PPF is supported.");
TRANSLATE_NOOP("FullscreenUI", "Automatically loads and applies cheats on game start. Cheats can break games and saves.");
TRANSLATE_NOOP("FullscreenUI", "Automatically resizes the window to match the internal resolution.");
TRANSLATE_NOOP("FullscreenUI", "Automatically saves the emulator state when powering down or exiting. You can then resume directly from where you left off next time.");
TRANSLATE_NOOP("FullscreenUI", "Automatically switches to fullscreen mode when the program is started.");
TRANSLATE_NOOP("FullscreenUI", "Avoids calls to C++ code, significantly speeding up the recompiler.");

View file

@ -1985,6 +1985,13 @@ void GPU::SetDisplayTexture(GPUTexture* texture, GPUTexture* depth_buffer, s32 v
s32 view_height)
{
DebugAssert(texture);
if (g_settings.display_auto_resize_window &&
(view_width != m_display_texture_view_width || view_height != m_display_texture_view_height))
{
System::RequestDisplaySize();
}
m_display_texture = texture;
m_display_depth_buffer = depth_buffer;
m_display_texture_view_x = view_x;

View file

@ -318,6 +318,7 @@ void Settings::Load(SettingsInterface& si, SettingsInterface& controller_si)
display_show_inputs = si.GetBoolValue("Display", "ShowInputs", false);
display_show_enhancements = si.GetBoolValue("Display", "ShowEnhancements", false);
display_stretch_vertically = si.GetBoolValue("Display", "StretchVertically", false);
display_auto_resize_window = si.GetBoolValue("Display", "AutoResizeWindow", false);
display_osd_scale = si.GetFloatValue("Display", "OSDScale", DEFAULT_OSD_SCALE);
save_state_compression = ParseSaveStateCompressionModeName(
@ -593,6 +594,7 @@ void Settings::Save(SettingsInterface& si, bool ignore_base) const
}
si.SetBoolValue("Display", "StretchVertically", display_stretch_vertically);
si.SetBoolValue("Display", "AutoResizeWindow", display_auto_resize_window);
si.SetIntValue("CDROM", "ReadaheadSectors", cdrom_readahead_sectors);
si.SetStringValue("CDROM", "MechaconVersion", GetCDROMMechVersionName(cdrom_mechacon_version));

View file

@ -173,6 +173,7 @@ struct Settings
bool display_show_inputs : 1 = false;
bool display_show_enhancements : 1 = false;
bool display_stretch_vertically : 1 = false;
bool display_auto_resize_window : 1 = false;
float display_pre_frame_sleep_buffer = DEFAULT_DISPLAY_PRE_FRAME_SLEEP_BUFFER;
float display_osd_scale = 100.0f;
float gpu_pgxp_tolerance = -1.0f;

View file

@ -123,6 +123,8 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget*
"DisableMailboxPresentation", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.stretchDisplayVertically, "Display", "StretchVertically",
false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.automaticallyResizeWindow, "Display", "AutoResizeWindow",
false);
#ifdef _WIN32
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.blitSwapChain, "Display", "UseBlitSwapChain", false);
#endif
@ -381,6 +383,9 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget*
dialog->registerWidgetHelp(
m_ui.stretchDisplayVertically, tr("Stretch Vertically"), tr("Unchecked"),
tr("Prefers stretching the display vertically instead of horizontally, when applying the display aspect ratio."));
dialog->registerWidgetHelp(m_ui.stretchDisplayVertically, tr("Automatically Resize Window"), tr("Unchecked"),
tr("Automatically resizes the window to match the internal resolution. <strong>For high "
"internal resolutions, this will create very large windows.</strong>"));
#ifdef _WIN32
dialog->registerWidgetHelp(m_ui.blitSwapChain, tr("Use Blit Swap Chain"), tr("Unchecked"),
tr("Uses a blit presentation model instead of flipping when using the Direct3D 11 "

View file

@ -355,6 +355,13 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="automaticallyResizeWindow">
<property name="text">
<string>Automatically Resize Window</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">