From 331f374a5b39ece4b5145c7c0c8addab494f6a3d Mon Sep 17 00:00:00 2001 From: Jeffrey Han Date: Tue, 8 Jul 2014 13:38:16 -0400 Subject: [PATCH] Better positioning of mod icons and song menu header text. Signed-off-by: Jeffrey Han --- src/itdelatrisu/opsu/GameScore.java | 48 ++++++++++++++++------- src/itdelatrisu/opsu/SoundController.java | 4 +- src/itdelatrisu/opsu/states/Game.java | 14 ------- src/itdelatrisu/opsu/states/SongMenu.java | 21 +++++----- 4 files changed, 45 insertions(+), 42 deletions(-) diff --git a/src/itdelatrisu/opsu/GameScore.java b/src/itdelatrisu/opsu/GameScore.java index a9dc0fe0..13439c18 100644 --- a/src/itdelatrisu/opsu/GameScore.java +++ b/src/itdelatrisu/opsu/GameScore.java @@ -468,7 +468,9 @@ public class GameScore { } /** - * Draws game elements: scorebar, score, score percentage, combo count, and combo burst. + * Draws game elements: + * scorebar, score, score percentage, map progress circle, + * mod icons, combo count, combo burst, and grade. * @param g the graphics context * @param mapLength the length of the beatmap (in ms) * @param breakPeriod if true, will not draw scorebar and combo elements, and will draw grade @@ -480,26 +482,43 @@ public class GameScore { width - 2, 0, 1.0f, true); // score percentage + int symbolHeight = getScoreSymbolImage('0').getHeight(); String scorePercentage = String.format("%02.2f%%", getScorePercent()); - drawSymbolString(scorePercentage, width - 2, getScoreSymbolImage('0').getHeight(), 0.75f, true); + drawSymbolString(scorePercentage, width - 2, symbolHeight, 0.75f, true); // map progress circle g.setAntiAlias(true); g.setLineWidth(2f); g.setColor(Color.white); int circleX = width - (getScoreSymbolImage('0').getWidth() * scorePercentage.length()); - int circleY = getScoreSymbolImage('0').getHeight(); - float circleDiameter = getScoreSymbolImage('0').getHeight() * 0.75f; - g.drawOval(circleX, circleY, circleDiameter, circleDiameter); + float circleDiameter = symbolHeight * 0.75f; + g.drawOval(circleX, symbolHeight, circleDiameter, circleDiameter); int firstObjectTime = MusicController.getOsuFile().objects[0].time; int trackPosition = MusicController.getPosition(); if (trackPosition > firstObjectTime) { - g.fillArc(circleX, circleY, circleDiameter, circleDiameter, + g.fillArc(circleX, symbolHeight, circleDiameter, circleDiameter, -90, -90 + (int) (360f * (trackPosition - firstObjectTime) / mapLength) ); } + // mod icons + if ((firstObject && trackPosition < firstObjectTime) || Options.isModActive(Options.MOD_AUTO)) { + int modWidth = Options.getModImage(0).getWidth(); + float modX = (width * 0.98f) - modWidth; + for (int i = Options.MOD_MAX - 1, modCount = 0; i >= 0; i--) { + if (Options.isModActive(i)) { + Image modImage = Options.getModImage(i); + modImage.draw( +// (width * 0.85f) + ((i - (Options.MOD_MAX / 2)) * modImage.getWidth() / 3f), + modX - (modCount * (modWidth / 2f)), + symbolHeight + circleDiameter + 10 + ); + modCount++; + } + } + } + if (!breakPeriod) { // scorebar float healthRatio = health / 100f; @@ -511,15 +530,14 @@ public class GameScore { Image colour = GameImage.SCOREBAR_COLOUR.getImage(); Image colourCropped = colour.getSubImage(0, 0, (int) (colour.getWidth() * healthRatio), colour.getHeight()); colourCropped.draw(0, GameImage.SCOREBAR_BG.getImage().getHeight() / 4f); + Image ki = null; if (health >= 50f) - GameImage.SCOREBAR_KI.getImage().drawCentered( - colourCropped.getWidth(), GameImage.SCOREBAR_KI.getImage().getHeight() / 2f); + ki = GameImage.SCOREBAR_KI.getImage(); else if (health >= 25f) - GameImage.SCOREBAR_KI_DANGER.getImage().drawCentered( - colourCropped.getWidth(), GameImage.SCOREBAR_KI_DANGER.getImage().getHeight() / 2f); + ki = GameImage.SCOREBAR_KI_DANGER.getImage(); else - GameImage.SCOREBAR_KI_DANGER2.getImage().drawCentered( - colourCropped.getWidth(), GameImage.SCOREBAR_KI_DANGER2.getImage().getHeight() / 2f); + ki = GameImage.SCOREBAR_KI_DANGER2.getImage(); + ki.drawCentered(colourCropped.getWidth(), ki.getHeight() / 2f); // combo burst if (comboBurstIndex != -1 && comboBurstAlpha > 0f) { @@ -530,13 +548,13 @@ public class GameScore { // combo count if (combo > 0) // 0 isn't a combo - drawSymbolString(String.format("%dx", combo), 10, height - 10 - getScoreSymbolImage('0').getHeight(), 1.0f, false); + drawSymbolString(String.format("%dx", combo), 10, height - 10 - symbolHeight, 1.0f, false); } else { // grade Image grade = gradesSmall[getGrade()]; - float gradeScale = circleY * 0.75f / grade.getHeight(); + float gradeScale = symbolHeight * 0.75f / grade.getHeight(); gradesSmall[getGrade()].getScaledCopy(gradeScale).draw( - circleX - grade.getWidth(), circleY + circleX - grade.getWidth(), symbolHeight ); } } diff --git a/src/itdelatrisu/opsu/SoundController.java b/src/itdelatrisu/opsu/SoundController.java index 2796b00e..52769c8f 100644 --- a/src/itdelatrisu/opsu/SoundController.java +++ b/src/itdelatrisu/opsu/SoundController.java @@ -239,8 +239,8 @@ public class SoundController { // PulseAudio does not support Master Gain if (clip.isControlSupported(FloatControl.Type.MASTER_GAIN)) { // set volume - FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN); - float dB = (float) (Math.log(volume) / Math.log(10.0) * 20.0); + FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN); + float dB = (float) (Math.log(volume) / Math.log(10.0) * 20.0); gainControl.setValue(dB); } diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index 94ac318d..00973623 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -297,20 +297,6 @@ public class Game extends BasicGameState { trackPosition < osu.objects[0].time - skipOffsetTime) skipButton.draw(); - // mod icons - if ((objectIndex == 0 && trackPosition < osu.objects[0].time) || - Options.isModActive(Options.MOD_AUTO)) { - for (int i = Options.MOD_MAX - 1; i >= 0; i--) { - if (Options.isModActive(i)) { - Image modImage = Options.getModImage(i); - modImage.draw( - (width * 0.85f) + ((i - (Options.MOD_MAX / 2)) * modImage.getWidth() / 3f), - height / 10f - ); - } - } - } - if (isLeadIn()) trackPosition = leadInTime * -1; // render approach circles during song lead-in diff --git a/src/itdelatrisu/opsu/states/SongMenu.java b/src/itdelatrisu/opsu/states/SongMenu.java index f9d6cc54..58ee5a8d 100644 --- a/src/itdelatrisu/opsu/states/SongMenu.java +++ b/src/itdelatrisu/opsu/states/SongMenu.java @@ -181,7 +181,8 @@ public class SongMenu extends BasicGameState { Image optionsIcon = new Image("options.png").getScaledCopy(iconScale); optionsButton = new GUIMenuButton(optionsIcon, search.getX() - (optionsIcon.getWidth() * 1.5f), search.getY()); - musicNote = new Image("music-note.png"); + int musicNoteDim = (int) (Utils.FONT_LARGE.getHeight() * 0.75f + Utils.FONT_DEFAULT.getHeight()); + musicNote = new Image("music-note.png").getScaledCopy(musicNoteDim, musicNoteDim); } @Override @@ -213,17 +214,15 @@ public class SongMenu extends BasicGameState { String[] info = focusNode.getInfo(); g.setColor(Color.white); - Utils.FONT_LARGE.drawString( - musicNoteWidth + 5, -3, info[0]); - float y1 = -3 + Utils.FONT_LARGE.getHeight() * 0.75f; + Utils.FONT_LARGE.drawString(musicNoteWidth + 5, -3, info[0]); Utils.FONT_DEFAULT.drawString( - musicNoteWidth + 5, y1, info[1]); - Utils.FONT_BOLD.drawString( - 5, Math.max(y1 + 4, musicNoteHeight - 3), info[2]); - Utils.FONT_DEFAULT.drawString( - 5, musicNoteHeight + Utils.FONT_BOLD.getLineHeight() - 9, info[3]); - Utils.FONT_SMALL.drawString( - 5, musicNoteHeight + Utils.FONT_BOLD.getLineHeight() + Utils.FONT_DEFAULT.getLineHeight() - 13, info[4]); + musicNoteWidth + 5, -3 + Utils.FONT_LARGE.getHeight() * 0.75f, info[1]); + int headerY = musicNoteHeight - 3; + Utils.FONT_BOLD.drawString(5, headerY, info[2]); + headerY += Utils.FONT_BOLD.getLineHeight() - 6; + Utils.FONT_DEFAULT.drawString(5, headerY, info[3]); + headerY += Utils.FONT_DEFAULT.getLineHeight() - 4; + Utils.FONT_SMALL.drawString(5, headerY, info[4]); } // song buttons