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 ffc77e832..1d5f31298 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -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(); 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 52149eccf..3c61c99ac 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIndicator.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BuffIndicator.java @@ -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 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){ 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 fd0af2094..49ca6b367 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java @@ -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; diff --git a/ios/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ios/IOSPlatformSupport.java b/ios/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ios/IOSPlatformSupport.java index 82ad8deef..a377a6fa3 100644 --- a/ios/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ios/IOSPlatformSupport.java +++ b/ios/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ios/IOSPlatformSupport.java @@ -36,7 +36,6 @@ import com.watabou.utils.PlatformSupport; import com.watabou.utils.RectF; import org.robovm.apple.audiotoolbox.AudioServices; -import org.robovm.apple.coregraphics.CGRect; import org.robovm.apple.systemconfiguration.SCNetworkReachability; import org.robovm.apple.systemconfiguration.SCNetworkReachabilityFlags; import org.robovm.apple.uikit.UIApplication; @@ -75,9 +74,17 @@ public class IOSPlatformSupport extends PlatformSupport { // this is inaccurate, as there's space left and right, but we don't care return new RectF(0, 0, Game.width, topInset / 1.2f); } else { - //we estimate dynamic island as being 130x390 px, 35px from top. + //we estimate dynamic island as being 390x120 px, 40px from top. // this is mostly accurate, slightly oversized - RectF cutout = new RectF( Game.width/2 - 195, 35, Game.width/2 + 195, 165); + RectF cutout = new RectF( Game.width/2 - 195, 40, Game.width/2 + 195, 160); + + //iPhone air specifically has its island a bit lower + // so we check for its machine string and also simulator with same width + String machineString = HWMachine.getMachineString(); + if (machineString.equals("iPhone18,4") + || (machineString.equals("arm64") && Game.width == 1260)){ + cutout.shift(0, 15); + } return cutout; } }