Added an option to set the proportion of the screens when using layout "Large Screen Small Screen", to allow the user to define how much bigger the large screen should be with respect to the smaller screen. Currently the value must be between 1 and 16, but I could set a different maximum value if that would be desired. Thank you very much! (#6252)

This commit is contained in:
komasanzura 2023-02-17 09:19:52 -05:00 committed by GitHub
parent bb8dde8480
commit 9eb1cd2875
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 83 additions and 20 deletions

View file

@ -160,6 +160,8 @@ void Config::ReadValues() {
static_cast<Settings::LayoutOption>(sdl2_config->GetInteger("Layout", "layout_option", 0)); static_cast<Settings::LayoutOption>(sdl2_config->GetInteger("Layout", "layout_option", 0));
Settings::values.swap_screen = sdl2_config->GetBoolean("Layout", "swap_screen", false); Settings::values.swap_screen = sdl2_config->GetBoolean("Layout", "swap_screen", false);
Settings::values.upright_screen = sdl2_config->GetBoolean("Layout", "upright_screen", false); Settings::values.upright_screen = sdl2_config->GetBoolean("Layout", "upright_screen", false);
Settings::values.large_screen_proportion =
sdl2_config->GetReal("Layout", "large_screen_proportion", 4.0);
Settings::values.custom_layout = sdl2_config->GetBoolean("Layout", "custom_layout", false); Settings::values.custom_layout = sdl2_config->GetBoolean("Layout", "custom_layout", false);
Settings::values.custom_top_left = Settings::values.custom_top_left =
static_cast<u16>(sdl2_config->GetInteger("Layout", "custom_top_left", 0)); static_cast<u16>(sdl2_config->GetInteger("Layout", "custom_top_left", 0));

View file

@ -216,6 +216,10 @@ swap_screen =
# 0 (default): Off, 1: On # 0 (default): Off, 1: On
upright_screen = upright_screen =
# The proportion between the large and small screens when playing in Large Screen Small Screen layout.
# Must be a real value between 1.0 and 16.0. Default is 4
large_screen_proportion =
# Dumps textures as PNG to dump/textures/[Title ID]/. # Dumps textures as PNG to dump/textures/[Title ID]/.
# 0 (default): Off, 1: On # 0 (default): Off, 1: On
dump_textures = dump_textures =

View file

@ -485,6 +485,7 @@ void Config::ReadLayoutValues() {
ReadGlobalSetting(Settings::values.layout_option); ReadGlobalSetting(Settings::values.layout_option);
ReadGlobalSetting(Settings::values.swap_screen); ReadGlobalSetting(Settings::values.swap_screen);
ReadGlobalSetting(Settings::values.upright_screen); ReadGlobalSetting(Settings::values.upright_screen);
ReadGlobalSetting(Settings::values.large_screen_proportion);
if (global) { if (global) {
ReadBasicSetting(Settings::values.mono_render_option); ReadBasicSetting(Settings::values.mono_render_option);
@ -996,6 +997,7 @@ void Config::SaveLayoutValues() {
WriteGlobalSetting(Settings::values.layout_option); WriteGlobalSetting(Settings::values.layout_option);
WriteGlobalSetting(Settings::values.swap_screen); WriteGlobalSetting(Settings::values.swap_screen);
WriteGlobalSetting(Settings::values.upright_screen); WriteGlobalSetting(Settings::values.upright_screen);
WriteGlobalSetting(Settings::values.large_screen_proportion);
if (global) { if (global) {
WriteBasicSetting(Settings::values.mono_render_option); WriteBasicSetting(Settings::values.mono_render_option);

View file

@ -69,6 +69,7 @@ void ConfigureEnhancements::SetConfiguration() {
static_cast<int>(Settings::values.layout_option.GetValue())); static_cast<int>(Settings::values.layout_option.GetValue()));
ui->swap_screen->setChecked(Settings::values.swap_screen.GetValue()); ui->swap_screen->setChecked(Settings::values.swap_screen.GetValue());
ui->upright_screen->setChecked(Settings::values.upright_screen.GetValue()); ui->upright_screen->setChecked(Settings::values.upright_screen.GetValue());
ui->large_screen_proportion->setValue(Settings::values.large_screen_proportion.GetValue());
ui->toggle_dump_textures->setChecked(Settings::values.dump_textures.GetValue()); ui->toggle_dump_textures->setChecked(Settings::values.dump_textures.GetValue());
ui->toggle_custom_textures->setChecked(Settings::values.custom_textures.GetValue()); ui->toggle_custom_textures->setChecked(Settings::values.custom_textures.GetValue());
ui->toggle_preload_textures->setChecked(Settings::values.preload_textures.GetValue()); ui->toggle_preload_textures->setChecked(Settings::values.preload_textures.GetValue());
@ -122,6 +123,7 @@ void ConfigureEnhancements::ApplyConfiguration() {
static_cast<Settings::LayoutOption>(ui->layout_combobox->currentIndex()); static_cast<Settings::LayoutOption>(ui->layout_combobox->currentIndex());
Settings::values.swap_screen = ui->swap_screen->isChecked(); Settings::values.swap_screen = ui->swap_screen->isChecked();
Settings::values.upright_screen = ui->upright_screen->isChecked(); Settings::values.upright_screen = ui->upright_screen->isChecked();
Settings::values.large_screen_proportion = ui->large_screen_proportion->value();
Settings::values.dump_textures = ui->toggle_dump_textures->isChecked(); Settings::values.dump_textures = ui->toggle_dump_textures->isChecked();
Settings::values.custom_textures = ui->toggle_custom_textures->isChecked(); Settings::values.custom_textures = ui->toggle_custom_textures->isChecked();
Settings::values.preload_textures = ui->toggle_preload_textures->isChecked(); Settings::values.preload_textures = ui->toggle_preload_textures->isChecked();

View file

@ -295,6 +295,30 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Large Screen Proportion:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="large_screen_proportion">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>16</number>
</property>
<property name="value">
<number>4</number>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_6">
<item> <item>
@ -384,6 +408,7 @@
<tabstop>layout_combobox</tabstop> <tabstop>layout_combobox</tabstop>
<tabstop>swap_screen</tabstop> <tabstop>swap_screen</tabstop>
<tabstop>upright_screen</tabstop> <tabstop>upright_screen</tabstop>
<tabstop>large_screen_proportion</tabstop>
<tabstop>bg_button</tabstop> <tabstop>bg_button</tabstop>
<tabstop>toggle_custom_textures</tabstop> <tabstop>toggle_custom_textures</tabstop>
<tabstop>toggle_dump_textures</tabstop> <tabstop>toggle_dump_textures</tabstop>

View file

@ -113,6 +113,7 @@ void LogSettings() {
log_setting("Layout_LayoutOption", values.layout_option.GetValue()); log_setting("Layout_LayoutOption", values.layout_option.GetValue());
log_setting("Layout_SwapScreen", values.swap_screen.GetValue()); log_setting("Layout_SwapScreen", values.swap_screen.GetValue());
log_setting("Layout_UprightScreen", values.upright_screen.GetValue()); log_setting("Layout_UprightScreen", values.upright_screen.GetValue());
log_setting("Layout_LargeScreenProportion", values.large_screen_proportion.GetValue());
log_setting("Utility_DumpTextures", values.dump_textures.GetValue()); log_setting("Utility_DumpTextures", values.dump_textures.GetValue());
log_setting("Utility_CustomTextures", values.custom_textures.GetValue()); log_setting("Utility_CustomTextures", values.custom_textures.GetValue());
log_setting("Utility_UseDiskShaderCache", values.use_disk_shader_cache.GetValue()); log_setting("Utility_UseDiskShaderCache", values.use_disk_shader_cache.GetValue());
@ -189,6 +190,7 @@ void RestoreGlobalState(bool is_powered_on) {
values.layout_option.SetGlobal(true); values.layout_option.SetGlobal(true);
values.swap_screen.SetGlobal(true); values.swap_screen.SetGlobal(true);
values.upright_screen.SetGlobal(true); values.upright_screen.SetGlobal(true);
values.large_screen_proportion.SetGlobal(true);
values.bg_red.SetGlobal(true); values.bg_red.SetGlobal(true);
values.bg_green.SetGlobal(true); values.bg_green.SetGlobal(true);
values.bg_blue.SetGlobal(true); values.bg_blue.SetGlobal(true);

View file

@ -455,6 +455,8 @@ struct Values {
SwitchableSetting<LayoutOption> layout_option{LayoutOption::Default, "layout_option"}; SwitchableSetting<LayoutOption> layout_option{LayoutOption::Default, "layout_option"};
SwitchableSetting<bool> swap_screen{false, "swap_screen"}; SwitchableSetting<bool> swap_screen{false, "swap_screen"};
SwitchableSetting<bool> upright_screen{false, "upright_screen"}; SwitchableSetting<bool> upright_screen{false, "upright_screen"};
SwitchableSetting<float, true> large_screen_proportion{4.f, 1.f, 16.f,
"large_screen_proportion"};
Setting<bool> custom_layout{false, "custom_layout"}; Setting<bool> custom_layout{false, "custom_layout"};
Setting<u16> custom_top_left{0, "custom_top_left"}; Setting<u16> custom_top_left{0, "custom_top_left"};
Setting<u16> custom_top_top{0, "custom_top_top"}; Setting<u16> custom_top_top{0, "custom_top_top"};

View file

@ -197,7 +197,8 @@ void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height,
case Settings::LayoutOption::LargeScreen: case Settings::LayoutOption::LargeScreen:
layout = layout =
Layout::LargeFrameLayout(width, height, Settings::values.swap_screen.GetValue(), Layout::LargeFrameLayout(width, height, Settings::values.swap_screen.GetValue(),
Settings::values.upright_screen.GetValue()); Settings::values.upright_screen.GetValue(),
Settings::values.large_screen_proportion.GetValue());
break; break;
case Settings::LayoutOption::SideScreen: case Settings::LayoutOption::SideScreen:
layout = Layout::SideFrameLayout(width, height, Settings::values.swap_screen.GetValue(), layout = Layout::SideFrameLayout(width, height, Settings::values.swap_screen.GetValue(),

View file

@ -231,7 +231,8 @@ FramebufferLayout SingleFrameLayout(u32 width, u32 height, bool swapped, bool up
return res; return res;
} }
FramebufferLayout LargeFrameLayout(u32 width, u32 height, bool swapped, bool upright) { FramebufferLayout LargeFrameLayout(u32 width, u32 height, bool swapped, bool upright,
float scale_factor) {
ASSERT(width > 0); ASSERT(width > 0);
ASSERT(height > 0); ASSERT(height > 0);
@ -244,25 +245,29 @@ FramebufferLayout LargeFrameLayout(u32 width, u32 height, bool swapped, bool upr
float small_screen_aspect_ratio; float small_screen_aspect_ratio;
if (upright) { if (upright) {
if (swapped) { if (swapped) {
emulation_aspect_ratio = (Core::kScreenBottomWidth * 4.0f + Core::kScreenTopWidth) / emulation_aspect_ratio =
(Core::kScreenBottomHeight * 4); (Core::kScreenBottomWidth * scale_factor + Core::kScreenTopWidth) /
(Core::kScreenBottomHeight * scale_factor);
large_screen_aspect_ratio = BOT_SCREEN_UPRIGHT_ASPECT_RATIO; large_screen_aspect_ratio = BOT_SCREEN_UPRIGHT_ASPECT_RATIO;
small_screen_aspect_ratio = TOP_SCREEN_UPRIGHT_ASPECT_RATIO; small_screen_aspect_ratio = TOP_SCREEN_UPRIGHT_ASPECT_RATIO;
} else { } else {
emulation_aspect_ratio = (Core::kScreenTopWidth * 4.0f + Core::kScreenBottomWidth) / emulation_aspect_ratio =
(Core::kScreenTopHeight * 4); (Core::kScreenTopWidth * scale_factor + Core::kScreenBottomWidth) /
(Core::kScreenTopHeight * scale_factor);
large_screen_aspect_ratio = TOP_SCREEN_UPRIGHT_ASPECT_RATIO; large_screen_aspect_ratio = TOP_SCREEN_UPRIGHT_ASPECT_RATIO;
small_screen_aspect_ratio = BOT_SCREEN_UPRIGHT_ASPECT_RATIO; small_screen_aspect_ratio = BOT_SCREEN_UPRIGHT_ASPECT_RATIO;
} }
} else { } else {
if (swapped) { if (swapped) {
emulation_aspect_ratio = Core::kScreenBottomHeight * 4 / emulation_aspect_ratio =
(Core::kScreenBottomWidth * 4.0f + Core::kScreenTopWidth); Core::kScreenBottomHeight * scale_factor /
(Core::kScreenBottomWidth * scale_factor + Core::kScreenTopWidth);
large_screen_aspect_ratio = BOT_SCREEN_ASPECT_RATIO; large_screen_aspect_ratio = BOT_SCREEN_ASPECT_RATIO;
small_screen_aspect_ratio = TOP_SCREEN_ASPECT_RATIO; small_screen_aspect_ratio = TOP_SCREEN_ASPECT_RATIO;
} else { } else {
emulation_aspect_ratio = Core::kScreenTopHeight * 4 / emulation_aspect_ratio =
(Core::kScreenTopWidth * 4.0f + Core::kScreenBottomWidth); Core::kScreenTopHeight * scale_factor /
(Core::kScreenTopWidth * scale_factor + Core::kScreenBottomWidth);
large_screen_aspect_ratio = TOP_SCREEN_ASPECT_RATIO; large_screen_aspect_ratio = TOP_SCREEN_ASPECT_RATIO;
small_screen_aspect_ratio = BOT_SCREEN_ASPECT_RATIO; small_screen_aspect_ratio = BOT_SCREEN_ASPECT_RATIO;
} }
@ -271,7 +276,7 @@ FramebufferLayout LargeFrameLayout(u32 width, u32 height, bool swapped, bool upr
Common::Rectangle<u32> screen_window_area{0, 0, width, height}; Common::Rectangle<u32> screen_window_area{0, 0, width, height};
Common::Rectangle<u32> total_rect = maxRectangle(screen_window_area, emulation_aspect_ratio); Common::Rectangle<u32> total_rect = maxRectangle(screen_window_area, emulation_aspect_ratio);
Common::Rectangle<u32> large_screen = maxRectangle(total_rect, large_screen_aspect_ratio); Common::Rectangle<u32> large_screen = maxRectangle(total_rect, large_screen_aspect_ratio);
Common::Rectangle<u32> fourth_size_rect = total_rect.Scale(.25f); Common::Rectangle<u32> fourth_size_rect = total_rect.Scale(1.f / scale_factor);
Common::Rectangle<u32> small_screen = maxRectangle(fourth_size_rect, small_screen_aspect_ratio); Common::Rectangle<u32> small_screen = maxRectangle(fourth_size_rect, small_screen_aspect_ratio);
if (window_aspect_ratio < emulation_aspect_ratio) { if (window_aspect_ratio < emulation_aspect_ratio) {
@ -416,22 +421,35 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale, bool is_secondar
if (Settings::values.upright_screen.GetValue()) { if (Settings::values.upright_screen.GetValue()) {
if (Settings::values.swap_screen.GetValue()) { if (Settings::values.swap_screen.GetValue()) {
width = Core::kScreenBottomHeight * res_scale; width = Core::kScreenBottomHeight * res_scale;
height = (Core::kScreenBottomWidth + Core::kScreenTopWidth / 4) * res_scale; height = (Core::kScreenBottomWidth +
Core::kScreenTopWidth /
Settings::values.large_screen_proportion.GetValue()) *
res_scale;
} else { } else {
width = Core::kScreenTopHeight * res_scale; width = Core::kScreenTopHeight * res_scale;
height = (Core::kScreenTopWidth + Core::kScreenBottomWidth / 4) * res_scale; height = (Core::kScreenTopWidth +
Core::kScreenBottomWidth /
Settings::values.large_screen_proportion.GetValue()) *
res_scale;
} }
} else { } else {
if (Settings::values.swap_screen.GetValue()) { if (Settings::values.swap_screen.GetValue()) {
width = (Core::kScreenBottomWidth + Core::kScreenTopWidth / 4) * res_scale; width = (Core::kScreenBottomWidth +
Core::kScreenTopWidth /
Settings::values.large_screen_proportion.GetValue()) *
res_scale;
height = Core::kScreenBottomHeight * res_scale; height = Core::kScreenBottomHeight * res_scale;
} else { } else {
width = (Core::kScreenTopWidth + Core::kScreenBottomWidth / 4) * res_scale; width = (Core::kScreenTopWidth +
Core::kScreenBottomWidth /
Settings::values.large_screen_proportion.GetValue()) *
res_scale;
height = Core::kScreenTopHeight * res_scale; height = Core::kScreenTopHeight * res_scale;
} }
} }
layout = LargeFrameLayout(width, height, Settings::values.swap_screen.GetValue(), layout = LargeFrameLayout(width, height, Settings::values.swap_screen.GetValue(),
Settings::values.upright_screen.GetValue()); Settings::values.upright_screen.GetValue(),
Settings::values.large_screen_proportion.GetValue());
break; break;
case Settings::LayoutOption::SideScreen: case Settings::LayoutOption::SideScreen:
if (Settings::values.upright_screen.GetValue()) { if (Settings::values.upright_screen.GetValue()) {
@ -576,9 +594,12 @@ std::pair<unsigned, unsigned> GetMinimumSizeFromLayout(Settings::LayoutOption la
min_height = Core::kScreenBottomHeight; min_height = Core::kScreenBottomHeight;
break; break;
case Settings::LayoutOption::LargeScreen: case Settings::LayoutOption::LargeScreen:
min_width = Settings::values.swap_screen min_width =
? Core::kScreenTopWidth / 4 + Core::kScreenBottomWidth Settings::values.swap_screen
: Core::kScreenTopWidth + Core::kScreenBottomWidth / 4; ? Core::kScreenTopWidth / Settings::values.large_screen_proportion.GetValue() +
Core::kScreenBottomWidth
: Core::kScreenTopWidth + Core::kScreenBottomWidth /
Settings::values.large_screen_proportion.GetValue();
min_height = Core::kScreenBottomHeight; min_height = Core::kScreenBottomHeight;
break; break;
case Settings::LayoutOption::SideScreen: case Settings::LayoutOption::SideScreen:

View file

@ -83,9 +83,11 @@ FramebufferLayout SingleFrameLayout(u32 width, u32 height, bool is_swapped, bool
* @param width Window framebuffer width in pixels * @param width Window framebuffer width in pixels
* @param height Window framebuffer height in pixels * @param height Window framebuffer height in pixels
* @param is_swapped if true, the bottom screen will be the large display * @param is_swapped if true, the bottom screen will be the large display
* @param scale_factor The ratio between the large screen with respect to the smaller screen
* @return Newly created FramebufferLayout object with default screen regions initialized * @return Newly created FramebufferLayout object with default screen regions initialized
*/ */
FramebufferLayout LargeFrameLayout(u32 width, u32 height, bool is_swapped, bool upright); FramebufferLayout LargeFrameLayout(u32 width, u32 height, bool is_swapped, bool upright,
float scale_factor);
/** /**
* Factory method for constructing a Frame with the Top screen and bottom * Factory method for constructing a Frame with the Top screen and bottom