v3.2.5: further improved dynamic island handling

This commit is contained in:
Evan Debenham
2025-09-26 11:16:00 -04:00
committed by Evan Debenham
parent a511156298
commit c9cb58bcf1
4 changed files with 58 additions and 16 deletions

View File

@@ -372,7 +372,9 @@ 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 = 55; //default max width
float[] buffBarRowLimits = new float[9];
float[] buffBarRowAdjusts = new float[9];
if (largeInsetTop == 0 && insets.top > 0){
//smaller non-notch cutouts are of varying size and may obstruct various UI elements
// some are small hole punches, some are huge dynamic islands
@@ -406,9 +408,21 @@ public class GameScene extends PixelScene {
&& cutout.top < 10
&& cutout.right > 32
&& cutout.bottom > 11) {
//subtract starting position, add a bit back to allow slight overlap
buffBarTopRowMaxWidth = cutout.left - 32 + 3;
//TODO dynamic island can block 2nd row too =S
int i = 1;
int rowTop = 11;
//in most cases this just obstructs one row, but dynamic island can block more =S
while (cutout.bottom > rowTop){
if (i == 1 || cutout.bottom > rowTop+2 ) { //always shorten first row
//subtract starting position, add a bit back to allow slight overlap
buffBarRowLimits[i] = cutout.left - 32 + 3;
} else {
//if row is only slightly cut off, lower it instead of limiting width
buffBarRowAdjusts[i] = cutout.bottom - rowTop + 1;
rowTop += buffBarRowAdjusts[i];
}
i++;
rowTop += 8;
}
}
}
@@ -438,7 +452,8 @@ public class GameScene extends PixelScene {
status.camera = uiCamera;
StatusPane.heroPaneExtraWidth = heroPaneExtraWidth;
StatusPane.hpBarMaxWidth = hpBarMaxWidth;
StatusPane.buffBarTopRowMaxWidth = buffBarTopRowMaxWidth;
StatusPane.buffBarRowMaxWidths = buffBarRowLimits;
StatusPane.buffBarRowAdjusts = buffBarRowAdjusts;
status.setRect(insets.left, uiSize > 0 ? uiCamera.height-39-insets.bottom : screentop, uiCamera.width - insets.left - insets.right, 0 );
add(status);
@@ -455,6 +470,13 @@ public class GameScene extends PixelScene {
boss = new BossHealthBar();
boss.camera = uiCamera;
boss.setPos( (uiCamera.width - boss.width())/2, screentop + (landscape() ? 7 : 26));
if (buffBarRowLimits[2] != 0){
//if we potentially have a 3rd buff bar row, lower by 7px
boss.setPos(boss.left(), boss.top() + 7);
} else if (buffBarRowAdjusts[2] != 0){
//
boss.setPos(boss.left(), boss.top() + buffBarRowAdjusts[2]);
}
add(boss);
resume = new ResumeIndicator();

View File

@@ -149,7 +149,10 @@ public class BuffIndicator extends Component {
private boolean large = false;
public float firstRowWidth = -1;
//in some cases we want to limit some rows but not all by just reducing width
public float[] rowWidthLimits = new float[9]; //0 = no limit
//sometimes we also need to slightly lower a row, to avoid having to cut off width
public float[] rowHeightAdjusts = new float[9]; //0 = default adjust of 1
public BuffIndicator( Char ch, boolean large ) {
super();
@@ -231,6 +234,7 @@ public class BuffIndicator extends Component {
//layout
int row = 1;
float rowTop = 0;
int pos = 0;
float lastIconRight = 0;
int total = 0;
@@ -241,18 +245,21 @@ public class BuffIndicator extends Component {
}
icon.visible = true;
//offset is needed to handle adjusting oversized click boxes on multiple rows
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-1)*(size+1)-icon.topOffset, size + 1, size + (large ? 0 : 5));
icon.setRect(x + pos * (size + 1), y + rowTop-icon.topOffset, size + 1, size + (large ? 0 : 5));
PixelScene.align(icon);
pos++;
lastIconRight = icon.right()-1;
if ((row+1)*(size+1) <= height
&& (pos * (size + 1) + size > width || (row == 1 && firstRowWidth != -1 && pos * (size + 1) + size > firstRowWidth))){
//if we're out of overall width but have more height, or this row has hits its limit
if ((rowTop+2*size+2 <= height && (pos * (size + 1) + size > width))
|| (rowWidthLimits[row] != 0 && pos * (size + 1) + size > rowWidthLimits[row])){
row++;
rowTop += size+1 + rowHeightAdjusts[row];
pos = 0;
}
total++;
@@ -265,7 +272,7 @@ public class BuffIndicator extends Component {
if (excessWidth > 0) {
//if multiple rows, only compress last row
ArrayList<BuffButton> buttons = new ArrayList<>();
float lastRowY = PixelScene.align(y + (row-1)*(size+1));
float lastRowY = PixelScene.align(y + rowTop);
int i = 1;
for (BuffButton button : buffButtons.values()){
if (i > maxBuffs){

View File

@@ -83,8 +83,9 @@ public class StatusPane extends Component {
//potentially shrinks and/or repositions the hp bar to avoid some cutouts
public static int hpBarMaxWidth = 50;
private Image hpCutout;
//potentially cuts off the top row of the the buff indicator to avoid some cutouts
public static float buffBarTopRowMaxWidth = 50;
//potentially adjusts the row(s) of the the buff indicator to avoid some cutouts
public static float[] buffBarRowMaxWidths;
public static float[] buffBarRowAdjusts;
public StatusPane( boolean large ){
super();
@@ -264,7 +265,12 @@ public class StatusPane extends Component {
heroInfoOnBar.setRect(heroInfo.right(), y, 50, 9);
buffs.firstRowWidth = buffBarTopRowMaxWidth;
if (buffBarRowMaxWidths != null){
buffs.rowWidthLimits = buffBarRowMaxWidths;
}
if (buffBarRowAdjusts != null){
buffs.rowHeightAdjusts = buffBarRowAdjusts;
}
buffs.setRect( x + heroPaneWidth + 1, y + 8, 55, 16 );
busy.x = x + 1;