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.Desktop;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Properties;
|
||||
|
@ -44,12 +46,13 @@ public class ErrorHandler {
|
|||
/** Error popup description text. */
|
||||
private static final String
|
||||
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. */
|
||||
private static final String[]
|
||||
options = {"View Error Log", "Close"},
|
||||
optionsR = {"Send Report", "View Error Log", "Close"};
|
||||
optionsLog = {"View Error Log", "Close"},
|
||||
optionsReport = {"Send Report", "Close"},
|
||||
optionsLogReport = {"Send Report", "View Error Log", "Close"};
|
||||
|
||||
/** Text area for Exception. */
|
||||
private static final JTextArea textArea = new JTextArea(7, 30);
|
||||
|
@ -67,7 +70,7 @@ public class ErrorHandler {
|
|||
/** Error popup objects. */
|
||||
private static final Object[]
|
||||
message = { desc, scroll },
|
||||
messageR = { descR, scroll };
|
||||
messageReport = { descReport, scroll };
|
||||
|
||||
// This class should not be instantiated.
|
||||
private ErrorHandler() {}
|
||||
|
@ -107,72 +110,106 @@ public class ErrorHandler {
|
|||
// display popup
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
Desktop desktop = null;
|
||||
boolean isBrowseSupported = false, isOpenSupported = false;
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
// try to open the log file and/or issues webpage
|
||||
if (report) {
|
||||
// ask to report the error
|
||||
int n = JOptionPane.showOptionDialog(null, messageR, title,
|
||||
JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE,
|
||||
null, optionsR, optionsR[2]);
|
||||
if (n == 0) {
|
||||
// auto-fill debug information
|
||||
String issueTitle = (error != null) ? error : e.getMessage();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
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');
|
||||
}
|
||||
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
|
||||
desktop = Desktop.getDesktop();
|
||||
isBrowseSupported = desktop.isSupported(Desktop.Action.BROWSE);
|
||||
isOpenSupported = desktop.isSupported(Desktop.Action.OPEN);
|
||||
}
|
||||
if (desktop != null && (isOpenSupported || (report && isBrowseSupported))) { // try to open the log file and/or issues webpage
|
||||
if (report && isBrowseSupported) { // ask to report the error
|
||||
if (isOpenSupported) { // also ask to open the log
|
||||
int n = JOptionPane.showOptionDialog(null, messageReport, title,
|
||||
JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE,
|
||||
null, optionsLogReport, optionsLogReport[2]);
|
||||
if (n == 0)
|
||||
desktop.browse(getIssueURI(error, e, trace));
|
||||
else if (n == 1)
|
||||
desktop.open(Options.LOG_FILE);
|
||||
} else { // only ask to report the error
|
||||
int n = JOptionPane.showOptionDialog(null, message, title,
|
||||
JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE,
|
||||
null, optionsReport, optionsReport[1]);
|
||||
if (n == 0)
|
||||
desktop.browse(getIssueURI(error, e, trace));
|
||||
}
|
||||
} else { // don't report the error
|
||||
int n = JOptionPane.showOptionDialog(null, message, title,
|
||||
JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE,
|
||||
null, options, options[1]);
|
||||
null, optionsLog, optionsLog[1]);
|
||||
if (n == 0)
|
||||
Desktop.getDesktop().open(Options.LOG_FILE);
|
||||
desktop.open(Options.LOG_FILE);
|
||||
}
|
||||
} else {
|
||||
// display error only
|
||||
JOptionPane.showMessageDialog(null, report ? messageR : message,
|
||||
} else { // display error only
|
||||
JOptionPane.showMessageDialog(null, report ? messageReport : message,
|
||||
title, JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} 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
|
||||
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();
|
||||
repoButton = new MenuButton(repoImg,
|
||||
startX - repoImg.getWidth(), startY - repoImg.getHeight()
|
||||
|
@ -501,7 +501,9 @@ public class MainMenu extends BasicGameState {
|
|||
else if (repoButton != null && repoButton.contains(x, y)) {
|
||||
try {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -200,12 +200,12 @@ public class OptionsMenu extends BasicGameState {
|
|||
@Override
|
||||
public void render(GameContainer container, StateBasedGame game, Graphics g)
|
||||
throws SlickException {
|
||||
g.setBackground(Utils.COLOR_BLACK_ALPHA);
|
||||
|
||||
int width = container.getWidth();
|
||||
int height = container.getHeight();
|
||||
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
|
||||
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,
|
||||
"Change the way opsu! behaves", Color.white);
|
||||
|
||||
// background
|
||||
GameImage.OPTIONS_BG.getImage().draw(0, lineY);
|
||||
|
||||
// game options
|
||||
g.setLineWidth(1f);
|
||||
GameOption hoverOption = (keyEntryLeft) ? GameOption.KEY_LEFT :
|
||||
|
@ -243,6 +240,7 @@ public class OptionsMenu extends BasicGameState {
|
|||
currentTab.getName(), true, false);
|
||||
g.setColor(Color.white);
|
||||
g.setLineWidth(2f);
|
||||
float lineY = OptionTab.DISPLAY.button.getY() + (GameImage.MENU_TAB.getImage().getHeight() / 2f);
|
||||
g.drawLine(0, lineY, width, lineY);
|
||||
g.resetLineWidth();
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ import org.newdawn.slick.state.StateBasedGame;
|
|||
*/
|
||||
public class Splash extends BasicGameState {
|
||||
/** 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. */
|
||||
private boolean finished = false;
|
||||
|
|
|
@ -135,8 +135,6 @@ public class Cursor {
|
|||
if (cursorScale != 1f) {
|
||||
cursor = cursor.getScaledCopy(cursorScale);
|
||||
cursorTrail = cursorTrail.getScaledCopy(cursorScale);
|
||||
if (hasMiddle)
|
||||
cursorMiddle = cursorMiddle.getScaledCopy(cursorScale);
|
||||
}
|
||||
|
||||
// TODO: use an image buffer
|
||||
|
|
|
@ -26,6 +26,7 @@ import itdelatrisu.opsu.Utils;
|
|||
import itdelatrisu.opsu.audio.SoundController;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapParser;
|
||||
import itdelatrisu.opsu.replay.ReplayImporter;
|
||||
import itdelatrisu.opsu.ui.animations.AnimatedValue;
|
||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
@ -71,11 +72,8 @@ public class UI {
|
|||
/** Whether or not to check the current tooltip for line breaks. */
|
||||
private static boolean tooltipNewlines;
|
||||
|
||||
/** The current tooltip timer. */
|
||||
private static int tooltipTimer = -1;
|
||||
|
||||
/** Duration, in milliseconds, to fade tooltips. */
|
||||
private static final int TOOLTIP_FADE_TIME = 200;
|
||||
/** The alpha level of the current tooltip (if any). */
|
||||
private static AnimatedValue tooltipAlpha = new AnimatedValue(200, 0f, 1f, AnimationEquation.LINEAR);
|
||||
|
||||
// game-related variables
|
||||
private static GameContainer container;
|
||||
|
@ -120,8 +118,7 @@ public class UI {
|
|||
cursor.update(delta);
|
||||
updateVolumeDisplay(delta);
|
||||
updateBarNotification(delta);
|
||||
if (tooltipTimer > 0)
|
||||
tooltipTimer -= delta;
|
||||
tooltipAlpha.update(-delta);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -363,12 +360,7 @@ public class UI {
|
|||
if (s != null) {
|
||||
tooltip = s;
|
||||
tooltipNewlines = newlines;
|
||||
if (tooltipTimer <= 0)
|
||||
tooltipTimer = delta;
|
||||
else
|
||||
tooltipTimer += delta * 2;
|
||||
if (tooltipTimer > TOOLTIP_FADE_TIME)
|
||||
tooltipTimer = TOOLTIP_FADE_TIME;
|
||||
tooltipAlpha.update(delta * 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -378,7 +370,7 @@ public class UI {
|
|||
* @param g the graphics context
|
||||
*/
|
||||
public static void drawTooltip(Graphics g) {
|
||||
if (tooltipTimer <= 0 || tooltip == null)
|
||||
if (tooltipAlpha.getTime() == 0 || tooltip == null)
|
||||
return;
|
||||
|
||||
int containerWidth = container.getWidth(), containerHeight = container.getHeight();
|
||||
|
@ -411,7 +403,7 @@ public class UI {
|
|||
y = margin;
|
||||
|
||||
// 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;
|
||||
Utils.COLOR_BLACK_ALPHA.a = alpha;
|
||||
g.setColor(Utils.COLOR_BLACK_ALPHA);
|
||||
|
@ -433,7 +425,7 @@ public class UI {
|
|||
* Resets the tooltip.
|
||||
*/
|
||||
public static void resetTooltip() {
|
||||
tooltipTimer = -1;
|
||||
tooltipAlpha.setTime(0);
|
||||
tooltip = null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user