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

@@ -280,7 +280,7 @@ public class DownloadsMenu extends ComplexOpsuState {
this.importedNode = BeatmapParser.parseDirectories(dirs);
if (importedNode != null) {
// 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)));
}
}
@@ -687,7 +687,7 @@ public class DownloadsMenu extends ComplexOpsuState {
if (playing)
previewID = node.getID();
} 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);
}
}
@@ -710,7 +710,7 @@ public class DownloadsMenu extends ComplexOpsuState {
if (!DownloadList.get().contains(node.getID())) {
node.createDownload(serverMenu.getSelectedItem());
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 {
DownloadList.get().addNode(node);
node.getDownload().start();
@@ -952,7 +952,7 @@ public class DownloadsMenu extends ComplexOpsuState {
pageDir = Page.RESET;
previewID = -1;
if (barNotificationOnLoad != null) {
EventBus.instance.post(new BarNotificationEvent(barNotificationOnLoad));
EventBus.post(new BarNotificationEvent(barNotificationOnLoad));
barNotificationOnLoad = null;
}
}

View File

@@ -344,7 +344,7 @@ public class Game extends ComplexOpsuState {
gOffscreen.setBackground(Color.black);
} catch (SlickException 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
@@ -1184,7 +1184,7 @@ public class Game extends ComplexOpsuState {
int position = (pauseTime > -1) ? pauseTime : trackPosition;
if (Options.setCheckpoint(position / 1000)) {
SoundController.playSound(SoundEffect.MENUCLICK);
EventBus.instance.post(new BarNotificationEvent("Checkpoint saved."));
EventBus.post(new BarNotificationEvent("Checkpoint saved."));
}
}
break;
@@ -1196,7 +1196,7 @@ public class Game extends ComplexOpsuState {
break; // invalid checkpoint
loadCheckpoint(checkpoint);
SoundController.playSound(SoundEffect.MENUHIT);
EventBus.instance.post(new BarNotificationEvent("Checkpoint loaded."));
EventBus.post(new BarNotificationEvent("Checkpoint loaded."));
}
break;
case Input.KEY_F:
@@ -1241,12 +1241,12 @@ public class Game extends ComplexOpsuState {
break;
case Input.KEY_MINUS:
currentMapMusicOffset += 5;
EventBus.instance.post(new BarNotificationEvent("Current map offset: " + currentMapMusicOffset));
EventBus.post(new BarNotificationEvent("Current map offset: " + currentMapMusicOffset));
break;
}
if (key == Input.KEY_ADD || c == '+') {
currentMapMusicOffset -= 5;
EventBus.instance.post(new BarNotificationEvent("Current map offset: " + currentMapMusicOffset));
EventBus.post(new BarNotificationEvent("Current map offset: " + currentMapMusicOffset));
}
return true;
@@ -1466,7 +1466,7 @@ public class Game extends ComplexOpsuState {
}
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);
}
@@ -1568,7 +1568,7 @@ public class Game extends ComplexOpsuState {
} catch (Exception e) {
String message = String.format("Failed to create %s at index %d:\n%s", hitObject.getTypeName(), i, hitObject.toString());
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);
}
}
@@ -2154,7 +2154,7 @@ public class Game extends ComplexOpsuState {
this.replay = null;
} else {
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;
}
this.isReplay = true;

View File

@@ -166,13 +166,13 @@ public class GameRanking extends BaseOpsuState {
gameState.setRestart((data.isGameplay()) ? Game.Restart.REPLAY : Game.Restart.NEW);
returnToGame = true;
} catch (FileNotFoundException e) {
EventBus.instance.post(new BarNotificationEvent("Replay file not found."));
EventBus.post(new BarNotificationEvent("Replay file not found."));
} catch (IOException 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
EventBus.instance.post(new BarNotificationEvent("Replay file not found."));
EventBus.post(new BarNotificationEvent("Replay file not found."));
}
// retry

View File

@@ -471,10 +471,10 @@ public class MainMenu extends BaseOpsuState {
UI.enter();
if (!enterNotification) {
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;
} 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;
}
}
@@ -537,15 +537,15 @@ public class MainMenu extends BaseOpsuState {
if (musicPlay.contains(x, y)) {
if (MusicController.isPlaying()) {
MusicController.pause();
EventBus.instance.post(new BarNotificationEvent("Pause"));
EventBus.post(new BarNotificationEvent("Pause"));
} else if (!MusicController.isTrackLoading()) {
MusicController.resume();
EventBus.instance.post(new BarNotificationEvent("Play"));
EventBus.post(new BarNotificationEvent("Play"));
}
return true;
} else if (musicNext.contains(x, y)) {
nextTrack(true);
EventBus.instance.post(new BarNotificationEvent(">> Next"));
EventBus.post(new BarNotificationEvent(">> Next"));
return true;
} else if (musicPrevious.contains(x, y)) {
lastMeasureProgress = 0f;
@@ -555,7 +555,7 @@ public class MainMenu extends BaseOpsuState {
bgAlpha.setTime(0);
} else
MusicController.setPosition(0);
EventBus.instance.post(new BarNotificationEvent("<< Previous"));
EventBus.post(new BarNotificationEvent("<< Previous"));
return true;
}
@@ -571,10 +571,10 @@ public class MainMenu extends BaseOpsuState {
try {
Desktop.getDesktop().browse(Options.REPOSITORY_URI);
} 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) {
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;
}
@@ -583,10 +583,10 @@ public class MainMenu extends BaseOpsuState {
try {
Desktop.getDesktop().browse(Options.DANCE_REPOSITORY_URI);
} 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) {
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;
}

View File

@@ -455,7 +455,7 @@ public class SongMenu extends ComplexOpsuState {
if (!songFolderChanged && kind != StandardWatchEventKinds.ENTRY_MODIFY) {
songFolderChanged = true;
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);
if (BeatmapSetList.get().size() < 1 && group.getEmptyMessage() != null) {
EventBus.instance.post(new BarNotificationEvent(group.getEmptyMessage()));
EventBus.post(new BarNotificationEvent(group.getEmptyMessage()));
}
}
return true;
@@ -1773,7 +1773,7 @@ public class SongMenu extends ComplexOpsuState {
Beatmap beatmap = MusicController.getBeatmap();
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;
}