refactor options
This commit is contained in:
@@ -19,9 +19,7 @@
|
||||
package itdelatrisu.opsu.ui;
|
||||
|
||||
import itdelatrisu.opsu.GameImage;
|
||||
import itdelatrisu.opsu.Options;
|
||||
import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.skins.Skin;
|
||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||
|
||||
import java.awt.Point;
|
||||
@@ -29,6 +27,9 @@ import java.util.LinkedList;
|
||||
|
||||
import org.newdawn.slick.*;
|
||||
import yugecin.opsudance.Dancer;
|
||||
import yugecin.opsudance.skinning.SkinService;
|
||||
|
||||
import static yugecin.opsudance.options.Options.*;
|
||||
|
||||
/**
|
||||
* Updates and draws the cursor.
|
||||
@@ -66,9 +67,6 @@ public class Cursor {
|
||||
|
||||
private boolean isMirrored;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public Cursor() {
|
||||
this(false);
|
||||
}
|
||||
@@ -83,19 +81,20 @@ public class Cursor {
|
||||
* @param mousePressed whether or not the mouse button is pressed
|
||||
*/
|
||||
public void draw(boolean mousePressed) {
|
||||
if (Options.isCursorDisabled())
|
||||
if (OPTION_DISABLE_CURSOR.state) {
|
||||
return;
|
||||
}
|
||||
|
||||
// determine correct cursor image
|
||||
Image cursor, cursorMiddle = null, cursorTrail;
|
||||
boolean beatmapSkinned = GameImage.CURSOR.hasBeatmapSkinImage();
|
||||
boolean hasMiddle;
|
||||
Skin skin = Options.getSkin();
|
||||
if (beatmapSkinned) {
|
||||
newStyle = true; // osu! currently treats all beatmap cursors as new-style cursors
|
||||
hasMiddle = GameImage.CURSOR_MIDDLE.hasBeatmapSkinImage();
|
||||
} else
|
||||
newStyle = hasMiddle = Options.isNewCursorEnabled();
|
||||
} else {
|
||||
newStyle = hasMiddle = OPTION_NEW_CURSOR.state;
|
||||
}
|
||||
if (beatmapSkinned || newStyle) {
|
||||
cursor = GameImage.CURSOR.getImage();
|
||||
cursorTrail = GameImage.CURSOR_TRAIL.getImage();
|
||||
@@ -108,7 +107,7 @@ public class Cursor {
|
||||
|
||||
// scale cursor
|
||||
float cursorScaleAnimated = 1f;
|
||||
if (skin.isCursorExpanded()) {
|
||||
if (SkinService.skin.isCursorExpanded()) {
|
||||
if (lastCursorPressState != mousePressed) {
|
||||
lastCursorPressState = mousePressed;
|
||||
lastCursorPressTime = System.currentTimeMillis();
|
||||
@@ -118,7 +117,7 @@ public class Cursor {
|
||||
Utils.clamp(System.currentTimeMillis() - lastCursorPressTime, 0, CURSOR_SCALE_TIME) / CURSOR_SCALE_TIME);
|
||||
cursorScaleAnimated = 1f + ((mousePressed) ? cursorScaleChange : CURSOR_SCALE_CHANGE - cursorScaleChange);
|
||||
}
|
||||
float cursorScale = cursorScaleAnimated * Options.getCursorScale();
|
||||
float cursorScale = cursorScaleAnimated * OPTION_CURSOR_SIZE.val / 100f;
|
||||
if (cursorScale != 1f) {
|
||||
cursor = cursor.getScaledCopy(cursorScale);
|
||||
cursorTrail = cursorTrail.getScaledCopy(cursorScale);
|
||||
@@ -135,7 +134,7 @@ public class Cursor {
|
||||
float alpha = 0f;
|
||||
float t = 2f / trail.size();
|
||||
int cursorTrailWidth = cursorTrail.getWidth(), cursorTrailHeight = cursorTrail.getHeight();
|
||||
float cursorTrailRotation = (skin.isCursorTrailRotated()) ? cursorAngle : 0;
|
||||
float cursorTrailRotation = (SkinService.skin.isCursorTrailRotated()) ? cursorAngle : 0;
|
||||
cursorTrail.startUse();
|
||||
for (Point p : trail) {
|
||||
alpha += t;
|
||||
@@ -150,11 +149,13 @@ public class Cursor {
|
||||
cursorTrail.endUse();
|
||||
|
||||
// draw the other components
|
||||
if (newStyle && skin.isCursorRotated())
|
||||
if (newStyle && SkinService.skin.isCursorRotated()) {
|
||||
cursor.setRotation(cursorAngle);
|
||||
cursor.drawCentered(lastPosition.x, lastPosition.y, Options.isCursorOnlyColorTrail() ? Color.white : filter);
|
||||
if (hasMiddle)
|
||||
cursorMiddle.drawCentered(lastPosition.x, lastPosition.y, Options.isCursorOnlyColorTrail() ? Color.white : filter);
|
||||
}
|
||||
cursor.drawCentered(lastPosition.x, lastPosition.y, OPTION_DANCE_CURSOR_ONLY_COLOR_TRAIL.state ? Color.white : filter);
|
||||
if (hasMiddle) {
|
||||
cursorMiddle.drawCentered(lastPosition.x, lastPosition.y, OPTION_DANCE_CURSOR_ONLY_COLOR_TRAIL.state ? Color.white : filter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,7 +184,7 @@ public class Cursor {
|
||||
removeCount = trail.size() - max;
|
||||
}
|
||||
|
||||
int cursortraillength = Options.getCursorTrailOverride();
|
||||
int cursortraillength = OPTION_DANCE_CURSOR_TRAIL_OVERRIDE.val;
|
||||
if (cursortraillength > 20) {
|
||||
removeCount = trail.size() - cursortraillength;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package itdelatrisu.opsu.ui;
|
||||
|
||||
import itdelatrisu.opsu.GameImage;
|
||||
import itdelatrisu.opsu.Options;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.FontFormatException;
|
||||
@@ -35,6 +34,7 @@ import org.newdawn.slick.font.effects.ColorEffect;
|
||||
import org.newdawn.slick.font.effects.Effect;
|
||||
import org.newdawn.slick.util.Log;
|
||||
import org.newdawn.slick.util.ResourceLoader;
|
||||
import yugecin.opsudance.options.Configuration;
|
||||
|
||||
/**
|
||||
* Fonts used for drawing.
|
||||
@@ -54,9 +54,9 @@ public class Fonts {
|
||||
* @throws FontFormatException if any font stream data does not contain the required font tables
|
||||
* @throws IOException if a font stream cannot be completely read
|
||||
*/
|
||||
public static void init() throws SlickException, FontFormatException, IOException {
|
||||
public static void init(Configuration config) throws SlickException, FontFormatException, IOException {
|
||||
float fontBase = 12f * GameImage.getUIscale();
|
||||
Font javaFont = Font.createFont(Font.TRUETYPE_FONT, ResourceLoader.getResourceAsStream(Options.FONT_NAME));
|
||||
Font javaFont = Font.createFont(Font.TRUETYPE_FONT, ResourceLoader.getResourceAsStream(config.FONT_NAME));
|
||||
Font font = javaFont.deriveFont(Font.PLAIN, (int) (fontBase * 4 / 3));
|
||||
DEFAULT = new UnicodeFont(font);
|
||||
BOLD = new UnicodeFont(font.deriveFont(Font.BOLD));
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package itdelatrisu.opsu.ui;
|
||||
|
||||
import itdelatrisu.opsu.GameImage;
|
||||
import itdelatrisu.opsu.Options;
|
||||
import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.audio.SoundController;
|
||||
import itdelatrisu.opsu.beatmap.BeatmapParser;
|
||||
@@ -28,14 +27,14 @@ import itdelatrisu.opsu.replay.ReplayImporter;
|
||||
import itdelatrisu.opsu.ui.animations.AnimatedValue;
|
||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||
|
||||
import org.newdawn.slick.Animation;
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Image;
|
||||
import yugecin.opsudance.core.DisplayContainer;
|
||||
import yugecin.opsudance.events.ResolutionOrSkinChangedEvent;
|
||||
import yugecin.opsudance.ui.BackButton;
|
||||
|
||||
import static yugecin.opsudance.options.Options.*;
|
||||
|
||||
/**
|
||||
* Draws common UI components.
|
||||
*/
|
||||
@@ -70,9 +69,6 @@ public class UI {
|
||||
*/
|
||||
public static void init(DisplayContainer displayContainer) {
|
||||
UI.displayContainer = displayContainer;
|
||||
}
|
||||
|
||||
public static void revalidate() {
|
||||
backButton = new BackButton(displayContainer);
|
||||
}
|
||||
|
||||
@@ -151,7 +147,7 @@ public class UI {
|
||||
|
||||
img.drawCentered(displayContainer.width - img.getWidth() / 2f + xOffset, displayContainer.height / 2f);
|
||||
float barHeight = img.getHeight() * 0.9f;
|
||||
float volume = Options.getMasterVolume();
|
||||
float volume = OPTION_MASTER_VOLUME.val / 100f;
|
||||
g.setColor(Color.white);
|
||||
g.fillRoundRect(
|
||||
displayContainer.width - (img.getWidth() * 0.368f) + xOffset,
|
||||
@@ -179,7 +175,8 @@ public class UI {
|
||||
*/
|
||||
public static void changeVolume(int units) {
|
||||
final float UNIT_OFFSET = 0.05f;
|
||||
Options.setMasterVolume(Utils.clamp(Options.getMasterVolume() + (UNIT_OFFSET * units), 0f, 1f));
|
||||
float volume = Utils.clamp(OPTION_MASTER_VOLUME.val / 100f + (UNIT_OFFSET * units), 0f, 1f);
|
||||
OPTION_MASTER_VOLUME.setValue((int) (volume * 100f));
|
||||
if (volumeDisplay == -1)
|
||||
volumeDisplay = 0;
|
||||
else if (volumeDisplay >= VOLUME_DISPLAY_TIME / 10)
|
||||
@@ -196,6 +193,9 @@ public class UI {
|
||||
int progress;
|
||||
|
||||
// determine current action
|
||||
//
|
||||
/*
|
||||
TODO
|
||||
if ((file = OszUnpacker.getCurrentFileName()) != null) {
|
||||
text = "Unpacking new beatmaps...";
|
||||
progress = OszUnpacker.getUnpackerProgress();
|
||||
@@ -211,12 +211,17 @@ public class UI {
|
||||
progress = SoundController.getLoadingProgress();
|
||||
} else
|
||||
return;
|
||||
*/
|
||||
|
||||
if (true) {
|
||||
return; // TODO
|
||||
}
|
||||
|
||||
// draw loading info
|
||||
float marginX = displayContainer.width * 0.02f, marginY = displayContainer.height * 0.02f;
|
||||
float lineY = displayContainer.height - marginY;
|
||||
int lineOffsetY = Fonts.MEDIUM.getLineHeight();
|
||||
if (Options.isLoadVerbose()) {
|
||||
if (OPTION_LOAD_VERBOSE.state) {
|
||||
// verbose: display percentages and file names
|
||||
Fonts.MEDIUM.drawString(
|
||||
marginX, lineY - (lineOffsetY * 2),
|
||||
|
||||
Reference in New Issue
Block a user