From 08f0b8d669bf1a8135ea1d8f68b206fcde06deac Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 8 May 2025 14:11:51 -0400 Subject: [PATCH] v3.1.0: gold now shows on the toolbar on mobile while buying items --- .../actors/mobs/npcs/Shopkeeper.java | 8 ++++++++ .../ui/CurrencyIndicator.java | 19 +++++++++++++++++-- .../windows/WndTradeItem.java | 3 +++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Shopkeeper.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Shopkeeper.java index 5584f1e80..e398c7e47 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Shopkeeper.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Shopkeeper.java @@ -42,6 +42,7 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ShopkeeperSprite; +import com.shatteredpixel.shatteredpixeldungeon.ui.CurrencyIndicator; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag; import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; @@ -250,6 +251,7 @@ public class Shopkeeper extends NPC { if (options[i].length() > maxLen) options[i] = options[i].substring(0, maxLen-3) + "..."; i++; } + CurrencyIndicator.showGold = true; GameScene.show(new WndOptions(sprite(), Messages.titleCase(name()), description(), options){ @Override protected void onSelect(int index) { @@ -290,6 +292,12 @@ public class Shopkeeper extends NPC { } return null; } + + @Override + public void hide() { + super.hide(); + CurrencyIndicator.showGold = false; + } }); } }); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/CurrencyIndicator.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/CurrencyIndicator.java index 89eecf5ae..39cf27ae9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/CurrencyIndicator.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/CurrencyIndicator.java @@ -39,13 +39,21 @@ public class CurrencyIndicator extends Component { private float goldTime; private float energyTime; + + public static boolean showGold = false; @Override protected void createChildren() { gold = new BitmapText( PixelScene.pixelFont); + gold.text( Integer.toString(lastGold) ); + gold.measure(); + gold.hardlight( 0xFFFF00 ); add( gold ); energy = new BitmapText( PixelScene.pixelFont); + energy.text( Integer.toString(lastEnergy) ); + energy.measure(); + energy.hardlight( 0x44CCFF ); add( energy ); gold.visible = energy.visible = false; @@ -96,7 +104,6 @@ public class CurrencyIndicator extends Component { gold.text( Integer.toString(lastGold) ); gold.measure(); - gold.hardlight( 0xFFFF00 ); gold.visible = true; goldTime = TIME; @@ -109,12 +116,20 @@ public class CurrencyIndicator extends Component { energy.text( Integer.toString(lastEnergy) ); energy.measure(); - energy.hardlight( 0x44CCFF ); energy.visible = true; energyTime = TIME; layout(); } + + if (showGold){ + if (!gold.visible){ + gold.visible = true; + layout(); + } + goldTime = TIME/2; + } + } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java index 1d992ca74..6f40a70ca 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java @@ -37,6 +37,7 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; +import com.shatteredpixel.shatteredpixeldungeon.ui.CurrencyIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; public class WndTradeItem extends WndInfoItem { @@ -121,6 +122,7 @@ public class WndTradeItem extends WndInfoItem { super(heap); selling = false; + CurrencyIndicator.showGold = true; Item item = heap.peek(); @@ -207,6 +209,7 @@ public class WndTradeItem extends WndInfoItem { public void hide() { super.hide(); + CurrencyIndicator.showGold = false; if (owner != null) { owner.hide();