From 99bc944ed621bede996b7aaa8e782a44b9d4112a Mon Sep 17 00:00:00 2001 From: Jeffrey Han Date: Wed, 11 Feb 2015 02:56:02 -0500 Subject: [PATCH] Minor updates. - Draw the playfield background in the song menu if a background cannot be drawn for the focused beatmap. - Added ScoreDB.deleteScore() method to delete a score from the database. - Added @author tags for curve-related classes (by fluddokt, #12). Signed-off-by: Jeffrey Han --- src/itdelatrisu/opsu/ScoreDB.java | 24 +++++++++++++++++++ .../opsu/objects/curves/Bezier2.java | 2 ++ .../objects/curves/CircumscribedCircle.java | 2 ++ .../opsu/objects/curves/Curve.java | 2 ++ .../opsu/objects/curves/LinearBezier.java | 2 ++ .../opsu/objects/curves/Vec2f.java | 2 ++ src/itdelatrisu/opsu/states/Game.java | 1 + src/itdelatrisu/opsu/states/SongMenu.java | 7 ++++-- 8 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/itdelatrisu/opsu/ScoreDB.java b/src/itdelatrisu/opsu/ScoreDB.java index 59883ceb..1e0b9964 100644 --- a/src/itdelatrisu/opsu/ScoreDB.java +++ b/src/itdelatrisu/opsu/ScoreDB.java @@ -44,6 +44,9 @@ public class ScoreDB { /** Score select statement. */ private static PreparedStatement selectMapStmt, selectMapSetStmt; + /** Score deletion statement. */ + private static PreparedStatement deleteStmt; + // This class should not be instantiated. private ScoreDB() {} @@ -82,6 +85,10 @@ public class ScoreDB { "SELECT * FROM scores WHERE " + "MSID = ? AND title = ? AND artist = ? AND creator = ? ORDER BY version DESC" ); + deleteStmt = connection.prepareStatement( + "DELETE FROM scores WHERE " + + "MID = ? AND title = ? AND artist = ? AND creator = ? AND version = ?" + ); } catch (SQLException e) { ErrorHandler.error("Failed to prepare score insertion statement.", e, true); } @@ -139,6 +146,23 @@ public class ScoreDB { } } + /** + * Deletes all the scores for the given beatmap from the database. + * @param osu the OsuFile object + */ + public static void deleteScore(OsuFile osu) { + try { + deleteStmt.setInt(1, osu.beatmapID); + deleteStmt.setString(2, osu.title); + deleteStmt.setString(3, osu.artist); + deleteStmt.setString(4, osu.creator); + deleteStmt.setString(5, osu.version); + deleteStmt.executeUpdate(); + } catch (SQLException e) { + ErrorHandler.error("Failed to delete score from database.", e, true); + } + } + /** * Retrieves the game scores for an OsuFile map. * @param osu the OsuFile diff --git a/src/itdelatrisu/opsu/objects/curves/Bezier2.java b/src/itdelatrisu/opsu/objects/curves/Bezier2.java index 1dc4524b..e71a53aa 100644 --- a/src/itdelatrisu/opsu/objects/curves/Bezier2.java +++ b/src/itdelatrisu/opsu/objects/curves/Bezier2.java @@ -20,6 +20,8 @@ package itdelatrisu.opsu.objects.curves; /** * Representation of a Bezier curve with the distance between each point calculated. + * + * @author fluddokt (https://github.com/fluddokt) */ public class Bezier2 { /** The control points of the Bezier curve. */ diff --git a/src/itdelatrisu/opsu/objects/curves/CircumscribedCircle.java b/src/itdelatrisu/opsu/objects/curves/CircumscribedCircle.java index 386bf9f5..2b4c22b3 100644 --- a/src/itdelatrisu/opsu/objects/curves/CircumscribedCircle.java +++ b/src/itdelatrisu/opsu/objects/curves/CircumscribedCircle.java @@ -29,6 +29,8 @@ import org.newdawn.slick.Image; /** * Representation of a curve along a Circumscribed Circle of three points. * http://en.wikipedia.org/wiki/Circumscribed_circle + * + * @author fluddokt (https://github.com/fluddokt) */ public class CircumscribedCircle extends Curve { /** PI constants. */ diff --git a/src/itdelatrisu/opsu/objects/curves/Curve.java b/src/itdelatrisu/opsu/objects/curves/Curve.java index 5725479e..1a593f40 100644 --- a/src/itdelatrisu/opsu/objects/curves/Curve.java +++ b/src/itdelatrisu/opsu/objects/curves/Curve.java @@ -24,6 +24,8 @@ import org.newdawn.slick.Color; /** * Representation of a curve. + * + * @author fluddokt (https://github.com/fluddokt) */ public abstract class Curve { /** The associated OsuHitObject. */ diff --git a/src/itdelatrisu/opsu/objects/curves/LinearBezier.java b/src/itdelatrisu/opsu/objects/curves/LinearBezier.java index 2708241f..249e77dd 100644 --- a/src/itdelatrisu/opsu/objects/curves/LinearBezier.java +++ b/src/itdelatrisu/opsu/objects/curves/LinearBezier.java @@ -31,6 +31,8 @@ import org.newdawn.slick.Image; /** * Representation of a Bezier curve with equidistant points. * http://pomax.github.io/bezierinfo/#tracing + * + * @author fluddokt (https://github.com/fluddokt) */ public class LinearBezier extends Curve { /** The angles of the first and last control points for drawing. */ diff --git a/src/itdelatrisu/opsu/objects/curves/Vec2f.java b/src/itdelatrisu/opsu/objects/curves/Vec2f.java index e94389f4..b49bac2d 100644 --- a/src/itdelatrisu/opsu/objects/curves/Vec2f.java +++ b/src/itdelatrisu/opsu/objects/curves/Vec2f.java @@ -20,6 +20,8 @@ package itdelatrisu.opsu.objects.curves; /** * A two-dimensional floating-point vector. + * + * @author fluddokt (https://github.com/fluddokt) */ public class Vec2f { /** Vector coordinates. */ diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index d55d9543..3384ab92 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -177,6 +177,7 @@ public class Game extends BasicGameState { Image playfield = GameImage.PLAYFIELD.getImage(); playfield.setAlpha(dimLevel); playfield.draw(); + playfield.setAlpha(1f); } int trackPosition = MusicController.getPosition(); diff --git a/src/itdelatrisu/opsu/states/SongMenu.java b/src/itdelatrisu/opsu/states/SongMenu.java index 2537b738..c7dc8ef7 100644 --- a/src/itdelatrisu/opsu/states/SongMenu.java +++ b/src/itdelatrisu/opsu/states/SongMenu.java @@ -238,8 +238,11 @@ public class SongMenu extends BasicGameState { int mouseX = input.getMouseX(), mouseY = input.getMouseY(); // background - if (focusNode != null) - focusNode.osuFiles.get(focusNode.osuFileIndex).drawBG(width, height, 1.0f, true); + if (focusNode != null) { + OsuFile focusNodeOsu = focusNode.osuFiles.get(focusNode.osuFileIndex); + if (!focusNodeOsu.drawBG(width, height, 1.0f, true)) + GameImage.PLAYFIELD.getImage().draw(); + } // header setup float lowerBound = height * 0.15f;