use the new errorhandler & bubble notifs

This commit is contained in:
yugecin 2017-01-21 01:16:27 +01:00
parent aceebb95ca
commit f730935622
35 changed files with 199 additions and 147 deletions

View File

@ -27,7 +27,11 @@ import java.util.List;
import org.newdawn.slick.Animation; import org.newdawn.slick.Animation;
import org.newdawn.slick.Image; import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException; import org.newdawn.slick.SlickException;
import org.newdawn.slick.util.Log;
import org.newdawn.slick.util.ResourceLoader; import org.newdawn.slick.util.ResourceLoader;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.events.BubbleNotificationEvent;
import yugecin.opsudance.utils.SlickUtil; import yugecin.opsudance.utils.SlickUtil;
/** /**
@ -706,7 +710,9 @@ public enum GameImage {
return; return;
} }
ErrorHandler.error(String.format("Could not find default image '%s'.", filename), null, false); String err = String.format("Could not find default image '%s'.", filename);
Log.warn(err);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
/** /**
@ -765,7 +771,7 @@ public enum GameImage {
img = img.getScaledCopy(0.5f); img = img.getScaledCopy(0.5f);
list.add(img); list.add(img);
} catch (SlickException e) { } catch (SlickException e) {
ErrorHandler.error(String.format("Failed to set image '%s'.", name), null, false); EventBus.instance.post(new BubbleNotificationEvent(String.format("Failed to set image '%s'.", name), BubbleNotificationEvent.COMMONCOLOR_RED));
break; break;
} }
} }
@ -779,7 +785,7 @@ public enum GameImage {
img = img.getScaledCopy(0.5f); img = img.getScaledCopy(0.5f);
list.add(img); list.add(img);
} catch (SlickException e) { } catch (SlickException e) {
ErrorHandler.error(String.format("Failed to set image '%s'.", name), null, false); EventBus.instance.post(new BubbleNotificationEvent(String.format("Failed to set image '%s'.", name), BubbleNotificationEvent.COMMONCOLOR_RED));
break; break;
} }
} }
@ -806,7 +812,7 @@ public enum GameImage {
img = img.getScaledCopy(0.5f); img = img.getScaledCopy(0.5f);
return img; return img;
} catch (SlickException e) { } catch (SlickException e) {
ErrorHandler.error(String.format("Failed to set image '%s'.", filename), null, false); EventBus.instance.post(new BubbleNotificationEvent(String.format("Failed to set image '%s'.", filename), BubbleNotificationEvent.COMMONCOLOR_RED));
} }
} }
} }
@ -851,7 +857,7 @@ public enum GameImage {
skinImages = null; skinImages = null;
} }
} catch (SlickException e) { } catch (SlickException e) {
ErrorHandler.error(String.format("Failed to destroy beatmap skin images for '%s'.", this.name()), e, true); ErrorHandler.error(String.format("Failed to destroy beatmap skin images for '%s'.", this.name()), e).show();
} }
} }

View File

@ -60,6 +60,8 @@ import com.sun.jna.platform.win32.Win32Exception;
import com.sun.jna.platform.win32.WinReg; import com.sun.jna.platform.win32.WinReg;
import yugecin.opsudance.*; import yugecin.opsudance.*;
import yugecin.opsudance.core.DisplayContainer; import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.events.BubbleNotificationEvent; import yugecin.opsudance.events.BubbleNotificationEvent;
import yugecin.opsudance.movers.factories.ExgonMoverFactory; import yugecin.opsudance.movers.factories.ExgonMoverFactory;
import yugecin.opsudance.movers.factories.QuadraticBezierMoverFactory; import yugecin.opsudance.movers.factories.QuadraticBezierMoverFactory;
@ -197,7 +199,7 @@ public class Options {
} }
File dir = new File(rootPath, "opsu"); File dir = new File(rootPath, "opsu");
if (!dir.isDirectory() && !dir.mkdir()) if (!dir.isDirectory() && !dir.mkdir())
ErrorHandler.error(String.format("Failed to create configuration folder at '%s/opsu'.", rootPath), null, false); ErrorHandler.error(String.format("Failed to create configuration folder at '%s/opsu'.", rootPath), new Exception("empty")).preventReport().show();
return dir; return dir;
} else } else
return workingDir; return workingDir;
@ -1785,7 +1787,7 @@ public class Options {
// use default directory // use default directory
beatmapDir = BEATMAP_DIR; beatmapDir = BEATMAP_DIR;
if (!beatmapDir.isDirectory() && !beatmapDir.mkdir()) if (!beatmapDir.isDirectory() && !beatmapDir.mkdir())
ErrorHandler.error(String.format("Failed to create beatmap directory at '%s'.", beatmapDir.getAbsolutePath()), null, false); EventBus.instance.post(new BubbleNotificationEvent(String.format("Failed to create beatmap directory at '%s'.", beatmapDir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED));
return beatmapDir; return beatmapDir;
} }
@ -1800,7 +1802,7 @@ public class Options {
oszDir = new File(DATA_DIR, "SongPacks/"); oszDir = new File(DATA_DIR, "SongPacks/");
if (!oszDir.isDirectory() && !oszDir.mkdir()) if (!oszDir.isDirectory() && !oszDir.mkdir())
ErrorHandler.error(String.format("Failed to create song packs directory at '%s'.", oszDir.getAbsolutePath()), null, false); EventBus.instance.post(new BubbleNotificationEvent(String.format("Failed to create song packs directory at '%s'.", oszDir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED));
return oszDir; return oszDir;
} }
@ -1815,7 +1817,7 @@ public class Options {
replayImportDir = new File(DATA_DIR, "ReplayImport/"); replayImportDir = new File(DATA_DIR, "ReplayImport/");
if (!replayImportDir.isDirectory() && !replayImportDir.mkdir()) if (!replayImportDir.isDirectory() && !replayImportDir.mkdir())
ErrorHandler.error(String.format("Failed to create replay import directory at '%s'.", replayImportDir.getAbsolutePath()), null, false); EventBus.instance.post(new BubbleNotificationEvent(String.format("Failed to create replay import directory at '%s'.", replayImportDir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED));
return replayImportDir; return replayImportDir;
} }
@ -1865,7 +1867,7 @@ public class Options {
// use default directory // use default directory
skinRootDir = SKIN_ROOT_DIR; skinRootDir = SKIN_ROOT_DIR;
if (!skinRootDir.isDirectory() && !skinRootDir.mkdir()) if (!skinRootDir.isDirectory() && !skinRootDir.mkdir())
ErrorHandler.error(String.format("Failed to create skins directory at '%s'.", skinRootDir.getAbsolutePath()), null, false); EventBus.instance.post(new BubbleNotificationEvent(String.format("Failed to create skins directory at '%s'.", skinRootDir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED));
return skinRootDir; return skinRootDir;
} }
@ -1998,7 +2000,9 @@ public class Options {
} }
GameOption.DANCE_HIDE_WATERMARK.setValue(false); GameOption.DANCE_HIDE_WATERMARK.setValue(false);
} catch (IOException e) { } catch (IOException e) {
ErrorHandler.error(String.format("Failed to read file '%s'.", OPTIONS_FILE.getAbsolutePath()), e, false); String err = String.format("Failed to read file '%s'.", OPTIONS_FILE.getAbsolutePath());
Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
} }
@ -2027,7 +2031,9 @@ public class Options {
} }
writer.close(); writer.close();
} catch (IOException e) { } catch (IOException e) {
ErrorHandler.error(String.format("Failed to write to file '%s'.", OPTIONS_FILE.getAbsolutePath()), e, false); String err = String.format("Failed to write to file '%s'.", OPTIONS_FILE.getAbsolutePath());
Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
} }
} }

View File

@ -73,6 +73,9 @@ import org.newdawn.slick.util.Log;
import com.sun.jna.platform.FileUtils; import com.sun.jna.platform.FileUtils;
import yugecin.opsudance.core.DisplayContainer; import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.events.BubbleNotificationEvent;
/** /**
* Contains miscellaneous utilities. * Contains miscellaneous utilities.
@ -245,14 +248,14 @@ public class Utils {
// create the screenshot directory // create the screenshot directory
File dir = Options.getScreenshotDir(); File dir = Options.getScreenshotDir();
if (!dir.isDirectory() && !dir.mkdir()) { if (!dir.isDirectory() && !dir.mkdir()) {
ErrorHandler.error(String.format("Failed to create screenshot directory at '%s'.", dir.getAbsolutePath()), null, false); EventBus.instance.post(new BubbleNotificationEvent(String.format("Failed to create screenshot directory at '%s'.", dir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED));
return; return;
} }
// create file name // create file name
SimpleDateFormat date = new SimpleDateFormat("yyyyMMdd_HHmmss"); SimpleDateFormat date = new SimpleDateFormat("yyyyMMdd_HHmmss");
final File file = new File(dir, String.format("screenshot_%s.%s", final String fileName = String.format("screenshot_%s.%s", date.format(new Date()), Options.getScreenshotFormat());
date.format(new Date()), Options.getScreenshotFormat())); final File file = new File(dir, fileName);
SoundController.playSound(SoundEffect.SHUTTER); SoundController.playSound(SoundEffect.SHUTTER);
@ -279,8 +282,9 @@ public class Utils {
} }
} }
ImageIO.write(image, Options.getScreenshotFormat(), file); ImageIO.write(image, Options.getScreenshotFormat(), file);
EventBus.instance.post(new BubbleNotificationEvent("Created " + fileName, BubbleNotificationEvent.COMMONCOLOR_PURPLE));
} catch (Exception e) { } catch (Exception e) {
ErrorHandler.error("Failed to take a screenshot.", e, true); ErrorHandler.error("Failed to take a screenshot.", e).show();
} }
} }
}.start(); }.start();
@ -429,7 +433,7 @@ public class Utils {
try { try {
json = new JSONObject(s); json = new JSONObject(s);
} catch (JSONException e) { } catch (JSONException e) {
ErrorHandler.error("Failed to create JSON object.", e, true); ErrorHandler.error("Failed to create JSON object.", e).show();
} }
} }
return json; return json;
@ -448,7 +452,7 @@ public class Utils {
try { try {
json = new JSONArray(s); json = new JSONArray(s);
} catch (JSONException e) { } catch (JSONException e) {
ErrorHandler.error("Failed to create JSON array.", e, true); ErrorHandler.error("Failed to create JSON array.", e).show();
} }
} }
return json; return json;
@ -490,7 +494,7 @@ public class Utils {
result.append(String.format("%02x", b)); result.append(String.format("%02x", b));
return result.toString(); return result.toString();
} catch (NoSuchAlgorithmException | IOException e) { } catch (NoSuchAlgorithmException | IOException e) {
ErrorHandler.error("Failed to calculate MD5 hash.", e, true); ErrorHandler.error("Failed to calculate MD5 hash.", e).show();
} }
return null; return null;
} }
@ -514,7 +518,7 @@ public class Utils {
* @return true if JAR, false if file * @return true if JAR, false if file
*/ */
public static boolean isJarRunning() { public static boolean isJarRunning() {
return Opsu.class.getResource(String.format("%s.class", Opsu.class.getSimpleName())).toString().startsWith("jar:"); return Utils.class.getResource(String.format("%s.class", Utils.class.getSimpleName())).toString().startsWith("jar:");
} }
/** /**
@ -526,7 +530,7 @@ public class Utils {
return null; return null;
try { try {
return new JarFile(new File(Opsu.class.getProtectionDomain().getCodeSource().getLocation().toURI()), false); return new JarFile(new File(Utils.class.getProtectionDomain().getCodeSource().getLocation().toURI()), false);
} catch (URISyntaxException | IOException e) { } catch (URISyntaxException | IOException e) {
Log.error("Could not determine the JAR file.", e); Log.error("Could not determine the JAR file.", e);
return null; return null;
@ -539,7 +543,7 @@ public class Utils {
*/ */
public static File getRunningDirectory() { public static File getRunningDirectory() {
try { try {
return new File(Opsu.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()); return new File(Utils.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
Log.error("Could not get the running directory.", e); Log.error("Could not get the running directory.", e);
return null; return null;

View File

@ -1,6 +1,6 @@
package itdelatrisu.opsu.audio; package itdelatrisu.opsu.audio;
import itdelatrisu.opsu.ErrorHandler; import yugecin.opsudance.core.errorhandling.ErrorHandler;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator; import java.util.Iterator;
@ -194,7 +194,7 @@ public class MultiClip {
try { try {
audioIn.close(); audioIn.close();
} catch (IOException e) { } catch (IOException e) {
ErrorHandler.error(String.format("Could not close AudioInputStream for MultiClip %s.", name), e, true); ErrorHandler.error(String.format("Could not close AudioInputStream for MultiClip %s.", name), e).show();
} }
} }
} }

View File

@ -18,7 +18,6 @@
package itdelatrisu.opsu.audio; package itdelatrisu.opsu.audio;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.beatmap.Beatmap; import itdelatrisu.opsu.beatmap.Beatmap;
import itdelatrisu.opsu.beatmap.BeatmapParser; import itdelatrisu.opsu.beatmap.BeatmapParser;
@ -44,8 +43,12 @@ import org.newdawn.slick.MusicListener;
import org.newdawn.slick.SlickException; import org.newdawn.slick.SlickException;
import org.newdawn.slick.openal.Audio; import org.newdawn.slick.openal.Audio;
import org.newdawn.slick.openal.SoundStore; import org.newdawn.slick.openal.SoundStore;
import org.newdawn.slick.util.Log;
import org.newdawn.slick.util.ResourceLoader; import org.newdawn.slick.util.ResourceLoader;
import org.tritonus.share.sampled.file.TAudioFileFormat; import org.tritonus.share.sampled.file.TAudioFileFormat;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.events.BubbleNotificationEvent;
/** /**
* Controller for all music. * Controller for all music.
@ -152,7 +155,9 @@ public class MusicController {
}); });
playAt(position, loop); playAt(position, loop);
} catch (Exception e) { } catch (Exception e) {
ErrorHandler.error(String.format("Could not play track '%s'.", file.getName()), e, false); String err = String.format("Could not play track '%s'.", file.getName());
Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
} }
@ -496,9 +501,7 @@ public class MusicController {
trackLoader.interrupt(); trackLoader.interrupt();
try { try {
trackLoader.join(); trackLoader.join();
} catch (InterruptedException e) { } catch (InterruptedException ignored) { }
ErrorHandler.error(null, e, true);
}
} }
trackLoader = null; trackLoader = null;
@ -575,7 +578,7 @@ public class MusicController {
player = null; player = null;
} catch (Exception e) { } catch (Exception e) {
ErrorHandler.error("Failed to destroy OpenAL.", e, true); ErrorHandler.error("Failed to destroy OpenAL.", e).show();
} }
} }

View File

@ -18,7 +18,6 @@
package itdelatrisu.opsu.audio; package itdelatrisu.opsu.audio;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.audio.HitSound.SampleSet; import itdelatrisu.opsu.audio.HitSound.SampleSet;
import itdelatrisu.opsu.beatmap.HitObject; import itdelatrisu.opsu.beatmap.HitObject;
@ -41,6 +40,9 @@ import javax.sound.sampled.LineUnavailableException;
import org.newdawn.slick.SlickException; import org.newdawn.slick.SlickException;
import org.newdawn.slick.util.ResourceLoader; import org.newdawn.slick.util.ResourceLoader;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.events.BubbleNotificationEvent;
/** /**
* Controller for all (non-music) sound components. * Controller for all (non-music) sound components.
@ -99,7 +101,7 @@ public class SoundController {
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url); AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
return loadClip(ref, audioIn, isMP3); return loadClip(ref, audioIn, isMP3);
} catch (Exception e) { } catch (Exception e) {
ErrorHandler.error(String.format("Failed to load file '%s'.", ref), e, true); ErrorHandler.error(String.format("Failed to load file '%s'.", ref), e).show();
return null; return null;
} }
} }
@ -214,7 +216,7 @@ public class SoundController {
// menu and game sounds // menu and game sounds
for (SoundEffect s : SoundEffect.values()) { for (SoundEffect s : SoundEffect.values()) {
if ((currentFileName = getSoundFileName(s.getFileName())) == null) { if ((currentFileName = getSoundFileName(s.getFileName())) == null) {
ErrorHandler.error(String.format("Could not find sound file '%s'.", s.getFileName()), null, false); EventBus.instance.post(new BubbleNotificationEvent("Could not find sound file " + s.getFileName(), BubbleNotificationEvent.COLOR_ORANGE));
continue; continue;
} }
MultiClip newClip = loadClip(currentFileName, currentFileName.endsWith(".mp3")); MultiClip newClip = loadClip(currentFileName, currentFileName.endsWith(".mp3"));
@ -233,7 +235,7 @@ public class SoundController {
for (HitSound s : HitSound.values()) { for (HitSound s : HitSound.values()) {
String filename = String.format("%s-%s", ss.getName(), s.getFileName()); String filename = String.format("%s-%s", ss.getName(), s.getFileName());
if ((currentFileName = getSoundFileName(filename)) == null) { if ((currentFileName = getSoundFileName(filename)) == null) {
ErrorHandler.error(String.format("Could not find hit sound file '%s'.", filename), null, false); EventBus.instance.post(new BubbleNotificationEvent("Could not find hit sound file " + filename, BubbleNotificationEvent.COLOR_ORANGE));
continue; continue;
} }
MultiClip newClip = loadClip(currentFileName, false); MultiClip newClip = loadClip(currentFileName, false);
@ -277,7 +279,7 @@ public class SoundController {
try { try {
clip.start(volume, listener); clip.start(volume, listener);
} catch (LineUnavailableException e) { } catch (LineUnavailableException e) {
ErrorHandler.error(String.format("Could not start a clip '%s'.", clip.getName()), e, true); ErrorHandler.error(String.format("Could not start a clip '%s'.", clip.getName()), e).show();
} }
} }
} }

View File

@ -18,7 +18,6 @@
package itdelatrisu.opsu.beatmap; package itdelatrisu.opsu.beatmap;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.db.BeatmapDB; import itdelatrisu.opsu.db.BeatmapDB;
@ -35,6 +34,9 @@ import java.util.Map;
import org.newdawn.slick.Color; import org.newdawn.slick.Color;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.events.BubbleNotificationEvent;
/** /**
* Parser for beatmaps. * Parser for beatmaps.
@ -243,9 +245,11 @@ public class BeatmapParser {
} }
map.timingPoints.trimToSize(); map.timingPoints.trimToSize();
} catch (IOException e) { } catch (IOException e) {
ErrorHandler.error(String.format("Failed to read file '%s'.", map.getFile().getAbsolutePath()), e, false); String err = String.format("Failed to read file '%s'.", map.getFile().getAbsolutePath());
Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
ErrorHandler.error("Failed to get MD5 hash stream.", e, true); ErrorHandler.error("Failed to get MD5 hash stream.", e).show();
// retry without MD5 // retry without MD5
hasNoMD5Algorithm = true; hasNoMD5Algorithm = true;
@ -646,9 +650,11 @@ public class BeatmapParser {
if (md5stream != null) if (md5stream != null)
beatmap.md5Hash = md5stream.getMD5(); beatmap.md5Hash = md5stream.getMD5();
} catch (IOException e) { } catch (IOException e) {
ErrorHandler.error(String.format("Failed to read file '%s'.", file.getAbsolutePath()), e, false); String err = String.format("Failed to read file '%s'.", file.getAbsolutePath());
Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
ErrorHandler.error("Failed to get MD5 hash stream.", e, true); ErrorHandler.error("Failed to get MD5 hash stream.", e).show();
// retry without MD5 // retry without MD5
hasNoMD5Algorithm = true; hasNoMD5Algorithm = true;
@ -727,7 +733,9 @@ public class BeatmapParser {
} }
beatmap.timingPoints.trimToSize(); beatmap.timingPoints.trimToSize();
} catch (IOException e) { } catch (IOException e) {
ErrorHandler.error(String.format("Failed to read file '%s'.", beatmap.getFile().getAbsolutePath()), e, false); String err = String.format("Failed to read file '%s'.", beatmap.getFile().getAbsolutePath());
Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
} }
@ -803,9 +811,11 @@ public class BeatmapParser {
// check that all objects were parsed // check that all objects were parsed
if (objectIndex != beatmap.objects.length) if (objectIndex != beatmap.objects.length)
ErrorHandler.error(String.format("Parsed %d objects for beatmap '%s', %d objects expected.", ErrorHandler.error(String.format("Parsed %d objects for beatmap '%s', %d objects expected.",
objectIndex, beatmap.toString(), beatmap.objects.length), null, true); objectIndex, beatmap.toString(), beatmap.objects.length), new Exception("no")).show();
} catch (IOException e) { } catch (IOException e) {
ErrorHandler.error(String.format("Failed to read file '%s'.", beatmap.getFile().getAbsolutePath()), e, false); String err = String.format("Failed to read file '%s'.", beatmap.getFile().getAbsolutePath());
Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
} }

View File

@ -18,11 +18,12 @@
package itdelatrisu.opsu.beatmap; package itdelatrisu.opsu.beatmap;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController; import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.db.BeatmapDB; import itdelatrisu.opsu.db.BeatmapDB;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.events.BubbleNotificationEvent;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -215,7 +216,7 @@ public class BeatmapSetList {
try { try {
Utils.deleteToTrash(dir); Utils.deleteToTrash(dir);
} catch (IOException e) { } catch (IOException e) {
ErrorHandler.error("Could not delete song group.", e, true); EventBus.instance.post(new BubbleNotificationEvent("Could not delete song group", BubbleNotificationEvent.COLOR_ORANGE));
} }
if (ws != null) if (ws != null)
ws.resume(); ws.resume();
@ -270,7 +271,7 @@ public class BeatmapSetList {
try { try {
Utils.deleteToTrash(file); Utils.deleteToTrash(file);
} catch (IOException e) { } catch (IOException e) {
ErrorHandler.error("Could not delete song.", e, true); EventBus.instance.post(new BubbleNotificationEvent("Could not delete song", BubbleNotificationEvent.COLOR_ORANGE));
} }
if (ws != null) if (ws != null)
ws.resume(); ws.resume();

View File

@ -18,7 +18,6 @@
package itdelatrisu.opsu.beatmap; package itdelatrisu.opsu.beatmap;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import java.io.IOException; import java.io.IOException;
@ -42,6 +41,8 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.events.BubbleNotificationEvent;
/* /*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
@ -96,7 +97,8 @@ public class BeatmapWatchService {
ws = new BeatmapWatchService(); ws = new BeatmapWatchService();
ws.register(Options.getBeatmapDir().toPath()); ws.register(Options.getBeatmapDir().toPath());
} catch (IOException e) { } catch (IOException e) {
ErrorHandler.error("An I/O exception occurred while creating the watch service.", e, true); Log.error("Could not create watch service", e);
EventBus.instance.post(new BubbleNotificationEvent("Could not create watch service", BubbleNotificationEvent.COMMONCOLOR_RED));
return; return;
} }
@ -117,8 +119,9 @@ public class BeatmapWatchService {
ws.service.shutdownNow(); ws.service.shutdownNow();
ws = null; ws = null;
} catch (IOException e) { } catch (IOException e) {
Log.error("An I/O exception occurred while closing the previous watch service.", e);
EventBus.instance.post(new BubbleNotificationEvent("An I/O exception occurred while closing the previous watch service.", BubbleNotificationEvent.COMMONCOLOR_RED));
ws = null; ws = null;
ErrorHandler.error("An I/O exception occurred while closing the previous watch service.", e, true);
} }
} }

View File

@ -18,7 +18,6 @@
package itdelatrisu.opsu.beatmap; package itdelatrisu.opsu.beatmap;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import java.io.File; import java.io.File;
@ -28,6 +27,9 @@ import java.util.List;
import net.lingala.zip4j.core.ZipFile; import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException; import net.lingala.zip4j.exception.ZipException;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.events.BubbleNotificationEvent;
/** /**
* Unpacker for OSZ (ZIP) archives. * Unpacker for OSZ (ZIP) archives.
@ -97,8 +99,9 @@ public class OszUnpacker {
ZipFile zipFile = new ZipFile(file); ZipFile zipFile = new ZipFile(file);
zipFile.extractAll(dest.getAbsolutePath()); zipFile.extractAll(dest.getAbsolutePath());
} catch (ZipException e) { } catch (ZipException e) {
ErrorHandler.error(String.format("Failed to unzip file %s to dest %s.", String err = String.format("Failed to unzip file %s to dest %s.", file.getAbsolutePath(), dest.getAbsolutePath());
file.getAbsolutePath(), dest.getAbsolutePath()), e, false); Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
} }

View File

@ -18,7 +18,6 @@
package itdelatrisu.opsu.db; package itdelatrisu.opsu.db;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.beatmap.Beatmap; import itdelatrisu.opsu.beatmap.Beatmap;
import itdelatrisu.opsu.beatmap.BeatmapParser; import itdelatrisu.opsu.beatmap.BeatmapParser;
@ -35,6 +34,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
/** /**
* Handles connections and queries with the cached beatmap database. * Handles connections and queries with the cached beatmap database.
@ -110,7 +110,7 @@ public class BeatmapDB {
try { try {
updateSizeStmt = connection.prepareStatement("REPLACE INTO info (key, value) VALUES ('size', ?)"); updateSizeStmt = connection.prepareStatement("REPLACE INTO info (key, value) VALUES ('size', ?)");
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to prepare beatmap statements.", e, true); ErrorHandler.error("Failed to prepare beatmap statements.", e).show();
} }
// retrieve the cache size // retrieve the cache size
@ -132,7 +132,7 @@ public class BeatmapDB {
updatePlayStatsStmt = connection.prepareStatement("UPDATE beatmaps SET playCount = ?, lastPlayed = ? WHERE dir = ? AND file = ?"); updatePlayStatsStmt = connection.prepareStatement("UPDATE beatmaps SET playCount = ?, lastPlayed = ? WHERE dir = ? AND file = ?");
setFavoriteStmt = connection.prepareStatement("UPDATE beatmaps SET favorite = ? WHERE dir = ? AND file = ?"); setFavoriteStmt = connection.prepareStatement("UPDATE beatmaps SET favorite = ? WHERE dir = ? AND file = ?");
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to prepare beatmap statements.", e, true); ErrorHandler.error("Failed to prepare beatmap statements.", e).show();
} }
} }
@ -170,7 +170,7 @@ public class BeatmapDB {
sql = String.format("INSERT OR IGNORE INTO info(key, value) VALUES('version', '%s')", DATABASE_VERSION); sql = String.format("INSERT OR IGNORE INTO info(key, value) VALUES('version', '%s')", DATABASE_VERSION);
stmt.executeUpdate(sql); stmt.executeUpdate(sql);
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Could not create beatmap database.", e, true); ErrorHandler.error("Coudl not create beatmap database.", e).show();
} }
} }
@ -222,7 +222,7 @@ public class BeatmapDB {
ps.close(); ps.close();
} }
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to update beatmap database.", e, true); ErrorHandler.error("Failed to update beatmap database.", e).show();
} }
} }
@ -240,7 +240,7 @@ public class BeatmapDB {
} }
rs.close(); rs.close();
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Could not get beatmap cache size.", e, true); ErrorHandler.error("Could not get beatmap cache size.", e).show();
} }
} }
@ -255,7 +255,7 @@ public class BeatmapDB {
updateSizeStmt.setString(1, Integer.toString(Math.max(cacheSize, 0))); updateSizeStmt.setString(1, Integer.toString(Math.max(cacheSize, 0)));
updateSizeStmt.executeUpdate(); updateSizeStmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Could not update beatmap cache size.", e, true); ErrorHandler.error("Could not update beatmap cache size.", e).show();
} }
} }
@ -273,7 +273,7 @@ public class BeatmapDB {
cacheSize = 0; cacheSize = 0;
updateCacheSize(); updateCacheSize();
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Could not drop beatmap database.", e, true); ErrorHandler.error("Could not drop beatmap database.", e).show();
} }
createDatabase(); createDatabase();
} }
@ -291,7 +291,7 @@ public class BeatmapDB {
cacheSize += insertStmt.executeUpdate(); cacheSize += insertStmt.executeUpdate();
updateCacheSize(); updateCacheSize();
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to add beatmap to database.", e, true); ErrorHandler.error("Failed to add beatmap to database.", e).show();
} }
} }
@ -344,7 +344,7 @@ public class BeatmapDB {
// update cache size // update cache size
updateCacheSize(); updateCacheSize();
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to add beatmaps to database.", e, true); ErrorHandler.error("Failed to add beatmaps to database.", e).show();
} }
} }
@ -432,7 +432,7 @@ public class BeatmapDB {
} }
rs.close(); rs.close();
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to load Beatmap from database.", e, true); ErrorHandler.error("Failed to load Beatmap from database.", e).show();
} }
} }
@ -495,7 +495,7 @@ public class BeatmapDB {
} }
rs.close(); rs.close();
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to load beatmaps from database.", e, true); ErrorHandler.error("Failed to load beatmaps from database.", e).show();
} }
} }
@ -596,7 +596,7 @@ public class BeatmapDB {
rs.close(); rs.close();
return map; return map;
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to get last modified map from database.", e, true); ErrorHandler.error("Failed to get last modified map from database.", e).show();
return null; return null;
} }
} }
@ -616,7 +616,7 @@ public class BeatmapDB {
cacheSize -= deleteMapStmt.executeUpdate(); cacheSize -= deleteMapStmt.executeUpdate();
updateCacheSize(); updateCacheSize();
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to delete beatmap entry from database.", e, true); ErrorHandler.error("Failed to delete beatmap entry from database.", e).show();
} }
} }
@ -633,7 +633,7 @@ public class BeatmapDB {
cacheSize -= deleteGroupStmt.executeUpdate(); cacheSize -= deleteGroupStmt.executeUpdate();
updateCacheSize(); updateCacheSize();
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to delete beatmap group entry from database.", e, true); ErrorHandler.error("Failed to delete beatmap group entry from database.", e).show();
} }
} }
@ -652,7 +652,7 @@ public class BeatmapDB {
setStarsStmt.executeUpdate(); setStarsStmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error(String.format("Failed to save star rating '%.4f' for beatmap '%s' in database.", ErrorHandler.error(String.format("Failed to save star rating '%.4f' for beatmap '%s' in database.",
beatmap.starRating, beatmap.toString()), e, true); beatmap.starRating, beatmap.toString()), e).show();
} }
} }
@ -672,7 +672,7 @@ public class BeatmapDB {
updatePlayStatsStmt.executeUpdate(); updatePlayStatsStmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error(String.format("Failed to update play statistics for beatmap '%s' in database.", ErrorHandler.error(String.format("Failed to update play statistics for beatmap '%s' in database.",
beatmap.toString()), e, true); beatmap.toString()), e).show();
} }
} }
@ -691,7 +691,7 @@ public class BeatmapDB {
setFavoriteStmt.executeUpdate(); setFavoriteStmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error(String.format("Failed to update favorite status for beatmap '%s' in database.", ErrorHandler.error(String.format("Failed to update favorite status for beatmap '%s' in database.",
beatmap.toString()), e, true); beatmap.toString()), e).show();
} }
} }
@ -711,7 +711,7 @@ public class BeatmapDB {
connection.close(); connection.close();
connection = null; connection = null;
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to close beatmap database.", e, true); ErrorHandler.error("Failed to close beatmap database.", e).show();
} }
} }
} }

View File

@ -18,7 +18,7 @@
package itdelatrisu.opsu.db; package itdelatrisu.opsu.db;
import itdelatrisu.opsu.ErrorHandler; import yugecin.opsudance.core.errorhandling.ErrorHandler;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
@ -39,7 +39,7 @@ public class DBController {
try { try {
Class.forName("org.sqlite.JDBC"); Class.forName("org.sqlite.JDBC");
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
ErrorHandler.error("Could not load sqlite-JDBC driver.", e, true); ErrorHandler.error("Could not load sqlite-JDBC driver.", e).show();
} }
// initialize the databases // initialize the databases
@ -65,7 +65,7 @@ public class DBController {
return DriverManager.getConnection(String.format("jdbc:sqlite:%s", path)); return DriverManager.getConnection(String.format("jdbc:sqlite:%s", path));
} catch (SQLException e) { } catch (SQLException e) {
// if the error message is "out of memory", it probably means no database file is found // if the error message is "out of memory", it probably means no database file is found
ErrorHandler.error(String.format("Could not connect to database: '%s'.", path), e, true); ErrorHandler.error(String.format("Could not connect to database: '%s'.", path), e).show();
return null; return null;
} }
} }

View File

@ -18,10 +18,10 @@
package itdelatrisu.opsu.db; package itdelatrisu.opsu.db;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.ScoreData; import itdelatrisu.opsu.ScoreData;
import itdelatrisu.opsu.beatmap.Beatmap; import itdelatrisu.opsu.beatmap.Beatmap;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -124,7 +124,7 @@ public class ScoreDB {
// TODO: extra playerName checks not needed if name is guaranteed not null // TODO: extra playerName checks not needed if name is guaranteed not null
); );
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to prepare score statements.", e, true); ErrorHandler.error("Failed to prepare score statements.", e).show();
} }
} }
@ -157,7 +157,7 @@ public class ScoreDB {
sql = String.format("INSERT OR IGNORE INTO info(key, value) VALUES('version', %d)", DATABASE_VERSION); sql = String.format("INSERT OR IGNORE INTO info(key, value) VALUES('version', %d)", DATABASE_VERSION);
stmt.executeUpdate(sql); stmt.executeUpdate(sql);
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Could not create score database.", e, true); ErrorHandler.error("Could not create score database.", e).show();
} }
} }
@ -209,7 +209,7 @@ public class ScoreDB {
ps.close(); ps.close();
} }
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to update score database.", e, true); ErrorHandler.error("Failed to update score database.", e).show();
} }
} }
@ -227,7 +227,7 @@ public class ScoreDB {
insertStmt.setString(19, data.playerName); insertStmt.setString(19, data.playerName);
insertStmt.executeUpdate(); insertStmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to save score to database.", e, true); ErrorHandler.error("Failed to save score to database.", e).show();
} }
} }
@ -247,7 +247,7 @@ public class ScoreDB {
deleteScoreStmt.setString(21, data.playerName); deleteScoreStmt.setString(21, data.playerName);
deleteScoreStmt.executeUpdate(); deleteScoreStmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to delete score from database.", e, true); ErrorHandler.error("Failed to delete score from database.", e).show();
} }
} }
@ -267,7 +267,7 @@ public class ScoreDB {
deleteSongStmt.setString(5, beatmap.version); deleteSongStmt.setString(5, beatmap.version);
deleteSongStmt.executeUpdate(); deleteSongStmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to delete scores from database.", e, true); ErrorHandler.error("Failed to delete scores from database.", e).show();
} }
} }
@ -335,7 +335,7 @@ public class ScoreDB {
} }
rs.close(); rs.close();
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to read scores from database.", e, true); ErrorHandler.error("Failed to read scores from database.", e).show();
return null; return null;
} }
return getSortedArray(list); return getSortedArray(list);
@ -377,7 +377,7 @@ public class ScoreDB {
map.put(version, getSortedArray(list)); map.put(version, getSortedArray(list));
rs.close(); rs.close();
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to read scores from database.", e, true); ErrorHandler.error("Failed to read scores from database.", e).show();
return null; return null;
} }
return map; return map;
@ -406,7 +406,7 @@ public class ScoreDB {
connection.close(); connection.close();
connection = null; connection = null;
} catch (SQLException e) { } catch (SQLException e) {
ErrorHandler.error("Failed to close score database.", e, true); ErrorHandler.error("Failed to close score database.", e).show();
} }
} }
} }

View File

@ -18,7 +18,6 @@
package itdelatrisu.opsu.downloads; package itdelatrisu.opsu.downloads;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import java.io.File; import java.io.File;
@ -35,6 +34,9 @@ import java.nio.file.Path;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.events.BubbleNotificationEvent;
/** /**
* File download. * File download.
@ -142,7 +144,7 @@ public class Download {
this.url = new URL(remoteURL); this.url = new URL(remoteURL);
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
this.status = Status.ERROR; this.status = Status.ERROR;
ErrorHandler.error(String.format("Bad download URL: '%s'", remoteURL), e, true); ErrorHandler.error(String.format("Bad download URL: '%s'", remoteURL), e).show();
return; return;
} }
this.localPath = localPath; this.localPath = localPath;
@ -215,7 +217,7 @@ public class Download {
else if (redirectCount > MAX_REDIRECTS) else if (redirectCount > MAX_REDIRECTS)
error = String.format("Download for URL '%s' is attempting too many redirects (over %d).", base.toString(), MAX_REDIRECTS); error = String.format("Download for URL '%s' is attempting too many redirects (over %d).", base.toString(), MAX_REDIRECTS);
if (error != null) { if (error != null) {
ErrorHandler.error(error, null, false); EventBus.instance.post(new BubbleNotificationEvent(error, BubbleNotificationEvent.COLOR_ORANGE));
throw new IOException(); throw new IOException();
} }
@ -417,7 +419,7 @@ public class Download {
} }
} catch (IOException e) { } catch (IOException e) {
this.status = Status.ERROR; this.status = Status.ERROR;
ErrorHandler.error("Failed to cancel download.", e, true); ErrorHandler.error("Failed to cancel download.", e).show();
} }
} }
} }

View File

@ -18,7 +18,6 @@
package itdelatrisu.opsu.downloads; package itdelatrisu.opsu.downloads;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.GameImage; import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
@ -35,6 +34,8 @@ import java.io.File;
import org.newdawn.slick.Color; import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics; import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image; import org.newdawn.slick.Image;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.events.BubbleNotificationEvent;
/** /**
* Node containing song data and a Download object. * Node containing song data and a Download object.
@ -402,7 +403,7 @@ public class DownloadNode {
public void drawDownload(Graphics g, float position, int id, boolean hover) { public void drawDownload(Graphics g, float position, int id, boolean hover) {
Download download = this.download; // in case clearDownload() is called asynchronously Download download = this.download; // in case clearDownload() is called asynchronously
if (download == null) { if (download == null) {
ErrorHandler.error("Trying to draw download information for button without Download object.", null, false); EventBus.instance.post(new BubbleNotificationEvent("Trying to draw download information for button without Download object", BubbleNotificationEvent.COLOR_ORANGE));
return; return;
} }

View File

@ -18,7 +18,6 @@
package itdelatrisu.opsu.downloads; package itdelatrisu.opsu.downloads;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.downloads.Download.DownloadListener; import itdelatrisu.opsu.downloads.Download.DownloadListener;
@ -38,6 +37,7 @@ import java.util.Properties;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
import org.newdawn.slick.util.ResourceLoader; import org.newdawn.slick.util.ResourceLoader;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
/** /**
* Handles automatic program updates. * Handles automatic program updates.
@ -298,7 +298,7 @@ public class Updater {
pb.start(); pb.start();
} catch (IOException e) { } catch (IOException e) {
status = Status.INTERNAL_ERROR; status = Status.INTERNAL_ERROR;
ErrorHandler.error("Failed to start new process.", e, true); ErrorHandler.error("Failed to start new process.", e).show();
} }
} }
} }

View File

@ -18,7 +18,6 @@
package itdelatrisu.opsu.downloads.servers; package itdelatrisu.opsu.downloads.servers;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.downloads.DownloadNode; import itdelatrisu.opsu.downloads.DownloadNode;
@ -34,6 +33,7 @@ import java.util.Date;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
/** /**
* Download server: http://bloodcat.com/osu/ * Download server: http://bloodcat.com/osu/
@ -97,7 +97,7 @@ public class BloodcatServer extends DownloadServer {
resultCount++; resultCount++;
this.totalResults = resultCount; this.totalResults = resultCount;
} catch (MalformedURLException | UnsupportedEncodingException e) { } catch (MalformedURLException | UnsupportedEncodingException e) {
ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e, true); ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e).show();
} }
return nodes; return nodes;
} }

View File

@ -18,7 +18,6 @@
package itdelatrisu.opsu.downloads.servers; package itdelatrisu.opsu.downloads.servers;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.downloads.DownloadNode; import itdelatrisu.opsu.downloads.DownloadNode;
@ -30,6 +29,7 @@ import java.net.URLEncoder;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
/** /**
* Download server: https://osu.hexide.com/ * Download server: https://osu.hexide.com/
@ -128,7 +128,7 @@ public class HexideServer extends DownloadServer {
// all results at once; this approach just gets pagination correct. // all results at once; this approach just gets pagination correct.
this.totalResults = arr.length() + resultIndex; this.totalResults = arr.length() + resultIndex;
} catch (MalformedURLException | UnsupportedEncodingException e) { } catch (MalformedURLException | UnsupportedEncodingException e) {
ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e, true); ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e).show();
} }
return nodes; return nodes;
} }

View File

@ -18,7 +18,6 @@
package itdelatrisu.opsu.downloads.servers; package itdelatrisu.opsu.downloads.servers;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.downloads.DownloadNode; import itdelatrisu.opsu.downloads.DownloadNode;
@ -30,6 +29,7 @@ import java.net.URLEncoder;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
/** /**
* Download server: http://osu.mengsky.net/ * Download server: http://osu.mengsky.net/
@ -101,7 +101,7 @@ public class MengSkyServer extends DownloadServer {
resultCount = 1 + (pageTotal - 1) * PAGE_LIMIT; resultCount = 1 + (pageTotal - 1) * PAGE_LIMIT;
this.totalResults = resultCount; this.totalResults = resultCount;
} catch (MalformedURLException | UnsupportedEncodingException e) { } catch (MalformedURLException | UnsupportedEncodingException e) {
ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e, true); ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e).show();
} }
return nodes; return nodes;
} }

View File

@ -18,9 +18,9 @@
package itdelatrisu.opsu.downloads.servers; package itdelatrisu.opsu.downloads.servers;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.downloads.DownloadNode; import itdelatrisu.opsu.downloads.DownloadNode;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
@ -120,7 +120,7 @@ public class MnetworkServer extends DownloadServer {
// store total result count // store total result count
this.totalResults = nodes.length; this.totalResults = nodes.length;
} catch (MalformedURLException | UnsupportedEncodingException e) { } catch (MalformedURLException | UnsupportedEncodingException e) {
ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e, true); ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e).show();
} }
return nodes; return nodes;
} }

View File

@ -18,7 +18,6 @@
package itdelatrisu.opsu.downloads.servers; package itdelatrisu.opsu.downloads.servers;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.downloads.DownloadNode; import itdelatrisu.opsu.downloads.DownloadNode;
@ -36,6 +35,7 @@ import java.util.TimeZone;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
/** /**
* Download server: http://loli.al/ * Download server: http://loli.al/
@ -123,7 +123,7 @@ public class OsuMirrorServer extends DownloadServer {
else else
this.totalResults = maxServerID; this.totalResults = maxServerID;
} catch (MalformedURLException | UnsupportedEncodingException e) { } catch (MalformedURLException | UnsupportedEncodingException e) {
ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e, true); ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e).show();
} }
return nodes; return nodes;
} }

View File

@ -17,7 +17,6 @@
*/ */
package itdelatrisu.opsu.downloads.servers; package itdelatrisu.opsu.downloads.servers;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.downloads.DownloadNode; import itdelatrisu.opsu.downloads.DownloadNode;
@ -34,6 +33,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import org.json.JSONObject; import org.json.JSONObject;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
/** /**
* Download server: http://osu.yas-online.net/ * Download server: http://osu.yas-online.net/
@ -114,7 +114,7 @@ public class YaSOnlineServer extends DownloadServer {
String downloadLink = item.getString("downloadLink"); String downloadLink = item.getString("downloadLink");
return String.format(DOWNLOAD_FETCH_URL, downloadLink); return String.format(DOWNLOAD_FETCH_URL, downloadLink);
} catch (MalformedURLException | UnsupportedEncodingException e) { } catch (MalformedURLException | UnsupportedEncodingException e) {
ErrorHandler.error(String.format("Problem retrieving download URL for beatmap '%d'.", beatmapSetID), e, true); ErrorHandler.error(String.format("Problem retrieving download URL for beatmap '%d'.", beatmapSetID), e).show();
return null; return null;
} finally { } finally {
Utils.setSSLCertValidation(true); Utils.setSSLCertValidation(true);
@ -186,7 +186,7 @@ public class YaSOnlineServer extends DownloadServer {
else else
this.totalResults = maxServerID; this.totalResults = maxServerID;
} catch (MalformedURLException | UnsupportedEncodingException e) { } catch (MalformedURLException | UnsupportedEncodingException e) {
ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e, true); ErrorHandler.error(String.format("Problem loading result list for query '%s'.", query), e).show();
} finally { } finally {
Utils.setSSLCertValidation(true); Utils.setSSLCertValidation(true);
} }

View File

@ -96,7 +96,7 @@ public class CurveRenderState {
*/ */
public static void shutdown() { public static void shutdown() {
staticState.shutdown(); staticState.shutdown();
FrameBufferCache.shutdown(); //FrameBufferCache.shutdown();
} }
/** /**

View File

@ -128,6 +128,7 @@ public class FrameBufferCache {
* <p> * <p>
* This is necessary for cases when the game gets restarted with a * This is necessary for cases when the game gets restarted with a
* different resolution without closing the process. * different resolution without closing the process.
* // TODO d do we still need this
*/ */
public static void shutdown() { public static void shutdown() {
FrameBufferCache fbcInstance = FrameBufferCache.getInstance(); FrameBufferCache fbcInstance = FrameBufferCache.getInstance();

View File

@ -18,7 +18,6 @@
package itdelatrisu.opsu.replay; package itdelatrisu.opsu.replay;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.ScoreData; import itdelatrisu.opsu.ScoreData;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
@ -45,6 +44,9 @@ import org.apache.commons.compress.compressors.lzma.LZMACompressorInputStream;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
import lzma.streams.LzmaOutputStream; import lzma.streams.LzmaOutputStream;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.events.BubbleNotificationEvent;
/** /**
* Captures osu! replay data. * Captures osu! replay data.
@ -273,7 +275,7 @@ public class Replay {
File dir = Options.getReplayDir(); File dir = Options.getReplayDir();
if (!dir.isDirectory()) { if (!dir.isDirectory()) {
if (!dir.mkdir()) { if (!dir.mkdir()) {
ErrorHandler.error("Failed to create replay directory.", null, false); EventBus.instance.post(new BubbleNotificationEvent("Failed to create replay directory.", BubbleNotificationEvent.COMMONCOLOR_RED));
return; return;
} }
} }
@ -343,7 +345,7 @@ public class Replay {
compressedOut.write(bytes); compressedOut.write(bytes);
} catch (IOException e) { } catch (IOException e) {
// possible OOM: https://github.com/jponge/lzma-java/issues/9 // possible OOM: https://github.com/jponge/lzma-java/issues/9
ErrorHandler.error("LZMA compression failed (possible out-of-memory error).", e, true); ErrorHandler.error("LZMA compression failed (possible out-of-memory error).", e).show();
} }
compressedOut.close(); compressedOut.close();
bout.close(); bout.close();
@ -357,7 +359,7 @@ public class Replay {
writer.close(); writer.close();
} catch (IOException e) { } catch (IOException e) {
ErrorHandler.error("Could not save replay data.", e, true); ErrorHandler.error("Could not save replay data.", e).show();
} }
} }
}.start(); }.start();

View File

@ -18,7 +18,7 @@
package itdelatrisu.opsu.replay; package itdelatrisu.opsu.replay;
import itdelatrisu.opsu.ErrorHandler; import com.sun.deploy.security.EnhancedJarVerifier;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.beatmap.Beatmap; import itdelatrisu.opsu.beatmap.Beatmap;
import itdelatrisu.opsu.beatmap.BeatmapSetList; import itdelatrisu.opsu.beatmap.BeatmapSetList;
@ -31,6 +31,8 @@ import java.nio.file.Files;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.events.BubbleNotificationEvent;
/** /**
* Importer for replay files. * Importer for replay files.
@ -70,7 +72,9 @@ public class ReplayImporter {
File replayDir = Options.getReplayDir(); File replayDir = Options.getReplayDir();
if (!replayDir.isDirectory()) { if (!replayDir.isDirectory()) {
if (!replayDir.mkdir()) { if (!replayDir.mkdir()) {
ErrorHandler.error(String.format("Failed to create replay directory '%s'.", replayDir.getAbsolutePath()), null, false); String err = String.format("Failed to create replay directory '%s'.", replayDir.getAbsolutePath());
Log.error(err);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
return; return;
} }
} }
@ -83,7 +87,9 @@ public class ReplayImporter {
r.loadHeader(); r.loadHeader();
} catch (IOException e) { } catch (IOException e) {
moveToFailedDirectory(file); moveToFailedDirectory(file);
ErrorHandler.error(String.format("Failed to import replay '%s'. The replay file could not be parsed.", file.getName()), e, false); String err = String.format("Failed to import replay '%s'. The replay file could not be parsed.", file.getName());
Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
continue; continue;
} }
Beatmap beatmap = BeatmapSetList.get().getBeatmapFromHash(r.beatmapHash); Beatmap beatmap = BeatmapSetList.get().getBeatmapFromHash(r.beatmapHash);
@ -100,8 +106,9 @@ public class ReplayImporter {
} }
} else { } else {
moveToFailedDirectory(file); moveToFailedDirectory(file);
ErrorHandler.error(String.format("Failed to import replay '%s'. The associated beatmap could not be found.", file.getName()), null, false); String err = String.format("Failed to import replay '%s'. The associated beatmap could not be found.", file.getName());
continue; Log.error(err);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
} }

View File

@ -18,7 +18,6 @@
package itdelatrisu.opsu.skins; package itdelatrisu.opsu.skins;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.GameImage; import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
@ -32,6 +31,8 @@ import java.util.LinkedList;
import org.newdawn.slick.Color; import org.newdawn.slick.Color;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.events.BubbleNotificationEvent;
/** /**
* Loads skin configuration files. * Loads skin configuration files.
@ -290,7 +291,9 @@ public class SkinLoader {
} }
} }
} catch (IOException e) { } catch (IOException e) {
ErrorHandler.error(String.format("Failed to read file '%s'.", skinFile.getAbsolutePath()), e, false); String err = String.format("Failed to read file '%s'.", skinFile.getAbsolutePath());
Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
return skin; return skin;

View File

@ -19,7 +19,6 @@
package itdelatrisu.opsu.states; package itdelatrisu.opsu.states;
import itdelatrisu.opsu.GameImage; import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController; import itdelatrisu.opsu.audio.MusicController;

View File

@ -18,7 +18,6 @@
package itdelatrisu.opsu.states; package itdelatrisu.opsu.states;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.GameImage; import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
@ -46,10 +45,13 @@ import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics; import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image; import org.newdawn.slick.Image;
import org.newdawn.slick.Input; import org.newdawn.slick.Input;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.DisplayContainer; import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.core.inject.InstanceContainer; import yugecin.opsudance.core.inject.InstanceContainer;
import yugecin.opsudance.core.state.BaseOpsuState; import yugecin.opsudance.core.state.BaseOpsuState;
import yugecin.opsudance.core.state.OpsuState; import yugecin.opsudance.core.state.OpsuState;
import yugecin.opsudance.events.BubbleNotificationEvent;
/** /**
* "Main Menu" state. * "Main Menu" state.
@ -570,7 +572,8 @@ public class MainMenu extends BaseOpsuState {
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
UI.sendBarNotification("The repository web page could not be opened."); UI.sendBarNotification("The repository web page could not be opened.");
} catch (IOException e) { } catch (IOException e) {
ErrorHandler.error("Could not browse to repository URI.", e, false); Log.error("could not browse to repo", e);
displayContainer.eventBus.post(new BubbleNotificationEvent("Could not browse to repo", BubbleNotificationEvent.COLOR_ORANGE));
} }
return true; return true;
} }
@ -581,7 +584,8 @@ public class MainMenu extends BaseOpsuState {
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
UI.sendBarNotification("The repository web page could not be opened."); UI.sendBarNotification("The repository web page could not be opened.");
} catch (IOException e) { } catch (IOException e) {
ErrorHandler.error("Could not browse to repository URI.", e, false); Log.error("could not browse to repo", e);
displayContainer.eventBus.post(new BubbleNotificationEvent("Could not browse to repo", BubbleNotificationEvent.COLOR_ORANGE));
} }
return true; return true;
} }

View File

@ -18,9 +18,7 @@
package itdelatrisu.opsu.ui; package itdelatrisu.opsu.ui;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.GameImage; import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController; import itdelatrisu.opsu.audio.MusicController;
@ -37,6 +35,7 @@ import org.newdawn.slick.*;
import org.newdawn.slick.state.StateBasedGame; import org.newdawn.slick.state.StateBasedGame;
import yugecin.opsudance.Dancer; import yugecin.opsudance.Dancer;
import yugecin.opsudance.core.DisplayContainer; import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
/** /**
* Updates and draws the cursor. * Updates and draws the cursor.
@ -91,7 +90,7 @@ public class Cursor {
IntBuffer tmp = BufferUtils.createIntBuffer(min * min); IntBuffer tmp = BufferUtils.createIntBuffer(min * min);
emptyCursor = new org.lwjgl.input.Cursor(min, min, min/2, min/2, 1, tmp, null); emptyCursor = new org.lwjgl.input.Cursor(min, min, min/2, min/2, 1, tmp, null);
} catch (LWJGLException e) { } catch (LWJGLException e) {
ErrorHandler.error("Failed to create hidden cursor.", e, true); ErrorHandler.error("Failed to create hidden cursor.", e).show();
} }
} }

View File

@ -18,7 +18,6 @@
package itdelatrisu.opsu.ui; package itdelatrisu.opsu.ui;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.GameImage; import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
@ -455,19 +454,4 @@ public class UI {
Colors.WHITE_ALPHA.a = oldAlphaW; Colors.WHITE_ALPHA.a = oldAlphaW;
} }
/**
* Shows a confirmation dialog (used before exiting the game).
* @param message the message to display
* @return true if user selects "yes", false otherwise
*/
public static boolean showExitConfirmation(String message) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
ErrorHandler.error("Could not set system look and feel for exit confirmation.", e, true);
}
int n = JOptionPane.showConfirmDialog(null, message, "Warning",
JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
return (n != JOptionPane.YES_OPTION);
}
} }

View File

@ -23,7 +23,6 @@ import itdelatrisu.opsu.beatmap.BeatmapWatchService;
import itdelatrisu.opsu.db.DBController; import itdelatrisu.opsu.db.DBController;
import itdelatrisu.opsu.downloads.DownloadList; import itdelatrisu.opsu.downloads.DownloadList;
import itdelatrisu.opsu.downloads.Updater; import itdelatrisu.opsu.downloads.Updater;
import itdelatrisu.opsu.render.CurveRenderState;
import itdelatrisu.opsu.states.Splash; import itdelatrisu.opsu.states.Splash;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.DisplayContainer; import yugecin.opsudance.core.DisplayContainer;
@ -78,7 +77,6 @@ public class OpsuDance {
DBController.closeConnections(); DBController.closeConnections();
DownloadList.get().cancelAllDownloads(); DownloadList.get().cancelAllDownloads();
Utils.deleteDirectory(Options.TEMP_DIR); Utils.deleteDirectory(Options.TEMP_DIR);
CurveRenderState.shutdown();
if (!Options.isWatchServiceEnabled()) { if (!Options.isWatchServiceEnabled()) {
BeatmapWatchService.destroy(); BeatmapWatchService.destroy();
} }
@ -89,7 +87,7 @@ public class OpsuDance {
container.setup(); container.setup();
container.resume(); container.resume();
} catch (Exception e) { } catch (Exception e) {
ErrorHandler.error("could not initialize GL", e).preventContinue().show(); ErrorHandler.error("could not initialize GL", e).allowTerminate().preventContinue().show();
return false; return false;
} }
Exception caughtException = null; Exception caughtException = null;
@ -100,7 +98,7 @@ public class OpsuDance {
} }
container.teardown(); container.teardown();
container.pause(); container.pause();
return caughtException != null && ErrorHandler.error("update/render error", caughtException).show().shouldIgnoreAndContinue(); return caughtException != null && ErrorHandler.error("update/render error", caughtException).allowTerminate().show().shouldIgnoreAndContinue();
} }
private void initDatabase() { private void initDatabase() {
@ -174,7 +172,7 @@ public class OpsuDance {
} }
private void errorAndExit(String errstr) { private void errorAndExit(String errstr) {
ErrorHandler.error(errstr, new Throwable()).preventContinue().show(); ErrorHandler.error(errstr, new Throwable()).allowTerminate().preventContinue().show();
System.exit(1); System.exit(1);
} }

View File

@ -24,6 +24,7 @@ import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.beatmap.Beatmap; import itdelatrisu.opsu.beatmap.Beatmap;
import itdelatrisu.opsu.downloads.DownloadList; import itdelatrisu.opsu.downloads.DownloadList;
import itdelatrisu.opsu.downloads.Updater; import itdelatrisu.opsu.downloads.Updater;
import itdelatrisu.opsu.render.CurveRenderState;
import itdelatrisu.opsu.ui.Fonts; import itdelatrisu.opsu.ui.Fonts;
import org.lwjgl.Sys; import org.lwjgl.Sys;
import org.lwjgl.openal.AL; import org.lwjgl.openal.AL;
@ -222,6 +223,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
GameImage.destroyImages(); GameImage.destroyImages();
GameData.Grade.destroyImages(); GameData.Grade.destroyImages();
Beatmap.destroyBackgroundImageCache(); Beatmap.destroyBackgroundImageCache();
CurveRenderState.shutdown();
Display.destroy(); Display.destroy();
} }

