diff --git a/src/itdelatrisu/opsu/GameMod.java b/src/itdelatrisu/opsu/GameMod.java index 4ef301ae..f59f9bc0 100644 --- a/src/itdelatrisu/opsu/GameMod.java +++ b/src/itdelatrisu/opsu/GameMod.java @@ -149,9 +149,6 @@ public enum GameMod { /** The score multiplier. */ private final float multiplier; - /** Whether or not the mod is implemented. */ - private final boolean implemented; - /** The name of the mod. */ private final String name; @@ -313,24 +310,6 @@ public enum GameMod { */ GameMod(Category category, int categoryIndex, GameImage image, String abbrev, int bit, int key, float multiplier, String name, String description) { - this(category, categoryIndex, image, abbrev, bit, key, multiplier, true, name, description); - } - - /** - * Constructor. - * @param category the category for the mod - * @param categoryIndex the index in the category - * @param image the GameImage - * @param abbrev the two-letter abbreviation - * @param bit the bit - * @param key the shortcut key - * @param multiplier the score multiplier - * @param implemented whether the mod is implemented - * @param name the name - * @param description the description - */ - GameMod(Category category, int categoryIndex, GameImage image, String abbrev, - int bit, int key, float multiplier, boolean implemented, String name, String description) { this.category = category; this.categoryIndex = categoryIndex; this.image = image; @@ -338,7 +317,6 @@ public enum GameMod { this.bit = bit; this.key = key; this.multiplier = multiplier; - this.implemented = implemented; this.name = name; this.description = description; } @@ -380,20 +358,11 @@ public enum GameMod { */ public String getDescription() { return description; } - /** - * Returns whether or not the mod is implemented. - * @return true if implemented - */ - public boolean isImplemented() { return implemented; } - /** * Toggles the active status of the mod. * @param checkInverse if true, perform checks for mutual exclusivity */ public void toggle(boolean checkInverse) { - if (!implemented) - return; - active = !active; scoreMultiplier = speedMultiplier = difficultyMultiplier = -1f; @@ -450,14 +419,7 @@ public enum GameMod { /** * Draws the game mod. */ - public void draw() { - if (!implemented) { - button.getImage().setAlpha(0.2f); - button.draw(); - button.getImage().setAlpha(1f); - } else - button.draw(); - } + public void draw() { button.draw(); } /** * Checks if the coordinates are within the image bounds. diff --git a/src/itdelatrisu/opsu/NativeLoader.java b/src/itdelatrisu/opsu/NativeLoader.java index a3ed28cd..6984baf0 100644 --- a/src/itdelatrisu/opsu/NativeLoader.java +++ b/src/itdelatrisu/opsu/NativeLoader.java @@ -95,10 +95,10 @@ public class NativeLoader { } else if (osName.startsWith("Linux")) { if (name.endsWith(".so")) return true; - } else if (((osName.startsWith("Mac")) || (osName.startsWith("Darwin"))) && ((name.endsWith(".jnilib")) || (name.endsWith(".dylib")))) { - return true; + } else if (osName.startsWith("Mac") || osName.startsWith("Darwin")) { + if (name.endsWith(".dylib") || name.endsWith(".jnilib")) + return true; } - return false; } } \ No newline at end of file diff --git a/src/itdelatrisu/opsu/Options.java b/src/itdelatrisu/opsu/Options.java index d6f7623f..40d5bc3e 100644 --- a/src/itdelatrisu/opsu/Options.java +++ b/src/itdelatrisu/opsu/Options.java @@ -640,7 +640,7 @@ public class Options { */ public void drag(GameContainer container, int d) { if (type == OptionType.NUMERIC) - val = Utils.getBoundedValue(val, d, min, max); + val = Utils.clamp(val + d, min, max); } /** diff --git a/src/itdelatrisu/opsu/Utils.java b/src/itdelatrisu/opsu/Utils.java index f1f2fdfd..e20ab7e9 100644 --- a/src/itdelatrisu/opsu/Utils.java +++ b/src/itdelatrisu/opsu/Utils.java @@ -156,40 +156,6 @@ public class Utils { anim.draw(x - (anim.getWidth() / 2f), y - (anim.getHeight() / 2f)); } - /** - * Returns a bounded value for a base value and displacement. - * @param base the initial value - * @param diff the value change - * @param min the minimum value - * @param max the maximum value - * @return the bounded value - */ - public static int getBoundedValue(int base, int diff, int min, int max) { - int val = base + diff; - if (val < min) - val = min; - else if (val > max) - val = max; - return val; - } - - /** - * Returns a bounded value for a base value and displacement. - * @param base the initial value - * @param diff the value change - * @param min the minimum value - * @param max the maximum value - * @return the bounded value - */ - public static float getBoundedValue(float base, float diff, float min, float max) { - float val = base + diff; - if (val < min) - val = min; - else if (val > max) - val = max; - return val; - } - /** * Clamps a value between a lower and upper bound. * @param val the value to clamp @@ -236,6 +202,13 @@ public class Utils { return (float) Math.sqrt((v1 * v1) + (v2 * v2)); } + /** + * Linear interpolation of a and b at t. + */ + public static float lerp(float a, float b, float t) { + return a * (1 - t) + b * t; + } + /** * Returns true if a game input key is pressed (mouse/keyboard left/right). * @return true if pressed @@ -603,11 +576,4 @@ public class Utils { public static boolean parseBoolean(String s) { return (Integer.parseInt(s) == 1); } - - /** - * Linear interpolation of a and b at t. - */ - public static float lerp(float a, float b, float t) { - return a * (1 - t) + b * t; - } } diff --git a/src/itdelatrisu/opsu/states/ButtonMenu.java b/src/itdelatrisu/opsu/states/ButtonMenu.java index 1f21300e..23843f35 100644 --- a/src/itdelatrisu/opsu/states/ButtonMenu.java +++ b/src/itdelatrisu/opsu/states/ButtonMenu.java @@ -220,7 +220,7 @@ public class ButtonMenu extends BasicGameState { } // tooltips - if (hoverMod != null && hoverMod.isImplemented()) + if (hoverMod != null) UI.updateTooltip(delta, hoverMod.getDescription(), true); } diff --git a/src/itdelatrisu/opsu/ui/MenuButton.java b/src/itdelatrisu/opsu/ui/MenuButton.java index e9fa1089..99c454f2 100644 --- a/src/itdelatrisu/opsu/ui/MenuButton.java +++ b/src/itdelatrisu/opsu/ui/MenuButton.java @@ -460,7 +460,7 @@ public class MenuButton { return; int d = delta * (autoAnimationForward ? 1 : -1); - if (Utils.getBoundedValue(time, d, 0, animationDuration) == time) { + if (Utils.clamp(time + d, 0, animationDuration) == time) { if (reverseAtEnd) autoAnimationForward = !autoAnimationForward; else { diff --git a/src/itdelatrisu/opsu/ui/UI.java b/src/itdelatrisu/opsu/ui/UI.java index b855aa8b..a067b1b1 100644 --- a/src/itdelatrisu/opsu/ui/UI.java +++ b/src/itdelatrisu/opsu/ui/UI.java @@ -263,7 +263,7 @@ public class UI { */ public static void changeVolume(int units) { final float UNIT_OFFSET = 0.05f; - Options.setMasterVolume(container, Utils.getBoundedValue(Options.getMasterVolume(), UNIT_OFFSET * units, 0f, 1f)); + Options.setMasterVolume(container, Utils.clamp(Options.getMasterVolume() + (UNIT_OFFSET * units), 0f, 1f)); if (volumeDisplay == -1) volumeDisplay = 0; else if (volumeDisplay >= VOLUME_DISPLAY_TIME / 10) diff --git a/src/itdelatrisu/opsu/ui/animations/AnimatedValue.java b/src/itdelatrisu/opsu/ui/animations/AnimatedValue.java index 5e1636f9..d1a7fcdf 100644 --- a/src/itdelatrisu/opsu/ui/animations/AnimatedValue.java +++ b/src/itdelatrisu/opsu/ui/animations/AnimatedValue.java @@ -105,7 +105,7 @@ public class AnimatedValue { * @return true if an update was applied, false if the animation was not updated */ public boolean update(int delta) { - int newTime = Utils.getBoundedValue(time, delta, 0, duration); + int newTime = Utils.clamp(time + delta, 0, duration); if (time != newTime) { this.time = newTime; updateValue();