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_LANDSCAPE = "landscape";
|
||||||
public static final String KEY_IMMERSIVE = "immersive";
|
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_MUSIC = "music";
|
||||||
public static final String KEY_SOUND_FX = "soundfx";
|
public static final String KEY_SOUND_FX = "soundfx";
|
||||||
public static final String KEY_ZOOM = "zoom";
|
public static final String KEY_ZOOM = "zoom";
|
||||||
|
|
|
@ -200,8 +200,8 @@ public class ShatteredPixelDungeon extends Game {
|
||||||
return width > height;
|
return width > height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void scaleUp( boolean value ) {
|
public static void scale( int value ) {
|
||||||
Preferences.INSTANCE.put( Preferences.KEY_SCALE_UP, value );
|
Preferences.INSTANCE.put( Preferences.KEY_SCALE, value );
|
||||||
switchScene( TitleScene.class );
|
switchScene( TitleScene.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,8 +259,8 @@ public class ShatteredPixelDungeon extends Game {
|
||||||
|
|
||||||
// *****************************
|
// *****************************
|
||||||
|
|
||||||
public static boolean scaleUp() {
|
public static int scale() {
|
||||||
return Preferences.INSTANCE.getBoolean( Preferences.KEY_SCALE_UP, true );
|
return Preferences.INSTANCE.getInt( Preferences.KEY_SCALE, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void zoom( int value ) {
|
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_WIDTH_L = 224;
|
||||||
public static final float MIN_HEIGHT_L = 160;
|
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 minZoom;
|
||||||
public static float maxZoom;
|
public static float maxZoom;
|
||||||
|
|
||||||
|
@ -77,26 +78,23 @@ public class PixelScene extends Scene {
|
||||||
minHeight = MIN_HEIGHT_P;
|
minHeight = MIN_HEIGHT_P;
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultZoom = (int)Math.ceil( Game.density * 2.5 );
|
defaultZoom = ShatteredPixelDungeon.scale();
|
||||||
while ((
|
if (defaultZoom < Game.density){
|
||||||
Game.width / defaultZoom < minWidth ||
|
defaultZoom = (int)Math.ceil( Game.density * 2.5 );
|
||||||
Game.height / defaultZoom < minHeight
|
while ((
|
||||||
|
Game.width / defaultZoom < minWidth ||
|
||||||
|
Game.height / defaultZoom < minHeight
|
||||||
) && defaultZoom > 1) {
|
) && defaultZoom > 1) {
|
||||||
|
defaultZoom--;
|
||||||
defaultZoom--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ShatteredPixelDungeon.scaleUp()) {
|
|
||||||
while (
|
|
||||||
Game.width / (defaultZoom + 1) >= minWidth &&
|
|
||||||
Game.height / (defaultZoom + 1) >= minHeight) {
|
|
||||||
defaultZoom++;
|
|
||||||
}
|
}
|
||||||
|
ShatteredPixelDungeon.scale(defaultZoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maxDefaultZoom = (int)Math.min(Game.width/minWidth, Game.height/minHeight);
|
||||||
|
|
||||||
minZoom = 1;
|
minZoom = 1;
|
||||||
maxZoom = defaultZoom * 2;
|
maxZoom = defaultZoom * 2;
|
||||||
|
|
||||||
|
|
||||||
Camera.reset( new PixelCamera( defaultZoom ) );
|
Camera.reset( new PixelCamera( defaultZoom ) );
|
||||||
|
|
||||||
float uiZoom = defaultZoom;
|
float uiZoom = defaultZoom;
|
||||||
|
|
|
@ -21,9 +21,11 @@
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.TitleScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Toolbar;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Toolbar;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||||
import com.watabou.noosa.Camera;
|
import com.watabou.noosa.Camera;
|
||||||
|
import com.watabou.noosa.Game;
|
||||||
import com.watabou.noosa.audio.Sample;
|
import com.watabou.noosa.audio.Sample;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
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_OUT = "-";
|
||||||
private static final String TXT_ZOOM_DEFAULT = "Default Zoom";
|
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_IMMERSIVE = "Immersive mode";
|
||||||
|
|
||||||
private static final String TXT_MUSIC = "Music";
|
private static final String TXT_MUSIC = "Music";
|
||||||
|
@ -58,6 +60,8 @@ public class WndSettings extends Window {
|
||||||
private RedButton btnZoomOut;
|
private RedButton btnZoomOut;
|
||||||
private RedButton btnZoomIn;
|
private RedButton btnZoomIn;
|
||||||
|
|
||||||
|
private int setScale = PixelScene.defaultZoom;
|
||||||
|
|
||||||
public WndSettings( boolean inGame ) {
|
public WndSettings( boolean inGame ) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -94,15 +98,16 @@ public class WndSettings extends Window {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
CheckBox btnScaleUp = new CheckBox( TXT_SCALE_UP ) {
|
RedButton btnScaleUp = new RedButton( Utils.format(TXT_SCALE, setScale) ) {
|
||||||
@Override
|
@Override
|
||||||
protected void onClick() {
|
protected void onClick() {
|
||||||
super.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.setRect( 0, 0, WIDTH, BTN_HEIGHT );
|
||||||
btnScaleUp.checked( ShatteredPixelDungeon.scaleUp() );
|
|
||||||
add( btnScaleUp );
|
add( btnScaleUp );
|
||||||
|
|
||||||
btnImmersive = new CheckBox( TXT_IMMERSIVE ) {
|
btnImmersive = new CheckBox( TXT_IMMERSIVE ) {
|
||||||
|
@ -218,4 +223,13 @@ public class WndSettings extends Window {
|
||||||
private String orientationText() {
|
private String orientationText() {
|
||||||
return ShatteredPixelDungeon.landscape() ? TXT_SWITCH_PORT : TXT_SWITCH_LAND;
|
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