From 728b2ceb978d8b3f32ab40e475522e8958412ce3 Mon Sep 17 00:00:00 2001 From: yugecin Date: Tue, 27 Sep 2016 22:02:49 +0200 Subject: [PATCH] Add options in the ingame menu --- src/itdelatrisu/opsu/Options.java | 90 +++++++++++++++++++- src/itdelatrisu/opsu/states/OptionsMenu.java | 6 +- src/yugecin/opsudance/Dancer.java | 21 +++++ 3 files changed, 115 insertions(+), 2 deletions(-) diff --git a/src/itdelatrisu/opsu/Options.java b/src/itdelatrisu/opsu/Options.java index b62e811d..55c0e73f 100644 --- a/src/itdelatrisu/opsu/Options.java +++ b/src/itdelatrisu/opsu/Options.java @@ -54,6 +54,8 @@ import org.newdawn.slick.util.ResourceLoader; 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.movers.factories.AutoMoverFactory; /** * Handles all user options. @@ -538,9 +540,95 @@ public class Options { ENABLE_WATCH_SERVICE ("Enable Watch Service", "WatchService", "Watch the beatmap directory for changes. Requires a restart.", false), DANCE_MOVER ("Mover algorithm", "Mover", "Algorithm that decides how to move from note to note" ) { + @Override + public Object[] getListItems() { + return Dancer.moverFactories; + } + @Override + public void clickListItem(int index) { + Dancer.instance.setMoverFactoryIndex(index); + } + + @Override + public String getValueString() { + return Dancer.moverFactories[Dancer.instance.getMoverFactoryIndex()].toString(); + } + + @Override + public String write() { + return Dancer.instance.getMoverFactoryIndex() + ""; + } + + @Override + public void read(String s) { + Dancer.instance.setMoverFactoryIndex(Integer.parseInt(s)); + } + }, + + DANCE_SPINNER ("Spinner", "Spinner", "Spinner style") { + @Override + public Object[] getListItems() { + return Dancer.spinners; + } + + @Override + public void clickListItem(int index) { + Dancer.instance.setSpinnerIndex(index); + } + + @Override + public String getValueString() { + return Dancer.spinners[Dancer.instance.getSpinnerIndex()].toString(); + } + + @Override + public String write() { + return Dancer.instance.getSpinnerIndex() + ""; + } + + @Override + public void read(String s) { + Dancer.instance.setSpinnerIndex(Integer.parseInt(s)); + } + }, + + DANCE_LAZY_SLIDERS ("Lazy sliders", "LazySliders", "Don't do short sliders", true) { + @Override + public void click(GameContainer container) { + + } + }, + + DANCE_ONLY_CIRCLE_STACKS ("Only circle stacks", "CircleStacks", "Only do circle movement on stacks", true) { + @Override + public void click(GameContainer container) { + bool = !bool; + AutoMoverFactory.ONLY_CIRCLE_STACKS = bool; + } + + @Override + public void read(String s) { + super.read(s); + AutoMoverFactory.ONLY_CIRCLE_STACKS = bool; + } + }, + + DANCE_CIRCLE_STREAMS ("Circle streams", "CircleStreams", "Make circles while streaming", false) { + @Override + public void click(GameContainer container) { + bool = !bool; + AutoMoverFactory.CIRCLE_STREAM = bool ? 58 : 85; + } + + @Override + public void read(String s) { + super.read(s); + AutoMoverFactory.CIRCLE_STREAM = bool ? 58 : 85; + } }; + /** Option name. */ private final String name; @@ -690,7 +778,7 @@ public class Options { * Fired when an item in the value list has been clicked * @param index the itemindex which has been clicked */ - public void clickListItem(int index) { }; + public void clickListItem(int index) { } /** * Processes a mouse drag action (via override). diff --git a/src/itdelatrisu/opsu/states/OptionsMenu.java b/src/itdelatrisu/opsu/states/OptionsMenu.java index fd9ec7ad..85b2b320 100644 --- a/src/itdelatrisu/opsu/states/OptionsMenu.java +++ b/src/itdelatrisu/opsu/states/OptionsMenu.java @@ -105,7 +105,11 @@ public class OptionsMenu extends BasicGameState { GameOption.ENABLE_WATCH_SERVICE }), DANCE ("Dance", new GameOption[] { - GameOption.DANCE_MOVER + GameOption.DANCE_MOVER, + GameOption.DANCE_SPINNER, + GameOption.DANCE_LAZY_SLIDERS, + GameOption.DANCE_CIRCLE_STREAMS, + GameOption.DANCE_ONLY_CIRCLE_STACKS, }); /** Total number of tabs. */ diff --git a/src/yugecin/opsudance/Dancer.java b/src/yugecin/opsudance/Dancer.java index b02a9f2f..02104a1a 100644 --- a/src/yugecin/opsudance/Dancer.java +++ b/src/yugecin/opsudance/Dancer.java @@ -56,6 +56,9 @@ public class Dancer { private Mover mover; private Spinner spinner; + private int moverFactoryIndex; + private int spinnerIndex; + public float x; public float y; @@ -73,6 +76,24 @@ public class Dancer { } } + public int getSpinnerIndex() { + return spinnerIndex; + } + + public void setSpinnerIndex(int spinnerIndex) { + this.spinnerIndex = spinnerIndex; + spinner = spinners[spinnerIndex]; + } + + public int getMoverFactoryIndex() { + return moverFactoryIndex; + } + + public void setMoverFactoryIndex(int moverFactoryIndex) { + this.moverFactoryIndex = moverFactoryIndex; + moverFactory = moverFactories[moverFactoryIndex]; + } + public void update(int time, GameObject p, GameObject c) { if (this.p != p) { this.p = p;