v0.3.1a: reworked screen size scaling to fix certain resolutions, adjusted quickslots to compensate

This commit is contained in:
Evan Debenham 2015-08-22 18:59:52 -04:00 committed by Evan Debenham
parent 67b439dc1d
commit 81341c93d0
3 changed files with 59 additions and 19 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -43,11 +43,11 @@ import com.watabou.utils.BitmapCache;
public class PixelScene extends Scene { public class PixelScene extends Scene {
// Minimum virtual display size for portrait orientation // Minimum virtual display size for portrait orientation
public static final float MIN_WIDTH_P = 144; public static final float MIN_WIDTH_P = 135;
public static final float MIN_HEIGHT_P = 224; public static final float MIN_HEIGHT_P = 225;
// Minimum virtual display size for landscape orientation // Minimum virtual display size for landscape orientation
public static final float MIN_WIDTH_L = 224; public static final float MIN_WIDTH_L = 240;
public static final float MIN_HEIGHT_L = 160; public static final float MIN_HEIGHT_L = 160;
public static int defaultZoom = 0; public static int defaultZoom = 0;
@ -88,7 +88,6 @@ public class PixelScene extends Scene {
) && defaultZoom > 1) { ) && defaultZoom > 1) {
defaultZoom--; defaultZoom--;
} }
ShatteredPixelDungeon.scale(defaultZoom);
} }
minZoom = 1; minZoom = 1;

View File

