Fixed bug where skinned old-style cursors were ignored. (part of #120)

Previously, enabling old-style cursors would try to load files "cursor2" and "cursortrail2". Now the actual files are loaded, and the -2 images are only used when no game skin image is provided.

Added a hasGameSkinImage() method in GameImage to check if the "default" image is skinned (by a game skin).

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-08-23 21:16:28 -05:00
parent b83d6be5fd
commit 5efb61d3bb
3 changed files with 39 additions and 20 deletions

View File

@ -371,7 +371,7 @@ public enum GameImage {
* Whether or not the image is skinnable by a beatmap.
* These images are typically related to gameplay.
*/
private final boolean skinnable;
private final boolean beatmapSkinnable;
/** Whether or not to preload the image when the program starts. */
private final boolean preload;
@ -382,6 +382,9 @@ public enum GameImage {
/** The default image array. */
private Image[] defaultImages;
/** Whether the image is currently skinned by a game skin. */
private boolean isSkinned = false;
/** The beatmap skin image (optional, temporary). */
private Image skinImage;
@ -429,6 +432,7 @@ public enum GameImage {
for (GameImage img : GameImage.values()) {
img.defaultImage = img.skinImage = null;
img.defaultImages = img.skinImages = null;
img.isSkinned = false;
}
}
@ -519,21 +523,21 @@ public enum GameImage {
* Constructor for general images.
* @param filename the image file name
* @param type the file types (separated by '|')
* @param skinnable whether or not the image is beatmap-skinnable
* @param beatmapSkinnable whether or not the image is beatmap-skinnable
* @param preload whether or not to preload the image
*/
GameImage(String filename, String type, boolean skinnable, boolean preload) {
GameImage(String filename, String type, boolean beatmapSkinnable, boolean preload) {
this.filename = filename;
this.type = getType(type);
this.skinnable = skinnable;
this.beatmapSkinnable = beatmapSkinnable;
this.preload = preload;
}
/**
* Returns whether or not the image is beatmap-skinnable.
* @return true if skinnable
* @return true if beatmap-skinnable
*/
public boolean isBeatmapSkinnable() { return skinnable; }
public boolean isBeatmapSkinnable() { return beatmapSkinnable; }
/**
* Returns whether or not to preload the image when the program starts.
@ -610,16 +614,26 @@ public enum GameImage {
// try to load multiple images
File skinDir = Options.getSkin().getDirectory();
if (filenameFormat != null) {
if ((skinDir != null && ((defaultImages = loadImageArray(skinDir)) != null)) ||
((defaultImages = loadImageArray(null)) != null)) {
if (skinDir != null && ((defaultImages = loadImageArray(skinDir)) != null)) {
isSkinned = true;
process();
return;
}
if ((defaultImages = loadImageArray(null)) != null) {
isSkinned = false;
process();
return;
}
}
// try to load a single image
if ((skinDir != null && ((defaultImage = loadImageSingle(skinDir)) != null)) ||
((defaultImage = loadImageSingle(null)) != null)) {
if (skinDir != null && ((defaultImage = loadImageSingle(skinDir)) != null)) {
isSkinned = true;
process();
return;
}
if ((defaultImage = loadImageSingle(null)) != null) {
isSkinned = false;
process();
return;
}
@ -716,6 +730,12 @@ public enum GameImage {
return null;
}
/**
* Returns whether the default image loaded is part of a game skin.
* @return true if a game skin image is loaded, false if the default image is loaded
*/
public boolean hasGameSkinImage() { return isSkinned; }
/**
* Returns whether a beatmap skin image is currently loaded.
* @return true if a beatmap skin image exists

View File

@ -220,7 +220,7 @@ public class MainMenu extends BasicGameState {
float centerOffsetX = width / 5f;
logoOpen = new AnimatedValue(400, 0, centerOffsetX, AnimationEquation.OUT_QUAD);
logoClose = new AnimatedValue(2200, centerOffsetX, 0, AnimationEquation.OUT_QUAD);
logoButtonAlpha = new AnimatedValue(300, 0f, 1f, AnimationEquation.LINEAR);
logoButtonAlpha = new AnimatedValue(200, 0f, 1f, AnimationEquation.LINEAR);
reset();
}

View File

@ -107,27 +107,24 @@ public class Cursor {
public void draw(int mouseX, int mouseY, boolean mousePressed) {
// determine correct cursor image
Image cursor = null, cursorMiddle = null, cursorTrail = null;
boolean skinned = GameImage.CURSOR.hasBeatmapSkinImage();
boolean beatmapSkinned = GameImage.CURSOR.hasBeatmapSkinImage();
boolean newStyle, hasMiddle;
if (skinned) {
Skin skin = Options.getSkin();
if (beatmapSkinned) {
newStyle = true; // osu! currently treats all beatmap cursors as new-style cursors
hasMiddle = GameImage.CURSOR_MIDDLE.hasBeatmapSkinImage();
} else
newStyle = hasMiddle = Options.isNewCursorEnabled();
if (skinned || newStyle) {
if (newStyle || beatmapSkinned) {
cursor = GameImage.CURSOR.getImage();
cursorTrail = GameImage.CURSOR_TRAIL.getImage();
} else {
cursor = GameImage.CURSOR_OLD.getImage();
cursorTrail = GameImage.CURSOR_TRAIL_OLD.getImage();
cursor = GameImage.CURSOR.hasGameSkinImage() ? GameImage.CURSOR.getImage() : GameImage.CURSOR_OLD.getImage();
cursorTrail = GameImage.CURSOR_TRAIL.hasGameSkinImage() ? GameImage.CURSOR_TRAIL.getImage() : GameImage.CURSOR_TRAIL_OLD.getImage();
}
if (hasMiddle)
cursorMiddle = GameImage.CURSOR_MIDDLE.getImage();
int removeCount = 0;
float FPSmod = Math.max(container.getFPS(), 1) / 60f;
Skin skin = Options.getSkin();
// scale cursor
float cursorScale = Options.getCursorScale();
if (mousePressed && skin.isCursorExpanded())
@ -138,6 +135,8 @@ public class Cursor {
}
// TODO: use an image buffer
int removeCount = 0;
float FPSmod = Math.max(container.getFPS(), 1) / 60f;
if (newStyle) {
// new style: add all points between cursor movements
if (lastX < 0) {