From 9ccdbc5e50fc3ff67492ce14c209100eb1528c48 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 31 Aug 2025 14:41:37 -0400 Subject: [PATCH] v3.2.3: brought back Android orientation setting as 'force landscape' --- .../android/AndroidPlatformSupport.java | 4 ++++ .../assets/messages/windows/windows.properties | 3 +-- .../shatteredpixeldungeon/SPDSettings.java | 11 ++++++++++- .../windows/WndSettings.java | 18 ++++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidPlatformSupport.java b/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidPlatformSupport.java index a23185fdc..3159d9642 100644 --- a/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidPlatformSupport.java +++ b/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidPlatformSupport.java @@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.android; import android.annotation.SuppressLint; import android.content.Context; +import android.content.pm.ActivityInfo; import android.net.ConnectivityManager; import android.os.Build; import android.view.DisplayCutout; @@ -45,6 +46,9 @@ import java.util.regex.Pattern; public class AndroidPlatformSupport extends PlatformSupport { public void updateDisplaySize(){ + AndroidLauncher.instance.setRequestedOrientation( SPDSettings.landscape() ? + ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : + ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED ); //TODO seem to be existing bugs with handling split screen here, should look into that diff --git a/core/src/main/assets/messages/windows/windows.properties b/core/src/main/assets/messages/windows/windows.properties index eb1e63b47..a9d9d3502 100644 --- a/core/src/main/assets/messages/windows/windows.properties +++ b/core/src/main/assets/messages/windows/windows.properties @@ -289,8 +289,7 @@ windows.wndsettings$displaytab.saver=Power Saver windows.wndsettings$displaytab.saver_desc=Power Saver mode draws the game at a reduced size and scales it up to fit your screen.\n\nThis will make graphics less crisp and enlarge the UI slightly, but will also improve performance and battery life.\n\nYou may need to restart the game for changes to take effect. windows.wndsettings$displaytab.okay=Okay windows.wndsettings$displaytab.cancel=Cancel -windows.wndsettings$displaytab.portrait=Switch to portrait -windows.wndsettings$displaytab.landscape=Switch to landscape +windows.wndsettings$displaytab.landscape=Force landscape windows.wndsettings$displaytab.brightness=Brightness windows.wndsettings$displaytab.dark=Dark windows.wndsettings$displaytab.bright=Bright diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java index d5ab90592..614af1a65 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java @@ -50,7 +50,7 @@ public class SPDSettings extends GameSettings { //Display public static final String KEY_FULLSCREEN = "fullscreen"; - public static final String KEY_LANDSCAPE = "landscape"; + public static final String KEY_LANDSCAPE = "force_landscape"; public static final String KEY_ZOOM = "zoom"; public static final String KEY_BRIGHTNESS = "brightness"; public static final String KEY_GRID = "visual_grid"; @@ -66,6 +66,15 @@ public class SPDSettings extends GameSettings { public static boolean fullscreen() { return getBoolean( KEY_FULLSCREEN, true ); } + + public static void landscape( boolean value ){ + put( KEY_LANDSCAPE, value ); + ((ShatteredPixelDungeon)ShatteredPixelDungeon.instance).updateDisplaySize(); + } + + public static boolean landscape(){ + return getBoolean(KEY_LANDSCAPE, false); + } public static void zoom( int value ) { put( KEY_ZOOM, value ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java index 3dc71dcf4..22109af64 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java @@ -220,6 +220,7 @@ public class WndSettings extends WndTabbed { RenderedTextBlock title; ColorBlock sep1; CheckBox chkFullscreen; + CheckBox chkLandscape; ColorBlock sep2; OptionSlider optBrightness; OptionSlider optVisGrid; @@ -250,6 +251,18 @@ public class WndSettings extends WndTabbed { } add(chkFullscreen); + if (DeviceCompat.isAndroid()) { + chkLandscape = new CheckBox(Messages.get(this, "landscape")) { + @Override + protected void onClick() { + super.onClick(); + SPDSettings.landscape(checked()); + } + }; + chkLandscape.checked(SPDSettings.landscape()); + add(chkLandscape); + } + sep2 = new ColorBlock(1, 1, 0xFF000000); add(sep2); @@ -309,6 +322,11 @@ public class WndSettings extends WndTabbed { chkFullscreen.setRect(0, bottom + GAP, width, BTN_HEIGHT); bottom = chkFullscreen.bottom(); + if (chkLandscape != null) { + chkLandscape.setRect(0, bottom + GAP, width, BTN_HEIGHT); + bottom = chkLandscape.bottom(); + } + sep2.size(width, 1); sep2.y = bottom + GAP; bottom = sep2.y + 1;