v0.9.4: reverted removal of orientation control from Android version

This commit is contained in:
Evan Debenham 2021-07-09 18:39:09 -04:00
parent ed5d5a56ee
commit 04d8278950
5 changed files with 41 additions and 1 deletions

View File

@ -39,7 +39,7 @@
<activity <activity
android:label="${appName}" android:label="${appName}"
android:name=".AndroidGame" android:name=".AndroidGame"
android:screenOrientation="user" android:screenOrientation="nosensor"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize"> android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize">
</activity> </activity>

View File

@ -89,6 +89,13 @@ public class AndroidGame extends AndroidApplication {
instance = this; instance = this;
} }
//set desired orientation (if it exists) before initializing the app.
if (SPDSettings.landscape() != null) {
instance.setRequestedOrientation( SPDSettings.landscape() ?
ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE :
ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT );
}
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
config.depth = 0; config.depth = 0;
if (DeviceCompat.legacyDevice()) { if (DeviceCompat.legacyDevice()) {

View File

@ -55,6 +55,12 @@ import java.util.regex.Pattern;
public class AndroidPlatformSupport extends PlatformSupport { public class AndroidPlatformSupport extends PlatformSupport {
public void updateDisplaySize(){ public void updateDisplaySize(){
if (SPDSettings.landscape() != null) {
AndroidGame.instance.setRequestedOrientation( SPDSettings.landscape() ?
ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE :
ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT );
}
GLSurfaceView view = (GLSurfaceView) ((AndroidGraphics)Gdx.graphics).getView(); GLSurfaceView view = (GLSurfaceView) ((AndroidGraphics)Gdx.graphics).getView();
if (view.getMeasuredWidth() == 0 || view.getMeasuredHeight() == 0) if (view.getMeasuredWidth() == 0 || view.getMeasuredHeight() == 0)
@ -66,6 +72,13 @@ public class AndroidPlatformSupport extends PlatformSupport {
boolean fullscreen = Build.VERSION.SDK_INT < Build.VERSION_CODES.N boolean fullscreen = Build.VERSION.SDK_INT < Build.VERSION_CODES.N
|| !AndroidGame.instance.isInMultiWindowMode(); || !AndroidGame.instance.isInMultiWindowMode();
if (fullscreen && SPDSettings.landscape() != null
&& (Game.dispWidth >= Game.dispHeight) != SPDSettings.landscape()){
int tmp = Game.dispWidth;
Game.dispWidth = Game.dispHeight;
Game.dispHeight = tmp;
}
float dispRatio = Game.dispWidth / (float)Game.dispHeight; float dispRatio = Game.dispWidth / (float)Game.dispHeight;
float renderWidth = dispRatio > 1 ? PixelScene.MIN_WIDTH_L : PixelScene.MIN_WIDTH_P; float renderWidth = dispRatio > 1 ? PixelScene.MIN_WIDTH_L : PixelScene.MIN_WIDTH_P;

View File

@ -164,6 +164,8 @@ 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.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.okay=Okay
windows.wndsettings$displaytab.cancel=Cancel windows.wndsettings$displaytab.cancel=Cancel
windows.wndsettings$displaytab.portrait=Switch to portrait
windows.wndsettings$displaytab.landscape=Switch to landscape
windows.wndsettings$displaytab.scale=Display Scale windows.wndsettings$displaytab.scale=Display Scale
windows.wndsettings$displaytab.brightness=Brightness windows.wndsettings$displaytab.brightness=Brightness
windows.wndsettings$displaytab.dark=Dark windows.wndsettings$displaytab.dark=Dark

View File

@ -192,6 +192,7 @@ public class WndSettings extends WndTabbed {
CheckBox chkFullscreen; CheckBox chkFullscreen;
OptionSlider optScale; OptionSlider optScale;
CheckBox chkSaver; CheckBox chkSaver;
RedButton btnOrientation;
ColorBlock sep2; ColorBlock sep2;
OptionSlider optBrightness; OptionSlider optBrightness;
OptionSlider optVisGrid; OptionSlider optVisGrid;
@ -267,6 +268,18 @@ public class WndSettings extends WndTabbed {
add( chkSaver ); add( chkSaver );
} }
if (DeviceCompat.isAndroid()) {
btnOrientation = new RedButton(PixelScene.landscape() ?
Messages.get(this, "portrait")
: Messages.get(this, "landscape")) {
@Override
protected void onClick() {
SPDSettings.landscape(!PixelScene.landscape());
}
};
add(btnOrientation);
}
sep2 = new ColorBlock(1, 1, 0xFF000000); sep2 = new ColorBlock(1, 1, 0xFF000000);
add(sep2); add(sep2);
@ -317,6 +330,11 @@ public class WndSettings extends WndTabbed {
} }
} }
if (btnOrientation != null) {
btnOrientation.setRect(0, bottom + GAP, width, BTN_HEIGHT);
bottom = btnOrientation.bottom();
}
if (optScale != null){ if (optScale != null){
optScale.setRect(0, bottom + GAP, width, SLIDER_HEIGHT); optScale.setRect(0, bottom + GAP, width, SLIDER_HEIGHT);
bottom = optScale.bottom(); bottom = optScale.bottom();