v0.4.3a: game now defaults to landscape on appropriate tablets

This commit is contained in:
Evan Debenham
2016-10-18 02:01:21 -04:00
parent 64087bf3ed
commit a6852b1b97
3 changed files with 17 additions and 10 deletions
+1 -1
View File
@@ -31,7 +31,7 @@
android:label="@string/app_name" android:label="@string/app_name"
android:name=".ShatteredPixelDungeon" android:name=".ShatteredPixelDungeon"
android:configChanges="keyboardHidden|orientation|screenSize" android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="sensorPortrait"> android:screenOrientation="nosensor">
<intent-filter > <intent-filter >
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
@@ -58,6 +58,10 @@ enum Preferences {
return prefs; return prefs;
} }
boolean contains( String key ){
return get().contains( key );
}
int getInt( String key, int defValue ) { int getInt( String key, int defValue ) {
return getInt(key, defValue, Integer.MIN_VALUE, Integer.MAX_VALUE); return getInt(key, defValue, Integer.MIN_VALUE, Integer.MAX_VALUE);
} }
@@ -172,6 +172,10 @@ public class ShatteredPixelDungeon extends Game {
updateImmersiveMode(); updateImmersiveMode();
if (Preferences.INSTANCE.contains( Preferences.KEY_LANDSCAPE )){
landscape ( Preferences.INSTANCE.getBoolean( Preferences.KEY_LANDSCAPE, false));
} else {
DisplayMetrics metrics = new DisplayMetrics(); DisplayMetrics metrics = new DisplayMetrics();
if (immersed() && Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1) if (immersed() && Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1)
getWindowManager().getDefaultDisplay().getRealMetrics( metrics ); getWindowManager().getDefaultDisplay().getRealMetrics( metrics );
@@ -179,8 +183,7 @@ public class ShatteredPixelDungeon extends Game {
getWindowManager().getDefaultDisplay().getMetrics( metrics ); getWindowManager().getDefaultDisplay().getMetrics( metrics );
boolean landscape = metrics.widthPixels > metrics.heightPixels; boolean landscape = metrics.widthPixels > metrics.heightPixels;
if (Preferences.INSTANCE.getBoolean( Preferences.KEY_LANDSCAPE, false ) != landscape) { landscape( landscape );
landscape( !landscape );
} }
Music.INSTANCE.enable( music() ); Music.INSTANCE.enable( music() );