Merge branch 'options-redesign'

This commit is contained in:
yugecin 2016-12-11 13:34:28 +01:00
commit 814922e58a
25 changed files with 792 additions and 1370 deletions

BIN
res/control-check-off.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

BIN
res/control-check-on.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

BIN
res/control-sliderball.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

View File

@ -1190,7 +1190,7 @@ public class GameData {
public void sendInitialSliderResult(int time, float x, float y, Color color, Color mirrorcolor) { public void sendInitialSliderResult(int time, float x, float y, Color color, Color mirrorcolor) {
hitResultList.add(new HitObjectResult(time, HIT_SLIDER_INITIAL, x, y, color, null, null, true, false)); hitResultList.add(new HitObjectResult(time, HIT_SLIDER_INITIAL, x, y, color, null, null, true, false));
if (!Dancer.mirror || !GameMod.AUTO.isActive()) { if (!Options.isMirror() || !GameMod.AUTO.isActive()) {
return; return;
} }
float[] m = Utils.mirrorPoint(x, y); float[] m = Utils.mirrorPoint(x, y);

View File

@ -237,6 +237,9 @@ public enum GameImage {
REPLAY_PLAYBACK_HALF ("playback-half", "png", false, false), REPLAY_PLAYBACK_HALF ("playback-half", "png", false, false),
// Non-Game Components // Non-Game Components
CONTROL_SLIDER_BALL ("control-sliderball", "png", false, false),
CONTROL_CHECK_ON ("control-check-on", "png", false, false),
CONTROL_CHECK_OFF ("control-check-off", "png", false, false),
VOLUME ("volume-bg", "png", false, false) { VOLUME ("volume-bg", "png", false, false) {
@Override @Override
protected Image process_sub(Image img, int w, int h) { protected Image process_sub(Image img, int w, int h) {

View File

@ -522,13 +522,13 @@ public class Options {
MAP_START_DELAY ("Map start delay", "StartDelay", "Have a fix amount of time to prepare your play/record", 20, 1, 50) { MAP_START_DELAY ("Map start delay", "StartDelay", "Have a fix amount of time to prepare your play/record", 20, 1, 50) {
@Override @Override
public String getValueString() { public String getValueString() {
return String.valueOf(val * 100); return (val * 100) + "ms";
} }
}, },
MAP_END_DELAY ("Map end delay", "EndDelay", "Have a fix amount of time at the and of the map for a smooth finish", 50, 1, 150) { MAP_END_DELAY ("Map end delay", "EndDelay", "Have a fix amount of time at the and of the map for a smooth finish", 50, 1, 150) {
@Override @Override
public String getValueString() { public String getValueString() {
return String.valueOf(val * 100); return (val * 100) + "ms";
} }
}, },
EPILEPSY_WARNING ("Epilepsy warning image", "EpiWarn", "Show a little warning for flashing colours in the beginning", 0, 0, 20) { EPILEPSY_WARNING ("Epilepsy warning image", "EpiWarn", "Show a little warning for flashing colours in the beginning", 0, 0, 20) {
@ -537,7 +537,7 @@ public class Options {
if (val == 0) { if (val == 0) {
return "Disabled"; return "Disabled";
} }
return String.valueOf(val * 100); return (val * 100) + "ms";
} }
}, },
LOAD_HD_IMAGES ("Load HD Images", "LoadHDImages", String.format("Loads HD (%s) images when available. Increases memory usage and loading times.", GameImage.HD_SUFFIX), true), LOAD_HD_IMAGES ("Load HD Images", "LoadHDImages", String.format("Loads HD (%s) images when available. Increases memory usage and loading times.", GameImage.HD_SUFFIX), true),
@ -609,7 +609,6 @@ public class Options {
REPLAY_SEEKING ("Replay Seeking", "ReplaySeeking", "Enable a seeking bar on the left side of the screen during replays.", false), REPLAY_SEEKING ("Replay Seeking", "ReplaySeeking", "Enable a seeking bar on the left side of the screen during replays.", false),
DISABLE_UPDATER ("Disable Automatic Updates", "DisableUpdater", "Disable automatic checking for updates upon starting opsu!.", false), DISABLE_UPDATER ("Disable Automatic Updates", "DisableUpdater", "Disable automatic checking for updates upon starting opsu!.", false),
ENABLE_WATCH_SERVICE ("Enable Watch Service", "WatchService", "Watch the beatmap directory for changes. Requires a restart.", false), ENABLE_WATCH_SERVICE ("Enable Watch Service", "WatchService", "Watch the beatmap directory for changes. Requires a restart.", false),
DANCE_MOVER ("Mover algorithm", "Mover", "Algorithm that decides how to move from note to note" ) { DANCE_MOVER ("Mover algorithm", "Mover", "Algorithm that decides how to move from note to note" ) {
@Override @Override
public Object[] getListItems() { public Object[] getListItems() {
@ -637,41 +636,21 @@ public class Options {
Dancer.instance.setMoverFactoryIndex(i); Dancer.instance.setMoverFactoryIndex(i);
} }
}, },
DANCE_QUAD_BEZ_AGGRESSIVENESS ("Quadratic Bezier aggressiveness", "QuadBezAgr", "AKA initial D factor", 50, 0, 200) { DANCE_QUAD_BEZ_AGGRESSIVENESS ("Quadratic Bezier aggressiveness", "QuadBezAgr", "AKA initial D factor", 50, 0, 200) {
@Override @Override
public String getValueString() { public String getValueString() {
return val + ""; return String.valueOf(val);
}
@Override
public void drag(GameContainer container, int d) {
super.drag(container, d);
QuadraticBezierMover.aggressiveness = val;
} }
@Override @Override
public boolean showCondition() { public boolean showCondition() {
return Dancer.moverFactories[Dancer.instance.getMoverFactoryIndex()] instanceof QuadraticBezierMoverFactory; return Dancer.moverFactories[Dancer.instance.getMoverFactoryIndex()] instanceof QuadraticBezierMoverFactory;
} }
@Override
public void read(String s) {
super.read(s);
QuadraticBezierMover.aggressiveness = val;
}
}, },
DANCE_QUAD_BEZ_SLIDER_AGGRESSIVENESS_FACTOR ("Slider exit aggressiveness factor", "CubBezSliderExitAgr", "AKA initial D factor for sliderexits", 4, 1, 6) {
DANCE_QUAD_BEZ_SLIDER_AGGRESSIVENESS_FACTOR ("Slider exit aggressiveness factor", "CubBezSliderExitAgr", "AKA initial D factor for sliderexits", 40, 10, 60) {
@Override @Override
public String getValueString() { public String getValueString() {
return val / 10 + ""; return String.valueOf(val);
}
@Override
public void drag(GameContainer container, int d) {
super.drag(container, d);
QuadraticBezierMover.sliderExitAggressivenessfactor = val / 10;
} }
@Override @Override
@ -679,43 +658,17 @@ public class Options {
return DANCE_QUAD_BEZ_AGGRESSIVENESS.showCondition() return DANCE_QUAD_BEZ_AGGRESSIVENESS.showCondition()
&& Dancer.sliderMoverController instanceof DefaultSliderMoverController; && Dancer.sliderMoverController instanceof DefaultSliderMoverController;
} }
@Override
public void read(String s) {
super.read(s);
QuadraticBezierMover.sliderExitAggressivenessfactor = val / 10;
}
}, },
DANCE_QUAD_BEZ_USE_CUBIC_ON_SLIDERS ("Use cubic bezier before sliders", "QuadBezCubicSliders", "Slider entry looks better using this", true) { DANCE_QUAD_BEZ_USE_CUBIC_ON_SLIDERS ("Use cubic bezier before sliders", "QuadBezCubicSliders", "Slider entry looks better using this", true) {
@Override
public void click(GameContainer container) {
super.click(container);
QuadraticBezierMoverFactory.cubicForSliderEntries = bool;
}
@Override @Override
public boolean showCondition() { public boolean showCondition() {
return DANCE_QUAD_BEZ_SLIDER_AGGRESSIVENESS_FACTOR.showCondition(); return DANCE_QUAD_BEZ_SLIDER_AGGRESSIVENESS_FACTOR.showCondition();
} }
@Override
public void read(String s) {
super.read(s);
QuadraticBezierMoverFactory.cubicForSliderEntries = bool;
}
}, },
DANCE_QUAD_BEZ_CUBIC_AGGRESSIVENESS_FACTOR ("Slider entry aggressiveness factor", "CubBezSliderEntryAgr", "AKA initial D factor for sliderentries", 4, 1, 6) {
DANCE_QUAD_BEZ_CUBIC_AGGRESSIVENESS_FACTOR ("Slider entry aggressiveness factor", "CubBezSliderEntryAgr", "AKA initial D factor for sliderentries", 40, 10, 60) {
@Override @Override
public String getValueString() { public String getValueString() {
return val / 10 + ""; return String.valueOf(val);
}
@Override
public void drag(GameContainer container, int d) {
super.drag(container, d);
CubicBezierMover.aggressivenessfactor = val / 10;
} }
@Override @Override
@ -723,14 +676,7 @@ public class Options {
return DANCE_QUAD_BEZ_USE_CUBIC_ON_SLIDERS.showCondition() return DANCE_QUAD_BEZ_USE_CUBIC_ON_SLIDERS.showCondition()
&& DANCE_QUAD_BEZ_USE_CUBIC_ON_SLIDERS.getBooleanValue(); && DANCE_QUAD_BEZ_USE_CUBIC_ON_SLIDERS.getBooleanValue();
} }
@Override
public void read(String s) {
super.read(s);
CubicBezierMover.aggressivenessfactor = val / 10;
}
}, },
DANCE_MOVER_DIRECTION ("Mover direction", "MoverDirection", "The direction the mover goes" ) { DANCE_MOVER_DIRECTION ("Mover direction", "MoverDirection", "The direction the mover goes" ) {
@Override @Override
public String getValueString() { public String getValueString() {
@ -757,7 +703,6 @@ public class Options {
Dancer.moverDirection = MoverDirection.values()[Integer.parseInt(s)]; Dancer.moverDirection = MoverDirection.values()[Integer.parseInt(s)];
} }
}, },
DANCE_SLIDER_MOVER_TYPE ("Slider mover", "SliderMover", "How to move in sliders") { DANCE_SLIDER_MOVER_TYPE ("Slider mover", "SliderMover", "How to move in sliders") {
@Override @Override
public String getValueString() { public String getValueString() {
@ -785,7 +730,6 @@ public class Options {
Dancer.sliderMoverController = Dancer.sliderMovers[val = Integer.parseInt(s)]; Dancer.sliderMoverController = Dancer.sliderMovers[val = Integer.parseInt(s)];
} }
}, },
DANCE_SPINNER ("Spinner", "Spinner", "Spinner style") { DANCE_SPINNER ("Spinner", "Spinner", "Spinner style") {
@Override @Override
public Object[] getListItems() { public Object[] getListItems() {
@ -812,96 +756,17 @@ public class Options {
Dancer.instance.setSpinnerIndex(Integer.parseInt(s)); Dancer.instance.setSpinnerIndex(Integer.parseInt(s));
} }
}, },
DANCE_SPINNER_DELAY ("Spinner delay", "SpinnerDelay", "Fiddle with this if spinner goes too fast.", 3, 0, 20) {
DANCE_SPINNER_DELAY ("Spinner delay", "SpinnerDelay", "Fiddle with this if spinner goes too fast.", Spinner.DELAY, 0, 200) {
@Override @Override
public String getValueString() { public String getValueString() {
return String.format("%dms", val / 10); return String.format("%dms", val);
}
@Override
public void drag(GameContainer container, int d) {
super.drag(container, d);
Spinner.DELAY = val / 10;
}
@Override
public void read(String s) {
super.read(s);
Spinner.DELAY = val / 10;
} }
}, },
DANCE_LAZY_SLIDERS ("Lazy sliders", "LazySliders", "Don't do short sliders", false),
DANCE_LAZY_SLIDERS ("Lazy sliders", "LazySliders", "Don't do short sliders", Dancer.LAZY_SLIDERS) { DANCE_ONLY_CIRCLE_STACKS ("Only circle stacks", "CircleStacks", "Only do circle movement on stacks", false),
@Override DANCE_CIRCLE_STREAMS ("Circle streams", "CircleStreams", "Make circles while streaming", false),
public void click(GameContainer container) { DANCE_MIRROR ("Mirror collage", "MirrorCollage", "Hypnotizing stuff. Toggle this ingame by pressing the M key.", false),
bool = !bool; DANCE_DRAW_APPROACH ("Draw approach circles", "DrawApproach", "Can get a bit busy when using mirror collage", true),
Dancer.LAZY_SLIDERS = bool;
}
@Override
public void read(String s) {
super.read(s);
Dancer.LAZY_SLIDERS = bool;
}
},
DANCE_ONLY_CIRCLE_STACKS ("Only circle stacks", "CircleStacks", "Only do circle movement on stacks", AutoMoverFactory.ONLY_CIRCLE_STACKS) {
@Override
public void click(GameContainer container) {
bool = !bool;
AutoMoverFactory.ONLY_CIRCLE_STACKS = bool;
}
@Override
public void read(String s) {
super.read(s);
AutoMoverFactory.ONLY_CIRCLE_STACKS = bool;
}
},
DANCE_CIRCLE_STREAMS ("Circle streams", "CircleStreams", "Make circles while streaming", AutoMoverFactory.CIRCLE_STREAM == 58) {
@Override
public void click(GameContainer container) {
bool = !bool;
AutoMoverFactory.CIRCLE_STREAM = bool ? 58 : 85;
}
@Override
public void read(String s) {
super.read(s);
AutoMoverFactory.CIRCLE_STREAM = bool ? 58 : 85;
}
},
DANCE_MIRROR ("Mirror collage", "MirrorCollage", "Hypnotizing stuff. Toggle this ingame by pressing the M key.", Dancer.mirror) {
@Override
public void click(GameContainer container) {
bool = !bool;
Dancer.mirror = bool;
}
@Override
public void read(String s) {
super.read(s);
Dancer.mirror = bool;
}
},
DANCE_DRAW_APPROACH ("Draw approach circles", "DrawApproach", "Can get a bit busy when using mirror collage", Dancer.drawApproach) {
@Override
public void click(GameContainer container) {
bool = !bool;
Dancer.drawApproach = bool;
}
@Override
public void read(String s) {
super.read(s);
Dancer.drawApproach = bool;
}
},
DANCE_OBJECT_COLOR_OVERRIDE ("Object color override", "ObjColorOverride", "Override object colors") { DANCE_OBJECT_COLOR_OVERRIDE ("Object color override", "ObjColorOverride", "Override object colors") {
@Override @Override
public String getValueString() { public String getValueString() {
@ -928,7 +793,6 @@ public class Options {
Dancer.colorOverride = ObjectColorOverrides.values()[Integer.parseInt(s)]; Dancer.colorOverride = ObjectColorOverrides.values()[Integer.parseInt(s)];
} }
}, },
DANCE_OBJECT_COLOR_OVERRIDE_MIRRORED ("Collage object color override", "ObjColorMirroredOverride", "Override collage object colors") { DANCE_OBJECT_COLOR_OVERRIDE_MIRRORED ("Collage object color override", "ObjColorMirroredOverride", "Override collage object colors") {
@Override @Override
public String getValueString() { public String getValueString() {
@ -955,26 +819,12 @@ public class Options {
Dancer.colorMirrorOverride = ObjectColorOverrides.values()[Integer.parseInt(s)]; Dancer.colorMirrorOverride = ObjectColorOverrides.values()[Integer.parseInt(s)];
} }
}, },
DANCE_RGB_OBJECT_INC ("RGB objects increment", "RGBInc", "Amount of hue to shift, used for rainbow object override", 70, -1800, 1800) {
DANCE_RGB_OBJECT_INC ("RGB objects increment", "RGBInc", "Amount of hue to shift, used for rainbow object override", Dancer.rgbhueinc, -1800, 1800) {
@Override @Override
public String getValueString() { public String getValueString() {
return String.format("%.1f°", val / 10f); return String.format("%.1f°", val / 10f);
} }
@Override
public void drag(GameContainer container, int d) {
super.drag(container, d);
Dancer.rgbhueinc = val;
}
@Override
public void read(String s) {
super.read(s);
Dancer.rgbhueinc = val;
}
}, },
DANCE_CURSOR_COLOR_OVERRIDE ("Cursor color override", "CursorColorOverride", "Override cursor color") { DANCE_CURSOR_COLOR_OVERRIDE ("Cursor color override", "CursorColorOverride", "Override cursor color") {
@Override @Override
public String getValueString() { public String getValueString() {
@ -1001,7 +851,6 @@ public class Options {
Dancer.cursorColorOverride = CursorColorOverrides.values()[Integer.parseInt(s)]; Dancer.cursorColorOverride = CursorColorOverrides.values()[Integer.parseInt(s)];
} }
}, },
DANCE_CURSOR_MIRROR_COLOR_OVERRIDE ("Cursor mirror color override", "CursorMirrorColorOverride", "Override mirror cursor color") { DANCE_CURSOR_MIRROR_COLOR_OVERRIDE ("Cursor mirror color override", "CursorMirrorColorOverride", "Override mirror cursor color") {
@Override @Override
public String getValueString() { public String getValueString() {
@ -1028,41 +877,14 @@ public class Options {
Dancer.cursorColorMirrorOverride = CursorColorOverrides.values()[Integer.parseInt(s)]; Dancer.cursorColorMirrorOverride = CursorColorOverrides.values()[Integer.parseInt(s)];
} }
}, },
DANCE_CURSOR_ONLY_COLOR_TRAIL ("Only color cursor trail", "OnlyColorTrail", "Don't color the cursor, only the trail", false),
DANCE_CURSOR_ONLY_COLOR_TRAIL ("Only color cursor trail", "OnlyColorTrail", "Don't color the cursor, only the trail", Dancer.onlycolortrail) { DANCE_RGB_CURSOR_INC ("RGB cursor increment", "RGBCursorInc", "Amount of hue to shift, used for rainbow cursor override", 100, -2000, 2000) {
@Override
public void click(GameContainer container) {
bool = !bool;
Dancer.onlycolortrail = bool;
}
@Override
public void read(String s) {
super.read(s);
Dancer.onlycolortrail = bool;
}
},
DANCE_RGB_CURSOR_INC ("RGB cursor increment", "RGBCursorInc", "Amount of hue to shift, used for rainbow cursor override", Dancer.rgbhueinc, -2000, 2000) {
@Override @Override
public String getValueString() { public String getValueString() {
return String.format("%.2f°", val / 1000f); return String.format("%.2f°", val / 1000f);
} }
@Override
public void drag(GameContainer container, int d) {
super.drag(container, d);
Dancer.rgbcursorhueinc = val;
}
@Override
public void read(String s) {
super.read(s);
Dancer.rgbcursorhueinc = val;
}
}, },
DANCE_CURSOR_TRAIL_OVERRIDE ("Cursor trail length override", "CursorTrailOverride", "Override cursor trail length", 20, 20, 400) {
DANCE_CURSOR_TRAIL_OVERRIDE ("Cursor trail length override", "CursorTrailOverride", "Override cursor trail length", Dancer.cursortraillength, 20, 400) {
@Override @Override
public String getValueString() { public String getValueString() {
if (val == 20) { if (val == 20) {
@ -1070,141 +892,20 @@ public class Options {
} }
return "" + val; return "" + val;
} }
@Override
public void drag(GameContainer container, int d) {
super.drag(container, d);
Dancer.cursortraillength = val;
}
@Override
public void read(String s) {
super.read(s);
Dancer.cursortraillength = val;
}
}, },
DANCE_HIDE_OBJECTS ("Don't draw objects", "HideObj", "If you only want to see cursors :)", false),
DANCE_HIDE_OBJECTS ("Don't draw objects", "HideObj", "If you only want to see cursors :)", Dancer.hideobjects) { DANCE_REMOVE_BG ("Use black background instead of image", "RemoveBG", "Hello darkness my old friend", true),
@Override DANCE_CIRLCE_IN_SLOW_SLIDERS ("Do circles in slow sliders", "CircleInSlider", "Circle around sliderball in lazy & slow sliders", false),
public void click(GameContainer container) { DANCE_CIRLCE_IN_LAZY_SLIDERS ("Do circles in lazy sliders", "CircleInLazySlider", "Circle in hitcircle in lazy sliders", false),
bool = !bool; DANCE_HIDE_UI ("Hide all UI", "HideUI", ".", true),
Dancer.hideobjects = bool; DANCE_ENABLE_SB ("Enable storyboard editor", "EnableStoryBoard", "Dance storyboard", false),
} DANCE_HIDE_WATERMARK ("Hide watermark", "HideWaterMark", "Hide the githublink in the top left corner of the playfield", false),
PIPPI_ENABLE ("Pippi", "Pippi", "Move in circles like dancing pippi (osu! april fools joke 2016)", false),
@Override PIPPI_RADIUS_PERCENT ("Pippi radius", "PippiRad", "Radius of pippi, percentage of circle radius", 100, 0, 100) {
public void read(String s) {
super.read(s);
Dancer.hideobjects = bool;
}
},
DANCE_REMOVE_BG ("Use black background instead of image", "RemoveBG", "Hello darkness my old friend", Dancer.removebg) {
@Override
public void click(GameContainer container) {
bool = !bool;
Dancer.removebg = bool;
}
@Override
public void read(String s) {
super.read(s);
Dancer.removebg = bool;
}
},
DANCE_CIRLCE_IN_SLOW_SLIDERS ("Do circles in slow sliders", "CircleInSlider", "Circle around sliderball in lazy & slow sliders", Pippi.circleSlowSliders) {
@Override
public void click(GameContainer container) {
bool = !bool;
Pippi.circleSlowSliders = bool;
}
@Override
public void read(String s) {
super.read(s);
Pippi.circleSlowSliders = bool;
}
},
DANCE_CIRLCE_IN_LAZY_SLIDERS ("Do circles in lazy sliders", "CircleInLazySlider", "Circle in hitcircle in lazy sliders", Pippi.circleLazySliders) {
@Override
public void click(GameContainer container) {
bool = !bool;
Pippi.circleLazySliders = bool;
}
@Override
public void read(String s) {
super.read(s);
Pippi.circleLazySliders = bool;
}
},
DANCE_HIDE_UI ("Hide all UI", "HideUI", ".", Dancer.hideui) {
@Override
public void click(GameContainer container) {
bool = !bool;
Dancer.hideui = bool;
}
@Override
public void read(String s) {
super.read(s);
Dancer.hideui = bool;
}
},
DANCE_ENABLE_SB ("Enable storyboard editor", "EnableStoryBoard", "Dance storyboard", false) {
@Override
public void click(GameContainer container) {
super.click(container);
SBOverlay.isActive = bool;
}
@Override
public void read(String s) {
super.read(s);
SBOverlay.isActive = bool;
}
},
DANCE_HIDE_WATERMARK ("Hide watermark", "HideWaterMark", "Hide the githublink in the top left corner of the playfield", false) {
@Override
public String getValueString() {
return Dancer.hidewatermark ? "Yes" : "No";
}
@Override
public void click(GameContainer container) {
Dancer.hidewatermark = false;
}
@Override
public boolean showRWM() {
return !Dancer.hidewatermark;
}
},
PIPPI_ENABLE ("Pippi", "Pippi", "Move in circles like dancing pippi (osu! april fools joke 2016)", Pippi.enabled) {
@Override
public void click(GameContainer container) {
bool = !bool;
Pippi.enabled = bool;
}
@Override
public void read(String s) {
super.read(s);
Pippi.enabled = bool;
}
},
PIPPI_RADIUS_PERCENT ("Pippi radius", "PippiRad", "Radius of pippi, percentage of circle radius", 200, 0, 200) {
@Override @Override
public String getValueString() { public String getValueString() {
return (val / 2) + "%"; return (val / 2) + "%";
} }
@Override @Override
public void drag(GameContainer container, int d) { public void drag(GameContainer container, int d) {
super.drag(container, d); super.drag(container, d);
@ -1217,72 +918,20 @@ public class Options {
Pippi.setRadiusPercent(val / 2); Pippi.setRadiusPercent(val / 2);
} }
}, },
PIPPI_ANGLE_INC_MUL("Pippi angle increment multiplier", "PippiAngIncMul", "How fast pippi's angle increments", 10, -200, 200) {
PIPPI_ANGLE_INC_MUL("Pippi angle increment multiplier", "PippiAngIncMul", "How fast pippi's angle increments", Pippi.angleInc, -200, 200) {
@Override @Override
public String getValueString() { public String getValueString() {
return String.format("x%.1f", val / 10f); return String.format("x%.1f", val / 10f);
} }
@Override
public void drag(GameContainer container, int d) {
super.drag(container, d);
Pippi.angleInc = val;
}
@Override
public void read(String s) {
super.read(s);
Pippi.angleInc = val;
}
}, },
PIPPI_ANGLE_INC_MUL_SLIDER ("Pippi angle increment multiplier slider", "PippiAngIncMulSlider", "Same as above, but in sliders", 50, -200, 200) {
PIPPI_ANGLE_INC_MUL_SLIDER ("Pippi angle increment multiplier slider", "PippiAngIncMulSlider", "Same as above, but in sliders", Pippi.angleSliderInc, -200, 200) {
@Override @Override
public String getValueString() { public String getValueString() {
return String.format("x%.1f", val / 10f); return String.format("x%.1f", val / 10f);
} }
@Override
public void drag(GameContainer container, int d) {
super.drag(container, d);
Pippi.angleSliderInc = val;
}
@Override
public void read(String s) {
super.read(s);
Pippi.angleSliderInc = val;
}
}, },
PIPPI_SLIDER_FOLLOW_EXPAND ("Followcircle expand", "PippiFollowExpand", "Increase radius in followcircles", false),
PIPPI_SLIDER_FOLLOW_EXPAND ("Followcircle expand", "PippiFollowExpand", "Increase radius in followcircles", Pippi.followcircleExpand) { PIPPI_PREVENT_WOBBLY_STREAMS ("Prevent wobbly streams", "PippiPreventWobblyStreams", "Force linear mover while doing streams to prevent wobbly pippi", true);
@Override
public void click(GameContainer container) {
bool = !bool;
Pippi.followcircleExpand = bool;
}
@Override
public void read(String s) {
super.read(s);
Pippi.followcircleExpand = bool;
}
},
PIPPI_PREVENT_WOBBLY_STREAMS ("Prevent wobbly streams", "PippiPreventWobblyStreams", "Force linear mover while doing streams to prevent wobbly pippi", Pippi.preventWobblyStreams) {
@Override
public void click(GameContainer container) {
bool = !bool;
Pippi.preventWobblyStreams = bool;
}
@Override
public void read(String s) {
super.read(s);
Pippi.preventWobblyStreams = bool;
}
};
/** Option name. */ /** Option name. */
@ -1306,7 +955,7 @@ public class Options {
private int max, min; private int max, min;
/** Option types. */ /** Option types. */
private enum OptionType { BOOLEAN, NUMERIC, OTHER }; public enum OptionType { BOOLEAN, NUMERIC, OTHER };
/** Whether or not this is a numeric option. */ /** Whether or not this is a numeric option. */
private OptionType type = OptionType.OTHER; private OptionType type = OptionType.OTHER;
@ -1385,8 +1034,6 @@ public class Options {
*/ */
public String getDescription() { return description; } public String getDescription() { return description; }
public boolean showRWM() { return false; } // this is probably a shitty way to implement this :)
/** /**
* Returns the boolean value for the option, if applicable. * Returns the boolean value for the option, if applicable.
* @return the boolean value * @return the boolean value
@ -1456,7 +1103,7 @@ public class Options {
* @param container the game container * @param container the game container
* @param d the dragged distance (modified by multiplier) * @param d the dragged distance (modified by multiplier)
*/ */
public void drag(GameContainer container, int d) { public void drag(GameContainer container, int d) { // TODO rename this
if (type == OptionType.NUMERIC) if (type == OptionType.NUMERIC)
val = Utils.clamp(val + d, min, max); val = Utils.clamp(val + d, min, max);
} }
@ -1495,8 +1142,8 @@ public class Options {
bool = Boolean.parseBoolean(s); bool = Boolean.parseBoolean(s);
} }
public boolean isDragOption() { public OptionType getType() {
return type == OptionType.NUMERIC; return type;
} }
public int getMinValue() { public int getMinValue() {
@ -1698,6 +1345,88 @@ public class Options {
} }
} }
public static int getQuadBezAggressiveness() {
return GameOption.DANCE_QUAD_BEZ_AGGRESSIVENESS.getIntegerValue();
}
public static int getQuadBezSliderAggressiveness() {
return GameOption.DANCE_QUAD_BEZ_SLIDER_AGGRESSIVENESS_FACTOR.getIntegerValue();
}
public static boolean isQuadBezCubicEnabled() {
return GameOption.DANCE_QUAD_BEZ_USE_CUBIC_ON_SLIDERS.getBooleanValue();
}
public static int getQuadBezSliderEntryAggressiveness() {
return GameOption.DANCE_QUAD_BEZ_CUBIC_AGGRESSIVENESS_FACTOR.getIntegerValue();
}
public static int getSpinnerDelay() {
return GameOption.DANCE_SPINNER_DELAY.getIntegerValue();
}
public static boolean isLazySliders() {
return GameOption.DANCE_LAZY_SLIDERS.getBooleanValue();
}
public static boolean isOnlyCircleStacks() {
return GameOption.DANCE_ONLY_CIRCLE_STACKS.getBooleanValue();
}
public static boolean isCircleStreams() {
return GameOption.DANCE_CIRCLE_STREAMS.getBooleanValue();
}
public static boolean isMirror() {
return GameOption.DANCE_MIRROR.getBooleanValue();
}
public static void setMirror(boolean mirror) {
GameOption.DANCE_MIRROR.setValue(mirror);
}
public static boolean isDrawApproach() {
return GameOption.DANCE_DRAW_APPROACH.getBooleanValue();
}
public static int getRGBObjInc() {
return GameOption.DANCE_RGB_OBJECT_INC.getIntegerValue();
}
public static boolean isCursorOnlyColorTrail() {
return GameOption.DANCE_CURSOR_ONLY_COLOR_TRAIL.getBooleanValue();
}
public static int getRGBCursorInc() {
return GameOption.DANCE_RGB_CURSOR_INC.getIntegerValue();
}
public static int getCursorTrailOverride() {
return GameOption.DANCE_CURSOR_TRAIL_OVERRIDE.getIntegerValue();
}
public static boolean isHideObjects() {
return GameOption.DANCE_HIDE_OBJECTS.getBooleanValue();
}
public static boolean isRemoveBG() {
return GameOption.DANCE_REMOVE_BG.getBooleanValue();
}
public static boolean isCircleInSlowSliders() {
return GameOption.DANCE_CIRLCE_IN_SLOW_SLIDERS.getBooleanValue();
}
public static boolean isCircleInLazySliders() {
return GameOption.DANCE_CIRLCE_IN_LAZY_SLIDERS.getBooleanValue();
}
public static boolean isHideUI() {
return GameOption.DANCE_HIDE_UI.getBooleanValue();
}
public static boolean isEnableSB() {
return GameOption.DANCE_ENABLE_SB.getBooleanValue();
}
public static boolean isHideWM() {
return GameOption.DANCE_HIDE_WATERMARK.getBooleanValue();
}
public static boolean isPippiEnabled() {
return GameOption.PIPPI_ENABLE.getBooleanValue();
}
public static int getPippiAngIncMultiplier() {
return GameOption.PIPPI_ANGLE_INC_MUL.getIntegerValue();
}
public static int getPippiAngIncMultiplierSlider() {
return GameOption.PIPPI_ANGLE_INC_MUL_SLIDER.getIntegerValue();
}
public static boolean isPippiFollowcircleExpand() {
return GameOption.PIPPI_SLIDER_FOLLOW_EXPAND.getBooleanValue();
}
public static boolean isPippiPreventWobblyStreams() {
return GameOption.PIPPI_PREVENT_WOBBLY_STREAMS.getBooleanValue();
}
/** /**
* Returns whether or not fullscreen mode is enabled. * Returns whether or not fullscreen mode is enabled.
* @return true if enabled * @return true if enabled

View File

@ -130,7 +130,7 @@ public class Circle extends GameObject {
float oldAlpha = Colors.WHITE_FADE.a; float oldAlpha = Colors.WHITE_FADE.a;
Colors.WHITE_FADE.a = color.a = alpha; Colors.WHITE_FADE.a = color.a = alpha;
if (timeDiff >= 0 && !GameMod.HIDDEN.isActive() && Dancer.drawApproach) if (timeDiff >= 0 && !GameMod.HIDDEN.isActive() && Options.isDrawApproach())
GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale).drawCentered(x, y, color); GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale).drawCentered(x, y, color);
GameImage.HITCIRCLE.getImage().drawCentered(x, y, color); GameImage.HITCIRCLE.getImage().drawCentered(x, y, color);
boolean overlayAboveNumber = Options.getSkin().isHitCircleOverlayAboveNumber(); boolean overlayAboveNumber = Options.getSkin().isHitCircleOverlayAboveNumber();
@ -196,7 +196,7 @@ public class Circle extends GameObject {
if (trackPosition > time + hitResultOffset[GameData.HIT_50]) { if (trackPosition > time + hitResultOffset[GameData.HIT_50]) {
if (isAutoMod) {// "auto" mod: catch any missed notes due to lag if (isAutoMod) {// "auto" mod: catch any missed notes due to lag
data.hitResult(time, GameData.HIT_300, x, y, color, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false); data.hitResult(time, GameData.HIT_300, x, y, color, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false);
if (Dancer.mirror && GameMod.AUTO.isActive()) { if (Options.isMirror() && GameMod.AUTO.isActive()) {
float[] m = Utils.mirrorPoint(x, y); float[] m = Utils.mirrorPoint(x, y);
data.hitResult(time, GameData.HIT_300, m[0], m[1], mirrorColor, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false, false); data.hitResult(time, GameData.HIT_300, m[0], m[1], mirrorColor, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false, false);
} }
@ -211,7 +211,7 @@ public class Circle extends GameObject {
else if (isAutoMod) { else if (isAutoMod) {
if (Math.abs(trackPosition - time) < hitResultOffset[GameData.HIT_300]) { if (Math.abs(trackPosition - time) < hitResultOffset[GameData.HIT_300]) {
data.hitResult(time, GameData.HIT_300, x, y, color, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false); data.hitResult(time, GameData.HIT_300, x, y, color, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false);
if (Dancer.mirror && GameMod.AUTO.isActive()) { if (Options.isMirror() && GameMod.AUTO.isActive()) {
float[] m = Utils.mirrorPoint(x, y); float[] m = Utils.mirrorPoint(x, y);
data.hitResult(time, GameData.HIT_300, m[0], m[1], mirrorColor, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false, false); data.hitResult(time, GameData.HIT_300, m[0], m[1], mirrorColor, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false, false);
} }

View File

@ -311,7 +311,7 @@ public class Slider extends GameObject {
if (mirror) { if (mirror) {
g.rotate(x, y, -180f); g.rotate(x, y, -180f);
} }
if (!GameMod.HIDDEN.isActive() && Dancer.drawApproach) { if (!GameMod.HIDDEN.isActive() && Options.isDrawApproach()) {
GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale).drawCentered(x, y, color); GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale).drawCentered(x, y, color);
} }
g.popTransform(); g.popTransform();
@ -515,7 +515,7 @@ public class Slider extends GameObject {
data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result, data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result,
cx, cy, color, comboEnd, hitObject, type, sliderHeldToEnd, cx, cy, color, comboEnd, hitObject, type, sliderHeldToEnd,
currentRepeats + 1, curve, sliderHeldToEnd); currentRepeats + 1, curve, sliderHeldToEnd);
if (Dancer.mirror && GameMod.AUTO.isActive()) { if (Options.isMirror() && GameMod.AUTO.isActive()) {
float[] m = Utils.mirrorPoint(cx, cy); float[] m = Utils.mirrorPoint(cx, cy);
data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result, data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result,
m[0], m[1], mirrorColor, comboEnd, hitObject, type, sliderHeldToEnd, m[0], m[1], mirrorColor, comboEnd, hitObject, type, sliderHeldToEnd,

View File

@ -299,14 +299,13 @@ public class Game extends BasicGameState {
private final int state; private final int state;
private final Cursor mirrorCursor; private final Cursor mirrorCursor;
private final SBOverlay sbOverlay; private SBOverlay sbOverlay;
private FakeCombinedCurve knorkesliders; private FakeCombinedCurve knorkesliders;
public Game(int state) { public Game(int state) {
this.state = state; this.state = state;
mirrorCursor = new Cursor(true); mirrorCursor = new Cursor(true);
sbOverlay = new SBOverlay(this);
} }
public void loadCheckpoint(int checkpoint) { public void loadCheckpoint(int checkpoint) {
@ -347,6 +346,7 @@ public class Game extends BasicGameState {
@Override @Override
public void init(GameContainer container, StateBasedGame game) public void init(GameContainer container, StateBasedGame game)
throws SlickException { throws SlickException {
this.sbOverlay = new SBOverlay(this, container);
this.container = container; this.container = container;
this.game = game; this.game = game;
input = container.getInput(); input = container.getInput();
@ -354,8 +354,6 @@ public class Game extends BasicGameState {
int width = container.getWidth(); int width = container.getWidth();
int height = container.getHeight(); int height = container.getHeight();
sbOverlay.init(container, input, width, height);
// create offscreen graphics // create offscreen graphics
offscreen = new Image(width, height); offscreen = new Image(width, height);
gOffscreen = offscreen.getGraphics(); gOffscreen = offscreen.getGraphics();
@ -396,7 +394,7 @@ public class Game extends BasicGameState {
} }
// background // background
if (!Dancer.removebg && GameMod.AUTO.isActive()) { if (!Options.isRemoveBG() && GameMod.AUTO.isActive()) {
float dimLevel = Options.getBackgroundDim(); float dimLevel = Options.getBackgroundDim();
if (trackPosition < firstObjectTime) { if (trackPosition < firstObjectTime) {
if (timeDiff < approachTime) if (timeDiff < approachTime)
@ -510,7 +508,7 @@ public class Game extends BasicGameState {
Colors.BLACK_ALPHA.a = a; Colors.BLACK_ALPHA.a = a;
} }
if (!Dancer.hideui || !GameMod.AUTO.isActive()) { if (!Options.isHideUI() || !GameMod.AUTO.isActive()) {
data.drawGameElements(g, true, objectIndex == 0); data.drawGameElements(g, true, objectIndex == 0);
} }
@ -548,7 +546,7 @@ public class Game extends BasicGameState {
// non-break // non-break
else { else {
if (!GameMod.AUTO.isActive() || !Dancer.hideui) { if (!GameMod.AUTO.isActive() || !Options.isHideUI()) {
// game elements // game elements
data.drawGameElements(g, false, objectIndex == 0); data.drawGameElements(g, false, objectIndex == 0);
@ -672,11 +670,11 @@ public class Game extends BasicGameState {
} }
} }
if (!Dancer.hideui && GameMod.AUTO.isActive()) if (!Options.isHideUI() && GameMod.AUTO.isActive())
GameImage.UNRANKED.getImage().drawCentered(width / 2, height * 0.077f); GameImage.UNRANKED.getImage().drawCentered(width / 2, height * 0.077f);
// draw replay speed button // draw replay speed button
if (isReplay || (!Dancer.hideui && GameMod.AUTO.isActive())) if (isReplay || (!Options.isHideUI()&& GameMod.AUTO.isActive()))
playbackSpeed.getButton().draw(); playbackSpeed.getButton().draw();
// draw music position bar (for replay seeking) // draw music position bar (for replay seeking)
@ -711,7 +709,7 @@ public class Game extends BasicGameState {
UI.draw(g, replayX, replayY, replayKeyPressed); UI.draw(g, replayX, replayY, replayKeyPressed);
else if (GameMod.AUTO.isActive()) { else if (GameMod.AUTO.isActive()) {
UI.draw(g, (int) autoMousePosition.x, (int) autoMousePosition.y, autoMousePressed); UI.draw(g, (int) autoMousePosition.x, (int) autoMousePosition.y, autoMousePressed);
if (Dancer.mirror && GameMod.AUTO.isActive()) { if (Options.isMirror() && GameMod.AUTO.isActive()) {
double dx = autoMousePosition.x - Options.width / 2d; double dx = autoMousePosition.x - Options.width / 2d;
double dy = autoMousePosition.y - Options.height / 2d; double dy = autoMousePosition.y - Options.height / 2d;
double d = Math.sqrt(dx * dx + dy * dy); double d = Math.sqrt(dx * dx + dy * dy);
@ -724,9 +722,9 @@ public class Game extends BasicGameState {
else else
UI.draw(g); UI.draw(g);
sbOverlay.render(container, game, g); sbOverlay.render(container, g);
if (!Dancer.hidewatermark) { if (!Options.isHideWM()) {
Fonts.SMALL.drawString(0.3f, 0.3f, "opsu!dance " + Updater.get().getCurrentVersion() + " by robin_be | https://github.com/yugecin/opsu-dance"); Fonts.SMALL.drawString(0.3f, 0.3f, "opsu!dance " + Updater.get().getCurrentVersion() + " by robin_be | https://github.com/yugecin/opsu-dance");
} }
} }
@ -741,7 +739,7 @@ public class Game extends BasicGameState {
} }
yugecin.opsudance.spinners.Spinner.update(delta); yugecin.opsudance.spinners.Spinner.update(delta);
int mouseX = input.getMouseX(), mouseY = input.getMouseY(); int mouseX = input.getMouseX(), mouseY = input.getMouseY();
sbOverlay.update(mouseX, mouseY); sbOverlay.update(delta, mouseX, mouseY);
skipButton.hoverUpdate(delta, mouseX, mouseY); skipButton.hoverUpdate(delta, mouseX, mouseY);
if (isReplay || GameMod.AUTO.isActive()) if (isReplay || GameMod.AUTO.isActive())
playbackSpeed.getButton().hoverUpdate(delta, mouseX, mouseY); playbackSpeed.getButton().hoverUpdate(delta, mouseX, mouseY);
@ -853,7 +851,7 @@ public class Game extends BasicGameState {
} }
// update in-game scoreboard // update in-game scoreboard
if (!Dancer.hideui && previousScores != null && trackPosition > firstObjectTime) { if (!Options.isHideUI() && previousScores != null && trackPosition > firstObjectTime) {
// show scoreboard if selected, and always in break // show scoreboard if selected, and always in break
if (scoreboardVisible || breakTime > 0) { if (scoreboardVisible || breakTime > 0) {
currentScoreboardAlpha += 1f / SCOREBOARD_FADE_IN_TIME * delta; currentScoreboardAlpha += 1f / SCOREBOARD_FADE_IN_TIME * delta;
@ -1035,7 +1033,7 @@ public class Game extends BasicGameState {
objectIndex++; // done, so increment object index objectIndex++; // done, so increment object index
sbOverlay.updateIndex(objectIndex); sbOverlay.updateIndex(objectIndex);
if (objectIndex >= mirrorTo) { if (objectIndex >= mirrorTo) {
Dancer.mirror = false; Options.setMirror(false);
} }
} else } else
break; break;
@ -1150,30 +1148,30 @@ public class Game extends BasicGameState {
Utils.takeScreenShot(); Utils.takeScreenShot();
break; break;
case Input.KEY_TAB: case Input.KEY_TAB:
if (!Dancer.hideui) { if (!Options.isHideUI()) {
scoreboardVisible = !scoreboardVisible; scoreboardVisible = !scoreboardVisible;
} }
break; break;
case Input.KEY_M: case Input.KEY_M:
if (Dancer.mirror) { if (Options.isMirror()) {
mirrorTo = objectIndex; mirrorTo = objectIndex;
Dancer.mirror = false; Options.setMirror(false);
} else { } else {
mirrorCursor.resetLocations(); mirrorCursor.resetLocations();
mirrorFrom = objectIndex; mirrorFrom = objectIndex;
mirrorTo = gameObjects.length; mirrorTo = gameObjects.length;
Dancer.mirror = true; Options.setMirror(true);
} }
break; break;
case Input.KEY_P: case Input.KEY_P:
if (Dancer.mirror) { if (Options.isMirror()) {
mirrorTo = objectIndex; mirrorTo = objectIndex;
Dancer.mirror = false; Options.setMirror(false);
} else { } else {
mirrorCursor.resetLocations(); mirrorCursor.resetLocations();
mirrorFrom = objectIndex; mirrorFrom = objectIndex;
mirrorTo = mirrorFrom + 1; mirrorTo = mirrorFrom + 1;
Dancer.mirror = true; Options.setMirror(true);
} }
break; break;
case Input.KEY_MINUS: case Input.KEY_MINUS:
@ -1189,7 +1187,10 @@ public class Game extends BasicGameState {
@Override @Override
public void mouseDragged(int oldx, int oldy, int newx, int newy) { public void mouseDragged(int oldx, int oldy, int newx, int newy) {
sbOverlay.mouseDragged(oldx, oldy, newx, newy); if (sbOverlay.mouseDragged(oldx, oldy, newx, newy)) {
//noinspection UnnecessaryReturnStatement
return;
}
} }
@Override @Override
@ -1622,7 +1623,7 @@ public class Game extends BasicGameState {
stack.add(index); stack.add(index);
// draw follow points // draw follow points
if (!Options.isFollowPointEnabled() || loseState) if (!Options.isFollowPointEnabled() || loseState || !Options.isHideObjects())
continue; continue;
if (beatmap.objects[index].isSpinner()) { if (beatmap.objects[index].isSpinner()) {
lastObjectIndex = -1; lastObjectIndex = -1;
@ -1687,9 +1688,9 @@ public class Game extends BasicGameState {
// normal case // normal case
if (!loseState) { if (!loseState) {
if (!Dancer.hideobjects) { if (!Options.isHideObjects()) {
gameObj.draw(g, trackPosition, false); gameObj.draw(g, trackPosition, false);
if (Dancer.mirror && GameMod.AUTO.isActive() && idx < mirrorTo && idx >= mirrorFrom) { if (Options.isMirror() && GameMod.AUTO.isActive() && idx < mirrorTo && idx >= mirrorFrom) {
g.pushTransform(); g.pushTransform();
g.rotate(Options.width / 2f, Options.height / 2f, 180f); g.rotate(Options.width / 2f, Options.height / 2f, 180f);
gameObj.draw(g, trackPosition, true); gameObj.draw(g, trackPosition, true);
@ -1729,7 +1730,7 @@ public class Game extends BasicGameState {
} }
// draw result objects // draw result objects
if (!Dancer.hideobjects) { if (!Options.isHideObjects()) {
data.drawHitResults(trackPosition); data.drawHitResults(trackPosition);
} }
} }

View File

@ -22,39 +22,32 @@ import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.Opsu; import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Options.GameOption; import itdelatrisu.opsu.Options.GameOption;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController; import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.audio.SoundController; import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect; import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.ui.Colors;
import itdelatrisu.opsu.ui.Fonts;
import itdelatrisu.opsu.ui.MenuButton;
import itdelatrisu.opsu.ui.UI; import itdelatrisu.opsu.ui.UI;
import java.util.*;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer; import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics; import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input; import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException; import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState; import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame; import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.FadeInTransition; import org.newdawn.slick.state.transition.FadeInTransition;
import org.newdawn.slick.state.transition.EmptyTransition; import org.newdawn.slick.state.transition.EmptyTransition;
import yugecin.opsudance.ui.ItemList; import yugecin.opsudance.ui.OptionsOverlay;
import yugecin.opsudance.ui.RWM; import yugecin.opsudance.ui.OptionsOverlay.OptionTab;
/** /**
* "Game Options" state. * "Game Options" state.
* <p> * <p>
* Players are able to view and change various game settings in this state. * Players are able to view and change various game settings in this state.
*/ */
public class OptionsMenu extends BasicGameState { public class OptionsMenu extends BasicGameState implements OptionsOverlay.Parent {
/** Option tabs. */ /** Option tabs. */
private enum OptionTab { private static final OptionTab[] options = new OptionsOverlay.OptionTab[]{
DISPLAY ("Display", new GameOption[] { new OptionTab("Display", new GameOption[]{
GameOption.SCREEN_RESOLUTION, GameOption.SCREEN_RESOLUTION,
GameOption.FULLSCREEN, GameOption.FULLSCREEN,
GameOption.ALLOW_LARGER_RESOLUTIONS, GameOption.ALLOW_LARGER_RESOLUTIONS,
@ -67,7 +60,7 @@ public class OptionsMenu extends BasicGameState {
GameOption.LOAD_HD_IMAGES, GameOption.LOAD_HD_IMAGES,
GameOption.LOAD_VERBOSE GameOption.LOAD_VERBOSE
}), }),
MUSIC ("Music", new GameOption[] { new OptionTab("Music", new GameOption[] {
GameOption.MASTER_VOLUME, GameOption.MASTER_VOLUME,
GameOption.MUSIC_VOLUME, GameOption.MUSIC_VOLUME,
GameOption.EFFECT_VOLUME, GameOption.EFFECT_VOLUME,
@ -77,7 +70,7 @@ public class OptionsMenu extends BasicGameState {
GameOption.DISABLE_SOUNDS, GameOption.DISABLE_SOUNDS,
GameOption.ENABLE_THEME_SONG GameOption.ENABLE_THEME_SONG
}), }),
GAMEPLAY ("Gameplay", new GameOption[] { new OptionTab("Gameplay", new GameOption[] {
GameOption.BACKGROUND_DIM, GameOption.BACKGROUND_DIM,
GameOption.FORCE_DEFAULT_PLAYFIELD, GameOption.FORCE_DEFAULT_PLAYFIELD,
GameOption.IGNORE_BEATMAP_SKINS, GameOption.IGNORE_BEATMAP_SKINS,
@ -95,7 +88,7 @@ public class OptionsMenu extends BasicGameState {
GameOption.MAP_END_DELAY, GameOption.MAP_END_DELAY,
GameOption.EPILEPSY_WARNING, GameOption.EPILEPSY_WARNING,
}), }),
INPUT ("Input", new GameOption[] { new OptionTab("Input", new GameOption[] {
GameOption.KEY_LEFT, GameOption.KEY_LEFT,
GameOption.KEY_RIGHT, GameOption.KEY_RIGHT,
GameOption.DISABLE_MOUSE_WHEEL, GameOption.DISABLE_MOUSE_WHEEL,
@ -104,7 +97,7 @@ public class OptionsMenu extends BasicGameState {
GameOption.NEW_CURSOR, GameOption.NEW_CURSOR,
GameOption.DISABLE_CURSOR GameOption.DISABLE_CURSOR
}), }),
CUSTOM ("Custom", new GameOption[] { new OptionTab("Custom", new GameOption[] {
GameOption.FIXED_CS, GameOption.FIXED_CS,
GameOption.FIXED_HP, GameOption.FIXED_HP,
GameOption.FIXED_AR, GameOption.FIXED_AR,
@ -114,7 +107,7 @@ public class OptionsMenu extends BasicGameState {
GameOption.DISABLE_UPDATER, GameOption.DISABLE_UPDATER,
GameOption.ENABLE_WATCH_SERVICE GameOption.ENABLE_WATCH_SERVICE
}), }),
DANCE ("Dance", new GameOption[] { new OptionTab("Dance", new GameOption[] {
GameOption.DANCE_MOVER, GameOption.DANCE_MOVER,
GameOption.DANCE_QUAD_BEZ_AGGRESSIVENESS, GameOption.DANCE_QUAD_BEZ_AGGRESSIVENESS,
GameOption.DANCE_QUAD_BEZ_SLIDER_AGGRESSIVENESS_FACTOR, GameOption.DANCE_QUAD_BEZ_SLIDER_AGGRESSIVENESS_FACTOR,
@ -131,7 +124,7 @@ public class OptionsMenu extends BasicGameState {
GameOption.DANCE_CIRLCE_IN_LAZY_SLIDERS, GameOption.DANCE_CIRLCE_IN_LAZY_SLIDERS,
GameOption.DANCE_MIRROR, GameOption.DANCE_MIRROR,
}), }),
DANCEDISP ("Dance display", new GameOption[] { new OptionTab("Dance display", new GameOption[] {
GameOption.DANCE_DRAW_APPROACH, GameOption.DANCE_DRAW_APPROACH,
GameOption.DANCE_OBJECT_COLOR_OVERRIDE, GameOption.DANCE_OBJECT_COLOR_OVERRIDE,
GameOption.DANCE_OBJECT_COLOR_OVERRIDE_MIRRORED, GameOption.DANCE_OBJECT_COLOR_OVERRIDE_MIRRORED,
@ -147,406 +140,80 @@ public class OptionsMenu extends BasicGameState {
GameOption.DANCE_ENABLE_SB, GameOption.DANCE_ENABLE_SB,
GameOption.DANCE_HIDE_WATERMARK, GameOption.DANCE_HIDE_WATERMARK,
}), }),
PIPPI ("Pippi", new GameOption[] { new OptionTab ("Pippi", new GameOption[] {
GameOption.PIPPI_ENABLE, GameOption.PIPPI_ENABLE,
GameOption.PIPPI_RADIUS_PERCENT, GameOption.PIPPI_RADIUS_PERCENT,
GameOption.PIPPI_ANGLE_INC_MUL, GameOption.PIPPI_ANGLE_INC_MUL,
GameOption.PIPPI_ANGLE_INC_MUL_SLIDER, GameOption.PIPPI_ANGLE_INC_MUL_SLIDER,
GameOption.PIPPI_SLIDER_FOLLOW_EXPAND, GameOption.PIPPI_SLIDER_FOLLOW_EXPAND,
GameOption.PIPPI_PREVENT_WOBBLY_STREAMS, GameOption.PIPPI_PREVENT_WOBBLY_STREAMS,
}); })
};
/** Total number of tabs. */
public static final int SIZE = values().length;
/** Array of OptionTab objects in reverse order. */
public static final OptionTab[] VALUES_REVERSED;
static {
VALUES_REVERSED = values();
Collections.reverse(Arrays.asList(VALUES_REVERSED));
}
/** Enum values. */
private static OptionTab[] values = values();
/** Tab name. */
private final String name;
/** Options array. */
public final GameOption[] options;
/** Associated tab button. */
public MenuButton button;
/**
* Constructor.
* @param name the tab name
* @param options the options to display under the tab
*/
OptionTab(String name, GameOption[] options) {
this.name = name;
this.options = options;
}
/**
* Returns the tab name.
*/
public String getName() { return name; }
/**
* Returns the next tab.
*/
public OptionTab next() { return values[(this.ordinal() + 1) % values.length]; }
/**
* Returns the previous tab.
*/
public OptionTab prev() { return values[(this.ordinal() + (SIZE - 1)) % values.length]; }
}
/** Current tab. */
private OptionTab currentTab;
/** Key entry states. */
private boolean keyEntryLeft = false, keyEntryRight = false;
/** Game option coordinate modifiers (for drawing). */
private int textY, offsetY;
// game-related variables
private GameContainer container;
private StateBasedGame game; private StateBasedGame game;
private Input input; private Input input;
private Graphics g;
private final int state; private final int state;
private GameOption selectedOption;
private final ItemList list; private OptionsOverlay optionsOverlay;
private final RWM rwm;
public OptionsMenu(int state) { public OptionsMenu(int state) {
this.state = state; this.state = state;
list = new ItemList();
rwm = new RWM();
} }
@Override @Override
public void init(GameContainer container, StateBasedGame game) public void init(GameContainer container, StateBasedGame game)
throws SlickException { throws SlickException {
list.init(container);
rwm.init(container);
this.container = container;
this.game = game; this.game = game;
this.input = container.getInput(); this.input = container.getInput();
this.g = container.getGraphics();
int width = container.getWidth(); optionsOverlay = new OptionsOverlay(this, options, 5, container);
int height = container.getHeight();
// option tabs
Image tabImage = GameImage.MENU_TAB.getImage();
float tabX = width * 0.032f + (tabImage.getWidth() / 3);
float tabY = Fonts.XLARGE.getLineHeight() + Fonts.DEFAULT.getLineHeight() +
height * 0.015f - (tabImage.getHeight() / 2f);
int tabOffset = Math.min(tabImage.getWidth(), width / OptionTab.SIZE);
for (OptionTab tab : OptionTab.values())
tab.button = new MenuButton(tabImage, tabX + (tab.ordinal() * tabOffset), tabY);
// game option coordinate modifiers
textY = (int) (tabY + tabImage.getHeight());
//int backHeight = GameImage.MENU_BACK.getAnimation(1).getHeight();
//offsetY = (height - textY - (backHeight * 4 / 5)) / maxOptionsScreen;
offsetY = (int) ((Fonts.MEDIUM.getLineHeight() + Fonts.SMALL.getLineHeight()) * 1.1f);
} }
@Override @Override
public void render(GameContainer container, StateBasedGame game, Graphics g) public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
throws SlickException {
int width = container.getWidth();
int height = container.getHeight();
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
// background // background
GameImage.OPTIONS_BG.getImage().draw(); GameImage.OPTIONS_BG.getImage().draw();
// title int mouseX = input.getMouseX(), mouseY = input.getMouseY();
float marginX = width * 0.015f, marginY = height * 0.01f; optionsOverlay.render(g, mouseX, mouseY);
Fonts.XLARGE.drawString(marginX, marginY, "Options", Color.white);
Fonts.DEFAULT.drawString(marginX + Fonts.XLARGE.getWidth("Options") * 1.2f, marginY + Fonts.XLARGE.getLineHeight() * 0.9f - Fonts.DEFAULT.getLineHeight(),
"Change the way opsu! behaves", Color.white);
// game options
g.setLineWidth(1f);
GameOption hoverOption = (keyEntryLeft) ? GameOption.KEY_LEFT :
(keyEntryRight) ? GameOption.KEY_RIGHT :
getOptionAt(mouseY);
if (selectedOption != null) {
hoverOption = selectedOption;
}
for (int i = 0, j = 0; i < currentTab.options.length; i++) {
GameOption option = currentTab.options[i];
if (!option.showCondition()) {
continue;
}
drawOption(option, j++, hoverOption == option);
}
// option tabs
OptionTab hoverTab = null;
for (OptionTab tab : OptionTab.values()) {
if (tab.button.contains(mouseX, mouseY)) {
hoverTab = tab;
break;
}
}
for (OptionTab tab : OptionTab.VALUES_REVERSED) {
if (tab != currentTab)
UI.drawTab(tab.button.getX(), tab.button.getY(),
tab.getName(), false, tab == hoverTab && !list.isVisible());
}
UI.drawTab(currentTab.button.getX(), currentTab.button.getY(),
currentTab.getName(), true, false);
g.setColor(Color.white);
g.setLineWidth(2f);
float lineY = OptionTab.DISPLAY.button.getY() + (GameImage.MENU_TAB.getImage().getHeight() / 2f);
g.drawLine(0, lineY, width, lineY);
g.resetLineWidth();
if (list.isVisible()) {
list.render(container, game, g);
}
if (rwm.isVisible()) {
rwm.render(container, game, g);
}
UI.getBackButton().draw();
// key entry state
if (keyEntryLeft || keyEntryRight) {
g.setColor(Colors.BLACK_ALPHA);
g.fillRect(0, 0, width, height);
g.setColor(Color.white);
String prompt = (keyEntryLeft) ?
"Please press the new left-click key." :
"Please press the new right-click key.";
Fonts.LARGE.drawString(
(width / 2) - (Fonts.LARGE.getWidth(prompt) / 2),
(height / 2) - Fonts.LARGE.getLineHeight(), prompt
);
}
UI.draw(g); UI.draw(g);
} }
@Override @Override
public void update(GameContainer container, StateBasedGame game, int delta) public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException {
throws SlickException {
rwm.update(delta);
UI.update(delta); UI.update(delta);
MusicController.loopTrackIfEnded(false); MusicController.loopTrackIfEnded(false);
int mouseX = input.getMouseX(), mouseY = input.getMouseY(); optionsOverlay.update(delta, input.getMouseX(), input.getMouseY());
UI.getBackButton().hoverUpdate(delta, mouseX, mouseY);
} }
@Override @Override
public int getID() { return state; } public int getID() {
return state;
}
@Override @Override
public void mouseReleased(int button, int x, int y) { public void mouseReleased(int button, int x, int y) {
selectedOption = null; optionsOverlay.mouseReleased(button, x, y);
if (list.isVisible()) {
list.mouseReleased(button, x, y);
}
if (rwm.isVisible()) {
rwm.mouseReleased(button, x, y);
}
} }
@Override @Override
public void mousePressed(int button, int x, int y) { public void mousePressed(int button, int x, int y) {
if (list.isVisible()) { optionsOverlay.mousePressed(button, x, y);
list.mousePressed(button, x, y);
return;
}
if (rwm.isVisible()) {
return;
}
// key entry state
if (keyEntryLeft || keyEntryRight) {
keyEntryLeft = keyEntryRight = false;
return;
}
// check mouse button
if (button == Input.MOUSE_MIDDLE_BUTTON)
return;
// back
if (UI.getBackButton().contains(x, y)) {
SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition());
return;
}
// option tabs
for (OptionTab tab : OptionTab.values()) {
if (tab.button.contains(x, y)) {
if (tab != currentTab) {
currentTab = tab;
SoundController.playSound(SoundEffect.MENUCLICK);
}
return;
}
}
// options (click only)
final GameOption option = getOptionAt(y);
if (option != null) {
selectedOption = option;
Object[] listItems = option.getListItems();
if (listItems == null) {
if (option.showRWM()) {
rwm.show();
} else {
option.click(container);
}
} else {
list.setItems(listItems);
list.setClickListener(new Observer() {
@Override
public void update(Observable o, Object arg) {
option.clickListItem((int) arg);
}
});
list.show();
}
}
// special key entry states
if (option == GameOption.KEY_LEFT) {
keyEntryLeft = true;
keyEntryRight = false;
} else if (option == GameOption.KEY_RIGHT) {
keyEntryLeft = false;
keyEntryRight = true;
}
// ctrl+click to reset slider options
if (selectedOption != null && selectedOption.isDragOption() && (input.isKeyDown(Input.KEY_LCONTROL) || input.isKeyDown(Input.KEY_RCONTROL))) {
selectedOption.setValue(selectedOption.getDefaultVal() - 1);
// trigger update
selectedOption.drag(container, 1);
}
} }
@Override @Override
public void mouseDragged(int oldx, int oldy, int newx, int newy) { public void mouseDragged(int oldx, int oldy, int newx, int newy) {
if (list.isVisible()) { optionsOverlay.mouseDragged(oldx, oldy, newx, newy);
list.mouseDragged(oldx, oldy, newx, newy);
return;
}
if (rwm.isVisible()) {
return;
}
// key entry state
if (keyEntryLeft || keyEntryRight)
return;
if (selectedOption == null || !selectedOption.isDragOption()) {
return;
}
// check control keys (reset to default value on ctrl+click)
if (input.isKeyDown(Input.KEY_LCONTROL) || input.isKeyDown(Input.KEY_RCONTROL)) {
selectedOption.setValue(selectedOption.getDefaultVal() - 1);
// trigger update
selectedOption.drag(container, 1);
return;
}
// check mouse button (right click scrolls faster)
int multiplier;
if (input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON))
multiplier = 4;
else if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON))
multiplier = 1;
else
return;
// get direction
int diff = newx - oldx;
if (diff == 0)
return;
diff = ((diff > 0) ? 1 : -1) * multiplier;
// options (drag only)
selectedOption.drag(container, diff);
} }
@Override @Override
public void mouseWheelMoved(int newValue) { public void mouseWheelMoved(int newValue) {
if (list.isVisible()) { optionsOverlay.mouseWheelMoved(newValue);
list.mouseWheelMoved(newValue);
}
if (input.isKeyDown(Input.KEY_LALT) || input.isKeyDown(Input.KEY_RALT))
UI.changeVolume((newValue < 0) ? -1 : 1);
} }
@Override @Override
public void keyPressed(int key, char c) { public void keyPressed(int key, char c) {
if (list.isVisible()) { optionsOverlay.keyPressed(key, c);
list.keyPressed(key, c);
return;
}
if (rwm.isVisible()) {
rwm.keyPressed(key, c);
return;
}
// key entry state
if (keyEntryLeft || keyEntryRight) {
if (keyEntryLeft)
Options.setGameKeyLeft(key);
else
Options.setGameKeyRight(key);
keyEntryLeft = keyEntryRight = false;
return;
}
switch (key) {
case Input.KEY_ESCAPE:
SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition());
break;
case Input.KEY_F5:
// restart application
if ((input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) &&
(input.isKeyDown(Input.KEY_RSHIFT) || input.isKeyDown(Input.KEY_LSHIFT))) {
container.setForceExit(false);
container.exit();
}
break;
case Input.KEY_F7:
Options.setNextFPS(container);
break;
case Input.KEY_F10:
Options.toggleMouseDisabled();
break;
case Input.KEY_F12:
Utils.takeScreenShot();
break;
case Input.KEY_TAB:
// change tabs
if (input.isKeyDown(Input.KEY_LSHIFT) || input.isKeyDown(Input.KEY_RSHIFT))
currentTab = currentTab.prev();
else
currentTab = currentTab.next();
SoundController.playSound(SoundEffect.MENUCLICK);
break;
}
} }
/** /**
@ -560,7 +227,6 @@ public class OptionsMenu extends BasicGameState {
public void enter(GameContainer container, StateBasedGame game) public void enter(GameContainer container, StateBasedGame game)
throws SlickException { throws SlickException {
UI.enter(); UI.enter();
currentTab = OptionTab.DANCE;
restartOptions = "" + Options.getResolutionIdx() + Options.isFullscreen() + Options.allowLargeResolutions() + Options.getSkinName(); restartOptions = "" + Options.getResolutionIdx() + Options.isFullscreen() + Options.allowLargeResolutions() + Options.getSkinName();
} }
@ -569,57 +235,19 @@ public class OptionsMenu extends BasicGameState {
if (!("" + Options.getResolutionIdx() + Options.isFullscreen() + Options.allowLargeResolutions() + Options.getSkinName()).equals(restartOptions)) { if (!("" + Options.getResolutionIdx() + Options.isFullscreen() + Options.allowLargeResolutions() + Options.getSkinName()).equals(restartOptions)) {
container.setForceExit(false); container.setForceExit(false);
container.exit(); container.exit();
return;
} }
SoundController.playSound(SoundEffect.MENUBACK);
} }
/** @Override
* Draws a game option. public void onLeave() {
* @param option the option game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition());
* @param pos the position to draw at
* @param focus whether the option is currently focused
*/
private void drawOption(GameOption option, int pos, boolean focus) {
int width = container.getWidth();
int textHeight = Fonts.MEDIUM.getLineHeight();
float y = textY + (pos * offsetY);
Color color = (focus) ? Color.cyan : Color.white;
Fonts.MEDIUM.drawString(width / 30, y, option.getName(), 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);
} }
/** @Override
* Returns the option at the given y coordinate. public void onSaveOption(GameOption option) {
* @param y the y coordinate
* @return the option, or GameOption.NULL if no such option exists
*/
private GameOption getOptionAt(int y) {
if (y < textY)
return null;
int index = (y - textY) / offsetY;
if (index >= currentTab.options.length)
return null;
for (GameOption option : currentTab.options) {
if (option.showCondition()) {
index--;
}
if (index < 0) {
return option;
}
}
return null;
} }
} }

View File

@ -26,6 +26,8 @@ import org.newdawn.slick.Color;
public class Colors { public class Colors {
public static final Color public static final Color
BLACK_ALPHA = new Color(0, 0, 0, 0.5f), BLACK_ALPHA = new Color(0, 0, 0, 0.5f),
BLACK_ALPHA_75 = new Color(0, 0, 0, 0.75f),
BLACK_ALPHA_85 = new Color(0, 0, 0, 0.85f),
WHITE_ALPHA = new Color(255, 255, 255, 0.5f), WHITE_ALPHA = new Color(255, 255, 255, 0.5f),
BLUE_DIVIDER = new Color(49, 94, 237), BLUE_DIVIDER = new Color(49, 94, 237),
BLUE_BACKGROUND = new Color(74, 130, 255), BLUE_BACKGROUND = new Color(74, 130, 255),

View File

@ -200,9 +200,9 @@ public class Cursor {
// draw the other components // draw the other components
if (newStyle && skin.isCursorRotated()) if (newStyle && skin.isCursorRotated())
cursor.setRotation(cursorAngle); cursor.setRotation(cursorAngle);
cursor.drawCentered(mouseX, mouseY, Dancer.onlycolortrail ? Color.white : filter); cursor.drawCentered(mouseX, mouseY, Options.isCursorOnlyColorTrail() ? Color.white : filter);
if (hasMiddle) if (hasMiddle)
cursorMiddle.drawCentered(mouseX, mouseY, Dancer.onlycolortrail ? Color.white : filter); cursorMiddle.drawCentered(mouseX, mouseY, Options.isCursorOnlyColorTrail() ? Color.white : filter);
} }
/** /**
@ -231,8 +231,9 @@ public class Cursor {
removeCount = trail.size() - max; removeCount = trail.size() - max;
} }
if (Dancer.cursortraillength > 20) { int cursortraillength = Options.getCursorTrailOverride();
removeCount = trail.size() - Dancer.cursortraillength; if (cursortraillength > 20) {
removeCount = trail.size() - cursortraillength;
} }
// remove points from the lists // remove points from the lists

View File

@ -17,6 +17,7 @@
*/ */
package yugecin.opsudance; package yugecin.opsudance;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.ui.Cursor; import itdelatrisu.opsu.ui.Cursor;
import org.newdawn.slick.Color; import org.newdawn.slick.Color;
@ -110,12 +111,12 @@ public enum CursorColorOverrides {
} }
private static Color nextRainbowColor() { private static Color nextRainbowColor() {
hue += Dancer.rgbcursorhueinc / 1000f; hue += Options.getRGBCursorInc() / 1000f;
return new Color(java.awt.Color.getHSBColor(hue / 360f, 1.0f, 1.0f).getRGB()); return new Color(java.awt.Color.getHSBColor(hue / 360f, 1.0f, 1.0f).getRGB());
} }
private static Color nextMirrorRainbowColor() { private static Color nextMirrorRainbowColor() {
hue += Dancer.rgbcursorhueinc / 1000f; hue += Options.getRGBCursorInc() / 1000f;
return new Color(java.awt.Color.getHSBColor((hue + 180f) / 360f, 1.0f, 1.0f).getRGB()); return new Color(java.awt.Color.getHSBColor((hue + 180f) / 360f, 1.0f, 1.0f).getRGB());
} }

View File

@ -20,7 +20,6 @@ package yugecin.opsudance;
import awlex.ospu.movers.factories.CenterSpiralMoverFactory; import awlex.ospu.movers.factories.CenterSpiralMoverFactory;
import awlex.ospu.movers.factories.SpiralMoverFactory; import awlex.ospu.movers.factories.SpiralMoverFactory;
import awlex.ospu.polymover.factory.ArcFactory; import awlex.ospu.polymover.factory.ArcFactory;
import awlex.ospu.polymover.factory.LinearFactory;
import awlex.ospu.polymover.factory.PolyMoverFactory; import awlex.ospu.polymover.factory.PolyMoverFactory;
import awlex.ospu.spinners.SpiralSpinner; import awlex.ospu.spinners.SpiralSpinner;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
@ -85,21 +84,11 @@ public class Dancer {
public static Dancer instance = new Dancer(); public static Dancer instance = new Dancer();
public static boolean multipoint = false; public static boolean multipoint = false;
public static boolean mirror = false; // this should really get its own place somewhere...
public static boolean drawApproach = true; // this should really get its own place somewhere...
public static boolean removebg = true; // this should really get its own place somewhere...
public static boolean hideui = true; // this should really get its own place somewhere...
public static ObjectColorOverrides colorOverride = ObjectColorOverrides.NONE; public static ObjectColorOverrides colorOverride = ObjectColorOverrides.NONE;
public static ObjectColorOverrides colorMirrorOverride = ObjectColorOverrides.NONE; public static ObjectColorOverrides colorMirrorOverride = ObjectColorOverrides.NONE;
public static int rgbhueinc = 70; // this should really get its own place somewhere...
public static CursorColorOverrides cursorColorOverride = CursorColorOverrides.NONE; public static CursorColorOverrides cursorColorOverride = CursorColorOverrides.NONE;
public static CursorColorOverrides cursorColorMirrorOverride = CursorColorOverrides.NONE; public static CursorColorOverrides cursorColorMirrorOverride = CursorColorOverrides.NONE;
public static int rgbcursorhueinc = 100; // this should really get its own place somewhere...
public static MoverDirection moverDirection = MoverDirection.RANDOM; public static MoverDirection moverDirection = MoverDirection.RANDOM;
public static boolean hideobjects = false;
public static int cursortraillength = 20;
public static boolean hidewatermark = false;
public static boolean onlycolortrail = false;
private int dir; private int dir;
public static final GameObject d = new DummyObject(); public static final GameObject d = new DummyObject();
@ -120,8 +109,6 @@ public class Dancer {
private boolean isCurrentLazySlider; private boolean isCurrentLazySlider;
public static boolean LAZY_SLIDERS;
public Dancer() { public Dancer() {
moverFactory = moverFactories[0]; moverFactory = moverFactories[0];
spinner = spinners[0]; spinner = spinners[0];
@ -205,7 +192,7 @@ public class Dancer {
} }
isCurrentLazySlider = false; isCurrentLazySlider = false;
// detect lazy sliders, should work pretty good // detect lazy sliders, should work pretty good
if (c.isSlider() && LAZY_SLIDERS && Utils.distance(c.start.x, c.start.y, c.end.x, c.end.y) <= Circle.diameter * 0.8f) { if (c.isSlider() && Options.isLazySliders() && Utils.distance(c.start.x, c.start.y, c.end.x, c.end.y) <= Circle.diameter * 0.8f) {
Slider s = (Slider) c; Slider s = (Slider) c;
Vec2f mid = s.getCurve().pointAt(1f); Vec2f mid = s.getCurve().pointAt(1f);
if (s.getRepeats() == 1 || Utils.distance(c.start.x, c.start.y, mid.x, mid.y) <= Circle.diameter * 0.8f) { if (s.getRepeats() == 1 || Utils.distance(c.start.x, c.start.y, mid.x, mid.y) <= Circle.diameter * 0.8f) {

View File

@ -17,6 +17,7 @@
*/ */
package yugecin.opsudance; package yugecin.opsudance;
import itdelatrisu.opsu.Options;
import org.newdawn.slick.Color; import org.newdawn.slick.Color;
public enum ObjectColorOverrides { public enum ObjectColorOverrides {
@ -94,7 +95,7 @@ public enum ObjectColorOverrides {
} }
private static Color nextRainbowColor() { private static Color nextRainbowColor() {
hue += Dancer.rgbhueinc / 10f; hue += Options.getRGBObjInc() / 10f;
return new Color(java.awt.Color.getHSBColor(hue / 360f, 1.0f, 1.0f).getRGB()); return new Color(java.awt.Color.getHSBColor(hue / 360f, 1.0f, 1.0f).getRGB());
} }

View File

@ -17,6 +17,7 @@
*/ */
package yugecin.opsudance; package yugecin.opsudance;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.objects.Circle; import itdelatrisu.opsu.objects.Circle;
import itdelatrisu.opsu.objects.GameObject; import itdelatrisu.opsu.objects.GameObject;
import itdelatrisu.opsu.objects.Slider; import itdelatrisu.opsu.objects.Slider;
@ -27,14 +28,7 @@ public class Pippi {
private static int currentdelta; private static int currentdelta;
private static final int targetdelta = 4; private static final int targetdelta = 4;
public static boolean enabled = false;
private static int radiusPercent; private static int radiusPercent;
public static int angleInc = 10;
public static int angleSliderInc = 50;
public static boolean preventWobblyStreams = true;
public static boolean followcircleExpand = true;
public static boolean circleSlowSliders = false;
public static boolean circleLazySliders = false;
private static double pippirad; private static double pippirad;
private static double pippiminrad; private static double pippiminrad;
@ -54,19 +48,19 @@ public class Pippi {
} }
public static void dance(int time, GameObject c, boolean isCurrentLazySlider) { public static void dance(int time, GameObject c, boolean isCurrentLazySlider) {
boolean slowSlider = circleSlowSliders && c.isSlider() && (((((Slider) c).pixelLength < 200 || c.getEndTime() - c.getTime() > 400)) || isCurrentLazySlider); boolean slowSlider = Options.isCircleInSlowSliders() && c.isSlider() && (((((Slider) c).pixelLength < 200 || c.getEndTime() - c.getTime() > 400)) || isCurrentLazySlider);
if (!slowSlider) { if (!slowSlider) {
slowSlider = circleLazySliders && isCurrentLazySlider; slowSlider = Options.isCircleInLazySliders() && isCurrentLazySlider;
} }
if ((!enabled || c.isSpinner()) && !slowSlider) { if ((!Options.isPippiEnabled() || c.isSpinner()) && !slowSlider) {
return; return;
} }
if (currentdelta >= targetdelta && c != previous) { if (currentdelta >= targetdelta && c != previous) {
currentdelta = 0; currentdelta = 0;
if (c.isSlider() && c.getTime() < time) { if (c.isSlider() && c.getTime() < time) {
angle += angleSliderInc / 1800d * Math.PI; angle += Options.getPippiAngIncMultiplierSlider() / 1800d * Math.PI;
if (!slowSlider) { if (!slowSlider) {
if (followcircleExpand) { if (Options.isPippiFollowcircleExpand()) {
if (c.getEndTime() - time < 40 && pippirad > pippimaxrad) { if (c.getEndTime() - time < 40 && pippirad > pippimaxrad) {
pippirad -= 5d; pippirad -= 5d;
} else if (time - c.getTime() > 10 && c.getEndTime() - c.getTime() > 600 && pippirad < pippimaxrad) { } else if (time - c.getTime() > 10 && c.getEndTime() - c.getTime() > 600 && pippirad < pippimaxrad) {
@ -75,10 +69,10 @@ public class Pippi {
} }
} }
} else if (!c.isSpinner()) { } else if (!c.isSpinner()) {
if (followcircleExpand && pippirad != pippiminrad) { if (Options.isPippiFollowcircleExpand() && pippirad != pippiminrad) {
pippirad = pippiminrad; pippirad = pippiminrad;
} }
angle += angleInc / 1800d * Math.PI; angle += Options.getPippiAngIncMultiplier() / 1800d * Math.PI;
} }
// don't inc on long movements // don't inc on long movements
if (c.getTime() - time > 400) { if (c.getTime() - time > 400) {
@ -97,7 +91,7 @@ public class Pippi {
} }
public static boolean shouldPreventWobblyStream(double distance) { public static boolean shouldPreventWobblyStream(double distance) {
return enabled && distance < Circle.diameter * 0.93f && preventWobblyStreams; return Options.isPippiEnabled() && distance < Circle.diameter * 0.93f && Options.isPippiPreventWobblyStreams();
} }
} }

View File

@ -17,6 +17,7 @@
*/ */
package yugecin.opsudance.movers; package yugecin.opsudance.movers;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.objects.GameObject; import itdelatrisu.opsu.objects.GameObject;
import itdelatrisu.opsu.objects.Slider; import itdelatrisu.opsu.objects.Slider;
@ -26,8 +27,6 @@ import java.awt.*;
public class CubicBezierMover extends Mover { public class CubicBezierMover extends Mover {
public static int aggressivenessfactor = 4;
private static Point p2 = new Point(0, 0); private static Point p2 = new Point(0, 0);
private static Point p1 = new Point(0, 0); private static Point p1 = new Point(0, 0);
@ -42,7 +41,7 @@ public class CubicBezierMover extends Mover {
double ang = s.getCurve().getStartAngle() * Math.PI / 180d + Math.PI; double ang = s.getCurve().getStartAngle() * Math.PI / 180d + Math.PI;
Vec2f nextpos = s.getPointAt(s.getTime() + 10); Vec2f nextpos = s.getPointAt(s.getTime() + 10);
double dist = Utils.distance(end.start.x, end.start.y, nextpos.x, nextpos.y); double dist = Utils.distance(end.start.x, end.start.y, nextpos.x, nextpos.y);
double speed = dist * QuadraticBezierMover.aggressiveness * aggressivenessfactor / 10; double speed = dist * Options.getQuadBezAggressiveness() * Options.getQuadBezSliderEntryAggressiveness() / 10;
p2.x = (int) (end.start.x + Math.cos(ang) * speed); p2.x = (int) (end.start.x + Math.cos(ang) * speed);
p2.y = (int) (end.start.y + Math.sin(ang) * speed); p2.y = (int) (end.start.y + Math.sin(ang) * speed);
} }

View File

@ -17,6 +17,7 @@
*/ */
package yugecin.opsudance.movers; package yugecin.opsudance.movers;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.objects.GameObject; import itdelatrisu.opsu.objects.GameObject;
@ -24,8 +25,6 @@ import java.awt.*;
public class QuadraticBezierMover extends Mover { public class QuadraticBezierMover extends Mover {
public static int sliderExitAggressivenessfactor = 4;
public static int aggressiveness = 50;
public static Point p; public static Point p;
private static double prevspeed; private static double prevspeed;
@ -35,7 +34,7 @@ public class QuadraticBezierMover extends Mover {
} }
public static void setPrevspeed(double distance, int timedelta) { public static void setPrevspeed(double distance, int timedelta) {
prevspeed = distance * aggressiveness * sliderExitAggressivenessfactor / timedelta; prevspeed = distance * Options.getQuadBezAggressiveness() * Options.getQuadBezSliderAggressiveness() / timedelta;
} }
public static double getPrevspeed() { public static double getPrevspeed() {
@ -54,7 +53,7 @@ public class QuadraticBezierMover extends Mover {
double dist = Utils.distance(startX, startY, endX, endY); double dist = Utils.distance(startX, startY, endX, endY);
p.x = (int) (startX + Math.cos(startAngle) * prevspeed); p.x = (int) (startX + Math.cos(startAngle) * prevspeed);
p.y = (int) (startY + Math.sin(startAngle) * prevspeed); p.y = (int) (startY + Math.sin(startAngle) * prevspeed);
prevspeed = (dist / totalTime) * aggressiveness; prevspeed = (dist / totalTime) * Options.getQuadBezSliderAggressiveness();
} }
@Override @Override

View File

@ -27,8 +27,6 @@ import yugecin.opsudance.movers.*;
public class AutoMoverFactory implements MoverFactory { public class AutoMoverFactory implements MoverFactory {
public static boolean ONLY_CIRCLE_STACKS = false;
public static int CIRCLE_STREAM = 58;
private int starttime; private int starttime;
private int endtime; private int endtime;
protected Mover m; protected Mover m;
@ -44,7 +42,8 @@ public class AutoMoverFactory implements MoverFactory {
} }
// stacked: circles if not too quick // stacked: circles if not too quick
if (distance < Circle.diameter && ((dt > CIRCLE_STREAM && !ONLY_CIRCLE_STACKS) || distance < HitObject.getStackOffset() * 5.2f)) { // TODO get the correct multiplier for stackoffsets int circle_stream = Options.isCircleStreams() ? 58: 85;
if (distance < Circle.diameter && ((dt > circle_stream && !Options.isOnlyCircleStacks()) || distance < HitObject.getStackOffset() * 5.2f)) { // TODO get the correct multiplier for stackoffsets
return new CircleMover(start, end, dir); return new CircleMover(start, end, dir);
} }

View File

@ -17,6 +17,7 @@
*/ */
package yugecin.opsudance.movers.factories; package yugecin.opsudance.movers.factories;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.objects.GameObject; import itdelatrisu.opsu.objects.GameObject;
import yugecin.opsudance.movers.CubicBezierMover; import yugecin.opsudance.movers.CubicBezierMover;
import yugecin.opsudance.movers.Mover; import yugecin.opsudance.movers.Mover;
@ -24,11 +25,9 @@ import yugecin.opsudance.movers.QuadraticBezierMover;
public class QuadraticBezierMoverFactory implements MoverFactory { public class QuadraticBezierMoverFactory implements MoverFactory {
public static boolean cubicForSliderEntries = true;
@Override @Override
public Mover create(GameObject start, GameObject end, int dir) { public Mover create(GameObject start, GameObject end, int dir) {
if (cubicForSliderEntries && end.isSlider()) { if (Options.isQuadBezCubicEnabled() && end.isSlider()) {
return new CubicBezierMover(start, end, dir); return new CubicBezierMover(start, end, dir);
} }
return new QuadraticBezierMover(start, end, dir); return new QuadraticBezierMover(start, end, dir);

View File

@ -17,13 +17,14 @@
*/ */
package yugecin.opsudance.spinners; package yugecin.opsudance.spinners;
import itdelatrisu.opsu.Options;
public abstract class Spinner { public abstract class Spinner {
private double[][] points; private double[][] points;
private int length; private int length;
private int index; private int index;
private static int delay; private static int delay;
public static int DELAY = 3;
public static double PROGRESS; public static double PROGRESS;
public abstract void init(); public abstract void init();
@ -41,7 +42,7 @@ public abstract class Spinner {
} }
public boolean waitForDelay() { public boolean waitForDelay() {
if (delay >= DELAY) { if (delay >= Options.getSpinnerDelay()) {
delay = 0; delay = 0;
return true; return true;
} }

View File

@ -1,147 +0,0 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2016 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* opsu!dance is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with opsu!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance.ui;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.ui.Fonts;
import itdelatrisu.opsu.ui.UI;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.state.StateBasedGame;
import java.util.Observer;
public class ItemList {
private int x;
private int y;
private int width;
private int height;
private int start;
private Object[] items;
private Observer observer;
private boolean visible;
public void init(GameContainer container) {
x = container.getWidth() / 6;
y = 0;
width = x * 4;
height = container.getHeight();
}
public void setItems(Object[] items) {
this.items = items;
}
public void setClickListener(Observer o) {
observer = o;
}
public boolean isVisible() {
return visible;
}
public void show() {
visible = true;
}
public void render(GameContainer container, StateBasedGame game, Graphics g) {
g.setColor(Color.black);
g.fillRect(x, y, width, height);
int y = this.y + 5;
for (int i = start, m = items.length; i < m; i++) {
if (container.getInput().getMouseX() >= x && container.getInput().getMouseX() < x + width) {
if (container.getInput().getMouseY() >= y && container.getInput().getMouseY() < y + Fonts.MEDIUM.getLineHeight() + 5) {
g.setColor(new Color(0x11A9FF));
g.fillRect(x, y, width, Fonts.MEDIUM.getLineHeight() + 5);
}
}
Fonts.MEDIUM.drawString(x + 5, y + 2, items[i].toString(), Color.white);
y += Fonts.MEDIUM.getLineHeight() + 5;
if (y >= height - Fonts.MEDIUM.getLineHeight()) {
break;
}
}
}
private int startStart;
private int mouseStartX;
private int mouseStartY;
public void mousePressed(int button, int x, int y) {
mouseStartX = x;
mouseStartY = y;
startStart = start;
}
public void mouseReleased(int button, int x, int y) {
if (Utils.distance(x, y, mouseStartX, mouseStartY) > 5) {
return;
}
if (UI.getBackButton().contains(x, y)) {
visible = false;
}
if (x < this.x || x > this.x + width) {
visible = false;
return;
}
if (button != 0) {
return;
}
if (y < 5) {
return;
}
y -= 5;
int index = y / (Fonts.MEDIUM.getLineHeight() + 5);
index += start;
if (index >= 0 && index < items.length) {
observer.update(null, index);
visible = false;
}
}
public void mouseDragged(int oldx, int oldy, int x, int y) {
start = startStart - (y - mouseStartY) / (Fonts.MEDIUM.getLineHeight() + 5);
if (start < 0) {
start = 0;
} else if (start > items.length - 1) {
start = items.length - 1;
}
}
public void mouseWheelMoved(int delta) {
if (delta > 0) {
start = Math.max(0, start - 1);
} else {
start = Math.min(items.length - 1, start + 1);
}
}
public void keyPressed(int key, char c) {
if (key == Input.KEY_ESCAPE) {
visible = false;
}
}
}

View File

@ -17,213 +17,489 @@
*/ */
package yugecin.opsudance.ui; package yugecin.opsudance.ui;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Options.GameOption;
import itdelatrisu.opsu.Options.GameOption.OptionType;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.ui.Colors; import itdelatrisu.opsu.ui.Colors;
import itdelatrisu.opsu.ui.Fonts; import itdelatrisu.opsu.ui.Fonts;
import org.newdawn.slick.Color; import itdelatrisu.opsu.ui.MenuButton;
import org.newdawn.slick.GameContainer; import itdelatrisu.opsu.ui.UI;
import org.newdawn.slick.Graphics; import org.newdawn.slick.*;
import org.newdawn.slick.Input;
import org.newdawn.slick.state.StateBasedGame;
import java.util.Observable;
import java.util.Observer;
@SuppressWarnings("UnusedParameters")
public class OptionsOverlay { public class OptionsOverlay {
private Parent parent;
private GameContainer container;
private final Image sliderBallImg;
private final Image checkOnImg;
private final Image checkOffImg;
private OptionTab[] tabs;
private int selectedTab;
private GameOption hoverOption;
private GameOption selectedOption;
private int sliderOptionStartX;
private int sliderOptionLength;
private boolean isAdjustingSlider;
private boolean isListOptionOpen;
private int listStartX;
private int listStartY;
private int listWidth;
private int listHeight;
private int listHoverIndex;
private int width; private int width;
private int height; private int height;
private static Options.GameOption[] options = new Options.GameOption[] { private int optionWidth;
Options.GameOption.DANCE_MOVER, private int optionStartX;
Options.GameOption.DANCE_QUAD_BEZ_AGGRESSIVENESS, private int optionStartY;
Options.GameOption.DANCE_QUAD_BEZ_SLIDER_AGGRESSIVENESS_FACTOR, private int optionHeight;
Options.GameOption.DANCE_QUAD_BEZ_USE_CUBIC_ON_SLIDERS,
Options.GameOption.DANCE_QUAD_BEZ_CUBIC_AGGRESSIVENESS_FACTOR,
Options.GameOption.DANCE_MOVER_DIRECTION,
Options.GameOption.DANCE_SLIDER_MOVER_TYPE,
Options.GameOption.DANCE_SPINNER,
Options.GameOption.DANCE_SPINNER_DELAY,
Options.GameOption.DANCE_LAZY_SLIDERS,
Options.GameOption.DANCE_CIRCLE_STREAMS,
Options.GameOption.DANCE_ONLY_CIRCLE_STACKS,
Options.GameOption.DANCE_CIRLCE_IN_SLOW_SLIDERS,
Options.GameOption.DANCE_CIRLCE_IN_LAZY_SLIDERS,
Options.GameOption.DANCE_MIRROR,
Options.GameOption.DANCE_DRAW_APPROACH,
Options.GameOption.DANCE_OBJECT_COLOR_OVERRIDE,
Options.GameOption.DANCE_OBJECT_COLOR_OVERRIDE_MIRRORED,
Options.GameOption.DANCE_RGB_OBJECT_INC,
Options.GameOption.DANCE_CURSOR_COLOR_OVERRIDE,
Options.GameOption.DANCE_CURSOR_MIRROR_COLOR_OVERRIDE,
Options.GameOption.DANCE_CURSOR_ONLY_COLOR_TRAIL,
Options.GameOption.DANCE_RGB_CURSOR_INC,
Options.GameOption.DANCE_CURSOR_TRAIL_OVERRIDE,
Options.GameOption.DANCE_REMOVE_BG,
Options.GameOption.DANCE_HIDE_OBJECTS,
Options.GameOption.DANCE_HIDE_UI,
Options.GameOption.PIPPI_ENABLE,
Options.GameOption.PIPPI_RADIUS_PERCENT,
Options.GameOption.PIPPI_ANGLE_INC_MUL,
Options.GameOption.PIPPI_ANGLE_INC_MUL_SLIDER,
Options.GameOption.PIPPI_SLIDER_FOLLOW_EXPAND,
Options.GameOption.PIPPI_PREVENT_WOBBLY_STREAMS,
Options.GameOption.SHOW_HIT_LIGHTING,
};
private int textHeight; private int scrollOffset;
private Input input; private int maxScrollOffset;
private final ItemList list;
private GameContainer container;
private Options.GameOption selectedOption;
private final SBOverlay overlay;
public OptionsOverlay(SBOverlay overlay) { private int mousePressY;
this.overlay = overlay;
list = new ItemList();
}
public Options.GameOption[] getSavedOptionList() { private boolean keyEntryLeft;
return options; private boolean keyEntryRight;
}
public void init(GameContainer container, Input input, int width, int height) { public OptionsOverlay(Parent parent, OptionTab[] tabs, int defaultSelectedTabIndex, GameContainer container) {
list.init(container); this.parent = parent;
this.input = input;
this.width = width;
this.height = height;
this.container = container; this.container = container;
textHeight = Fonts.SMALL.getLineHeight();
this.tabs = tabs;
selectedTab = defaultSelectedTabIndex;
sliderBallImg = GameImage.CONTROL_SLIDER_BALL.getImage().getScaledCopy(20, 20);
checkOnImg = GameImage.CONTROL_CHECK_ON.getImage().getScaledCopy(20, 20);
checkOffImg = GameImage.CONTROL_CHECK_OFF.getImage().getScaledCopy(20, 20);
width = container.getWidth();
height = container.getHeight();
// calculate positions
optionWidth = width / 2;
optionHeight = (int) ((Fonts.MEDIUM.getLineHeight()) * 1.1f);
optionStartX = optionWidth / 2;
// initialize tabs
Image tabImage = GameImage.MENU_TAB.getImage();
float tabX = width * 0.032f + (tabImage.getWidth() / 3);
float tabY = Fonts.XLARGE.getLineHeight() + Fonts.DEFAULT.getLineHeight() + height * 0.015f - (tabImage.getHeight() / 2f);
int tabOffset = Math.min(tabImage.getWidth(), width / tabs.length);
maxScrollOffset = Fonts.MEDIUM.getLineHeight() * 2 * tabs.length;
for (OptionTab tab : tabs) {
maxScrollOffset += tab.options.length * optionHeight;
tab.button = new MenuButton(tabImage, tabX, tabY);
tabX += tabOffset;
if (tabX + tabOffset > width) {
tabX = 0;
tabY += GameImage.MENU_TAB.getImage().getHeight() / 2f;
}
}
maxScrollOffset += -optionStartY - optionHeight;
// calculate other positions
optionStartY = (int) (tabY + tabImage.getHeight() / 2 + 2); // +2 for the separator line
} }
public void render(GameContainer container, StateBasedGame game, Graphics g) { public void render(Graphics g, int mouseX, int mouseY) {
int hoverIdx = getOptionIdxAt(input.getMouseY()); // bg
float a = Color.black.a; g.setColor(Colors.BLACK_ALPHA_75);
Color.black.a = 0.8f;
g.setColor(Color.black);
g.fillRect(0, 0, width, height); g.fillRect(0, 0, width, height);
Color.black.a = a;
for (int i = 0, j = 0; i < options.length; i++) { // title
if (!options[i].showCondition()) { renderTitle();
continue;
} // option tabs
drawOption(g, options[i], j++, selectedOption == null ? hoverIdx == i : selectedOption == options[i]); renderTabs(mouseX, mouseY);
// line separator
g.setColor(Color.white);
g.setLineWidth(2f);
g.drawLine(0, optionStartY - 1, width, optionStartY - 1);
g.resetLineWidth();
// options
renderOptions(g);
if (isListOptionOpen) {
renderOpenList(g);
} }
if (list.isVisible()) {
list.render(container, game, g); // scrollbar
g.setColor(Color.white);
g.fillRoundRect(optionStartX + optionWidth + 15, optionStartY + ((float) scrollOffset / (maxScrollOffset)) * (height - optionStartY - 45), 10, 45, 2);
g.clearClip();
// UI
UI.getBackButton().draw();
// tooltip
renderTooltip(g, mouseX, mouseY);
// key input options
if (keyEntryLeft ||keyEntryRight) {
renderKeyEntry(g);
} }
} }
// I know... kill me private void renderKeyEntry(Graphics g) {
private void drawOption(Graphics g, Options.GameOption option, int pos, boolean focus) { g.setColor(Colors.BLACK_ALPHA_75);
float y = pos * (textHeight + 5); g.fillRect(0, 0, width, height);
Color color = (focus) ? Color.cyan : Color.white; g.setColor(Color.white);
String prompt = (keyEntryLeft) ? "Please press the new left-click key." : "Please press the new right-click key.";
Fonts.MEDIUM.drawString(width / 6 * 2, y, option.getName(), color); Fonts.LARGE.drawString((width - Fonts.LARGE.getWidth(prompt)) / 2, (height - Fonts.LARGE.getLineHeight()) / 2, prompt);
Fonts.MEDIUM.drawString(width / 3 * 2, y, option.getValueString(), color);
g.setColor(Colors.WHITE_ALPHA);
g.drawLine(0, y + textHeight + 3, width, y + textHeight + 3 + 1);
} }
private int getOptionIdxAt(int y) { private void renderTooltip(Graphics g, int mouseX, int mouseY) {
int index = y / (textHeight + 5); if (hoverOption != null) {
if (index >= options.length) { String optionDescription = hoverOption.getDescription();
return -1; float textWidth = Fonts.SMALL.getWidth(optionDescription);
Color.black.a = 0.7f;
g.setColor(Color.black);
g.fillRoundRect(mouseX + 10, mouseY + 10, 10 + textWidth, 10 + Fonts.SMALL.getLineHeight(), 4);
Fonts.SMALL.drawString(mouseX + 15, mouseY + 15, optionDescription, Color.white);
Color.black.a = 1f;
} }
for (int i = 0; i < options.length; i++) {
if (options[i].showCondition()) {
index--;
}
if (index < 0) {
return i;
}
}
return -1;
} }
public void update(int mouseX, int mouseY) { private void renderOptions(Graphics g) {
g.setClip(0, optionStartY, width, height - optionStartY);
} listStartX = listStartY = listWidth = listHeight = 0; // render out of the screen
int y = -scrollOffset + optionStartY;
public boolean mousePressed(int button, int x, int y) { selectedTab = 0;
if (list.isVisible()) { maxScrollOffset = Fonts.MEDIUM.getLineHeight() * 2 * tabs.length;
list.mousePressed(button, x, y); boolean render = true;
return true; for (int tabIndex = 0; tabIndex < tabs.length; tabIndex++) {
} OptionTab tab = tabs[tabIndex];
int idx = getOptionIdxAt(y); if (y > 0) {
if (idx >= 0 && idx < options.length) { if (render) {
final Options.GameOption option = options[idx]; int x = optionStartX + (optionWidth - Fonts.LARGE.getWidth(tab.name)) / 2;
selectedOption = option; Fonts.LARGE.drawString(x, y + Fonts.LARGE.getLineHeight() * 0.6f, tab.name, Color.cyan);
Object[] listItems = option.getListItems(); }
if (listItems == null) {
option.click(container);
} else { } else {
list.setItems(listItems); selectedTab++;
list.setClickListener(new Observer() { }
@Override y += Fonts.MEDIUM.getLineHeight() * 2;
public void update(Observable o, Object arg) { for (int optionIndex = 0; optionIndex < tab.options.length; optionIndex++) {
option.clickListItem((int) arg); GameOption option = tab.options[optionIndex];
overlay.saveOption(option); if (!option.showCondition()) {
} continue;
}); }
list.show(); maxScrollOffset += optionHeight;
if ((y > 0 && render) || (isListOptionOpen && hoverOption == option)) {
renderOption(g, option, y, option == hoverOption);
}
y += optionHeight;
if (y > height) {
render = false;
tabIndex = tabs.length;
}
} }
} }
return true; maxScrollOffset -= optionStartY - optionHeight * 2;
} }
private void renderOpenList(Graphics g) {
g.setColor(Colors.BLACK_ALPHA_85);
g.fillRect(listStartX, listStartY, listWidth, listHeight);
if (listHoverIndex != -1) {
g.setColor(Colors.ORANGE_BUTTON);
g.fillRect(listStartX, listStartY + listHoverIndex * optionHeight, listWidth, optionHeight);
}
g.setLineWidth(1f);
g.setColor(Color.white);
g.drawRect(listStartX, listStartY, listWidth, listHeight);
Object[] listItems = hoverOption.getListItems();
int y = listStartY;
for (Object item : listItems) {
Fonts.MEDIUM.drawString(listStartX + 20, y, item.toString());
y += optionHeight;
}
}
private void renderOption(Graphics g, GameOption option, int y, boolean focus) {
Color col = focus ? Colors.GREEN : Colors.WHITE_FADE;
OptionType type = option.getType();
Object[] listItems = option.getListItems();
if (listItems != null) {
renderListOption(g, option, y, col, listItems);
} else if (type == OptionType.BOOLEAN) {
renderCheckOption(g, option, y, col);
} else if (type == OptionType.NUMERIC) {
renderSliderOption(g, option, y, col);
} else {
renderGenericOption(g, option, y, col);
}
}
private void renderListOption(Graphics g, GameOption option, int y, Color textColor, Object[] listItems) {
int nameLen = Fonts.MEDIUM.getWidth(option.getName());
Fonts.MEDIUM.drawString(optionStartX, y, option.getName(), textColor);
int size = (int) (optionHeight * 4f / 5f);
int padding = (int) (optionHeight / 10f);
nameLen += 20;
int itemStart = optionStartX + nameLen;
int itemWidth = optionWidth - nameLen;
Color backColor = Colors.BLACK_ALPHA;
if (hoverOption == option && listHoverIndex == -1) {
backColor = Colors.ORANGE_BUTTON;
}
g.setColor(backColor);
g.fillRect(itemStart, y + padding, itemWidth, size);
g.setColor(Color.white);
g.setLineWidth(1f);
g.drawRect(itemStart, y + padding, itemWidth, size);
Fonts.MEDIUM.drawString(itemStart + 20, y, option.getValueString(), Color.white);
if (isListOptionOpen && hoverOption == option) {
listStartX = optionStartX + nameLen;
listStartY = y + padding + size;
listWidth = itemWidth;
listHeight = listItems.length * optionHeight;
}
}
private void renderCheckOption(Graphics g, GameOption option, int y, Color textColor) {
if (option.getBooleanValue()) {
checkOnImg.draw(optionStartX, y + optionHeight / 4, Color.pink);
} else {
checkOffImg.draw(optionStartX, y + optionHeight / 4, Color.pink);
}
Fonts.MEDIUM.drawString(optionStartX + 30, y, option.getName(), textColor);
}
private void renderSliderOption(Graphics g, GameOption option, int y, Color textColor) {
String value = option.getValueString();
int nameLen = Fonts.MEDIUM.getWidth(option.getName());
int valueLen = Fonts.MEDIUM.getWidth(value);
Fonts.MEDIUM.drawString(optionStartX, y, option.getName(), textColor);
Fonts.MEDIUM.drawString(optionStartX + optionWidth - valueLen, y, value, Colors.BLUE_BACKGROUND);
int sliderLen = optionWidth - nameLen - valueLen - 50;
if (hoverOption == option) {
if (!isAdjustingSlider) {
sliderOptionLength = sliderLen;
sliderOptionStartX = optionStartX + nameLen + 25;
} else {
sliderLen = sliderOptionLength;
}
}
g.setColor(Color.pink);
g.setLineWidth(3f);
g.drawLine(optionStartX + nameLen + 25, y + optionHeight / 2, optionStartX + nameLen + 25 + sliderLen, y + optionHeight / 2);
float sliderValue = (float) (sliderLen + 10) * (option.getIntegerValue() - option.getMinValue()) / (option.getMaxValue() - option.getMinValue());
sliderBallImg.draw(optionStartX + nameLen + 25 + sliderValue - 10, y + optionHeight / 2 - 10, Color.pink);
}
private void renderGenericOption(Graphics g, GameOption option, int y, Color textColor) {
String value = option.getValueString();
int valueLen = Fonts.MEDIUM.getWidth(value);
Fonts.MEDIUM.drawString(optionStartX, y, option.getName(), textColor);
Fonts.MEDIUM.drawString(optionStartX + optionWidth - valueLen, y, value, Colors.BLUE_BACKGROUND);
}
public void renderTabs(int mouseX, int mouseY) {
for (int i = 0; i < tabs.length; i++) {
OptionTab tab = tabs[i];
boolean hovering = tab.button.contains(mouseX, mouseY);
UI.drawTab(tab.button.getX(), tab.button.getY(), tab.name, i == selectedTab, hovering);
}
}
private void renderTitle() {
float marginX = width * 0.015f;
float marginY = height * 0.01f;
Fonts.XLARGE.drawString(marginX, marginY, "Options", Color.white);
marginX += Fonts.XLARGE.getWidth("Options") * 1.2f;
marginY += Fonts.XLARGE.getLineHeight() * 0.9f - Fonts.DEFAULT.getLineHeight();
Fonts.DEFAULT.drawString(marginX, marginY, "Change the way opsu! behaves", Color.white);
}
public void update(int delta, int mouseX, int mouseY) {
updateHoverOption(mouseX, mouseY);
UI.getBackButton().hoverUpdate(delta, mouseX, mouseY);
if (isAdjustingSlider) {
int min = selectedOption.getMinValue();
int max = selectedOption.getMaxValue();
int value = min + (int) ((float) (max - min) * (mouseX - sliderOptionStartX) / (sliderOptionLength));
selectedOption.setValue(Utils.clamp(value, min, max));
selectedOption.drag(container, 0);
} else if (isListOptionOpen) {
if (listStartX <= mouseX && mouseX < listStartX + listWidth && listStartY <= mouseY && mouseY < listStartY + listHeight) {
listHoverIndex = (mouseY - listStartY) / optionHeight;
} else {
listHoverIndex = -1;
}
}
}
public void mousePressed(int button, int x, int y) {
if (keyEntryLeft || keyEntryRight) {
keyEntryLeft = keyEntryRight = false;
return;
}
if (isListOptionOpen) {
if (y > optionStartY && listStartX <= x && x < listStartX + listWidth && listStartY <= y && y < listStartY + listHeight) {
hoverOption.clickListItem(listHoverIndex);
parent.onSaveOption(hoverOption);
SoundController.playSound(SoundEffect.MENUCLICK);
}
isListOptionOpen = false;
listHoverIndex = -1;
return;
}
mousePressY = y;
selectedOption = hoverOption;
if (selectedOption != null) {
if (selectedOption.getListItems() != null) {
isListOptionOpen = true;
} else if (selectedOption.getType() == OptionType.NUMERIC) {
isAdjustingSlider = sliderOptionStartX <= x && x < sliderOptionStartX + sliderOptionLength;
} else if (selectedOption == GameOption.KEY_LEFT) {
keyEntryLeft = true;
} else if (selectedOption == GameOption.KEY_RIGHT) {
keyEntryLeft = true;
}
}
if (UI.getBackButton().contains(x, y)) {
parent.onLeave();
}
}
public void mouseReleased(int button, int x, int y) {
selectedOption = null;
isAdjustingSlider = false;
sliderOptionLength = 0;
// check if clicked, not dragged
if (Math.abs(y - mousePressY) >= 5) {
return;
}
if (hoverOption != null) {
parent.onSaveOption(hoverOption);
if (hoverOption.getType() == OptionType.BOOLEAN) {
hoverOption.click(container);
SoundController.playSound(SoundEffect.MENUHIT);
return;
}
}
int tScrollOffset = 0;
for (int tabIndex = 0; tabIndex < tabs.length; tabIndex++) {
if (tabs[tabIndex].button.contains(x, y)) {
if (selectedTab != tabIndex) {
selectedTab = tabIndex;
scrollOffset = tScrollOffset;
SoundController.playSound(SoundEffect.MENUCLICK);
}
return;
}
tScrollOffset += Fonts.MEDIUM.getLineHeight() * 2;
tScrollOffset += tabs[tabIndex].options.length * optionHeight;
}
}
public void mouseDragged(int oldx, int oldy, int newx, int newy) { public void mouseDragged(int oldx, int oldy, int newx, int newy) {
if (list.isVisible()) { if (!isAdjustingSlider) {
list.mouseDragged(oldx, oldy, newx, newy); scrollOffset = Utils.clamp(scrollOffset + oldy - newy, 0, maxScrollOffset);
return;
}
int multiplier;
if (input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON))
multiplier = 4;
else if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON))
multiplier = 1;
else
return;
// get direction
int diff = newx - oldx;
if (diff == 0)
return;
diff = ((diff > 0) ? 1 : -1) * multiplier;
// options (drag only)
if (selectedOption != null) {
selectedOption.drag(container, diff);
} }
} }
public boolean mouseReleased(int button, int x, int y) { public void mouseWheelMoved(int delta) {
if (selectedOption != null) { if (!isAdjustingSlider) {
overlay.saveOption(selectedOption); scrollOffset = Utils.clamp(scrollOffset - delta, 0, maxScrollOffset);
} }
selectedOption = null;
if (list.isVisible()) {
list.mouseReleased(button, x, y);
return true;
}
return true;
}
public boolean mouseWheenMoved(int newValue) {
if (list.isVisible()) {
list.mouseWheelMoved(newValue);
return true;
}
return true;
} }
public boolean keyPressed(int key, char c) { public boolean keyPressed(int key, char c) {
if (list.isVisible()) { if (keyEntryRight) {
list.keyPressed(key, c); Options.setGameKeyRight(key);
keyEntryRight = false;
return true; return true;
} }
if (keyEntryLeft) {
Options.setGameKeyLeft(key);
keyEntryLeft = false;
return true;
}
switch (key) {
case Input.KEY_ESCAPE:
if (isListOptionOpen) {
isListOptionOpen = false;
listHoverIndex = -1;
return true;
}
parent.onLeave();
return true;
}
return false; return false;
} }
private void updateHoverOption(int mouseX, int mouseY) {
if (isListOptionOpen || keyEntryLeft || keyEntryRight) {
return;
}
if (selectedOption != null) {
hoverOption = selectedOption;
return;
}
hoverOption = null;
if (mouseY < optionStartY || mouseX < optionStartX || mouseX > optionStartX + optionWidth) {
return;
}
int mouseVirtualY = scrollOffset + mouseY - optionStartY;
for (OptionTab tab : tabs) {
mouseVirtualY -= Fonts.MEDIUM.getLineHeight() * 2;
for (int optionIndex = 0; optionIndex < tab.options.length; optionIndex++) {
GameOption option = tab.options[optionIndex];
if (!option.showCondition()) {
continue;
}
if (mouseVirtualY <= optionHeight) {
if (mouseVirtualY >= 0) {
hoverOption = option;
}
return;
}
mouseVirtualY -= optionHeight;
}
}
}
public static class OptionTab {
public final String name;
public final GameOption[] options;
private MenuButton button;
public OptionTab(String name, GameOption[] options) {
this.name = name;
this.options = options;
}
}
public interface Parent {
void onLeave();
void onSaveOption(GameOption option);
}
} }

View File

@ -1,108 +0,0 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2016 yugecin
*
* opsu!dance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* opsu!dance is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with opsu!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance.ui;
import itdelatrisu.opsu.ui.Fonts;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.state.StateBasedGame;
import yugecin.opsudance.Dancer;
public class RWM {
private int x;
private int y;
private int width;
private int height;
private int delay;
private boolean visible;
public void init(GameContainer container) {
x = container.getWidth() / 10;
y = 0;
width = x * 8;
height = container.getHeight();
}
public boolean isVisible() {
return visible;
}
public void show() {
visible = true;
delay = 0;
}
public void update(int delta) {
delay += delta;
}
public void render(GameContainer container, StateBasedGame game, Graphics g) {
g.setColor(Color.black);
g.fillRect(x, y, width, height);
int y = 20;
y = drawCentered(y, "Hi! robin_be here", Color.cyan);
y = drawCentered(y, "I'm glad you're enjoying this client", Color.white);
y += 20;
y = drawCentered(y, "If you want to remove the watermark to make a video, please read following conditions:", Color.white);
y += 20;
y = drawCentered(y, "* You will not deny you used opsu!dance to make your video", Color.white);
y = drawCentered(y, "* You may provide a link to my repository. This is always very appreciated <3.", Color.white);
y = drawCentered(y, " Please do keep in mind I only made some adjustements/fixes and added the dancing stuff. opsu! was made by itdelatrisu", Color.white);
y = drawCentered(y, "* Asking for beatmap requests is discouraged. After all, everyone can download this and see it for themselves.", Color.white);
y = drawCentered(y, "* YOU WILL NOT PRETEND LIKE YOU MADE/OWN THIS SOFTWARE", Color.red);
y += 20;
y = drawCentered(y, "I'll love you if you leave the watermark visible, but I understand that it sucks to have that in a video.", Color.white);
y = drawCentered(y, "If you decide to hide it, please consider linking the repository in the video's description.", Color.white);
y += 20;
if (delay < 10000) {
y = drawCentered(y, "You can disable the watermark in a few seconds..", Color.white);
} else {
y += 50;
y = drawCentered(y, "Click this black area to disable it", Color.green);
}
}
public int drawCentered(int y, String text, Color color) {
int textwidth = Fonts.MEDIUM.getWidth(text);
Fonts.MEDIUM.drawString(x + width / 2 - textwidth / 2, y, text, color);
return y + Fonts.MEDIUM.getLineHeight() + 5;
}
public void mouseReleased(int button, int x, int y) {
if (x < this.x || x > this.x + width) {
this.visible = false;
return;
}
if (delay > 10000) {
Dancer.hidewatermark = true;
this.visible = false;
}
}
public void keyPressed(int key, char c) {
if (key == Input.KEY_ESCAPE) {
visible = false;
}
}
}

View File

@ -18,6 +18,7 @@
package yugecin.opsudance.ui; package yugecin.opsudance.ui;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Options.GameOption;
import itdelatrisu.opsu.audio.MusicController; import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.objects.GameObject; import itdelatrisu.opsu.objects.GameObject;
import itdelatrisu.opsu.states.Game; import itdelatrisu.opsu.states.Game;
@ -26,17 +27,73 @@ import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer; import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics; import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input; import org.newdawn.slick.Input;
import org.newdawn.slick.state.StateBasedGame;
import yugecin.opsudance.ObjectColorOverrides; import yugecin.opsudance.ObjectColorOverrides;
import yugecin.opsudance.ui.OptionsOverlay.OptionTab;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.Map;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class SBOverlay { public class SBOverlay implements OptionsOverlay.Parent {
public static boolean isActive = false; private static final OptionTab[] options = new OptionsOverlay.OptionTab[]{
new OptionTab("Gameplay", new GameOption[] {
GameOption.BACKGROUND_DIM,
GameOption.SNAKING_SLIDERS,
GameOption.SHRINKING_SLIDERS,
GameOption.SHOW_HIT_LIGHTING,
GameOption.SHOW_COMBO_BURSTS,
GameOption.SHOW_PERFECT_HIT,
GameOption.SHOW_FOLLOW_POINTS,
}),
new OptionTab("Input", new GameOption[] {
GameOption.CURSOR_SIZE,
GameOption.NEW_CURSOR,
GameOption.DISABLE_CURSOR
}),
new OptionTab("Dance", new GameOption[] {
GameOption.DANCE_MOVER,
GameOption.DANCE_QUAD_BEZ_AGGRESSIVENESS,
GameOption.DANCE_QUAD_BEZ_SLIDER_AGGRESSIVENESS_FACTOR,
GameOption.DANCE_QUAD_BEZ_USE_CUBIC_ON_SLIDERS,
GameOption.DANCE_QUAD_BEZ_CUBIC_AGGRESSIVENESS_FACTOR,
GameOption.DANCE_MOVER_DIRECTION,
GameOption.DANCE_SLIDER_MOVER_TYPE,
GameOption.DANCE_SPINNER,
GameOption.DANCE_SPINNER_DELAY,
GameOption.DANCE_LAZY_SLIDERS,
GameOption.DANCE_CIRCLE_STREAMS,
GameOption.DANCE_ONLY_CIRCLE_STACKS,
GameOption.DANCE_CIRLCE_IN_SLOW_SLIDERS,
GameOption.DANCE_CIRLCE_IN_LAZY_SLIDERS,
GameOption.DANCE_MIRROR,
}),
new OptionTab("Dance display", new GameOption[] {
GameOption.DANCE_DRAW_APPROACH,
GameOption.DANCE_OBJECT_COLOR_OVERRIDE,
GameOption.DANCE_OBJECT_COLOR_OVERRIDE_MIRRORED,
GameOption.DANCE_RGB_OBJECT_INC,
GameOption.DANCE_CURSOR_COLOR_OVERRIDE,
GameOption.DANCE_CURSOR_MIRROR_COLOR_OVERRIDE,
GameOption.DANCE_CURSOR_ONLY_COLOR_TRAIL,
GameOption.DANCE_RGB_CURSOR_INC,
GameOption.DANCE_CURSOR_TRAIL_OVERRIDE,
GameOption.DANCE_REMOVE_BG,
GameOption.DANCE_HIDE_OBJECTS,
GameOption.DANCE_HIDE_UI,
GameOption.DANCE_ENABLE_SB,
GameOption.DANCE_HIDE_WATERMARK,
}),
new OptionTab ("Pippi", new GameOption[] {
GameOption.PIPPI_ENABLE,
GameOption.PIPPI_RADIUS_PERCENT,
GameOption.PIPPI_ANGLE_INC_MUL,
GameOption.PIPPI_ANGLE_INC_MUL_SLIDER,
GameOption.PIPPI_SLIDER_FOLLOW_EXPAND,
GameOption.PIPPI_PREVENT_WOBBLY_STREAMS,
})
};
private final static List<GameOption> optionList = new ArrayList<>();
private boolean hide; private boolean hide;
private boolean menu; private boolean menu;
@ -52,24 +109,26 @@ public class SBOverlay {
private int index; private int index;
private final Game game; private final Game game;
private final OptionsOverlay options; private final OptionsOverlay overlay;
public SBOverlay(Game game) { static {
this.game = game; for (OptionTab tab : options) {
options = new OptionsOverlay(this); optionList.addAll(Arrays.asList(tab.options));
initialOptions = new HashMap<>(); }
} }
public void init(GameContainer container, Input input, int width, int height) { public SBOverlay(Game game, GameContainer container) {
this.width = width; this.game = game;
this.height = height; initialOptions = new HashMap<>();
overlay = new OptionsOverlay(this, options, 2, container);
this.width = container.getWidth();
this.height = container.getHeight();
speed = 10; speed = 10;
gameObjects = new GameObject[0]; gameObjects = new GameObject[0];
options.init(container, input, width, height);
} }
public void render(GameContainer container, StateBasedGame game, Graphics g) { public void render(GameContainer container, Graphics g) {
if (!isActive || hide) { if (!Options.isEnableSB() || hide) {
return; return;
} }
int lh = Fonts.SMALL.getLineHeight(); int lh = Fonts.SMALL.getLineHeight();
@ -84,7 +143,7 @@ public class SBOverlay {
for (Object o : optionsMap[index].entrySet()) { for (Object o : optionsMap[index].entrySet()) {
Map.Entry<Options.GameOption, String> option = (Map.Entry<Options.GameOption, String>) o; Map.Entry<Options.GameOption, String> option = (Map.Entry<Options.GameOption, String>) o;
Fonts.SMALL.drawString(10, 50 + i * lh, option.getKey().getName(), Color.cyan); Fonts.SMALL.drawString(10, 50 + i * lh, option.getKey().getName(), Color.cyan);
Fonts.SMALL.drawString(250, 50 + i * lh, option.getKey().getValueString(), Color.cyan); Fonts.SMALL.drawString(width / 5, 50 + i * lh, option.getKey().getValueString(), Color.cyan);
g.fillRect(0, 50 + i * lh + lh / 4, 10, 10); g.fillRect(0, 50 + i * lh + lh / 4, 10, 10);
i++; i++;
} }
@ -96,24 +155,21 @@ public class SBOverlay {
g.fillRect(curtime * width, height - 10f, 10f, 10f); g.fillRect(curtime * width, height - 10f, 10f, 10f);
} }
if (menu) { if (menu) {
options.render(container, game, g); overlay.render(g, container.getInput().getMouseX(), container.getInput().getMouseY());
} }
} }
public void update(int mouseX, int mouseY) { public void update(int delta, int mouseX, int mouseY) {
if (!isActive) { if (Options.isEnableSB() && menu) {
return; overlay.update(delta, mouseX, mouseY);
}
if (menu) {
options.update(mouseX, mouseY);
} }
} }
public boolean keyPressed(int key, char c) { public boolean keyPressed(int key, char c) {
if (!isActive) { if (!Options.isEnableSB()) {
return false; return false;
} }
if (options.keyPressed(key, c)) { if (menu && overlay.keyPressed(key, c)) {
return true; return true;
} }
if (key == Input.KEY_C) { if (key == Input.KEY_C) {
@ -148,12 +204,6 @@ public class SBOverlay {
index++; index++;
setMusicPosition(); setMusicPosition();
updateIndex(index); updateIndex(index);
} else if (key == Input.KEY_ESCAPE && menu) {
menu = false;
if (speed != 0) {
MusicController.resume();
}
return true;
} }
return false; return false;
} }
@ -188,27 +238,27 @@ public class SBOverlay {
if (optionsMap.length > 0) { if (optionsMap.length > 0) {
// copy all current settings in first obj map // copy all current settings in first obj map
optionsMap[0] = new HashMap<>(); optionsMap[0] = new HashMap<>();
for (Options.GameOption o : options.getSavedOptionList()) { for (Options.GameOption o : optionList) {
optionsMap[0].put(o, o.write()); optionsMap[0].put(o, o.write());
} }
} }
this.gameObjects = gameObjects; this.gameObjects = gameObjects;
} }
public void saveOption(Options.GameOption option) {
if (optionsMap[index] == null) {
optionsMap[index] = new HashMap<>();
}
optionsMap[index].put(option, option.write());
readOption(option);
}
public boolean mousePressed(int button, int x, int y) { public boolean mousePressed(int button, int x, int y) {
return menu && options.mousePressed(button, x, y); if (!menu) {
return false;
}
overlay.mousePressed(button, x, y);
return true;
} }
public void mouseDragged(int oldx, int oldy, int newx, int newy) { public boolean mouseDragged(int oldx, int oldy, int newx, int newy) {
if (menu) options.mouseDragged(oldx, oldy, newx, newy); if (!menu) {
return false;
}
overlay.mouseDragged(oldx, oldy, newx, newy);
return true;
} }
public void updateIndex(int index) { public void updateIndex(int index) {
@ -227,42 +277,32 @@ public class SBOverlay {
} }
public boolean mouseReleased(int button, int x, int y) { public boolean mouseReleased(int button, int x, int y) {
if (menu) { if (!menu) {
return options.mouseReleased(button, x, y);
}
if (x > 10 || index >= optionsMap.length || optionsMap[index] == null) {
return false; return false;
} }
int lh = Fonts.SMALL.getLineHeight(); overlay.mouseReleased(button, x, y);
int ypos = 50 + lh / 4; return true;
for (Object o : optionsMap[index].entrySet()) {
if (y >= ypos && y <= ypos + 10) {
optionsMap[index].remove(((Map.Entry<Options.GameOption, String>) o).getKey());
if (optionsMap[index].size() == 0) {
optionsMap[index] = null;
}
reloadSBsettingsToIndex(index);
return true;
}
ypos += lh;
}
return false;
} }
public boolean mouseWheelMoved(int newValue) { public boolean mouseWheelMoved(int delta) {
return menu && options.mouseWheenMoved(newValue); if (!menu) {
return false;
}
overlay.mouseWheelMoved(delta);
return true;
} }
public void enter() { public void enter() {
// enter, save current settings // enter, save current settings
for (Options.GameOption o : options.getSavedOptionList()) { for (Options.GameOption o : optionList) {
initialOptions.put(o, o.write()); initialOptions.put(o, o.write());
} }
speed = 10;
} }
public void leave() { public void leave() {
// leave, revert the settings saved before entering // leave, revert the settings saved before entering
for (Options.GameOption o : options.getSavedOptionList()) { for (Options.GameOption o : optionList) {
if (initialOptions.containsKey(o)) { if (initialOptions.containsKey(o)) {
o.read(initialOptions.get(o)); o.read(initialOptions.get(o));
readOption(o); readOption(o);
@ -284,4 +324,21 @@ public class SBOverlay {
} }
} }
@Override
public void onLeave() {
menu = false;
if (speed != 0) {
MusicController.resume();
}
}
@Override
public void onSaveOption(GameOption option) {
if (optionsMap[index] == null) {
optionsMap[index] = new HashMap<>();
}
optionsMap[index].put(option, option.write());
readOption(option);
}
} }