v3.2.4: adjusted how buff bar handles display cutouts
This commit is contained in:
@@ -368,26 +368,23 @@ public class GameScene extends PixelScene {
|
|||||||
|
|
||||||
int uiSize = SPDSettings.interfaceSize();
|
int uiSize = SPDSettings.interfaceSize();
|
||||||
|
|
||||||
//TODO make top bar transparent and add 1px of top status and menu bar to it?
|
//Some more medium sized display cutouts can obstruct the buff bar, so we limit the length
|
||||||
|
// of the 1st row in some cases
|
||||||
//most cutouts supported by the game are small
|
float buffBarTopRowMaxWidth = 50; //default max width
|
||||||
// but some are more 'medium' can can be supported with a little UI offsetting
|
|
||||||
float mediumCutoutOffset = 0;
|
|
||||||
if (largeInsetTop != insets.top){
|
if (largeInsetTop != insets.top){
|
||||||
//most notably iOS's Dynamic island, which must exist in this case
|
//most notably iOS's Dynamic island, which must exist in this case
|
||||||
if (DeviceCompat.isiOS()){
|
if (DeviceCompat.isiOS()){
|
||||||
//TODO we should handle this logic in platformSupport, not hardcode it here
|
//TODO bad to hardcode this atm, need to change this so platformsupport returns cutout dimensions
|
||||||
mediumCutoutOffset = 7;
|
buffBarTopRowMaxWidth = 15;
|
||||||
} else if (DeviceCompat.isAndroid()) {
|
} else if (DeviceCompat.isAndroid()) {
|
||||||
//some android hole punches can also be big too
|
//some android hole punches can also be big too
|
||||||
RectF cutout = Game.platform.getDisplayCutout().scale(1f / defaultZoom);
|
RectF cutout = Game.platform.getDisplayCutout().scale(1f / defaultZoom);
|
||||||
//if the cutout is positioned to obstruct the buff bar
|
//if the cutout is positioned to obstruct the buff bar
|
||||||
//TODO could buff bar just be squished in some cases here?
|
|
||||||
if (cutout.left < 80
|
if (cutout.left < 80
|
||||||
&& cutout.top < 10
|
&& cutout.top < 10
|
||||||
&& cutout.right > 32
|
&& cutout.right > 32
|
||||||
&& cutout.bottom > 11) {
|
&& cutout.bottom > 12) {
|
||||||
mediumCutoutOffset = (int) Math.floor(cutout.bottom - 11);
|
buffBarTopRowMaxWidth = cutout.left - 32; //subtract starting position
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -404,7 +401,7 @@ public class GameScene extends PixelScene {
|
|||||||
|
|
||||||
status = new StatusPane( SPDSettings.interfaceSize() > 0 );
|
status = new StatusPane( SPDSettings.interfaceSize() > 0 );
|
||||||
status.camera = uiCamera;
|
status.camera = uiCamera;
|
||||||
StatusPane.cutoutOffset = mediumCutoutOffset;
|
StatusPane.buffBarTopRowMaxWidth = buffBarTopRowMaxWidth;
|
||||||
status.setRect(insets.left, uiSize > 0 ? uiCamera.height-39-insets.bottom : screentop, uiCamera.width - insets.left - insets.right, 0 );
|
status.setRect(insets.left, uiSize > 0 ? uiCamera.height-39-insets.bottom : screentop, uiCamera.width - insets.left - insets.right, 0 );
|
||||||
add(status);
|
add(status);
|
||||||
|
|
||||||
|
|||||||
@@ -149,6 +149,8 @@ public class BuffIndicator extends Component {
|
|||||||
|
|
||||||
private boolean large = false;
|
private boolean large = false;
|
||||||
|
|
||||||
|
public float firstRowWidth = -1;
|
||||||
|
|
||||||
public BuffIndicator( Char ch, boolean large ) {
|
public BuffIndicator( Char ch, boolean large ) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@@ -226,31 +228,62 @@ 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 pos = 0;
|
int pos = 0;
|
||||||
float lastIconLeft = 0;
|
float lastIconLeft = 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
|
||||||
|
icon.visible = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
icon.visible = true;
|
||||||
|
|
||||||
|
icon.topOffset = (row > 0 && !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, size + 1, size + (large ? 0 : 5));
|
icon.setRect(x + pos * (size + 1), y + row*(size+1)-icon.topOffset, size + 1, size + (large ? 0 : 5));
|
||||||
PixelScene.align(icon);
|
PixelScene.align(icon);
|
||||||
pos++;
|
pos++;
|
||||||
|
|
||||||
icon.visible = icon.left() <= right();
|
|
||||||
lastIconLeft = icon.left();
|
lastIconLeft = icon.left();
|
||||||
|
|
||||||
|
if ((row+1)*(size+1) <= height
|
||||||
|
&& (pos * (size + 1) > width || (row == 0 && firstRowWidth != -1 && pos * (size + 1) > firstRowWidth))){
|
||||||
|
row++;
|
||||||
|
pos = 0;
|
||||||
|
}
|
||||||
|
total++;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = lastIconLeft - right();
|
||||||
if (excessWidth > 0) {
|
|
||||||
float leftAdjust = excessWidth/(buffButtons.size()-1);
|
|
||||||
//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);
|
|
||||||
|
|
||||||
ArrayList<BuffButton> buttons = new ArrayList<>(buffButtons.values());
|
if (excessWidth > 0) {
|
||||||
|
//if multiple rows, only compress last row
|
||||||
|
ArrayList<BuffButton> buttons = new ArrayList<>();
|
||||||
|
float lastRowY = y + row*(size+1);
|
||||||
|
int i = 1;
|
||||||
|
for (BuffButton button : buffButtons.values()){
|
||||||
|
if (i > 14){
|
||||||
|
button.visible = false;
|
||||||
|
buffsHidden = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (button.top()+button.topOffset == lastRowY){
|
||||||
|
buttons.add(button);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
float leftAdjust = excessWidth/(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());
|
||||||
@@ -277,6 +310,7 @@ public class BuffIndicator extends Component {
|
|||||||
private Buff buff;
|
private Buff buff;
|
||||||
|
|
||||||
private boolean large;
|
private boolean large;
|
||||||
|
private int topOffset = 0;
|
||||||
|
|
||||||
public Image grey; //only for small
|
public Image grey; //only for small
|
||||||
public BitmapText text; //only for large
|
public BitmapText text; //only for large
|
||||||
@@ -329,7 +363,7 @@ public class BuffIndicator extends Component {
|
|||||||
protected void layout() {
|
protected void layout() {
|
||||||
super.layout();
|
super.layout();
|
||||||
grey.x = icon.x = this.x + (large ? 0 : 1);
|
grey.x = icon.x = this.x + (large ? 0 : 1);
|
||||||
grey.y = icon.y = this.y + (large ? 0 : 2);
|
grey.y = icon.y = this.y + (large ? 0 : 2) + topOffset;
|
||||||
|
|
||||||
if (text.width > width()){
|
if (text.width > width()){
|
||||||
text.scale.set(PixelScene.align(0.5f));
|
text.scale.set(PixelScene.align(0.5f));
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ public class StatusPane extends Component {
|
|||||||
|
|
||||||
//lower the buff indicator to avoid larger cutouts (e.g. iPhone dynamic island)
|
//lower the buff indicator to avoid larger cutouts (e.g. iPhone dynamic island)
|
||||||
public static float cutoutOffset;
|
public static float cutoutOffset;
|
||||||
|
public static float buffBarTopRowMaxWidth = 50;
|
||||||
|
|
||||||
public StatusPane( boolean large ){
|
public StatusPane( boolean large ){
|
||||||
super();
|
super();
|
||||||
@@ -232,7 +233,8 @@ public class StatusPane extends Component {
|
|||||||
|
|
||||||
heroInfoOnBar.setRect(heroInfo.right(), y, 50, 9);
|
heroInfoOnBar.setRect(heroInfo.right(), y, 50, 9);
|
||||||
|
|
||||||
buffs.setRect( x + 31, y + 8 + cutoutOffset, 50, 8 );
|
buffs.firstRowWidth = buffBarTopRowMaxWidth;
|
||||||
|
buffs.setRect( x + 31, y + 8 + cutoutOffset, 50, 15 );
|
||||||
|
|
||||||
busy.x = x + 1;
|
busy.x = x + 1;
|
||||||
busy.y = y + 37;
|
busy.y = y + 37;
|
||||||
|
|||||||
Reference in New Issue
Block a user