v3.2.2: Removed power saver, no longer useful now that we're Android 5+
This commit is contained in:
@@ -33,36 +33,7 @@ public class InputHandler extends InputAdapter {
|
|||||||
private InputMultiplexer multiplexer;
|
private InputMultiplexer multiplexer;
|
||||||
|
|
||||||
public InputHandler( Input input ){
|
public InputHandler( Input input ){
|
||||||
//An input multiplexer, with additional coord tweaks for power saver mode
|
multiplexer = new InputMultiplexer();
|
||||||
multiplexer = new InputMultiplexer(){
|
|
||||||
@Override
|
|
||||||
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
|
|
||||||
screenX /= (Game.dispWidth / (float)Game.width);
|
|
||||||
screenY /= (Game.dispHeight / (float)Game.height);
|
|
||||||
return super.touchDown(screenX, screenY, pointer, button);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean touchDragged(int screenX, int screenY, int pointer) {
|
|
||||||
screenX /= (Game.dispWidth / (float)Game.width);
|
|
||||||
screenY /= (Game.dispHeight / (float)Game.height);
|
|
||||||
return super.touchDragged(screenX, screenY, pointer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
|
|
||||||
screenX /= (Game.dispWidth / (float)Game.width);
|
|
||||||
screenY /= (Game.dispHeight / (float)Game.height);
|
|
||||||
return super.touchUp(screenX, screenY, pointer, button);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean mouseMoved(int screenX, int screenY) {
|
|
||||||
screenX /= (Game.dispWidth / (float)Game.width);
|
|
||||||
screenY /= (Game.dispHeight / (float)Game.height);
|
|
||||||
return super.mouseMoved(screenX, screenY);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
input.setInputProcessor(multiplexer);
|
input.setInputProcessor(multiplexer);
|
||||||
addInputProcessor(this);
|
addInputProcessor(this);
|
||||||
input.setCatchKey( Input.Keys.BACK, true);
|
input.setCatchKey( Input.Keys.BACK, true);
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
package com.watabou.noosa;
|
package com.watabou.noosa;
|
||||||
|
|
||||||
import com.badlogic.gdx.Application;
|
|
||||||
import com.badlogic.gdx.ApplicationListener;
|
import com.badlogic.gdx.ApplicationListener;
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.controllers.Controllers;
|
import com.badlogic.gdx.controllers.Controllers;
|
||||||
@@ -47,10 +46,6 @@ public class Game implements ApplicationListener {
|
|||||||
|
|
||||||
public static Game instance;
|
public static Game instance;
|
||||||
|
|
||||||
//actual size of the display
|
|
||||||
public static int dispWidth;
|
|
||||||
public static int dispHeight;
|
|
||||||
|
|
||||||
// Size of the EGL surface view
|
// Size of the EGL surface view
|
||||||
public static int width;
|
public static int width;
|
||||||
public static int height;
|
public static int height;
|
||||||
@@ -93,13 +88,12 @@ public class Game implements ApplicationListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
dispHeight = Gdx.graphics.getDisplayMode().height;
|
|
||||||
dispWidth = Gdx.graphics.getDisplayMode().width;
|
|
||||||
|
|
||||||
density = Gdx.graphics.getDensity();
|
density = Gdx.graphics.getDensity();
|
||||||
if (density == Float.POSITIVE_INFINITY){
|
if (density == Float.POSITIVE_INFINITY){
|
||||||
density = 100f / 160f; //assume 100PPI if density can't be found
|
density = 100f / 160f; //assume 100PPI if density can't be found
|
||||||
} else if (DeviceCompat.isDesktop()) {
|
} else if (DeviceCompat.isDesktop()) {
|
||||||
|
int dispWidth = Gdx.graphics.getDisplayMode().width;
|
||||||
|
int dispHeight = Gdx.graphics.getDisplayMode().height;
|
||||||
float reportedWidth = dispWidth / Gdx.graphics.getPpiX();
|
float reportedWidth = dispWidth / Gdx.graphics.getPpiX();
|
||||||
float reportedHeight = dispHeight / Gdx.graphics.getPpiY();
|
float reportedHeight = dispHeight / Gdx.graphics.getPpiY();
|
||||||
|
|
||||||
@@ -148,12 +142,6 @@ public class Game implements ApplicationListener {
|
|||||||
Game.width = width;
|
Game.width = width;
|
||||||
Game.height = height;
|
Game.height = height;
|
||||||
|
|
||||||
//TODO might be better to put this in platform support
|
|
||||||
if (Gdx.app.getType() != Application.ApplicationType.Android){
|
|
||||||
Game.dispWidth = Game.width;
|
|
||||||
Game.dispHeight = Game.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
resetScene();
|
resetScene();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,7 @@
|
|||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
|
||||||
<!-- Note that the game doesn't truly support small screen resolutions,
|
<!-- Hilariously small screens still exist but are usually high enough DPI to work now -->
|
||||||
it instead forces downscaling to work on these displays.-->
|
|
||||||
<supports-screens
|
<supports-screens
|
||||||
android:smallScreens="true"
|
android:smallScreens="true"
|
||||||
android:normalScreens="true"
|
android:normalScreens="true"
|
||||||
|
|||||||
@@ -25,19 +25,15 @@ import android.annotation.SuppressLint;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.opengl.GLSurfaceView;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.backends.android.AndroidGraphics;
|
|
||||||
import com.badlogic.gdx.graphics.Pixmap;
|
import com.badlogic.gdx.graphics.Pixmap;
|
||||||
import com.badlogic.gdx.graphics.g2d.PixmapPacker;
|
import com.badlogic.gdx.graphics.g2d.PixmapPacker;
|
||||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
|
||||||
import com.watabou.noosa.Game;
|
|
||||||
import com.watabou.utils.PlatformSupport;
|
import com.watabou.utils.PlatformSupport;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -52,63 +48,7 @@ public class AndroidPlatformSupport extends PlatformSupport {
|
|||||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE :
|
ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE :
|
||||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT );
|
ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT );
|
||||||
}
|
}
|
||||||
|
//TODO seem to be existing bugs with handling split screen here, should look into that
|
||||||
GLSurfaceView view = (GLSurfaceView) ((AndroidGraphics)Gdx.graphics).getView();
|
|
||||||
|
|
||||||
if (view.getMeasuredWidth() == 0 || view.getMeasuredHeight() == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Game.dispWidth = view.getMeasuredWidth();
|
|
||||||
Game.dispHeight = view.getMeasuredHeight();
|
|
||||||
|
|
||||||
boolean fullscreen = Build.VERSION.SDK_INT < Build.VERSION_CODES.N
|
|
||||||
|| !AndroidLauncher.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 renderWidth = dispRatio > 1 ? PixelScene.MIN_WIDTH_L : PixelScene.MIN_WIDTH_P;
|
|
||||||
float renderHeight = dispRatio > 1 ? PixelScene.MIN_HEIGHT_L : PixelScene.MIN_HEIGHT_P;
|
|
||||||
|
|
||||||
if (SPDSettings.powerSaver() && fullscreen){
|
|
||||||
|
|
||||||
int maxZoom = (int)Math.min(Game.dispWidth/renderWidth, Game.dispHeight/renderHeight);
|
|
||||||
|
|
||||||
renderWidth *= Math.max( 2, Math.round(1f + maxZoom*0.4f));
|
|
||||||
renderHeight *= Math.max( 2, Math.round(1f + maxZoom*0.4f));
|
|
||||||
|
|
||||||
if (dispRatio > renderWidth / renderHeight){
|
|
||||||
renderWidth = renderHeight * dispRatio;
|
|
||||||
} else {
|
|
||||||
renderHeight = renderWidth / dispRatio;
|
|
||||||
}
|
|
||||||
|
|
||||||
final int finalW = Math.round(renderWidth);
|
|
||||||
final int finalH = Math.round(renderHeight);
|
|
||||||
if (finalW != Game.width || finalH != Game.height){
|
|
||||||
|
|
||||||
AndroidLauncher.instance.runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
view.getHolder().setFixedSize(finalW, finalH);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
AndroidLauncher.instance.runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
view.getHolder().setSizeFromLayout();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateSystemUI() {
|
public void updateSystemUI() {
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ public class SPDSettings extends GameSettings {
|
|||||||
|
|
||||||
public static final String KEY_FULLSCREEN = "fullscreen";
|
public static final String KEY_FULLSCREEN = "fullscreen";
|
||||||
public static final String KEY_LANDSCAPE = "landscape";
|
public static final String KEY_LANDSCAPE = "landscape";
|
||||||
public static final String KEY_POWER_SAVER = "power_saver";
|
|
||||||
public static final String KEY_ZOOM = "zoom";
|
public static final String KEY_ZOOM = "zoom";
|
||||||
public static final String KEY_BRIGHTNESS = "brightness";
|
public static final String KEY_BRIGHTNESS = "brightness";
|
||||||
public static final String KEY_GRID = "visual_grid";
|
public static final String KEY_GRID = "visual_grid";
|
||||||
@@ -83,15 +82,6 @@ public class SPDSettings extends GameSettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void powerSaver( boolean value ){
|
|
||||||
put( KEY_POWER_SAVER, value );
|
|
||||||
((ShatteredPixelDungeon)ShatteredPixelDungeon.instance).updateDisplaySize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean powerSaver(){
|
|
||||||
return getBoolean( KEY_POWER_SAVER, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void zoom( int value ) {
|
public static void zoom( int value ) {
|
||||||
put( KEY_ZOOM, value );
|
put( KEY_ZOOM, value );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ public class PixelScene extends Scene {
|
|||||||
|
|
||||||
public static int defaultZoom = 0;
|
public static int defaultZoom = 0;
|
||||||
public static int maxDefaultZoom = 0;
|
public static int maxDefaultZoom = 0;
|
||||||
public static int maxScreenZoom = 0;
|
|
||||||
public static float minZoom;
|
public static float minZoom;
|
||||||
public static float maxZoom;
|
public static float maxZoom;
|
||||||
|
|
||||||
@@ -122,7 +121,7 @@ public class PixelScene extends Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
maxDefaultZoom = (int)Math.min(Game.width/minWidth, Game.height/minHeight);
|
maxDefaultZoom = (int)Math.min(Game.width/minWidth, Game.height/minHeight);
|
||||||
maxScreenZoom = (int)Math.min(Game.dispWidth/minWidth, Game.dispHeight/minHeight);
|
maxDefaultZoom = Math.max(2, maxDefaultZoom);
|
||||||
defaultZoom = SPDSettings.scale();
|
defaultZoom = SPDSettings.scale();
|
||||||
|
|
||||||
if (defaultZoom < Math.ceil( Game.density * 2 ) || defaultZoom > maxDefaultZoom){
|
if (defaultZoom < Math.ceil( Game.density * 2 ) || defaultZoom > maxDefaultZoom){
|
||||||
|
|||||||
@@ -221,7 +221,6 @@ public class WndSettings extends WndTabbed {
|
|||||||
ColorBlock sep1;
|
ColorBlock sep1;
|
||||||
CheckBox chkFullscreen;
|
CheckBox chkFullscreen;
|
||||||
OptionSlider optScale;
|
OptionSlider optScale;
|
||||||
CheckBox chkSaver;
|
|
||||||
RedButton btnOrientation;
|
RedButton btnOrientation;
|
||||||
ColorBlock sep2;
|
ColorBlock sep2;
|
||||||
OptionSlider optBrightness;
|
OptionSlider optBrightness;
|
||||||
@@ -253,39 +252,7 @@ public class WndSettings extends WndTabbed {
|
|||||||
}
|
}
|
||||||
add(chkFullscreen);
|
add(chkFullscreen);
|
||||||
|
|
||||||
//power saver is being slowly phased out, only show it on old (4.3-) android devices
|
//TODO change to respect auto-rotation when updating Android SDK?
|
||||||
// this is being phased out as the setting is useless on all but very old devices anyway
|
|
||||||
// and support is going to be dropped for 4.3- in the forseeable future
|
|
||||||
if (DeviceCompat.isAndroid() && PixelScene.maxScreenZoom >= 2
|
|
||||||
&& (SPDSettings.powerSaver() || !DeviceCompat.supportsFullScreen())) {
|
|
||||||
chkSaver = new CheckBox(Messages.get(this, "saver")) {
|
|
||||||
@Override
|
|
||||||
protected void onClick() {
|
|
||||||
super.onClick();
|
|
||||||
if (checked()) {
|
|
||||||
checked(!checked());
|
|
||||||
ShatteredPixelDungeon.scene().add(new WndOptions(Icons.get(Icons.DISPLAY),
|
|
||||||
Messages.get(DisplayTab.class, "saver"),
|
|
||||||
Messages.get(DisplayTab.class, "saver_desc"),
|
|
||||||
Messages.get(DisplayTab.class, "okay"),
|
|
||||||
Messages.get(DisplayTab.class, "cancel")) {
|
|
||||||
@Override
|
|
||||||
protected void onSelect(int index) {
|
|
||||||
if (index == 0) {
|
|
||||||
checked(!checked());
|
|
||||||
SPDSettings.powerSaver(checked());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
SPDSettings.powerSaver(checked());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
chkSaver.checked( SPDSettings.powerSaver() );
|
|
||||||
add( chkSaver );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DeviceCompat.isAndroid()) {
|
if (DeviceCompat.isAndroid()) {
|
||||||
Boolean landscape = SPDSettings.landscape();
|
Boolean landscape = SPDSettings.landscape();
|
||||||
if (landscape == null){
|
if (landscape == null){
|
||||||
@@ -359,20 +326,9 @@ public class WndSettings extends WndTabbed {
|
|||||||
|
|
||||||
bottom = sep1.y + 1;
|
bottom = sep1.y + 1;
|
||||||
|
|
||||||
if (width > 200 && chkSaver != null) {
|
|
||||||
chkFullscreen.setRect(0, bottom + GAP, width/2-1, BTN_HEIGHT);
|
|
||||||
chkSaver.setRect(chkFullscreen.right()+ GAP, bottom + GAP, width/2-1, BTN_HEIGHT);
|
|
||||||
bottom = chkFullscreen.bottom();
|
|
||||||
} else {
|
|
||||||
chkFullscreen.setRect(0, bottom + GAP, width, BTN_HEIGHT);
|
chkFullscreen.setRect(0, bottom + GAP, width, BTN_HEIGHT);
|
||||||
bottom = chkFullscreen.bottom();
|
bottom = chkFullscreen.bottom();
|
||||||
|
|
||||||
if (chkSaver != null) {
|
|
||||||
chkSaver.setRect(0, bottom + GAP, width, BTN_HEIGHT);
|
|
||||||
bottom = chkSaver.bottom();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (btnOrientation != null) {
|
if (btnOrientation != null) {
|
||||||
btnOrientation.setRect(0, bottom + GAP, width, BTN_HEIGHT);
|
btnOrientation.setRect(0, bottom + GAP, width, BTN_HEIGHT);
|
||||||
bottom = btnOrientation.bottom();
|
bottom = btnOrientation.bottom();
|
||||||
|
|||||||
@@ -74,10 +74,8 @@ public class IOSPlatformSupport extends PlatformSupport {
|
|||||||
int insetChange = Gdx.graphics.getSafeInsetBottom() - Game.bottomInset;
|
int insetChange = Gdx.graphics.getSafeInsetBottom() - Game.bottomInset;
|
||||||
Game.bottomInset = Gdx.graphics.getSafeInsetBottom();
|
Game.bottomInset = Gdx.graphics.getSafeInsetBottom();
|
||||||
Game.height -= insetChange;
|
Game.height -= insetChange;
|
||||||
Game.dispHeight = Game.height;
|
|
||||||
} else {
|
} else {
|
||||||
Game.height += Game.bottomInset;
|
Game.height += Game.bottomInset;
|
||||||
Game.dispHeight = Game.height;
|
|
||||||
Game.bottomInset = 0;
|
Game.bottomInset = 0;
|
||||||
}
|
}
|
||||||
Gdx.gl.glViewport(0, Game.bottomInset, Game.width, Game.height);
|
Gdx.gl.glViewport(0, Game.bottomInset, Game.width, Game.height);
|
||||||
|
|||||||
Reference in New Issue
Block a user