From 0b2815c77c01daa4c6bac1842fbe45b1ae346b55 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 7 Apr 2023 14:31:30 -0400 Subject: [PATCH] v2.0.2: more action ind. improvements, moved some info to new indicator --- .../src/main/assets/interfaces/hero_icons.png | Bin 1823 -> 1863 bytes .../actors/buffs/Berserk.java | 20 ++- .../actors/buffs/Combo.java | 19 ++- .../actors/buffs/Momentum.java | 32 +++-- .../actors/buffs/MonkEnergy.java | 38 ++++-- .../actors/buffs/Preparation.java | 42 +++--- .../actors/buffs/SnipersMark.java | 11 +- .../items/weapon/melee/MeleeWeapon.java | 17 ++- .../ui/ActionIndicator.java | 124 ++++++++++-------- .../shatteredpixeldungeon/ui/HeroIcon.java | 10 +- 10 files changed, 179 insertions(+), 134 deletions(-) diff --git a/core/src/main/assets/interfaces/hero_icons.png b/core/src/main/assets/interfaces/hero_icons.png index 148174b3b65046c0d16a34d69da93634f4549263..4a7c0525f8a35ff79cccca426d8cd5deb9270ec1 100644 GIT binary patch delta 1626 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 s;D7`G002PH|JUsZQ~&?~007`CX&> 16) * 0.875f); int g = (int) (((best.tintColor >> 8) & 0xFF) * 0.875f); int b = (int) ((best.tintColor & 0xFF) * 0.875f); return (r << 16) + (g << 8) + b; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Momentum.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Momentum.java index 2748bb818..62065c54f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Momentum.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Momentum.java @@ -27,11 +27,15 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; +import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIcon; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.HeroIcon; +import com.watabou.noosa.BitmapText; import com.watabou.noosa.Image; +import com.watabou.noosa.Visual; import com.watabou.noosa.audio.Sample; import com.watabou.utils.Bundle; import com.watabou.utils.GameMath; @@ -77,6 +81,8 @@ public class Momentum extends Buff implements ActionIndicator.Action { if (momentumStacks <= 0) { ActionIndicator.clearAction(this); if (freerunCooldown <= 0) detach(); + } else { + ActionIndicator.refresh(); } } movedLastTurn = false; @@ -123,12 +129,10 @@ public class Momentum extends Buff implements ActionIndicator.Action { @Override public void tintIcon(Image icon) { - if (freerunTurns > 0){ + if (freerunCooldown == 0){ icon.hardlight(1,1,0); - } else if (freerunCooldown > 0){ - icon.hardlight(0.5f,0.5f,1); } else { - icon.hardlight(1f - (momentumStacks /10f),1,1f - (momentumStacks /10f)); + icon.hardlight(0.5f,0.5f,1); } } @@ -139,7 +143,7 @@ public class Momentum extends Buff implements ActionIndicator.Action { } else if (freerunCooldown > 0){ return (freerunCooldown) / 30f; } else { - return (10 - momentumStacks) / 10f; + return 0; } } @@ -150,7 +154,7 @@ public class Momentum extends Buff implements ActionIndicator.Action { } else if (freerunCooldown > 0){ return Integer.toString(freerunCooldown); } else { - return Integer.toString(momentumStacks); + return ""; } } @@ -206,19 +210,21 @@ public class Momentum extends Buff implements ActionIndicator.Action { } @Override - public Image actionIcon() { - Image actionIco = new HeroIcon(HeroIcon.MOMENTUM); - actionIco.hardlight(1, 1, 0); - return actionIco; + public int actionIcon() { + return HeroIcon.MOMENTUM; } @Override - public Image secondIcon() { - return null; + public Visual secondaryVisual() { + BitmapText txt = new BitmapText(PixelScene.pixelFont); + txt.text(Integer.toString((int)momentumStacks) ); + txt.hardlight(CharSprite.POSITIVE); + txt.measure(); + return txt; } @Override - public int actionColor() { + public int indicatorColor() { return 0x444444; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/MonkEnergy.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/MonkEnergy.java index 99b2ec4bd..060ad9c1b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/MonkEnergy.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/MonkEnergy.java @@ -43,14 +43,18 @@ import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; +import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.AttackIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.HeroIcon; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoItem; import com.shatteredpixel.shatteredpixeldungeon.windows.WndMonkAbilities; import com.watabou.noosa.BitmapText; import com.watabou.noosa.Image; +import com.watabou.noosa.Visual; import com.watabou.noosa.audio.Sample; import com.watabou.utils.Bundle; import com.watabou.utils.Callback; @@ -65,6 +69,8 @@ public class MonkEnergy extends Buff implements ActionIndicator.Action { public float energy; public int cooldown; + private static final float MAX_COOLDOWN = 5; + @Override public int icon() { return BuffIndicator.MONK_ENERGY; @@ -74,8 +80,6 @@ public class MonkEnergy extends Buff implements ActionIndicator.Action { public void tintIcon(Image icon) { if (cooldown > 0){ icon.hardlight(0.33f, 0.33f, 1f); - } else if (abilitiesEmpowered(Dungeon.hero)) { - icon.tint(0.6f, 1f, 0.2f, 0.33f); } else { icon.resetColor(); } @@ -83,12 +87,16 @@ public class MonkEnergy extends Buff implements ActionIndicator.Action { @Override public float iconFadePercent() { - return Math.max(0, (energyCap() - energy)/ energyCap()); + return Math.max(0, cooldown/MAX_COOLDOWN); } @Override public String iconTextDisplay() { - return Integer.toString((int)energy); + if (cooldown > 0){ + return Integer.toString(cooldown); + } else { + return ""; + } } @Override @@ -218,6 +226,8 @@ public class MonkEnergy extends Buff implements ActionIndicator.Action { if (cooldown > 0 || energy < 1){ ActionIndicator.clearAction(this); + } else { + ActionIndicator.refresh(); } BuffIndicator.refreshHero(); } @@ -243,22 +253,22 @@ public class MonkEnergy extends Buff implements ActionIndicator.Action { } @Override - public Image actionIcon() { - return new HeroIcon(HeroIcon.MONK_ABILITIES); + public int actionIcon() { + return HeroIcon.MONK_ABILITIES; } @Override - public Image secondIcon() { - return null; + public Visual secondaryVisual() { + BitmapText txt = new BitmapText(PixelScene.pixelFont); + txt.text( Integer.toString((int)energy) ); + if (abilitiesEmpowered(Dungeon.hero)) txt.hardlight(CharSprite.POSITIVE); + txt.measure(); + return txt; } @Override - public int actionColor() { - if (abilitiesEmpowered(Dungeon.hero)){ - return 0xA0FF40; - } else { - return 0xA08840; - } + public int indicatorColor() { + return 0xA08840; } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Preparation.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Preparation.java index ea5c3043c..f33e86298 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Preparation.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Preparation.java @@ -34,12 +34,16 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; +import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; +import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.HeroIcon; import com.shatteredpixel.shatteredpixeldungeon.utils.BArray; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; +import com.watabou.noosa.BitmapText; import com.watabou.noosa.Image; +import com.watabou.noosa.Visual; import com.watabou.noosa.audio.Sample; import com.watabou.utils.Bundle; import com.watabou.utils.PathFinder; @@ -183,25 +187,6 @@ public class Preparation extends Buff implements ActionIndicator.Action { } } - @Override - public float iconFadePercent() { - AttackLevel level = AttackLevel.getLvl(turnsInvis); - if (level == AttackLevel.LVL_4){ - return 0; - } else { - float turnsForCur = level.turnsReq; - float turnsForNext = AttackLevel.values()[level.ordinal()+1].turnsReq; - turnsForNext -= turnsForCur; - float turnsToNext = turnsInvis - turnsForCur; - return Math.min(1, (turnsForNext - turnsToNext)/(turnsForNext)); - } - } - - @Override - public String iconTextDisplay() { - return Integer.toString(turnsInvis); - } - @Override public String desc() { String desc = Messages.get(this, "desc"); @@ -252,19 +237,28 @@ public class Preparation extends Buff implements ActionIndicator.Action { } @Override - public Image actionIcon() { - Image actionIco = new HeroIcon(HeroIcon.PREPARATION); + public int actionIcon() { + return HeroIcon.PREPARATION; + } + + @Override + public Visual primaryVisual() { + Image actionIco = new HeroIcon(this); tintIcon(actionIco); return actionIco; } @Override - public Image secondIcon() { - return null; + public Visual secondaryVisual() { + BitmapText txt = new BitmapText(PixelScene.pixelFont); + txt.text(Integer.toString(Math.min(9, turnsInvis))); + txt.hardlight(CharSprite.POSITIVE); + txt.measure(); + return txt; } @Override - public int actionColor() { + public int indicatorColor() { return 0x444444; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/SnipersMark.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/SnipersMark.java index b52caf770..59de08cf2 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/SnipersMark.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/SnipersMark.java @@ -114,17 +114,12 @@ public class SnipersMark extends FlavourBuff implements ActionIndicator.Action { } @Override - public Image actionIcon() { - return new HeroIcon(HeroIcon.SNIPERS_MARK); + public int actionIcon() { + return HeroIcon.SNIPERS_MARK; } @Override - public Image secondIcon() { - return null; - } - - @Override - public int actionColor() { + public int indicatorColor() { return 0x444444; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MeleeWeapon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MeleeWeapon.java index 754672b4a..834f01b57 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MeleeWeapon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MeleeWeapon.java @@ -46,8 +46,10 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.AttackIndicator; +import com.shatteredpixel.shatteredpixeldungeon.ui.HeroIcon; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.noosa.Image; +import com.watabou.noosa.Visual; import com.watabou.noosa.audio.Sample; import com.watabou.utils.Bundle; import com.watabou.utils.Random; @@ -548,10 +550,15 @@ public class MeleeWeapon extends Weapon { } @Override - public Image actionIcon() { + public int actionIcon() { + return HeroIcon.WEAPON_SWAP; + } + + @Override + public Visual primaryVisual() { Image ico; if (Dungeon.hero.belongings.weapon == null){ - ico = new ItemSprite(ItemSpriteSheet.WEAPON_HOLDER); + ico = new HeroIcon(this); } else { ico = new ItemSprite(Dungeon.hero.belongings.weapon); } @@ -560,10 +567,10 @@ public class MeleeWeapon extends Weapon { } @Override - public Image secondIcon() { + public Visual secondaryVisual() { Image ico; if (Dungeon.hero.belongings.secondWep == null){ - ico = new ItemSprite(ItemSpriteSheet.WEAPON_HOLDER); + ico = new HeroIcon(this); } else { ico = new ItemSprite(Dungeon.hero.belongings.secondWep); } @@ -573,7 +580,7 @@ public class MeleeWeapon extends Weapon { } @Override - public int actionColor() { + public int indicatorColor() { return 0x5500BB; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ActionIndicator.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ActionIndicator.java index 93934b8df..d19d919a3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ActionIndicator.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ActionIndicator.java @@ -26,12 +26,13 @@ import com.shatteredpixel.shatteredpixeldungeon.SPDAction; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.watabou.input.GameAction; -import com.watabou.noosa.Image; +import com.watabou.noosa.BitmapText; +import com.watabou.noosa.Visual; public class ActionIndicator extends Tag { - Image icon; - Image secondIcon; + Visual primaryVis; + Visual secondVis; public static Action action; public static ActionIndicator instance; @@ -60,44 +61,72 @@ public class ActionIndicator extends Tag { protected synchronized void layout() { super.layout(); - if (icon != null){ - if (!flipped) icon.x = x + (SIZE - icon.width()) / 2f + 1; - else icon.x = x + width - (SIZE + icon.width()) / 2f - 1; - icon.y = y + (height - icon.height()) / 2f; - PixelScene.align(icon); - if (secondIcon != null){ - secondIcon.x = icon.center().x + 8 - secondIcon.width(); - secondIcon.y = icon.y + icon.height() - secondIcon.height(); + if (primaryVis != null){ + if (!flipped) primaryVis.x = x + (SIZE - primaryVis.width()) / 2f + 1; + else primaryVis.x = x + width - (SIZE + primaryVis.width()) / 2f - 1; + primaryVis.y = y + (height - primaryVis.height()) / 2f; + PixelScene.align(primaryVis); + if (secondVis != null){ + if (secondVis.width() > 16) secondVis.x = primaryVis.center().x - secondVis.width()/2f; + else secondVis.x = primaryVis.center().x + 8 - secondVis.width(); + if (secondVis instanceof BitmapText){ + //need a special case here for text unfortunately + secondVis.y = primaryVis.center().y + 8 - ((BitmapText) secondVis).baseLine(); + } else { + secondVis.y = primaryVis.center().y + 8 - secondVis.height(); + } + PixelScene.align(secondVis); } } } - private boolean needsLayout = false; + private boolean needsRefresh = false; @Override public synchronized void update() { super.update(); - if (!Dungeon.hero.ready){ - if (icon != null) icon.alpha(0.5f); - if (secondIcon != null) secondIcon.alpha(0.5f); - } else { - if (icon != null) icon.alpha(1f); - if (secondIcon != null) secondIcon.alpha(1f); - } - if (!visible && action != null){ visible = true; - refresh(); + needsRefresh = true; flash(); } else { visible = action != null; } - - if (needsLayout){ + + if (needsRefresh){ + if (primaryVis != null) { + primaryVis.killAndErase(); + primaryVis = null; + } + if (secondVis != null){ + secondVis.killAndErase(); + secondVis = null; + } + if (action != null) { + primaryVis = action.primaryVisual(); + add(primaryVis); + + secondVis = action.secondaryVisual(); + if (secondVis != null){ + add(secondVis); + } + + needsRefresh = true; + setColor(action.indicatorColor()); + } + layout(); - needsLayout = false; } + + if (!Dungeon.hero.ready){ + if (primaryVis != null) primaryVis.alpha(0.5f); + if (secondVis != null) secondVis.alpha(0.5f); + } else { + if (primaryVis != null) primaryVis.alpha(1f); + if (secondVis != null) secondVis.alpha(1f); + } + } @Override @@ -130,44 +159,31 @@ public class ActionIndicator extends Tag { public static void refresh(){ if (instance != null){ - synchronized (instance) { - if (instance.icon != null) { - instance.icon.killAndErase(); - instance.icon = null; - } - if (instance.secondIcon != null){ - instance.secondIcon.killAndErase(); - instance.secondIcon = null; - } - if (action != null) { - instance.icon = action.actionIcon(); - instance.add(instance.icon); - - Image secondIco = action.secondIcon(); - if (secondIco != null){ - instance.secondIcon = secondIco; - instance.add(instance.secondIcon); - } - - instance.needsLayout = true; - instance.setColor(action.actionColor()); - } - } + instance.needsRefresh = true; } } - public interface Action{ + public interface Action { - public String actionName(); + String actionName(); - public Image actionIcon(); + default int actionIcon(){ + return HeroIcon.NONE; + } - //TODO more variable than an icon maybe - public Image secondIcon(); + //usually just a static icon, unless overridden + default Visual primaryVisual(){ + return new HeroIcon(this); + } - public int actionColor(); + //a smaller visual on the bottom-right, usually a tiny icon or bitmap text + default Visual secondaryVisual(){ + return null; //no second visual by default + } - public void doAction(); + int indicatorColor(); + + void doAction(); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/HeroIcon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/HeroIcon.java index 773e03269..83139baeb 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/HeroIcon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/HeroIcon.java @@ -34,7 +34,7 @@ public class HeroIcon extends Image { private static final int SIZE = 16; //transparent icon - public static final int NONE = 31; + public static final int NONE = 63; //subclasses public static final int BERSERKER = 0; @@ -72,7 +72,8 @@ public class HeroIcon extends Image { public static final int PREPARATION = 34; public static final int MOMENTUM = 35; public static final int SNIPERS_MARK = 36; - public static final int MONK_ABILITIES = 37; + public static final int WEAPON_SWAP = 37; + public static final int MONK_ABILITIES = 38; public HeroIcon(HeroSubClass subCls){ super( Assets.Interfaces.HERO_ICONS ); @@ -90,13 +91,12 @@ public class HeroIcon extends Image { frame(film.get(abil.icon())); } - //TODO make this consistent with subclass and ability icons - public HeroIcon(int icon){ + public HeroIcon(ActionIndicator.Action action){ super( Assets.Interfaces.HERO_ICONS ); if (film == null){ film = new TextureFilm(texture, SIZE, SIZE); } - frame(film.get(icon)); + frame(film.get(action.actionIcon())); } }