Small GUI tweaks.
- FPS display is now much more subtle. - A couple of main menu tweaks. Other changes: - Restore old alpha levels of Utils.COLOR_* constants when modifying them. - Utils.loadFont() can load any font effect, not just a ColorEffect. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
d92e67e5f1
commit
2f56bca9f7
|
@ -42,6 +42,7 @@ import org.newdawn.slick.Input;
|
|||
import org.newdawn.slick.SlickException;
|
||||
import org.newdawn.slick.UnicodeFont;
|
||||
import org.newdawn.slick.font.effects.ColorEffect;
|
||||
import org.newdawn.slick.font.effects.Effect;
|
||||
import org.newdawn.slick.imageout.ImageOut;
|
||||
import org.newdawn.slick.state.StateBasedGame;
|
||||
import org.newdawn.slick.util.Log;
|
||||
|
@ -496,11 +497,16 @@ public class Utils {
|
|||
if (!Options.isFPSCounterEnabled())
|
||||
return;
|
||||
|
||||
String fps = String.format("FPS: %d", container.getFPS());
|
||||
String fps = String.format("%dFPS", container.getFPS());
|
||||
FONT_BOLD.drawString(
|
||||
container.getWidth() * 0.997f - FONT_BOLD.getWidth(fps),
|
||||
container.getHeight() * 0.997f - FONT_BOLD.getHeight(fps),
|
||||
Integer.toString(container.getFPS()), Color.white
|
||||
);
|
||||
FONT_DEFAULT.drawString(
|
||||
container.getWidth() - 15 - FONT_DEFAULT.getWidth(fps),
|
||||
container.getHeight() - 15 - FONT_DEFAULT.getHeight(fps),
|
||||
fps, Color.white
|
||||
container.getWidth() * 0.997f - FONT_BOLD.getWidth("FPS"),
|
||||
container.getHeight() * 0.997f - FONT_BOLD.getHeight("FPS"),
|
||||
"FPS", Color.white
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -541,16 +547,16 @@ public class Utils {
|
|||
* Loads a Unicode font.
|
||||
* @param font the font to load
|
||||
* @param padding the top and bottom padding
|
||||
* @param colorEffect the ColorEffect
|
||||
* @param effect the font effect
|
||||
* @throws SlickException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void loadFont(UnicodeFont font, int padding,
|
||||
ColorEffect colorEffect) throws SlickException {
|
||||
Effect effect) throws SlickException {
|
||||
font.setPaddingTop(padding);
|
||||
font.setPaddingBottom(padding);
|
||||
font.addAsciiGlyphs();
|
||||
font.getEffects().add(colorEffect);
|
||||
font.getEffects().add(effect);
|
||||
font.loadGlyphs();
|
||||
}
|
||||
|
||||
|
|
|
@ -99,11 +99,12 @@ public class Circle implements HitObject {
|
|||
float approachScale = 1 + (timeDiff * 2f / game.getApproachTime());
|
||||
Utils.drawCentered(GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale), x, y, color);
|
||||
float alpha = (approachScale > 3.3f) ? 0f : 1f - (approachScale - 1f) / 2.7f;
|
||||
float oldAlpha = color.a;
|
||||
color.a = alpha;
|
||||
Utils.COLOR_WHITE_FADE.a = alpha;
|
||||
Utils.drawCentered(GameImage.HITCIRCLE_OVERLAY.getImage(), x, y, Utils.COLOR_WHITE_FADE);
|
||||
Utils.drawCentered(GameImage.HITCIRCLE.getImage(), x, y, color);
|
||||
color.a = 1f;
|
||||
color.a = oldAlpha;
|
||||
Utils.COLOR_WHITE_FADE.a = 1f;
|
||||
score.drawSymbolNumber(hitObject.getComboNumber(), x, y,
|
||||
GameImage.HITCIRCLE.getImage().getWidth() * 0.40f / score.getDefaultSymbolImage(0).getHeight());
|
||||
|
|
|
@ -344,6 +344,8 @@ public class Slider implements HitObject {
|
|||
|
||||
float approachScale = (timeDiff >= 0) ? 1 + (timeDiff * 2f / game.getApproachTime()) : 1f;
|
||||
float alpha = (approachScale > 3.3f) ? 0f : 1f - (approachScale - 1f) / 2.7f;
|
||||
float oldAlpha = color.a;
|
||||
float oldAlphaFade = Utils.COLOR_WHITE_FADE.a;
|
||||
color.a = alpha;
|
||||
Utils.COLOR_WHITE_FADE.a = alpha;
|
||||
|
||||
|
@ -376,8 +378,8 @@ public class Slider implements HitObject {
|
|||
score.drawSymbolNumber(hitObject.getComboNumber(), x, y,
|
||||
hitCircle.getWidth() * 0.40f / score.getDefaultSymbolImage(0).getHeight());
|
||||
|
||||
color.a = 1f;
|
||||
Utils.COLOR_WHITE_FADE.a = 1f;
|
||||
color.a = oldAlpha;
|
||||
Utils.COLOR_WHITE_FADE.a = oldAlphaFade;
|
||||
|
||||
// repeats
|
||||
if (hitObject.getRepeatCount() - 1 > currentRepeats) {
|
||||
|
|
|
@ -334,6 +334,7 @@ public class Game extends BasicGameState {
|
|||
GameImage.SCOREBAR_BG.getImage().getHeight(),
|
||||
GameImage.SCOREBAR_KI.getImage().getHeight()
|
||||
);
|
||||
float oldAlpha = Utils.COLOR_WHITE_FADE.a;
|
||||
if (timeDiff < -500)
|
||||
Utils.COLOR_WHITE_FADE.a = (1000 + timeDiff) / 500f;
|
||||
Utils.FONT_MEDIUM.drawString(
|
||||
|
@ -341,7 +342,7 @@ public class Game extends BasicGameState {
|
|||
String.format("%d retries and counting...", retries),
|
||||
Utils.COLOR_WHITE_FADE
|
||||
);
|
||||
Utils.COLOR_WHITE_FADE.a = 1f;
|
||||
Utils.COLOR_WHITE_FADE.a = oldAlpha;
|
||||
}
|
||||
|
||||
if (isLeadIn())
|
||||
|
|
|
@ -161,7 +161,7 @@ public class MainMenu extends BasicGameState {
|
|||
if (Desktop.isDesktopSupported()) { // only if a webpage can be opened
|
||||
Image repoImg = GameImage.REPOSITORY.getImage();
|
||||
repoButton = new MenuButton(repoImg,
|
||||
(width * 0.995f) - repoImg.getWidth(), (height * 0.995f) - repoImg.getHeight()
|
||||
(width * 0.997f) - repoImg.getWidth(), (height * 0.997f) - repoImg.getHeight()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -185,6 +185,13 @@ public class MainMenu extends BasicGameState {
|
|||
bg.draw();
|
||||
}
|
||||
|
||||
float oldAlpha = Utils.COLOR_BLACK_ALPHA.a;
|
||||
Utils.COLOR_BLACK_ALPHA.a = 0.2f;
|
||||
g.setColor(Utils.COLOR_BLACK_ALPHA);
|
||||
g.fillRect(0, 0, width, height / 9f);
|
||||
g.fillRect(0, height * 8 / 9f, width, height / 9f);
|
||||
Utils.COLOR_BLACK_ALPHA.a = oldAlpha;
|
||||
|
||||
// draw buttons
|
||||
if (logoTimer > 0) {
|
||||
playButton.draw();
|
||||
|
@ -211,28 +218,29 @@ public class MainMenu extends BasicGameState {
|
|||
repoButton.draw();
|
||||
|
||||
// draw text
|
||||
float marginX = width * 0.015f, marginY = height * 0.015f;
|
||||
g.setFont(Utils.FONT_MEDIUM);
|
||||
int lineHeight = Utils.FONT_MEDIUM.getLineHeight();
|
||||
int lineHeight = Utils.FONT_MEDIUM.getLineHeight() * 9 / 10;
|
||||
g.drawString(String.format("Loaded %d songs and %d beatmaps.",
|
||||
OsuGroupList.get().size(), OsuGroupList.get().getMapCount()), 25, 25);
|
||||
OsuGroupList.get().size(), OsuGroupList.get().getMapCount()), marginX, marginY);
|
||||
if (MusicController.isTrackLoading())
|
||||
g.drawString("Track loading...", 25, 25 + lineHeight);
|
||||
g.drawString("Track loading...", marginX, marginY + lineHeight);
|
||||
else if (MusicController.trackExists()) {
|
||||
g.drawString((MusicController.isPlaying()) ? "Now Playing:" : "Paused:", 25, 25 + lineHeight);
|
||||
g.drawString((MusicController.isPlaying()) ? "Now Playing:" : "Paused:", marginX, marginY + lineHeight);
|
||||
g.drawString(String.format("%s: %s",
|
||||
MusicController.getArtistName(),
|
||||
MusicController.getTrackName()),
|
||||
50, 25 + (lineHeight * 2));
|
||||
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))),
|
||||
25, height - 25 - (lineHeight * 2));
|
||||
marginX, height - marginY - (lineHeight * 2));
|
||||
g.drawString(String.format("The current time is %s.",
|
||||
new SimpleDateFormat("h:mm a").format(new Date())),
|
||||
25, height - 25 - lineHeight);
|
||||
marginX, height - marginY - lineHeight);
|
||||
|
||||
Utils.drawFPS();
|
||||
Utils.drawCursor();
|
||||
|
|
Loading…
Reference in New Issue
Block a user