diff --git a/src/itdelatrisu/opsu/Options.java b/src/itdelatrisu/opsu/Options.java index 66b50f03..15eff8a0 100644 --- a/src/itdelatrisu/opsu/Options.java +++ b/src/itdelatrisu/opsu/Options.java @@ -55,6 +55,7 @@ import com.sun.jna.platform.win32.Advapi32Util; import com.sun.jna.platform.win32.Win32Exception; import com.sun.jna.platform.win32.WinReg; import yugecin.opsudance.Dancer; +import yugecin.opsudance.MoverDirection; import yugecin.opsudance.ObjectColorOverrides; import yugecin.opsudance.movers.factories.AutoMoverFactory; @@ -571,6 +572,33 @@ public class Options { } }, + DANCE_MOVER_DIRECTION ("Mover direction", "MoverDirection", "The direction the mover goes" ) { + @Override + public String getValueString() { + return Dancer.moverDirection.toString(); + } + + @Override + public Object[] getListItems() { + return MoverDirection.values(); + } + + @Override + public void clickListItem(int index) { + Dancer.moverDirection = MoverDirection.values()[index]; + } + + @Override + public String write() { + return "" + Dancer.moverDirection.nr; + } + + @Override + public void read(String s) { + Dancer.moverDirection = MoverDirection.values()[Integer.parseInt(s)]; + } + }, + DANCE_SPINNER ("Spinner", "Spinner", "Spinner style") { @Override public Object[] getListItems() { diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index df94e338..6a20c711 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -71,6 +71,7 @@ import org.newdawn.slick.state.transition.EasedFadeOutTransition; import org.newdawn.slick.state.transition.EmptyTransition; import org.newdawn.slick.state.transition.FadeInTransition; import yugecin.opsudance.Dancer; +import yugecin.opsudance.MoverDirection; import yugecin.opsudance.ObjectColorOverrides; /** @@ -1163,7 +1164,8 @@ public class Game extends BasicGameState { if (beatmap == null || beatmap.objects == null) throw new RuntimeException("Running game with no beatmap loaded."); - Dancer.instance.init(beatmap.getTitle()); + Dancer.instance.reset(); + MoverDirection.reset(beatmap.getTitle()); // free all previously cached hitobject to framebuffer mappings if some still exist FrameBufferCache.getInstance().freeMap(); diff --git a/src/itdelatrisu/opsu/states/OptionsMenu.java b/src/itdelatrisu/opsu/states/OptionsMenu.java index c8333a52..064580fe 100644 --- a/src/itdelatrisu/opsu/states/OptionsMenu.java +++ b/src/itdelatrisu/opsu/states/OptionsMenu.java @@ -107,6 +107,7 @@ public class OptionsMenu extends BasicGameState { }), DANCE ("Dance", new GameOption[] { GameOption.DANCE_MOVER, + GameOption.DANCE_MOVER_DIRECTION, GameOption.DANCE_SPINNER, GameOption.DANCE_LAZY_SLIDERS, GameOption.DANCE_CIRCLE_STREAMS, diff --git a/src/yugecin/opsudance/Dancer.java b/src/yugecin/opsudance/Dancer.java index 3afe44dc..9effc665 100644 --- a/src/yugecin/opsudance/Dancer.java +++ b/src/yugecin/opsudance/Dancer.java @@ -58,10 +58,10 @@ public class Dancer { public static ObjectColorOverrides colorMirrorOverride = ObjectColorOverrides.NONE; public static int rgbhueinc = 70; // this should really get its own place somewhere... public static boolean cursoruselastobjectcolor; + public static MoverDirection moverDirection = MoverDirection.RANDOM; private int dir; private GameObject p; - private Random rand; private MoverFactory moverFactory; private Mover mover; @@ -82,10 +82,9 @@ public class Dancer { spinner = spinners[0]; } - public void init(String mapname) { + public void reset() { isCurrentLazySlider = false; p = null; - rand = new Random(mapname.hashCode()); dir = 1; for (Spinner s : spinners) { s.init(); @@ -131,9 +130,7 @@ public class Dancer { } } } - if (rand.nextInt(2) == 1) { - dir *= -1; - } + dir = moverDirection.getDirection(dir); if (c.isSpinner()) { double[] spinnerStartPoint = spinner.getPoint(); c.start = new Vec2f((float) spinnerStartPoint[0], (float) spinnerStartPoint[1]); diff --git a/src/yugecin/opsudance/MoverDirection.java b/src/yugecin/opsudance/MoverDirection.java new file mode 100644 index 00000000..427b2b3e --- /dev/null +++ b/src/yugecin/opsudance/MoverDirection.java @@ -0,0 +1,73 @@ +/* + * 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 . + */ +package yugecin.opsudance; + +import java.util.Random; + +public enum MoverDirection { + + LEFT ("Left", 0) { + @Override + public int getDirection(int currentDirection) { + return 1; + } + }, + RIGHT ("Right", 1) { + @Override + public int getDirection(int currentDirection) { + return -1; + } + }, + ALTERNATE ("Alternate", 2) { + @Override + public int getDirection(int currentDirection) { + return currentDirection * -1; + } + }, + RANDOM ("Random", 3) { + @Override + public int getDirection(int currentDirection) { + if (rand.nextInt(2) == 1) { + return currentDirection * -1; + } + return currentDirection; + } + }; + + public String displayName; + public int nr; + + private static Random rand; + + MoverDirection(String displayName, int nr) { + this.displayName = displayName; + this.nr = nr; + } + + public static void reset(String mapName) { + rand = new Random(mapName.hashCode()); + } + + public abstract int getDirection(int currentDirection); + + @Override + public String toString() { + return displayName; + } + +}