Merge branch 'slidermovers'

This commit is contained in:
yugecin 2016-11-12 18:32:06 +01:00
commit a066d3fe48
10 changed files with 219 additions and 1 deletions

View File

@ -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") {
@Override
public Object[] getListItems() {

View File

@ -160,6 +160,13 @@ public class HitObject {
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.
*/
@ -286,6 +293,10 @@ public class HitObject {
*/
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.
*/
@ -296,6 +307,14 @@ public class HitObject {
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.
* @return the start time (in ms)

View File

@ -91,6 +91,11 @@ public class Circle extends GameObject {
mirrorColor = Dancer.colorMirrorOverride.getColor(comboColorIndex);
}
public Circle(float x, float y, int time) {
hitObject = new HitObject(x, y, time);
super.updateStartEndPositions(time);
}
@Override
public void draw(Graphics g, int trackPosition, boolean mirror) {
Color orig = color;
@ -229,6 +234,7 @@ public class Circle extends GameObject {
public void updatePosition() {
this.x = hitObject.getScaledX();
this.y = hitObject.getScaledY();
super.updateStartEndPositions(hitObject.getTime());
}
@Override

View File

@ -32,7 +32,6 @@ import itdelatrisu.opsu.states.Game;
import itdelatrisu.opsu.ui.Colors;
import itdelatrisu.opsu.ui.animations.AnimationEquation;
import org.lwjgl.opengl.GL11;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
@ -688,4 +687,27 @@ public class Slider extends GameObject {
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;
}
}

View File

@ -1727,6 +1727,10 @@ public class Game extends BasicGameState {
*/
public float getBeatLength() { return beatLength; }
public float getBeatLengthBase() {
return beatLengthBase;
}
/**
* Sets the beat length fields based on a given timing point.
* @param timingPoint the timing point

View File

@ -111,6 +111,7 @@ public class OptionsMenu extends BasicGameState {
DANCE ("Dance", new GameOption[] {
GameOption.DANCE_MOVER,
GameOption.DANCE_MOVER_DIRECTION,
GameOption.DANCE_SLIDER_MOVER_TYPE,
GameOption.DANCE_SPINNER,
GameOption.DANCE_SPINNER_DELAY,
GameOption.DANCE_LAZY_SLIDERS,

View File

@ -29,6 +29,9 @@ import itdelatrisu.opsu.objects.Slider;
import itdelatrisu.opsu.objects.curves.Vec2f;
import yugecin.opsudance.movers.Mover;
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.*;
public class Dancer {
@ -61,6 +64,11 @@ public class Dancer {
new SpiralSpinner(),
};
public static SliderMoverController[] sliderMovers = new SliderMoverController[] {
new DefaultSliderMoverController(),
new InheritedSliderMoverController(),
};
public static Dancer instance = new Dancer();
public static boolean mirror = false; // this should really get its own place somewhere...
@ -86,6 +94,7 @@ public class Dancer {
private MoverFactory moverFactory;
private Mover mover;
private Spinner spinner;
public static SliderMoverController sliderMoverController;
private int moverFactoryIndex;
private int spinnerIndex;
@ -100,6 +109,7 @@ public class Dancer {
public Dancer() {
moverFactory = moverFactories[0];
spinner = spinners[0];
sliderMoverController = sliderMovers[0];
}
public void reset() {
@ -136,6 +146,9 @@ public class Dancer {
}
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) {
this.p = p;
if (this.p == d) {

View File

@ -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";
}
}

View File

@ -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";
}
}

View File

@ -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);
}