Merge branch 'slidermovers'
This commit is contained in:
commit
a066d3fe48
|
@ -626,6 +626,34 @@ public class Options {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
DANCE_SLIDER_MOVER_TYPE ("Slider mover", "SliderMover", "How to move in sliders") {
|
||||||
|
@Override
|
||||||
|
public String getValueString() {
|
||||||
|
return Dancer.sliderMoverController.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getListItems() {
|
||||||
|
return Dancer.sliderMovers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clickListItem(int index) {
|
||||||
|
val = index;
|
||||||
|
Dancer.sliderMoverController = Dancer.sliderMovers[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String write() {
|
||||||
|
return String.valueOf(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(String 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() {
|
||||||
|
|
|
@ -160,6 +160,13 @@ public class HitObject {
|
||||||
yOffset = (int) (height - MAX_Y * yMultiplier) / 2;
|
yOffset = (int) (height - MAX_Y * yMultiplier) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HitObject( float x, float y, int time) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.time = time;
|
||||||
|
this.type = HitObject.TYPE_CIRCLE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the X multiplier for coordinates.
|
* Returns the X multiplier for coordinates.
|
||||||
*/
|
*/
|
||||||
|
@ -286,6 +293,10 @@ public class HitObject {
|
||||||
*/
|
*/
|
||||||
public float getScaledX() { return (x - stack * stackOffset) * xMultiplier + xOffset; }
|
public float getScaledX() { return (x - stack * stackOffset) * xMultiplier + xOffset; }
|
||||||
|
|
||||||
|
public static float unscaleX(float x) {
|
||||||
|
return (x - xOffset) / xMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the scaled starting y coordinate.
|
* Returns the scaled starting y coordinate.
|
||||||
*/
|
*/
|
||||||
|
@ -296,6 +307,14 @@ public class HitObject {
|
||||||
return (y - stack * stackOffset) * yMultiplier + yOffset;
|
return (y - stack * stackOffset) * yMultiplier + yOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float unscaleY(float y) {
|
||||||
|
if(GameMod.HARD_ROCK.isActive()) {
|
||||||
|
return ((containerHeight - y) - yOffset) / yMultiplier;
|
||||||
|
}
|
||||||
|
return (y - yOffset) / yMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the start time.
|
* Returns the start time.
|
||||||
* @return the start time (in ms)
|
* @return the start time (in ms)
|
||||||
|
|
|
@ -91,6 +91,11 @@ public class Circle extends GameObject {
|
||||||
mirrorColor = Dancer.colorMirrorOverride.getColor(comboColorIndex);
|
mirrorColor = Dancer.colorMirrorOverride.getColor(comboColorIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Circle(float x, float y, int time) {
|
||||||
|
hitObject = new HitObject(x, y, time);
|
||||||
|
super.updateStartEndPositions(time);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics g, int trackPosition, boolean mirror) {
|
public void draw(Graphics g, int trackPosition, boolean mirror) {
|
||||||
Color orig = color;
|
Color orig = color;
|
||||||
|
@ -229,6 +234,7 @@ public class Circle extends GameObject {
|
||||||
public void updatePosition() {
|
public void updatePosition() {
|
||||||
this.x = hitObject.getScaledX();
|
this.x = hitObject.getScaledX();
|
||||||
this.y = hitObject.getScaledY();
|
this.y = hitObject.getScaledY();
|
||||||
|
super.updateStartEndPositions(hitObject.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -32,7 +32,6 @@ import itdelatrisu.opsu.states.Game;
|
||||||
import itdelatrisu.opsu.ui.Colors;
|
import itdelatrisu.opsu.ui.Colors;
|
||||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
import org.newdawn.slick.Color;
|
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;
|
||||||
|
@ -688,4 +687,27 @@ public class Slider extends GameObject {
|
||||||
return mirrorColor;
|
return mirrorColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Circle[] getTickPositionCircles() {
|
||||||
|
float tickLengthDiv = 100f * sliderMultiplier / sliderTickRate / (game.getBeatLength() / game.getBeatLengthBase());
|
||||||
|
int tickCount = (int) Math.ceil(pixelLength / tickLengthDiv) - 1;
|
||||||
|
Circle[] ticks = new Circle[1 + ( tickCount + 1 ) * repeats];
|
||||||
|
Vec2f pos;
|
||||||
|
pos = getPointAt( getTime() );
|
||||||
|
pos.set( HitObject.unscaleX( pos.x ), HitObject.unscaleY( pos.y ) );
|
||||||
|
ticks[0] = new Circle(pos.x, pos.y, getTime() );
|
||||||
|
float tickTOffset = 1f / (tickCount + 1) / repeats;
|
||||||
|
float t = tickTOffset;
|
||||||
|
for( int i = 0; i < (tickCount + 1) * repeats; i++, t += tickTOffset ) {
|
||||||
|
pos = getPointAt( getTime() + (int) (t * sliderTimeTotal ) );
|
||||||
|
pos.set( HitObject.unscaleX( pos.x ), HitObject.unscaleY( pos.y ) );
|
||||||
|
ticks[1 + i] = new Circle(pos.x, pos.y, getTime() + (int) (t * sliderTimeTotal));
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Circle c : ticks) {
|
||||||
|
c.updatePosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ticks;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1727,6 +1727,10 @@ public class Game extends BasicGameState {
|
||||||
*/
|
*/
|
||||||
public float getBeatLength() { return beatLength; }
|
public float getBeatLength() { return beatLength; }
|
||||||
|
|
||||||
|
public float getBeatLengthBase() {
|
||||||
|
return beatLengthBase;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the beat length fields based on a given timing point.
|
* Sets the beat length fields based on a given timing point.
|
||||||
* @param timingPoint the timing point
|
* @param timingPoint the timing point
|
||||||
|
|
|
@ -111,6 +111,7 @@ public class OptionsMenu extends BasicGameState {
|
||||||
DANCE ("Dance", new GameOption[] {
|
DANCE ("Dance", new GameOption[] {
|
||||||
GameOption.DANCE_MOVER,
|
GameOption.DANCE_MOVER,
|
||||||
GameOption.DANCE_MOVER_DIRECTION,
|
GameOption.DANCE_MOVER_DIRECTION,
|
||||||
|
GameOption.DANCE_SLIDER_MOVER_TYPE,
|
||||||
GameOption.DANCE_SPINNER,
|
GameOption.DANCE_SPINNER,
|
||||||
GameOption.DANCE_SPINNER_DELAY,
|
GameOption.DANCE_SPINNER_DELAY,
|
||||||
GameOption.DANCE_LAZY_SLIDERS,
|
GameOption.DANCE_LAZY_SLIDERS,
|
||||||
|
|
|
@ -29,6 +29,9 @@ import itdelatrisu.opsu.objects.Slider;
|
||||||
import itdelatrisu.opsu.objects.curves.Vec2f;
|
import itdelatrisu.opsu.objects.curves.Vec2f;
|
||||||
import yugecin.opsudance.movers.Mover;
|
import yugecin.opsudance.movers.Mover;
|
||||||
import yugecin.opsudance.movers.factories.*;
|
import yugecin.opsudance.movers.factories.*;
|
||||||
|
import yugecin.opsudance.movers.slidermovers.DefaultSliderMoverController;
|
||||||
|
import yugecin.opsudance.movers.slidermovers.InheritedSliderMoverController;
|
||||||
|
import yugecin.opsudance.movers.slidermovers.SliderMoverController;
|
||||||
import yugecin.opsudance.spinners.*;
|
import yugecin.opsudance.spinners.*;
|
||||||
|
|
||||||
public class Dancer {
|
public class Dancer {
|
||||||
|
@ -61,6 +64,11 @@ public class Dancer {
|
||||||
new SpiralSpinner(),
|
new SpiralSpinner(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static SliderMoverController[] sliderMovers = new SliderMoverController[] {
|
||||||
|
new DefaultSliderMoverController(),
|
||||||
|
new InheritedSliderMoverController(),
|
||||||
|
};
|
||||||
|
|
||||||
public static Dancer instance = new Dancer();
|
public static Dancer instance = new Dancer();
|
||||||
|
|
||||||
public static boolean mirror = false; // this should really get its own place somewhere...
|
public static boolean mirror = false; // this should really get its own place somewhere...
|
||||||
|
@ -86,6 +94,7 @@ public class Dancer {
|
||||||
private MoverFactory moverFactory;
|
private MoverFactory moverFactory;
|
||||||
private Mover mover;
|
private Mover mover;
|
||||||
private Spinner spinner;
|
private Spinner spinner;
|
||||||
|
public static SliderMoverController sliderMoverController;
|
||||||
|
|
||||||
private int moverFactoryIndex;
|
private int moverFactoryIndex;
|
||||||
private int spinnerIndex;
|
private int spinnerIndex;
|
||||||
|
@ -100,6 +109,7 @@ public class Dancer {
|
||||||
public Dancer() {
|
public Dancer() {
|
||||||
moverFactory = moverFactories[0];
|
moverFactory = moverFactories[0];
|
||||||
spinner = spinners[0];
|
spinner = spinners[0];
|
||||||
|
sliderMoverController = sliderMovers[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
|
@ -136,6 +146,9 @@ public class Dancer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(int time, GameObject p, GameObject c) {
|
public void update(int time, GameObject p, GameObject c) {
|
||||||
|
GameObject[] e = sliderMoverController.process(p, c, time);
|
||||||
|
p = e[0];
|
||||||
|
c = e[1];
|
||||||
if (this.p != p) {
|
if (this.p != p) {
|
||||||
this.p = p;
|
this.p = p;
|
||||||
if (this.p == d) {
|
if (this.p == d) {
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* 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.movers.slidermovers;
|
||||||
|
|
||||||
|
import itdelatrisu.opsu.objects.GameObject;
|
||||||
|
|
||||||
|
public class DefaultSliderMoverController implements SliderMoverController {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameObject[] process(GameObject p, GameObject c, int time) {
|
||||||
|
return new GameObject[] {
|
||||||
|
p,
|
||||||
|
c
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Nothing special, just follow it";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* 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.movers.slidermovers;
|
||||||
|
|
||||||
|
import itdelatrisu.opsu.objects.Circle;
|
||||||
|
import itdelatrisu.opsu.objects.GameObject;
|
||||||
|
import itdelatrisu.opsu.objects.Slider;
|
||||||
|
|
||||||
|
public class InheritedSliderMoverController implements SliderMoverController {
|
||||||
|
|
||||||
|
private GameObject currentSlider;
|
||||||
|
private Circle[] positions;
|
||||||
|
private int idx;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameObject[] process(GameObject p, GameObject c, int time) {
|
||||||
|
GameObject[] ret = new GameObject[2];
|
||||||
|
if (!c.isSlider()) {
|
||||||
|
ret[0] = p;
|
||||||
|
ret[1] = c;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if (currentSlider != c) {
|
||||||
|
currentSlider = c;
|
||||||
|
positions = ((Slider) c).getTickPositionCircles();
|
||||||
|
idx = 0;
|
||||||
|
}
|
||||||
|
for (; idx < positions.length; idx++) {
|
||||||
|
if (time < positions[idx].getTime() || idx == positions.length - 1) {
|
||||||
|
ret[1] = positions[idx];
|
||||||
|
if (idx == 0) {
|
||||||
|
ret[0] = p;
|
||||||
|
} else {
|
||||||
|
ret[0] = positions[idx - 1];
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null; // make the compiler happy c:
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Inherited from normal mover";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* 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.movers.slidermovers;
|
||||||
|
|
||||||
|
import itdelatrisu.opsu.objects.GameObject;
|
||||||
|
|
||||||
|
public interface SliderMoverController {
|
||||||
|
|
||||||
|
GameObject[] process(GameObject p, GameObject c, int time);
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user