diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java index fbe76f024..a64229a51 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -372,14 +372,14 @@ public class GameScene extends PixelScene { float heroPaneExtraWidth = insets.left; float menuBarMaxLeft = uiCamera.width-insets.right-MenuPane.WIDTH; int hpBarMaxWidth = 50; //default max width - float buffBarTopRowMaxWidth = 50; //default max width + float buffBarTopRowMaxWidth = 55; //default max width if (largeInsetTop == 0){ //iOS's Dynamic island badly obstructs the first buff bar row if (DeviceCompat.isiOS()){ //TODO bad to hardcode and approximate this atm // need to change this so iOS platformsupport returns cutout dimensions float cutoutLeft = (Game.width*0.3f)/defaultZoom; - buffBarTopRowMaxWidth = Math.min(50, cutoutLeft - 32); + buffBarTopRowMaxWidth = Math.min(55, cutoutLeft - 32); } else if (DeviceCompat.isAndroid()) { //Android hole punches are of varying size and may obstruct various UI elements RectF cutout = Game.platform.getDisplayCutout().scale(1f / defaultZoom); @@ -408,11 +408,12 @@ public class GameScene extends PixelScene { hpBarMaxWidth = Math.max(hpBarMaxWidth, 21); //cannot go below 21 (30 effective) } //if the cutout is positioned to obstruct the buff bar - if (cutout.left < 80 + if (cutout.left < 84 && cutout.top < 10 && cutout.right > 32 && cutout.bottom > 11) { - buffBarTopRowMaxWidth = cutout.left - 32; //subtract starting position + //subtract starting position, add a bit back to allow slight overlap + buffBarTopRowMaxWidth = cutout.left - 32 + 3; } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BossHealthBar.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BossHealthBar.java index 61a02ab5d..867bbd6a5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BossHealthBar.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BossHealthBar.java @@ -154,10 +154,12 @@ public class BossHealthBar extends Component { bossInfo.setRect(x, y, bar.width, bar.height); if (buffs != null) { + buffs.maxBuffs = 12; if (large) { - buffs.setRect(hp.x+1, hp.y + 12, 80, 16); + //little extra width here for a 6th column + buffs.setRect(hp.x+1, hp.y + 12, 102, 34); } else { - buffs.setRect(hp.x, hp.y + 5, 40, 7); + buffs.setRect(hp.x, hp.y + 5, 47, 16); } } 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 6f44e9de0..52149eccf 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIndicator.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIndicator.java @@ -180,6 +180,7 @@ public class BuffIndicator extends Component { } private boolean buffsHidden = false; + public int maxBuffs = 14; //by default @Override protected void layout() { @@ -228,32 +229,29 @@ public class BuffIndicator extends Component { } } - //TODO several aspects of the layout code have been a bit hackily changed to support 2 rows - // should clean this up - //layout - int row = 0; + int row = 1; int pos = 0; - float lastIconLeft = 0; + float lastIconRight = 0; int total = 0; for (BuffButton icon : buffButtons.values()){ - if (total >= 14){ //buff bar supports a max of 14 buffs at once + if (total >= maxBuffs){ icon.visible = false; continue; } icon.visible = true; - icon.topOffset = (row > 0 && !large) ? -1 : 0; + icon.topOffset = (row > 1 && !large) ? -1 : 0; icon.updateIcon(); //button areas are slightly oversized, especially on small buttons - icon.setRect(x + pos * (size + 1), y + row*(size+1)-icon.topOffset, size + 1, size + (large ? 0 : 5)); + icon.setRect(x + pos * (size + 1), y + (row-1)*(size+1)-icon.topOffset, size + 1, size + (large ? 0 : 5)); PixelScene.align(icon); pos++; - lastIconLeft = icon.left(); + lastIconRight = icon.right()-1; if ((row+1)*(size+1) <= height - && (pos * (size + 1) > width || (row == 0 && firstRowWidth != -1 && pos * (size + 1) > firstRowWidth))){ + && (pos * (size + 1) + size > width || (row == 1 && firstRowWidth != -1 && pos * (size + 1) + size > firstRowWidth))){ row++; pos = 0; } @@ -262,15 +260,15 @@ public class BuffIndicator extends Component { buffsHidden = false; //squish buff icons together if there isn't enough room - float excessWidth = lastIconLeft - right(); + float excessWidth = lastIconRight - right(); if (excessWidth > 0) { //if multiple rows, only compress last row ArrayList buttons = new ArrayList<>(); - float lastRowY = y + row*(size+1); + float lastRowY = PixelScene.align(y + (row-1)*(size+1)); int i = 1; for (BuffButton button : buffButtons.values()){ - if (i > 14){ + if (i > maxBuffs){ button.visible = false; buffsHidden = true; continue; @@ -282,12 +280,14 @@ public class BuffIndicator extends Component { } float leftAdjust = excessWidth/(buttons.size()-1); + //can't squish by more than 50% + if (leftAdjust >= size*0.48f) leftAdjust = size*0.5f; float cumulativeAdjust = leftAdjust * (buttons.size()-1); Collections.reverse(buttons); for (BuffButton icon : buttons) { icon.setPos(icon.left() - cumulativeAdjust, icon.top()); - icon.visible = icon.left() <= right(); + icon.visible = icon.right() <= right()+1; if (!icon.visible) buffsHidden = true; PixelScene.align(icon); bringToFront(icon); 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 ac226cde8..19a9bf4f4 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java @@ -222,7 +222,8 @@ public class StatusPane extends Component { heroInfoOnBar.setRect(heroInfo.right(), y + 19, 130, 20); - buffs.setRect(x + 31, y, 128, 16); + //little extra for 14th buff + buffs.setRect(x + 31, y, 142, 16); busy.x = x + bg.width + 1; busy.y = y + bg.height - 9; @@ -271,7 +272,7 @@ public class StatusPane extends Component { heroInfoOnBar.setRect(heroInfo.right(), y, 50, 9); buffs.firstRowWidth = buffBarTopRowMaxWidth; - buffs.setRect( x + heroPaneWidth + 1, y + 8, 50, 15 ); + buffs.setRect( x + heroPaneWidth + 1, y + 8, 55, 16 ); busy.x = x + 1; busy.y = y + 37; 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 619bf7005..5af1288a2 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoMob.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoMob.java @@ -71,23 +71,22 @@ 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.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.setPos(name.right(), name.bottom() - BuffIndicator.SIZE_SMALL-2); + buffs.maxBuffs = 50; //infinite, effectively + buffs.setRect(name.right(), name.bottom() - BuffIndicator.SIZE_SMALL-2, w - name.width(), 8); - height = Math.max(image.y + image.height(), health.bottom()); + //If buff bar doesn't have enough room, move it below + if (!buffs.allBuffsVisible()){ + buffs.setRect(0, health.bottom(), width, 8); + height = Math.max(image.y + image.height(), buffs.bottom()); + } else { + height = Math.max(image.y + image.height(), health.bottom()); + } } } }