v0.3.1: all sorta UI changes

This commit is contained in:
Evan Debenham
2015-07-14 23:07:51 -04:00
committed by Evan Debenham
parent 3cd86934bd
commit c5252a5045
9 changed files with 260 additions and 210 deletions
@@ -42,13 +42,14 @@ public class AttackIndicator extends Tag {
private CharSprite sprite = null;
private static Mob lastTarget = null;
private static Mob lastTarget;
private ArrayList<Mob> candidates = new ArrayList<Mob>();
public AttackIndicator() {
super( DangerIndicator.COLOR );
instance = this;
lastTarget = null;
setSize( 24, 24 );
visible( false );
@@ -66,6 +66,6 @@ public class PrefsButton extends Button {
@Override
protected void onClick() {
parent.add( new WndSettings( false ) );
parent.add( new WndSettings() );
}
}
@@ -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;
@@ -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 <http://www.gnu.org/licenses/>
*/
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());
}
}