mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2025-02-18 19:06:21 +01:00
android: Refactor layout code to use LargeScreen layout instead of MobileLandscape
This commit is contained in:
parent
7e938fcdd9
commit
a319b81665
@ -27,7 +27,7 @@ class ScreenAdjustmentUtil(
|
|||||||
}
|
}
|
||||||
fun cycleLayouts() {
|
fun cycleLayouts() {
|
||||||
// TODO: figure out how to pull these from R.array
|
// TODO: figure out how to pull these from R.array
|
||||||
val landscape_values = intArrayOf(6,1,3,4,0,5);
|
val landscape_values = intArrayOf(2,1,3,4,0,5);
|
||||||
val portrait_values = intArrayOf(0,1);
|
val portrait_values = intArrayOf(0,1);
|
||||||
if (NativeLibrary.isPortraitMode) {
|
if (NativeLibrary.isPortraitMode) {
|
||||||
val current_layout = IntSetting.PORTRAIT_SCREEN_LAYOUT.int
|
val current_layout = IntSetting.PORTRAIT_SCREEN_LAYOUT.int
|
||||||
|
@ -11,13 +11,12 @@ enum class ScreenLayout(val int: Int) {
|
|||||||
LARGE_SCREEN(2),
|
LARGE_SCREEN(2),
|
||||||
SIDE_SCREEN(3),
|
SIDE_SCREEN(3),
|
||||||
HYBRID_SCREEN(4),
|
HYBRID_SCREEN(4),
|
||||||
CUSTOM_LAYOUT(5),
|
CUSTOM_LAYOUT(5);
|
||||||
MOBILE_LANDSCAPE(6);
|
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun from(int: Int): ScreenLayout {
|
fun from(int: Int): ScreenLayout {
|
||||||
return entries.firstOrNull { it.int == int } ?: MOBILE_LANDSCAPE
|
return entries.firstOrNull { it.int == int } ?: LARGE_SCREEN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -806,14 +806,14 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram
|
|||||||
ScreenLayout.CUSTOM_LAYOUT.int ->
|
ScreenLayout.CUSTOM_LAYOUT.int ->
|
||||||
R.id.menu_screen_layout_custom
|
R.id.menu_screen_layout_custom
|
||||||
|
|
||||||
else -> R.id.menu_screen_layout_landscape
|
else -> R.id.menu_screen_layout_largescreen
|
||||||
}
|
}
|
||||||
popupMenu.menu.findItem(layoutOptionMenuItem).setChecked(true)
|
popupMenu.menu.findItem(layoutOptionMenuItem).setChecked(true)
|
||||||
|
|
||||||
popupMenu.setOnMenuItemClickListener {
|
popupMenu.setOnMenuItemClickListener {
|
||||||
when (it.itemId) {
|
when (it.itemId) {
|
||||||
R.id.menu_screen_layout_landscape -> {
|
R.id.menu_screen_layout_largescreen -> {
|
||||||
screenAdjustmentUtil.changeScreenOrientation(ScreenLayout.MOBILE_LANDSCAPE.int)
|
screenAdjustmentUtil.changeScreenOrientation(ScreenLayout.LARGE_SCREEN.int)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,8 +174,18 @@ void Config::ReadValues() {
|
|||||||
ReadSetting("Renderer", Settings::values.bg_blue);
|
ReadSetting("Renderer", Settings::values.bg_blue);
|
||||||
|
|
||||||
// Layout
|
// Layout
|
||||||
Settings::values.layout_option = static_cast<Settings::LayoutOption>(sdl2_config->GetInteger(
|
// Somewhat inelegant solution to ensure layout value is between 0 and 5 on read
|
||||||
"Layout", "layout_option", static_cast<int>(Settings::LayoutOption::LargeScreen)));
|
// since older config files may have other values
|
||||||
|
int layoutInt = (int)sdl2_config->GetInteger(
|
||||||
|
"Layout", "layout_option", static_cast<int>(Settings::LayoutOption::LargeScreen));
|
||||||
|
if (layoutInt < 0 || layoutInt > 5) {
|
||||||
|
layoutInt = static_cast<int>(Settings::LayoutOption::LargeScreen);
|
||||||
|
}
|
||||||
|
Settings::values.layout_option = static_cast<Settings::LayoutOption>(layoutInt);
|
||||||
|
|
||||||
|
Settings::values.large_screen_proportion =
|
||||||
|
static_cast<float>(sdl2_config->GetReal("Layout", "large_screen_proportion", 2.25));
|
||||||
|
|
||||||
ReadSetting("Layout", Settings::values.custom_top_x);
|
ReadSetting("Layout", Settings::values.custom_top_x);
|
||||||
ReadSetting("Layout", Settings::values.custom_top_y);
|
ReadSetting("Layout", Settings::values.custom_top_y);
|
||||||
ReadSetting("Layout", Settings::values.custom_top_width);
|
ReadSetting("Layout", Settings::values.custom_top_width);
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
<group android:checkableBehavior="single">
|
<group android:checkableBehavior="single">
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_screen_layout_landscape"
|
android:id="@+id/menu_screen_layout_largescreen"
|
||||||
android:title="@string/emulation_screen_layout_landscape" />
|
android:title="@string/emulation_screen_layout_largescreen" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_screen_layout_single"
|
android:id="@+id/menu_screen_layout_single"
|
||||||
|
@ -12,19 +12,16 @@
|
|||||||
</integer-array>
|
</integer-array>
|
||||||
|
|
||||||
<string-array name="landscapeLayouts">
|
<string-array name="landscapeLayouts">
|
||||||
<item>@string/emulation_screen_layout_landscape</item>
|
<item>@string/emulation_screen_layout_largescreen</item>
|
||||||
<item>@string/emulation_screen_layout_single</item>
|
<item>@string/emulation_screen_layout_single</item>
|
||||||
<item>@string/emulation_screen_layout_sidebyside</item>
|
<item>@string/emulation_screen_layout_sidebyside</item>
|
||||||
<item>@string/emulation_screen_layout_hybrid</item>
|
<item>@string/emulation_screen_layout_hybrid</item>
|
||||||
<item>@string/emulation_screen_layout_original</item>
|
<item>@string/emulation_screen_layout_original</item>
|
||||||
<item>@string/emulation_screen_layout_custom</item>
|
<item>@string/emulation_screen_layout_custom</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<!-- start with 6 because that is the MobileLandscape layout in cpp files
|
<!-- start with 2 because that is the Large Screen layout in cpp files -->
|
||||||
- skip 0 because top/bottom rarely makes sense in landscape
|
|
||||||
- skip 2 because that is "Large Screen" which the default replaces in mobile
|
|
||||||
-->
|
|
||||||
<integer-array name="landscapeLayoutValues">
|
<integer-array name="landscapeLayoutValues">
|
||||||
<item>6</item>
|
<item>2</item>
|
||||||
<item>1</item>
|
<item>1</item>
|
||||||
<item>3</item>
|
<item>3</item>
|
||||||
<item>4</item>
|
<item>4</item>
|
||||||
|
@ -363,7 +363,7 @@
|
|||||||
<string name="emulation_open_cheats">Open Cheats</string>
|
<string name="emulation_open_cheats">Open Cheats</string>
|
||||||
<string name="emulation_switch_screen_layout">Landscape Screen Layout</string>
|
<string name="emulation_switch_screen_layout">Landscape Screen Layout</string>
|
||||||
<string name="emulation_switch_portrait_layout">Portrait Screen Layout</string>
|
<string name="emulation_switch_portrait_layout">Portrait Screen Layout</string>
|
||||||
<string name="emulation_screen_layout_landscape">Default</string>
|
<string name="emulation_screen_layout_largescreen">Large Screen</string>
|
||||||
<string name="emulation_screen_layout_portrait">Portrait</string>
|
<string name="emulation_screen_layout_portrait">Portrait</string>
|
||||||
<string name="emulation_screen_layout_single">Single Screen</string>
|
<string name="emulation_screen_layout_single">Single Screen</string>
|
||||||
<string name="emulation_screen_layout_sidebyside">Side by Side Screens</string>
|
<string name="emulation_screen_layout_sidebyside">Side by Side Screens</string>
|
||||||
|
@ -44,10 +44,6 @@ enum class LayoutOption : u32 {
|
|||||||
#endif
|
#endif
|
||||||
HybridScreen,
|
HybridScreen,
|
||||||
CustomLayout,
|
CustomLayout,
|
||||||
|
|
||||||
// Similiar to LargeScreen, but better for mobile devices in landscape mode. The screens are
|
|
||||||
// clamped to the top of the frame, and the bottom screen is a bit bigger.
|
|
||||||
MobileLandscape,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Defines the layout option for mobile portrait */
|
/** Defines the layout option for mobile portrait */
|
||||||
|
@ -232,12 +232,6 @@ void EmuWindow::UpdateCurrentFramebufferLayout(u32 width, u32 height, bool is_po
|
|||||||
Settings::values.upright_screen.GetValue());
|
Settings::values.upright_screen.GetValue());
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case Settings::LayoutOption::MobileLandscape:
|
|
||||||
layout =
|
|
||||||
Layout::LargeFrameLayout(width, height, Settings::values.swap_screen.GetValue(),
|
|
||||||
false, 2.25f, Layout::VerticalAlignment::Top);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Settings::LayoutOption::Default:
|
case Settings::LayoutOption::Default:
|
||||||
default:
|
default:
|
||||||
layout =
|
layout =
|
||||||
|
@ -204,7 +204,9 @@ FramebufferLayout LargeFrameLayout(u32 width, u32 height, bool swapped, bool upr
|
|||||||
float scale_factor, VerticalAlignment vertical_alignment) {
|
float scale_factor, VerticalAlignment vertical_alignment) {
|
||||||
ASSERT(width > 0);
|
ASSERT(width > 0);
|
||||||
ASSERT(height > 0);
|
ASSERT(height > 0);
|
||||||
|
#ifdef ANDROID
|
||||||
|
vertical_alignment = VerticalAlignment::Top;
|
||||||
|
#endif
|
||||||
FramebufferLayout res{width, height, true, true, {}, {}, !upright};
|
FramebufferLayout res{width, height, true, true, {}, {}, !upright};
|
||||||
// Split the window into two parts. Give 4x width to the main screen and 1x width to the small
|
// Split the window into two parts. Give 4x width to the main screen and 1x width to the small
|
||||||
// To do that, find the total emulation box and maximize that based on window size
|
// To do that, find the total emulation box and maximize that based on window size
|
||||||
@ -512,23 +514,6 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale, bool is_secondar
|
|||||||
Settings::values.upright_screen.GetValue(), 1,
|
Settings::values.upright_screen.GetValue(), 1,
|
||||||
VerticalAlignment::Middle);
|
VerticalAlignment::Middle);
|
||||||
|
|
||||||
case Settings::LayoutOption::MobileLandscape: {
|
|
||||||
constexpr float large_screen_proportion = 2.25f;
|
|
||||||
if (Settings::values.swap_screen.GetValue()) {
|
|
||||||
width = (Core::kScreenBottomWidth +
|
|
||||||
static_cast<int>(Core::kScreenTopWidth / large_screen_proportion)) *
|
|
||||||
res_scale;
|
|
||||||
height = Core::kScreenBottomHeight * res_scale;
|
|
||||||
} else {
|
|
||||||
width = (Core::kScreenTopWidth +
|
|
||||||
static_cast<int>(Core::kScreenBottomWidth / large_screen_proportion)) *
|
|
||||||
res_scale;
|
|
||||||
height = Core::kScreenTopHeight * res_scale;
|
|
||||||
}
|
|
||||||
return LargeFrameLayout(width, height, Settings::values.swap_screen.GetValue(), false,
|
|
||||||
large_screen_proportion, VerticalAlignment::Top);
|
|
||||||
}
|
|
||||||
|
|
||||||
case Settings::LayoutOption::Default:
|
case Settings::LayoutOption::Default:
|
||||||
default:
|
default:
|
||||||
width = Core::kScreenTopWidth * res_scale;
|
width = Core::kScreenTopWidth * res_scale;
|
||||||
@ -579,10 +564,7 @@ FramebufferLayout GetCardboardSettings(const FramebufferLayout& layout) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (Settings::values.layout_option.GetValue()) {
|
switch (Settings::values.layout_option.GetValue()) {
|
||||||
case Settings::LayoutOption::MobileLandscape:
|
|
||||||
case Settings::LayoutOption::SideScreen:
|
case Settings::LayoutOption::SideScreen:
|
||||||
// If orientation is portrait, only use MobilePortrait
|
|
||||||
|
|
||||||
cardboard_screen_width = top_screen_width + bottom_screen_width;
|
cardboard_screen_width = top_screen_width + bottom_screen_width;
|
||||||
cardboard_screen_height = is_swapped ? bottom_screen_height : top_screen_height;
|
cardboard_screen_height = is_swapped ? bottom_screen_height : top_screen_height;
|
||||||
if (is_swapped)
|
if (is_swapped)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user