Quick fixes.

- Fixed a crash when closing the application in the ranking screen when viewing a score.
- Fixed a minor bug where OsuGroupList fields were not being erased upon restart.
- Dim the track volume by 50% when viewing a score.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-01-28 20:57:43 -05:00
parent ce15f25ca1
commit 2007058eb1
7 changed files with 48 additions and 15 deletions

View File

@ -95,6 +95,10 @@ public class Container extends AppGameContainer {
// prevent loading tracks from re-initializing OpenAL
MusicController.reset();
// reset OsuGroupList data
if (OsuGroupList.get() != null)
OsuGroupList.get().reset();
}
@Override

View File

@ -175,12 +175,20 @@ public class Opsu extends StateBasedGame {
if (id == STATE_GAME || id == STATE_GAMEPAUSEMENU || id == STATE_GAMERANKING) {
// start playing track at preview position
SongMenu songMenu = (SongMenu) this.getState(Opsu.STATE_SONGMENU);
songMenu.resetGameDataOnLoad();
if (id == STATE_GAME) {
MusicController.pause();
MusicController.resume();
} else
songMenu.resetTrackOnLoad();
if (id == STATE_GAMERANKING) {
GameData data = ((GameRanking) this.getState(Opsu.STATE_GAMERANKING)).getGameData();
if (data != null && data.isGameplay()) {
songMenu.resetGameDataOnLoad();
songMenu.resetTrackOnLoad();
}
} else {
songMenu.resetGameDataOnLoad();
if (id == STATE_GAME) {
MusicController.pause();
MusicController.resume();
} else
songMenu.resetTrackOnLoad();
}
Utils.resetCursor();
this.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
return false;

View File

@ -48,10 +48,10 @@ public class OsuGroupList {
private ArrayList<OsuGroupNode> nodes;
/** Index of current expanded node (-1 if no node is expanded). */
private int expandedIndex = -1;
private int expandedIndex;
/** The last search query. */
private String lastQuery = "";
private String lastQuery;
/**
* Creates a new instance of this class (overwriting any previous instance).
@ -68,7 +68,17 @@ public class OsuGroupList {
*/
private OsuGroupList() {
parsedNodes = new ArrayList<OsuGroupNode>();
reset();
}
/**
* Resets the list's fields.
* This does not erase any parsed nodes.
*/
public void reset() {
nodes = parsedNodes;
expandedIndex = -1;
lastQuery = "";
}
/**

View File

@ -289,10 +289,11 @@ public class MusicController {
/**
* Toggles the volume dim state of the current track.
* @param multiplier the volume multiplier when the track is dimmed
*/
public static void toggleTrackDimmed() {
public static void toggleTrackDimmed(float multiplier) {
float volume = Options.getMusicVolume() * Options.getMasterVolume();
setVolume((trackDimmed) ? volume : volume / 3f);
setVolume((trackDimmed) ? volume : volume * multiplier);
trackDimmed = !trackDimmed;
}

View File

@ -171,7 +171,10 @@ public class GameRanking extends BasicGameState {
throws SlickException {
Display.setTitle(game.getTitle());
Utils.getBackButton().setScale(1f);
if (data.isGameplay())
if (!data.isGameplay()) {
if (!MusicController.isTrackDimmed())
MusicController.toggleTrackDimmed(0.5f);
} else
SoundController.playSound(SoundEffect.APPLAUSE);
}
@ -199,7 +202,10 @@ public class GameRanking extends BasicGameState {
* Sets the associated GameData object.
* @param data the GameData
*/
public void setGameData(GameData data) {
this.data = data;
}
public void setGameData(GameData data) { this.data = data; }
/**
* Returns the current GameData object (usually null unless state active).
*/
public GameData getGameData() { return data; }
}

View File

@ -249,7 +249,7 @@ public class MainMenu extends BasicGameState {
// window focus change: increase/decrease theme song volume
if (MusicController.isThemePlaying() &&
MusicController.isTrackDimmed() == container.hasFocus())
MusicController.toggleTrackDimmed();
MusicController.toggleTrackDimmed(0.33f);
// fade in background
if (bgAlpha < 0.9f) {

View File

@ -777,6 +777,10 @@ public class SongMenu extends BasicGameState {
else if (MusicController.isPaused())
MusicController.resume();
// undim track
if (MusicController.isTrackDimmed())
MusicController.toggleTrackDimmed(1f);
// reset song stack
randomStack = new Stack<SongNode>();