Removed some unneeded methods.
- Removed "isImplemented" field from GameMod as all of the base mods have been implemented. - Removed Utils.getBoundedValue() methods in preference for Utils.clamp(). Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
31d0c237df
commit
9d19dacab4
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ public class ButtonMenu extends BasicGameState {
|
|||
}
|
||||
|
||||
// tooltips
|
||||
if (hoverMod != null && hoverMod.isImplemented())
|
||||
if (hoverMod != null)
|
||||
UI.updateTooltip(delta, hoverMod.getDescription(), true);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user