fix back button loading and improve back button chevron animation (itdelatrisu/opsu@c5749e3)

This commit is contained in:
yugecin 2017-02-04 20:17:24 +01:00
parent 1faee53830
commit c741db3923
2 changed files with 19 additions and 4 deletions

View File

@ -252,7 +252,7 @@ public enum GameImage {
return img.getScaledCopy((h * 0.3f) / img.getHeight());
}
},
MENU_BACK ("menu-back", "menu-back-%d", "png"),
MENU_BACK ("menu-back", "menu-back-%d", "png", false, true),
MENU_BACK_CHEVRON ("menu-back-chevron", "png"),
MENU_BACK_SLOPE("menu-back-slope", "png"),
MENU_BUTTON_BG ("menu-button-background", "png", false, false),
@ -600,6 +600,18 @@ public enum GameImage {
this.preload = preload;
}
/**
* Constructor for an array of general images.
* @param filename the image file name
* @param filenameFormat the formatted file name string (for loading multiple images)
* @param type the file types (separated by '|')
* @param beatmapSkinnable whether or not the image is beatmap-skinnable
* @param preload whether or not to preload the image
*/
GameImage(String filename, String filenameFormat, String type, boolean beatmapSkinnable, boolean preload) {
this(filename, type, beatmapSkinnable, preload);
this.filenameFormat = filenameFormat;
}
/**
* Returns whether or not the image is beatmap-skinnable.
* @return true if beatmap-skinnable

View File

@ -36,7 +36,7 @@ public class BackButton {
COLOR_DARKPINK = new Color(186, 19, 121);
/** Target duration, in ms, of the button animations. */
private static final int ANIMATION_TIME = 500;
private static final int ANIMATION_TIME = 500;
/** How much time passed for the animations. */
private int animationTime;
@ -81,8 +81,7 @@ public class BackButton {
private int realButtonWidth;
public BackButton(DisplayContainer container) {
//if (!GameImage.MENU_BACK.hasGameSkinImage()) {
if (GameImage.MENU_BACK.getImage() != null && GameImage.MENU_BACK.getImage().getWidth() < 2) {
if (!GameImage.MENU_BACK.hasGameSkinImage()) {
backButton = null;
textWidth = Fonts.MEDIUM.getWidth("back");
paddingY = Fonts.MEDIUM.getHeight("back");
@ -126,6 +125,10 @@ public class BackButton {
Float beatProgress = MusicController.getBeatProgress();
if (beatProgress == null) {
beatProgress = 0f;
} else if (beatProgress < 0.2f) {
beatProgress = AnimationEquation.IN_QUINT.calc(beatProgress * 5f);
} else {
beatProgress = 1f - AnimationEquation.OUT_QUAD.calc((beatProgress - 0.2f) * 1.25f);
}
int chevronSize = (int) (chevronBaseSize - (isHovered ? 6f : 3f) * beatProgress);