2016-09-27 21:29:03 +02:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
2016-09-28 13:34:54 +02:00
|
|
|
* opsu!dance is distributed in the hope that it will be useful,
|
2016-09-27 21:29:03 +02:00
|
|
|
* 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;
|
|
|
|
|
2016-10-11 14:45:58 +02:00
|
|
|
import awlex.ospu.movers.factories.CenterSpiralMoverFactory;
|
|
|
|
import awlex.ospu.movers.factories.SpiralMoverFactory;
|
2016-11-19 02:33:15 +01:00
|
|
|
import awlex.ospu.polymover.factory.ArcFactory;
|
2016-11-20 04:42:46 +01:00
|
|
|
import awlex.ospu.polymover.factory.LinearFactory;
|
2016-11-19 02:33:15 +01:00
|
|
|
import awlex.ospu.polymover.factory.PolyMoverFactory;
|
2016-10-11 14:45:58 +02:00
|
|
|
import awlex.ospu.spinners.SpiralSpinner;
|
2016-09-27 21:29:03 +02:00
|
|
|
import itdelatrisu.opsu.Options;
|
|
|
|
import itdelatrisu.opsu.Utils;
|
2016-11-20 23:40:30 +01:00
|
|
|
import itdelatrisu.opsu.audio.MusicController;
|
2016-09-27 22:23:14 +02:00
|
|
|
import itdelatrisu.opsu.objects.Circle;
|
2016-10-01 11:34:32 +02:00
|
|
|
import itdelatrisu.opsu.objects.DummyObject;
|
2016-09-27 21:29:03 +02:00
|
|
|
import itdelatrisu.opsu.objects.GameObject;
|
2016-09-27 22:23:14 +02:00
|
|
|
import itdelatrisu.opsu.objects.Slider;
|
2016-09-27 21:29:03 +02:00
|
|
|
import itdelatrisu.opsu.objects.curves.Vec2f;
|
2016-11-13 03:18:21 +01:00
|
|
|
import yugecin.opsudance.movers.LinearMover;
|
2016-09-27 21:29:03 +02:00
|
|
|
import yugecin.opsudance.movers.Mover;
|
2016-12-04 13:23:37 +01:00
|
|
|
import yugecin.opsudance.movers.QuadraticBezierMover;
|
2016-09-27 21:29:03 +02:00
|
|
|
import yugecin.opsudance.movers.factories.*;
|
2016-11-12 15:41:20 +01:00
|
|
|
import yugecin.opsudance.movers.slidermovers.DefaultSliderMoverController;
|
|
|
|
import yugecin.opsudance.movers.slidermovers.InheritedSliderMoverController;
|
|
|
|
import yugecin.opsudance.movers.slidermovers.SliderMoverController;
|
2016-10-01 10:57:05 +02:00
|
|
|
import yugecin.opsudance.spinners.*;
|
2016-09-27 21:29:03 +02:00
|
|
|
|
2016-12-04 15:00:07 +01:00
|
|
|
import java.awt.*;
|
|
|
|
|
2016-09-27 21:29:03 +02:00
|
|
|
public class Dancer {
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-11-20 22:29:40 +01:00
|
|
|
public static MoverFactory[] moverFactories = new MoverFactory[] {
|
2016-09-27 21:29:03 +02:00
|
|
|
new AutoMoverFactory(),
|
|
|
|
new AutoEllipseMoverFactory(),
|
|
|
|
new CircleMoverFactory(),
|
|
|
|
new HalfCircleMoverFactory(),
|
|
|
|
new HalfEllipseMoverFactory(),
|
|
|
|
new HalfLowEllipseMoverFactory(),
|
|
|
|
new JumpMoverFactory(),
|
|
|
|
new LinearMoverFactory(),
|
2016-10-11 14:45:58 +02:00
|
|
|
new QuartCircleMoverFactory(),
|
2016-10-11 15:06:36 +02:00
|
|
|
new SpiralMoverFactory(),
|
|
|
|
new CenterSpiralMoverFactory(),
|
2016-12-02 14:56:33 +01:00
|
|
|
//new LinearFactory(),
|
2016-11-20 17:24:58 +01:00
|
|
|
new ArcFactory(),
|
2016-12-04 13:23:37 +01:00
|
|
|
new QuadraticBezierMoverFactory(),
|
2016-09-27 21:29:03 +02:00
|
|
|
};
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-11-20 22:29:40 +01:00
|
|
|
public static Spinner[] spinners = new Spinner[] {
|
2016-10-01 10:50:35 +02:00
|
|
|
new RektSpinner(),
|
|
|
|
new BeamSpinner(),
|
2016-10-01 10:52:25 +02:00
|
|
|
new CircleSpinner(),
|
2016-10-01 11:14:15 +02:00
|
|
|
new DonutSpinner(),
|
2016-10-01 10:57:05 +02:00
|
|
|
new CubeSpinner(),
|
2016-10-01 10:58:28 +02:00
|
|
|
new HalfCircleSpinner(),
|
2016-10-01 10:59:50 +02:00
|
|
|
new IlluminatiSpinner(),
|
2016-10-01 11:02:00 +02:00
|
|
|
new LessThanThreeSpinner(),
|
2016-10-01 11:04:45 +02:00
|
|
|
new RektCircleSpinner(),
|
2016-10-07 21:47:15 +02:00
|
|
|
new ApproachCircleSpinner(),
|
2016-10-11 15:06:36 +02:00
|
|
|
new SpiralSpinner(),
|
2016-11-20 22:29:40 +01:00
|
|
|
new FivePointStarSpinner(),
|
2016-11-20 22:38:05 +01:00
|
|
|
new FivePointStarApproachSpinner(),
|
2016-09-27 21:29:03 +02:00
|
|
|
};
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-11-20 22:29:40 +01:00
|
|
|
public static SliderMoverController[] sliderMovers = new SliderMoverController[] {
|
2016-11-12 15:41:20 +01:00
|
|
|
new DefaultSliderMoverController(),
|
|
|
|
new InheritedSliderMoverController(),
|
|
|
|
};
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-09-27 21:29:03 +02:00
|
|
|
public static Dancer instance = new Dancer();
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-11-19 02:33:15 +01:00
|
|
|
public static boolean multipoint = false;
|
2016-09-30 21:51:59 +02:00
|
|
|
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...
|
2016-09-30 19:05:53 +02:00
|
|
|
public static ObjectColorOverrides colorOverride = ObjectColorOverrides.NONE;
|
|
|
|
public static ObjectColorOverrides colorMirrorOverride = ObjectColorOverrides.NONE;
|
|
|
|
public static int rgbhueinc = 70; // this should really get its own place somewhere...
|
2016-10-01 11:53:33 +02:00
|
|
|
public static CursorColorOverrides cursorColorOverride = CursorColorOverrides.NONE;
|
|
|
|
public static CursorColorOverrides cursorColorMirrorOverride = CursorColorOverrides.NONE;
|
2016-10-01 12:03:07 +02:00
|
|
|
public static int rgbcursorhueinc = 100; // this should really get its own place somewhere...
|
2016-09-30 21:40:33 +02:00
|
|
|
public static MoverDirection moverDirection = MoverDirection.RANDOM;
|
2016-09-30 23:11:43 +02:00
|
|
|
public static boolean hideobjects = false;
|
2016-10-01 12:14:39 +02:00
|
|
|
public static int cursortraillength = 20;
|
2016-10-04 14:40:41 +02:00
|
|
|
public static boolean hidewatermark = false;
|
2016-10-04 15:22:13 +02:00
|
|
|
public static boolean onlycolortrail = false;
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-09-27 21:29:03 +02:00
|
|
|
private int dir;
|
2016-10-01 15:47:01 +02:00
|
|
|
public static final GameObject d = new DummyObject();
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-11-20 17:01:56 +01:00
|
|
|
private GameObject[] gameObjects;
|
2016-11-20 18:35:20 +01:00
|
|
|
private int objectIndex;
|
2016-11-20 17:01:56 +01:00
|
|
|
|
2016-09-27 21:29:03 +02:00
|
|
|
private MoverFactory moverFactory;
|
|
|
|
private Mover mover;
|
|
|
|
private Spinner spinner;
|
2016-11-12 15:41:20 +01:00
|
|
|
public static SliderMoverController sliderMoverController;
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-09-27 22:02:49 +02:00
|
|
|
private int moverFactoryIndex;
|
|
|
|
private int spinnerIndex;
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-09-27 21:29:03 +02:00
|
|
|
public float x;
|
|
|
|
public float y;
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-09-27 22:23:14 +02:00
|
|
|
private boolean isCurrentLazySlider;
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-09-27 22:23:14 +02:00
|
|
|
public static boolean LAZY_SLIDERS;
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-09-27 21:29:03 +02:00
|
|
|
public Dancer() {
|
|
|
|
moverFactory = moverFactories[0];
|
|
|
|
spinner = spinners[0];
|
2016-11-12 15:41:20 +01:00
|
|
|
sliderMoverController = sliderMovers[0];
|
2016-09-27 21:29:03 +02:00
|
|
|
}
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-09-30 21:40:33 +02:00
|
|
|
public void reset() {
|
2016-09-27 22:23:14 +02:00
|
|
|
isCurrentLazySlider = false;
|
2016-11-20 18:35:20 +01:00
|
|
|
objectIndex = -1;
|
2016-09-27 21:29:03 +02:00
|
|
|
dir = 1;
|
|
|
|
for (Spinner s : spinners) {
|
|
|
|
s.init();
|
|
|
|
}
|
2016-12-04 13:23:37 +01:00
|
|
|
QuadraticBezierMover.reset();
|
2016-09-27 21:29:03 +02:00
|
|
|
}
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-09-27 22:02:49 +02:00
|
|
|
public int getSpinnerIndex() {
|
|
|
|
return spinnerIndex;
|
|
|
|
}
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-09-27 22:02:49 +02:00
|
|
|
public void setSpinnerIndex(int spinnerIndex) {
|
2016-09-27 22:04:14 +02:00
|
|
|
if (spinnerIndex < 0 || spinnerIndex >= spinners.length) {
|
|
|
|
spinnerIndex = 0;
|
|
|
|
}
|
2016-09-27 22:02:49 +02:00
|
|
|
this.spinnerIndex = spinnerIndex;
|
|
|
|
spinner = spinners[spinnerIndex];
|
|
|
|
}
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-09-27 22:02:49 +02:00
|
|
|
public int getMoverFactoryIndex() {
|
|
|
|
return moverFactoryIndex;
|
|
|
|
}
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-09-27 22:02:49 +02:00
|
|
|
public void setMoverFactoryIndex(int moverFactoryIndex) {
|
2016-09-27 22:04:14 +02:00
|
|
|
if (moverFactoryIndex < 0 || moverFactoryIndex >= moverFactories.length) {
|
|
|
|
moverFactoryIndex = 0;
|
|
|
|
}
|
2016-09-27 22:02:49 +02:00
|
|
|
this.moverFactoryIndex = moverFactoryIndex;
|
|
|
|
moverFactory = moverFactories[moverFactoryIndex];
|
2016-12-04 23:54:53 +01:00
|
|
|
multipoint = moverFactory instanceof MoverFactory.MultiPoint;
|
2016-11-20 18:35:20 +01:00
|
|
|
// to prevent crashes when changing mover in storyboard, create mover now
|
|
|
|
createNewMover();
|
2016-09-27 22:02:49 +02:00
|
|
|
}
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-11-20 17:24:58 +01:00
|
|
|
public int getPolyMoverFactoryMinBufferSize() {
|
|
|
|
if (!multipoint) {
|
|
|
|
return 0;
|
2016-11-19 02:33:15 +01:00
|
|
|
}
|
2016-11-20 17:24:58 +01:00
|
|
|
return ((PolyMoverFactory) moverFactory).getMinBufferSize();
|
2016-11-19 02:33:15 +01:00
|
|
|
}
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-11-20 17:01:56 +01:00
|
|
|
public void setGameObjects(GameObject[] objs) {
|
|
|
|
this.gameObjects = objs;
|
|
|
|
}
|
|
|
|
|
2016-11-20 18:35:20 +01:00
|
|
|
public void setObjectIndex(int objectIndex) {
|
|
|
|
this.objectIndex = objectIndex;
|
|
|
|
// storyboard
|
|
|
|
createNewMover();
|
|
|
|
}
|
|
|
|
|
2016-11-20 17:01:56 +01:00
|
|
|
public void update(int time, int objectIndex) {
|
|
|
|
GameObject p;
|
|
|
|
if (objectIndex == 0) {
|
|
|
|
p = d;
|
|
|
|
} else {
|
|
|
|
p = gameObjects[objectIndex - 1];
|
|
|
|
}
|
|
|
|
GameObject c = gameObjects[objectIndex];
|
2016-11-20 17:02:55 +01:00
|
|
|
if (!multipoint) {
|
|
|
|
GameObject[] e = sliderMoverController.process(p, c, time);
|
|
|
|
p = e[0];
|
|
|
|
c = e[1];
|
|
|
|
}
|
2016-11-20 23:40:30 +01:00
|
|
|
if (this.objectIndex != objectIndex || c != gameObjects[objectIndex]) {
|
2016-11-20 18:35:20 +01:00
|
|
|
this.objectIndex = objectIndex;
|
|
|
|
if (objectIndex == 0) {
|
2016-10-01 15:47:01 +02:00
|
|
|
if (c.isSpinner()) {
|
|
|
|
double[] spinnerStartPoint = spinner.getPoint();
|
|
|
|
c.start.set((float) spinnerStartPoint[0], (float) spinnerStartPoint[1]);
|
|
|
|
}
|
2016-10-01 11:34:32 +02:00
|
|
|
}
|
2016-09-27 22:23:14 +02:00
|
|
|
isCurrentLazySlider = false;
|
|
|
|
// detect lazy sliders, should work pretty good
|
2016-10-01 14:46:39 +02:00
|
|
|
if (c.isSlider() && LAZY_SLIDERS && Utils.distance(c.start.x, c.start.y, c.end.x, c.end.y) <= Circle.diameter * 0.8f) {
|
2016-09-27 22:23:14 +02:00
|
|
|
Slider s = (Slider) c;
|
|
|
|
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) {
|
|
|
|
mid = s.getCurve().pointAt(0.5f);
|
|
|
|
if (Utils.distance(c.start.x, c.start.y, mid.x, mid.y) <= Circle.diameter * 0.8f) {
|
|
|
|
isCurrentLazySlider = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-30 21:40:33 +02:00
|
|
|
dir = moverDirection.getDirection(dir);
|
2016-09-27 21:29:03 +02:00
|
|
|
if (c.isSpinner()) {
|
|
|
|
double[] spinnerStartPoint = spinner.getPoint();
|
|
|
|
c.start = new Vec2f((float) spinnerStartPoint[0], (float) spinnerStartPoint[1]);
|
|
|
|
}
|
2016-11-20 17:01:56 +01:00
|
|
|
|
2016-12-04 15:00:07 +01:00
|
|
|
// specific mover stuff
|
|
|
|
if (p.isSlider() && sliderMoverController instanceof DefaultSliderMoverController) {
|
|
|
|
Vec2f st = p.getPointAt(p.getEndTime() - 10);
|
|
|
|
Vec2f en = p.getPointAt(p.getEndTime());
|
|
|
|
//double atan = Math.atan2(en.y - st.y, en.x - st.x);
|
|
|
|
double distance = Utils.distance(st.x, st.y, en.x, en.y);
|
|
|
|
QuadraticBezierMover.p = new Point((int) st.x, (int) st.y);
|
|
|
|
QuadraticBezierMover.setPrevspeed(distance, 10);
|
|
|
|
}
|
|
|
|
|
2016-11-20 18:35:20 +01:00
|
|
|
createNewMover();
|
2016-09-27 21:29:03 +02:00
|
|
|
}
|
2016-11-19 22:16:36 +01:00
|
|
|
|
2016-09-27 21:29:03 +02:00
|
|
|
if (time < c.getTime()) {
|
|
|
|
if (!p.isSpinner() || !c.isSpinner()) {
|
2016-11-20 17:01:56 +01:00
|
|
|
double[] point;
|
|
|
|
if (multipoint) {
|
2016-11-20 17:24:58 +01:00
|
|
|
point = ((PolyMoverFactory) moverFactory).getPointAt(time);
|
2016-11-20 17:01:56 +01:00
|
|
|
} else {
|
|
|
|
point = mover.getPointAt(time);
|
2016-11-19 02:33:15 +01:00
|
|
|
}
|
|
|
|
x = (float) point[0];
|
|
|
|
y = (float) point[1];
|
|
|
|
}
|
2016-11-20 17:01:56 +01:00
|
|
|
} else {
|
2016-11-19 02:33:15 +01:00
|
|
|
if (c.isSpinner()) {
|
|
|
|
Spinner.PROGRESS = (double) (time - c.getTime()) / (double) (c.getEndTime() - c.getTime());
|
|
|
|
double[] point = spinner.getPoint();
|
|
|
|
x = (float) point[0];
|
|
|
|
y = (float) point[1];
|
|
|
|
c.end = new Vec2f(x, y);
|
2016-11-20 17:01:56 +01:00
|
|
|
} else {
|
2016-09-27 21:29:03 +02:00
|
|
|
Vec2f point = c.getPointAt(time);
|
2016-09-27 22:23:14 +02:00
|
|
|
if (isCurrentLazySlider) {
|
|
|
|
point = c.start;
|
|
|
|
}
|
2016-09-27 21:29:03 +02:00
|
|
|
x = point.x;
|
|
|
|
y = point.y;
|
|
|
|
}
|
|
|
|
}
|
2016-09-30 22:57:57 +02:00
|
|
|
Pippi.dance(time, c, isCurrentLazySlider);
|
|
|
|
x = Utils.clamp(x, 10, Options.width - 10);
|
|
|
|
y = Utils.clamp(y, 10, Options.height - 10);
|
2016-09-27 21:29:03 +02:00
|
|
|
}
|
2016-11-20 17:01:56 +01:00
|
|
|
|
2016-11-20 18:35:20 +01:00
|
|
|
private void createNewMover() {
|
|
|
|
if (gameObjects == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (objectIndex < 0) {
|
|
|
|
objectIndex = 0;
|
|
|
|
}
|
|
|
|
GameObject c = gameObjects[objectIndex];
|
|
|
|
if (multipoint) {
|
|
|
|
PolyMoverFactory pmf = (PolyMoverFactory) moverFactory;
|
|
|
|
if (pmf.isInitialized() && pmf.getLatestIndex() < objectIndex + pmf.getLatestIndex() - 1) {
|
|
|
|
pmf.update(gameObjects[objectIndex + pmf.getMaxBufferSize() - 1]);
|
|
|
|
} else {
|
|
|
|
pmf.create(gameObjects, objectIndex - 1);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2016-11-20 23:52:28 +01:00
|
|
|
GameObject p = d;
|
2016-11-20 23:40:30 +01:00
|
|
|
if (objectIndex > 0) {
|
|
|
|
p = gameObjects[objectIndex - 1];
|
|
|
|
}
|
2016-11-20 23:52:28 +01:00
|
|
|
GameObject[] e = sliderMoverController.process(p, c, MusicController.getPosition());
|
|
|
|
p = e[0];
|
|
|
|
c = e[1];
|
|
|
|
if (mover == null || p == d) {
|
|
|
|
mover = new LinearMover(d, c, dir);
|
|
|
|
} else if (mover.getEnd() != c) {
|
|
|
|
mover = moverFactory.create(p, c, dir);
|
2016-11-20 18:35:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-27 21:29:03 +02:00
|
|
|
}
|