remove old bar notification code

This commit is contained in:
yugecin 2017-01-21 15:49:54 +01:00
parent 7f1abb085f
commit 02ef422003

View File

@ -48,15 +48,6 @@ public class UI {
/** Volume display elapsed time. */ /** Volume display elapsed time. */
private static int volumeDisplay = -1; private static int volumeDisplay = -1;
/** The current bar notification string. */
private static String barNotif;
/** The current bar notification timer. */
private static int barNotifTimer = -1;
/** Duration, in milliseconds, to display bar notifications. */
private static final int BAR_NOTIFICATION_TIME = 1500;
/** The current tooltip. */ /** The current tooltip. */
private static String tooltip; private static String tooltip;
@ -97,7 +88,6 @@ public class UI {
*/ */
public static void update(int delta) { public static void update(int delta) {
updateVolumeDisplay(delta); updateVolumeDisplay(delta);
updateBarNotification(delta);
tooltipAlpha.update(-delta); tooltipAlpha.update(-delta);
} }
@ -106,7 +96,6 @@ public class UI {
* @param g the graphics context * @param g the graphics context
*/ */
public static void draw(Graphics g) { public static void draw(Graphics g) {
drawBarNotification(g);
drawVolume(g); drawVolume(g);
} }
@ -115,7 +104,6 @@ public class UI {
*/ */
public static void enter() { public static void enter() {
backButton.resetHover(); backButton.resetHover();
resetBarNotification();
resetTooltip(); resetTooltip();
} }
@ -361,62 +349,4 @@ public class UI {
tooltip = null; tooltip = null;
} }
/**
* Submits a bar notification for drawing.
* Must be called with {@link #drawBarNotification(Graphics)}.
* @param s the notification string
*/
public static void sendBarNotification(String s) {
if (s != null) {
barNotif = s;
barNotifTimer = 0;
}
}
/**
* Updates the bar notification by a delta interval.
* @param delta the delta interval since the last call
*/
private static void updateBarNotification(int delta) {
if (barNotifTimer > -1 && barNotifTimer < BAR_NOTIFICATION_TIME) {
barNotifTimer += delta;
if (barNotifTimer > BAR_NOTIFICATION_TIME)
barNotifTimer = BAR_NOTIFICATION_TIME;
}
}
/**
* Resets the bar notification.
*/
public static void resetBarNotification() {
barNotifTimer = -1;
barNotif = null;
}
/**
* Draws the notification sent from {@link #sendBarNotification(String)}.
* @param g the graphics context
*/
public static void drawBarNotification(Graphics g) {
if (barNotifTimer <= 0 || barNotifTimer >= BAR_NOTIFICATION_TIME)
return;
float alpha = 1f;
if (barNotifTimer >= BAR_NOTIFICATION_TIME * 0.9f)
alpha -= 1 - ((BAR_NOTIFICATION_TIME - barNotifTimer) / (BAR_NOTIFICATION_TIME * 0.1f));
int midX = displayContainer.width / 2, midY = displayContainer.height / 2;
float barHeight = Fonts.LARGE.getLineHeight() * (1f + 0.6f * Math.min(barNotifTimer * 15f / BAR_NOTIFICATION_TIME, 1f));
float oldAlphaB = Colors.BLACK_ALPHA.a, oldAlphaW = Colors.WHITE_ALPHA.a;
Colors.BLACK_ALPHA.a *= alpha;
Colors.WHITE_ALPHA.a = alpha;
g.setColor(Colors.BLACK_ALPHA);
g.fillRect(0, midY - barHeight / 2f, displayContainer.width, barHeight);
Fonts.LARGE.drawString(
midX - Fonts.LARGE.getWidth(barNotif) / 2f,
midY - Fonts.LARGE.getLineHeight() / 2.2f,
barNotif, Colors.WHITE_ALPHA);
Colors.BLACK_ALPHA.a = oldAlphaB;
Colors.WHITE_ALPHA.a = oldAlphaW;
}
} }