From 81341c93d0875e8fce568e2728bfd0b93fafa09c Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 22 Aug 2015 18:59:52 -0400 Subject: [PATCH] v0.3.1a: reworked screen size scaling to fix certain resolutions, adjusted quickslots to compensate --- assets/toolbar.png | Bin 3872 -> 3758 bytes .../scenes/PixelScene.java | 7 +- .../shatteredpixeldungeon/ui/Toolbar.java | 71 ++++++++++++++---- 3 files changed, 59 insertions(+), 19 deletions(-) diff --git a/assets/toolbar.png b/assets/toolbar.png index 066aa34c8baeafa3917d909e47c41427b6163fa9..d35c67f6fa8ab230fb5df6a44d519f843f652318 100644 GIT binary patch delta 1097 zcmZ1=w@!9~BnLAC1H;=t4dNRWJ-8-UbIH_mh%vJ;@Jz93Wnf^O8sHP+3RDmn>=hW| z9Te&l9OfGm?iU*29~K!99u*i79T*uC6crmB9TyT49~zqw7MBg3tT~e7-T9w<@UDwguFm-mWiuyifbB6YIFQ+n@a1N%j#Ro8(J$G+bWyd ztC~BiTRLl6yJ~?RYVWBB`e{N#?9`e4Xg-^@pnvwl33C=roV$3^yd{(8FP*Yr+0=#0 zr!87Beeuc}OIFQXx_Z{KnR(0V*UVnNcFu}*b62jPw`#-u)f*SASyQ`a)55j$^44x% zv}x;_)8~#}xU}j2|Np`ZPOb*VjcQ4dUoem+3~p~)^c|>*G0EHArLE_lbu0q|lcuMO zV@Sl|x6>WHA3KN~pPyL2dV_od|FISh*V$qDaW+quT)$)6!EWE7Q#a*M)Au>HUl**D z^9qlWuIjkjO}f z)rc7h3*w%u|NE-R)*$+X<=Qom8LL@29J9SY-D}!yef;6$84k9S-^`h4y5Wh%x!bif zSF``%`o5Yo_Oz11nmaFl^!T}-*j5v<`l^_zx#Asl_UEc9pK4by{irjUdgt(?w8DL1 zm$Da3FH~sp5mZsHTf{I+dqSer#jn99>)&(n$=%F!dvo|Y!?GX~9YX`JPk-uax6Wx^ zrNH!O$rrbD)*a$)wrd%_dkfEedjHnUj+pGK=7S7oZZAtScd@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Qre-m{qmk2S4SEn8QvW~j!TUSV z_w|R6q(_$Q7Et)zE9x59+c&J#Q=i9BU%kRI00ssIbZM5-J2!O)twE2{X6hT!`Swou zTs7F-!eVlI1p&Ya0IQyQ44YovptMKM&7yhjGpct!I~;#43jms-!1Mf~aRATrpczUR z001y~;jg^mc2WBliS;P?bKx3HMVISBye27!f}U(8+!ZZ&jHniW)Pm33P~NKRkJ z$>S4X-FG$Kg~>4hDmw;{gTR~fxA63;l|`R=vR|b(ouXYz!lzUsh@xGlTr1gNJ0^yr ziYFM)R1tpfnS3Zg}W9RRuV&8bvkO#;&7qzCW#Enr~+q@0meLq5C0KFbyecSf3Gj?WW z0{>4v0)PcZ03ZNV1OOE6f|sEP0Lu}8%jqmK{}z8M=1%~yIRIXUasV*Z1B?uwQsn~* z>$U 1) { defaultZoom--; } - ShatteredPixelDungeon.scale(defaultZoom); } minZoom = 1; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java b/src/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java index 386f58839..86d065698 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java @@ -55,7 +55,7 @@ public class Toolbar extends Component { private Tool btnWait; private Tool btnSearch; private Tool btnInventory; - private Tool[] btnQuick; + private QuickslotTool[] btnQuick; 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) ); @@ -165,16 +165,44 @@ public class Toolbar extends Component { @Override protected void layout() { - 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 = 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; @@ -185,25 +213,26 @@ public class Toolbar extends Component { 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]); + btnQuick[0].setPos(btnInventory.left() - btnQuick[0].width(), visible[0]); + btnQuick[1].setPos(btnQuick[0].left() - btnQuick[1].width(), visible[1]); + btnQuick[2].setPos(btnQuick[1].left() - btnQuick[2].width(), visible[2]); + btnQuick[3].setPos(btnQuick[2].left() - btnQuick[3].width(), 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; + right = width - (width - btnWait.width() - btnSearch.width() - btnInventory.width() - + btnQuick[0].width() - btnQuick[1].width() - btnQuick[2].width() - btnQuick[3].width())/2; 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]); + btnQuick[0].setPos(btnInventory.left() - btnQuick[0].width(), visible[0]); + btnQuick[1].setPos(btnQuick[0].left() - btnQuick[1].width(), visible[1]); + btnQuick[2].setPos(btnQuick[1].left() - btnQuick[2].width(), visible[2]); + btnQuick[3].setPos(btnQuick[2].left() - btnQuick[3].width(), visible[3]); break; } right = width; @@ -318,8 +347,12 @@ public class Toolbar extends Component { public Tool( int x, int y, int width, int height ) { super(); + frame(x, y, width, height); + } + + public void frame( int x, int y, int width, int height) { base.frame( x, y, width, height ); - + this.width = width; this.height = height; } @@ -369,6 +402,8 @@ public class Toolbar extends Component { private static class QuickslotTool extends Tool { private QuickSlotButton slot; + private int borderLeft = 2; + private int borderRight = 2; public QuickslotTool( int x, int y, int width, int height, int slotNum ) { super( x, y, width, height ); @@ -376,11 +411,17 @@ public class Toolbar extends Component { slot = new QuickSlotButton( slotNum ); add( slot ); } + + public void border( int left, int right ){ + borderLeft = left; + borderRight = right; + layout(); + } @Override protected void 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