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:
@@ -95,6 +95,10 @@ public class Container extends AppGameContainer {
|
|||||||
|
|
||||||
// prevent loading tracks from re-initializing OpenAL
|
// prevent loading tracks from re-initializing OpenAL
|
||||||
MusicController.reset();
|
MusicController.reset();
|
||||||
|
|
||||||
|
// reset OsuGroupList data
|
||||||
|
if (OsuGroupList.get() != null)
|
||||||
|
OsuGroupList.get().reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -175,12 +175,20 @@ public class Opsu extends StateBasedGame {
|
|||||||
if (id == STATE_GAME || id == STATE_GAMEPAUSEMENU || id == STATE_GAMERANKING) {
|
if (id == STATE_GAME || id == STATE_GAMEPAUSEMENU || id == STATE_GAMERANKING) {
|
||||||
// start playing track at preview position
|
// start playing track at preview position
|
||||||
SongMenu songMenu = (SongMenu) this.getState(Opsu.STATE_SONGMENU);
|
SongMenu songMenu = (SongMenu) this.getState(Opsu.STATE_SONGMENU);
|
||||||
songMenu.resetGameDataOnLoad();
|
if (id == STATE_GAMERANKING) {
|
||||||
if (id == STATE_GAME) {
|
GameData data = ((GameRanking) this.getState(Opsu.STATE_GAMERANKING)).getGameData();
|
||||||
MusicController.pause();
|
if (data != null && data.isGameplay()) {
|
||||||
MusicController.resume();
|
songMenu.resetGameDataOnLoad();
|
||||||
} else
|
songMenu.resetTrackOnLoad();
|
||||||
songMenu.resetTrackOnLoad();
|
}
|
||||||
|
} else {
|
||||||
|
songMenu.resetGameDataOnLoad();
|
||||||
|
if (id == STATE_GAME) {
|
||||||
|
MusicController.pause();
|
||||||
|
MusicController.resume();
|
||||||
|
} else
|
||||||
|
songMenu.resetTrackOnLoad();
|
||||||
|
}
|
||||||
Utils.resetCursor();
|
Utils.resetCursor();
|
||||||
this.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
this.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ public class OsuGroupList {
|
|||||||
private ArrayList<OsuGroupNode> nodes;
|
private ArrayList<OsuGroupNode> nodes;
|
||||||
|
|
||||||
/** Index of current expanded node (-1 if no node is expanded). */
|
/** Index of current expanded node (-1 if no node is expanded). */
|
||||||
private int expandedIndex = -1;
|
private int expandedIndex;
|
||||||
|
|
||||||
/** The last search query. */
|
/** The last search query. */
|
||||||
private String lastQuery = "";
|
private String lastQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of this class (overwriting any previous instance).
|
* Creates a new instance of this class (overwriting any previous instance).
|
||||||
@@ -68,7 +68,17 @@ public class OsuGroupList {
|
|||||||
*/
|
*/
|
||||||
private OsuGroupList() {
|
private OsuGroupList() {
|
||||||
parsedNodes = new ArrayList<OsuGroupNode>();
|
parsedNodes = new ArrayList<OsuGroupNode>();
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the list's fields.
|
||||||
|
* This does not erase any parsed nodes.
|
||||||
|
*/
|
||||||
|
public void reset() {
|
||||||
nodes = parsedNodes;
|
nodes = parsedNodes;
|
||||||
|
expandedIndex = -1;
|
||||||
|
lastQuery = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -289,10 +289,11 @@ public class MusicController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggles the volume dim state of the current track.
|
* 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();
|
float volume = Options.getMusicVolume() * Options.getMasterVolume();
|
||||||
setVolume((trackDimmed) ? volume : volume / 3f);
|
setVolume((trackDimmed) ? volume : volume * multiplier);
|
||||||
trackDimmed = !trackDimmed;
|
trackDimmed = !trackDimmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -171,7 +171,10 @@ public class GameRanking extends BasicGameState {
|
|||||||
throws SlickException {
|
throws SlickException {
|
||||||
Display.setTitle(game.getTitle());
|
Display.setTitle(game.getTitle());
|
||||||
Utils.getBackButton().setScale(1f);
|
Utils.getBackButton().setScale(1f);
|
||||||
if (data.isGameplay())
|
if (!data.isGameplay()) {
|
||||||
|
if (!MusicController.isTrackDimmed())
|
||||||
|
MusicController.toggleTrackDimmed(0.5f);
|
||||||
|
} else
|
||||||
SoundController.playSound(SoundEffect.APPLAUSE);
|
SoundController.playSound(SoundEffect.APPLAUSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +202,10 @@ public class GameRanking extends BasicGameState {
|
|||||||
* Sets the associated GameData object.
|
* Sets the associated GameData object.
|
||||||
* @param data the GameData
|
* @param data the GameData
|
||||||
*/
|
*/
|
||||||
public void setGameData(GameData data) {
|
public void setGameData(GameData data) { this.data = data; }
|
||||||
this.data = data;
|
|
||||||
}
|
/**
|
||||||
|
* Returns the current GameData object (usually null unless state active).
|
||||||
|
*/
|
||||||
|
public GameData getGameData() { return data; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ public class MainMenu extends BasicGameState {
|
|||||||
// window focus change: increase/decrease theme song volume
|
// window focus change: increase/decrease theme song volume
|
||||||
if (MusicController.isThemePlaying() &&
|
if (MusicController.isThemePlaying() &&
|
||||||
MusicController.isTrackDimmed() == container.hasFocus())
|
MusicController.isTrackDimmed() == container.hasFocus())
|
||||||
MusicController.toggleTrackDimmed();
|
MusicController.toggleTrackDimmed(0.33f);
|
||||||
|
|
||||||
// fade in background
|
// fade in background
|
||||||
if (bgAlpha < 0.9f) {
|
if (bgAlpha < 0.9f) {
|
||||||
|
|||||||
@@ -777,6 +777,10 @@ public class SongMenu extends BasicGameState {
|
|||||||
else if (MusicController.isPaused())
|
else if (MusicController.isPaused())
|
||||||
MusicController.resume();
|
MusicController.resume();
|
||||||
|
|
||||||
|
// undim track
|
||||||
|
if (MusicController.isTrackDimmed())
|
||||||
|
MusicController.toggleTrackDimmed(1f);
|
||||||
|
|
||||||
// reset song stack
|
// reset song stack
|
||||||
randomStack = new Stack<SongNode>();
|
randomStack = new Stack<SongNode>();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user