replace all calls to old bar notif with new method

This commit is contained in:
yugecin
2017-01-21 23:52:19 +01:00
parent 02ef422003
commit 36aaccda29
11 changed files with 55 additions and 42 deletions

View File

@@ -20,7 +20,6 @@ package itdelatrisu.opsu.states;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
@@ -57,8 +56,10 @@ import org.newdawn.slick.SlickException;
import org.newdawn.slick.gui.TextField;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.core.inject.InstanceContainer;
import yugecin.opsudance.core.state.ComplexOpsuState;
import yugecin.opsudance.events.BarNotificationEvent;
/**
* Downloads menu.
@@ -279,8 +280,8 @@ public class DownloadsMenu extends ComplexOpsuState {
this.importedNode = BeatmapParser.parseDirectories(dirs);
if (importedNode != null) {
// send notification
UI.sendBarNotification((dirs.length == 1) ? "Imported 1 new song." :
String.format("Imported %d new songs.", dirs.length));
EventBus.instance.post(new BarNotificationEvent((dirs.length == 1) ? "Imported 1 new song." :
String.format("Imported %d new songs.", dirs.length)));
}
}
@@ -686,7 +687,7 @@ public class DownloadsMenu extends ComplexOpsuState {
if (playing)
previewID = node.getID();
} catch (SlickException e) {
UI.sendBarNotification("Failed to load track preview. See log for details.");
EventBus.instance.post(new BarNotificationEvent("Failed to load track preview. See log for details."));
Log.error(e);
}
}
@@ -708,9 +709,9 @@ public class DownloadsMenu extends ComplexOpsuState {
// start download
if (!DownloadList.get().contains(node.getID())) {
node.createDownload(serverMenu.getSelectedItem());
if (node.getDownload() == null)
UI.sendBarNotification("The download could not be started.");
else {
if (node.getDownload() == null) {
EventBus.instance.post(new BarNotificationEvent("The download could not be started"));
} else {
DownloadList.get().addNode(node);
node.getDownload().start();
}
@@ -953,7 +954,7 @@ public class DownloadsMenu extends ComplexOpsuState {
pageDir = Page.RESET;
previewID = -1;
if (barNotificationOnLoad != null) {
UI.sendBarNotification(barNotificationOnLoad);
EventBus.instance.post(new BarNotificationEvent(barNotificationOnLoad));
barNotificationOnLoad = null;
}
}

View File

@@ -64,10 +64,12 @@ import org.newdawn.slick.SlickException;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.*;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.core.inject.InstanceContainer;
import yugecin.opsudance.core.state.ComplexOpsuState;
import yugecin.opsudance.core.state.transitions.FadeInTransitionState;
import yugecin.opsudance.core.state.transitions.FadeOutTransitionState;
import yugecin.opsudance.events.BarNotificationEvent;
import yugecin.opsudance.events.BubbleNotificationEvent;
import yugecin.opsudance.objects.curves.FakeCombinedCurve;
import yugecin.opsudance.sbv2.MoveStoryboard;
@@ -1186,7 +1188,7 @@ public class Game extends ComplexOpsuState {
int position = (pauseTime > -1) ? pauseTime : trackPosition;
if (Options.setCheckpoint(position / 1000)) {
SoundController.playSound(SoundEffect.MENUCLICK);
UI.sendBarNotification("Checkpoint saved.");
EventBus.instance.post(new BarNotificationEvent("Checkpoint saved."));
}
}
break;
@@ -1198,7 +1200,7 @@ public class Game extends ComplexOpsuState {
break; // invalid checkpoint
loadCheckpoint(checkpoint);
SoundController.playSound(SoundEffect.MENUHIT);
UI.sendBarNotification("Checkpoint loaded.");
EventBus.instance.post(new BarNotificationEvent("Checkpoint loaded."));
}
break;
case Input.KEY_F:
@@ -1243,12 +1245,12 @@ public class Game extends ComplexOpsuState {
break;
case Input.KEY_MINUS:
currentMapMusicOffset += 5;
UI.sendBarNotification("Current map offset: " + currentMapMusicOffset);
EventBus.instance.post(new BarNotificationEvent("Current map offset: " + currentMapMusicOffset));
break;
}
if (key == Input.KEY_ADD || c == '+') {
currentMapMusicOffset -= 5;
UI.sendBarNotification("Current map offset: " + currentMapMusicOffset);
EventBus.instance.post(new BarNotificationEvent("Current map offset: " + currentMapMusicOffset));
}
return true;

View File

@@ -37,8 +37,10 @@ import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.core.inject.InstanceContainer;
import yugecin.opsudance.core.state.BaseOpsuState;
import yugecin.opsudance.events.BarNotificationEvent;
/**
* "Game Ranking" (score card) state.
@@ -167,13 +169,13 @@ public class GameRanking extends BaseOpsuState {
gameState.setRestart((data.isGameplay()) ? Game.Restart.REPLAY : Game.Restart.NEW);
returnToGame = true;
} catch (FileNotFoundException e) {
UI.sendBarNotification("Replay file not found.");
EventBus.instance.post(new BarNotificationEvent("Replay file not found."));
} catch (IOException e) {
Log.error("Failed to load replay data.", e);
UI.sendBarNotification("Failed to load replay data. See log for details.");
EventBus.instance.post(new BarNotificationEvent("Failed to load replay data. See log for details."));
}
} else
UI.sendBarNotification("Replay file not found.");
EventBus.instance.post(new BarNotificationEvent("Replay file not found."));
}
// retry

View File

@@ -51,6 +51,7 @@ import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.core.inject.InstanceContainer;
import yugecin.opsudance.core.state.BaseOpsuState;
import yugecin.opsudance.core.state.OpsuState;
import yugecin.opsudance.events.BarNotificationEvent;
import yugecin.opsudance.events.BubbleNotificationEvent;
/**
@@ -470,10 +471,10 @@ public class MainMenu extends BaseOpsuState {
UI.enter();
if (!enterNotification) {
if (Updater.get().getStatus() == Updater.Status.UPDATE_AVAILABLE) {
UI.sendBarNotification("An opsu! update is available.");
EventBus.instance.post(new BarNotificationEvent("An opsu! update is available."));
enterNotification = true;
} else if (Updater.get().justUpdated()) {
UI.sendBarNotification("opsu! is now up to date!");
EventBus.instance.post(new BarNotificationEvent("opsu! is now up to date!"));
enterNotification = true;
}
}
@@ -536,15 +537,15 @@ public class MainMenu extends BaseOpsuState {
if (musicPlay.contains(x, y)) {
if (MusicController.isPlaying()) {
MusicController.pause();
UI.sendBarNotification("Pause");
EventBus.instance.post(new BarNotificationEvent("Pause"));
} else if (!MusicController.isTrackLoading()) {
MusicController.resume();
UI.sendBarNotification("Play");
EventBus.instance.post(new BarNotificationEvent("Play"));
}
return true;
} else if (musicNext.contains(x, y)) {
nextTrack(true);
UI.sendBarNotification(">> Next");
EventBus.instance.post(new BarNotificationEvent(">> Next"));
return true;
} else if (musicPrevious.contains(x, y)) {
lastMeasureProgress = 0f;
@@ -554,7 +555,7 @@ public class MainMenu extends BaseOpsuState {
bgAlpha.setTime(0);
} else
MusicController.setPosition(0);
UI.sendBarNotification("<< Previous");
EventBus.instance.post(new BarNotificationEvent("<< Previous"));
return true;
}
@@ -570,7 +571,7 @@ public class MainMenu extends BaseOpsuState {
try {
Desktop.getDesktop().browse(Options.REPOSITORY_URI);
} catch (UnsupportedOperationException e) {
UI.sendBarNotification("The repository web page could not be opened.");
EventBus.instance.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));
@@ -582,7 +583,7 @@ public class MainMenu extends BaseOpsuState {
try {
Desktop.getDesktop().browse(Options.DANCE_REPOSITORY_URI);
} catch (UnsupportedOperationException e) {
UI.sendBarNotification("The repository web page could not be opened.");
EventBus.instance.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));

View File

@@ -69,8 +69,10 @@ import org.newdawn.slick.Input;
import org.newdawn.slick.SpriteSheet;
import org.newdawn.slick.gui.TextField;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.core.inject.InstanceContainer;
import yugecin.opsudance.core.state.ComplexOpsuState;
import yugecin.opsudance.events.BarNotificationEvent;
import yugecin.opsudance.ui.OptionsOverlay;
/**
@@ -453,7 +455,7 @@ public class SongMenu extends ComplexOpsuState {
if (!songFolderChanged && kind != StandardWatchEventKinds.ENTRY_MODIFY) {
songFolderChanged = true;
if (displayContainer.isInState(SongMenu.class)) {
UI.sendBarNotification("Changes in Songs folder detected. Hit F5 to refresh.");
EventBus.instance.post(new BarNotificationEvent("Changed is Songs folder detected. Hit F5 to refresh."));
}
}
}
@@ -958,8 +960,9 @@ public class SongMenu extends ComplexOpsuState {
BeatmapSetList.get().init();
setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
if (BeatmapSetList.get().size() < 1 && group.getEmptyMessage() != null)
UI.sendBarNotification(group.getEmptyMessage());
if (BeatmapSetList.get().size() < 1 && group.getEmptyMessage() != null) {
EventBus.instance.post(new BarNotificationEvent(group.getEmptyMessage()));
}
}
return true;
}
@@ -1775,7 +1778,7 @@ public class SongMenu extends ComplexOpsuState {
Beatmap beatmap = MusicController.getBeatmap();
if (focusNode == null || beatmap != focusNode.getSelectedBeatmap()) {
UI.sendBarNotification("Unable to load the beatmap audio.");
EventBus.instance.post(new BarNotificationEvent("Unable to load the beatmap audio."));
return;
}