Merge branch 'moverdirection'

This commit is contained in:
yugecin 2016-09-30 21:45:27 +02:00
commit 0df478544c
5 changed files with 108 additions and 7 deletions

View File

@ -55,6 +55,7 @@ import com.sun.jna.platform.win32.Advapi32Util;
import com.sun.jna.platform.win32.Win32Exception; import com.sun.jna.platform.win32.Win32Exception;
import com.sun.jna.platform.win32.WinReg; import com.sun.jna.platform.win32.WinReg;
import yugecin.opsudance.Dancer; import yugecin.opsudance.Dancer;
import yugecin.opsudance.MoverDirection;
import yugecin.opsudance.ObjectColorOverrides; import yugecin.opsudance.ObjectColorOverrides;
import yugecin.opsudance.movers.factories.AutoMoverFactory; 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") { DANCE_SPINNER ("Spinner", "Spinner", "Spinner style") {
@Override @Override
public Object[] getListItems() { public Object[] getListItems() {

View File

@ -71,6 +71,7 @@ import org.newdawn.slick.state.transition.EasedFadeOutTransition;
import org.newdawn.slick.state.transition.EmptyTransition; import org.newdawn.slick.state.transition.EmptyTransition;
import org.newdawn.slick.state.transition.FadeInTransition; import org.newdawn.slick.state.transition.FadeInTransition;
import yugecin.opsudance.Dancer; import yugecin.opsudance.Dancer;
import yugecin.opsudance.MoverDirection;
import yugecin.opsudance.ObjectColorOverrides; import yugecin.opsudance.ObjectColorOverrides;
/** /**
@ -1163,7 +1164,8 @@ public class Game extends BasicGameState {
if (beatmap == null || beatmap.objects == null) if (beatmap == null || beatmap.objects == null)
throw new RuntimeException("Running game with no beatmap loaded."); 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 // free all previously cached hitobject to framebuffer mappings if some still exist
FrameBufferCache.getInstance().freeMap(); FrameBufferCache.getInstance().freeMap();

View File

@ -107,6 +107,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_SPINNER, GameOption.DANCE_SPINNER,
GameOption.DANCE_LAZY_SLIDERS, GameOption.DANCE_LAZY_SLIDERS,
GameOption.DANCE_CIRCLE_STREAMS, GameOption.DANCE_CIRCLE_STREAMS,

View File

@ -58,10 +58,10 @@ public class Dancer {
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 int rgbhueinc = 70; // this should really get its own place somewhere...
public static boolean cursoruselastobjectcolor; public static boolean cursoruselastobjectcolor;
public static MoverDirection moverDirection = MoverDirection.RANDOM;
private int dir; private int dir;
private GameObject p; private GameObject p;
private Random rand;
private MoverFactory moverFactory; private MoverFactory moverFactory;
private Mover mover; private Mover mover;
@ -82,10 +82,9 @@ public class Dancer {
spinner = spinners[0]; spinner = spinners[0];
} }
public void init(String mapname) { public void reset() {
isCurrentLazySlider = false; isCurrentLazySlider = false;
p = null; p = null;
rand = new Random(mapname.hashCode());
dir = 1; dir = 1;
for (Spinner s : spinners) { for (Spinner s : spinners) {
s.init(); s.init();
@ -131,9 +130,7 @@ public class Dancer {
} }
} }
} }
if (rand.nextInt(2) == 1) { dir = moverDirection.getDirection(dir);
dir *= -1;
}
if (c.isSpinner()) { if (c.isSpinner()) {
double[] spinnerStartPoint = spinner.getPoint(); double[] spinnerStartPoint = spinner.getPoint();
c.start = new Vec2f((float) spinnerStartPoint[0], (float) spinnerStartPoint[1]); c.start = new Vec2f((float) spinnerStartPoint[0], (float) spinnerStartPoint[1]);

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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;
}
}