From 9d3a12ad9c3cec75b93a888f79b5d1bb9986cec5 Mon Sep 17 00:00:00 2001 From: Jeffrey Han Date: Sat, 20 Dec 2014 15:30:20 -0500 Subject: [PATCH] Display checkpoint time on game screen after loading. Also fixed some indentation issues. Signed-off-by: Jeffrey Han --- src/itdelatrisu/opsu/MusicController.java | 4 ++-- src/itdelatrisu/opsu/OszUnpacker.java | 12 ++++++------ src/itdelatrisu/opsu/Utils.java | 8 ++++---- src/itdelatrisu/opsu/objects/Slider.java | 8 ++++---- src/itdelatrisu/opsu/states/Game.java | 9 ++++++++- src/itdelatrisu/opsu/states/SongMenu.java | 2 +- 6 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/itdelatrisu/opsu/MusicController.java b/src/itdelatrisu/opsu/MusicController.java index fd69accb..46a624da 100644 --- a/src/itdelatrisu/opsu/MusicController.java +++ b/src/itdelatrisu/opsu/MusicController.java @@ -139,14 +139,14 @@ public class MusicController { * Converts an MP3 file to a temporary WAV file. */ private static File convertMp3(File file) { - try { + try { wavFile = File.createTempFile(".osu", ".wav", Options.TMP_DIR); wavFile.deleteOnExit(); Converter converter = new Converter(); converter.convert(file.getPath(), wavFile.getPath()); return wavFile; - } catch (Exception e) { + } catch (Exception e) { Log.error(String.format("Failed to play file '%s'.", file.getAbsolutePath()), e); } return wavFile; diff --git a/src/itdelatrisu/opsu/OszUnpacker.java b/src/itdelatrisu/opsu/OszUnpacker.java index 5acb5084..0ab56bd3 100644 --- a/src/itdelatrisu/opsu/OszUnpacker.java +++ b/src/itdelatrisu/opsu/OszUnpacker.java @@ -79,12 +79,12 @@ public class OszUnpacker { * @param dest the destination directory */ private static void unzip(File file, File dest) { - try { - ZipFile zipFile = new ZipFile(file); - zipFile.extractAll(dest.getAbsolutePath()); - } catch (ZipException e) { - e.printStackTrace(); - } + try { + ZipFile zipFile = new ZipFile(file); + zipFile.extractAll(dest.getAbsolutePath()); + } catch (ZipException e) { + e.printStackTrace(); + } } /** diff --git a/src/itdelatrisu/opsu/Utils.java b/src/itdelatrisu/opsu/Utils.java index 5796ecec..247f5073 100644 --- a/src/itdelatrisu/opsu/Utils.java +++ b/src/itdelatrisu/opsu/Utils.java @@ -145,10 +145,10 @@ public class Utils { // set the cursor try { // hide the native cursor - int min = Cursor.getMinCursorSize(); - IntBuffer tmp = BufferUtils.createIntBuffer(min * min); - Cursor emptyCursor = new Cursor(min, min, min/2, min/2, 1, tmp, null); - container.setMouseCursor(emptyCursor, 0, 0); + int min = Cursor.getMinCursorSize(); + IntBuffer tmp = BufferUtils.createIntBuffer(min * min); + Cursor emptyCursor = new Cursor(min, min, min/2, min/2, 1, tmp, null); + container.setMouseCursor(emptyCursor, 0, 0); } catch (LWJGLException e) { Log.error("Failed to set the cursor.", e); } diff --git a/src/itdelatrisu/opsu/objects/Slider.java b/src/itdelatrisu/opsu/objects/Slider.java index e08d704e..e51cc195 100644 --- a/src/itdelatrisu/opsu/objects/Slider.java +++ b/src/itdelatrisu/opsu/objects/Slider.java @@ -236,8 +236,8 @@ public class Slider { int n = order - 1; if (n < 4) { // normal curve for (int i = 0; i <= n; i++) { - c[0] += getX(i) * bernstein(i, n, t); - c[1] += getY(i) * bernstein(i, n, t); + c[0] += getX(i) * bernstein(i, n, t); + c[1] += getY(i) * bernstein(i, n, t); } } else { // split curve into path // TODO: this is probably wrong... @@ -247,8 +247,8 @@ public class Slider { int segmentOrder = Math.min(startIndex + 3, n) - startIndex; float segmentT = (t * segmentCount) - segment; for (int i = 0; i <= segmentOrder; i++) { - c[0] += getX(i + startIndex) * bernstein(i, segmentOrder, segmentT); - c[1] += getY(i + startIndex) * bernstein(i, segmentOrder, segmentT); + c[0] += getX(i + startIndex) * bernstein(i, segmentOrder, segmentT); + c[1] += getY(i + startIndex) * bernstein(i, segmentOrder, segmentT); } } return c; diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index e43264fc..e67a650c 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -36,6 +36,7 @@ import itdelatrisu.opsu.objects.Spinner; import java.io.File; import java.util.HashMap; import java.util.Stack; +import java.util.concurrent.TimeUnit; import org.lwjgl.input.Keyboard; import org.newdawn.slick.Color; @@ -248,7 +249,13 @@ public class Game extends BasicGameState { // checkpoint if (checkpointLoaded) { - String checkpointText = "~ Playing from checkpoint. ~"; + int checkpoint = Options.getCheckpoint(); + String checkpointText = String.format( + "~ Playing from checkpoint at %02d:%02d. ~", + TimeUnit.MILLISECONDS.toMinutes(checkpoint), + TimeUnit.MILLISECONDS.toSeconds(checkpoint) - + TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(checkpoint)) + ); Utils.FONT_MEDIUM.drawString( (container.getWidth() - Utils.FONT_MEDIUM.getWidth(checkpointText)) / 2, container.getHeight() - 15 - Utils.FONT_MEDIUM.getLineHeight(), diff --git a/src/itdelatrisu/opsu/states/SongMenu.java b/src/itdelatrisu/opsu/states/SongMenu.java index bdfd53fc..566cd27c 100644 --- a/src/itdelatrisu/opsu/states/SongMenu.java +++ b/src/itdelatrisu/opsu/states/SongMenu.java @@ -526,7 +526,7 @@ public class SongMenu extends BasicGameState { buttonY = height * 0.18f; shift++; } else if (shift > 0 && startNode.next != null && - Opsu.groups.getNode(startNode, MAX_BUTTONS) != null) { + Opsu.groups.getNode(startNode, MAX_BUTTONS) != null) { startNode = startNode.next; buttonY -= buttonOffset / 4; if (buttonY < height * 0.14f)