Minor main menu changes.
- Changed the time format displayed on the main menu to match osu!. - If no beatmaps are loaded, redirect the user to the downloads menu instead of an empty song menu. Also, start showing bar notifications at time 1 instead of 0 so it can be called in enter() methods without visual delays. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
cb8c7c399c
commit
fc5f56f75a
|
@ -680,7 +680,7 @@ public class UI {
|
|||
* @param g the graphics context
|
||||
*/
|
||||
public static void drawBarNotification(Graphics g) {
|
||||
if (barNotifTimer == -1 || barNotifTimer >= BAR_NOTIFICATION_TIME)
|
||||
if (barNotifTimer <= 0 || barNotifTimer >= BAR_NOTIFICATION_TIME)
|
||||
return;
|
||||
|
||||
float alpha = 1f;
|
||||
|
|
|
@ -573,4 +573,18 @@ public class Utils {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a formatted time string for a given number of seconds.
|
||||
* @param seconds the number of seconds
|
||||
* @return the time as a readable string
|
||||
*/
|
||||
public static String getTimeString(int seconds) {
|
||||
if (seconds < 60)
|
||||
return (seconds == 1) ? "1 second" : String.format("%d seconds", seconds);
|
||||
else if (seconds < 3600)
|
||||
return String.format("%02d:%02d", seconds / 60, seconds % 60);
|
||||
else
|
||||
return String.format("%02d:%02d:%02d", seconds / 3600, (seconds / 60) % 60, seconds % 60);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,6 +146,9 @@ public class DownloadsMenu extends BasicGameState {
|
|||
/** Beatmap set ID of the current beatmap being previewed, or -1 if none. */
|
||||
private int previewID = -1;
|
||||
|
||||
/** The bar notification to send upon entering the state. */
|
||||
private String barNotificationOnLoad;
|
||||
|
||||
// game-related variables
|
||||
private GameContainer container;
|
||||
private StateBasedGame game;
|
||||
|
@ -739,6 +742,10 @@ public class DownloadsMenu extends BasicGameState {
|
|||
startDownloadIndex = 0;
|
||||
pageDir = Page.RESET;
|
||||
previewID = -1;
|
||||
if (barNotificationOnLoad != null) {
|
||||
UI.sendBarNotification(barNotificationOnLoad);
|
||||
barNotificationOnLoad = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -789,4 +796,10 @@ public class DownloadsMenu extends BasicGameState {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a bar notification upon entering the state.
|
||||
* @param s the notification string
|
||||
*/
|
||||
public void notifyOnLoad(String s) { barNotificationOnLoad = s; }
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ import java.io.IOException;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Stack;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.GameContainer;
|
||||
|
@ -281,13 +280,10 @@ public class MainMenu extends BasicGameState {
|
|||
g.drawString((MusicController.isPlaying()) ? "Now Playing:" : "Paused:", marginX, marginY + lineHeight);
|
||||
g.drawString(String.format("%s: %s", osu.getArtist(), osu.getTitle()), marginX + 25, marginY + (lineHeight * 2));
|
||||
}
|
||||
long time = System.currentTimeMillis() - osuStartTime;
|
||||
g.drawString(String.format("opsu! has been running for %d minutes, %d seconds.",
|
||||
TimeUnit.MILLISECONDS.toMinutes(time),
|
||||
TimeUnit.MILLISECONDS.toSeconds(time) -
|
||||
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(time))),
|
||||
g.drawString(String.format("opsu! has been running for %s.",
|
||||
Utils.getTimeString((int) (System.currentTimeMillis() - osuStartTime) / 1000)),
|
||||
marginX, height - marginY - (lineHeight * 2));
|
||||
g.drawString(String.format("The current time is %s.",
|
||||
g.drawString(String.format("It is currently %s.",
|
||||
new SimpleDateFormat("h:mm a").format(new Date())),
|
||||
marginX, height - marginY - lineHeight);
|
||||
|
||||
|
@ -505,7 +501,7 @@ public class MainMenu extends BasicGameState {
|
|||
else if (logoClicked) {
|
||||
if (logo.contains(x, y, 0.25f) || playButton.contains(x, y, 0.25f)) {
|
||||
SoundController.playSound(SoundEffect.MENUHIT);
|
||||
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||
enterSongMenu();
|
||||
} else if (exitButton.contains(x, y, 0.25f))
|
||||
container.exit();
|
||||
}
|
||||
|
@ -532,7 +528,7 @@ public class MainMenu extends BasicGameState {
|
|||
playButton.getImage().setAlpha(0f);
|
||||
exitButton.getImage().setAlpha(0f);
|
||||
} else
|
||||
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||
enterSongMenu();
|
||||
break;
|
||||
case Input.KEY_D:
|
||||
SoundController.playSound(SoundEffect.MENUHIT);
|
||||
|
@ -607,4 +603,16 @@ public class MainMenu extends BasicGameState {
|
|||
if (Options.isDynamicBackgroundEnabled() && !sameAudio && !MusicController.isThemePlaying())
|
||||
bgAlpha = 0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enters the song menu, or the downloads menu if no beatmaps are loaded.
|
||||
*/
|
||||
private void enterSongMenu() {
|
||||
int state = Opsu.STATE_SONGMENU;
|
||||
if (OsuGroupList.get().getMapSetCount() == 0) {
|
||||
((DownloadsMenu) game.getState(Opsu.STATE_DOWNLOADSMENU)).notifyOnLoad("Download some beatmaps to get started!");
|
||||
state = Opsu.STATE_DOWNLOADSMENU;
|
||||
}
|
||||
game.enterState(state, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user