add cursor color overrides

This commit is contained in:
yugecin 2016-10-01 11:53:33 +02:00
parent f313a1639f
commit 652bb4f2d0
6 changed files with 176 additions and 36 deletions

View File

@ -54,10 +54,7 @@ import org.newdawn.slick.util.ResourceLoader;
import com.sun.jna.platform.win32.Advapi32Util; 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.*;
import yugecin.opsudance.MoverDirection;
import yugecin.opsudance.ObjectColorOverrides;
import yugecin.opsudance.Pippi;
import yugecin.opsudance.movers.factories.AutoMoverFactory; 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 @Override
public String getValueString() { public String getValueString() {
return String.format("%.1f°", val / 10f); 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) { DANCE_HIDE_OBJECTS ("Don't draw objects", "HideObj", "If you only want to see cursors :)", Dancer.hideobjects) {
@Override @Override

View File

@ -70,10 +70,7 @@ import org.newdawn.slick.state.transition.DelayedFadeOutTransition;
import org.newdawn.slick.state.transition.EasedFadeOutTransition; 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.*;
import yugecin.opsudance.MoverDirection;
import yugecin.opsudance.ObjectColorOverrides;
import yugecin.opsudance.Pippi;
/** /**
* "Game" state. * "Game" state.
@ -1218,7 +1215,7 @@ public class Game extends BasicGameState {
} }
// initialize object maps // initialize object maps
ObjectColorOverrides.comboColors = beatmap.getComboColors(); CursorColorOverrides.comboColors = ObjectColorOverrides.comboColors = beatmap.getComboColors();
ObjectColorOverrides.hue = 0f; ObjectColorOverrides.hue = 0f;
for (int i = 0; i < beatmap.objects.length; i++) { for (int i = 0; i < beatmap.objects.length; i++) {
HitObject hitObject = beatmap.objects[i]; HitObject hitObject = beatmap.objects[i];

View File

@ -118,8 +118,9 @@ public class OptionsMenu extends BasicGameState {
GameOption.DANCE_DRAW_APPROACH, GameOption.DANCE_DRAW_APPROACH,
GameOption.DANCE_OBJECT_COLOR_OVERRIDE, GameOption.DANCE_OBJECT_COLOR_OVERRIDE,
GameOption.DANCE_OBJECT_COLOR_OVERRIDE_MIRRORED, GameOption.DANCE_OBJECT_COLOR_OVERRIDE_MIRRORED,
GameOption.DANCE_CURSOR_COLOR_OVERRIDE,
GameOption.DANCE_CURSOR_MIRROR_COLOR_OVERRIDE,
GameOption.DANCE_RGB_INC, GameOption.DANCE_RGB_INC,
GameOption.DANCE_CURSOR_USE_OBJECT_COLOR,
GameOption.DANCE_REMOVE_BG, GameOption.DANCE_REMOVE_BG,
GameOption.DANCE_HIDE_OBJECTS, GameOption.DANCE_HIDE_OBJECTS,
GameOption.DANCE_HIDE_UI, GameOption.DANCE_HIDE_UI,

View File

@ -190,7 +190,12 @@ public class Cursor {
for (int i = 0; i < removeCount && !trail.isEmpty(); i++) for (int i = 0; i < removeCount && !trail.isEmpty(); i++)
trail.remove(); trail.remove();
Color filter = getColorFilter(); Color filter;
if (isMirrored) {
filter = Dancer.cursorColorMirrorOverride.getMirrorColor();
} else {
filter = Dancer.cursorColorOverride.getColor();
}
// draw a fading trail // draw a fading trail
float alpha = 0f; float alpha = 0f;
@ -218,16 +223,6 @@ public class Cursor {
cursorMiddle.drawCentered(mouseX, mouseY, filter); 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. * 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 * @author http://rosettacode.org/wiki/Bitmap/Bresenham's_line_algorithm#Java

View File

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

View File

@ -63,7 +63,8 @@ public class Dancer {
public static ObjectColorOverrides colorOverride = ObjectColorOverrides.NONE; public static ObjectColorOverrides colorOverride = ObjectColorOverrides.NONE;
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 = false; public static CursorColorOverrides cursorColorOverride = CursorColorOverrides.NONE;
public static CursorColorOverrides cursorColorMirrorOverride = CursorColorOverrides.NONE;
public static MoverDirection moverDirection = MoverDirection.RANDOM; public static MoverDirection moverDirection = MoverDirection.RANDOM;
public static boolean hideobjects = false; public static boolean hideobjects = false;