From df43c611e750dc60a86d5b55f25d828f1d7ec11e Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 4 Jul 2016 19:52:30 -0400 Subject: [PATCH] v0.4.1: keys now display in the journal button --- assets/menu_button.png | Bin 330 -> 617 bytes .../items/keys/SkeletonKey.java | 2 +- .../shatteredpixeldungeon/ui/StatusPane.java | 54 +++++++++++++----- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/assets/menu_button.png b/assets/menu_button.png index dd2478af1c28a8767b04300a090bc2cdd5c58afe..a118f69cba386d21c8c11ac74820e255ca92c4bc 100644 GIT binary patch delta 576 zcmV-G0>Ayr0_g;h7#j!%0001{=Xogr000JJOGiWi{{a60|De66laV1He;oxn4h|X9 zu z5m!gWMR%uyRK$RTpx7&76DP6Fat@mFqK!!|SNcKdyYybT@7??Hk+r?W(F3?m4+r~4 zl*T8Y&x^Cx>-E_EL=^k|f1KO&;JR;0B!-6vm3+s>M?-#`b1onH_geO4j8PB>d2f^* z8-T@yd7PeIV&mf_6^Z+YcMO!*Q~Q?AtJpi<#na=nATN`QTgzD>lZ>)s1Mr(vQZ!ly zCR6&B9S55evx&anZnwE%7#(k)F-Alb3Qm+AhrVvsdD(HqZ`pBBe=*I(zJ_5$rm@Z} z&>n!bT1`Bj@8flK6`t?^OP))R*HQZ!W7MffMA?Z;KnD(s#n5`kaWHanlBrX7>H|R# zvX()v8yOJ5wry+yShK7@fk^|Ih|b&ZY6b-LUolM_{*wX9I^cr+{4vedb%5@s=lMPW z;MKNaSyp6es3N2Te+nRei)=bTX8r zd)qzWtgyS01!4+_ASh0Oru&AO;uHp!mqN-e z2?F1h<)zeqSu;U2x^MEzI^gQ63IMpN-6Wj*2 z)*l2483g!*xB_V)5M*TyjSR@hNi43&sctB4P%~}rsA_3x>7U#(Q%`U4vZ?z6EPwv| z`Tzg_$9q)rfEt)eg8YIR4Ap(lG68vv^-13DF8mU^7;XZ2lRRAV#|9>vOF7bz*X--%MvuMMSAB8hM6x)R`GV=*fDSI5c;pP87|9|)f-0Hp0qPjqO zqlwmyI6fv*Hvz8TgI&f61*_Pd615E6SZ8pt1U544vSBEhHNA-Svdw;=^B6o`{an^L HB{Ts50&{MA diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/keys/SkeletonKey.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/keys/SkeletonKey.java index df817dfd7..acb95f640 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/keys/SkeletonKey.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/keys/SkeletonKey.java @@ -43,7 +43,7 @@ public class SkeletonKey extends Key { @Override public boolean doPickUp(Hero hero) { - Dungeon.hero.belongings.specialKeys[Dungeon.depth]++; + Dungeon.hero.belongings.specialKeys[depth]++; return super.doPickUp(hero); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java b/src/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java index 1adddafcf..21f3379cb 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java @@ -58,7 +58,6 @@ public class StatusPane extends Component { private BossHealthBar bossHP; private int lastLvl = -1; - private int lastKeys = -1; private BitmapText level; private BitmapText depth; @@ -222,6 +221,7 @@ public class StatusPane extends Component { private static class JournalButton extends Button { private Image bg; + //used to display key state to the player private Image icon; public JournalButton() { @@ -238,7 +238,7 @@ public class StatusPane extends Component { bg = new Image( Assets.MENU, 2, 2, 13, 11 ); add( bg ); - icon = new Image( Assets.MENU, 32, 1, 10, 6); + icon = new Image( Assets.MENU, 31, 0, 11, 7); add( icon ); } @@ -249,41 +249,69 @@ public class StatusPane extends Component { bg.x = x + 13; bg.y = y + 2; - icon.x = bg.x + 2; - icon.y = bg.y + 3; + icon.x = bg.x + (bg.width() - icon.width())/2f; + icon.y = bg.y + (bg.height() - icon.height())/2f; + PixelScene.align(icon); } @Override public void update() { super.update(); + updateKeyDisplay(); + } + public void updateKeyDisplay() { + boolean foundKeys = false; + boolean blackKey = false; + boolean specialKey = false; + int ironKeys = 0; + for (int i = 1; i <= Dungeon.depth; i++) { + if (Dungeon.hero.belongings.ironKeys[i] > 0 || Dungeon.hero.belongings.specialKeys[i] > 0) { + foundKeys = true; - for (int i = 1; i <= Dungeon.depth; i++){ - if (Dungeon.hero.belongings.ironKeys[i] > 0){ + if (i < Dungeon.depth){ + blackKey = true; - if (i == Dungeon.depth){ - icon.resetColor(); } else { - icon.brightness(0); - icon.alpha(1f); + if (Dungeon.hero.belongings.specialKeys[i] > 0){ + specialKey = true; + } + ironKeys = Dungeon.hero.belongings.ironKeys[i]; } - return; } } - icon.brightness(0); - icon.alpha(0.33f); + if (!foundKeys){ + icon.frame(31, 0, 11, 7); + } else { + int left = 46, top = 0, width = 0, height = 7; + if (blackKey){ + left = 43; + width += 3; + } + if (specialKey){ + top = 8; + width += 3; + } + width += ironKeys*3; + width = Math.min( width, 9); + icon.frame(left, top, width, height); + } + layout(); + } @Override protected void onTouchDown() { bg.brightness( 1.5f ); + icon.brightness( 1.5f ); Sample.INSTANCE.play( Assets.SND_CLICK ); } @Override protected void onTouchUp() { bg.resetColor(); + icon.resetColor(); } @Override