From 95b2a2208b2af46b68009ddff406a886b2c02f70 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 31 Oct 2022 17:33:35 -0400 Subject: [PATCH] v1.4.3: adjusted mod info windows to be able to show compressed buffs --- .../shatteredpixeldungeon/ui/BuffIndicator.java | 12 ++++++++++-- .../windows/WndInfoMob.java | 16 +++++++++------- 2 files changed, 19 insertions(+), 9 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 3e891e973..31b3f6f2d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIndicator.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIndicator.java @@ -151,7 +151,9 @@ public class BuffIndicator extends Component { layout(); } } - + + private boolean buffsHidden = false; + @Override protected void layout() { @@ -213,11 +215,12 @@ public class BuffIndicator extends Component { lastIconLeft = icon.left(); } + buffsHidden = false; //squish buff icons together if there isn't enough room float excessWidth = lastIconLeft - right(); if (excessWidth > 0) { float leftAdjust = excessWidth/(buffButtons.size()-1); - //can't squish by more than 50% on desktop and 62% on mobile + //can't squish by more than 50% on large and 62% on small if (large && leftAdjust >= size*0.48f) leftAdjust = size*0.5f; if (!large && leftAdjust >= size*0.62f) leftAdjust = size*0.65f; float cumulativeAdjust = leftAdjust * (buffButtons.size()-1); @@ -227,6 +230,7 @@ public class BuffIndicator extends Component { for (BuffButton icon : buttons) { icon.setPos(icon.left() - cumulativeAdjust, icon.top()); icon.visible = icon.left() <= right(); + if (!icon.visible) buffsHidden = true; PixelScene.align(icon); bringToFront(icon); icon.givePointerPriority(); @@ -235,6 +239,10 @@ public class BuffIndicator extends Component { } } + public boolean allBuffsVisible(){ + return !buffsHidden; + } + private static class BuffButton extends IconButton { private Buff buff; 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 b9531a055..2c6b47d0d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoMob.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoMob.java @@ -71,19 +71,21 @@ public class WndInfoMob extends WndTitledMessage { image.y = Math.max( 0, name.height() + health.height() - image.height() ); float w = width - image.width() - GAP; + int extraBuffSpace = 0; + + //Tries to make space for up to 11 visible buffs + do { + name.maxWidth((int)w - extraBuffSpace); + buffs.setSize(w - name.width() - 8, 8); + extraBuffSpace += 8; + } while (extraBuffSpace <= 40 && !buffs.allBuffsVisible()); - name.maxWidth((int)w); name.setPos(x + image.width + GAP, image.height() > name.height() ? y +(image.height() - name.height()) / 2 : y); health.setRect(image.width() + GAP, name.bottom() + GAP, w, health.height()); - buffs.setRect( - name.right() + GAP-1, - name.bottom() - BuffIndicator.SIZE_SMALL-2, - w, - 8 - ); + buffs.setPos(name.right(), name.bottom() - BuffIndicator.SIZE_SMALL-2); height = health.bottom(); }