From 632ae6cca04a953b2237cbe13fc029f015128cb6 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 19 Jan 2022 20:15:42 -0500 Subject: [PATCH] v1.2.0: added functionality for large buff indicators --- .../ui/BuffIndicator.java | 26 ++++++++++++------- .../shatteredpixeldungeon/ui/StatusPane.java | 2 +- .../windows/WndInfoMob.java | 4 +-- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIndicator.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIndicator.java index b4675bd61..07534aff0 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIndicator.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIndicator.java @@ -101,18 +101,22 @@ public class BuffIndicator extends Component { public static final int ANKH = 52; public static final int NOINV = 53; - public static final int SIZE = 7; + public static final int SIZE_SMALL = 7; + public static final int SIZE_LARGE = 16; private static BuffIndicator heroInstance; private LinkedHashMap buffButtons = new LinkedHashMap<>(); private boolean needsRefresh; private Char ch; + + private boolean large = false; - public BuffIndicator( Char ch ) { + public BuffIndicator( Char ch, boolean large ) { super(); this.ch = ch; + this.large = large; if (ch == Dungeon.hero) { heroInstance = this; } @@ -138,19 +142,21 @@ public class BuffIndicator extends Component { @Override protected void layout() { - + ArrayList newBuffs = new ArrayList<>(); for (Buff buff : ch.buffs()) { if (buff.icon() != NONE) { newBuffs.add(buff); } } - + + int size = large ? SIZE_LARGE : SIZE_SMALL; + //remove any icons no longer present for (Buff buff : buffButtons.keySet().toArray(new Buff[0])){ if (!newBuffs.contains(buff)){ Image icon = buffButtons.get( buff ).icon; - icon.origin.set( SIZE / 2f ); + icon.originToCenter(); icon.alpha(0.6f); add( icon ); add( new AlphaTweener( icon, 0, 0.6f ) { @@ -175,7 +181,7 @@ public class BuffIndicator extends Component { //add new icons for (Buff buff : newBuffs) { if (!buffButtons.containsKey(buff)) { - BuffButton icon = new BuffButton(buff); + BuffButton icon = new BuffButton(buff, large); add(icon); buffButtons.put( buff, icon ); } @@ -185,7 +191,8 @@ public class BuffIndicator extends Component { int pos = 0; for (BuffButton icon : buffButtons.values()){ icon.updateIcon(); - icon.setRect(x + pos * (SIZE + 2), y, 9, 12); + //button areas are slightly oversized, especially on small buttons + icon.setRect(x + pos * (size + 2), y, size + 2, size + (large ? 2 : 5)); PixelScene.align(icon); pos++; } @@ -198,8 +205,9 @@ public class BuffIndicator extends Component { //Todo maybe move into buff icon? public Image grey; - public BuffButton(Buff buff ){ - super( new BuffIcon(buff, false)); + //TODO for large buffs there is room to have text instead of fading + public BuffButton( Buff buff, boolean large ){ + super( new BuffIcon(buff, large)); this.buff = buff; bringToFront(grey); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java index 4720fabdd..cd68fd364 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java @@ -125,7 +125,7 @@ public class StatusPane extends Component { level.hardlight( 0xFFFFAA ); add( level ); - buffs = new BuffIndicator( Dungeon.hero ); + buffs = new BuffIndicator( Dungeon.hero, false ); add( buffs ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoMob.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoMob.java index c8c94e508..9a062c27c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoMob.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoMob.java @@ -60,7 +60,7 @@ public class WndInfoMob extends WndTitledMessage { health.level(mob); add( health ); - buffs = new BuffIndicator( mob ); + buffs = new BuffIndicator( mob, false ); add( buffs ); } @@ -80,7 +80,7 @@ public class WndInfoMob extends WndTitledMessage { buffs.setPos( name.right() + GAP-1, - name.bottom() - BuffIndicator.SIZE-2 + name.bottom() - BuffIndicator.SIZE_SMALL-2 ); height = health.bottom();