diff --git a/src/itdelatrisu/opsu/Options.java b/src/itdelatrisu/opsu/Options.java index f9009224..ce2b5f45 100644 --- a/src/itdelatrisu/opsu/Options.java +++ b/src/itdelatrisu/opsu/Options.java @@ -54,10 +54,7 @@ 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.MoverDirection; -import yugecin.opsudance.ObjectColorOverrides; -import yugecin.opsudance.Pippi; +import yugecin.opsudance.*; import yugecin.opsudance.movers.factories.AutoMoverFactory; /** @@ -759,7 +756,61 @@ public class Options { } }, - DANCE_RGB_INC ("RGB objects increment", "RGBInc", "Amount of hue to shift, used for rainbow object color override", Dancer.rgbhueinc, -1800, 1800) { + DANCE_CURSOR_COLOR_OVERRIDE ("Cursor color override", "CursorColorOverride", "Override cursor color") { + @Override + public String getValueString() { + return Dancer.cursorColorOverride.toString(); + } + + @Override + public Object[] getListItems() { + return CursorColorOverrides.values(); + } + + @Override + public void clickListItem(int index) { + Dancer.cursorColorOverride = CursorColorOverrides.values()[index]; + } + + @Override + public String write() { + return "" + Dancer.cursorColorOverride.nr; + } + + @Override + public void read(String s) { + Dancer.cursorColorOverride = CursorColorOverrides.values()[Integer.parseInt(s)]; + } + }, + + DANCE_CURSOR_MIRROR_COLOR_OVERRIDE ("Cursor mirror color override", "CursorMirrorColorOverride", "Override mirror cursor color") { + @Override + public String getValueString() { + return Dancer.cursorColorMirrorOverride.toString(); + } + + @Override + public Object[] getListItems() { + return CursorColorOverrides.values(); + } + + @Override + public void clickListItem(int index) { + Dancer.cursorColorMirrorOverride = CursorColorOverrides.values()[index]; + } + + @Override + public String write() { + return "" + Dancer.cursorColorMirrorOverride.nr; + } + + @Override + public void read(String s) { + Dancer.cursorColorMirrorOverride = CursorColorOverrides.values()[Integer.parseInt(s)]; + } + }, + + DANCE_RGB_INC ("RGB objects increment", "RGBInc", "Amount of hue to shift, used for rainbow color override", Dancer.rgbhueinc, -1800, 1800) { @Override public String getValueString() { return String.format("%.1f°", val / 10f); @@ -778,19 +829,6 @@ public class Options { } }, - DANCE_CURSOR_USE_OBJECT_COLOR ("Give object color to cursor", "CursorUseObjectColor", "The color of the last object will be used on the cursor", Dancer.cursoruselastobjectcolor) { - @Override - public void click(GameContainer container) { - bool = !bool; - Dancer.cursoruselastobjectcolor = bool; - } - - @Override - public void read(String s) { - super.read(s); - Dancer.cursoruselastobjectcolor = bool; - } - }, DANCE_HIDE_OBJECTS ("Don't draw objects", "HideObj", "If you only want to see cursors :)", Dancer.hideobjects) { @Override diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index 563a798f..f6374db2 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -70,10 +70,7 @@ import org.newdawn.slick.state.transition.DelayedFadeOutTransition; 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; -import yugecin.opsudance.Pippi; +import yugecin.opsudance.*; /** * "Game" state. @@ -1218,7 +1215,7 @@ public class Game extends BasicGameState { } // initialize object maps - ObjectColorOverrides.comboColors = beatmap.getComboColors(); + CursorColorOverrides.comboColors = ObjectColorOverrides.comboColors = beatmap.getComboColors(); ObjectColorOverrides.hue = 0f; for (int i = 0; i < beatmap.objects.length; i++) { HitObject hitObject = beatmap.objects[i]; diff --git a/src/itdelatrisu/opsu/states/OptionsMenu.java b/src/itdelatrisu/opsu/states/OptionsMenu.java index 81528478..e1bb31ba 100644 --- a/src/itdelatrisu/opsu/states/OptionsMenu.java +++ b/src/itdelatrisu/opsu/states/OptionsMenu.java @@ -118,8 +118,9 @@ public class OptionsMenu extends BasicGameState { GameOption.DANCE_DRAW_APPROACH, GameOption.DANCE_OBJECT_COLOR_OVERRIDE, GameOption.DANCE_OBJECT_COLOR_OVERRIDE_MIRRORED, + GameOption.DANCE_CURSOR_COLOR_OVERRIDE, + GameOption.DANCE_CURSOR_MIRROR_COLOR_OVERRIDE, GameOption.DANCE_RGB_INC, - GameOption.DANCE_CURSOR_USE_OBJECT_COLOR, GameOption.DANCE_REMOVE_BG, GameOption.DANCE_HIDE_OBJECTS, GameOption.DANCE_HIDE_UI, diff --git a/src/itdelatrisu/opsu/ui/Cursor.java b/src/itdelatrisu/opsu/ui/Cursor.java index e9b7562f..dacc3f31 100644 --- a/src/itdelatrisu/opsu/ui/Cursor.java +++ b/src/itdelatrisu/opsu/ui/Cursor.java @@ -190,7 +190,12 @@ public class Cursor { for (int i = 0; i < removeCount && !trail.isEmpty(); i++) trail.remove(); - Color filter = getColorFilter(); + Color filter; + if (isMirrored) { + filter = Dancer.cursorColorMirrorOverride.getMirrorColor(); + } else { + filter = Dancer.cursorColorOverride.getColor(); + } // draw a fading trail float alpha = 0f; @@ -218,16 +223,6 @@ public class Cursor { cursorMiddle.drawCentered(mouseX, mouseY, filter); } - private Color getColorFilter() { - if (!Dancer.cursoruselastobjectcolor) { - return Color.white; - } - if (isMirrored) { - return lastMirroredObjColor; - } - return lastObjColor; - } - /** * Adds all points between (x1, y1) and (x2, y2) to the cursor point lists. * @author http://rosettacode.org/wiki/Bitmap/Bresenham's_line_algorithm#Java diff --git a/src/yugecin/opsudance/CursorColorOverrides.java b/src/yugecin/opsudance/CursorColorOverrides.java new file mode 100644 index 00000000..6a845186 --- /dev/null +++ b/src/yugecin/opsudance/CursorColorOverrides.java @@ -0,0 +1,108 @@ +/* + * 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 itdelatrisu.opsu.ui.Cursor; +import org.newdawn.slick.Color; + +public enum CursorColorOverrides { + + NONE ("None", 0) { + @Override + public Color getColor(boolean mirrored) { + return Color.white; + } + }, + COMBO1 ("Combo1", 1), + COMBO2 ("Combo2", 2), + COMBO3 ("Combo3", 3), + COMBO4 ("Combo4", 4), + COMBO5 ("Combo5", 5), + COMBO6 ("Combo6", 6), + COMBO7 ("Combo7", 7), + COMBO8 ("Combo8", 8), + RAINBOW ("Rainbow", 10) { + @Override + public Color getColor(boolean mirrored) { + return nextRainbowColor(); + } + }, + RAINBOWSHIFT ("Rainbow + 180° hue shift", 11) { + @Override + public Color getColor(boolean mirrored) { + return nextMirrorRainbowColor(); + } + }, + BLACK ("Black", 12) { + @Override + public Color getColor(boolean mirrored) { + return Color.black; + } + }, + LASTOBJ ("Use last object's colors", 13) { + @Override + public Color getColor(boolean mirrored) { + if (mirrored) { + return Cursor.lastMirroredObjColor; + } + return Cursor.lastObjColor; + } + }; + + public int nr; + private String displayText; + + public static Color[] comboColors; + + public static float hue; + + CursorColorOverrides(String displayText, int nr) { + this.displayText = displayText; + this.nr = nr; + } + + @Override + public String toString() { + return displayText; + } + + public Color getColor(boolean mirrored) { + if (comboColors == null || comboColors.length == 0) { + return Color.white; + } + return comboColors[nr % comboColors.length]; + } + + public Color getColor() { + return getColor(false); + } + + public Color getMirrorColor() { + return getColor(true); + } + + private static Color nextRainbowColor() { + hue += Dancer.rgbhueinc / 10f; + return new Color(java.awt.Color.getHSBColor(hue / 360f, 1.0f, 1.0f).getRGB()); + } + + private static Color nextMirrorRainbowColor() { + return new Color(java.awt.Color.getHSBColor((hue + 180f) / 360f, 1.0f, 1.0f).getRGB()); + } + +} diff --git a/src/yugecin/opsudance/Dancer.java b/src/yugecin/opsudance/Dancer.java index 021c9476..5a1f308d 100644 --- a/src/yugecin/opsudance/Dancer.java +++ b/src/yugecin/opsudance/Dancer.java @@ -63,7 +63,8 @@ public class Dancer { public static ObjectColorOverrides colorOverride = ObjectColorOverrides.NONE; public static ObjectColorOverrides colorMirrorOverride = ObjectColorOverrides.NONE; public static int rgbhueinc = 70; // this should really get its own place somewhere... - public static boolean cursoruselastobjectcolor = false; + public static CursorColorOverrides cursorColorOverride = CursorColorOverrides.NONE; + public static CursorColorOverrides cursorColorMirrorOverride = CursorColorOverrides.NONE; public static MoverDirection moverDirection = MoverDirection.RANDOM; public static boolean hideobjects = false;