Follow-up to #68.

Fixes:
- Set the modified speed again after unpausing and loading from checkpoints.
- Changed countdown delays based on current speed.
- Changed color of highlighted song info text to that in osu!.
- Made playback images unskinnable.

Code changes:
- Changed playback field in Game class to the PlaybackSpeed object instead of just the button.
- Changed PlaybackSpeed.next() to a non-static method.
- Added/edited Javadocs.
- Changed image names.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han
2015-04-03 18:08:35 -04:00
parent 420284af4f
commit 2efb18e225
12 changed files with 115 additions and 89 deletions

View File

@@ -16,13 +16,13 @@
* along with opsu!. If not, see <http://www.gnu.org/licenses/>.
*/
package itdelatrisu.opsu.replay;
/**
* Captures a single life frame.
*
* @author smoogipooo (https://github.com/smoogipooo/osu-Replay-API/)
*/
package itdelatrisu.opsu.replay;
public class LifeFrame {
/** Time. */
private int time;

View File

@@ -1,31 +1,57 @@
/*
* opsu! - an open-source osu! client
* Copyright (C) 2014, 2015 Jeffrey Han
*
* opsu! is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* opsu! is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with opsu!. If not, see <http://www.gnu.org/licenses/>.
*/
package itdelatrisu.opsu.replay;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.MenuButton;
import org.newdawn.slick.Image;
/**
* Playback speeds for replays.
*
* @author DarkTigrus (https://github.com/DarkTigrus)
*/
public enum PlaybackSpeed {
NORMAL(GameImage.REPLAY_1XPLAYBACK, 1f),
DOUBLE(GameImage.REPLAY_2XPLAYBACK, 2f),
HALF(GameImage.REPLAY_05XPLAYBACK, 0.5f);
NORMAL (GameImage.REPLAY_PLAYBACK_NORMAL, 1f),
DOUBLE (GameImage.REPLAY_PLAYBACK_DOUBLE, 2f),
HALF (GameImage.REPLAY_PLAYBACK_HALF, 0.5f);
/** The file name of the button image. */
/** The button image. */
private GameImage gameImage;
/** The button of the playback. */
/** The button. */
private MenuButton button;
/** The speed modifier of the playback. */
/** The playback speed modifier. */
private float modifier;
PlaybackSpeed(GameImage gameImage, float modifier) {
this.gameImage = gameImage;
this.modifier = modifier;
}
/** Enum values. */
private static PlaybackSpeed[] values = PlaybackSpeed.values();
/**
* Initializes the playback buttons.
* @param width the container width
* @param height the container height
*/
public static void init(int width, int height) {
// create buttons
for (PlaybackSpeed playback : PlaybackSpeed.values()) {
Image img = playback.gameImage.getImage();
playback.button = new MenuButton(img, width * 0.98f - (img.getWidth() / 2f), height * 0.25f);
@@ -33,18 +59,14 @@ public enum PlaybackSpeed {
}
}
private static int index = 1;
public static PlaybackSpeed next() {
PlaybackSpeed next = values()[index++ % values().length];
if((GameMod.DOUBLE_TIME.isActive() && next == PlaybackSpeed.DOUBLE))
next = next();
return next;
}
public static void reset() {
index = 1;
/**
* Constructor.
* @param gameImage the button image
* @param modifier the speed modifier
*/
PlaybackSpeed(GameImage gameImage, float modifier) {
this.gameImage = gameImage;
this.modifier = modifier;
}
/**
@@ -58,5 +80,14 @@ public enum PlaybackSpeed {
* @return the speed
*/
public float getModifier() { return modifier; }
}
/**
* Returns the next playback speed.
*/
public PlaybackSpeed next() {
PlaybackSpeed next = values[(this.ordinal() + 1) % values.length];
if ((GameMod.DOUBLE_TIME.isActive() && next == PlaybackSpeed.DOUBLE))
next = next.next();
return next;
}
}