Moved all Utils.FONT_* into new class opsu.ui.Fonts.*.
- Moved Utils.loadGlyphs() into this class, and rewrote it to take a single generic string (instead of beatmap title/artist strings, specifically). - Also moved font initialization into this class. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -29,6 +29,7 @@ import itdelatrisu.opsu.objects.curves.Curve;
|
|||||||
import itdelatrisu.opsu.replay.Replay;
|
import itdelatrisu.opsu.replay.Replay;
|
||||||
import itdelatrisu.opsu.replay.ReplayFrame;
|
import itdelatrisu.opsu.replay.ReplayFrame;
|
||||||
import itdelatrisu.opsu.ui.Colors;
|
import itdelatrisu.opsu.ui.Colors;
|
||||||
|
import itdelatrisu.opsu.ui.Fonts;
|
||||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -841,12 +842,12 @@ public class GameData {
|
|||||||
g.fillRect(0, 0, width, 100 * uiScale);
|
g.fillRect(0, 0, width, 100 * uiScale);
|
||||||
rankingTitle.draw((width * 0.97f) - rankingTitle.getWidth(), 0);
|
rankingTitle.draw((width * 0.97f) - rankingTitle.getWidth(), 0);
|
||||||
float marginX = width * 0.01f, marginY = height * 0.002f;
|
float marginX = width * 0.01f, marginY = height * 0.002f;
|
||||||
Utils.FONT_LARGE.drawString(marginX, marginY,
|
Fonts.LARGE.drawString(marginX, marginY,
|
||||||
String.format("%s - %s [%s]", beatmap.getArtist(), beatmap.getTitle(), beatmap.version), Color.white);
|
String.format("%s - %s [%s]", beatmap.getArtist(), beatmap.getTitle(), beatmap.version), Color.white);
|
||||||
Utils.FONT_MEDIUM.drawString(marginX, marginY + Utils.FONT_LARGE.getLineHeight() - 6,
|
Fonts.MEDIUM.drawString(marginX, marginY + Fonts.LARGE.getLineHeight() - 6,
|
||||||
String.format("Beatmap by %s", beatmap.creator), Color.white);
|
String.format("Beatmap by %s", beatmap.creator), Color.white);
|
||||||
String player = (scoreData.playerName == null) ? "" : String.format(" by %s", scoreData.playerName);
|
String player = (scoreData.playerName == null) ? "" : String.format(" by %s", scoreData.playerName);
|
||||||
Utils.FONT_MEDIUM.drawString(marginX, marginY + Utils.FONT_LARGE.getLineHeight() + Utils.FONT_MEDIUM.getLineHeight() - 10,
|
Fonts.MEDIUM.drawString(marginX, marginY + Fonts.LARGE.getLineHeight() + Fonts.MEDIUM.getLineHeight() - 10,
|
||||||
String.format("Played%s on %s.", player, scoreData.getTimeString()), Color.white);
|
String.format("Played%s on %s.", player, scoreData.getTimeString()), Color.white);
|
||||||
|
|
||||||
// mod icons
|
// mod icons
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
package itdelatrisu.opsu;
|
package itdelatrisu.opsu;
|
||||||
|
|
||||||
|
import itdelatrisu.opsu.ui.Fonts;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -251,14 +253,14 @@ public enum GameImage {
|
|||||||
MENU_MUSICNOTE ("music-note", "png", false, false) {
|
MENU_MUSICNOTE ("music-note", "png", false, false) {
|
||||||
@Override
|
@Override
|
||||||
protected Image process_sub(Image img, int w, int h) {
|
protected Image process_sub(Image img, int w, int h) {
|
||||||
int r = (int) ((Utils.FONT_LARGE.getLineHeight() + Utils.FONT_DEFAULT.getLineHeight() - 8) / getUIscale());
|
int r = (int) ((Fonts.LARGE.getLineHeight() + Fonts.DEFAULT.getLineHeight() - 8) / getUIscale());
|
||||||
return img.getScaledCopy(r, r);
|
return img.getScaledCopy(r, r);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
MENU_LOADER ("loader", "png", false, false) {
|
MENU_LOADER ("loader", "png", false, false) {
|
||||||
@Override
|
@Override
|
||||||
protected Image process_sub(Image img, int w, int h) {
|
protected Image process_sub(Image img, int w, int h) {
|
||||||
int r = (int) ((Utils.FONT_LARGE.getLineHeight() + Utils.FONT_DEFAULT.getLineHeight() - 8) / getUIscale());
|
int r = (int) ((Fonts.LARGE.getLineHeight() + Fonts.DEFAULT.getLineHeight() - 8) / getUIscale());
|
||||||
return img.getScaledCopy(r / 48f);
|
return img.getScaledCopy(r / 48f);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -312,7 +314,7 @@ public enum GameImage {
|
|||||||
DELETE ("delete", "png", false, false) {
|
DELETE ("delete", "png", false, false) {
|
||||||
@Override
|
@Override
|
||||||
protected Image process_sub(Image img, int w, int h) {
|
protected Image process_sub(Image img, int w, int h) {
|
||||||
int lineHeight = Utils.FONT_DEFAULT.getLineHeight();
|
int lineHeight = Fonts.DEFAULT.getLineHeight();
|
||||||
return img.getScaledCopy(lineHeight, lineHeight);
|
return img.getScaledCopy(lineHeight, lineHeight);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package itdelatrisu.opsu;
|
package itdelatrisu.opsu;
|
||||||
|
|
||||||
|
import itdelatrisu.opsu.ui.Fonts;
|
||||||
import itdelatrisu.opsu.ui.MenuButton;
|
import itdelatrisu.opsu.ui.MenuButton;
|
||||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||||
|
|
||||||
@@ -97,10 +98,10 @@ public enum GameMod {
|
|||||||
* @param height the container height
|
* @param height the container height
|
||||||
*/
|
*/
|
||||||
public void init(int width, int height) {
|
public void init(int width, int height) {
|
||||||
float multY = Utils.FONT_LARGE.getLineHeight() * 2 + height * 0.06f;
|
float multY = Fonts.LARGE.getLineHeight() * 2 + height * 0.06f;
|
||||||
float offsetY = GameImage.MOD_EASY.getImage().getHeight() * 1.5f;
|
float offsetY = GameImage.MOD_EASY.getImage().getHeight() * 1.5f;
|
||||||
this.x = width / 30f;
|
this.x = width / 30f;
|
||||||
this.y = multY + Utils.FONT_LARGE.getLineHeight() * 3f + offsetY * index;
|
this.y = multY + Fonts.LARGE.getLineHeight() * 3f + offsetY * index;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -193,7 +194,7 @@ public enum GameMod {
|
|||||||
c.init(width, height);
|
c.init(width, height);
|
||||||
|
|
||||||
// create buttons
|
// create buttons
|
||||||
float baseX = Category.EASY.getX() + Utils.FONT_LARGE.getWidth(Category.EASY.getName()) * 1.25f;
|
float baseX = Category.EASY.getX() + Fonts.LARGE.getWidth(Category.EASY.getName()) * 1.25f;
|
||||||
float offsetX = GameImage.MOD_EASY.getImage().getWidth() * 2.1f;
|
float offsetX = GameImage.MOD_EASY.getImage().getWidth() * 2.1f;
|
||||||
for (GameMod mod : GameMod.values()) {
|
for (GameMod mod : GameMod.values()) {
|
||||||
Image img = mod.image.getImage();
|
Image img = mod.image.getImage();
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import itdelatrisu.opsu.audio.MusicController;
|
|||||||
import itdelatrisu.opsu.beatmap.Beatmap;
|
import itdelatrisu.opsu.beatmap.Beatmap;
|
||||||
import itdelatrisu.opsu.skins.Skin;
|
import itdelatrisu.opsu.skins.Skin;
|
||||||
import itdelatrisu.opsu.skins.SkinLoader;
|
import itdelatrisu.opsu.skins.SkinLoader;
|
||||||
|
import itdelatrisu.opsu.ui.Fonts;
|
||||||
import itdelatrisu.opsu.ui.UI;
|
import itdelatrisu.opsu.ui.UI;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@@ -287,9 +288,9 @@ public class Options {
|
|||||||
super.click(container);
|
super.click(container);
|
||||||
if (bool) {
|
if (bool) {
|
||||||
try {
|
try {
|
||||||
Utils.FONT_LARGE.loadGlyphs();
|
Fonts.LARGE.loadGlyphs();
|
||||||
Utils.FONT_MEDIUM.loadGlyphs();
|
Fonts.MEDIUM.loadGlyphs();
|
||||||
Utils.FONT_DEFAULT.loadGlyphs();
|
Fonts.DEFAULT.loadGlyphs();
|
||||||
} catch (SlickException e) {
|
} catch (SlickException e) {
|
||||||
Log.warn("Failed to load glyphs.", e);
|
Log.warn("Failed to load glyphs.", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ package itdelatrisu.opsu;
|
|||||||
import itdelatrisu.opsu.GameData.Grade;
|
import itdelatrisu.opsu.GameData.Grade;
|
||||||
import itdelatrisu.opsu.states.SongMenu;
|
import itdelatrisu.opsu.states.SongMenu;
|
||||||
import itdelatrisu.opsu.ui.Colors;
|
import itdelatrisu.opsu.ui.Colors;
|
||||||
|
import itdelatrisu.opsu.ui.Fonts;
|
||||||
import itdelatrisu.opsu.ui.UI;
|
import itdelatrisu.opsu.ui.UI;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -95,7 +96,7 @@ public class ScoreData implements Comparable<ScoreData> {
|
|||||||
baseY = topY;
|
baseY = topY;
|
||||||
buttonWidth = containerWidth * 0.4f;
|
buttonWidth = containerWidth * 0.4f;
|
||||||
float gradeHeight = GameImage.MENU_BUTTON_BG.getImage().getHeight() * 0.45f;
|
float gradeHeight = GameImage.MENU_BUTTON_BG.getImage().getHeight() * 0.45f;
|
||||||
buttonHeight = Math.max(gradeHeight, Utils.FONT_DEFAULT.getLineHeight() * 3.03f);
|
buttonHeight = Math.max(gradeHeight, Fonts.DEFAULT.getLineHeight() * 3.03f);
|
||||||
buttonOffset = buttonHeight + gradeHeight / 10f;
|
buttonOffset = buttonHeight + gradeHeight / 10f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,7 +232,7 @@ public class ScoreData implements Comparable<ScoreData> {
|
|||||||
float edgeX = baseX + buttonWidth * 0.98f;
|
float edgeX = baseX + buttonWidth * 0.98f;
|
||||||
float y = baseY + index * (buttonOffset);
|
float y = baseY + index * (buttonOffset);
|
||||||
float midY = y + buttonHeight / 2f;
|
float midY = y + buttonHeight / 2f;
|
||||||
float marginY = Utils.FONT_DEFAULT.getLineHeight() * 0.01f;
|
float marginY = Fonts.DEFAULT.getLineHeight() * 0.01f;
|
||||||
|
|
||||||
// rectangle outline
|
// rectangle outline
|
||||||
g.setColor((focus) ? Colors.BLACK_BG_FOCUS : Colors.BLACK_BG_NORMAL);
|
g.setColor((focus) ? Colors.BLACK_BG_FOCUS : Colors.BLACK_BG_NORMAL);
|
||||||
@@ -239,9 +240,9 @@ public class ScoreData implements Comparable<ScoreData> {
|
|||||||
|
|
||||||
// rank
|
// rank
|
||||||
if (focus) {
|
if (focus) {
|
||||||
Utils.FONT_LARGE.drawString(
|
Fonts.LARGE.drawString(
|
||||||
baseX + buttonWidth * 0.04f,
|
baseX + buttonWidth * 0.04f,
|
||||||
y + (buttonHeight - Utils.FONT_LARGE.getLineHeight()) / 2f,
|
y + (buttonHeight - Fonts.LARGE.getLineHeight()) / 2f,
|
||||||
Integer.toString(rank + 1), Color.white
|
Integer.toString(rank + 1), Color.white
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -250,8 +251,8 @@ public class ScoreData implements Comparable<ScoreData> {
|
|||||||
img.drawCentered(baseX + buttonWidth * 0.15f, midY);
|
img.drawCentered(baseX + buttonWidth * 0.15f, midY);
|
||||||
|
|
||||||
// score
|
// score
|
||||||
float textOffset = (buttonHeight - Utils.FONT_MEDIUM.getLineHeight() - Utils.FONT_SMALL.getLineHeight()) / 2f;
|
float textOffset = (buttonHeight - Fonts.MEDIUM.getLineHeight() - Fonts.SMALL.getLineHeight()) / 2f;
|
||||||
Utils.FONT_MEDIUM.drawString(
|
Fonts.MEDIUM.drawString(
|
||||||
textX, y + textOffset,
|
textX, y + textOffset,
|
||||||
String.format("Score: %s (%dx)", NumberFormat.getNumberInstance().format(score), combo),
|
String.format("Score: %s (%dx)", NumberFormat.getNumberInstance().format(score), combo),
|
||||||
Color.white
|
Color.white
|
||||||
@@ -259,8 +260,8 @@ public class ScoreData implements Comparable<ScoreData> {
|
|||||||
|
|
||||||
// hit counts (custom: osu! shows user instead, above score)
|
// hit counts (custom: osu! shows user instead, above score)
|
||||||
String player = (playerName == null) ? "" : String.format(" (%s)", playerName);
|
String player = (playerName == null) ? "" : String.format(" (%s)", playerName);
|
||||||
Utils.FONT_SMALL.drawString(
|
Fonts.SMALL.drawString(
|
||||||
textX, y + textOffset + Utils.FONT_MEDIUM.getLineHeight(),
|
textX, y + textOffset + Fonts.MEDIUM.getLineHeight(),
|
||||||
String.format("300:%d 100:%d 50:%d Miss:%d%s", hit300, hit100, hit50, miss, player),
|
String.format("300:%d 100:%d 50:%d Miss:%d%s", hit300, hit100, hit50, miss, player),
|
||||||
Color.white
|
Color.white
|
||||||
);
|
);
|
||||||
@@ -276,26 +277,26 @@ public class ScoreData implements Comparable<ScoreData> {
|
|||||||
if (sb.length() > 0) {
|
if (sb.length() > 0) {
|
||||||
sb.setLength(sb.length() - 1);
|
sb.setLength(sb.length() - 1);
|
||||||
String modString = sb.toString();
|
String modString = sb.toString();
|
||||||
Utils.FONT_DEFAULT.drawString(
|
Fonts.DEFAULT.drawString(
|
||||||
edgeX - Utils.FONT_DEFAULT.getWidth(modString),
|
edgeX - Fonts.DEFAULT.getWidth(modString),
|
||||||
y + marginY, modString, Color.white
|
y + marginY, modString, Color.white
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// accuracy
|
// accuracy
|
||||||
String accuracy = String.format("%.2f%%", getScorePercent());
|
String accuracy = String.format("%.2f%%", getScorePercent());
|
||||||
Utils.FONT_DEFAULT.drawString(
|
Fonts.DEFAULT.drawString(
|
||||||
edgeX - Utils.FONT_DEFAULT.getWidth(accuracy),
|
edgeX - Fonts.DEFAULT.getWidth(accuracy),
|
||||||
y + marginY + Utils.FONT_DEFAULT.getLineHeight(),
|
y + marginY + Fonts.DEFAULT.getLineHeight(),
|
||||||
accuracy, Color.white
|
accuracy, Color.white
|
||||||
);
|
);
|
||||||
|
|
||||||
// score difference
|
// score difference
|
||||||
String diff = (prevScore < 0 || score < prevScore) ?
|
String diff = (prevScore < 0 || score < prevScore) ?
|
||||||
"-" : String.format("+%s", NumberFormat.getNumberInstance().format(score - prevScore));
|
"-" : String.format("+%s", NumberFormat.getNumberInstance().format(score - prevScore));
|
||||||
Utils.FONT_DEFAULT.drawString(
|
Fonts.DEFAULT.drawString(
|
||||||
edgeX - Utils.FONT_DEFAULT.getWidth(diff),
|
edgeX - Fonts.DEFAULT.getWidth(diff),
|
||||||
y + marginY + Utils.FONT_DEFAULT.getLineHeight() * 2,
|
y + marginY + Fonts.DEFAULT.getLineHeight() * 2,
|
||||||
diff, Color.white
|
diff, Color.white
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -303,9 +304,9 @@ public class ScoreData implements Comparable<ScoreData> {
|
|||||||
if (getTimeSince() != null) {
|
if (getTimeSince() != null) {
|
||||||
Image clock = GameImage.HISTORY.getImage();
|
Image clock = GameImage.HISTORY.getImage();
|
||||||
clock.drawCentered(baseX + buttonWidth * 1.02f + clock.getWidth() / 2f, midY);
|
clock.drawCentered(baseX + buttonWidth * 1.02f + clock.getWidth() / 2f, midY);
|
||||||
Utils.FONT_DEFAULT.drawString(
|
Fonts.DEFAULT.drawString(
|
||||||
baseX + buttonWidth * 1.03f + clock.getWidth(),
|
baseX + buttonWidth * 1.03f + clock.getWidth(),
|
||||||
midY - Utils.FONT_DEFAULT.getLineHeight() / 2f,
|
midY - Fonts.DEFAULT.getLineHeight() / 2f,
|
||||||
getTimeSince(), Color.white
|
getTimeSince(), Color.white
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ import itdelatrisu.opsu.beatmap.HitObject;
|
|||||||
import itdelatrisu.opsu.downloads.Download;
|
import itdelatrisu.opsu.downloads.Download;
|
||||||
import itdelatrisu.opsu.downloads.DownloadNode;
|
import itdelatrisu.opsu.downloads.DownloadNode;
|
||||||
import itdelatrisu.opsu.replay.PlaybackSpeed;
|
import itdelatrisu.opsu.replay.PlaybackSpeed;
|
||||||
|
import itdelatrisu.opsu.ui.Fonts;
|
||||||
import itdelatrisu.opsu.ui.UI;
|
import itdelatrisu.opsu.ui.UI;
|
||||||
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@@ -46,8 +46,6 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
@@ -63,12 +61,8 @@ import org.newdawn.slick.Animation;
|
|||||||
import org.newdawn.slick.GameContainer;
|
import org.newdawn.slick.GameContainer;
|
||||||
import org.newdawn.slick.Input;
|
import org.newdawn.slick.Input;
|
||||||
import org.newdawn.slick.SlickException;
|
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.state.StateBasedGame;
|
import org.newdawn.slick.state.StateBasedGame;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import org.newdawn.slick.util.ResourceLoader;
|
|
||||||
|
|
||||||
import com.sun.jna.platform.FileUtils;
|
import com.sun.jna.platform.FileUtils;
|
||||||
|
|
||||||
@@ -76,14 +70,6 @@ import com.sun.jna.platform.FileUtils;
|
|||||||
* Contains miscellaneous utilities.
|
* Contains miscellaneous utilities.
|
||||||
*/
|
*/
|
||||||
public class Utils {
|
public class Utils {
|
||||||
/** Game fonts. */
|
|
||||||
public static UnicodeFont
|
|
||||||
FONT_DEFAULT, FONT_BOLD,
|
|
||||||
FONT_XLARGE, FONT_LARGE, FONT_MEDIUM, FONT_SMALL;
|
|
||||||
|
|
||||||
/** Set of all Unicode strings already loaded per font. */
|
|
||||||
private static HashMap<UnicodeFont, HashSet<String>> loadedGlyphs = new HashMap<UnicodeFont, HashSet<String>>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of illegal filename characters.
|
* List of illegal filename characters.
|
||||||
* @see #cleanFileName(String, char)
|
* @see #cleanFileName(String, char)
|
||||||
@@ -128,23 +114,8 @@ public class Utils {
|
|||||||
GameImage.init(width, height);
|
GameImage.init(width, height);
|
||||||
|
|
||||||
// create fonts
|
// create fonts
|
||||||
float fontBase = 12f * GameImage.getUIscale();
|
|
||||||
try {
|
try {
|
||||||
Font javaFont = Font.createFont(Font.TRUETYPE_FONT, ResourceLoader.getResourceAsStream(Options.FONT_NAME));
|
Fonts.init();
|
||||||
Font font = javaFont.deriveFont(Font.PLAIN, (int) (fontBase * 4 / 3));
|
|
||||||
FONT_DEFAULT = new UnicodeFont(font);
|
|
||||||
FONT_BOLD = new UnicodeFont(font.deriveFont(Font.BOLD));
|
|
||||||
FONT_XLARGE = new UnicodeFont(font.deriveFont(fontBase * 3));
|
|
||||||
FONT_LARGE = new UnicodeFont(font.deriveFont(fontBase * 2));
|
|
||||||
FONT_MEDIUM = new UnicodeFont(font.deriveFont(fontBase * 3 / 2));
|
|
||||||
FONT_SMALL = new UnicodeFont(font.deriveFont(fontBase));
|
|
||||||
ColorEffect colorEffect = new ColorEffect();
|
|
||||||
loadFont(FONT_DEFAULT, colorEffect);
|
|
||||||
loadFont(FONT_BOLD, colorEffect);
|
|
||||||
loadFont(FONT_XLARGE, colorEffect);
|
|
||||||
loadFont(FONT_LARGE, colorEffect);
|
|
||||||
loadFont(FONT_MEDIUM, colorEffect);
|
|
||||||
loadFont(FONT_SMALL, colorEffect);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ErrorHandler.error("Failed to load fonts.", e, true);
|
ErrorHandler.error("Failed to load fonts.", e, true);
|
||||||
}
|
}
|
||||||
@@ -326,54 +297,6 @@ public class Utils {
|
|||||||
}.start();
|
}.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads a Unicode font.
|
|
||||||
* @param font the font to load
|
|
||||||
* @param effect the font effect
|
|
||||||
* @throws SlickException
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private static void loadFont(UnicodeFont font, Effect effect) throws SlickException {
|
|
||||||
font.addAsciiGlyphs();
|
|
||||||
font.getEffects().add(effect);
|
|
||||||
font.loadGlyphs();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds and loads glyphs for a beatmap's Unicode title and artist strings.
|
|
||||||
* @param font the font to add the glyphs to
|
|
||||||
* @param title the title string
|
|
||||||
* @param artist the artist string
|
|
||||||
*/
|
|
||||||
public static void loadGlyphs(UnicodeFont font, String title, String artist) {
|
|
||||||
// get set of added strings
|
|
||||||
HashSet<String> set = loadedGlyphs.get(font);
|
|
||||||
if (set == null) {
|
|
||||||
set = new HashSet<String>();
|
|
||||||
loadedGlyphs.put(font, set);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add glyphs if not in set
|
|
||||||
boolean glyphsAdded = false;
|
|
||||||
if (title != null && !title.isEmpty() && !set.contains(title)) {
|
|
||||||
font.addGlyphs(title);
|
|
||||||
set.add(title);
|
|
||||||
glyphsAdded = true;
|
|
||||||
}
|
|
||||||
if (artist != null && !artist.isEmpty() && !set.contains(artist)) {
|
|
||||||
font.addGlyphs(artist);
|
|
||||||
set.add(artist);
|
|
||||||
glyphsAdded = true;
|
|
||||||
}
|
|
||||||
if (glyphsAdded) {
|
|
||||||
try {
|
|
||||||
font.loadGlyphs();
|
|
||||||
} catch (SlickException e) {
|
|
||||||
Log.warn("Failed to load glyphs.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a human-readable representation of a given number of bytes.
|
* Returns a human-readable representation of a given number of bytes.
|
||||||
* @param bytes the number of bytes
|
* @param bytes the number of bytes
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ package itdelatrisu.opsu.beatmap;
|
|||||||
import itdelatrisu.opsu.GameData.Grade;
|
import itdelatrisu.opsu.GameData.Grade;
|
||||||
import itdelatrisu.opsu.GameImage;
|
import itdelatrisu.opsu.GameImage;
|
||||||
import itdelatrisu.opsu.Options;
|
import itdelatrisu.opsu.Options;
|
||||||
import itdelatrisu.opsu.Utils;
|
|
||||||
import itdelatrisu.opsu.ui.Colors;
|
import itdelatrisu.opsu.ui.Colors;
|
||||||
|
import itdelatrisu.opsu.ui.Fonts;
|
||||||
|
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.Image;
|
import org.newdawn.slick.Image;
|
||||||
@@ -99,14 +99,14 @@ public class BeatmapSetNode {
|
|||||||
|
|
||||||
// draw text
|
// draw text
|
||||||
if (Options.useUnicodeMetadata()) { // load glyphs
|
if (Options.useUnicodeMetadata()) { // load glyphs
|
||||||
Utils.loadGlyphs(Utils.FONT_MEDIUM, beatmap.titleUnicode, null);
|
Fonts.loadGlyphs(Fonts.MEDIUM, beatmap.titleUnicode);
|
||||||
Utils.loadGlyphs(Utils.FONT_DEFAULT, null, beatmap.artistUnicode);
|
Fonts.loadGlyphs(Fonts.DEFAULT, beatmap.artistUnicode);
|
||||||
}
|
}
|
||||||
Utils.FONT_MEDIUM.drawString(cx, cy, beatmap.getTitle(), textColor);
|
Fonts.MEDIUM.drawString(cx, cy, beatmap.getTitle(), textColor);
|
||||||
Utils.FONT_DEFAULT.drawString(cx, cy + Utils.FONT_MEDIUM.getLineHeight() - 2,
|
Fonts.DEFAULT.drawString(cx, cy + Fonts.MEDIUM.getLineHeight() - 2,
|
||||||
String.format("%s // %s", beatmap.getArtist(), beatmap.creator), textColor);
|
String.format("%s // %s", beatmap.getArtist(), beatmap.creator), textColor);
|
||||||
if (expanded || beatmapSet.size() == 1)
|
if (expanded || beatmapSet.size() == 1)
|
||||||
Utils.FONT_BOLD.drawString(cx, cy + Utils.FONT_MEDIUM.getLineHeight() + Utils.FONT_DEFAULT.getLineHeight() - 4,
|
Fonts.BOLD.drawString(cx, cy + Fonts.MEDIUM.getLineHeight() + Fonts.DEFAULT.getLineHeight() - 4,
|
||||||
beatmap.version, textColor);
|
beatmap.version, textColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import itdelatrisu.opsu.downloads.Download.DownloadListener;
|
|||||||
import itdelatrisu.opsu.downloads.Download.Status;
|
import itdelatrisu.opsu.downloads.Download.Status;
|
||||||
import itdelatrisu.opsu.downloads.servers.DownloadServer;
|
import itdelatrisu.opsu.downloads.servers.DownloadServer;
|
||||||
import itdelatrisu.opsu.ui.Colors;
|
import itdelatrisu.opsu.ui.Colors;
|
||||||
|
import itdelatrisu.opsu.ui.Fonts;
|
||||||
import itdelatrisu.opsu.ui.UI;
|
import itdelatrisu.opsu.ui.UI;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -81,16 +82,16 @@ public class DownloadNode {
|
|||||||
buttonBaseX = width * 0.024f;
|
buttonBaseX = width * 0.024f;
|
||||||
buttonBaseY = height * 0.2f;
|
buttonBaseY = height * 0.2f;
|
||||||
buttonWidth = width * 0.7f;
|
buttonWidth = width * 0.7f;
|
||||||
buttonHeight = Utils.FONT_MEDIUM.getLineHeight() * 2.1f;
|
buttonHeight = Fonts.MEDIUM.getLineHeight() * 2.1f;
|
||||||
buttonOffset = buttonHeight * 1.1f;
|
buttonOffset = buttonHeight * 1.1f;
|
||||||
|
|
||||||
// download info
|
// download info
|
||||||
infoBaseX = width * 0.75f;
|
infoBaseX = width * 0.75f;
|
||||||
infoBaseY = height * 0.07f + Utils.FONT_LARGE.getLineHeight() * 2f;
|
infoBaseY = height * 0.07f + Fonts.LARGE.getLineHeight() * 2f;
|
||||||
infoWidth = width * 0.25f;
|
infoWidth = width * 0.25f;
|
||||||
infoHeight = Utils.FONT_DEFAULT.getLineHeight() * 2.4f;
|
infoHeight = Fonts.DEFAULT.getLineHeight() * 2.4f;
|
||||||
|
|
||||||
float searchY = (height * 0.05f) + Utils.FONT_LARGE.getLineHeight();
|
float searchY = (height * 0.05f) + Fonts.LARGE.getLineHeight();
|
||||||
float buttonHeight = height * 0.038f;
|
float buttonHeight = height * 0.038f;
|
||||||
maxResultsShown = (int) ((height - buttonBaseY - searchY) / buttonOffset);
|
maxResultsShown = (int) ((height - buttonBaseY - searchY) / buttonOffset);
|
||||||
maxDownloadsShown = (int) ((height - infoBaseY - searchY - buttonHeight) / infoHeight);
|
maxDownloadsShown = (int) ((height - infoBaseY - searchY - buttonHeight) / infoHeight);
|
||||||
@@ -257,7 +258,7 @@ public class DownloadNode {
|
|||||||
});
|
});
|
||||||
this.download = download;
|
this.download = download;
|
||||||
if (Options.useUnicodeMetadata()) // load glyphs
|
if (Options.useUnicodeMetadata()) // load glyphs
|
||||||
Utils.loadGlyphs(Utils.FONT_LARGE, getTitle(), null);
|
Fonts.loadGlyphs(Fonts.LARGE, getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -344,19 +345,21 @@ public class DownloadNode {
|
|||||||
|
|
||||||
// text
|
// text
|
||||||
// TODO: if the title/artist line is too long, shorten it (e.g. add "...") instead of just clipping
|
// TODO: if the title/artist line is too long, shorten it (e.g. add "...") instead of just clipping
|
||||||
if (Options.useUnicodeMetadata()) // load glyphs
|
if (Options.useUnicodeMetadata()) { // load glyphs
|
||||||
Utils.loadGlyphs(Utils.FONT_BOLD, getTitle(), getArtist());
|
Fonts.loadGlyphs(Fonts.BOLD, getTitle());
|
||||||
g.setClip((int) textX, (int) (y + marginY), (int) (edgeX - textX - Utils.FONT_DEFAULT.getWidth(creator)), Utils.FONT_BOLD.getLineHeight());
|
Fonts.loadGlyphs(Fonts.BOLD, getArtist());
|
||||||
Utils.FONT_BOLD.drawString(
|
}
|
||||||
|
g.setClip((int) textX, (int) (y + marginY), (int) (edgeX - textX - Fonts.DEFAULT.getWidth(creator)), Fonts.BOLD.getLineHeight());
|
||||||
|
Fonts.BOLD.drawString(
|
||||||
textX, y + marginY,
|
textX, y + marginY,
|
||||||
String.format("%s - %s%s", getArtist(), getTitle(),
|
String.format("%s - %s%s", getArtist(), getTitle(),
|
||||||
(dl != null) ? String.format(" [%s]", dl.getStatus().getName()) : ""), Color.white);
|
(dl != null) ? String.format(" [%s]", dl.getStatus().getName()) : ""), Color.white);
|
||||||
g.clearClip();
|
g.clearClip();
|
||||||
Utils.FONT_DEFAULT.drawString(
|
Fonts.DEFAULT.drawString(
|
||||||
textX, y + marginY + Utils.FONT_BOLD.getLineHeight(),
|
textX, y + marginY + Fonts.BOLD.getLineHeight(),
|
||||||
String.format("Last updated: %s", date), Color.white);
|
String.format("Last updated: %s", date), Color.white);
|
||||||
Utils.FONT_DEFAULT.drawString(
|
Fonts.DEFAULT.drawString(
|
||||||
edgeX - Utils.FONT_DEFAULT.getWidth(creator), y + marginY,
|
edgeX - Fonts.DEFAULT.getWidth(creator), y + marginY,
|
||||||
creator, Color.white);
|
creator, Color.white);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,8 +401,8 @@ public class DownloadNode {
|
|||||||
info = String.format("%s: %.1f%% (%s/%s)", status.getName(), progress,
|
info = String.format("%s: %.1f%% (%s/%s)", status.getName(), progress,
|
||||||
Utils.bytesToString(download.readSoFar()), Utils.bytesToString(download.contentLength()));
|
Utils.bytesToString(download.readSoFar()), Utils.bytesToString(download.contentLength()));
|
||||||
}
|
}
|
||||||
Utils.FONT_BOLD.drawString(textX, y + marginY, getTitle(), Color.white);
|
Fonts.BOLD.drawString(textX, y + marginY, getTitle(), Color.white);
|
||||||
Utils.FONT_DEFAULT.drawString(textX, y + marginY + Utils.FONT_BOLD.getLineHeight(), info, Color.white);
|
Fonts.DEFAULT.drawString(textX, y + marginY + Fonts.BOLD.getLineHeight(), info, Color.white);
|
||||||
|
|
||||||
// 'x' button
|
// 'x' button
|
||||||
if (hover) {
|
if (hover) {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import itdelatrisu.opsu.audio.SoundController;
|
|||||||
import itdelatrisu.opsu.audio.SoundEffect;
|
import itdelatrisu.opsu.audio.SoundEffect;
|
||||||
import itdelatrisu.opsu.beatmap.BeatmapSetList;
|
import itdelatrisu.opsu.beatmap.BeatmapSetList;
|
||||||
import itdelatrisu.opsu.beatmap.BeatmapSetNode;
|
import itdelatrisu.opsu.beatmap.BeatmapSetNode;
|
||||||
|
import itdelatrisu.opsu.ui.Fonts;
|
||||||
import itdelatrisu.opsu.ui.MenuButton;
|
import itdelatrisu.opsu.ui.MenuButton;
|
||||||
import itdelatrisu.opsu.ui.UI;
|
import itdelatrisu.opsu.ui.UI;
|
||||||
import itdelatrisu.opsu.ui.animations.AnimatedValue;
|
import itdelatrisu.opsu.ui.animations.AnimatedValue;
|
||||||
@@ -189,15 +190,15 @@ public class ButtonMenu extends BasicGameState {
|
|||||||
float mult = GameMod.getScoreMultiplier();
|
float mult = GameMod.getScoreMultiplier();
|
||||||
String multString = String.format("Score Multiplier: %.2fx", mult);
|
String multString = String.format("Score Multiplier: %.2fx", mult);
|
||||||
Color multColor = (mult == 1f) ? Color.white : (mult > 1f) ? Color.green : Color.red;
|
Color multColor = (mult == 1f) ? Color.white : (mult > 1f) ? Color.green : Color.red;
|
||||||
float multY = Utils.FONT_LARGE.getLineHeight() * 2 + height * 0.06f;
|
float multY = Fonts.LARGE.getLineHeight() * 2 + height * 0.06f;
|
||||||
Utils.FONT_LARGE.drawString(
|
Fonts.LARGE.drawString(
|
||||||
(width - Utils.FONT_LARGE.getWidth(multString)) / 2f,
|
(width - Fonts.LARGE.getWidth(multString)) / 2f,
|
||||||
multY, multString, multColor);
|
multY, multString, multColor);
|
||||||
|
|
||||||
// category text
|
// category text
|
||||||
for (GameMod.Category category : GameMod.Category.values()) {
|
for (GameMod.Category category : GameMod.Category.values()) {
|
||||||
Utils.FONT_LARGE.drawString(category.getX(),
|
Fonts.LARGE.drawString(category.getX(),
|
||||||
category.getY() - Utils.FONT_LARGE.getLineHeight() / 2f,
|
category.getY() - Fonts.LARGE.getLineHeight() / 2f,
|
||||||
category.getName(), category.getColor());
|
category.getName(), category.getColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,7 +294,7 @@ public class ButtonMenu extends BasicGameState {
|
|||||||
menuButtons = new MenuButton[buttons.length];
|
menuButtons = new MenuButton[buttons.length];
|
||||||
for (int i = 0; i < buttons.length; i++) {
|
for (int i = 0; i < buttons.length; i++) {
|
||||||
MenuButton b = new MenuButton(button, buttonL, buttonR, center, baseY + (i * offsetY));
|
MenuButton b = new MenuButton(button, buttonL, buttonR, center, baseY + (i * offsetY));
|
||||||
b.setText(String.format("%d. %s", i + 1, buttons[i].getText()), Utils.FONT_XLARGE, Color.white);
|
b.setText(String.format("%d. %s", i + 1, buttons[i].getText()), Fonts.XLARGE, Color.white);
|
||||||
b.setHoverFade();
|
b.setHoverFade();
|
||||||
menuButtons[i] = b;
|
menuButtons[i] = b;
|
||||||
}
|
}
|
||||||
@@ -306,7 +307,7 @@ public class ButtonMenu extends BasicGameState {
|
|||||||
*/
|
*/
|
||||||
protected float getBaseY(GameContainer container, StateBasedGame game) {
|
protected float getBaseY(GameContainer container, StateBasedGame game) {
|
||||||
float baseY = container.getHeight() * 0.2f;
|
float baseY = container.getHeight() * 0.2f;
|
||||||
baseY += ((getTitle(container, game).length - 1) * Utils.FONT_LARGE.getLineHeight());
|
baseY += ((getTitle(container, game).length - 1) * Fonts.LARGE.getLineHeight());
|
||||||
return baseY;
|
return baseY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,9 +321,9 @@ public class ButtonMenu extends BasicGameState {
|
|||||||
// draw title
|
// draw title
|
||||||
if (actualTitle != null) {
|
if (actualTitle != null) {
|
||||||
float marginX = container.getWidth() * 0.015f, marginY = container.getHeight() * 0.01f;
|
float marginX = container.getWidth() * 0.015f, marginY = container.getHeight() * 0.01f;
|
||||||
int lineHeight = Utils.FONT_LARGE.getLineHeight();
|
int lineHeight = Fonts.LARGE.getLineHeight();
|
||||||
for (int i = 0, size = actualTitle.size(); i < size; i++)
|
for (int i = 0, size = actualTitle.size(); i < size; i++)
|
||||||
Utils.FONT_LARGE.drawString(marginX, marginY + (i * lineHeight), actualTitle.get(i), Color.white);
|
Fonts.LARGE.drawString(marginX, marginY + (i * lineHeight), actualTitle.get(i), Color.white);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw buttons
|
// draw buttons
|
||||||
@@ -418,8 +419,8 @@ public class ButtonMenu extends BasicGameState {
|
|||||||
int maxLineWidth = (int) (container.getWidth() * 0.96f);
|
int maxLineWidth = (int) (container.getWidth() * 0.96f);
|
||||||
for (int i = 0; i < title.length; i++) {
|
for (int i = 0; i < title.length; i++) {
|
||||||
// wrap text if too long
|
// wrap text if too long
|
||||||
if (Utils.FONT_LARGE.getWidth(title[i]) > maxLineWidth) {
|
if (Fonts.LARGE.getWidth(title[i]) > maxLineWidth) {
|
||||||
List<String> list = Utils.wrap(title[i], Utils.FONT_LARGE, maxLineWidth);
|
List<String> list = Utils.wrap(title[i], Fonts.LARGE, maxLineWidth);
|
||||||
actualTitle.addAll(list);
|
actualTitle.addAll(list);
|
||||||
} else
|
} else
|
||||||
actualTitle.add(title[i]);
|
actualTitle.add(title[i]);
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import itdelatrisu.opsu.downloads.servers.HexideServer;
|
|||||||
import itdelatrisu.opsu.downloads.servers.MnetworkServer;
|
import itdelatrisu.opsu.downloads.servers.MnetworkServer;
|
||||||
import itdelatrisu.opsu.downloads.servers.YaSOnlineServer;
|
import itdelatrisu.opsu.downloads.servers.YaSOnlineServer;
|
||||||
import itdelatrisu.opsu.ui.Colors;
|
import itdelatrisu.opsu.ui.Colors;
|
||||||
|
import itdelatrisu.opsu.ui.Fonts;
|
||||||
import itdelatrisu.opsu.ui.MenuButton;
|
import itdelatrisu.opsu.ui.MenuButton;
|
||||||
import itdelatrisu.opsu.ui.UI;
|
import itdelatrisu.opsu.ui.UI;
|
||||||
|
|
||||||
@@ -261,17 +262,17 @@ public class DownloadsMenu extends BasicGameState {
|
|||||||
int width = container.getWidth();
|
int width = container.getWidth();
|
||||||
int height = container.getHeight();
|
int height = container.getHeight();
|
||||||
float baseX = width * 0.024f;
|
float baseX = width * 0.024f;
|
||||||
float searchY = (height * 0.04f) + Utils.FONT_LARGE.getLineHeight();
|
float searchY = (height * 0.04f) + Fonts.LARGE.getLineHeight();
|
||||||
float searchWidth = width * 0.3f;
|
float searchWidth = width * 0.3f;
|
||||||
|
|
||||||
// search
|
// search
|
||||||
searchTimer = SEARCH_DELAY;
|
searchTimer = SEARCH_DELAY;
|
||||||
searchResultString = "Loading data from server...";
|
searchResultString = "Loading data from server...";
|
||||||
search = new TextField(
|
search = new TextField(
|
||||||
container, Utils.FONT_DEFAULT, (int) baseX, (int) searchY,
|
container, Fonts.DEFAULT, (int) baseX, (int) searchY,
|
||||||
(int) searchWidth, Utils.FONT_MEDIUM.getLineHeight()
|
(int) searchWidth, Fonts.MEDIUM.getLineHeight()
|
||||||
);
|
);
|
||||||
search.setBackgroundColor(DownloadNode.BG_NORMAL);
|
search.setBackgroundColor(Colors.BLACK_BG_NORMAL);
|
||||||
search.setBorderColor(Color.white);
|
search.setBorderColor(Color.white);
|
||||||
search.setTextColor(Color.white);
|
search.setTextColor(Color.white);
|
||||||
search.setConsumeEvents(false);
|
search.setConsumeEvents(false);
|
||||||
@@ -296,7 +297,7 @@ public class DownloadsMenu extends BasicGameState {
|
|||||||
float rankedWidth = width * 0.15f;
|
float rankedWidth = width * 0.15f;
|
||||||
float serverWidth = width * 0.12f;
|
float serverWidth = width * 0.12f;
|
||||||
float lowerWidth = width * 0.12f;
|
float lowerWidth = width * 0.12f;
|
||||||
float topButtonY = searchY + Utils.FONT_MEDIUM.getLineHeight() / 2f;
|
float topButtonY = searchY + Fonts.MEDIUM.getLineHeight() / 2f;
|
||||||
float lowerButtonY = height * 0.995f - searchY - buttonHeight / 2f;
|
float lowerButtonY = height * 0.995f - searchY - buttonHeight / 2f;
|
||||||
Image button = GameImage.MENU_BUTTON_MID.getImage();
|
Image button = GameImage.MENU_BUTTON_MID.getImage();
|
||||||
Image buttonL = GameImage.MENU_BUTTON_LEFT.getImage();
|
Image buttonL = GameImage.MENU_BUTTON_LEFT.getImage();
|
||||||
@@ -322,9 +323,9 @@ public class DownloadsMenu extends BasicGameState {
|
|||||||
baseX + searchWidth + buttonMarginX * 2f + resetButtonWidth + rankedButtonWidth / 2f, topButtonY);
|
baseX + searchWidth + buttonMarginX * 2f + resetButtonWidth + rankedButtonWidth / 2f, topButtonY);
|
||||||
serverButton = new MenuButton(serverButtonImage, buttonL, buttonR,
|
serverButton = new MenuButton(serverButtonImage, buttonL, buttonR,
|
||||||
baseX + searchWidth + buttonMarginX * 3f + resetButtonWidth + rankedButtonWidth + serverButtonWidth / 2f, topButtonY);
|
baseX + searchWidth + buttonMarginX * 3f + resetButtonWidth + rankedButtonWidth + serverButtonWidth / 2f, topButtonY);
|
||||||
clearButton.setText("Clear", Utils.FONT_MEDIUM, Color.white);
|
clearButton.setText("Clear", Fonts.MEDIUM, Color.white);
|
||||||
importButton.setText("Import All", Utils.FONT_MEDIUM, Color.white);
|
importButton.setText("Import All", Fonts.MEDIUM, Color.white);
|
||||||
resetButton.setText("Reset", Utils.FONT_MEDIUM, Color.white);
|
resetButton.setText("Reset", Fonts.MEDIUM, Color.white);
|
||||||
clearButton.setHoverFade();
|
clearButton.setHoverFade();
|
||||||
importButton.setHoverFade();
|
importButton.setHoverFade();
|
||||||
resetButton.setHoverFade();
|
resetButton.setHoverFade();
|
||||||
@@ -343,13 +344,13 @@ public class DownloadsMenu extends BasicGameState {
|
|||||||
GameImage.SEARCH_BG.getImage().draw();
|
GameImage.SEARCH_BG.getImage().draw();
|
||||||
|
|
||||||
// title
|
// title
|
||||||
Utils.FONT_LARGE.drawString(width * 0.024f, height * 0.03f, "Download Beatmaps!", Color.white);
|
Fonts.LARGE.drawString(width * 0.024f, height * 0.03f, "Download Beatmaps!", Color.white);
|
||||||
|
|
||||||
// search
|
// search
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
g.setLineWidth(2f);
|
g.setLineWidth(2f);
|
||||||
search.render(container, g);
|
search.render(container, g);
|
||||||
Utils.FONT_BOLD.drawString(
|
Fonts.BOLD.drawString(
|
||||||
search.getX() + search.getWidth() * 0.01f, search.getY() + search.getHeight() * 1.3f,
|
search.getX() + search.getWidth() * 0.01f, search.getY() + search.getHeight() * 1.3f,
|
||||||
searchResultString, Color.white
|
searchResultString, Color.white
|
||||||
);
|
);
|
||||||
@@ -377,9 +378,9 @@ public class DownloadsMenu extends BasicGameState {
|
|||||||
float baseX = width * 0.024f;
|
float baseX = width * 0.024f;
|
||||||
float buttonY = height * 0.2f;
|
float buttonY = height * 0.2f;
|
||||||
float buttonWidth = width * 0.7f;
|
float buttonWidth = width * 0.7f;
|
||||||
Utils.FONT_BOLD.drawString(
|
Fonts.BOLD.drawString(
|
||||||
baseX + (buttonWidth - Utils.FONT_BOLD.getWidth("Page 1")) / 2f,
|
baseX + (buttonWidth - Fonts.BOLD.getWidth("Page 1")) / 2f,
|
||||||
buttonY - Utils.FONT_BOLD.getLineHeight() * 1.3f,
|
buttonY - Fonts.BOLD.getLineHeight() * 1.3f,
|
||||||
String.format("Page %d", page), Color.white
|
String.format("Page %d", page), Color.white
|
||||||
);
|
);
|
||||||
if (page > 1)
|
if (page > 1)
|
||||||
@@ -391,10 +392,10 @@ public class DownloadsMenu extends BasicGameState {
|
|||||||
|
|
||||||
// downloads
|
// downloads
|
||||||
float downloadsX = width * 0.75f, downloadsY = search.getY();
|
float downloadsX = width * 0.75f, downloadsY = search.getY();
|
||||||
g.setColor(DownloadNode.BG_NORMAL);
|
g.setColor(Colors.BLACK_BG_NORMAL);
|
||||||
g.fillRect(downloadsX, downloadsY,
|
g.fillRect(downloadsX, downloadsY,
|
||||||
width * 0.25f, height - downloadsY * 2f);
|
width * 0.25f, height - downloadsY * 2f);
|
||||||
Utils.FONT_LARGE.drawString(downloadsX + width * 0.015f, downloadsY + height * 0.015f, "Downloads", Color.white);
|
Fonts.LARGE.drawString(downloadsX + width * 0.015f, downloadsY + height * 0.015f, "Downloads", Color.white);
|
||||||
int downloadsSize = DownloadList.get().size();
|
int downloadsSize = DownloadList.get().size();
|
||||||
if (downloadsSize > 0) {
|
if (downloadsSize > 0) {
|
||||||
int maxDownloadsShown = DownloadNode.maxDownloadsShown();
|
int maxDownloadsShown = DownloadNode.maxDownloadsShown();
|
||||||
@@ -417,9 +418,9 @@ public class DownloadsMenu extends BasicGameState {
|
|||||||
clearButton.draw(Color.gray);
|
clearButton.draw(Color.gray);
|
||||||
importButton.draw(Color.orange);
|
importButton.draw(Color.orange);
|
||||||
resetButton.draw(Color.red);
|
resetButton.draw(Color.red);
|
||||||
rankedButton.setText((rankedOnly) ? "Show Unranked" : "Hide Unranked", Utils.FONT_MEDIUM, Color.white);
|
rankedButton.setText((rankedOnly) ? "Show Unranked" : "Hide Unranked", Fonts.MEDIUM, Color.white);
|
||||||
rankedButton.draw(Color.magenta);
|
rankedButton.draw(Color.magenta);
|
||||||
serverButton.setText(SERVERS[serverIndex].getName(), Utils.FONT_MEDIUM, Color.white);
|
serverButton.setText(SERVERS[serverIndex].getName(), Fonts.MEDIUM, Color.white);
|
||||||
serverButton.draw(Color.blue);
|
serverButton.draw(Color.blue);
|
||||||
|
|
||||||
// importing beatmaps
|
// importing beatmaps
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import itdelatrisu.opsu.replay.PlaybackSpeed;
|
|||||||
import itdelatrisu.opsu.replay.Replay;
|
import itdelatrisu.opsu.replay.Replay;
|
||||||
import itdelatrisu.opsu.replay.ReplayFrame;
|
import itdelatrisu.opsu.replay.ReplayFrame;
|
||||||
import itdelatrisu.opsu.ui.Colors;
|
import itdelatrisu.opsu.ui.Colors;
|
||||||
|
import itdelatrisu.opsu.ui.Fonts;
|
||||||
import itdelatrisu.opsu.ui.MenuButton;
|
import itdelatrisu.opsu.ui.MenuButton;
|
||||||
import itdelatrisu.opsu.ui.UI;
|
import itdelatrisu.opsu.ui.UI;
|
||||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||||
@@ -479,7 +480,7 @@ public class Game extends BasicGameState {
|
|||||||
float oldAlpha = Colors.WHITE_FADE.a;
|
float oldAlpha = Colors.WHITE_FADE.a;
|
||||||
if (timeDiff < -500)
|
if (timeDiff < -500)
|
||||||
Colors.WHITE_FADE.a = (1000 + timeDiff) / 500f;
|
Colors.WHITE_FADE.a = (1000 + timeDiff) / 500f;
|
||||||
Utils.FONT_MEDIUM.drawString(
|
Fonts.MEDIUM.drawString(
|
||||||
2 + (width / 100), retryHeight,
|
2 + (width / 100), retryHeight,
|
||||||
String.format("%d retries and counting...", retries),
|
String.format("%d retries and counting...", retries),
|
||||||
Colors.WHITE_FADE
|
Colors.WHITE_FADE
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import itdelatrisu.opsu.beatmap.BeatmapSetNode;
|
|||||||
import itdelatrisu.opsu.downloads.Updater;
|
import itdelatrisu.opsu.downloads.Updater;
|
||||||
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
|
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
|
||||||
import itdelatrisu.opsu.ui.Colors;
|
import itdelatrisu.opsu.ui.Colors;
|
||||||
|
import itdelatrisu.opsu.ui.Fonts;
|
||||||
import itdelatrisu.opsu.ui.MenuButton;
|
import itdelatrisu.opsu.ui.MenuButton;
|
||||||
import itdelatrisu.opsu.ui.MenuButton.Expand;
|
import itdelatrisu.opsu.ui.MenuButton.Expand;
|
||||||
import itdelatrisu.opsu.ui.UI;
|
import itdelatrisu.opsu.ui.UI;
|
||||||
@@ -292,15 +293,17 @@ public class MainMenu extends BasicGameState {
|
|||||||
|
|
||||||
// draw text
|
// draw text
|
||||||
float marginX = width * 0.015f, topMarginY = height * 0.01f, bottomMarginY = height * 0.015f;
|
float marginX = width * 0.015f, topMarginY = height * 0.01f, bottomMarginY = height * 0.015f;
|
||||||
g.setFont(Utils.FONT_MEDIUM);
|
g.setFont(Fonts.MEDIUM);
|
||||||
float lineHeight = Utils.FONT_MEDIUM.getLineHeight() * 0.925f;
|
float lineHeight = Fonts.MEDIUM.getLineHeight() * 0.925f;
|
||||||
g.drawString(String.format("Loaded %d songs and %d beatmaps.",
|
g.drawString(String.format("Loaded %d songs and %d beatmaps.",
|
||||||
BeatmapSetList.get().getMapSetCount(), BeatmapSetList.get().getMapCount()), marginX, topMarginY);
|
BeatmapSetList.get().getMapSetCount(), BeatmapSetList.get().getMapCount()), marginX, topMarginY);
|
||||||
if (MusicController.isTrackLoading())
|
if (MusicController.isTrackLoading())
|
||||||
g.drawString("Track loading...", marginX, topMarginY + lineHeight);
|
g.drawString("Track loading...", marginX, topMarginY + lineHeight);
|
||||||
else if (MusicController.trackExists()) {
|
else if (MusicController.trackExists()) {
|
||||||
if (Options.useUnicodeMetadata()) // load glyphs
|
if (Options.useUnicodeMetadata()) { // load glyphs
|
||||||
Utils.loadGlyphs(Utils.FONT_MEDIUM, beatmap.titleUnicode, beatmap.artistUnicode);
|
Fonts.loadGlyphs(Fonts.MEDIUM, beatmap.titleUnicode);
|
||||||
|
Fonts.loadGlyphs(Fonts.MEDIUM, beatmap.artistUnicode);
|
||||||
|
}
|
||||||
g.drawString((MusicController.isPlaying()) ? "Now Playing:" : "Paused:", marginX, topMarginY + lineHeight);
|
g.drawString((MusicController.isPlaying()) ? "Now Playing:" : "Paused:", marginX, topMarginY + lineHeight);
|
||||||
g.drawString(String.format("%s: %s", beatmap.getArtist(), beatmap.getTitle()), marginX + 25, topMarginY + (lineHeight * 2));
|
g.drawString(String.format("%s: %s", beatmap.getArtist(), beatmap.getTitle()), marginX + 25, topMarginY + (lineHeight * 2));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import itdelatrisu.opsu.audio.MusicController;
|
|||||||
import itdelatrisu.opsu.audio.SoundController;
|
import itdelatrisu.opsu.audio.SoundController;
|
||||||
import itdelatrisu.opsu.audio.SoundEffect;
|
import itdelatrisu.opsu.audio.SoundEffect;
|
||||||
import itdelatrisu.opsu.ui.Colors;
|
import itdelatrisu.opsu.ui.Colors;
|
||||||
|
import itdelatrisu.opsu.ui.Fonts;
|
||||||
import itdelatrisu.opsu.ui.MenuButton;
|
import itdelatrisu.opsu.ui.MenuButton;
|
||||||
import itdelatrisu.opsu.ui.UI;
|
import itdelatrisu.opsu.ui.UI;
|
||||||
|
|
||||||
@@ -185,8 +186,8 @@ public class OptionsMenu extends BasicGameState {
|
|||||||
|
|
||||||
// option tabs
|
// option tabs
|
||||||
Image tabImage = GameImage.MENU_TAB.getImage();
|
Image tabImage = GameImage.MENU_TAB.getImage();
|
||||||
float tabX = width * 0.032f + Utils.FONT_DEFAULT.getWidth("Change the way opsu! behaves") + (tabImage.getWidth() / 2);
|
float tabX = width * 0.032f + Fonts.DEFAULT.getWidth("Change the way opsu! behaves") + (tabImage.getWidth() / 2);
|
||||||
float tabY = Utils.FONT_XLARGE.getLineHeight() + Utils.FONT_DEFAULT.getLineHeight() +
|
float tabY = Fonts.XLARGE.getLineHeight() + Fonts.DEFAULT.getLineHeight() +
|
||||||
height * 0.015f - (tabImage.getHeight() / 2f);
|
height * 0.015f - (tabImage.getHeight() / 2f);
|
||||||
int tabOffset = Math.min(tabImage.getWidth(), width / OptionTab.SIZE);
|
int tabOffset = Math.min(tabImage.getWidth(), width / OptionTab.SIZE);
|
||||||
for (OptionTab tab : OptionTab.values())
|
for (OptionTab tab : OptionTab.values())
|
||||||
@@ -210,8 +211,8 @@ public class OptionsMenu extends BasicGameState {
|
|||||||
|
|
||||||
// title
|
// title
|
||||||
float marginX = width * 0.015f, marginY = height * 0.01f;
|
float marginX = width * 0.015f, marginY = height * 0.01f;
|
||||||
Utils.FONT_XLARGE.drawString(marginX, marginY, "Options", Color.white);
|
Fonts.XLARGE.drawString(marginX, marginY, "Options", Color.white);
|
||||||
Utils.FONT_DEFAULT.drawString(marginX, marginY + Utils.FONT_XLARGE.getLineHeight() * 0.92f,
|
Fonts.DEFAULT.drawString(marginX, marginY + Fonts.XLARGE.getLineHeight() * 0.92f,
|
||||||
"Change the way opsu! behaves", Color.white);
|
"Change the way opsu! behaves", Color.white);
|
||||||
|
|
||||||
// game options
|
// game options
|
||||||
@@ -255,9 +256,9 @@ public class OptionsMenu extends BasicGameState {
|
|||||||
String prompt = (keyEntryLeft) ?
|
String prompt = (keyEntryLeft) ?
|
||||||
"Please press the new left-click key." :
|
"Please press the new left-click key." :
|
||||||
"Please press the new right-click key.";
|
"Please press the new right-click key.";
|
||||||
Utils.FONT_LARGE.drawString(
|
Fonts.LARGE.drawString(
|
||||||
(width / 2) - (Utils.FONT_LARGE.getWidth(prompt) / 2),
|
(width / 2) - (Fonts.LARGE.getWidth(prompt) / 2),
|
||||||
(height / 2) - Utils.FONT_LARGE.getLineHeight(), prompt
|
(height / 2) - Fonts.LARGE.getLineHeight(), prompt
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,13 +415,13 @@ public class OptionsMenu extends BasicGameState {
|
|||||||
*/
|
*/
|
||||||
private void drawOption(GameOption option, int pos, boolean focus) {
|
private void drawOption(GameOption option, int pos, boolean focus) {
|
||||||
int width = container.getWidth();
|
int width = container.getWidth();
|
||||||
int textHeight = Utils.FONT_LARGE.getLineHeight();
|
int textHeight = Fonts.LARGE.getLineHeight();
|
||||||
float y = textY + (pos * offsetY);
|
float y = textY + (pos * offsetY);
|
||||||
Color color = (focus) ? Color.cyan : Color.white;
|
Color color = (focus) ? Color.cyan : Color.white;
|
||||||
|
|
||||||
Utils.FONT_LARGE.drawString(width / 30, y, option.getName(), color);
|
Fonts.LARGE.drawString(width / 30, y, option.getName(), color);
|
||||||
Utils.FONT_LARGE.drawString(width / 2, y, option.getValueString(), color);
|
Fonts.LARGE.drawString(width / 2, y, option.getValueString(), color);
|
||||||
Utils.FONT_SMALL.drawString(width / 30, y + textHeight, option.getDescription(), color);
|
Fonts.SMALL.drawString(width / 30, y + textHeight, option.getDescription(), color);
|
||||||
g.setColor(Colors.WHITE_ALPHA);
|
g.setColor(Colors.WHITE_ALPHA);
|
||||||
g.drawLine(0, y + textHeight, width, y + textHeight);
|
g.drawLine(0, y + textHeight, width, y + textHeight);
|
||||||
}
|
}
|
||||||
@@ -434,7 +435,7 @@ public class OptionsMenu extends BasicGameState {
|
|||||||
if (y < textY || y > textY + (offsetY * maxOptionsScreen))
|
if (y < textY || y > textY + (offsetY * maxOptionsScreen))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
int index = (y - textY + Utils.FONT_LARGE.getLineHeight()) / offsetY;
|
int index = (y - textY + Fonts.LARGE.getLineHeight()) / offsetY;
|
||||||
if (index >= currentTab.options.length)
|
if (index >= currentTab.options.length)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import itdelatrisu.opsu.db.BeatmapDB;
|
|||||||
import itdelatrisu.opsu.db.ScoreDB;
|
import itdelatrisu.opsu.db.ScoreDB;
|
||||||
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
|
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
|
||||||
import itdelatrisu.opsu.ui.Colors;
|
import itdelatrisu.opsu.ui.Colors;
|
||||||
|
import itdelatrisu.opsu.ui.Fonts;
|
||||||
import itdelatrisu.opsu.ui.MenuButton;
|
import itdelatrisu.opsu.ui.MenuButton;
|
||||||
import itdelatrisu.opsu.ui.UI;
|
import itdelatrisu.opsu.ui.UI;
|
||||||
import itdelatrisu.opsu.ui.animations.AnimatedValue;
|
import itdelatrisu.opsu.ui.animations.AnimatedValue;
|
||||||
@@ -226,8 +227,8 @@ public class SongMenu extends BasicGameState {
|
|||||||
|
|
||||||
// header/footer coordinates
|
// header/footer coordinates
|
||||||
headerY = height * 0.0075f + GameImage.MENU_MUSICNOTE.getImage().getHeight() +
|
headerY = height * 0.0075f + GameImage.MENU_MUSICNOTE.getImage().getHeight() +
|
||||||
Utils.FONT_BOLD.getLineHeight() + Utils.FONT_DEFAULT.getLineHeight() +
|
Fonts.BOLD.getLineHeight() + Fonts.DEFAULT.getLineHeight() +
|
||||||
Utils.FONT_SMALL.getLineHeight();
|
Fonts.SMALL.getLineHeight();
|
||||||
footerY = height - GameImage.SELECTION_MODS.getImage().getHeight();
|
footerY = height - GameImage.SELECTION_MODS.getImage().getHeight();
|
||||||
|
|
||||||
// initialize sorts
|
// initialize sorts
|
||||||
@@ -248,11 +249,11 @@ public class SongMenu extends BasicGameState {
|
|||||||
buttonOffset = (footerY - headerY - DIVIDER_LINE_WIDTH) / MAX_SONG_BUTTONS;
|
buttonOffset = (footerY - headerY - DIVIDER_LINE_WIDTH) / MAX_SONG_BUTTONS;
|
||||||
|
|
||||||
// search
|
// search
|
||||||
int textFieldX = (int) (width * 0.7125f + Utils.FONT_BOLD.getWidth("Search: "));
|
int textFieldX = (int) (width * 0.7125f + Fonts.BOLD.getWidth("Search: "));
|
||||||
int textFieldY = (int) (headerY + Utils.FONT_BOLD.getLineHeight() / 2);
|
int textFieldY = (int) (headerY + Fonts.BOLD.getLineHeight() / 2);
|
||||||
search = new TextField(
|
search = new TextField(
|
||||||
container, Utils.FONT_BOLD, textFieldX, textFieldY,
|
container, Fonts.BOLD, textFieldX, textFieldY,
|
||||||
(int) (width * 0.99f) - textFieldX, Utils.FONT_BOLD.getLineHeight()
|
(int) (width * 0.99f) - textFieldX, Fonts.BOLD.getLineHeight()
|
||||||
);
|
);
|
||||||
search.setBackgroundColor(Color.transparent);
|
search.setBackgroundColor(Color.transparent);
|
||||||
search.setBorderColor(Color.transparent);
|
search.setBorderColor(Color.transparent);
|
||||||
@@ -343,26 +344,27 @@ public class SongMenu extends BasicGameState {
|
|||||||
songInfo = focusNode.getInfo();
|
songInfo = focusNode.getInfo();
|
||||||
if (Options.useUnicodeMetadata()) { // load glyphs
|
if (Options.useUnicodeMetadata()) { // load glyphs
|
||||||
Beatmap beatmap = focusNode.getBeatmapSet().get(0);
|
Beatmap beatmap = focusNode.getBeatmapSet().get(0);
|
||||||
Utils.loadGlyphs(Utils.FONT_LARGE, beatmap.titleUnicode, beatmap.artistUnicode);
|
Fonts.loadGlyphs(Fonts.LARGE, beatmap.titleUnicode);
|
||||||
|
Fonts.loadGlyphs(Fonts.LARGE, beatmap.artistUnicode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
marginX += 5;
|
marginX += 5;
|
||||||
float headerTextY = marginY * 0.2f;
|
float headerTextY = marginY * 0.2f;
|
||||||
Utils.FONT_LARGE.drawString(marginX + iconWidth * 1.05f, headerTextY, songInfo[0], Color.white);
|
Fonts.LARGE.drawString(marginX + iconWidth * 1.05f, headerTextY, songInfo[0], Color.white);
|
||||||
headerTextY += Utils.FONT_LARGE.getLineHeight() - 6;
|
headerTextY += Fonts.LARGE.getLineHeight() - 6;
|
||||||
Utils.FONT_DEFAULT.drawString(marginX + iconWidth * 1.05f, headerTextY, songInfo[1], Color.white);
|
Fonts.DEFAULT.drawString(marginX + iconWidth * 1.05f, headerTextY, songInfo[1], Color.white);
|
||||||
headerTextY += Utils.FONT_DEFAULT.getLineHeight() - 2;
|
headerTextY += Fonts.DEFAULT.getLineHeight() - 2;
|
||||||
float speedModifier = GameMod.getSpeedMultiplier();
|
float speedModifier = GameMod.getSpeedMultiplier();
|
||||||
Color color2 = (speedModifier == 1f) ? Color.white :
|
Color color2 = (speedModifier == 1f) ? Color.white :
|
||||||
(speedModifier > 1f) ? Colors.RED_HIGHLIGHT : Colors.BLUE_HIGHLIGHT;
|
(speedModifier > 1f) ? Colors.RED_HIGHLIGHT : Colors.BLUE_HIGHLIGHT;
|
||||||
Utils.FONT_BOLD.drawString(marginX, headerTextY, songInfo[2], color2);
|
Fonts.BOLD.drawString(marginX, headerTextY, songInfo[2], color2);
|
||||||
headerTextY += Utils.FONT_BOLD.getLineHeight() - 4;
|
headerTextY += Fonts.BOLD.getLineHeight() - 4;
|
||||||
Utils.FONT_DEFAULT.drawString(marginX, headerTextY, songInfo[3], Color.white);
|
Fonts.DEFAULT.drawString(marginX, headerTextY, songInfo[3], Color.white);
|
||||||
headerTextY += Utils.FONT_DEFAULT.getLineHeight() - 4;
|
headerTextY += Fonts.DEFAULT.getLineHeight() - 4;
|
||||||
float multiplier = GameMod.getDifficultyMultiplier();
|
float multiplier = GameMod.getDifficultyMultiplier();
|
||||||
Color color4 = (multiplier == 1f) ? Color.white :
|
Color color4 = (multiplier == 1f) ? Color.white :
|
||||||
(multiplier > 1f) ? Colors.RED_HIGHLIGHT : Colors.BLUE_HIGHLIGHT;
|
(multiplier > 1f) ? Colors.RED_HIGHLIGHT : Colors.BLUE_HIGHLIGHT;
|
||||||
Utils.FONT_SMALL.drawString(marginX, headerTextY, songInfo[4], color4);
|
Fonts.SMALL.drawString(marginX, headerTextY, songInfo[4], color4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// score buttons
|
// score buttons
|
||||||
@@ -410,8 +412,8 @@ public class SongMenu extends BasicGameState {
|
|||||||
int searchX = search.getX(), searchY = search.getY();
|
int searchX = search.getX(), searchY = search.getY();
|
||||||
float searchBaseX = width * 0.7f;
|
float searchBaseX = width * 0.7f;
|
||||||
float searchTextX = width * 0.7125f;
|
float searchTextX = width * 0.7125f;
|
||||||
float searchRectHeight = Utils.FONT_BOLD.getLineHeight() * 2;
|
float searchRectHeight = Fonts.BOLD.getLineHeight() * 2;
|
||||||
float searchExtraHeight = Utils.FONT_DEFAULT.getLineHeight() * 0.7f;
|
float searchExtraHeight = Fonts.DEFAULT.getLineHeight() * 0.7f;
|
||||||
float searchProgress = (searchTransitionTimer < SEARCH_TRANSITION_TIME) ?
|
float searchProgress = (searchTransitionTimer < SEARCH_TRANSITION_TIME) ?
|
||||||
((float) searchTransitionTimer / SEARCH_TRANSITION_TIME) : 1f;
|
((float) searchTransitionTimer / SEARCH_TRANSITION_TIME) : 1f;
|
||||||
float oldAlpha = Colors.BLACK_ALPHA.a;
|
float oldAlpha = Colors.BLACK_ALPHA.a;
|
||||||
@@ -425,16 +427,16 @@ public class SongMenu extends BasicGameState {
|
|||||||
g.setColor(Colors.BLACK_ALPHA);
|
g.setColor(Colors.BLACK_ALPHA);
|
||||||
g.fillRect(searchBaseX, headerY + DIVIDER_LINE_WIDTH / 2, width - searchBaseX, searchRectHeight);
|
g.fillRect(searchBaseX, headerY + DIVIDER_LINE_WIDTH / 2, width - searchBaseX, searchRectHeight);
|
||||||
Colors.BLACK_ALPHA.a = oldAlpha;
|
Colors.BLACK_ALPHA.a = oldAlpha;
|
||||||
Utils.FONT_BOLD.drawString(searchTextX, searchY, "Search:", Colors.GREEN_SEARCH);
|
Fonts.BOLD.drawString(searchTextX, searchY, "Search:", Colors.GREEN_SEARCH);
|
||||||
if (searchEmpty)
|
if (searchEmpty)
|
||||||
Utils.FONT_BOLD.drawString(searchX, searchY, "Type to search!", Color.white);
|
Fonts.BOLD.drawString(searchX, searchY, "Type to search!", Color.white);
|
||||||
else {
|
else {
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
// TODO: why is this needed to correctly position the TextField?
|
// TODO: why is this needed to correctly position the TextField?
|
||||||
search.setLocation(searchX - 3, searchY - 1);
|
search.setLocation(searchX - 3, searchY - 1);
|
||||||
search.render(container, g);
|
search.render(container, g);
|
||||||
search.setLocation(searchX, searchY);
|
search.setLocation(searchX, searchY);
|
||||||
Utils.FONT_DEFAULT.drawString(searchTextX, searchY + Utils.FONT_BOLD.getLineHeight(),
|
Fonts.DEFAULT.drawString(searchTextX, searchY + Fonts.BOLD.getLineHeight(),
|
||||||
(searchResultString == null) ? "Searching..." : searchResultString, Color.white);
|
(searchResultString == null) ? "Searching..." : searchResultString, Color.white);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
113
src/itdelatrisu/opsu/ui/Fonts.java
Normal file
113
src/itdelatrisu/opsu/ui/Fonts.java
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
/*
|
||||||
|
* opsu! - an open-source osu! client
|
||||||
|
* Copyright (C) 2014, 2015 Jeffrey Han
|
||||||
|
*
|
||||||
|
* opsu! is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* opsu! is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with opsu!. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package itdelatrisu.opsu.ui;
|
||||||
|
|
||||||
|
import itdelatrisu.opsu.GameImage;
|
||||||
|
import itdelatrisu.opsu.Options;
|
||||||
|
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.FontFormatException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
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.util.Log;
|
||||||
|
import org.newdawn.slick.util.ResourceLoader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fonts used for drawing.
|
||||||
|
*/
|
||||||
|
public class Fonts {
|
||||||
|
public static UnicodeFont DEFAULT, BOLD, XLARGE, LARGE, MEDIUM, SMALL;
|
||||||
|
|
||||||
|
/** Set of all Unicode strings already loaded per font. */
|
||||||
|
private static HashMap<UnicodeFont, HashSet<String>> loadedGlyphs = new HashMap<UnicodeFont, HashSet<String>>();
|
||||||
|
|
||||||
|
// This class should not be instantiated.
|
||||||
|
private Fonts() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes all fonts.
|
||||||
|
* @throws SlickException if ASCII glyphs could not be loaded
|
||||||
|
* @throws FontFormatException if any font stream data does not contain the required font tables
|
||||||
|
* @throws IOException if a font stream cannot be completely read
|
||||||
|
*/
|
||||||
|
public static void init() throws SlickException, FontFormatException, IOException {
|
||||||
|
float fontBase = 12f * GameImage.getUIscale();
|
||||||
|
Font javaFont = Font.createFont(Font.TRUETYPE_FONT, ResourceLoader.getResourceAsStream(Options.FONT_NAME));
|
||||||
|
Font font = javaFont.deriveFont(Font.PLAIN, (int) (fontBase * 4 / 3));
|
||||||
|
DEFAULT = new UnicodeFont(font);
|
||||||
|
BOLD = new UnicodeFont(font.deriveFont(Font.BOLD));
|
||||||
|
XLARGE = new UnicodeFont(font.deriveFont(fontBase * 3));
|
||||||
|
LARGE = new UnicodeFont(font.deriveFont(fontBase * 2));
|
||||||
|
MEDIUM = new UnicodeFont(font.deriveFont(fontBase * 3 / 2));
|
||||||
|
SMALL = new UnicodeFont(font.deriveFont(fontBase));
|
||||||
|
ColorEffect colorEffect = new ColorEffect();
|
||||||
|
loadFont(DEFAULT, colorEffect);
|
||||||
|
loadFont(BOLD, colorEffect);
|
||||||
|
loadFont(XLARGE, colorEffect);
|
||||||
|
loadFont(LARGE, colorEffect);
|
||||||
|
loadFont(MEDIUM, colorEffect);
|
||||||
|
loadFont(SMALL, colorEffect);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads a Unicode font and its ASCII glyphs.
|
||||||
|
* @param font the font to load
|
||||||
|
* @param effect the font effect
|
||||||
|
* @throws SlickException if the glyphs could not be loaded
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private static void loadFont(UnicodeFont font, Effect effect) throws SlickException {
|
||||||
|
font.addAsciiGlyphs();
|
||||||
|
font.getEffects().add(effect);
|
||||||
|
font.loadGlyphs();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds and loads glyphs for a font.
|
||||||
|
* @param font the font to add the glyphs to
|
||||||
|
* @param s the string containing the glyphs to load
|
||||||
|
*/
|
||||||
|
public static void loadGlyphs(UnicodeFont font, String s) {
|
||||||
|
if (s == null || s.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// get set of added strings
|
||||||
|
HashSet<String> set = loadedGlyphs.get(font);
|
||||||
|
if (set == null) {
|
||||||
|
set = new HashSet<String>();
|
||||||
|
loadedGlyphs.put(font, set);
|
||||||
|
} else if (set.contains(s))
|
||||||
|
return; // string already in set
|
||||||
|
|
||||||
|
// load glyphs
|
||||||
|
font.addGlyphs(s);
|
||||||
|
set.add(s);
|
||||||
|
try {
|
||||||
|
font.loadGlyphs();
|
||||||
|
} catch (SlickException e) {
|
||||||
|
Log.warn(String.format("Failed to load glyphs for string '%s'.", s), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -178,7 +178,7 @@ public class UI {
|
|||||||
*/
|
*/
|
||||||
public static void drawTab(float x, float y, String text, boolean selected, boolean isHover) {
|
public static void drawTab(float x, float y, String text, boolean selected, boolean isHover) {
|
||||||
Image tabImage = GameImage.MENU_TAB.getImage();
|
Image tabImage = GameImage.MENU_TAB.getImage();
|
||||||
float tabTextX = x - (Utils.FONT_MEDIUM.getWidth(text) / 2);
|
float tabTextX = x - (Fonts.MEDIUM.getWidth(text) / 2);
|
||||||
float tabTextY = y - (tabImage.getHeight() / 2);
|
float tabTextY = y - (tabImage.getHeight() / 2);
|
||||||
Color filter, textColor;
|
Color filter, textColor;
|
||||||
if (selected) {
|
if (selected) {
|
||||||
@@ -189,7 +189,7 @@ public class UI {
|
|||||||
textColor = Color.white;
|
textColor = Color.white;
|
||||||
}
|
}
|
||||||
tabImage.drawCentered(x, y, filter);
|
tabImage.drawCentered(x, y, filter);
|
||||||
Utils.FONT_MEDIUM.drawString(tabTextX, tabTextY, text, textColor);
|
Fonts.MEDIUM.drawString(tabTextX, tabTextY, text, textColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -201,14 +201,14 @@ public class UI {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
String fps = String.format("%dFPS", container.getFPS());
|
String fps = String.format("%dFPS", container.getFPS());
|
||||||
Utils.FONT_BOLD.drawString(
|
Fonts.BOLD.drawString(
|
||||||
container.getWidth() * 0.997f - Utils.FONT_BOLD.getWidth(fps),
|
container.getWidth() * 0.997f - Fonts.BOLD.getWidth(fps),
|
||||||
container.getHeight() * 0.997f - Utils.FONT_BOLD.getHeight(fps),
|
container.getHeight() * 0.997f - Fonts.BOLD.getHeight(fps),
|
||||||
Integer.toString(container.getFPS()), Color.white
|
Integer.toString(container.getFPS()), Color.white
|
||||||
);
|
);
|
||||||
Utils.FONT_DEFAULT.drawString(
|
Fonts.DEFAULT.drawString(
|
||||||
container.getWidth() * 0.997f - Utils.FONT_BOLD.getWidth("FPS"),
|
container.getWidth() * 0.997f - Fonts.BOLD.getWidth("FPS"),
|
||||||
container.getHeight() * 0.997f - Utils.FONT_BOLD.getHeight("FPS"),
|
container.getHeight() * 0.997f - Fonts.BOLD.getHeight("FPS"),
|
||||||
"FPS", Color.white
|
"FPS", Color.white
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -298,16 +298,16 @@ public class UI {
|
|||||||
// draw loading info
|
// draw loading info
|
||||||
float marginX = container.getWidth() * 0.02f, marginY = container.getHeight() * 0.02f;
|
float marginX = container.getWidth() * 0.02f, marginY = container.getHeight() * 0.02f;
|
||||||
float lineY = container.getHeight() - marginY;
|
float lineY = container.getHeight() - marginY;
|
||||||
int lineOffsetY = Utils.FONT_MEDIUM.getLineHeight();
|
int lineOffsetY = Fonts.MEDIUM.getLineHeight();
|
||||||
if (Options.isLoadVerbose()) {
|
if (Options.isLoadVerbose()) {
|
||||||
// verbose: display percentages and file names
|
// verbose: display percentages and file names
|
||||||
Utils.FONT_MEDIUM.drawString(
|
Fonts.MEDIUM.drawString(
|
||||||
marginX, lineY - (lineOffsetY * 2),
|
marginX, lineY - (lineOffsetY * 2),
|
||||||
String.format("%s (%d%%)", text, progress), Color.white);
|
String.format("%s (%d%%)", text, progress), Color.white);
|
||||||
Utils.FONT_MEDIUM.drawString(marginX, lineY - lineOffsetY, file, Color.white);
|
Fonts.MEDIUM.drawString(marginX, lineY - lineOffsetY, file, Color.white);
|
||||||
} else {
|
} else {
|
||||||
// draw loading bar
|
// draw loading bar
|
||||||
Utils.FONT_MEDIUM.drawString(marginX, lineY - (lineOffsetY * 2), text, Color.white);
|
Fonts.MEDIUM.drawString(marginX, lineY - (lineOffsetY * 2), text, Color.white);
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
g.fillRoundRect(marginX, lineY - (lineOffsetY / 2f),
|
g.fillRoundRect(marginX, lineY - (lineOffsetY / 2f),
|
||||||
(container.getWidth() - (marginX * 2f)) * progress / 100f, lineOffsetY / 4f, 4
|
(container.getWidth() - (marginX * 2f)) * progress / 100f, lineOffsetY / 4f, 4
|
||||||
@@ -376,20 +376,20 @@ public class UI {
|
|||||||
int containerWidth = container.getWidth(), containerHeight = container.getHeight();
|
int containerWidth = container.getWidth(), containerHeight = container.getHeight();
|
||||||
int margin = containerWidth / 100, textMarginX = 2;
|
int margin = containerWidth / 100, textMarginX = 2;
|
||||||
int offset = GameImage.CURSOR_MIDDLE.getImage().getWidth() / 2;
|
int offset = GameImage.CURSOR_MIDDLE.getImage().getWidth() / 2;
|
||||||
int lineHeight = Utils.FONT_SMALL.getLineHeight();
|
int lineHeight = Fonts.SMALL.getLineHeight();
|
||||||
int textWidth = textMarginX * 2, textHeight = lineHeight;
|
int textWidth = textMarginX * 2, textHeight = lineHeight;
|
||||||
if (tooltipNewlines) {
|
if (tooltipNewlines) {
|
||||||
String[] lines = tooltip.split("\\n");
|
String[] lines = tooltip.split("\\n");
|
||||||
int maxWidth = Utils.FONT_SMALL.getWidth(lines[0]);
|
int maxWidth = Fonts.SMALL.getWidth(lines[0]);
|
||||||
for (int i = 1; i < lines.length; i++) {
|
for (int i = 1; i < lines.length; i++) {
|
||||||
int w = Utils.FONT_SMALL.getWidth(lines[i]);
|
int w = Fonts.SMALL.getWidth(lines[i]);
|
||||||
if (w > maxWidth)
|
if (w > maxWidth)
|
||||||
maxWidth = w;
|
maxWidth = w;
|
||||||
}
|
}
|
||||||
textWidth += maxWidth;
|
textWidth += maxWidth;
|
||||||
textHeight += lineHeight * (lines.length - 1);
|
textHeight += lineHeight * (lines.length - 1);
|
||||||
} else
|
} else
|
||||||
textWidth += Utils.FONT_SMALL.getWidth(tooltip);
|
textWidth += Fonts.SMALL.getWidth(tooltip);
|
||||||
|
|
||||||
// get drawing coordinates
|
// get drawing coordinates
|
||||||
int x = input.getMouseX() + offset, y = input.getMouseY() + offset;
|
int x = input.getMouseX() + offset, y = input.getMouseY() + offset;
|
||||||
@@ -417,7 +417,7 @@ public class UI {
|
|||||||
Colors.DARK_GRAY.a = oldAlpha;
|
Colors.DARK_GRAY.a = oldAlpha;
|
||||||
oldAlpha = Colors.WHITE_ALPHA.a;
|
oldAlpha = Colors.WHITE_ALPHA.a;
|
||||||
Colors.WHITE_ALPHA.a = alpha;
|
Colors.WHITE_ALPHA.a = alpha;
|
||||||
Utils.FONT_SMALL.drawString(x + textMarginX, y, tooltip, Colors.WHITE_ALPHA);
|
Fonts.SMALL.drawString(x + textMarginX, y, tooltip, Colors.WHITE_ALPHA);
|
||||||
Colors.WHITE_ALPHA.a = oldAlpha;
|
Colors.WHITE_ALPHA.a = oldAlpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,15 +473,15 @@ public class UI {
|
|||||||
if (barNotifTimer >= BAR_NOTIFICATION_TIME * 0.9f)
|
if (barNotifTimer >= BAR_NOTIFICATION_TIME * 0.9f)
|
||||||
alpha -= 1 - ((BAR_NOTIFICATION_TIME - barNotifTimer) / (BAR_NOTIFICATION_TIME * 0.1f));
|
alpha -= 1 - ((BAR_NOTIFICATION_TIME - barNotifTimer) / (BAR_NOTIFICATION_TIME * 0.1f));
|
||||||
int midX = container.getWidth() / 2, midY = container.getHeight() / 2;
|
int midX = container.getWidth() / 2, midY = container.getHeight() / 2;
|
||||||
float barHeight = Utils.FONT_LARGE.getLineHeight() * (1f + 0.6f * Math.min(barNotifTimer * 15f / BAR_NOTIFICATION_TIME, 1f));
|
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;
|
float oldAlphaB = Colors.BLACK_ALPHA.a, oldAlphaW = Colors.WHITE_ALPHA.a;
|
||||||
Colors.BLACK_ALPHA.a *= alpha;
|
Colors.BLACK_ALPHA.a *= alpha;
|
||||||
Colors.WHITE_ALPHA.a = alpha;
|
Colors.WHITE_ALPHA.a = alpha;
|
||||||
g.setColor(Colors.BLACK_ALPHA);
|
g.setColor(Colors.BLACK_ALPHA);
|
||||||
g.fillRect(0, midY - barHeight / 2f, container.getWidth(), barHeight);
|
g.fillRect(0, midY - barHeight / 2f, container.getWidth(), barHeight);
|
||||||
Utils.FONT_LARGE.drawString(
|
Fonts.LARGE.drawString(
|
||||||
midX - Utils.FONT_LARGE.getWidth(barNotif) / 2f,
|
midX - Fonts.LARGE.getWidth(barNotif) / 2f,
|
||||||
midY - Utils.FONT_LARGE.getLineHeight() / 2.2f,
|
midY - Fonts.LARGE.getLineHeight() / 2.2f,
|
||||||
barNotif, Colors.WHITE_ALPHA);
|
barNotif, Colors.WHITE_ALPHA);
|
||||||
Colors.BLACK_ALPHA.a = oldAlphaB;
|
Colors.BLACK_ALPHA.a = oldAlphaB;
|
||||||
Colors.WHITE_ALPHA.a = oldAlphaW;
|
Colors.WHITE_ALPHA.a = oldAlphaW;
|
||||||
|
|||||||
Reference in New Issue
Block a user