add forgotten recalculations after changing resolution

This commit is contained in:
yugecin 2017-01-17 16:22:06 +01:00
parent 281d888905
commit 3d5dacf70f

View File

@ -103,6 +103,13 @@ public class BubbleNotificationState implements EventListener<BubbleNotification
return; return;
} }
finishAddAnimation(); finishAddAnimation();
int y = Notification.baseLine;
for (Notification bubble : bubbles) {
bubble.recalculateDimensions();
y -= bubble.height;
bubble.baseY = bubble.y = y;
y -= Notification.paddingY;
}
} }
private void finishAddAnimation() { private void finishAddAnimation() {
@ -159,14 +166,16 @@ public class BubbleNotificationState implements EventListener<BubbleNotification
private int y; private int y;
private int baseY; private int baseY;
private int height; private int height;
private List<String> lines;
private boolean isFading;
private final String message;
private List<String> lines;
private boolean isFading;
private int hoverTime; private int hoverTime;
private Notification(String message, Color borderColor) { private Notification(String message, Color borderColor) {
this.lines = Fonts.wrap(Fonts.SMALLBOLD, message, (int) (width * 0.96f), true); this.message = message;
this.height = (int) (Fonts.SMALLBOLD.getLineHeight() * (lines.size() + 0.5f)); recalculateDimensions();
this.targetBorderColor = borderColor; this.targetBorderColor = borderColor;
this.borderColor = new Color(borderColor); this.borderColor = new Color(borderColor);
this.textColor = new Color(Color.white); this.textColor = new Color(Color.white);
@ -175,6 +184,11 @@ public class BubbleNotificationState implements EventListener<BubbleNotification
this.baseY = this.y; this.baseY = this.y;
} }
private void recalculateDimensions() {
this.lines = Fonts.wrap(Fonts.SMALLBOLD, message, (int) (width * 0.96f), true);
this.height = (int) (Fonts.SMALLBOLD.getLineHeight() * (lines.size() + 0.5f));
}
private boolean render(Graphics g, int mouseX, int mouseY, int delta) { private boolean render(Graphics g, int mouseX, int mouseY, int delta) {
timeShown += delta; timeShown += delta;
processAnimations(isMouseHovered(mouseX, mouseY), delta); processAnimations(isMouseHovered(mouseX, mouseY), delta);