From 7898b669f52c433924e9dce408ff30cdc1fbbdaa Mon Sep 17 00:00:00 2001 From: yugecin Date: Sun, 20 Nov 2016 23:06:47 +0100 Subject: [PATCH] add visual indicator for numeric values in the option menu --- src/itdelatrisu/opsu/Options.java | 15 ++++++++++++++- src/itdelatrisu/opsu/states/OptionsMenu.java | 10 +++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/itdelatrisu/opsu/Options.java b/src/itdelatrisu/opsu/Options.java index 5b846729..47b8a150 100644 --- a/src/itdelatrisu/opsu/Options.java +++ b/src/itdelatrisu/opsu/Options.java @@ -1376,7 +1376,20 @@ public class Options { } else if (type == OptionType.BOOLEAN) bool = Boolean.parseBoolean(s); } - }; + + public boolean isDragOption() { + return type == OptionType.NUMERIC; + } + + public int getMinValue() { + return min; + } + + public int getMaxValue() { + return max; + } + + } /** Map of option display names to GameOptions. */ private static HashMap optionMap; diff --git a/src/itdelatrisu/opsu/states/OptionsMenu.java b/src/itdelatrisu/opsu/states/OptionsMenu.java index cd31ac48..cb79755e 100644 --- a/src/itdelatrisu/opsu/states/OptionsMenu.java +++ b/src/itdelatrisu/opsu/states/OptionsMenu.java @@ -558,9 +558,17 @@ public class OptionsMenu extends BasicGameState { Color color = (focus) ? Color.cyan : Color.white; Fonts.MEDIUM.drawString(width / 30, y, option.getName(), color); - Fonts.MEDIUM.drawString(width / 2, y, option.getValueString(), color); Fonts.SMALL.drawString(width / 30, y + textHeight, option.getDescription(), color); + Fonts.MEDIUM.drawString(width / 2, y, option.getValueString(), color); g.setColor(Colors.WHITE_ALPHA); + if (option.isDragOption()) { + float availableWidth = width / 2 - width / 30; + g.fillRect(width / 2, y + textHeight, 20, 10); + g.fillRect(width / 2 + availableWidth - 20, y + textHeight, 20, 10); + availableWidth -= 40 + 100; + float optionPercent = (float) (option.getIntegerValue() - option.getMinValue()) / (option.getMaxValue() - option.getMinValue()); + g.fillRect(width / 2 + 20 + optionPercent * availableWidth, y + textHeight, 100, 10); + } g.drawLine(0, y + textHeight, width, y + textHeight); }