TextField updates, and bug fixes from some recent commits.

- Added modified copy of slick.gui.TextField: added CTRL+BACKSPACE for word deletion, and disabled left/right arrows to move cursor and CTRL+Z to undo.
- Fixed musicEnded() incorrectly setting the "trackEnded" upon swapping tracks.  This has caused some nasty loops since #38.
- Fixed a null pointer exception in OsuDB from 0b03912.
- Fixed the song menu search bar transition being incorrectly reset when hitting backspace on a 0-length query.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han
2015-03-08 16:34:28 -04:00
parent 0b03912b7a
commit dc26f6c131
6 changed files with 559 additions and 11 deletions

View File

@@ -254,6 +254,7 @@ public class OsuGroupList {
/**
* Returns the OsuGroupNode at an index, disregarding expansions.
* @param index the node index
*/
public OsuGroupNode getBaseNode(int index) {
if (index < 0 || index >= size())

View File

@@ -111,7 +111,10 @@ public class MusicController {
player = new Music(file.getPath(), true);
player.addListener(new MusicListener() {
@Override
public void musicEnded(Music music) { trackEnded = true; }
public void musicEnded(Music music) {
if (music == player) // don't fire if music swapped
trackEnded = true;
}
@Override
public void musicSwapped(Music music, Music newMusic) {}

View File

@@ -76,12 +76,6 @@ public class OsuDB {
// create the database
createDatabase();
// retrieve the cache size
getCacheSize();
// check the database version
checkVersion();
// prepare sql statements
try {
insertStmt = connection.prepareStatement(
@@ -96,6 +90,12 @@ public class OsuDB {
} catch (SQLException e) {
ErrorHandler.error("Failed to prepare beatmap statements.", e, true);
}
// retrieve the cache size
getCacheSize();
// check the database version
checkVersion();
}
/**

View File

@@ -199,6 +199,9 @@ public class SongMenu extends BasicGameState {
/** Time, in milliseconds, for fading the search bar. */
private int searchTransitionTimer = SEARCH_TRANSITION_TIME;
/** The text length of the last string in the search TextField. */
private int lastSearchTextLength = -1;
// game-related variables
private GameContainer container;
private StateBasedGame game;
@@ -831,11 +834,14 @@ public class SongMenu extends BasicGameState {
if ((c > 31 && c < 127) || key == Input.KEY_BACK) {
searchTimer = 0;
int textLength = search.getText().length();
if (key == Input.KEY_BACK) {
if (textLength == 0)
if (lastSearchTextLength != textLength) {
if (key == Input.KEY_BACK) {
if (textLength == 0)
searchTransitionTimer = 0;
} else if (textLength == 1)
searchTransitionTimer = 0;
} else if (textLength == 1)
searchTransitionTimer = 0;
lastSearchTextLength = textLength;
}
}
break;
}