v0.3.1: reworked UI scaling, now multiplier is user-selectable
This commit is contained in:
parent
dae5aca01b
commit
d3ea235f61
|
@ -30,7 +30,7 @@ enum Preferences {
|
|||
|
||||
public static final String KEY_LANDSCAPE = "landscape";
|
||||
public static final String KEY_IMMERSIVE = "immersive";
|
||||
public static final String KEY_SCALE_UP = "scaleup";
|
||||
public static final String KEY_SCALE = "scale";
|
||||
public static final String KEY_MUSIC = "music";
|
||||
public static final String KEY_SOUND_FX = "soundfx";
|
||||
public static final String KEY_ZOOM = "zoom";
|
||||
|
|
|
@ -200,8 +200,8 @@ public class ShatteredPixelDungeon extends Game {
|
|||
return width > height;
|
||||
}
|
||||
|
||||
public static void scaleUp( boolean value ) {
|
||||
Preferences.INSTANCE.put( Preferences.KEY_SCALE_UP, value );
|
||||
public static void scale( int value ) {
|
||||
Preferences.INSTANCE.put( Preferences.KEY_SCALE, value );
|
||||
switchScene( TitleScene.class );
|
||||
}
|
||||
|
||||
|
@ -259,8 +259,8 @@ public class ShatteredPixelDungeon extends Game {
|
|||
|
||||
// *****************************
|
||||
|
||||
public static boolean scaleUp() {
|
||||
return Preferences.INSTANCE.getBoolean( Preferences.KEY_SCALE_UP, true );
|
||||
public static int scale() {
|
||||
return Preferences.INSTANCE.getInt( Preferences.KEY_SCALE, 0 );
|
||||
}
|
||||
|
||||
public static void zoom( int value ) {
|
||||
|
|
|
@ -49,7 +49,8 @@ public class PixelScene extends Scene {
|
|||
public static final float MIN_WIDTH_L = 224;
|
||||
public static final float MIN_HEIGHT_L = 160;
|
||||
|
||||
public static float defaultZoom = 0;
|
||||
public static int defaultZoom = 0;
|
||||
public static int maxDefaultZoom = 0;
|
||||
public static float minZoom;
|
||||
public static float maxZoom;
|
||||
|
||||
|
@ -77,25 +78,22 @@ public class PixelScene extends Scene {
|
|||
minHeight = MIN_HEIGHT_P;
|
||||
}
|
||||
|
||||
defaultZoom = (int)Math.ceil( Game.density * 2.5 );
|
||||
while ((
|
||||
Game.width / defaultZoom < minWidth ||
|
||||
Game.height / defaultZoom < minHeight
|
||||
defaultZoom = ShatteredPixelDungeon.scale();
|
||||
if (defaultZoom < Game.density){
|
||||
defaultZoom = (int)Math.ceil( Game.density * 2.5 );
|
||||
while ((
|
||||
Game.width / defaultZoom < minWidth ||
|
||||
Game.height / defaultZoom < minHeight
|
||||
) && defaultZoom > 1) {
|
||||
|
||||
defaultZoom--;
|
||||
}
|
||||
|
||||
if (ShatteredPixelDungeon.scaleUp()) {
|
||||
while (
|
||||
Game.width / (defaultZoom + 1) >= minWidth &&
|
||||
Game.height / (defaultZoom + 1) >= minHeight) {
|
||||
defaultZoom++;
|
||||
defaultZoom--;
|
||||
}
|
||||
ShatteredPixelDungeon.scale(defaultZoom);
|
||||
}
|
||||
|
||||
maxDefaultZoom = (int)Math.min(Game.width/minWidth, Game.height/minHeight);
|
||||
|
||||
minZoom = 1;
|
||||
maxZoom = defaultZoom * 2;
|
||||
|
||||
|
||||
Camera.reset( new PixelCamera( defaultZoom ) );
|
||||
|
||||
|
|
|
@ -21,9 +21,11 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.TitleScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Toolbar;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
|
@ -37,7 +39,7 @@ public class WndSettings extends Window {
|
|||
private static final String TXT_ZOOM_OUT = "-";
|
||||
private static final String TXT_ZOOM_DEFAULT = "Default Zoom";
|
||||
|
||||
private static final String TXT_SCALE_UP = "Scale up UI";
|
||||
private static final String TXT_SCALE = "UI Scale: %dX";
|
||||
private static final String TXT_IMMERSIVE = "Immersive mode";
|
||||
|
||||
private static final String TXT_MUSIC = "Music";
|
||||
|
@ -57,6 +59,8 @@ public class WndSettings extends Window {
|
|||
|
||||
private RedButton btnZoomOut;
|
||||
private RedButton btnZoomIn;
|
||||
|
||||
private int setScale = PixelScene.defaultZoom;
|
||||
|
||||
public WndSettings( boolean inGame ) {
|
||||
super();
|
||||
|
@ -94,15 +98,16 @@ public class WndSettings extends Window {
|
|||
|
||||
} else {
|
||||
|
||||
CheckBox btnScaleUp = new CheckBox( TXT_SCALE_UP ) {
|
||||
RedButton btnScaleUp = new RedButton( Utils.format(TXT_SCALE, setScale) ) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
ShatteredPixelDungeon.scaleUp(checked());
|
||||
setScale++;
|
||||
if (setScale > PixelScene.maxDefaultZoom) setScale = (int)Math.ceil(Game.density);
|
||||
this.text(Utils.format(TXT_SCALE, setScale));
|
||||
}
|
||||
};
|
||||
btnScaleUp.setRect( 0, 0, WIDTH, BTN_HEIGHT );
|
||||
btnScaleUp.checked( ShatteredPixelDungeon.scaleUp() );
|
||||
add( btnScaleUp );
|
||||
|
||||
btnImmersive = new CheckBox( TXT_IMMERSIVE ) {
|
||||
|
@ -218,4 +223,13 @@ public class WndSettings extends Window {
|
|||
private String orientationText() {
|
||||
return ShatteredPixelDungeon.landscape() ? TXT_SWITCH_PORT : TXT_SWITCH_LAND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
super.hide();
|
||||
if (setScale != PixelScene.defaultZoom) {
|
||||
ShatteredPixelDungeon.scale(setScale);
|
||||
ShatteredPixelDungeon.switchScene(TitleScene.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user