fix bubble notifications having a width of 0

This commit is contained in:
yugecin 2017-05-28 23:21:10 +02:00
parent 7d9ea309bf
commit 02632deff0
2 changed files with 4 additions and 9 deletions

View File

@ -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;

View File

@ -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;