android: Refactor layout code to use LargeScreen layout instead of MobileLandscape

This commit is contained in:
David Griswold
2024-08-21 17:51:45 -03:00
committed by OpenSauce04
parent 10bf612cb0
commit 42a0a72c96
10 changed files with 27 additions and 49 deletions

View File

@@ -28,7 +28,7 @@ class ScreenAdjustmentUtil(
}
fun cycleLayouts() {
// 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);
if (NativeLibrary.isPortraitMode) {
val current_layout = IntSetting.PORTRAIT_SCREEN_LAYOUT.int

View File

@@ -11,13 +11,12 @@ enum class ScreenLayout(val int: Int) {
LARGE_SCREEN(2),
SIDE_SCREEN(3),
HYBRID_SCREEN(4),
CUSTOM_LAYOUT(5),
MOBILE_LANDSCAPE(6);
CUSTOM_LAYOUT(5);
companion object {
fun from(int: Int): ScreenLayout {
return entries.firstOrNull { it.int == int } ?: MOBILE_LANDSCAPE
return entries.firstOrNull { it.int == int } ?: LARGE_SCREEN
}
}
}

View File

@@ -828,14 +828,14 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram
ScreenLayout.CUSTOM_LAYOUT.int ->
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.setOnMenuItemClickListener {
when (it.itemId) {
R.id.menu_screen_layout_landscape -> {
screenAdjustmentUtil.changeScreenOrientation(ScreenLayout.MOBILE_LANDSCAPE.int)
R.id.menu_screen_layout_largescreen -> {
screenAdjustmentUtil.changeScreenOrientation(ScreenLayout.LARGE_SCREEN.int)
true
}

View File

@@ -174,8 +174,18 @@ void Config::ReadValues() {
ReadSetting("Renderer", Settings::values.delay_game_render_thread_us);
// Layout
Settings::values.layout_option = static_cast<Settings::LayoutOption>(sdl2_config->GetInteger(
"Layout", "layout_option", static_cast<int>(Settings::LayoutOption::LargeScreen)));
// Somewhat inelegant solution to ensure layout value is between 0 and 5 on read
// 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_y);
ReadSetting("Layout", Settings::values.custom_top_width);

View File

@@ -4,8 +4,8 @@
<group android:checkableBehavior="single">
<item
android:id="@+id/menu_screen_layout_landscape"
android:title="@string/emulation_screen_layout_landscape" />
android:id="@+id/menu_screen_layout_largescreen"
android:title="@string/emulation_screen_layout_largescreen" />
<item
android:id="@+id/menu_screen_layout_single"

View File

@@ -12,19 +12,16 @@
</integer-array>
<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_sidebyside</item>
<item>@string/emulation_screen_layout_hybrid</item>
<item>@string/emulation_screen_layout_original</item>
<item>@string/emulation_screen_layout_custom</item>
</string-array>
<!-- start with 6 because that is the MobileLandscape 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
-->
<!-- start with 2 because that is the Large Screen layout in cpp files -->
<integer-array name="landscapeLayoutValues">
<item>6</item>
<item>2</item>
<item>1</item>
<item>3</item>
<item>4</item>

View File

@@ -367,7 +367,7 @@
<string name="emulation_open_cheats">Open Cheats</string>
<string name="emulation_switch_screen_layout">Landscape 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_single">Single Screen</string>
<string name="emulation_screen_layout_sidebyside">Side by Side Screens</string>