Bug fixes and tweaks.
- Check if other Desktop actions are supported (follow-up to #114). - The cursor-middle image is no longer scaled (when clicking). - Changed the options menu background image (created with Trianglify at http://qrohlf.com/trianglify/), and made it fit the entire page. - Slightly increased minimum splash screen time. - Switched more animations to use AnimatedValue. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
cd59c332ab
commit
40ab94794f
Binary file not shown.
Before Width: | Height: | Size: 114 KiB |
BIN
res/options-background.png
Normal file
BIN
res/options-background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 340 KiB |
|
@ -20,8 +20,10 @@ package itdelatrisu.opsu;
|
||||||
|
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
@ -44,12 +46,13 @@ public class ErrorHandler {
|
||||||
/** Error popup description text. */
|
/** Error popup description text. */
|
||||||
private static final String
|
private static final String
|
||||||
desc = "opsu! has encountered an error.",
|
desc = "opsu! has encountered an error.",
|
||||||
descR = "opsu! has encountered an error. Please report this!";
|
descReport = "opsu! has encountered an error. Please report this!";
|
||||||
|
|
||||||
/** Error popup button options. */
|
/** Error popup button options. */
|
||||||
private static final String[]
|
private static final String[]
|
||||||
options = {"View Error Log", "Close"},
|
optionsLog = {"View Error Log", "Close"},
|
||||||
optionsR = {"Send Report", "View Error Log", "Close"};
|
optionsReport = {"Send Report", "Close"},
|
||||||
|
optionsLogReport = {"Send Report", "View Error Log", "Close"};
|
||||||
|
|
||||||
/** Text area for Exception. */
|
/** Text area for Exception. */
|
||||||
private static final JTextArea textArea = new JTextArea(7, 30);
|
private static final JTextArea textArea = new JTextArea(7, 30);
|
||||||
|
@ -67,7 +70,7 @@ public class ErrorHandler {
|
||||||
/** Error popup objects. */
|
/** Error popup objects. */
|
||||||
private static final Object[]
|
private static final Object[]
|
||||||
message = { desc, scroll },
|
message = { desc, scroll },
|
||||||
messageR = { descR, scroll };
|
messageReport = { descReport, scroll };
|
||||||
|
|
||||||
// This class should not be instantiated.
|
// This class should not be instantiated.
|
||||||
private ErrorHandler() {}
|
private ErrorHandler() {}
|
||||||
|
@ -107,72 +110,106 @@ public class ErrorHandler {
|
||||||
// display popup
|
// display popup
|
||||||
try {
|
try {
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
|
Desktop desktop = null;
|
||||||
|
boolean isBrowseSupported = false, isOpenSupported = false;
|
||||||
if (Desktop.isDesktopSupported()) {
|
if (Desktop.isDesktopSupported()) {
|
||||||
// try to open the log file and/or issues webpage
|
desktop = Desktop.getDesktop();
|
||||||
if (report) {
|
isBrowseSupported = desktop.isSupported(Desktop.Action.BROWSE);
|
||||||
// ask to report the error
|
isOpenSupported = desktop.isSupported(Desktop.Action.OPEN);
|
||||||
int n = JOptionPane.showOptionDialog(null, messageR, title,
|
}
|
||||||
JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE,
|
if (desktop != null && (isOpenSupported || (report && isBrowseSupported))) { // try to open the log file and/or issues webpage
|
||||||
null, optionsR, optionsR[2]);
|
if (report && isBrowseSupported) { // ask to report the error
|
||||||
if (n == 0) {
|
if (isOpenSupported) { // also ask to open the log
|
||||||
// auto-fill debug information
|
int n = JOptionPane.showOptionDialog(null, messageReport, title,
|
||||||
String issueTitle = (error != null) ? error : e.getMessage();
|
JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE,
|
||||||
StringBuilder sb = new StringBuilder();
|
null, optionsLogReport, optionsLogReport[2]);
|
||||||
Properties props = new Properties();
|
if (n == 0)
|
||||||
props.load(ResourceLoader.getResourceAsStream(Options.VERSION_FILE));
|
desktop.browse(getIssueURI(error, e, trace));
|
||||||
String version = props.getProperty("version");
|
else if (n == 1)
|
||||||
if (version != null && !version.equals("${pom.version}")) {
|
desktop.open(Options.LOG_FILE);
|
||||||
sb.append("**Version:** ");
|
} else { // only ask to report the error
|
||||||
sb.append(version);
|
int n = JOptionPane.showOptionDialog(null, message, title,
|
||||||
sb.append('\n');
|
JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE,
|
||||||
}
|
null, optionsReport, optionsReport[1]);
|
||||||
String timestamp = props.getProperty("build.date");
|
if (n == 0)
|
||||||
if (timestamp != null &&
|
desktop.browse(getIssueURI(error, e, trace));
|
||||||
!timestamp.equals("${maven.build.timestamp}") && !timestamp.equals("${timestamp}")) {
|
}
|
||||||
sb.append("**Build date:** ");
|
} else { // don't report the error
|
||||||
sb.append(timestamp);
|
|
||||||
sb.append('\n');
|
|
||||||
}
|
|
||||||
sb.append("**OS:** ");
|
|
||||||
sb.append(System.getProperty("os.name"));
|
|
||||||
sb.append(" (");
|
|
||||||
sb.append(System.getProperty("os.arch"));
|
|
||||||
sb.append(")\n");
|
|
||||||
sb.append("**JRE:** ");
|
|
||||||
sb.append(System.getProperty("java.version"));
|
|
||||||
sb.append('\n');
|
|
||||||
if (error != null) {
|
|
||||||
sb.append("**Error:** `");
|
|
||||||
sb.append(error);
|
|
||||||
sb.append("`\n");
|
|
||||||
}
|
|
||||||
if (trace != null) {
|
|
||||||
sb.append("**Stack trace:**");
|
|
||||||
sb.append("\n```\n");
|
|
||||||
sb.append(trace);
|
|
||||||
sb.append("```");
|
|
||||||
}
|
|
||||||
URI uri = URI.create(String.format(Options.ISSUES_URL,
|
|
||||||
URLEncoder.encode(issueTitle, "UTF-8"),
|
|
||||||
URLEncoder.encode(sb.toString(), "UTF-8")));
|
|
||||||
Desktop.getDesktop().browse(uri);
|
|
||||||
} else if (n == 1)
|
|
||||||
Desktop.getDesktop().open(Options.LOG_FILE);
|
|
||||||
} else {
|
|
||||||
// don't report the error
|
|
||||||
int n = JOptionPane.showOptionDialog(null, message, title,
|
int n = JOptionPane.showOptionDialog(null, message, title,
|
||||||
JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE,
|
JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE,
|
||||||
null, options, options[1]);
|
null, optionsLog, optionsLog[1]);
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
Desktop.getDesktop().open(Options.LOG_FILE);
|
desktop.open(Options.LOG_FILE);
|
||||||
}
|
}
|
||||||
} else {
|
} else { // display error only
|
||||||
// display error only
|
JOptionPane.showMessageDialog(null, report ? messageReport : message,
|
||||||
JOptionPane.showMessageDialog(null, report ? messageR : message,
|
|
||||||
title, JOptionPane.ERROR_MESSAGE);
|
title, JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
Log.error("Error opening crash popup.", e1);
|
Log.error("An error occurred in the crash popup.", e1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the issue reporting URI.
|
||||||
|
* This will auto-fill the report with the relevant information if possible.
|
||||||
|
* @param error a description of the error
|
||||||
|
* @param e the exception causing the error
|
||||||
|
* @param trace the stack trace
|
||||||
|
* @return the created URI
|
||||||
|
*/
|
||||||
|
private static URI getIssueURI(String error, Throwable e, String trace) {
|
||||||
|
// generate report information
|
||||||
|
String issueTitle = (error != null) ? error : e.getMessage();
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
try {
|
||||||
|
// read version and build date from version file, if possible
|
||||||
|
Properties props = new Properties();
|
||||||
|
props.load(ResourceLoader.getResourceAsStream(Options.VERSION_FILE));
|
||||||
|
String version = props.getProperty("version");
|
||||||
|
if (version != null && !version.equals("${pom.version}")) {
|
||||||
|
sb.append("**Version:** ");
|
||||||
|
sb.append(version);
|
||||||
|
sb.append('\n');
|
||||||
|
}
|
||||||
|
String timestamp = props.getProperty("build.date");
|
||||||
|
if (timestamp != null &&
|
||||||
|
!timestamp.equals("${maven.build.timestamp}") && !timestamp.equals("${timestamp}")) {
|
||||||
|
sb.append("**Build date:** ");
|
||||||
|
sb.append(timestamp);
|
||||||
|
sb.append('\n');
|
||||||
|
}
|
||||||
|
} catch (IOException e1) {
|
||||||
|
Log.warn("Could not read version file.", e1);
|
||||||
|
}
|
||||||
|
sb.append("**OS:** ");
|
||||||
|
sb.append(System.getProperty("os.name"));
|
||||||
|
sb.append(" (");
|
||||||
|
sb.append(System.getProperty("os.arch"));
|
||||||
|
sb.append(")\n");
|
||||||
|
sb.append("**JRE:** ");
|
||||||
|
sb.append(System.getProperty("java.version"));
|
||||||
|
sb.append('\n');
|
||||||
|
if (error != null) {
|
||||||
|
sb.append("**Error:** `");
|
||||||
|
sb.append(error);
|
||||||
|
sb.append("`\n");
|
||||||
|
}
|
||||||
|
if (trace != null) {
|
||||||
|
sb.append("**Stack trace:**");
|
||||||
|
sb.append("\n```\n");
|
||||||
|
sb.append(trace);
|
||||||
|
sb.append("```");
|
||||||
|
}
|
||||||
|
|
||||||
|
// return auto-filled URI
|
||||||
|
try {
|
||||||
|
return URI.create(String.format(Options.ISSUES_URL,
|
||||||
|
URLEncoder.encode(issueTitle, "UTF-8"),
|
||||||
|
URLEncoder.encode(sb.toString(), "UTF-8")));
|
||||||
|
} catch (UnsupportedEncodingException e1) {
|
||||||
|
Log.warn("URLEncoder failed to encode the auto-filled issue report URL.");
|
||||||
|
return URI.create(String.format(Options.ISSUES_URL, "", ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ public class MainMenu extends BasicGameState {
|
||||||
|
|
||||||
// initialize repository button
|
// initialize repository button
|
||||||
float startX = width * 0.997f, startY = height * 0.997f;
|
float startX = width * 0.997f, startY = height * 0.997f;
|
||||||
if (Desktop.isDesktopSupported()) { // only if a webpage can be opened
|
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { // only if a webpage can be opened
|
||||||
Image repoImg = GameImage.REPOSITORY.getImage();
|
Image repoImg = GameImage.REPOSITORY.getImage();
|
||||||
repoButton = new MenuButton(repoImg,
|
repoButton = new MenuButton(repoImg,
|
||||||
startX - repoImg.getWidth(), startY - repoImg.getHeight()
|
startX - repoImg.getWidth(), startY - repoImg.getHeight()
|
||||||
|
@ -501,7 +501,9 @@ public class MainMenu extends BasicGameState {
|
||||||
else if (repoButton != null && repoButton.contains(x, y)) {
|
else if (repoButton != null && repoButton.contains(x, y)) {
|
||||||
try {
|
try {
|
||||||
Desktop.getDesktop().browse(Options.REPOSITORY_URI);
|
Desktop.getDesktop().browse(Options.REPOSITORY_URI);
|
||||||
} catch (IOException | UnsupportedOperationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
|
UI.sendBarNotification("The repository web page could not be opened.");
|
||||||
|
} catch (IOException e) {
|
||||||
ErrorHandler.error("Could not browse to repository URI.", e, false);
|
ErrorHandler.error("Could not browse to repository URI.", e, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,12 +200,12 @@ public class OptionsMenu extends BasicGameState {
|
||||||
@Override
|
@Override
|
||||||
public void render(GameContainer container, StateBasedGame game, Graphics g)
|
public void render(GameContainer container, StateBasedGame game, Graphics g)
|
||||||
throws SlickException {
|
throws SlickException {
|
||||||
g.setBackground(Utils.COLOR_BLACK_ALPHA);
|
|
||||||
|
|
||||||
int width = container.getWidth();
|
int width = container.getWidth();
|
||||||
int height = container.getHeight();
|
int height = container.getHeight();
|
||||||
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
||||||
float lineY = OptionTab.DISPLAY.button.getY() + (GameImage.MENU_TAB.getImage().getHeight() / 2f);
|
|
||||||
|
// background
|
||||||
|
GameImage.OPTIONS_BG.getImage().draw();
|
||||||
|
|
||||||
// title
|
// title
|
||||||
float marginX = width * 0.015f, marginY = height * 0.01f;
|
float marginX = width * 0.015f, marginY = height * 0.01f;
|
||||||
|
@ -213,9 +213,6 @@ public class OptionsMenu extends BasicGameState {
|
||||||
Utils.FONT_DEFAULT.drawString(marginX, marginY + Utils.FONT_XLARGE.getLineHeight() * 0.92f,
|
Utils.FONT_DEFAULT.drawString(marginX, marginY + Utils.FONT_XLARGE.getLineHeight() * 0.92f,
|
||||||
"Change the way opsu! behaves", Color.white);
|
"Change the way opsu! behaves", Color.white);
|
||||||
|
|
||||||
// background
|
|
||||||
GameImage.OPTIONS_BG.getImage().draw(0, lineY);
|
|
||||||
|
|
||||||
// game options
|
// game options
|
||||||
g.setLineWidth(1f);
|
g.setLineWidth(1f);
|
||||||
GameOption hoverOption = (keyEntryLeft) ? GameOption.KEY_LEFT :
|
GameOption hoverOption = (keyEntryLeft) ? GameOption.KEY_LEFT :
|
||||||
|
@ -243,6 +240,7 @@ public class OptionsMenu extends BasicGameState {
|
||||||
currentTab.getName(), true, false);
|
currentTab.getName(), true, false);
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
g.setLineWidth(2f);
|
g.setLineWidth(2f);
|
||||||
|
float lineY = OptionTab.DISPLAY.button.getY() + (GameImage.MENU_TAB.getImage().getHeight() / 2f);
|
||||||
g.drawLine(0, lineY, width, lineY);
|
g.drawLine(0, lineY, width, lineY);
|
||||||
g.resetLineWidth();
|
g.resetLineWidth();
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ import org.newdawn.slick.state.StateBasedGame;
|
||||||
*/
|
*/
|
||||||
public class Splash extends BasicGameState {
|
public class Splash extends BasicGameState {
|
||||||
/** Minimum time, in milliseconds, to display the splash screen (and fade in the logo). */
|
/** Minimum time, in milliseconds, to display the splash screen (and fade in the logo). */
|
||||||
private static final int MIN_SPLASH_TIME = 300;
|
private static final int MIN_SPLASH_TIME = 400;
|
||||||
|
|
||||||
/** Whether or not loading has completed. */
|
/** Whether or not loading has completed. */
|
||||||
private boolean finished = false;
|
private boolean finished = false;
|
||||||
|
|
|
@ -135,8 +135,6 @@ public class Cursor {
|
||||||
if (cursorScale != 1f) {
|
if (cursorScale != 1f) {
|
||||||
cursor = cursor.getScaledCopy(cursorScale);
|
cursor = cursor.getScaledCopy(cursorScale);
|
||||||
cursorTrail = cursorTrail.getScaledCopy(cursorScale);
|
cursorTrail = cursorTrail.getScaledCopy(cursorScale);
|
||||||
if (hasMiddle)
|
|
||||||
cursorMiddle = cursorMiddle.getScaledCopy(cursorScale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use an image buffer
|
// TODO: use an image buffer
|
||||||
|
|
|
@ -26,6 +26,7 @@ import itdelatrisu.opsu.Utils;
|
||||||
import itdelatrisu.opsu.audio.SoundController;
|
import itdelatrisu.opsu.audio.SoundController;
|
||||||
import itdelatrisu.opsu.beatmap.BeatmapParser;
|
import itdelatrisu.opsu.beatmap.BeatmapParser;
|
||||||
import itdelatrisu.opsu.replay.ReplayImporter;
|
import itdelatrisu.opsu.replay.ReplayImporter;
|
||||||
|
import itdelatrisu.opsu.ui.animations.AnimatedValue;
|
||||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
@ -71,11 +72,8 @@ public class UI {
|
||||||
/** Whether or not to check the current tooltip for line breaks. */
|
/** Whether or not to check the current tooltip for line breaks. */
|
||||||
private static boolean tooltipNewlines;
|
private static boolean tooltipNewlines;
|
||||||
|
|
||||||
/** The current tooltip timer. */
|
/** The alpha level of the current tooltip (if any). */
|
||||||
private static int tooltipTimer = -1;
|
private static AnimatedValue tooltipAlpha = new AnimatedValue(200, 0f, 1f, AnimationEquation.LINEAR);
|
||||||
|
|
||||||
/** Duration, in milliseconds, to fade tooltips. */
|
|
||||||
private static final int TOOLTIP_FADE_TIME = 200;
|
|
||||||
|
|
||||||
// game-related variables
|
// game-related variables
|
||||||
private static GameContainer container;
|
private static GameContainer container;
|
||||||
|
@ -120,8 +118,7 @@ public class UI {
|
||||||
cursor.update(delta);
|
cursor.update(delta);
|
||||||
updateVolumeDisplay(delta);
|
updateVolumeDisplay(delta);
|
||||||
updateBarNotification(delta);
|
updateBarNotification(delta);
|
||||||
if (tooltipTimer > 0)
|
tooltipAlpha.update(-delta);
|
||||||
tooltipTimer -= delta;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -363,12 +360,7 @@ public class UI {
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
tooltip = s;
|
tooltip = s;
|
||||||
tooltipNewlines = newlines;
|
tooltipNewlines = newlines;
|
||||||
if (tooltipTimer <= 0)
|
tooltipAlpha.update(delta * 2);
|
||||||
tooltipTimer = delta;
|
|
||||||
else
|
|
||||||
tooltipTimer += delta * 2;
|
|
||||||
if (tooltipTimer > TOOLTIP_FADE_TIME)
|
|
||||||
tooltipTimer = TOOLTIP_FADE_TIME;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +370,7 @@ public class UI {
|
||||||
* @param g the graphics context
|
* @param g the graphics context
|
||||||
*/
|
*/
|
||||||
public static void drawTooltip(Graphics g) {
|
public static void drawTooltip(Graphics g) {
|
||||||
if (tooltipTimer <= 0 || tooltip == null)
|
if (tooltipAlpha.getTime() == 0 || tooltip == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int containerWidth = container.getWidth(), containerHeight = container.getHeight();
|
int containerWidth = container.getWidth(), containerHeight = container.getHeight();
|
||||||
|
@ -411,7 +403,7 @@ public class UI {
|
||||||
y = margin;
|
y = margin;
|
||||||
|
|
||||||
// draw tooltip text inside a filled rectangle
|
// draw tooltip text inside a filled rectangle
|
||||||
float alpha = (float) tooltipTimer / TOOLTIP_FADE_TIME;
|
float alpha = tooltipAlpha.getValue();
|
||||||
float oldAlpha = Utils.COLOR_BLACK_ALPHA.a;
|
float oldAlpha = Utils.COLOR_BLACK_ALPHA.a;
|
||||||
Utils.COLOR_BLACK_ALPHA.a = alpha;
|
Utils.COLOR_BLACK_ALPHA.a = alpha;
|
||||||
g.setColor(Utils.COLOR_BLACK_ALPHA);
|
g.setColor(Utils.COLOR_BLACK_ALPHA);
|
||||||
|
@ -433,7 +425,7 @@ public class UI {
|
||||||
* Resets the tooltip.
|
* Resets the tooltip.
|
||||||
*/
|
*/
|
||||||
public static void resetTooltip() {
|
public static void resetTooltip() {
|
||||||
tooltipTimer = -1;
|
tooltipAlpha.setTime(0);
|
||||||
tooltip = null;
|
tooltip = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user