View File

@ -52,6 +52,7 @@ public class ErrorHandler {
private boolean preventContinue; private boolean preventContinue;
private boolean preventReport; private boolean preventReport;
private boolean ignoreAndContinue; private boolean ignoreAndContinue;
private boolean allowTerminate;
public ErrorHandler(DisplayContainer displayContainer) { public ErrorHandler(DisplayContainer displayContainer) {
this.displayContainer = displayContainer; this.displayContainer = displayContainer;
@ -95,6 +96,11 @@ public class ErrorHandler {
return this; return this;
} }
public ErrorHandler allowTerminate() {
allowTerminate = true;
return this;
}
public ErrorHandler preventContinue() { public ErrorHandler preventContinue() {
preventContinue = true; preventContinue = true;
return this; return this;
@ -127,7 +133,9 @@ public class ErrorHandler {
Object[] messageComponents = new Object[] { message, new JScrollPane(textArea), createViewLogButton(), createReportButton() }; Object[] messageComponents = new Object[] { message, new JScrollPane(textArea), createViewLogButton(), createReportButton() };
String[] buttons; String[] buttons;
if (preventContinue) { if (!allowTerminate && !preventContinue) {
buttons = new String[] { "Ignore & continue" };
} else if (preventContinue) {
buttons = new String[] { "Terminate" }; buttons = new String[] { "Terminate" };
} else { } else {
buttons = new String[] { "Terminate", "Ignore & continue" }; buttons = new String[] { "Terminate", "Ignore & continue" };
@ -145,7 +153,7 @@ public class ErrorHandler {
null, null,
buttons, buttons,
buttons[buttons.length - 1]); buttons[buttons.length - 1]);
ignoreAndContinue = result == 1; ignoreAndContinue = !allowTerminate || result == 1;
frame.dispose(); frame.dispose();
return this; return this;

View File

@ -22,10 +22,14 @@ import java.util.*;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class EventBus { public class EventBus {
@Deprecated
public static EventBus instance; // TODO get rid of this
private final List<Subscriber> subscribers; private final List<Subscriber> subscribers;
public EventBus() { public EventBus() {
subscribers = new LinkedList<>(); subscribers = new LinkedList<>();
instance = this;
} }
public <T> void subscribe(Class<T> eventType, EventListener<T> eventListener) { public <T> void subscribe(Class<T> eventType, EventListener<T> eventListener) {