From c5252a5045ce8e0390086797e704fcf839f3e536 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 14 Jul 2015 23:07:51 -0400 Subject: [PATCH] v0.3.1: all sorta UI changes --- .../shatteredpixeldungeon/Preferences.java | 1 + .../ShatteredPixelDungeon.java | 11 +- .../scenes/GameScene.java | 2 + .../ui/AttackIndicator.java | 3 +- .../shatteredpixeldungeon/ui/PrefsButton.java | 2 +- .../shatteredpixeldungeon/ui/Toolbar.java | 103 ++++++---- .../shatteredpixeldungeon/ui/WndDisplay.java | 148 ++++++++++++++ .../windows/WndGame.java | 12 +- .../windows/WndSettings.java | 188 +++--------------- 9 files changed, 260 insertions(+), 210 deletions(-) create mode 100644 src/com/shatteredpixel/shatteredpixeldungeon/ui/WndDisplay.java diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Preferences.java b/src/com/shatteredpixel/shatteredpixeldungeon/Preferences.java index 36061781e..1eb023ec8 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/Preferences.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Preferences.java @@ -40,6 +40,7 @@ enum Preferences { public static final String KEY_CHALLENGES = "challenges"; public static final String KEY_QUICKSLOTS = "quickslots"; public static final String KEY_FLIPPEDUI = "flipped_ui"; + public static final String KEY_BARMODE = "toolbar_mode"; public static final String KEY_INTRO = "intro"; public static final String KEY_BRIGHTNESS = "brightness"; public static final String KEY_VERSION = "version"; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java b/src/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java index a72459abd..e04b03029 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java @@ -203,7 +203,7 @@ public class ShatteredPixelDungeon extends Game { public static void scale( int value ) { Preferences.INSTANCE.put( Preferences.KEY_SCALE, value ); - switchScene( TitleScene.class ); + resetScene(); } // *** IMMERSIVE MODE **** @@ -274,6 +274,7 @@ public class ShatteredPixelDungeon extends Game { public static void music( boolean value ) { Music.INSTANCE.enable( value ); + Music.INSTANCE.volume( musicVol()/10f ); Preferences.INSTANCE.put( Preferences.KEY_MUSIC, value ); } @@ -341,6 +342,14 @@ public class ShatteredPixelDungeon extends Game { Preferences.INSTANCE.put(Preferences.KEY_FLIPPEDUI, value ); } public static boolean flippedUI(){ return Preferences.INSTANCE.getBoolean(Preferences.KEY_FLIPPEDUI, false); } + + public static void toolbarMode( String value ) { + Preferences.INSTANCE.put( Preferences.KEY_BARMODE, value ); + } + + public static String toolbarMode() { + return Preferences.INSTANCE.getString(Preferences.KEY_BARMODE, !landscape() ? "SPLIT" : "GROUPED"); + } public static void intro( boolean value ) { Preferences.INSTANCE.put( Preferences.KEY_INTRO, value ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java index d8f399596..7dfa980a5 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -346,6 +346,8 @@ public class GameScene extends PixelScene { Dungeon.droppedItems.remove( Dungeon.depth ); } + Dungeon.hero.next(); + Camera.main.target = hero; fadeIn(); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ui/AttackIndicator.java b/src/com/shatteredpixel/shatteredpixeldungeon/ui/AttackIndicator.java index b56c4c3de..e5fe5a433 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ui/AttackIndicator.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ui/AttackIndicator.java @@ -42,13 +42,14 @@ public class AttackIndicator extends Tag { private CharSprite sprite = null; - private static Mob lastTarget = null; + private static Mob lastTarget; private ArrayList candidates = new ArrayList(); public AttackIndicator() { super( DangerIndicator.COLOR ); instance = this; + lastTarget = null; setSize( 24, 24 ); visible( false ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ui/PrefsButton.java b/src/com/shatteredpixel/shatteredpixeldungeon/ui/PrefsButton.java index 124091c69..87cb46ec3 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ui/PrefsButton.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ui/PrefsButton.java @@ -66,6 +66,6 @@ public class PrefsButton extends Button { @Override protected void onClick() { - parent.add( new WndSettings( false ) ); + parent.add( new WndSettings() ); } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java b/src/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java index 197ae5538..9e192c397 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java @@ -56,20 +56,24 @@ public class Toolbar extends Component { private Tool btnSearch; private Tool btnInventory; private Tool[] btnQuick; - - public static int slots; - public static boolean flipped; private PickedUpItem pickedUp; private boolean lastEnabled = true; - private static boolean examining = false; + private boolean examining = false; + + private static Toolbar instance; + + public enum Mode { + SPLIT, + GROUP, + CENTER + } public Toolbar() { super(); - slots = ShatteredPixelDungeon.quickSlots(); - flipped = ShatteredPixelDungeon.flippedUI(); + instance = this; height = btnInventory.height(); } @@ -80,10 +84,12 @@ public class Toolbar extends Component { add(btnWait = new Tool(24, 0, 20, 26) { @Override protected void onClick() { + examining = false; Dungeon.hero.rest(false); } protected boolean onLongClick() { + examining = false; Dungeon.hero.rest(true); return true; } @@ -155,41 +161,63 @@ public class Toolbar extends Component { int[] visible = new int[4]; + int slots = ShatteredPixelDungeon.quickSlots(); + int ofs = (slots == 4 && (width() < 146)) ? 2 : 0; for(int i = 0; i <= 3; i++) visible[i] = (int)((slots > i) ? y+2 : y+25); - for(int i = 0; i <= 3; i++) - btnQuick[i].visible = slots > i; - - if (!flipped) { - btnWait.setPos(x, y); - btnSearch.setPos(btnWait.right(), y); - - btnInventory.setPos(width - btnInventory.width(), y); - - int ofs = (slots == 4 && btnInventory.left() - btnSearch.right() < 90) ? 2 : 0; - - btnQuick[0].setPos(btnInventory.left() - btnQuick[0].width() + ofs, visible[0]); - btnQuick[1].setPos(btnQuick[0].left() - btnQuick[1].width() + ofs, visible[1]); - btnQuick[2].setPos(btnQuick[1].left() - btnQuick[2].width() + ofs, visible[2]); - btnQuick[3].setPos(btnQuick[2].left() - btnQuick[3].width() + ofs, visible[3]); - } else { - btnWait.setPos(width - btnWait.width(), y); - btnSearch.setPos(btnWait.left() - btnSearch.width(), y); - - btnInventory.setPos(x, y); - - int ofs = (slots == 4 && btnSearch.left() - btnInventory.right() < 90) ? 2 : 0; - - btnQuick[0].setPos(btnInventory.right() - ofs, visible[0]); - btnQuick[1].setPos(btnQuick[0].right() - ofs, visible[1]); - btnQuick[2].setPos(btnQuick[1].right() - ofs, visible[2]); - btnQuick[3].setPos(btnQuick[2].right() - ofs, visible[3]); + for(int i = 0; i <= 3; i++) { + btnQuick[i].visible = btnQuick[i].active = slots > i; } + float right = width; + switch(Mode.valueOf(ShatteredPixelDungeon.toolbarMode())){ + case SPLIT: + btnWait.setPos(x, y); + btnSearch.setPos(btnWait.right(), y); + btnInventory.setPos(right - btnInventory.width(), y); + btnQuick[0].setPos(btnInventory.left() - btnQuick[0].width() + ofs, visible[0]); + btnQuick[1].setPos(btnQuick[0].left() - btnQuick[1].width() + ofs, visible[1]); + btnQuick[2].setPos(btnQuick[1].left() - btnQuick[2].width() + ofs, visible[2]); + btnQuick[3].setPos(btnQuick[2].left() - btnQuick[3].width() + ofs, visible[3]); + break; + + //center = group but.. well.. centered, so all we need to do is pre-emptively set the right side further in. + case CENTER: + right = width - (width - btnWait.width() - btnSearch.width() - btnInventory.width() - (slots * (btnQuick[0].width() - ofs)))/2f; + + case GROUP: + btnWait.setPos(right - btnWait.width(), y); + btnSearch.setPos(btnWait.left() - btnSearch.width(), y); + btnInventory.setPos(btnSearch.left() - btnInventory.width(), y); + + btnQuick[0].setPos(btnInventory.left() - btnQuick[0].width() + ofs, visible[0]); + btnQuick[1].setPos(btnQuick[0].left() - btnQuick[1].width() + ofs, visible[1]); + btnQuick[2].setPos(btnQuick[1].left() - btnQuick[2].width() + ofs, visible[2]); + btnQuick[3].setPos(btnQuick[2].left() - btnQuick[3].width() + ofs, visible[3]); + break; + } + right = width; + + if (ShatteredPixelDungeon.flippedUI()) { + + btnWait.setPos( (right - btnWait.right()), y); + btnSearch.setPos( (right - btnSearch.right()), y); + btnInventory.setPos( (right - btnInventory.right()), y); + + for(int i = 0; i <= 3; i++) { + btnQuick[i].setPos( right - btnQuick[i].right(), visible[i]); + } + + } + + } + + public static void updateLayout(){ + if (instance != null) instance.layout(); } @Override @@ -209,13 +237,6 @@ public class Toolbar extends Component { if (!Dungeon.hero.isAlive()) { btnInventory.enable(true); } - - //check if visible slots or UI flipping has changed. - if ((slots == 0 && btnQuick[0].visible) || (slots != 0 && !btnQuick[slots-1].visible)){ - layout(); - } else if (flipped && btnWait.left() == 0 || !flipped && btnInventory.left() == 0){ - layout(); - } } public void pickup( Item item ) { @@ -228,7 +249,7 @@ public class Toolbar extends Component { @Override public void onSelect( Integer cell ) { - examining = false; + instance.examining = false; if (cell == null) { return; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ui/WndDisplay.java b/src/com/shatteredpixel/shatteredpixeldungeon/ui/WndDisplay.java new file mode 100644 index 000000000..6e72a9694 --- /dev/null +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ui/WndDisplay.java @@ -0,0 +1,148 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2015 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ +package com.shatteredpixel.shatteredpixeldungeon.ui; + +import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; +import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; +import com.watabou.noosa.BitmapText; +import com.watabou.noosa.Game; + +public class WndDisplay extends Window { + + private static final int WIDTH = 112; + private static final int SLIDER_HEIGHT = 25; + private static final int BTN_HEIGHT = 20; + private static final int GAP_SML = 2; + private static final int GAP_LRG = 10; + + public WndDisplay() { + + //***Screen Options*** + + OptionSlider scale = new OptionSlider("UI Scale", + (int)Math.ceil(2* Game.density)+ "X", + PixelScene.maxDefaultZoom + "X", + (int)Math.ceil(2* Game.density), + PixelScene.maxDefaultZoom ) { + @Override + protected void onChange() { + ShatteredPixelDungeon.scale(getSelectedValue()); + } + }; + scale.setSelectedValue(PixelScene.defaultZoom); + if ((int)Math.ceil(2* Game.density) < PixelScene.maxDefaultZoom) { + scale.setRect(0, 0, WIDTH, SLIDER_HEIGHT); + add(scale); + } else { + scale.setRect(0, 0, 0, 0); + } + + CheckBox chkImmersive = new CheckBox( "Hide Software Keys" ) { + @Override + protected void onClick() { + super.onClick(); + ShatteredPixelDungeon.immerse(checked()); + } + }; + chkImmersive.setRect( 0, scale.bottom() + GAP_SML, WIDTH, BTN_HEIGHT ); + chkImmersive.checked( ShatteredPixelDungeon.immersed() ); + chkImmersive.enable( android.os.Build.VERSION.SDK_INT >= 19 ); + add(chkImmersive); + + //***Brightness Option*** + + OptionSlider brightness = new OptionSlider("Brightness", "Dark", "Bright", -2, 4) { + @Override + protected void onChange() { + ShatteredPixelDungeon.brightness(getSelectedValue()); + } + }; + brightness.setSelectedValue(ShatteredPixelDungeon.brightness()); + brightness.setRect(0, chkImmersive.bottom() + GAP_LRG, WIDTH, SLIDER_HEIGHT); + add(brightness); + + //***Interface Options*** + + + BitmapText barDesc = PixelScene.createText("Toolbar Mode:", 9); + barDesc.measure(); + barDesc.x = (WIDTH-barDesc.width())/2; + barDesc.y = brightness.bottom() + GAP_LRG; + add(barDesc); + + RedButton btnSplit = new RedButton("Split"){ + @Override + protected void onClick() { + ShatteredPixelDungeon.toolbarMode(Toolbar.Mode.SPLIT.name()); + Toolbar.updateLayout(); + } + }; + btnSplit.setRect( 1, barDesc.y + barDesc.height(), 36, BTN_HEIGHT); + add(btnSplit); + + RedButton btnGrouped = new RedButton("Group"){ + @Override + protected void onClick() { + ShatteredPixelDungeon.toolbarMode(Toolbar.Mode.GROUP.name()); + Toolbar.updateLayout(); + } + }; + btnGrouped.setRect( btnSplit.right()+1, barDesc.y + barDesc.height(), 36, BTN_HEIGHT); + add(btnGrouped); + + RedButton btnCentered = new RedButton("Center"){ + @Override + protected void onClick() { + ShatteredPixelDungeon.toolbarMode(Toolbar.Mode.CENTER.name()); + Toolbar.updateLayout(); + } + }; + btnCentered.setRect(btnGrouped.right()+1, barDesc.y + barDesc.height(), 36, BTN_HEIGHT); + add(btnCentered); + + OptionSlider slots = new OptionSlider("Quickslots", "0", "4", 0, 4) { + @Override + protected void onChange() { + ShatteredPixelDungeon.quickSlots( getSelectedValue() ); + Toolbar.updateLayout(); + } + }; + slots.setSelectedValue(ShatteredPixelDungeon.quickSlots()); + slots.setRect(0, btnGrouped.bottom() + GAP_SML, WIDTH, SLIDER_HEIGHT); + add(slots); + + CheckBox chkFlip = new CheckBox("Flip Toolbar"){ + @Override + protected void onClick() { + super.onClick(); + ShatteredPixelDungeon.flippedUI(checked()); + Toolbar.updateLayout(); + } + }; + chkFlip.setRect(0, slots.bottom() + GAP_SML, WIDTH, BTN_HEIGHT); + chkFlip.checked(ShatteredPixelDungeon.flippedUI()); + add(chkFlip); + + resize(WIDTH, (int) chkFlip.bottom()); + + } +} diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndGame.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndGame.java index 008f437e1..dcdb7c787 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndGame.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndGame.java @@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import java.io.IOException; +import com.shatteredpixel.shatteredpixeldungeon.ui.*; import com.watabou.noosa.Game; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; @@ -29,9 +30,6 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.RankingsScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.TitleScene; -import com.shatteredpixel.shatteredpixeldungeon.ui.Icons; -import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; -import com.shatteredpixel.shatteredpixeldungeon.ui.Window; public class WndGame extends Window { @@ -53,15 +51,13 @@ public class WndGame extends Window { super(); - addButton( new RedButton( TXT_SETTINGS ) { + addButtons( new RedButton( "Display" ) { @Override protected void onClick() { hide(); - GameScene.show( new WndSettings( true ) ); + GameScene.show( new WndDisplay() ); } - }); - - addButton( new RedButton( "Audio Settings" ) { + }, new RedButton( "Audio" ) { @Override protected void onClick() { hide(); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java index 4a03089be..4eb63c1dd 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java @@ -22,184 +22,56 @@ 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.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; -import com.shatteredpixel.shatteredpixeldungeon.ui.CheckBox; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; +import com.shatteredpixel.shatteredpixeldungeon.ui.WndDisplay; +import com.watabou.noosa.Game; public class WndSettings extends Window { - - private static final String TXT_ZOOM_IN = "+"; - private static final String TXT_ZOOM_OUT = "-"; - private static final String TXT_ZOOM_DEFAULT = "Default Zoom"; - - private static final String TXT_SCALE = "UI Scale: %dX"; - private static final String TXT_IMMERSIVE = "Immersive mode"; - - private static final String TXT_BRIGHTNESS = "Brightness: %s"; - - private static final String TXT_QUICKSLOT = "QuickSlots: %s"; - private static final String TXT_SWITCH_PORT = "Switch to portrait"; private static final String TXT_SWITCH_LAND = "Switch to landscape"; private static final int WIDTH = 112; private static final int BTN_HEIGHT = 20; private static final int GAP = 2; - - private RedButton btnZoomOut; - private RedButton btnZoomIn; private int setScale = PixelScene.defaultZoom; - public WndSettings( boolean inGame ) { + public WndSettings() { super(); - CheckBox btnImmersive = null; + RedButton btnDisplay = new RedButton("Display"){ + @Override + protected void onClick() { + hide(); + Game.scene().add(new WndDisplay()); + } + }; + btnDisplay.setRect(0, 0, (WIDTH/2)-1, BTN_HEIGHT); + add( btnDisplay ); - if (inGame) { - int w = BTN_HEIGHT; - - // Zoom out - btnZoomOut = new RedButton( TXT_ZOOM_OUT ) { - @Override - protected void onClick() { - zoom( Camera.main.zoom - 1 ); - } - }; - add( btnZoomOut.setRect( 0, 0, w, BTN_HEIGHT) ); - - // Zoom in - btnZoomIn = new RedButton( TXT_ZOOM_IN ) { - @Override - protected void onClick() { - zoom( Camera.main.zoom + 1 ); - } - }; - add( btnZoomIn.setRect( WIDTH - w, 0, w, BTN_HEIGHT) ); - - // Default zoom - add( new RedButton( TXT_ZOOM_DEFAULT ) { - @Override - protected void onClick() { - zoom( PixelScene.defaultZoom ); - } - }.setRect( btnZoomOut.right(), 0, WIDTH - btnZoomIn.width() - btnZoomOut.width(), BTN_HEIGHT ) ); - - } else { - - RedButton btnScaleUp = new RedButton( Utils.format(TXT_SCALE, setScale) ) { - @Override - protected void onClick() { - super.onClick(); - setScale++; - if (setScale > PixelScene.maxDefaultZoom) setScale = (int)Math.ceil(2*Game.density); - this.text(Utils.format(TXT_SCALE, setScale)); - } - }; - btnScaleUp.setRect( 0, 0, WIDTH, BTN_HEIGHT ); - btnScaleUp.enable(PixelScene.maxDefaultZoom > Math.ceil(2*Game.density)); - add(btnScaleUp); + RedButton btnAudio = new RedButton("Audio") { + @Override + protected void onClick() { + hide(); + Game.scene().add(new WndAudio()); + } + }; + btnAudio.setRect( btnDisplay.right()+2, 0, (WIDTH/2)-1, BTN_HEIGHT ); + add( btnAudio ); - btnImmersive = new CheckBox( TXT_IMMERSIVE ) { - @Override - protected void onClick() { - super.onClick(); - ShatteredPixelDungeon.immerse(checked()); - } - }; - btnImmersive.setRect( 0, btnScaleUp.bottom() + GAP, WIDTH, BTN_HEIGHT ); - btnImmersive.checked( ShatteredPixelDungeon.immersed() ); - btnImmersive.enable( android.os.Build.VERSION.SDK_INT >= 19 ); - add( btnImmersive ); + RedButton btnOrientation = new RedButton( orientationText() ) { + @Override + protected void onClick() { + ShatteredPixelDungeon.landscape(!ShatteredPixelDungeon.landscape()); + } + }; + btnOrientation.setRect( 0, btnAudio.bottom() + GAP, WIDTH, BTN_HEIGHT ); + add( btnOrientation ); - } - - if (!inGame) { + resize( WIDTH, (int)btnOrientation.bottom() ); - RedButton btnAudio = new RedButton("Audio Settings") { - @Override - protected void onClick() { - hide(); - Game.scene().add(new WndAudio()); - } - }; - btnAudio.setRect( 0, btnImmersive.bottom() + GAP, WIDTH, BTN_HEIGHT ); - add( btnAudio ); - - RedButton btnOrientation = new RedButton( orientationText() ) { - @Override - protected void onClick() { - ShatteredPixelDungeon.landscape(!ShatteredPixelDungeon.landscape()); - } - }; - btnOrientation.setRect( 0, btnAudio.bottom() + GAP, WIDTH, BTN_HEIGHT ); - add( btnOrientation ); - - resize( WIDTH, (int)btnOrientation.bottom() ); - - } else { - - RedButton btnBrightness = new RedButton( Utils.format(TXT_BRIGHTNESS, ShatteredPixelDungeon.brightness()) ) { - @Override - protected void onClick() { - super.onClick(); - int brightness = ShatteredPixelDungeon.brightness()+1; - if (brightness == 5) brightness = -2; - ShatteredPixelDungeon.brightness(brightness); - this.text(Utils.format(TXT_BRIGHTNESS, brightness)); - } - }; - btnBrightness.setRect(0, btnZoomIn.bottom() + GAP, WIDTH, BTN_HEIGHT); - add(btnBrightness); - - RedButton btnQuickSlot = new RedButton( Utils.format(TXT_QUICKSLOT, ShatteredPixelDungeon.quickSlots()) ) { - @Override - protected void onClick() { - super.onClick(); - int quickslots = ShatteredPixelDungeon.quickSlots()+1; - if (quickslots == 5) quickslots = 0; - ShatteredPixelDungeon.quickSlots(quickslots); - this.text(Utils.format(TXT_QUICKSLOT, quickslots)); - Toolbar.slots = quickslots; - } - }; - btnQuickSlot.setRect(0, btnBrightness.bottom() + GAP, WIDTH, BTN_HEIGHT); - add(btnQuickSlot); - - CheckBox btnFlipUI = new CheckBox("Flip Toolbar") { - @Override - protected void onClick() { - super.onClick(); - ShatteredPixelDungeon.flippedUI(checked()); - Toolbar.flipped = checked(); - } - }; - btnFlipUI.setRect( 0, btnQuickSlot.bottom() + GAP, WIDTH, BTN_HEIGHT ); - btnFlipUI.checked(ShatteredPixelDungeon.flippedUI()); - add(btnFlipUI); - - resize( WIDTH, (int)btnFlipUI.bottom() ); - - } - } - - private void zoom( float value ) { - - Camera.main.zoom( value ); - ShatteredPixelDungeon.zoom((int) (value - PixelScene.defaultZoom)); - - updateEnabled(); - } - - private void updateEnabled() { - float zoom = Camera.main.zoom; - btnZoomIn.enable( zoom < PixelScene.maxZoom ); - btnZoomOut.enable( zoom > PixelScene.minZoom ); } private String orientationText() {