v1.4.3: adjusted mod info windows to be able to show compressed buffs

This commit is contained in:
Evan Debenham
2022-10-31 17:33:35 -04:00
parent 9aa8cf87e5
commit 95b2a2208b
2 changed files with 19 additions and 9 deletions

View File

@@ -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;

View File

@@ -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();
}