From 02632deff0c71afd31a20220dcebd48d5a1c06dc Mon Sep 17 00:00:00 2001 From: yugecin Date: Sun, 28 May 2017 23:21:10 +0200 Subject: [PATCH] fix bubble notifications having a width of 0 --- src/itdelatrisu/opsu/states/MainMenu.java | 1 - .../core/state/specialstates/BubNotifState.java | 12 ++++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/itdelatrisu/opsu/states/MainMenu.java b/src/itdelatrisu/opsu/states/MainMenu.java index dbfe4a6a..c711e05b 100644 --- a/src/itdelatrisu/opsu/states/MainMenu.java +++ b/src/itdelatrisu/opsu/states/MainMenu.java @@ -513,7 +513,6 @@ public class MainMenu extends BaseOpsuState { @Override public boolean mousePressed(int button, int x, int y) { - //BubNotifListener.EVENT.make().onBubNotif("hi", Colors.BUB_ORANGE); // check mouse button if (button == Input.MOUSE_MIDDLE_BUTTON) return false; diff --git a/src/yugecin/opsudance/core/state/specialstates/BubNotifState.java b/src/yugecin/opsudance/core/state/specialstates/BubNotifState.java index f3dc82d6..34cefd0f 100644 --- a/src/yugecin/opsudance/core/state/specialstates/BubNotifState.java +++ b/src/yugecin/opsudance/core/state/specialstates/BubNotifState.java @@ -24,7 +24,6 @@ import org.newdawn.slick.Graphics; import org.newdawn.slick.MouseListener; import yugecin.opsudance.events.BubNotifListener; import yugecin.opsudance.events.ResolutionChangedListener; -import yugecin.opsudance.events.SkinChangedListener; import java.util.LinkedList; import java.util.List; @@ -32,7 +31,7 @@ import java.util.ListIterator; import static yugecin.opsudance.core.InstanceContainer.*; -public class BubNotifState implements MouseListener, BubNotifListener, ResolutionChangedListener, SkinChangedListener { +public class BubNotifState implements MouseListener, BubNotifListener, ResolutionChangedListener { public static final int IN_TIME = 633; public static final int DISPLAY_TIME = 7000 + IN_TIME; @@ -48,6 +47,7 @@ public class BubNotifState implements MouseListener, BubNotifListener, Resolutio this.bubbles = new LinkedList<>(); this.addAnimationTime = IN_TIME; BubNotifListener.EVENT.addListener(this); + ResolutionChangedListener.EVENT.addListener(this); } public void render(Graphics g) { @@ -73,7 +73,8 @@ public class BubNotifState implements MouseListener, BubNotifListener, Resolutio } private void calculatePositions() { - Notification.width = (int) (displayContainer.width * 0.1703125f); + // if width is 0, attempting to wrap it will result in infinite loop + Notification.width = Math.max(50, (int) (displayContainer.width * 0.1703125f)); Notification.baseLine = (int) (displayContainer.height * 0.9645f); Notification.paddingY = (int) (displayContainer.height * 0.0144f); Notification.finalX = displayContainer.width - Notification.width - (int) (displayContainer.width * 0.01); @@ -130,11 +131,6 @@ public class BubNotifState implements MouseListener, BubNotifListener, Resolutio calculatePositions(); } - @Override - public void onSkinChanged(String stringName) { - calculatePositions(); - } - @Override public boolean mouseWheelMoved(int delta) { return false;