got rid of dependency injection, it doesn't add anything at this point and only slows down things and makes a mess. Also some refactoring.

This commit is contained in:
yugecin
2017-05-21 11:12:55 +02:00
parent 1ebf2c2dcb
commit ec53f531c8
72 changed files with 675 additions and 929 deletions

View File

@@ -45,14 +45,14 @@ import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.Constants;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.core.inject.Inject;
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;
import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.options.Options.*;
/**
@@ -62,12 +62,6 @@ import static yugecin.opsudance.options.Options.*;
*/
public class MainMenu extends BaseOpsuState {
@Inject
private InstanceContainer instanceContainer;
@Inject
private Updater updater;
/** Idle time, in milliseconds, before returning the logo to its original position. */
private static final short LOGO_IDLE_DELAY = 10000;
@@ -551,7 +545,7 @@ public class MainMenu extends BaseOpsuState {
} else if (musicPrevious.contains(x, y)) {
lastMeasureProgress = 0f;
if (!previous.isEmpty()) {
instanceContainer.provide(SongMenu.class).setFocus(BeatmapSetList.get().getBaseNode(previous.pop()), -1, true, false);
songMenuState.setFocus(BeatmapSetList.get().getBaseNode(previous.pop()), -1, true, false);
if (OPTION_DYNAMIC_BACKGROUND.state) {
bgAlpha.setTime(0);
}
@@ -565,14 +559,14 @@ public class MainMenu extends BaseOpsuState {
// downloads button actions
if (downloadsButton.contains(x, y)) {
SoundController.playSound(SoundEffect.MENUHIT);
displayContainer.switchState(DownloadsMenu.class);
displayContainer.switchState(downloadState);
return true;
}
// repository button actions
if (repoButton != null && repoButton.contains(x, y)) {
try {
Desktop.getDesktop().browse(config.REPOSITORY_URI);
Desktop.getDesktop().browse(Constants.REPOSITORY_URI);
} catch (UnsupportedOperationException e) {
EventBus.post(new BarNotificationEvent("The repository web page could not be opened."));
} catch (IOException e) {
@@ -584,7 +578,7 @@ public class MainMenu extends BaseOpsuState {
if (danceRepoButton != null && danceRepoButton.contains(x, y)) {
try {
Desktop.getDesktop().browse(config.DANCE_REPOSITORY_URI);
Desktop.getDesktop().browse(Constants.DANCE_REPOSITORY_URI);
} catch (UnsupportedOperationException e) {
EventBus.post(new BarNotificationEvent("The repository web page could not be opened."));
} catch (IOException e) {
@@ -665,8 +659,8 @@ public class MainMenu extends BaseOpsuState {
logoTimer = 0;
break;
}
instanceContainer.provide(ButtonMenu.class).setMenuState(MenuState.EXIT);
displayContainer.switchState(ButtonMenu.class);
buttonState.setMenuState(MenuState.EXIT);
displayContainer.switchState(buttonState);
return true;
case Input.KEY_P:
SoundController.playSound(SoundEffect.MENUHIT);
@@ -681,7 +675,7 @@ public class MainMenu extends BaseOpsuState {
return true;
case Input.KEY_D:
SoundController.playSound(SoundEffect.MENUHIT);
displayContainer.switchState(DownloadsMenu.class);
displayContainer.switchState(downloadState);
return true;
case Input.KEY_R:
nextTrack(true);
@@ -719,7 +713,7 @@ public class MainMenu extends BaseOpsuState {
MusicController.playAt(0, false);
return;
}
BeatmapSetNode node = instanceContainer.provide(SongMenu.class).setFocus(BeatmapSetList.get().getRandomNode(), -1, true, false);
BeatmapSetNode node = songMenuState.setFocus(BeatmapSetList.get().getRandomNode(), -1, true, false);
boolean sameAudio = false;
if (node != null) {
sameAudio = MusicController.getBeatmap().audioFilename.equals(node.getBeatmapSet().get(0).audioFilename);
@@ -735,10 +729,10 @@ public class MainMenu extends BaseOpsuState {
* Enters the song menu, or the downloads menu if no beatmaps are loaded.
*/
private void enterSongMenu() {
Class<? extends OpsuState> state = SongMenu.class;
OpsuState state = songMenuState;
if (BeatmapSetList.get().getMapSetCount() == 0) {
instanceContainer.provide(DownloadsMenu.class).notifyOnLoad("Download some beatmaps to get started!");
state = DownloadsMenu.class;
downloadState.notifyOnLoad("Download some beatmaps to get started!");
state = downloadState;
}
displayContainer.switchState(state);
}