From 86710f53b535f72933faea5724697a25ea94abdb Mon Sep 17 00:00:00 2001 From: yugecin Date: Sat, 5 Nov 2016 21:49:20 +0100 Subject: [PATCH] move logo to the beat --- src/itdelatrisu/opsu/GameImage.java | 2 +- src/itdelatrisu/opsu/states/MainMenu.java | 32 ++++++++++++++++++++++- src/itdelatrisu/opsu/ui/MenuButton.java | 24 +++++++++++++---- 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/itdelatrisu/opsu/GameImage.java b/src/itdelatrisu/opsu/GameImage.java index ac18af23..396f76e8 100644 --- a/src/itdelatrisu/opsu/GameImage.java +++ b/src/itdelatrisu/opsu/GameImage.java @@ -271,7 +271,7 @@ public enum GameImage { return img.getScaledCopy(w, h); } }, - MENU_LOGO ("logo", "png", false, true) { + MENU_LOGO ("logo2", "png", false, true) { @Override protected Image process_sub(Image img, int w, int h) { return img.getScaledCopy(0.8f); diff --git a/src/itdelatrisu/opsu/states/MainMenu.java b/src/itdelatrisu/opsu/states/MainMenu.java index 5a4c969d..f90d1de1 100644 --- a/src/itdelatrisu/opsu/states/MainMenu.java +++ b/src/itdelatrisu/opsu/states/MainMenu.java @@ -29,6 +29,7 @@ import itdelatrisu.opsu.audio.SoundEffect; import itdelatrisu.opsu.beatmap.Beatmap; import itdelatrisu.opsu.beatmap.BeatmapSetList; import itdelatrisu.opsu.beatmap.BeatmapSetNode; +import itdelatrisu.opsu.beatmap.TimingPoint; import itdelatrisu.opsu.downloads.Updater; import itdelatrisu.opsu.states.ButtonMenu.MenuState; import itdelatrisu.opsu.ui.Colors; @@ -269,7 +270,36 @@ public class MainMenu extends BasicGameState { playButton.draw(); exitButton.draw(); } - logo.draw(); + + float scale = 1f; + + if (MusicController.isPlaying() && MusicController.getBeatmap() != null) { + Beatmap map = MusicController.getBeatmap(); + TimingPoint p = null; + if (map.timingPoints != null) { + int time = 0; + float beatlen = 0f; + int i = 0; + for (TimingPoint pts : map.timingPoints) { + if (p == null || pts.getTime() < MusicController.getPosition()) { + i++; + p = pts; + if (!p.isInherited()) { + beatlen = p.getBeatLength(); + time = p.getTime(); + } + } + } + System.out.println(i); + if (p != null) { + double beatLength = beatlen * 100; + int realtime = MusicController.getPosition() * 100; + scale -= (0 - (((realtime - time * 100) % beatLength) / beatLength)) * 0.05; + } + } + } + + logo.draw(Color.white, scale); // draw music buttons if (MusicController.isPlaying()) diff --git a/src/itdelatrisu/opsu/ui/MenuButton.java b/src/itdelatrisu/opsu/ui/MenuButton.java index 1aa524dc..9684bd96 100644 --- a/src/itdelatrisu/opsu/ui/MenuButton.java +++ b/src/itdelatrisu/opsu/ui/MenuButton.java @@ -191,14 +191,21 @@ public class MenuButton { /** * Draws the button. */ - public void draw() { draw(Color.white); } + public void draw() { draw(Color.white, 1.0f); } /** - * Draw the button with a color filter. + * Draws the button with a color filter. * @param filter the color to filter with when drawing */ + public void draw(Color filter) { draw(filter, 1.0f); } + + /** + * Draw the button with a color filter and scale. + * @param filter the color to filter with when drawing + * @param scaleoverride the scale to use when drawing + */ @SuppressWarnings("deprecation") - public void draw(Color filter) { + public void draw(Color filter, float scaleoverride) { // animations: get current frame Image image = this.img; if (image == null) { @@ -208,8 +215,15 @@ public class MenuButton { // normal images if (imgL == null) { + float scaleposmodx = 0; + float scaleposmody = 0; + if (scaleoverride != 1f) { + image = image.getScaledCopy(scaleoverride); + scaleposmodx = image.getWidth() / 2 - xRadius; + scaleposmody = image.getHeight() / 2 - yRadius; + } if (hoverEffect == 0) - image.draw(x - xRadius, y - yRadius, filter); + image.draw(x - xRadius - scaleposmodx, y - yRadius - scaleposmody, filter); else { float oldAlpha = image.getAlpha(); float oldAngle = image.getRotation(); @@ -223,7 +237,7 @@ public class MenuButton { image.setAlpha(alpha.getValue()); if ((hoverEffect & EFFECT_ROTATE) > 0) image.setRotation(angle.getValue()); - image.draw(x - xRadius, y - yRadius, filter); + image.draw(x - xRadius - scaleposmodx, y - yRadius - scaleposmody, filter); if (image == this.img) { image.setAlpha(oldAlpha); image.setRotation(oldAngle);