make the eventbus static

This commit is contained in:
yugecin 2017-02-06 00:39:45 +01:00
parent 8c53973fa5
commit 77a5ebf537
29 changed files with 97 additions and 104 deletions

View File

@ -729,7 +729,7 @@ public enum GameImage {
String err = String.format("Could not find default image '%s'.", filename); String err = String.format("Could not find default image '%s'.", filename);
Log.warn(err); Log.warn(err);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
/** /**
@ -788,7 +788,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) {
EventBus.instance.post(new BubbleNotificationEvent(String.format("Failed to set image '%s'.", name), BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(String.format("Failed to set image '%s'.", name), BubbleNotificationEvent.COMMONCOLOR_RED));
break; break;
} }
} }
@ -814,7 +814,7 @@ public enum GameImage {
img = img.getScaledCopy(0.5f); img = img.getScaledCopy(0.5f);
return img; return img;
} catch (SlickException e) { } catch (SlickException e) {
EventBus.instance.post(new BubbleNotificationEvent(String.format("Failed to set image '%s'.", filename), BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(String.format("Failed to set image '%s'.", filename), BubbleNotificationEvent.COMMONCOLOR_RED));
} }
} }
} }

View File

@ -689,7 +689,7 @@ public class Options {
public void clickListItem(int index) { public void clickListItem(int index) {
if (Game.isInGame && Dancer.moverFactories[index] instanceof PolyMoverFactory) { if (Game.isInGame && Dancer.moverFactories[index] instanceof PolyMoverFactory) {
// TODO remove this when #79 is fixed // TODO remove this when #79 is fixed
EventBus.instance.post(new BarNotificationEvent("This mover is disabled in the storyboard right now")); EventBus.post(new BarNotificationEvent("This mover is disabled in the storyboard right now"));
return; return;
} }
Dancer.instance.setMoverFactoryIndex(index); Dancer.instance.setMoverFactoryIndex(index);
@ -1343,7 +1343,7 @@ public class Options {
public static void setNextFPS(DisplayContainer displayContainer) { public static void setNextFPS(DisplayContainer displayContainer) {
GameOption.displayContainer = displayContainer; // TODO dirty shit GameOption.displayContainer = displayContainer; // TODO dirty shit
GameOption.TARGET_FPS.clickListItem((targetFPSindex + 1) % targetFPS.length); GameOption.TARGET_FPS.clickListItem((targetFPSindex + 1) % targetFPS.length);
EventBus.instance.post(new BarNotificationEvent(String.format("Frame limiter: %s", GameOption.TARGET_FPS.getValueString()))); EventBus.post(new BarNotificationEvent(String.format("Frame limiter: %s", GameOption.TARGET_FPS.getValueString())));
} }
/** /**
@ -1430,7 +1430,7 @@ public class Options {
try { try {
container.setDisplayMode(width, height, isFullscreen()); container.setDisplayMode(width, height, isFullscreen());
} catch (Exception e) { } catch (Exception e) {
container.eventBus.post(new BubbleNotificationEvent("Failed to change resolution", BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent("Failed to change resolution", BubbleNotificationEvent.COMMONCOLOR_RED));
Log.error("Failed to set display mode.", e); Log.error("Failed to set display mode.", e);
} }
@ -1755,7 +1755,7 @@ public class Options {
*/ */
public static void toggleMouseDisabled() { public static void toggleMouseDisabled() {
GameOption.DISABLE_MOUSE_BUTTONS.click(); GameOption.DISABLE_MOUSE_BUTTONS.click();
EventBus.instance.post(new BarNotificationEvent((GameOption.DISABLE_MOUSE_BUTTONS.getBooleanValue()) ? EventBus.post(new BarNotificationEvent((GameOption.DISABLE_MOUSE_BUTTONS.getBooleanValue()) ?
"Mouse buttons are disabled." : "Mouse buttons are enabled.")); "Mouse buttons are disabled." : "Mouse buttons are enabled."));
} }
@ -1845,7 +1845,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())
EventBus.instance.post(new BubbleNotificationEvent(String.format("Failed to create beatmap directory at '%s'.", beatmapDir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(String.format("Failed to create beatmap directory at '%s'.", beatmapDir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED));
return beatmapDir; return beatmapDir;
} }
@ -1860,7 +1860,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())
EventBus.instance.post(new BubbleNotificationEvent(String.format("Failed to create song packs directory at '%s'.", oszDir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(String.format("Failed to create song packs directory at '%s'.", oszDir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED));
return oszDir; return oszDir;
} }
@ -1875,7 +1875,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())
EventBus.instance.post(new BubbleNotificationEvent(String.format("Failed to create replay import directory at '%s'.", replayImportDir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(String.format("Failed to create replay import directory at '%s'.", replayImportDir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED));
return replayImportDir; return replayImportDir;
} }
@ -1925,14 +1925,14 @@ 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())
EventBus.instance.post(new BubbleNotificationEvent(String.format("Failed to create skins directory at '%s'.", skinRootDir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(String.format("Failed to create skins directory at '%s'.", skinRootDir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED));
return skinRootDir; return skinRootDir;
} }
public static void reloadSkin() { public static void reloadSkin() {
loadSkin(); loadSkin();
SoundController.init(); SoundController.init();
EventBus.instance.post(new ResolutionOrSkinChangedEvent()); EventBus.post(new ResolutionOrSkinChangedEvent());
} }
/** /**
@ -2065,7 +2065,7 @@ public class Options {
} catch (IOException e) { } catch (IOException e) {
String err = String.format("Failed to read file '%s'.", OPTIONS_FILE.getAbsolutePath()); String err = String.format("Failed to read file '%s'.", OPTIONS_FILE.getAbsolutePath());
Log.error(err, e); Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
} }
@ -2096,7 +2096,7 @@ public class Options {
} catch (IOException e) { } catch (IOException e) {
String err = String.format("Failed to write to file '%s'.", OPTIONS_FILE.getAbsolutePath()); String err = String.format("Failed to write to file '%s'.", OPTIONS_FILE.getAbsolutePath());
Log.error(err, e); Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
} }
} }

View File

@ -248,7 +248,7 @@ 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()) {
EventBus.instance.post(new BubbleNotificationEvent(String.format("Failed to create screenshot directory at '%s'.", dir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(String.format("Failed to create screenshot directory at '%s'.", dir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED));
return; return;
} }
@ -282,7 +282,7 @@ 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)); EventBus.post(new BubbleNotificationEvent("Created " + fileName, BubbleNotificationEvent.COMMONCOLOR_PURPLE));
} catch (Exception e) { } catch (Exception e) {
ErrorHandler.error("Failed to take a screenshot.", e).show(); ErrorHandler.error("Failed to take a screenshot.", e).show();
} }

View File

@ -102,7 +102,7 @@ public class MusicController {
if (lastBeatmap == null || !beatmap.audioFilename.equals(lastBeatmap.audioFilename)) { if (lastBeatmap == null || !beatmap.audioFilename.equals(lastBeatmap.audioFilename)) {
final File audioFile = beatmap.audioFilename; final File audioFile = beatmap.audioFilename;
if (!audioFile.isFile() && !ResourceLoader.resourceExists(audioFile.getPath())) { if (!audioFile.isFile() && !ResourceLoader.resourceExists(audioFile.getPath())) {
EventBus.instance.post(new BarNotificationEvent(String.format("Could not find track '%s'.", audioFile.getName()))); EventBus.post(new BarNotificationEvent(String.format("Could not find track '%s'.", audioFile.getName())));
return; return;
} }
@ -157,7 +157,7 @@ public class MusicController {
} catch (Exception e) { } catch (Exception e) {
String err = String.format("Could not play track '%s'.", file.getName()); String err = String.format("Could not play track '%s'.", file.getName());
Log.error(err, e); Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
} }

View File

@ -217,7 +217,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) {
EventBus.instance.post(new BubbleNotificationEvent("Could not find sound file " + s.getFileName(), BubbleNotificationEvent.COLOR_ORANGE)); EventBus.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"));
@ -236,7 +236,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) {
EventBus.instance.post(new BubbleNotificationEvent("Could not find hit sound file " + filename, BubbleNotificationEvent.COLOR_ORANGE)); EventBus.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);
@ -392,7 +392,7 @@ public class SoundController {
@Override @Override
public void error() { public void error() {
EventBus.instance.post(new BarNotificationEvent("Failed to download track preview.")); EventBus.post(new BarNotificationEvent("Failed to download track preview."));
} }
}); });
try { try {

View File

@ -160,7 +160,7 @@ public class BeatmapParser {
beatmap = parseFile(file, dir, beatmaps, false); beatmap = parseFile(file, dir, beatmaps, false);
} catch(Exception e) { } catch(Exception e) {
Log.error("could not parse beatmap " + file.getName() + ": " + e.getMessage()); Log.error("could not parse beatmap " + file.getName() + ": " + e.getMessage());
EventBus.instance.post(new BubbleNotificationEvent("Could not parse beatmap " + file.getName(), BubbleNotificationEvent.COLOR_ORANGE)); EventBus.post(new BubbleNotificationEvent("Could not parse beatmap " + file.getName(), BubbleNotificationEvent.COLOR_ORANGE));
} }
// add to parsed beatmap list // add to parsed beatmap list
@ -249,7 +249,7 @@ public class BeatmapParser {
} catch (IOException e) { } catch (IOException e) {
String err = String.format("Failed to read file '%s'.", map.getFile().getAbsolutePath()); String err = String.format("Failed to read file '%s'.", map.getFile().getAbsolutePath());
Log.error(err, e); Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
ErrorHandler.error("Failed to get MD5 hash stream.", e).show(); ErrorHandler.error("Failed to get MD5 hash stream.", e).show();
@ -654,7 +654,7 @@ public class BeatmapParser {
} catch (IOException e) { } catch (IOException e) {
String err = String.format("Failed to read file '%s'.", file.getAbsolutePath()); String err = String.format("Failed to read file '%s'.", file.getAbsolutePath());
Log.error(err, e); Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
ErrorHandler.error("Failed to get MD5 hash stream.", e).show(); ErrorHandler.error("Failed to get MD5 hash stream.", e).show();
@ -737,7 +737,7 @@ public class BeatmapParser {
} catch (IOException e) { } catch (IOException e) {
String err = String.format("Failed to read file '%s'.", beatmap.getFile().getAbsolutePath()); String err = String.format("Failed to read file '%s'.", beatmap.getFile().getAbsolutePath());
Log.error(err, e); Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
} }
@ -817,7 +817,7 @@ public class BeatmapParser {
} catch (IOException e) { } catch (IOException e) {
String err = String.format("Failed to read file '%s'.", beatmap.getFile().getAbsolutePath()); String err = String.format("Failed to read file '%s'.", beatmap.getFile().getAbsolutePath());
Log.error(err, e); Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
} }

View File

@ -216,7 +216,7 @@ public class BeatmapSetList {
try { try {
Utils.deleteToTrash(dir); Utils.deleteToTrash(dir);
} catch (IOException e) { } catch (IOException e) {
EventBus.instance.post(new BubbleNotificationEvent("Could not delete song group", BubbleNotificationEvent.COLOR_ORANGE)); EventBus.post(new BubbleNotificationEvent("Could not delete song group", BubbleNotificationEvent.COLOR_ORANGE));
} }
if (ws != null) if (ws != null)
ws.resume(); ws.resume();
@ -271,7 +271,7 @@ public class BeatmapSetList {
try { try {
Utils.deleteToTrash(file); Utils.deleteToTrash(file);
} catch (IOException e) { } catch (IOException e) {
EventBus.instance.post(new BubbleNotificationEvent("Could not delete song", BubbleNotificationEvent.COLOR_ORANGE)); EventBus.post(new BubbleNotificationEvent("Could not delete song", BubbleNotificationEvent.COLOR_ORANGE));
} }
if (ws != null) if (ws != null)
ws.resume(); ws.resume();

View File

@ -98,7 +98,7 @@ public class BeatmapWatchService {
ws.register(Options.getBeatmapDir().toPath()); ws.register(Options.getBeatmapDir().toPath());
} catch (IOException e) { } catch (IOException e) {
Log.error("Could not create watch service", e); Log.error("Could not create watch service", e);
EventBus.instance.post(new BubbleNotificationEvent("Could not create watch service", BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent("Could not create watch service", BubbleNotificationEvent.COMMONCOLOR_RED));
return; return;
} }
@ -120,7 +120,7 @@ public class BeatmapWatchService {
ws = null; ws = null;
} catch (IOException e) { } catch (IOException e) {
Log.error("An I/O exception occurred while closing the previous watch service.", 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)); EventBus.post(new BubbleNotificationEvent("An I/O exception occurred while closing the previous watch service.", BubbleNotificationEvent.COMMONCOLOR_RED));
ws = null; ws = null;
} }
} }

View File

@ -101,7 +101,7 @@ public class OszUnpacker {
} catch (ZipException e) { } catch (ZipException e) {
String err = String.format("Failed to unzip file %s to dest %s.", file.getAbsolutePath(), dest.getAbsolutePath()); String err = String.format("Failed to unzip file %s to dest %s.", file.getAbsolutePath(), dest.getAbsolutePath());
Log.error(err, e); Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
} }

View File

@ -217,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) {
EventBus.instance.post(new BubbleNotificationEvent(error, BubbleNotificationEvent.COLOR_ORANGE)); EventBus.post(new BubbleNotificationEvent(error, BubbleNotificationEvent.COLOR_ORANGE));
throw new IOException(); throw new IOException();
} }

View File

@ -278,12 +278,12 @@ public class DownloadNode {
download.setListener(new DownloadListener() { download.setListener(new DownloadListener() {
@Override @Override
public void completed() { public void completed() {
EventBus.instance.post(new BarNotificationEvent(String.format("Download complete: %s", getTitle()))); EventBus.post(new BarNotificationEvent(String.format("Download complete: %s", getTitle())));
} }
@Override @Override
public void error() { public void error() {
EventBus.instance.post(new BarNotificationEvent("Download failed due to a connection error.")); EventBus.post(new BarNotificationEvent("Download failed due to a connection error."));
} }
}); });
this.download = download; this.download = download;
@ -404,7 +404,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) {
EventBus.instance.post(new BubbleNotificationEvent("Trying to draw download information for button without Download object", BubbleNotificationEvent.COLOR_ORANGE)); EventBus.post(new BubbleNotificationEvent("Trying to draw download information for button without Download object", BubbleNotificationEvent.COLOR_ORANGE));
return; return;
} }

View File

@ -251,13 +251,13 @@ public class Updater {
@Override @Override
public void completed() { public void completed() {
status = Status.UPDATE_DOWNLOADED; status = Status.UPDATE_DOWNLOADED;
EventBus.instance.post(new BarNotificationEvent("Update has finished downloading")); EventBus.post(new BarNotificationEvent("Update has finished downloading"));
} }
@Override @Override
public void error() { public void error() {
status = Status.CONNECTION_ERROR; status = Status.CONNECTION_ERROR;
EventBus.instance.post(new BarNotificationEvent("Update failed due to a connection error.")); EventBus.post(new BarNotificationEvent("Update failed due to a connection error."));
} }
}); });
} }

View File

@ -275,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()) {
EventBus.instance.post(new BubbleNotificationEvent("Failed to create replay directory.", BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent("Failed to create replay directory.", BubbleNotificationEvent.COMMONCOLOR_RED));
return; return;
} }
} }

View File

@ -73,7 +73,7 @@ public class ReplayImporter {
if (!replayDir.mkdir()) { if (!replayDir.mkdir()) {
String err = String.format("Failed to create replay directory '%s'.", replayDir.getAbsolutePath()); String err = String.format("Failed to create replay directory '%s'.", replayDir.getAbsolutePath());
Log.error(err); Log.error(err);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
return; return;
} }
} }
@ -88,7 +88,7 @@ public class ReplayImporter {
moveToFailedDirectory(file); moveToFailedDirectory(file);
String err = String.format("Failed to import replay '%s'. The replay file could not be parsed.", file.getName()); String err = String.format("Failed to import replay '%s'. The replay file could not be parsed.", file.getName());
Log.error(err, e); Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
continue; continue;
} }
Beatmap beatmap = BeatmapSetList.get().getBeatmapFromHash(r.beatmapHash); Beatmap beatmap = BeatmapSetList.get().getBeatmapFromHash(r.beatmapHash);
@ -107,7 +107,7 @@ public class ReplayImporter {
moveToFailedDirectory(file); moveToFailedDirectory(file);
String err = String.format("Failed to import replay '%s'. The associated beatmap could not be found.", file.getName()); String err = String.format("Failed to import replay '%s'. The associated beatmap could not be found.", file.getName());
Log.error(err); Log.error(err);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
} }

View File

@ -293,7 +293,7 @@ public class SkinLoader {
} catch (IOException e) { } catch (IOException e) {
String err = String.format("Failed to read file '%s'.", skinFile.getAbsolutePath()); String err = String.format("Failed to read file '%s'.", skinFile.getAbsolutePath());
Log.error(err, e); Log.error(err, e);
EventBus.instance.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
} }
return skin; return skin;

View File

@ -280,7 +280,7 @@ public class DownloadsMenu extends ComplexOpsuState {
this.importedNode = BeatmapParser.parseDirectories(dirs); this.importedNode = BeatmapParser.parseDirectories(dirs);
if (importedNode != null) { if (importedNode != null) {
// send notification // send notification
EventBus.instance.post(new BarNotificationEvent((dirs.length == 1) ? "Imported 1 new song." : EventBus.post(new BarNotificationEvent((dirs.length == 1) ? "Imported 1 new song." :
String.format("Imported %d new songs.", dirs.length))); String.format("Imported %d new songs.", dirs.length)));
} }
} }
@ -687,7 +687,7 @@ public class DownloadsMenu extends ComplexOpsuState {
if (playing) if (playing)
previewID = node.getID(); previewID = node.getID();
} catch (SlickException e) { } catch (SlickException e) {
EventBus.instance.post(new BarNotificationEvent("Failed to load track preview. See log for details.")); EventBus.post(new BarNotificationEvent("Failed to load track preview. See log for details."));
Log.error(e); Log.error(e);
} }
} }
@ -710,7 +710,7 @@ public class DownloadsMenu extends ComplexOpsuState {
if (!DownloadList.get().contains(node.getID())) { if (!DownloadList.get().contains(node.getID())) {
node.createDownload(serverMenu.getSelectedItem()); node.createDownload(serverMenu.getSelectedItem());
if (node.getDownload() == null) { if (node.getDownload() == null) {
EventBus.instance.post(new BarNotificationEvent("The download could not be started")); EventBus.post(new BarNotificationEvent("The download could not be started"));
} else { } else {
DownloadList.get().addNode(node); DownloadList.get().addNode(node);
node.getDownload().start(); node.getDownload().start();
@ -952,7 +952,7 @@ public class DownloadsMenu extends ComplexOpsuState {
pageDir = Page.RESET; pageDir = Page.RESET;
previewID = -1; previewID = -1;
if (barNotificationOnLoad != null) { if (barNotificationOnLoad != null) {
EventBus.instance.post(new BarNotificationEvent(barNotificationOnLoad)); EventBus.post(new BarNotificationEvent(barNotificationOnLoad));
barNotificationOnLoad = null; barNotificationOnLoad = null;
} }
} }

View File

@ -344,7 +344,7 @@ public class Game extends ComplexOpsuState {
gOffscreen.setBackground(Color.black); gOffscreen.setBackground(Color.black);
} catch (SlickException e) { } catch (SlickException e) {
Log.error("could not create offscreen graphics", e); Log.error("could not create offscreen graphics", e);
displayContainer.eventBus.post(new BubbleNotificationEvent("Exception while creating offscreen graphics. See logfile for details.", BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent("Exception while creating offscreen graphics. See logfile for details.", BubbleNotificationEvent.COMMONCOLOR_RED));
} }
// initialize music position bar location // initialize music position bar location
@ -1184,7 +1184,7 @@ public class Game extends ComplexOpsuState {
int position = (pauseTime > -1) ? pauseTime : trackPosition; int position = (pauseTime > -1) ? pauseTime : trackPosition;
if (Options.setCheckpoint(position / 1000)) { if (Options.setCheckpoint(position / 1000)) {
SoundController.playSound(SoundEffect.MENUCLICK); SoundController.playSound(SoundEffect.MENUCLICK);
EventBus.instance.post(new BarNotificationEvent("Checkpoint saved.")); EventBus.post(new BarNotificationEvent("Checkpoint saved."));
} }
} }
break; break;
@ -1196,7 +1196,7 @@ public class Game extends ComplexOpsuState {
break; // invalid checkpoint break; // invalid checkpoint
loadCheckpoint(checkpoint); loadCheckpoint(checkpoint);
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
EventBus.instance.post(new BarNotificationEvent("Checkpoint loaded.")); EventBus.post(new BarNotificationEvent("Checkpoint loaded."));
} }
break; break;
case Input.KEY_F: case Input.KEY_F:
@ -1241,12 +1241,12 @@ public class Game extends ComplexOpsuState {
break; break;
case Input.KEY_MINUS: case Input.KEY_MINUS:
currentMapMusicOffset += 5; currentMapMusicOffset += 5;
EventBus.instance.post(new BarNotificationEvent("Current map offset: " + currentMapMusicOffset)); EventBus.post(new BarNotificationEvent("Current map offset: " + currentMapMusicOffset));
break; break;
} }
if (key == Input.KEY_ADD || c == '+') { if (key == Input.KEY_ADD || c == '+') {
currentMapMusicOffset -= 5; currentMapMusicOffset -= 5;
EventBus.instance.post(new BarNotificationEvent("Current map offset: " + currentMapMusicOffset)); EventBus.post(new BarNotificationEvent("Current map offset: " + currentMapMusicOffset));
} }
return true; return true;
@ -1466,7 +1466,7 @@ public class Game extends ComplexOpsuState {
} }
if (beatmap == null || beatmap.objects == null) { if (beatmap == null || beatmap.objects == null) {
displayContainer.eventBus.post(new BubbleNotificationEvent("Game was running without a beatmap", BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent("Game was running without a beatmap", BubbleNotificationEvent.COMMONCOLOR_RED));
displayContainer.switchStateInstantly(SongMenu.class); displayContainer.switchStateInstantly(SongMenu.class);
} }
@ -1568,7 +1568,7 @@ public class Game extends ComplexOpsuState {
} catch (Exception e) { } catch (Exception e) {
String message = String.format("Failed to create %s at index %d:\n%s", hitObject.getTypeName(), i, hitObject.toString()); String message = String.format("Failed to create %s at index %d:\n%s", hitObject.getTypeName(), i, hitObject.toString());
Log.error(message, e); Log.error(message, e);
displayContainer.eventBus.post(new BubbleNotificationEvent(message, BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent(message, BubbleNotificationEvent.COMMONCOLOR_RED));
gameObjects[i] = new DummyObject(hitObject); gameObjects[i] = new DummyObject(hitObject);
} }
} }
@ -2154,7 +2154,7 @@ public class Game extends ComplexOpsuState {
this.replay = null; this.replay = null;
} else { } else {
if (replay.frames == null) { if (replay.frames == null) {
displayContainer.eventBus.post(new BubbleNotificationEvent("Attempting to set a replay with no frames.", BubbleNotificationEvent.COLOR_ORANGE)); EventBus.post(new BubbleNotificationEvent("Attempting to set a replay with no frames.", BubbleNotificationEvent.COLOR_ORANGE));
return; return;
} }
this.isReplay = true; this.isReplay = true;

View File

@ -166,13 +166,13 @@ public class GameRanking extends BaseOpsuState {
gameState.setRestart((data.isGameplay()) ? Game.Restart.REPLAY : Game.Restart.NEW); gameState.setRestart((data.isGameplay()) ? Game.Restart.REPLAY : Game.Restart.NEW);
returnToGame = true; returnToGame = true;
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
EventBus.instance.post(new BarNotificationEvent("Replay file not found.")); EventBus.post(new BarNotificationEvent("Replay file not found."));
} catch (IOException e) { } catch (IOException e) {
Log.error("Failed to load replay data.", e); Log.error("Failed to load replay data.", e);
EventBus.instance.post(new BarNotificationEvent("Failed to load replay data. See log for details.")); EventBus.post(new BarNotificationEvent("Failed to load replay data. See log for details."));
} }
} else } else
EventBus.instance.post(new BarNotificationEvent("Replay file not found.")); EventBus.post(new BarNotificationEvent("Replay file not found."));
} }
// retry // retry

View File

@ -471,10 +471,10 @@ public class MainMenu extends BaseOpsuState {
UI.enter(); UI.enter();
if (!enterNotification) { if (!enterNotification) {
if (Updater.get().getStatus() == Updater.Status.UPDATE_AVAILABLE) { if (Updater.get().getStatus() == Updater.Status.UPDATE_AVAILABLE) {
EventBus.instance.post(new BarNotificationEvent("An opsu! update is available.")); EventBus.post(new BarNotificationEvent("An opsu! update is available."));
enterNotification = true; enterNotification = true;
} else if (Updater.get().justUpdated()) { } else if (Updater.get().justUpdated()) {
EventBus.instance.post(new BarNotificationEvent("opsu! is now up to date!")); EventBus.post(new BarNotificationEvent("opsu! is now up to date!"));
enterNotification = true; enterNotification = true;
} }
} }
@ -537,15 +537,15 @@ public class MainMenu extends BaseOpsuState {
if (musicPlay.contains(x, y)) { if (musicPlay.contains(x, y)) {
if (MusicController.isPlaying()) { if (MusicController.isPlaying()) {
MusicController.pause(); MusicController.pause();
EventBus.instance.post(new BarNotificationEvent("Pause")); EventBus.post(new BarNotificationEvent("Pause"));
} else if (!MusicController.isTrackLoading()) { } else if (!MusicController.isTrackLoading()) {
MusicController.resume(); MusicController.resume();
EventBus.instance.post(new BarNotificationEvent("Play")); EventBus.post(new BarNotificationEvent("Play"));
} }
return true; return true;
} else if (musicNext.contains(x, y)) { } else if (musicNext.contains(x, y)) {
nextTrack(true); nextTrack(true);
EventBus.instance.post(new BarNotificationEvent(">> Next")); EventBus.post(new BarNotificationEvent(">> Next"));
return true; return true;
} else if (musicPrevious.contains(x, y)) { } else if (musicPrevious.contains(x, y)) {
lastMeasureProgress = 0f; lastMeasureProgress = 0f;
@ -555,7 +555,7 @@ public class MainMenu extends BaseOpsuState {
bgAlpha.setTime(0); bgAlpha.setTime(0);
} else } else
MusicController.setPosition(0); MusicController.setPosition(0);
EventBus.instance.post(new BarNotificationEvent("<< Previous")); EventBus.post(new BarNotificationEvent("<< Previous"));
return true; return true;
} }
@ -571,10 +571,10 @@ public class MainMenu extends BaseOpsuState {
try { try {
Desktop.getDesktop().browse(Options.REPOSITORY_URI); Desktop.getDesktop().browse(Options.REPOSITORY_URI);
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
EventBus.instance.post(new BarNotificationEvent("The repository web page could not be opened.")); EventBus.post(new BarNotificationEvent("The repository web page could not be opened."));
} catch (IOException e) { } catch (IOException e) {
Log.error("could not browse to repo", e); Log.error("could not browse to repo", e);
displayContainer.eventBus.post(new BubbleNotificationEvent("Could not browse to repo", BubbleNotificationEvent.COLOR_ORANGE)); EventBus.post(new BubbleNotificationEvent("Could not browse to repo", BubbleNotificationEvent.COLOR_ORANGE));
} }
return true; return true;
} }
@ -583,10 +583,10 @@ public class MainMenu extends BaseOpsuState {
try { try {
Desktop.getDesktop().browse(Options.DANCE_REPOSITORY_URI); Desktop.getDesktop().browse(Options.DANCE_REPOSITORY_URI);
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
EventBus.instance.post(new BarNotificationEvent("The repository web page could not be opened.")); EventBus.post(new BarNotificationEvent("The repository web page could not be opened."));
} catch (IOException e) { } catch (IOException e) {
Log.error("could not browse to repo", e); Log.error("could not browse to repo", e);
displayContainer.eventBus.post(new BubbleNotificationEvent("Could not browse to repo", BubbleNotificationEvent.COLOR_ORANGE)); EventBus.post(new BubbleNotificationEvent("Could not browse to repo", BubbleNotificationEvent.COLOR_ORANGE));
} }
return true; return true;
} }

View File

@ -455,7 +455,7 @@ public class SongMenu extends ComplexOpsuState {
if (!songFolderChanged && kind != StandardWatchEventKinds.ENTRY_MODIFY) { if (!songFolderChanged && kind != StandardWatchEventKinds.ENTRY_MODIFY) {
songFolderChanged = true; songFolderChanged = true;
if (displayContainer.isInState(SongMenu.class)) { if (displayContainer.isInState(SongMenu.class)) {
EventBus.instance.post(new BarNotificationEvent("Changed is Songs folder detected. Hit F5 to refresh.")); EventBus.post(new BarNotificationEvent("Changed is Songs folder detected. Hit F5 to refresh."));
} }
} }
} }
@ -961,7 +961,7 @@ public class SongMenu extends ComplexOpsuState {
setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true); setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
if (BeatmapSetList.get().size() < 1 && group.getEmptyMessage() != null) { if (BeatmapSetList.get().size() < 1 && group.getEmptyMessage() != null) {
EventBus.instance.post(new BarNotificationEvent(group.getEmptyMessage())); EventBus.post(new BarNotificationEvent(group.getEmptyMessage()));
} }
} }
return true; return true;
@ -1773,7 +1773,7 @@ public class SongMenu extends ComplexOpsuState {
Beatmap beatmap = MusicController.getBeatmap(); Beatmap beatmap = MusicController.getBeatmap();
if (focusNode == null || beatmap != focusNode.getSelectedBeatmap()) { if (focusNode == null || beatmap != focusNode.getSelectedBeatmap()) {
EventBus.instance.post(new BarNotificationEvent("Unable to load the beatmap audio.")); EventBus.post(new BarNotificationEvent("Unable to load the beatmap audio."));
return; return;
} }

View File

@ -66,7 +66,6 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
private static SGL GL = Renderer.get(); private static SGL GL = Renderer.get();
public final EventBus eventBus;
private final InstanceContainer instanceContainer; private final InstanceContainer instanceContainer;
private FpsRenderState fpsState; private FpsRenderState fpsState;
@ -117,9 +116,8 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
public final Cursor cursor; public final Cursor cursor;
public boolean drawCursor; public boolean drawCursor;
public DisplayContainer(InstanceContainer instanceContainer, EventBus eventBus) { public DisplayContainer(InstanceContainer instanceContainer) {
this.instanceContainer = instanceContainer; this.instanceContainer = instanceContainer;
this.eventBus = eventBus;
this.cursor = new Cursor(); this.cursor = new Cursor();
drawCursor = true; drawCursor = true;
instance = this; instance = this;
@ -143,7 +141,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
} }
}; };
eventBus.subscribe(ResolutionOrSkinChangedEvent.class, new EventListener<ResolutionOrSkinChangedEvent>() { EventBus.subscribe(ResolutionOrSkinChangedEvent.class, new EventListener<ResolutionOrSkinChangedEvent>() {
@Override @Override
public void onEvent(ResolutionOrSkinChangedEvent event) { public void onEvent(ResolutionOrSkinChangedEvent event) {
destroyImages(); destroyImages();
@ -291,13 +289,13 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
return true; return true;
} }
if (DownloadList.get().hasActiveDownloads()) { if (DownloadList.get().hasActiveDownloads()) {
eventBus.post(new BubbleNotificationEvent(DownloadList.EXIT_CONFIRMATION, BubbleNotificationEvent.COMMONCOLOR_PURPLE)); EventBus.post(new BubbleNotificationEvent(DownloadList.EXIT_CONFIRMATION, BubbleNotificationEvent.COMMONCOLOR_PURPLE));
exitRequested = false; exitRequested = false;
exitconfirmation = System.currentTimeMillis(); exitconfirmation = System.currentTimeMillis();
return false; return false;
} }
if (Updater.get().getStatus() == Updater.Status.UPDATE_DOWNLOADING) { if (Updater.get().getStatus() == Updater.Status.UPDATE_DOWNLOADING) {
eventBus.post(new BubbleNotificationEvent(Updater.EXIT_CONFIRMATION, BubbleNotificationEvent.COMMONCOLOR_PURPLE)); EventBus.post(new BubbleNotificationEvent(Updater.EXIT_CONFIRMATION, BubbleNotificationEvent.COMMONCOLOR_PURPLE));
exitRequested = false; exitRequested = false;
exitconfirmation = System.currentTimeMillis(); exitconfirmation = System.currentTimeMillis();
return false; return false;
@ -321,7 +319,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
if (fullscreen) { if (fullscreen) {
fullscreen = false; fullscreen = false;
Log.warn("could not find fullscreen displaymode for " + width + "x" + height); Log.warn("could not find fullscreen displaymode for " + width + "x" + height);
eventBus.post(new BubbleNotificationEvent("Fullscreen mode is not supported for " + width + "x" + height, BubbleNotificationEvent.COLOR_ORANGE)); EventBus.post(new BubbleNotificationEvent("Fullscreen mode is not supported for " + width + "x" + height, BubbleNotificationEvent.COLOR_ORANGE));
} }
} }
@ -357,7 +355,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
GameImage.init(width, height); GameImage.init(width, height);
Fonts.init(); Fonts.init();
eventBus.post(new ResolutionOrSkinChangedEvent()); EventBus.post(new ResolutionOrSkinChangedEvent());
} }
public void resetCursor() { public void resetCursor() {

View File

@ -22,21 +22,16 @@ import java.util.*;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class EventBus { public class EventBus {
@Deprecated private EventBus() {
public static EventBus instance; // TODO get rid of this
private final List<Subscriber> subscribers;
public EventBus() {
subscribers = new LinkedList<>();
instance = this;
} }
public <T> void subscribe(Class<T> eventType, EventListener<T> eventListener) { private static final List<Subscriber> subscribers = new LinkedList<>();
public static <T> void subscribe(Class<T> eventType, EventListener<T> eventListener) {
subscribers.add(new Subscriber<>(eventType, eventListener)); subscribers.add(new Subscriber<>(eventType, eventListener));
} }
public void post(Object event) { public static void post(Object event) {
for (Subscriber s : subscribers) { for (Subscriber s : subscribers) {
if (s.eventType.isInstance(event)) { if (s.eventType.isInstance(event)) {
s.listener.onEvent(event); s.listener.onEvent(event);
@ -44,7 +39,7 @@ public class EventBus {
} }
} }
private class Subscriber<T> { private static class Subscriber<T> {
private final Class<T> eventType; private final Class<T> eventType;
private final EventListener<T> listener; private final EventListener<T> listener;

View File

@ -20,7 +20,6 @@ package yugecin.opsudance.core.inject;
import itdelatrisu.opsu.states.*; import itdelatrisu.opsu.states.*;
import yugecin.opsudance.PreStartupInitializer; import yugecin.opsudance.PreStartupInitializer;
import yugecin.opsudance.core.DisplayContainer; import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.core.state.specialstates.BarNotificationState; import yugecin.opsudance.core.state.specialstates.BarNotificationState;
import yugecin.opsudance.core.state.specialstates.BubbleNotificationState; import yugecin.opsudance.core.state.specialstates.BubbleNotificationState;
import yugecin.opsudance.core.state.specialstates.FpsRenderState; import yugecin.opsudance.core.state.specialstates.FpsRenderState;
@ -34,8 +33,6 @@ import yugecin.opsudance.states.EmptyState;
public class OpsuDanceInjector extends Injector { public class OpsuDanceInjector extends Injector {
protected void configure() { protected void configure() {
bind(EventBus.class).asEagerSingleton();
bind(PreStartupInitializer.class).asEagerSingleton(); bind(PreStartupInitializer.class).asEagerSingleton();
bind(DisplayContainer.class).asEagerSingleton(); bind(DisplayContainer.class).asEagerSingleton();

View File

@ -24,6 +24,7 @@ import itdelatrisu.opsu.ui.UI;
import org.newdawn.slick.Graphics; import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input; import org.newdawn.slick.Input;
import yugecin.opsudance.core.DisplayContainer; import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.core.events.EventListener; import yugecin.opsudance.core.events.EventListener;
import yugecin.opsudance.events.ResolutionOrSkinChangedEvent; import yugecin.opsudance.events.ResolutionOrSkinChangedEvent;
@ -41,7 +42,7 @@ public abstract class BaseOpsuState implements OpsuState, EventListener<Resoluti
public BaseOpsuState(DisplayContainer displayContainer) { public BaseOpsuState(DisplayContainer displayContainer) {
this.displayContainer = displayContainer; this.displayContainer = displayContainer;
displayContainer.eventBus.subscribe(ResolutionOrSkinChangedEvent.class, this); EventBus.subscribe(ResolutionOrSkinChangedEvent.class, this);
} }
protected void revalidate() { protected void revalidate() {

View File

@ -49,13 +49,13 @@ public class BarNotificationState implements EventListener<BarNotificationEvent>
private int barHalfTargetHeight; private int barHalfTargetHeight;
private int barHalfHeight; private int barHalfHeight;
public BarNotificationState(DisplayContainer displayContainer, EventBus eventBus) { public BarNotificationState(DisplayContainer displayContainer) {
this.displayContainer = displayContainer; this.displayContainer = displayContainer;
this.bgcol = new Color(Color.black); this.bgcol = new Color(Color.black);
this.textCol = new Color(Color.white); this.textCol = new Color(Color.white);
this.timeShown = TOTAL_TIME; this.timeShown = TOTAL_TIME;
eventBus.subscribe(BarNotificationEvent.class, this); EventBus.subscribe(BarNotificationEvent.class, this);
eventBus.subscribe(ResolutionOrSkinChangedEvent.class, new EventListener<ResolutionOrSkinChangedEvent>() { EventBus.subscribe(ResolutionOrSkinChangedEvent.class, new EventListener<ResolutionOrSkinChangedEvent>() {
@Override @Override
public void onEvent(ResolutionOrSkinChangedEvent event) { public void onEvent(ResolutionOrSkinChangedEvent event) {
if (timeShown >= TOTAL_TIME) { if (timeShown >= TOTAL_TIME) {

View File

@ -44,12 +44,12 @@ public class BubbleNotificationState implements EventListener<BubbleNotification
private int addAnimationTime; private int addAnimationTime;
private int addAnimationHeight; private int addAnimationHeight;
public BubbleNotificationState(DisplayContainer displayContainer, EventBus eventBus) { public BubbleNotificationState(DisplayContainer displayContainer) {
this.displayContainer = displayContainer; this.displayContainer = displayContainer;
this.bubbles = new LinkedList<>(); this.bubbles = new LinkedList<>();
this.addAnimationTime = IN_TIME; this.addAnimationTime = IN_TIME;
eventBus.subscribe(BubbleNotificationEvent.class, this); EventBus.subscribe(BubbleNotificationEvent.class, this);
eventBus.subscribe(ResolutionOrSkinChangedEvent.class, new EventListener<ResolutionOrSkinChangedEvent>() { EventBus.subscribe(ResolutionOrSkinChangedEvent.class, new EventListener<ResolutionOrSkinChangedEvent>() {
@Override @Override
public void onEvent(ResolutionOrSkinChangedEvent event) { public void onEvent(ResolutionOrSkinChangedEvent event) {
calculatePositions(); calculatePositions();

View File

@ -22,6 +22,7 @@ import itdelatrisu.opsu.ui.Fonts;
import org.newdawn.slick.Color; import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics; import org.newdawn.slick.Graphics;
import yugecin.opsudance.core.DisplayContainer; import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.core.events.EventListener; import yugecin.opsudance.core.events.EventListener;
import yugecin.opsudance.events.ResolutionOrSkinChangedEvent; import yugecin.opsudance.events.ResolutionOrSkinChangedEvent;
import yugecin.opsudance.utils.FPSMeter; import yugecin.opsudance.utils.FPSMeter;
@ -44,7 +45,7 @@ public class FpsRenderState implements EventListener<ResolutionOrSkinChangedEven
this.displayContainer = displayContainer; this.displayContainer = displayContainer;
fpsMeter = new FPSMeter(10); fpsMeter = new FPSMeter(10);
upsMeter = new FPSMeter(10); upsMeter = new FPSMeter(10);
displayContainer.eventBus.subscribe(ResolutionOrSkinChangedEvent.class, this); EventBus.subscribe(ResolutionOrSkinChangedEvent.class, this);
} }
public void update() { public void update() {

View File

@ -186,7 +186,7 @@ public class MoveStoryboard extends OverlayOpsuState{
private StoryboardMove getCurrentMoveOrCreateNew() { private StoryboardMove getCurrentMoveOrCreateNew() {
if (gameObjects[objectIndex].isSlider() && trackPosition > gameObjects[objectIndex].getTime() && trackPosition < gameObjects[objectIndex].getEndTime()) { if (gameObjects[objectIndex].isSlider() && trackPosition > gameObjects[objectIndex].getTime() && trackPosition < gameObjects[objectIndex].getEndTime()) {
EventBus.instance.post(new BarNotificationEvent("Wait until the slider ended")); EventBus.post(new BarNotificationEvent("Wait until the slider ended"));
return dummyMove; return dummyMove;
} }
if (moves[objectIndex] == null) { if (moves[objectIndex] == null) {

View File

@ -20,6 +20,7 @@ package yugecin.opsudance.states;
import org.newdawn.slick.Color; import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics; import org.newdawn.slick.Graphics;
import yugecin.opsudance.core.DisplayContainer; import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.core.state.OpsuState; import yugecin.opsudance.core.state.OpsuState;
import yugecin.opsudance.events.BarNotificationEvent; import yugecin.opsudance.events.BarNotificationEvent;
import yugecin.opsudance.events.BubbleNotificationEvent; import yugecin.opsudance.events.BubbleNotificationEvent;
@ -74,7 +75,7 @@ public class EmptyRedState implements OpsuState {
@Override @Override
public boolean keyPressed(int key, char c) { public boolean keyPressed(int key, char c) {
displayContainer.eventBus.post(new BubbleNotificationEvent("this is a bubble notification... bubbly bubbly bubbly linewraaaaaaaaaap", BubbleNotificationEvent.COMMONCOLOR_RED)); EventBus.post(new BubbleNotificationEvent("this is a bubble notification... bubbly bubbly bubbly linewraaaaaaaaaap", BubbleNotificationEvent.COMMONCOLOR_RED));
return false; return false;
} }
@ -85,7 +86,7 @@ public class EmptyRedState implements OpsuState {
@Override @Override
public boolean mouseWheelMoved(int delta) { public boolean mouseWheelMoved(int delta) {
displayContainer.eventBus.post(new BubbleNotificationEvent("Life is like a box of chocolates. It's all going to melt by the end of the day.\n-Emily", BubbleNotificationEvent.COMMONCOLOR_PURPLE)); EventBus.post(new BubbleNotificationEvent("Life is like a box of chocolates. It's all going to melt by the end of the day.\n-Emily", BubbleNotificationEvent.COMMONCOLOR_PURPLE));
return false; return false;
} }
@ -96,7 +97,7 @@ public class EmptyRedState implements OpsuState {
@Override @Override
public boolean mouseReleased(int button, int x, int y) { public boolean mouseReleased(int button, int x, int y) {
displayContainer.eventBus.post(new BarNotificationEvent("this is a\nbar notification")); EventBus.post(new BarNotificationEvent("this is a\nbar notification"));
return false; return false;
} }