Option to apply last object color to cursor

This commit is contained in:
yugecin 2016-09-30 19:38:02 +02:00
parent add5e96af1
commit f6b791cf25
10 changed files with 99 additions and 10 deletions

View File

@ -694,7 +694,7 @@ public class Options {
}
},
DANCE_OBJECT_COLOR_OVERRIDE_MIRRORED ("Object color override", "ObjColorOverride", "Override object colors") {
DANCE_OBJECT_COLOR_OVERRIDE_MIRRORED ("Collage object color override", "ObjColorMirroredOverride", "Override collage object colors") {
@Override
public String getValueString() {
return Dancer.colorMirrorOverride.toString();
@ -740,6 +740,20 @@ 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", false) {
@Override
public void click(GameContainer container) {
bool = !bool;
Dancer.cursoruselastobjectcolor = bool;
}
@Override
public void read(String s) {
super.read(s);
Dancer.cursoruselastobjectcolor = bool;
}
},
DANCE_REMOVE_BG ("Never draw background", "RemoveBG", "Hello darkness my old friend", true) {
@Override
public void click(GameContainer container) {

View File

@ -240,4 +240,14 @@ public class Circle extends GameObject {
return false;
}
@Override
public Color getColor() {
return color;
}
@Override
public Color getMirroredColor() {
return mirrorColor;
}
}

View File

@ -21,6 +21,7 @@ package itdelatrisu.opsu.objects;
import itdelatrisu.opsu.beatmap.HitObject;
import itdelatrisu.opsu.objects.curves.Vec2f;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
/**
@ -83,4 +84,14 @@ public class DummyObject extends GameObject {
return false;
}
@Override
public Color getColor() {
return null;
}
@Override
public Color getMirroredColor() {
return null;
}
}

View File

@ -20,6 +20,7 @@ package itdelatrisu.opsu.objects;
import itdelatrisu.opsu.objects.curves.Vec2f;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
/**
@ -97,4 +98,7 @@ public abstract class GameObject {
public abstract boolean isSlider();
public abstract boolean isSpinner();
public abstract Color getColor();
public abstract Color getMirroredColor();
}

View File

@ -650,4 +650,14 @@ public class Slider extends GameObject {
return false;
}
@Override
public Color getColor() {
return color;
}
@Override
public Color getMirroredColor() {
return mirrorColor;
}
}

View File

@ -428,4 +428,14 @@ public class Spinner extends GameObject {
return true;
}
@Override
public Color getColor() {
return null;
}
@Override
public Color getMirroredColor() {
return null;
}
}

View File

@ -271,7 +271,7 @@ public class Game extends BasicGameState {
public Game(int state) {
this.state = state;
mirrorCursor = new Cursor();
mirrorCursor = new Cursor(true);
}
@Override
@ -876,6 +876,11 @@ public class Game extends BasicGameState {
break;
}
}
GameObject g = gameObjects[objectIndex];
if (g.isCircle() || g.isSlider() && g.getTime() <= trackPosition) {
Cursor.lastObjColor = g.getColor();
Cursor.lastMirroredObjColor = g.getMirroredColor();
}
}
@Override
@ -1308,6 +1313,9 @@ public class Game extends BasicGameState {
throws SlickException {
// container.setMouseGrabbed(false);
Cursor.lastObjColor = Color.white;
Cursor.lastMirroredObjColor = Color.white;
// re-hide cursor
if (GameMod.AUTO.isActive() || isReplay)
UI.getCursor().hide();

View File

@ -115,6 +115,7 @@ public class OptionsMenu extends BasicGameState {
GameOption.DANCE_OBJECT_COLOR_OVERRIDE,
GameOption.DANCE_OBJECT_COLOR_OVERRIDE_MIRRORED,
GameOption.DANCE_RGB_INC,
GameOption.DANCE_CURSOR_USE_OBJECT_COLOR,
GameOption.DANCE_REMOVE_BG,
GameOption.DANCE_HIDE_UI,
}),

View File

@ -32,11 +32,9 @@ import java.util.LinkedList;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.*;
import org.newdawn.slick.state.StateBasedGame;
import yugecin.opsudance.Dancer;
/**
* Updates and draws the cursor.
@ -49,7 +47,7 @@ public class Cursor {
private Point lastPosition;
/** Cursor rotation angle. */
private float cursorAngle = 0f;
private static float cursorAngle = 0f;
/** The time in milliseconds when the cursor was last pressed, used for the scaling animation. */
private long lastCursorPressTime = 0L;
@ -71,6 +69,11 @@ public class Cursor {
private static StateBasedGame game;
private static Input input;
public static Color lastObjColor = Color.white;
public static Color lastMirroredObjColor = Color.white;
private boolean isMirrored;
/**
* Initializes the class.
* @param container the game container
@ -95,7 +98,12 @@ public class Cursor {
* Constructor.
*/
public Cursor() {
this(false);
}
public Cursor(boolean isMirrored) {
resetLocations();
this.isMirrored = isMirrored;
}
/**
@ -182,6 +190,8 @@ public class Cursor {
for (int i = 0; i < removeCount && !trail.isEmpty(); i++)
trail.remove();
Color filter = getColorFilter();
// draw a fading trail
float alpha = 0f;
float t = 2f / trail.size();
@ -190,7 +200,7 @@ public class Cursor {
cursorTrail.startUse();
for (Point p : trail) {
alpha += t;
cursorTrail.setImageColor(1f, 1f, 1f, alpha);
cursorTrail.setImageColor(filter.r, filter.g, filter.b, alpha);
cursorTrail.drawEmbedded(
p.x - (cursorTrailWidth / 2f), p.y - (cursorTrailHeight / 2f),
cursorTrailWidth, cursorTrailHeight, cursorTrailRotation);
@ -203,9 +213,19 @@ public class Cursor {
// draw the other components
if (newStyle && skin.isCursorRotated())
cursor.setRotation(cursorAngle);
cursor.drawCentered(mouseX, mouseY);
cursor.drawCentered(mouseX, mouseY, filter);
if (hasMiddle)
cursorMiddle.drawCentered(mouseX, mouseY);
cursorMiddle.drawCentered(mouseX, mouseY, filter);
}
private Color getColorFilter() {
if (!Dancer.cursoruselastobjectcolor) {
return Color.white;
}
if (isMirrored) {
return lastMirroredObjColor;
}
return lastObjColor;
}
/**

View File

@ -57,6 +57,7 @@ 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;
private int dir;
private GameObject p;