Updater UI improvements.

Replaced ugly 'bang' image with 'fa-arrow-circle-o-down' and 'fa-restart' icons from Font Awesome v4.4.0 (https://github.com/FortAwesome/Font-Awesome).

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-08-12 19:06:58 -05:00
parent 52e973caf8
commit f22498ae7d
5 changed files with 65 additions and 45 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 653 B

BIN
res/download.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
res/update.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -328,10 +328,16 @@ public enum GameImage {
return img.getScaledCopy((h / 17f) / img.getHeight()); return img.getScaledCopy((h / 17f) / img.getHeight());
} }
}, },
BANG ("bang", "png", false, false) { DOWNLOAD ("download", "png", false, false) {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {
return REPOSITORY.process_sub(img, w, h); return img.getScaledCopy((h / 14f) / img.getHeight());
}
},
UPDATE ("update", "png", false, false) {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy((h / 14f) / img.getHeight());
} }
}, },
OPTIONS_BG ("options-background", "png|jpg", false, true) { OPTIONS_BG ("options-background", "png|jpg", false, true) {

View File

@ -98,8 +98,8 @@ public class MainMenu extends BasicGameState {
/** Button linking to repository. */ /** Button linking to repository. */
private MenuButton repoButton; private MenuButton repoButton;
/** Button for installing updates. */ /** Buttons for installing updates. */
private MenuButton updateButton; private MenuButton updateButton, restartButton;
/** Application start time, for drawing the total running time. */ /** Application start time, for drawing the total running time. */
private long programStartTime; private long programStartTime;
@ -204,17 +204,23 @@ public class MainMenu extends BasicGameState {
repoButton.setHoverAnimationDuration(350); repoButton.setHoverAnimationDuration(350);
repoButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_BACK); repoButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_BACK);
repoButton.setHoverExpand(); repoButton.setHoverExpand();
startX -= repoImg.getWidth() * 1.75f; }
} else
startX -= width * 0.005f;
// initialize update button // initialize update buttons
Image bangImg = GameImage.BANG.getImage(); float updateX = width / 2f, updateY = height * 17 / 18f;
updateButton = new MenuButton(bangImg, startX - bangImg.getWidth(), startY - bangImg.getHeight()); Image downloadImg = GameImage.DOWNLOAD.getImage();
updateButton.setHoverExpand(1.15f); updateButton = new MenuButton(downloadImg, updateX, updateY);
updateButton.setHoverAnimationDuration(400);
updateButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_QUAD);
updateButton.setHoverExpand(1.1f);
Image updateImg = GameImage.UPDATE.getImage();
restartButton = new MenuButton(updateImg, updateX, updateY);
restartButton.setHoverAnimationDuration(2000);
restartButton.setHoverAnimationEquation(AnimationEquation.LINEAR);
restartButton.setHoverRotate(360);
// logo animations // logo animations
float centerOffsetX = container.getWidth() / 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(300, 0f, 1f, AnimationEquation.LINEAR);
@ -281,22 +287,11 @@ public class MainMenu extends BasicGameState {
// draw update button // draw update button
if (Updater.get().showButton()) { if (Updater.get().showButton()) {
Color updateColor = null; Updater.Status status = Updater.get().getStatus();
switch (Updater.get().getStatus()) { if (status == Updater.Status.UPDATE_AVAILABLE || status == Updater.Status.UPDATE_DOWNLOADING)
case UPDATE_AVAILABLE: updateButton.draw();
updateColor = Color.red; else if (status == Updater.Status.UPDATE_DOWNLOADED)
break; restartButton.draw();
case UPDATE_DOWNLOADED:
updateColor = Color.green;
break;
case UPDATE_DOWNLOADING:
updateColor = Color.yellow;
break;
default:
updateColor = Color.white;
break;
}
updateButton.draw(updateColor);
} }
// draw text // draw text
@ -335,7 +330,10 @@ public class MainMenu extends BasicGameState {
exitButton.hoverUpdate(delta, mouseX, mouseY, 0.25f); exitButton.hoverUpdate(delta, mouseX, mouseY, 0.25f);
if (repoButton != null) if (repoButton != null)
repoButton.hoverUpdate(delta, mouseX, mouseY); repoButton.hoverUpdate(delta, mouseX, mouseY);
updateButton.hoverUpdate(delta, mouseX, mouseY); if (Updater.get().showButton()) {
updateButton.autoHoverUpdate(delta, true);
restartButton.autoHoverUpdate(delta, false);
}
downloadsButton.hoverUpdate(delta, mouseX, mouseY); downloadsButton.hoverUpdate(delta, mouseX, mouseY);
// ensure only one button is in hover state at once // ensure only one button is in hover state at once
boolean noHoverUpdate = musicPositionBarContains(mouseX, mouseY); boolean noHoverUpdate = musicPositionBarContains(mouseX, mouseY);
@ -401,8 +399,12 @@ public class MainMenu extends BasicGameState {
UI.updateTooltip(delta, "Next track", false); UI.updateTooltip(delta, "Next track", false);
else if (musicPrevious.contains(mouseX, mouseY)) else if (musicPrevious.contains(mouseX, mouseY))
UI.updateTooltip(delta, "Previous track", false); UI.updateTooltip(delta, "Previous track", false);
else if (Updater.get().showButton() && updateButton.contains(mouseX, mouseY)) else if (Updater.get().showButton()) {
UI.updateTooltip(delta, Updater.get().getStatus().getDescription(), true); Updater.Status status = Updater.get().getStatus();
if (((status == Updater.Status.UPDATE_AVAILABLE || status == Updater.Status.UPDATE_DOWNLOADING) && updateButton.contains(mouseX, mouseY)) ||
(status == Updater.Status.UPDATE_DOWNLOADED && restartButton.contains(mouseX, mouseY)))
UI.updateTooltip(delta, status.getDescription(), true);
}
} }
@Override @Override
@ -440,8 +442,8 @@ public class MainMenu extends BasicGameState {
musicPrevious.resetHover(); musicPrevious.resetHover();
if (repoButton != null && !repoButton.contains(mouseX, mouseY)) if (repoButton != null && !repoButton.contains(mouseX, mouseY))
repoButton.resetHover(); repoButton.resetHover();
if (!updateButton.contains(mouseX, mouseY)) updateButton.resetHover();
updateButton.resetHover(); restartButton.resetHover();
if (!downloadsButton.contains(mouseX, mouseY)) if (!downloadsButton.contains(mouseX, mouseY))
downloadsButton.resetHover(); downloadsButton.resetHover();
} }
@ -477,9 +479,11 @@ public class MainMenu extends BasicGameState {
MusicController.resume(); MusicController.resume();
UI.sendBarNotification("Play"); UI.sendBarNotification("Play");
} }
return;
} else if (musicNext.contains(x, y)) { } else if (musicNext.contains(x, y)) {
nextTrack(); nextTrack();
UI.sendBarNotification(">> Next"); UI.sendBarNotification(">> Next");
return;
} else if (musicPrevious.contains(x, y)) { } else if (musicPrevious.contains(x, y)) {
if (!previous.isEmpty()) { if (!previous.isEmpty()) {
SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU); SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
@ -489,16 +493,18 @@ public class MainMenu extends BasicGameState {
} else } else
MusicController.setPosition(0); MusicController.setPosition(0);
UI.sendBarNotification("<< Previous"); UI.sendBarNotification("<< Previous");
return;
} }
// downloads button actions // downloads button actions
else if (downloadsButton.contains(x, y)) { if (downloadsButton.contains(x, y)) {
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
game.enterState(Opsu.STATE_DOWNLOADSMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_DOWNLOADSMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
return;
} }
// repository button actions // repository button actions
else if (repoButton != null && repoButton.contains(x, y)) { if (repoButton != null && repoButton.contains(x, y)) {
try { try {
Desktop.getDesktop().browse(Options.REPOSITORY_URI); Desktop.getDesktop().browse(Options.REPOSITORY_URI);
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
@ -506,28 +512,31 @@ public class MainMenu extends BasicGameState {
} catch (IOException e) { } catch (IOException e) {
ErrorHandler.error("Could not browse to repository URI.", e, false); ErrorHandler.error("Could not browse to repository URI.", e, false);
} }
return;
} }
// update button actions // update button actions
else if (Updater.get().showButton() && updateButton.contains(x, y)) { if (Updater.get().showButton()) {
switch (Updater.get().getStatus()) { Updater.Status status = Updater.get().getStatus();
case UPDATE_AVAILABLE: if (updateButton.contains(x, y) && status == Updater.Status.UPDATE_AVAILABLE) {
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
Updater.get().startDownload(); Updater.get().startDownload();
break; updateButton.removeHoverEffects();
case UPDATE_DOWNLOADED: updateButton.setHoverAnimationDuration(800);
updateButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_QUAD);
updateButton.setHoverFade(0.6f);
return;
} else if (restartButton.contains(x, y) && status == Updater.Status.UPDATE_DOWNLOADED) {
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
Updater.get().prepareUpdate(); Updater.get().prepareUpdate();
container.setForceExit(false); container.setForceExit(false);
container.exit(); container.exit();
break; return;
default:
break;
} }
} }
// start moving logo (if clicked) // start moving logo (if clicked)
else if (logoState == LogoState.DEFAULT || logoState == LogoState.CLOSING) { if (logoState == LogoState.DEFAULT || logoState == LogoState.CLOSING) {
if (logo.contains(x, y, 0.25f)) { if (logo.contains(x, y, 0.25f)) {
logoState = LogoState.OPENING; logoState = LogoState.OPENING;
logoOpen.setTime(0); logoOpen.setTime(0);
@ -535,6 +544,7 @@ public class MainMenu extends BasicGameState {
playButton.getImage().setAlpha(0f); playButton.getImage().setAlpha(0f);
exitButton.getImage().setAlpha(0f); exitButton.getImage().setAlpha(0f);
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
return;
} }
} }
@ -543,8 +553,11 @@ public class MainMenu extends BasicGameState {
if (logo.contains(x, y, 0.25f) || playButton.contains(x, y, 0.25f)) { if (logo.contains(x, y, 0.25f) || playButton.contains(x, y, 0.25f)) {
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
enterSongMenu(); enterSongMenu();
} else if (exitButton.contains(x, y, 0.25f)) return;
} else if (exitButton.contains(x, y, 0.25f)) {
container.exit(); container.exit();
return;
}
} }
} }
@ -629,6 +642,7 @@ public class MainMenu extends BasicGameState {
if (repoButton != null) if (repoButton != null)
repoButton.resetHover(); repoButton.resetHover();
updateButton.resetHover(); updateButton.resetHover();
restartButton.resetHover();
downloadsButton.resetHover(); downloadsButton.resetHover();
} }