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:
parent
b83d6be5fd
commit
5efb61d3bb
|
@ -371,7 +371,7 @@ public enum GameImage {
|
||||||
* Whether or not the image is skinnable by a beatmap.
|
* Whether or not the image is skinnable by a beatmap.
|
||||||
* These images are typically related to gameplay.
|
* 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. */
|
/** Whether or not to preload the image when the program starts. */
|
||||||
private final boolean preload;
|
private final boolean preload;
|
||||||
|
@ -382,6 +382,9 @@ public enum GameImage {
|
||||||
/** The default image array. */
|
/** The default image array. */
|
||||||
private Image[] defaultImages;
|
private Image[] defaultImages;
|
||||||
|
|
||||||
|
/** Whether the image is currently skinned by a game skin. */
|
||||||
|
private boolean isSkinned = false;
|
||||||
|
|
||||||
/** The beatmap skin image (optional, temporary). */
|
/** The beatmap skin image (optional, temporary). */
|
||||||
private Image skinImage;
|
private Image skinImage;
|
||||||
|
|
||||||
|
@ -429,6 +432,7 @@ public enum GameImage {
|
||||||
for (GameImage img : GameImage.values()) {
|
for (GameImage img : GameImage.values()) {
|
||||||
img.defaultImage = img.skinImage = null;
|
img.defaultImage = img.skinImage = null;
|
||||||
img.defaultImages = img.skinImages = null;
|
img.defaultImages = img.skinImages = null;
|
||||||
|
img.isSkinned = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,21 +523,21 @@ public enum GameImage {
|
||||||
* Constructor for general images.
|
* Constructor for general images.
|
||||||
* @param filename the image file name
|
* @param filename the image file name
|
||||||
* @param type the file types (separated by '|')
|
* @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
|
* @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.filename = filename;
|
||||||
this.type = getType(type);
|
this.type = getType(type);
|
||||||
this.skinnable = skinnable;
|
this.beatmapSkinnable = beatmapSkinnable;
|
||||||
this.preload = preload;
|
this.preload = preload;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether or not the image is beatmap-skinnable.
|
* 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.
|
* Returns whether or not to preload the image when the program starts.
|
||||||
|
@ -610,16 +614,26 @@ public enum GameImage {
|
||||||
// try to load multiple images
|
// try to load multiple images
|
||||||
File skinDir = Options.getSkin().getDirectory();
|
File skinDir = Options.getSkin().getDirectory();
|
||||||
if (filenameFormat != null) {
|
if (filenameFormat != null) {
|
||||||
if ((skinDir != null && ((defaultImages = loadImageArray(skinDir)) != null)) ||
|
if (skinDir != null && ((defaultImages = loadImageArray(skinDir)) != null)) {
|
||||||
((defaultImages = loadImageArray(null)) != null)) {
|
isSkinned = true;
|
||||||
|
process();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((defaultImages = loadImageArray(null)) != null) {
|
||||||
|
isSkinned = false;
|
||||||
process();
|
process();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to load a single image
|
// try to load a single image
|
||||||
if ((skinDir != null && ((defaultImage = loadImageSingle(skinDir)) != null)) ||
|
if (skinDir != null && ((defaultImage = loadImageSingle(skinDir)) != null)) {
|
||||||
((defaultImage = loadImageSingle(null)) != null)) {
|
isSkinned = true;
|
||||||
|
process();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((defaultImage = loadImageSingle(null)) != null) {
|
||||||
|
isSkinned = false;
|
||||||
process();
|
process();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -716,6 +730,12 @@ public enum GameImage {
|
||||||
return null;
|
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.
|
* Returns whether a beatmap skin image is currently loaded.
|
||||||
* @return true if a beatmap skin image exists
|
* @return true if a beatmap skin image exists
|
||||||
|
|
|
@ -220,7 +220,7 @@ public class MainMenu extends BasicGameState {
|
||||||
float centerOffsetX = width / 5f;
|
float centerOffsetX = width / 5f;
|
||||||
logoOpen = new AnimatedValue(400, 0, centerOffsetX, AnimationEquation.OUT_QUAD);
|
logoOpen = new AnimatedValue(400, 0, centerOffsetX, AnimationEquation.OUT_QUAD);
|
||||||
logoClose = new AnimatedValue(2200, centerOffsetX, 0, 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();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,27 +107,24 @@ public class Cursor {
|
||||||
public void draw(int mouseX, int mouseY, boolean mousePressed) {
|
public void draw(int mouseX, int mouseY, boolean mousePressed) {
|
||||||
// determine correct cursor image
|
// determine correct cursor image
|
||||||
Image cursor = null, cursorMiddle = null, cursorTrail = null;
|
Image cursor = null, cursorMiddle = null, cursorTrail = null;
|
||||||
boolean skinned = GameImage.CURSOR.hasBeatmapSkinImage();
|
boolean beatmapSkinned = GameImage.CURSOR.hasBeatmapSkinImage();
|
||||||
boolean newStyle, hasMiddle;
|
boolean newStyle, hasMiddle;
|
||||||
if (skinned) {
|
Skin skin = Options.getSkin();
|
||||||
|
if (beatmapSkinned) {
|
||||||
newStyle = true; // osu! currently treats all beatmap cursors as new-style cursors
|
newStyle = true; // osu! currently treats all beatmap cursors as new-style cursors
|
||||||
hasMiddle = GameImage.CURSOR_MIDDLE.hasBeatmapSkinImage();
|
hasMiddle = GameImage.CURSOR_MIDDLE.hasBeatmapSkinImage();
|
||||||
} else
|
} else
|
||||||
newStyle = hasMiddle = Options.isNewCursorEnabled();
|
newStyle = hasMiddle = Options.isNewCursorEnabled();
|
||||||
if (skinned || newStyle) {
|
if (newStyle || beatmapSkinned) {
|
||||||
cursor = GameImage.CURSOR.getImage();
|
cursor = GameImage.CURSOR.getImage();
|
||||||
cursorTrail = GameImage.CURSOR_TRAIL.getImage();
|
cursorTrail = GameImage.CURSOR_TRAIL.getImage();
|
||||||
} else {
|
} else {
|
||||||
cursor = GameImage.CURSOR_OLD.getImage();
|
cursor = GameImage.CURSOR.hasGameSkinImage() ? GameImage.CURSOR.getImage() : GameImage.CURSOR_OLD.getImage();
|
||||||
cursorTrail = GameImage.CURSOR_TRAIL_OLD.getImage();
|
cursorTrail = GameImage.CURSOR_TRAIL.hasGameSkinImage() ? GameImage.CURSOR_TRAIL.getImage() : GameImage.CURSOR_TRAIL_OLD.getImage();
|
||||||
}
|
}
|
||||||
if (hasMiddle)
|
if (hasMiddle)
|
||||||
cursorMiddle = GameImage.CURSOR_MIDDLE.getImage();
|
cursorMiddle = GameImage.CURSOR_MIDDLE.getImage();
|
||||||
|
|
||||||
int removeCount = 0;
|
|
||||||
float FPSmod = Math.max(container.getFPS(), 1) / 60f;
|
|
||||||
Skin skin = Options.getSkin();
|
|
||||||
|
|
||||||
// scale cursor
|
// scale cursor
|
||||||
float cursorScale = Options.getCursorScale();
|
float cursorScale = Options.getCursorScale();
|
||||||
if (mousePressed && skin.isCursorExpanded())
|
if (mousePressed && skin.isCursorExpanded())
|
||||||
|
@ -138,6 +135,8 @@ public class Cursor {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use an image buffer
|
// TODO: use an image buffer
|
||||||
|
int removeCount = 0;
|
||||||
|
float FPSmod = Math.max(container.getFPS(), 1) / 60f;
|
||||||
if (newStyle) {
|
if (newStyle) {
|
||||||
// new style: add all points between cursor movements
|
// new style: add all points between cursor movements
|
||||||
if (lastX < 0) {
|
if (lastX < 0) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user