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 <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-02-11 02:56:02 -05:00
parent 63271c125c
commit 99bc944ed6
8 changed files with 40 additions and 2 deletions

View File

@ -44,6 +44,9 @@ public class ScoreDB {
/** Score select statement. */ /** Score select statement. */
private static PreparedStatement selectMapStmt, selectMapSetStmt; private static PreparedStatement selectMapStmt, selectMapSetStmt;
/** Score deletion statement. */
private static PreparedStatement deleteStmt;
// This class should not be instantiated. // This class should not be instantiated.
private ScoreDB() {} private ScoreDB() {}
@ -82,6 +85,10 @@ public class ScoreDB {
"SELECT * FROM scores WHERE " + "SELECT * FROM scores WHERE " +
"MSID = ? AND title = ? AND artist = ? AND creator = ? ORDER BY version DESC" "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) { } catch (SQLException e) {
ErrorHandler.error("Failed to prepare score insertion statement.", e, true); 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. * Retrieves the game scores for an OsuFile map.
* @param osu the OsuFile * @param osu the OsuFile

View File

@ -20,6 +20,8 @@ package itdelatrisu.opsu.objects.curves;
/** /**
* Representation of a Bezier curve with the distance between each point calculated. * Representation of a Bezier curve with the distance between each point calculated.
*
* @author fluddokt (https://github.com/fluddokt)
*/ */
public class Bezier2 { public class Bezier2 {
/** The control points of the Bezier curve. */ /** The control points of the Bezier curve. */

View File

@ -29,6 +29,8 @@ import org.newdawn.slick.Image;
/** /**
* Representation of a curve along a Circumscribed Circle of three points. * Representation of a curve along a Circumscribed Circle of three points.
* http://en.wikipedia.org/wiki/Circumscribed_circle * http://en.wikipedia.org/wiki/Circumscribed_circle
*
* @author fluddokt (https://github.com/fluddokt)
*/ */
public class CircumscribedCircle extends Curve { public class CircumscribedCircle extends Curve {
/** PI constants. */ /** PI constants. */

View File

@ -24,6 +24,8 @@ import org.newdawn.slick.Color;
/** /**
* Representation of a curve. * Representation of a curve.
*
* @author fluddokt (https://github.com/fluddokt)
*/ */
public abstract class Curve { public abstract class Curve {
/** The associated OsuHitObject. */ /** The associated OsuHitObject. */

View File

@ -31,6 +31,8 @@ import org.newdawn.slick.Image;
/** /**
* Representation of a Bezier curve with equidistant points. * Representation of a Bezier curve with equidistant points.
* http://pomax.github.io/bezierinfo/#tracing * http://pomax.github.io/bezierinfo/#tracing
*
* @author fluddokt (https://github.com/fluddokt)
*/ */
public class LinearBezier extends Curve { public class LinearBezier extends Curve {
/** The angles of the first and last control points for drawing. */ /** The angles of the first and last control points for drawing. */

View File

@ -20,6 +20,8 @@ package itdelatrisu.opsu.objects.curves;
/** /**
* A two-dimensional floating-point vector. * A two-dimensional floating-point vector.
*
* @author fluddokt (https://github.com/fluddokt)
*/ */
public class Vec2f { public class Vec2f {
/** Vector coordinates. */ /** Vector coordinates. */

View File

@ -177,6 +177,7 @@ public class Game extends BasicGameState {
Image playfield = GameImage.PLAYFIELD.getImage(); Image playfield = GameImage.PLAYFIELD.getImage();
playfield.setAlpha(dimLevel); playfield.setAlpha(dimLevel);
playfield.draw(); playfield.draw();
playfield.setAlpha(1f);
} }
int trackPosition = MusicController.getPosition(); int trackPosition = MusicController.getPosition();

View File

@ -238,8 +238,11 @@ public class SongMenu extends BasicGameState {
int mouseX = input.getMouseX(), mouseY = input.getMouseY(); int mouseX = input.getMouseX(), mouseY = input.getMouseY();
// background // background
if (focusNode != null) if (focusNode != null) {
focusNode.osuFiles.get(focusNode.osuFileIndex).drawBG(width, height, 1.0f, true); OsuFile focusNodeOsu = focusNode.osuFiles.get(focusNode.osuFileIndex);
if (!focusNodeOsu.drawBG(width, height, 1.0f, true))
GameImage.PLAYFIELD.getImage().draw();
}
// header setup // header setup
float lowerBound = height * 0.15f; float lowerBound = height * 0.15f;