v3.2.5: cleaned up some code and logic relating to buff indicators
This fixes some errors in enemy info windows, cases of cutouts cutting off some buffs, and lets more buffs appear in mob info windows
This commit is contained in:
@@ -372,14 +372,14 @@ public class GameScene extends PixelScene {
|
|||||||
float heroPaneExtraWidth = insets.left;
|
float heroPaneExtraWidth = insets.left;
|
||||||
float menuBarMaxLeft = uiCamera.width-insets.right-MenuPane.WIDTH;
|
float menuBarMaxLeft = uiCamera.width-insets.right-MenuPane.WIDTH;
|
||||||
int hpBarMaxWidth = 50; //default max width
|
int hpBarMaxWidth = 50; //default max width
|
||||||
float buffBarTopRowMaxWidth = 50; //default max width
|
float buffBarTopRowMaxWidth = 55; //default max width
|
||||||
if (largeInsetTop == 0){
|
if (largeInsetTop == 0){
|
||||||
//iOS's Dynamic island badly obstructs the first buff bar row
|
//iOS's Dynamic island badly obstructs the first buff bar row
|
||||||
if (DeviceCompat.isiOS()){
|
if (DeviceCompat.isiOS()){
|
||||||
//TODO bad to hardcode and approximate this atm
|
//TODO bad to hardcode and approximate this atm
|
||||||
// need to change this so iOS platformsupport returns cutout dimensions
|
// need to change this so iOS platformsupport returns cutout dimensions
|
||||||
float cutoutLeft = (Game.width*0.3f)/defaultZoom;
|
float cutoutLeft = (Game.width*0.3f)/defaultZoom;
|
||||||
buffBarTopRowMaxWidth = Math.min(50, cutoutLeft - 32);
|
buffBarTopRowMaxWidth = Math.min(55, cutoutLeft - 32);
|
||||||
} else if (DeviceCompat.isAndroid()) {
|
} else if (DeviceCompat.isAndroid()) {
|
||||||
//Android hole punches are of varying size and may obstruct various UI elements
|
//Android hole punches are of varying size and may obstruct various UI elements
|
||||||
RectF cutout = Game.platform.getDisplayCutout().scale(1f / defaultZoom);
|
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)
|
hpBarMaxWidth = Math.max(hpBarMaxWidth, 21); //cannot go below 21 (30 effective)
|
||||||
}
|
}
|
||||||
//if the cutout is positioned to obstruct the buff bar
|
//if the cutout is positioned to obstruct the buff bar
|
||||||
if (cutout.left < 80
|
if (cutout.left < 84
|
||||||
&& cutout.top < 10
|
&& cutout.top < 10
|
||||||
&& cutout.right > 32
|
&& cutout.right > 32
|
||||||
&& cutout.bottom > 11) {
|
&& 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,10 +154,12 @@ public class BossHealthBar extends Component {
|
|||||||
bossInfo.setRect(x, y, bar.width, bar.height);
|
bossInfo.setRect(x, y, bar.width, bar.height);
|
||||||
|
|
||||||
if (buffs != null) {
|
if (buffs != null) {
|
||||||
|
buffs.maxBuffs = 12;
|
||||||
if (large) {
|
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 {
|
} else {
|
||||||
buffs.setRect(hp.x, hp.y + 5, 40, 7);
|
buffs.setRect(hp.x, hp.y + 5, 47, 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ public class BuffIndicator extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean buffsHidden = false;
|
private boolean buffsHidden = false;
|
||||||
|
public int maxBuffs = 14; //by default
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void layout() {
|
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
|
//layout
|
||||||
int row = 0;
|
int row = 1;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
float lastIconLeft = 0;
|
float lastIconRight = 0;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for (BuffButton icon : buffButtons.values()){
|
for (BuffButton icon : buffButtons.values()){
|
||||||
if (total >= 14){ //buff bar supports a max of 14 buffs at once
|
if (total >= maxBuffs){
|
||||||
icon.visible = false;
|
icon.visible = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
icon.visible = true;
|
icon.visible = true;
|
||||||
|
|
||||||
icon.topOffset = (row > 0 && !large) ? -1 : 0;
|
icon.topOffset = (row > 1 && !large) ? -1 : 0;
|
||||||
icon.updateIcon();
|
icon.updateIcon();
|
||||||
//button areas are slightly oversized, especially on small buttons
|
//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);
|
PixelScene.align(icon);
|
||||||
pos++;
|
pos++;
|
||||||
|
|
||||||
lastIconLeft = icon.left();
|
lastIconRight = icon.right()-1;
|
||||||
|
|
||||||
if ((row+1)*(size+1) <= height
|
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++;
|
row++;
|
||||||
pos = 0;
|
pos = 0;
|
||||||
}
|
}
|
||||||
@@ -262,15 +260,15 @@ public class BuffIndicator extends Component {
|
|||||||
|
|
||||||
buffsHidden = false;
|
buffsHidden = false;
|
||||||
//squish buff icons together if there isn't enough room
|
//squish buff icons together if there isn't enough room
|
||||||
float excessWidth = lastIconLeft - right();
|
float excessWidth = lastIconRight - right();
|
||||||
|
|
||||||
if (excessWidth > 0) {
|
if (excessWidth > 0) {
|
||||||
//if multiple rows, only compress last row
|
//if multiple rows, only compress last row
|
||||||
ArrayList<BuffButton> buttons = new ArrayList<>();
|
ArrayList<BuffButton> buttons = new ArrayList<>();
|
||||||
float lastRowY = y + row*(size+1);
|
float lastRowY = PixelScene.align(y + (row-1)*(size+1));
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (BuffButton button : buffButtons.values()){
|
for (BuffButton button : buffButtons.values()){
|
||||||
if (i > 14){
|
if (i > maxBuffs){
|
||||||
button.visible = false;
|
button.visible = false;
|
||||||
buffsHidden = true;
|
buffsHidden = true;
|
||||||
continue;
|
continue;
|
||||||
@@ -282,12 +280,14 @@ public class BuffIndicator extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float leftAdjust = excessWidth/(buttons.size()-1);
|
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);
|
float cumulativeAdjust = leftAdjust * (buttons.size()-1);
|
||||||
|
|
||||||
Collections.reverse(buttons);
|
Collections.reverse(buttons);
|
||||||
for (BuffButton icon : buttons) {
|
for (BuffButton icon : buttons) {
|
||||||
icon.setPos(icon.left() - cumulativeAdjust, icon.top());
|
icon.setPos(icon.left() - cumulativeAdjust, icon.top());
|
||||||
icon.visible = icon.left() <= right();
|
icon.visible = icon.right() <= right()+1;
|
||||||
if (!icon.visible) buffsHidden = true;
|
if (!icon.visible) buffsHidden = true;
|
||||||
PixelScene.align(icon);
|
PixelScene.align(icon);
|
||||||
bringToFront(icon);
|
bringToFront(icon);
|
||||||
|
|||||||
@@ -222,7 +222,8 @@ public class StatusPane extends Component {
|
|||||||
|
|
||||||
heroInfoOnBar.setRect(heroInfo.right(), y + 19, 130, 20);
|
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.x = x + bg.width + 1;
|
||||||
busy.y = y + bg.height - 9;
|
busy.y = y + bg.height - 9;
|
||||||
@@ -271,7 +272,7 @@ public class StatusPane extends Component {
|
|||||||
heroInfoOnBar.setRect(heroInfo.right(), y, 50, 9);
|
heroInfoOnBar.setRect(heroInfo.right(), y, 50, 9);
|
||||||
|
|
||||||
buffs.firstRowWidth = buffBarTopRowMaxWidth;
|
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.x = x + 1;
|
||||||
busy.y = y + 37;
|
busy.y = y + 37;
|
||||||
|
|||||||
+9
-10
@@ -71,23 +71,22 @@ public class WndInfoMob extends WndTitledMessage {
|
|||||||
image.y = Math.max( 0, name.height() + health.height() - image.height() );
|
image.y = Math.max( 0, name.height() + health.height() - image.height() );
|
||||||
|
|
||||||
float w = width - image.width() - GAP;
|
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,
|
name.setPos(x + image.width() + GAP,
|
||||||
image.height() > name.height() ? y +(image.height() - name.height()) / 2 : y);
|
image.height() > name.height() ? y +(image.height() - name.height()) / 2 : y);
|
||||||
|
|
||||||
health.setRect(image.width() + GAP, name.bottom() + GAP, w, health.height());
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user