@ -55,7 +55,7 @@ public class Toolbar extends Component {
private Tool btnWait; private Tool btnWait;
private Tool btnSearch; private Tool btnSearch;
private Tool btnInventory; private Tool btnInventory;
private Tool[] btnQuick; private QuickslotTool[] btnQuick;
private PickedUpItem pickedUp; private PickedUpItem pickedUp;
@ -116,7 +116,7 @@ public class Toolbar extends Component {
} }
}); });
btnQuick = new Tool[4]; btnQuick = new QuickslotTool[4];
add( btnQuick[3] = new QuickslotTool( 64, 0, 22, 24, 3) ); add( btnQuick[3] = new QuickslotTool( 64, 0, 22, 24, 3) );
@ -165,16 +165,44 @@ public class Toolbar extends Component {
@Override @Override
protected void layout() { protected void layout() {
int[] visible = new int[4]; int[] visible = new int[4];
int slots = ShatteredPixelDungeon.quickSlots(); int slots = ShatteredPixelDungeon.quickSlots();
int ofs = (slots == 4 && (width() < 146)) ? 2 : 0;
for(int i = 0; i <= 3; i++) for(int i = 0; i <= 3; i++)
visible[i] = (int)((slots > i) ? y+2 : y+25); visible[i] = (int)((slots > i) ? y+2 : y+25);
for(int i = 0; i <= 3; i++) { for(int i = 0; i <= 3; i++) {
btnQuick[i].visible = btnQuick[i].active = slots > i; btnQuick[i].visible = btnQuick[i].active = slots > i;
//decides on quickslot layout, depending on available screen size.
if (slots == 4 && width < 150){
if (width < 139){
if ((ShatteredPixelDungeon.flipToolbar() && i == 3) ||
(!ShatteredPixelDungeon.flipToolbar() && i == 0)) {
btnQuick[i].border(0, 0);
btnQuick[i].frame(88, 0, 17, 24);
} else {
btnQuick[i].border(0, 1);
btnQuick[i].frame(88, 0, 18, 24);
}
} else {
if (i == 0 && !ShatteredPixelDungeon.flipToolbar() ||
i == 3 && ShatteredPixelDungeon.flipToolbar()){
btnQuick[i].border(0, 2);
btnQuick[i].frame(106, 0, 19, 24);
} else if (i == 0 && ShatteredPixelDungeon.flipToolbar() ||
i == 3 && !ShatteredPixelDungeon.flipToolbar()){
btnQuick[i].border(2, 1);
btnQuick[i].frame(86, 0, 20, 24);
} else {
btnQuick[i].border(0, 1);
btnQuick[i].frame(88, 0, 18, 24);
}
}
} else {
btnQuick[i].border(2, 2);
btnQuick[i].frame(64, 0, 22, 24);
}
} }
float right = width; float right = width;
@ -185,25 +213,26 @@ public class Toolbar extends Component {
btnInventory.setPos(right - btnInventory.width(), y); btnInventory.setPos(right - btnInventory.width(), y);
btnQuick[0].setPos(btnInventory.left() - btnQuick[0].width() + ofs, visible[0]); btnQuick[0].setPos(btnInventory.left() - btnQuick[0].width(), visible[0]);
btnQuick[1].setPos(btnQuick[0].left() - btnQuick[1].width() + ofs, visible[1]); btnQuick[1].setPos(btnQuick[0].left() - btnQuick[1].width(), visible[1]);
btnQuick[2].setPos(btnQuick[1].left() - btnQuick[2].width() + ofs, visible[2]); btnQuick[2].setPos(btnQuick[1].left() - btnQuick[2].width(), visible[2]);
btnQuick[3].setPos(btnQuick[2].left() - btnQuick[3].width() + ofs, visible[3]); btnQuick[3].setPos(btnQuick[2].left() - btnQuick[3].width(), visible[3]);
break; break;
//center = group but.. well.. centered, so all we need to do is pre-emptively set the right side further in. //center = group but.. well.. centered, so all we need to do is pre-emptively set the right side further in.
case CENTER: case CENTER:
right = width - (width - btnWait.width() - btnSearch.width() - btnInventory.width() - (slots * (btnQuick[0].width() - ofs)))/2f; right = width - (width - btnWait.width() - btnSearch.width() - btnInventory.width() -
btnQuick[0].width() - btnQuick[1].width() - btnQuick[2].width() - btnQuick[3].width())/2;
case GROUP: case GROUP:
btnWait.setPos(right - btnWait.width(), y); btnWait.setPos(right - btnWait.width(), y);
btnSearch.setPos(btnWait.left() - btnSearch.width(), y); btnSearch.setPos(btnWait.left() - btnSearch.width(), y);
btnInventory.setPos(btnSearch.left() - btnInventory.width(), y); btnInventory.setPos(btnSearch.left() - btnInventory.width(), y);
btnQuick[0].setPos(btnInventory.left() - btnQuick[0].width() + ofs, visible[0]); btnQuick[0].setPos(btnInventory.left() - btnQuick[0].width(), visible[0]);
btnQuick[1].setPos(btnQuick[0].left() - btnQuick[1].width() + ofs, visible[1]); btnQuick[1].setPos(btnQuick[0].left() - btnQuick[1].width(), visible[1]);
btnQuick[2].setPos(btnQuick[1].left() - btnQuick[2].width() + ofs, visible[2]); btnQuick[2].setPos(btnQuick[1].left() - btnQuick[2].width(), visible[2]);
btnQuick[3].setPos(btnQuick[2].left() - btnQuick[3].width() + ofs, visible[3]); btnQuick[3].setPos(btnQuick[2].left() - btnQuick[3].width(), visible[3]);
break; break;
} }
right = width; right = width;
@ -318,8 +347,12 @@ public class Toolbar extends Component {
public Tool( int x, int y, int width, int height ) { public Tool( int x, int y, int width, int height ) {
super(); super();
frame(x, y, width, height);
}
public void frame( int x, int y, int width, int height) {
base.frame( x, y, width, height ); base.frame( x, y, width, height );
this.width = width; this.width = width;
this.height = height; this.height = height;
} }
@ -369,6 +402,8 @@ public class Toolbar extends Component {
private static class QuickslotTool extends Tool { private static class QuickslotTool extends Tool {
private QuickSlotButton slot; private QuickSlotButton slot;
private int borderLeft = 2;
private int borderRight = 2;
public QuickslotTool( int x, int y, int width, int height, int slotNum ) { public QuickslotTool( int x, int y, int width, int height, int slotNum ) {
super( x, y, width, height ); super( x, y, width, height );
@ -376,11 +411,17 @@ public class Toolbar extends Component {
slot = new QuickSlotButton( slotNum ); slot = new QuickSlotButton( slotNum );
add( slot ); add( slot );
} }
public void border( int left, int right ){
borderLeft = left;
borderRight = right;
layout();
}
@Override @Override
protected void layout() { protected void layout() {
super.layout(); super.layout();
slot.setRect( x + 2, y + 2, width - 4, height - 3 ); slot.setRect( x + borderLeft, y + 2, width - borderLeft-borderRight, height - 4 );
} }
@Override @Override