Replaced native cursors with skinnable ones.

- Added support for both the new (2013+) and old cursor styles.  These can be toggled on/off in the configuration file.
- Added cursor images by XinCrin (old style) and teinecthel (new style).

Other changes:
- Refactoring: Created a "Utils" module, containing methods and constants that didn't belong in the "Options" state and some duplicated drawing methods.
- Mouse is now grabbed during gameplay.
- Removed 'optionsChanged' switch, simplifying adding new options.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han
2014-07-01 19:32:03 -04:00
parent 0604a25822
commit ab487c5e80
20 changed files with 523 additions and 266 deletions

View File

@@ -26,6 +26,7 @@ import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.OsuHitObject;
import itdelatrisu.opsu.OsuTimingPoint;
import itdelatrisu.opsu.SoundController;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.objects.Circle;
import itdelatrisu.opsu.objects.Slider;
import itdelatrisu.opsu.objects.Spinner;
@@ -264,8 +265,6 @@ public class Game extends BasicGameState {
if (!osu.drawBG(width, height, 0.7f))
g.setBackground(Color.black);
Options.drawFPS();
int trackPosition = MusicController.getPosition();
if (pauseTime > -1) // returning from pause screen
trackPosition = pauseTime;
@@ -313,6 +312,9 @@ public class Game extends BasicGameState {
warningArrowL.draw(width * 0.75f, height * 0.75f);
}
}
Utils.drawFPS();
Utils.drawCursor();
return;
}
}
@@ -413,7 +415,7 @@ public class Game extends BasicGameState {
// returning from pause screen
if (pauseTime > -1 && pausedMouseX > -1 && pausedMouseY > -1) {
// darken the screen
g.setColor(Options.COLOR_BLACK_ALPHA);
g.setColor(Utils.COLOR_BLACK_ALPHA);
g.fillRect(0, 0, width, height);
// draw glowing hit select circle and pulse effect
@@ -425,6 +427,9 @@ public class Game extends BasicGameState {
cursorCirclePulse.setAlpha(1f - pausePulse);
cursorCirclePulse.drawCentered(pausedMouseX, pausedMouseY);
}
Utils.drawFPS();
Utils.drawCursor();
}
@Override
@@ -589,7 +594,7 @@ public class Game extends BasicGameState {
mousePressed(Input.MOUSE_RIGHT_BUTTON, input.getMouseX(), input.getMouseY());
break;
case Input.KEY_F12:
Options.takeScreenShot();
Utils.takeScreenShot();
break;
}
}
@@ -647,6 +652,9 @@ public class Game extends BasicGameState {
if (osu == null || osu.objects == null)
throw new RuntimeException("Running game with no OsuFile loaded.");
// grab the mouse
container.setMouseGrabbed(true);
// restart the game
if (restart != RESTART_FALSE) {
// new game
@@ -720,6 +728,12 @@ public class Game extends BasicGameState {
}
}
@Override
public void leave(GameContainer container, StateBasedGame game)
throws SlickException {
container.setMouseGrabbed(false);
}
/**
* Skips the beginning of a track.
* @return true if skipped, false otherwise