v3.2.2: Removed power saver, no longer useful now that we're Android 5+

This commit is contained in:
Evan Debenham
2025-08-17 11:44:57 -04:00
parent 83535d9723
commit 45c8eb3e70
8 changed files with 9 additions and 168 deletions

View File

@@ -33,36 +33,7 @@ public class InputHandler extends InputAdapter {
private InputMultiplexer multiplexer;
public InputHandler( Input input ){
//An input multiplexer, with additional coord tweaks for power saver mode
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);
}
};
multiplexer = new InputMultiplexer();
input.setInputProcessor(multiplexer);
addInputProcessor(this);
input.setCatchKey( Input.Keys.BACK, true);

View File

@@ -21,7 +21,6 @@
package com.watabou.noosa;
import com.badlogic.gdx.Application;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.controllers.Controllers;
@@ -46,10 +45,6 @@ import java.io.StringWriter;
public class Game implements ApplicationListener {
public static Game instance;
//actual size of the display
public static int dispWidth;
public static int dispHeight;
// Size of the EGL surface view
public static int width;
@@ -93,13 +88,12 @@ public class Game implements ApplicationListener {
@Override
public void create() {
dispHeight = Gdx.graphics.getDisplayMode().height;
dispWidth = Gdx.graphics.getDisplayMode().width;
density = Gdx.graphics.getDensity();
if (density == Float.POSITIVE_INFINITY){
density = 100f / 160f; //assume 100PPI if density can't be found
} else if (DeviceCompat.isDesktop()) {
int dispWidth = Gdx.graphics.getDisplayMode().width;
int dispHeight = Gdx.graphics.getDisplayMode().height;
float reportedWidth = dispWidth / Gdx.graphics.getPpiX();
float reportedHeight = dispHeight / Gdx.graphics.getPpiY();
@@ -148,12 +142,6 @@ public class Game implements ApplicationListener {
Game.width = width;
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();
}
}

View File

@@ -12,8 +12,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Note that the game doesn't truly support small screen resolutions,
it instead forces downscaling to work on these displays.-->
<!-- Hilariously small screens still exist but are usually high enough DPI to work now -->
<supports-screens
android:smallScreens="true"
android:normalScreens="true"

View File

@@ -25,19 +25,15 @@ import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.net.ConnectivityManager;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.view.View;
import android.view.WindowManager;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.android.AndroidGraphics;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.g2d.PixmapPacker;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.watabou.noosa.Game;
import com.watabou.utils.PlatformSupport;
import java.util.HashMap;
@@ -52,63 +48,7 @@ public class AndroidPlatformSupport extends PlatformSupport {
ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE :
ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT );
}
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();
}
});
}
//TODO seem to be existing bugs with handling split screen here, should look into that
}
public void updateSystemUI() {

View File

@@ -51,7 +51,6 @@ public class SPDSettings extends GameSettings {
public static final String KEY_FULLSCREEN = "fullscreen";
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_BRIGHTNESS = "brightness";
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 ) {
put( KEY_ZOOM, value );
}

View File

@@ -78,7 +78,6 @@ public class PixelScene extends Scene {
public static int defaultZoom = 0;
public static int maxDefaultZoom = 0;
public static int maxScreenZoom = 0;
public static float minZoom;
public static float maxZoom;
@@ -122,7 +121,7 @@ public class PixelScene extends Scene {
}
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();
if (defaultZoom < Math.ceil( Game.density * 2 ) || defaultZoom > maxDefaultZoom){

View File

@@ -221,7 +221,6 @@ public class WndSettings extends WndTabbed {
ColorBlock sep1;
CheckBox chkFullscreen;
OptionSlider optScale;
CheckBox chkSaver;
RedButton btnOrientation;
ColorBlock sep2;
OptionSlider optBrightness;
@@ -253,39 +252,7 @@ public class WndSettings extends WndTabbed {
}
add(chkFullscreen);
//power saver is being slowly phased out, only show it on old (4.3-) android devices
// 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 );
}
//TODO change to respect auto-rotation when updating Android SDK?
if (DeviceCompat.isAndroid()) {
Boolean landscape = SPDSettings.landscape();
if (landscape == null){
@@ -359,19 +326,8 @@ public class WndSettings extends WndTabbed {
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);
bottom = chkFullscreen.bottom();
if (chkSaver != null) {
chkSaver.setRect(0, bottom + GAP, width, BTN_HEIGHT);
bottom = chkSaver.bottom();
}
}
chkFullscreen.setRect(0, bottom + GAP, width, BTN_HEIGHT);
bottom = chkFullscreen.bottom();
if (btnOrientation != null) {
btnOrientation.setRect(0, bottom + GAP, width, BTN_HEIGHT);

View File

@@ -74,10 +74,8 @@ public class IOSPlatformSupport extends PlatformSupport {
int insetChange = Gdx.graphics.getSafeInsetBottom() - Game.bottomInset;
Game.bottomInset = Gdx.graphics.getSafeInsetBottom();
Game.height -= insetChange;
Game.dispHeight = Game.height;
} else {
Game.height += Game.bottomInset;
Game.dispHeight = Game.height;
Game.bottomInset = 0;
}
Gdx.gl.glViewport(0, Game.bottomInset, Game.width, Game.height);