v1.4.2: Buff bar can now squish itself, max visible hero buffs up to 15

This commit is contained in:
Evan Debenham
2022-10-11 13:28:07 -04:00
parent 46525d4784
commit 5d0c1bf2e2
3 changed files with 34 additions and 0 deletions

View File

@@ -130,6 +130,12 @@ public class PointerArea extends Visual implements Signal.Listener<PointerEvent>
curEvent = null; curEvent = null;
} }
//moves this pointer area to the front of the pointer event order
public void givePointerPriority(){
PointerEvent.removePointerListener( this );
PointerEvent.addPointerListener( this );
}
@Override @Override
public void destroy() { public void destroy() {
PointerEvent.removePointerListener( this ); PointerEvent.removePointerListener( this );

View File

@@ -41,6 +41,7 @@ import com.watabou.noosa.tweeners.AlphaTweener;
import com.watabou.noosa.ui.Component; import com.watabou.noosa.ui.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
public class BuffIndicator extends Component { public class BuffIndicator extends Component {
@@ -200,6 +201,7 @@ public class BuffIndicator extends Component {
//layout //layout
int pos = 0; int pos = 0;
float lastIconLeft = 0;
for (BuffButton icon : buffButtons.values()){ for (BuffButton icon : buffButtons.values()){
icon.updateIcon(); icon.updateIcon();
//button areas are slightly oversized, especially on small buttons //button areas are slightly oversized, especially on small buttons
@@ -208,6 +210,28 @@ public class BuffIndicator extends Component {
pos++; pos++;
icon.visible = icon.left() <= right(); icon.visible = icon.left() <= right();
lastIconLeft = icon.left();
}
//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
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());
Collections.reverse(buttons);
for (BuffButton icon : buttons) {
icon.setPos(icon.left() - cumulativeAdjust, icon.top());
icon.visible = icon.left() <= right();
PixelScene.align(icon);
bringToFront(icon);
icon.givePointerPriority();
cumulativeAdjust -= leftAdjust;
}
} }
} }

View File

@@ -211,4 +211,8 @@ public class Button extends Component {
killTooltip(); killTooltip();
} }
public void givePointerPriority(){
hotArea.givePointerPriority();
}
} }