put common hitcircle render code in separate class
This commit is contained in:
parent
c3e6826464
commit
2e3a782fdc
|
@ -20,7 +20,6 @@ package itdelatrisu.opsu.objects;
|
||||||
|
|
||||||
import itdelatrisu.opsu.GameData;
|
import itdelatrisu.opsu.GameData;
|
||||||
import itdelatrisu.opsu.GameData.HitObjectType;
|
import itdelatrisu.opsu.GameData.HitObjectType;
|
||||||
import itdelatrisu.opsu.GameImage;
|
|
||||||
import itdelatrisu.opsu.GameMod;
|
import itdelatrisu.opsu.GameMod;
|
||||||
import itdelatrisu.opsu.Options;
|
import itdelatrisu.opsu.Options;
|
||||||
import itdelatrisu.opsu.Utils;
|
import itdelatrisu.opsu.Utils;
|
||||||
|
@ -30,16 +29,18 @@ import itdelatrisu.opsu.states.Game;
|
||||||
import itdelatrisu.opsu.ui.Colors;
|
import itdelatrisu.opsu.ui.Colors;
|
||||||
|
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.GameContainer;
|
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
import yugecin.opsudance.Dancer;
|
import yugecin.opsudance.Dancer;
|
||||||
|
import yugecin.opsudance.core.inject.Inject;
|
||||||
|
import yugecin.opsudance.render.GameObjectRenderer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data type representing a circle object.
|
* Data type representing a circle object.
|
||||||
*/
|
*/
|
||||||
public class Circle extends GameObject {
|
public class Circle extends GameObject {
|
||||||
/** The diameter of hit circles. */
|
|
||||||
public static float diameter;
|
@Inject
|
||||||
|
private GameObjectRenderer gameObjectRenderer;
|
||||||
|
|
||||||
/** The associated HitObject. */
|
/** The associated HitObject. */
|
||||||
private HitObject hitObject;
|
private HitObject hitObject;
|
||||||
|
@ -62,18 +63,6 @@ public class Circle extends GameObject {
|
||||||
|
|
||||||
private int comboColorIndex;
|
private int comboColorIndex;
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the Circle data type with map modifiers, images, and dimensions.
|
|
||||||
* @param circleDiameter the circle diameter
|
|
||||||
*/
|
|
||||||
public static void init(float circleDiameter) {
|
|
||||||
diameter = circleDiameter * HitObject.getXMultiplier(); // convert from Osupixels (640x480)
|
|
||||||
int diameterInt = (int) diameter;
|
|
||||||
GameImage.HITCIRCLE.setImage(GameImage.HITCIRCLE.getImage().getScaledCopy(diameterInt, diameterInt));
|
|
||||||
GameImage.HITCIRCLE_OVERLAY.setImage(GameImage.HITCIRCLE_OVERLAY.getImage().getScaledCopy(diameterInt, diameterInt));
|
|
||||||
GameImage.APPROACHCIRCLE.setImage(GameImage.APPROACHCIRCLE.getImage().getScaledCopy(diameterInt, diameterInt));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
* @param hitObject the associated HitObject
|
* @param hitObject the associated HitObject
|
||||||
|
@ -129,16 +118,10 @@ public class Circle extends GameObject {
|
||||||
float oldAlpha = Colors.WHITE_FADE.a;
|
float oldAlpha = Colors.WHITE_FADE.a;
|
||||||
Colors.WHITE_FADE.a = color.a = alpha;
|
Colors.WHITE_FADE.a = color.a = alpha;
|
||||||
|
|
||||||
if (timeDiff >= 0 && !GameMod.HIDDEN.isActive() && Options.isDrawApproach())
|
if (timeDiff >= 0) {
|
||||||
GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale).drawCentered(x, y, color);
|
gameObjectRenderer.renderApproachCircle(x, y, color, approachScale);
|
||||||
GameImage.HITCIRCLE.getImage().drawCentered(x, y, color);
|
}
|
||||||
boolean overlayAboveNumber = Options.getSkin().isHitCircleOverlayAboveNumber();
|
gameObjectRenderer.renderHitCircle(x, y, color, hitObject.getComboNumber(), alpha);
|
||||||
if (!overlayAboveNumber)
|
|
||||||
GameImage.HITCIRCLE_OVERLAY.getImage().drawCentered(x, y, Colors.WHITE_FADE);
|
|
||||||
data.drawSymbolNumber(hitObject.getComboNumber(), x, y,
|
|
||||||
GameImage.HITCIRCLE.getImage().getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight(), alpha);
|
|
||||||
if (overlayAboveNumber)
|
|
||||||
GameImage.HITCIRCLE_OVERLAY.getImage().drawCentered(x, y, Colors.WHITE_FADE);
|
|
||||||
|
|
||||||
Colors.WHITE_FADE.a = oldAlpha;
|
Colors.WHITE_FADE.a = oldAlpha;
|
||||||
|
|
||||||
|
@ -172,7 +155,7 @@ public class Circle extends GameObject {
|
||||||
@Override
|
@Override
|
||||||
public boolean mousePressed(int x, int y, int trackPosition) {
|
public boolean mousePressed(int x, int y, int trackPosition) {
|
||||||
double distance = Math.hypot(this.x - x, this.y - y);
|
double distance = Math.hypot(this.x - x, this.y - y);
|
||||||
if (distance < diameter / 2) {
|
if (distance < gameObjectRenderer.getCircleDiameter() / 2) {
|
||||||
int timeDiff = trackPosition - hitObject.getTime();
|
int timeDiff = trackPosition - hitObject.getTime();
|
||||||
int result = hitResult(timeDiff);
|
int result = hitResult(timeDiff);
|
||||||
|
|
||||||
|
|
|
@ -37,11 +37,20 @@ import org.newdawn.slick.Graphics;
|
||||||
import org.newdawn.slick.Image;
|
import org.newdawn.slick.Image;
|
||||||
import yugecin.opsudance.Dancer;
|
import yugecin.opsudance.Dancer;
|
||||||
import yugecin.opsudance.core.DisplayContainer;
|
import yugecin.opsudance.core.DisplayContainer;
|
||||||
|
import yugecin.opsudance.core.inject.Inject;
|
||||||
|
import yugecin.opsudance.render.GameObjectRenderer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data type representing a slider object.
|
* Data type representing a slider object.
|
||||||
*/
|
*/
|
||||||
public class Slider extends GameObject {
|
public class Slider extends GameObject {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private DisplayContainer displayContainer;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private GameObjectRenderer gameObjectRenderer;
|
||||||
|
|
||||||
/** Slider ball frames. */
|
/** Slider ball frames. */
|
||||||
private static Image[] sliderBallImages;
|
private static Image[] sliderBallImages;
|
||||||
|
|
||||||
|
@ -54,9 +63,6 @@ public class Slider extends GameObject {
|
||||||
/** Follow circle radius. */
|
/** Follow circle radius. */
|
||||||
private static float followRadius;
|
private static float followRadius;
|
||||||
|
|
||||||
/** The diameter of hit circles. */
|
|
||||||
private static float diameter;
|
|
||||||
|
|
||||||
/** The associated HitObject. */
|
/** The associated HitObject. */
|
||||||
private HitObject hitObject;
|
private HitObject hitObject;
|
||||||
|
|
||||||
|
@ -116,9 +122,6 @@ public class Slider extends GameObject {
|
||||||
private static final int FOLLOW_EXPAND_TIME = 150;
|
private static final int FOLLOW_EXPAND_TIME = 150;
|
||||||
private static final int FOLLOW_SHRINK_TIME = 100;
|
private static final int FOLLOW_SHRINK_TIME = 100;
|
||||||
|
|
||||||
/** Container dimensions. */
|
|
||||||
private static int containerWidth, containerHeight;
|
|
||||||
|
|
||||||
private int repeats;
|
private int repeats;
|
||||||
|
|
||||||
private static Color curveColor = new Color(0, 0, 0, 20);
|
private static Color curveColor = new Color(0, 0, 0, 20);
|
||||||
|
@ -134,14 +137,9 @@ public class Slider extends GameObject {
|
||||||
* @param circleDiameter the circle diameter
|
* @param circleDiameter the circle diameter
|
||||||
* @param beatmap the associated beatmap
|
* @param beatmap the associated beatmap
|
||||||
*/
|
*/
|
||||||
public static void init(DisplayContainer displayContainer, float circleDiameter, Beatmap beatmap) {
|
public static void init(float circleDiameter, Beatmap beatmap) {
|
||||||
containerWidth = displayContainer.width;
|
followRadius = circleDiameter / 2 * 3f;
|
||||||
containerHeight = displayContainer.height;
|
int diameterInt = (int) circleDiameter;
|
||||||
|
|
||||||
diameter = circleDiameter * HitObject.getXMultiplier(); // convert from Osupixels (640x480)
|
|
||||||
int diameterInt = (int) diameter;
|
|
||||||
|
|
||||||
followRadius = diameter / 2 * 3f;
|
|
||||||
|
|
||||||
// slider ball
|
// slider ball
|
||||||
if (GameImage.SLIDER_BALL.hasBeatmapSkinImages() ||
|
if (GameImage.SLIDER_BALL.hasBeatmapSkinImages() ||
|
||||||
|
@ -219,8 +217,6 @@ public class Slider extends GameObject {
|
||||||
boolean overlayAboveNumber = Options.getSkin().isHitCircleOverlayAboveNumber();
|
boolean overlayAboveNumber = Options.getSkin().isHitCircleOverlayAboveNumber();
|
||||||
float oldAlpha = Colors.WHITE_FADE.a;
|
float oldAlpha = Colors.WHITE_FADE.a;
|
||||||
Colors.WHITE_FADE.a = color.a = alpha;
|
Colors.WHITE_FADE.a = color.a = alpha;
|
||||||
Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage();
|
|
||||||
Image hitCircle = GameImage.HITCIRCLE.getImage();
|
|
||||||
Vec2f endPos = curve.pointAt(1);
|
Vec2f endPos = curve.pointAt(1);
|
||||||
|
|
||||||
float oldWhiteFadeAlpha = Colors.WHITE_FADE.a;
|
float oldWhiteFadeAlpha = Colors.WHITE_FADE.a;
|
||||||
|
@ -249,8 +245,8 @@ public class Slider extends GameObject {
|
||||||
circleColor.a = overlayColor.a = sliderAlpha * getCircleAlphaAfterRepeat(trackPosition, true);
|
circleColor.a = overlayColor.a = sliderAlpha * getCircleAlphaAfterRepeat(trackPosition, true);
|
||||||
}
|
}
|
||||||
Vec2f endCircPos = curve.pointAt(1f);
|
Vec2f endCircPos = curve.pointAt(1f);
|
||||||
hitCircle.drawCentered(endCircPos.x, endCircPos.y, circleColor);
|
gameObjectRenderer.renderHitCircleOnly(endCircPos.x, endCircPos.y, circleColor);
|
||||||
hitCircleOverlay.drawCentered(endCircPos.x, endCircPos.y, overlayColor);
|
gameObjectRenderer.renderHitCircleOverlayOnly(endCircPos.x, endCircPos.y, overlayColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
g.pushTransform();
|
g.pushTransform();
|
||||||
|
@ -268,9 +264,10 @@ public class Slider extends GameObject {
|
||||||
|
|
||||||
// start circle, only draw if ball still has to go there
|
// start circle, only draw if ball still has to go there
|
||||||
if (!sliderClickedInitial || (Options.isDrawSliderEndCircles() && currentRepeats < repeatCount - (repeatCount % 2 == 1 ? 1 : 0))) {
|
if (!sliderClickedInitial || (Options.isDrawSliderEndCircles() && currentRepeats < repeatCount - (repeatCount % 2 == 1 ? 1 : 0))) {
|
||||||
hitCircle.drawCentered(x, y, firstCircleColor);
|
gameObjectRenderer.renderHitCircleOnly(x, y, firstCircleColor);
|
||||||
if (!overlayAboveNumber || sliderClickedInitial)
|
if (!overlayAboveNumber || sliderClickedInitial) {
|
||||||
hitCircleOverlay.drawCentered(x, y, startCircleOverlayColor);
|
gameObjectRenderer.renderHitCircleOverlayOnly(x, y, startCircleOverlayColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g.popTransform();
|
g.popTransform();
|
||||||
|
@ -297,12 +294,11 @@ public class Slider extends GameObject {
|
||||||
|
|
||||||
// draw combo number and overlay if not initially clicked
|
// draw combo number and overlay if not initially clicked
|
||||||
if (!sliderClickedInitial) {
|
if (!sliderClickedInitial) {
|
||||||
data.drawSymbolNumber(hitObject.getComboNumber(), x, y,
|
gameObjectRenderer.renderComboNumberOnly(x, y, hitObject.getComboNumber(), alpha);
|
||||||
hitCircle.getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight(), alpha);
|
|
||||||
|
|
||||||
if (overlayAboveNumber) {
|
if (overlayAboveNumber) {
|
||||||
startCircleOverlayColor.a = sliderAlpha;
|
startCircleOverlayColor.a = sliderAlpha;
|
||||||
hitCircleOverlay.drawCentered(x, y, startCircleOverlayColor);
|
gameObjectRenderer.renderHitCircleOverlayOnly(x, y, startCircleOverlayColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,7 +336,7 @@ public class Slider extends GameObject {
|
||||||
g.rotate(x, y, -180f);
|
g.rotate(x, y, -180f);
|
||||||
}
|
}
|
||||||
if (!GameMod.HIDDEN.isActive() && Options.isDrawApproach()) {
|
if (!GameMod.HIDDEN.isActive() && Options.isDrawApproach()) {
|
||||||
GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale).drawCentered(x, y, color);
|
gameObjectRenderer.renderApproachCircle(x, y, color, approachScale);
|
||||||
}
|
}
|
||||||
g.popTransform();
|
g.popTransform();
|
||||||
} else {
|
} else {
|
||||||
|
@ -394,7 +390,7 @@ public class Slider extends GameObject {
|
||||||
float oldAlphaBlack = Colors.BLACK_ALPHA.a;
|
float oldAlphaBlack = Colors.BLACK_ALPHA.a;
|
||||||
Colors.BLACK_ALPHA.a = 0.75f;
|
Colors.BLACK_ALPHA.a = 0.75f;
|
||||||
g.setColor(Colors.BLACK_ALPHA);
|
g.setColor(Colors.BLACK_ALPHA);
|
||||||
g.fillRect(0, 0, containerWidth, containerHeight);
|
g.fillRect(0, 0, displayContainer.width, displayContainer.height);
|
||||||
Colors.BLACK_ALPHA.a = oldAlphaBlack;
|
Colors.BLACK_ALPHA.a = oldAlphaBlack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -606,7 +602,7 @@ public class Slider extends GameObject {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
double distance = Math.hypot(this.x - x, this.y - y);
|
double distance = Math.hypot(this.x - x, this.y - y);
|
||||||
if (distance < diameter / 2) {
|
if (distance < gameObjectRenderer.getCircleDiameter() / 2) {
|
||||||
int timeDiff = Math.abs(trackPosition - hitObject.getTime());
|
int timeDiff = Math.abs(trackPosition - hitObject.getTime());
|
||||||
int[] hitResultOffset = game.getHitResultOffsets();
|
int[] hitResultOffset = game.getHitResultOffsets();
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ import itdelatrisu.opsu.GameImage;
|
||||||
import itdelatrisu.opsu.Options;
|
import itdelatrisu.opsu.Options;
|
||||||
import itdelatrisu.opsu.Utils;
|
import itdelatrisu.opsu.Utils;
|
||||||
import itdelatrisu.opsu.beatmap.HitObject;
|
import itdelatrisu.opsu.beatmap.HitObject;
|
||||||
import itdelatrisu.opsu.objects.Circle;
|
|
||||||
import itdelatrisu.opsu.objects.curves.Vec2f;
|
import itdelatrisu.opsu.objects.curves.Vec2f;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
@ -37,6 +36,7 @@ import org.lwjgl.opengl.GL20;
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.Image;
|
import org.newdawn.slick.Image;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
|
import yugecin.opsudance.render.GameObjectRenderer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hold the temporary render state that needs to be restored again after the new
|
* Hold the temporary render state that needs to be restored again after the new
|
||||||
|
@ -303,7 +303,7 @@ public class CurveRenderState {
|
||||||
double diff_x = x - last_x;
|
double diff_x = x - last_x;
|
||||||
double diff_y = y - last_y;
|
double diff_y = y - last_y;
|
||||||
float dist = Utils.distance(x, y, last_x, last_y);
|
float dist = Utils.distance(x, y, last_x, last_y);
|
||||||
if (dist < Circle.diameter / 8) {
|
if (dist < GameObjectRenderer.instance.getCircleDiameter() / 8) {
|
||||||
x = (float) (x - diff_x / 2);
|
x = (float) (x - diff_x / 2);
|
||||||
y = (float) (y - diff_y / 2);
|
y = (float) (y - diff_y / 2);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -73,6 +73,7 @@ import yugecin.opsudance.core.state.transitions.FadeOutTransitionState;
|
||||||
import yugecin.opsudance.events.BarNotificationEvent;
|
import yugecin.opsudance.events.BarNotificationEvent;
|
||||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
import yugecin.opsudance.events.BubbleNotificationEvent;
|
||||||
import yugecin.opsudance.objects.curves.FakeCombinedCurve;
|
import yugecin.opsudance.objects.curves.FakeCombinedCurve;
|
||||||
|
import yugecin.opsudance.render.GameObjectRenderer;
|
||||||
import yugecin.opsudance.sbv2.MoveStoryboard;
|
import yugecin.opsudance.sbv2.MoveStoryboard;
|
||||||
import yugecin.opsudance.ui.OptionsOverlay;
|
import yugecin.opsudance.ui.OptionsOverlay;
|
||||||
import yugecin.opsudance.ui.StoryboardOverlay;
|
import yugecin.opsudance.ui.StoryboardOverlay;
|
||||||
|
@ -86,6 +87,9 @@ public class Game extends ComplexOpsuState {
|
||||||
@Inject
|
@Inject
|
||||||
private InstanceContainer instanceContainer;
|
private InstanceContainer instanceContainer;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private GameObjectRenderer gameObjectRenderer;
|
||||||
|
|
||||||
public static boolean isInGame; // TODO delete this when #79 is fixed
|
public static boolean isInGame; // TODO delete this when #79 is fixed
|
||||||
/** Game restart states. */
|
/** Game restart states. */
|
||||||
public enum Restart {
|
public enum Restart {
|
||||||
|
@ -362,6 +366,7 @@ public class Game extends ComplexOpsuState {
|
||||||
|
|
||||||
// create the associated GameData object
|
// create the associated GameData object
|
||||||
data = new GameData(displayContainer.width, displayContainer.height);
|
data = new GameData(displayContainer.width, displayContainer.height);
|
||||||
|
gameObjectRenderer.setGameData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1560,12 +1565,13 @@ public class Game extends ComplexOpsuState {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (hitObject.isCircle())
|
if (hitObject.isCircle()) {
|
||||||
gameObjects[i] = new Circle(hitObject, this, data, hitObject.getComboIndex(), comboEnd);
|
gameObjects[i] = instanceContainer.injectFields(new Circle(hitObject, this, data, hitObject.getComboIndex(), comboEnd));
|
||||||
else if (hitObject.isSlider())
|
} else if (hitObject.isSlider()) {
|
||||||
gameObjects[i] = new Slider(hitObject, this, data, hitObject.getComboIndex(), comboEnd);
|
gameObjects[i] = instanceContainer.injectFields(new Slider(hitObject, this, data, hitObject.getComboIndex(), comboEnd));
|
||||||
else if (hitObject.isSpinner())
|
} else if (hitObject.isSpinner()) {
|
||||||
gameObjects[i] = new Spinner(hitObject, this, data);
|
gameObjects[i] = new Spinner(hitObject, this, data);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String message = String.format("Failed to create %s at index %d:\n%s", hitObject.getTypeName(), i, hitObject.toString());
|
String message = String.format("Failed to create %s at index %d:\n%s", hitObject.getTypeName(), i, hitObject.toString());
|
||||||
Log.error(message, e);
|
Log.error(message, e);
|
||||||
|
@ -2036,8 +2042,8 @@ public class Game extends ComplexOpsuState {
|
||||||
HitObject.setStackOffset(diameter * STACK_OFFSET_MODIFIER);
|
HitObject.setStackOffset(diameter * STACK_OFFSET_MODIFIER);
|
||||||
|
|
||||||
// initialize objects
|
// initialize objects
|
||||||
Circle.init(diameter);
|
gameObjectRenderer.initForGame(data, diameter);
|
||||||
Slider.init(displayContainer, diameter, beatmap);
|
Slider.init(gameObjectRenderer.getCircleDiameter(), beatmap);
|
||||||
Spinner.init(displayContainer, overallDifficulty);
|
Spinner.init(displayContainer, overallDifficulty);
|
||||||
Curve.init(displayContainer.width, displayContainer.height, diameter, (Options.isBeatmapSkinIgnored()) ?
|
Curve.init(displayContainer.width, displayContainer.height, diameter, (Options.isBeatmapSkinIgnored()) ?
|
||||||
Options.getSkin().getSliderBorderColor() : beatmap.getSliderBorderColor());
|
Options.getSkin().getSliderBorderColor() : beatmap.getSliderBorderColor());
|
||||||
|
|
|
@ -25,7 +25,6 @@ import awlex.ospu.spinners.SpiralSpinner;
|
||||||
import itdelatrisu.opsu.Options;
|
import itdelatrisu.opsu.Options;
|
||||||
import itdelatrisu.opsu.Utils;
|
import itdelatrisu.opsu.Utils;
|
||||||
import itdelatrisu.opsu.audio.MusicController;
|
import itdelatrisu.opsu.audio.MusicController;
|
||||||
import itdelatrisu.opsu.objects.Circle;
|
|
||||||
import itdelatrisu.opsu.objects.DummyObject;
|
import itdelatrisu.opsu.objects.DummyObject;
|
||||||
import itdelatrisu.opsu.objects.GameObject;
|
import itdelatrisu.opsu.objects.GameObject;
|
||||||
import itdelatrisu.opsu.objects.Slider;
|
import itdelatrisu.opsu.objects.Slider;
|
||||||
|
@ -37,6 +36,7 @@ import yugecin.opsudance.movers.factories.*;
|
||||||
import yugecin.opsudance.movers.slidermovers.DefaultSliderMoverController;
|
import yugecin.opsudance.movers.slidermovers.DefaultSliderMoverController;
|
||||||
import yugecin.opsudance.movers.slidermovers.InheritedSliderMoverController;
|
import yugecin.opsudance.movers.slidermovers.InheritedSliderMoverController;
|
||||||
import yugecin.opsudance.movers.slidermovers.SliderMoverController;
|
import yugecin.opsudance.movers.slidermovers.SliderMoverController;
|
||||||
|
import yugecin.opsudance.render.GameObjectRenderer;
|
||||||
import yugecin.opsudance.spinners.*;
|
import yugecin.opsudance.spinners.*;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
@ -193,12 +193,12 @@ public class Dancer {
|
||||||
}
|
}
|
||||||
isCurrentLazySlider = false;
|
isCurrentLazySlider = false;
|
||||||
// detect lazy sliders, should work pretty good
|
// detect lazy sliders, should work pretty good
|
||||||
if (c.isSlider() && Options.isLazySliders() && Utils.distance(c.start.x, c.start.y, c.end.x, c.end.y) <= Circle.diameter * 0.8f) {
|
if (c.isSlider() && Options.isLazySliders() && Utils.distance(c.start.x, c.start.y, c.end.x, c.end.y) <= GameObjectRenderer.instance.getCircleDiameter() * 0.8f) {
|
||||||
Slider s = (Slider) c;
|
Slider s = (Slider) c;
|
||||||
Vec2f mid = s.getCurve().pointAt(1f);
|
Vec2f mid = s.getCurve().pointAt(1f);
|
||||||
if (s.getRepeats() == 1 || Utils.distance(c.start.x, c.start.y, mid.x, mid.y) <= Circle.diameter * 0.8f) {
|
if (s.getRepeats() == 1 || Utils.distance(c.start.x, c.start.y, mid.x, mid.y) <= GameObjectRenderer.instance.getCircleDiameter() * 0.8f) {
|
||||||
mid = s.getCurve().pointAt(0.5f);
|
mid = s.getCurve().pointAt(0.5f);
|
||||||
if (Utils.distance(c.start.x, c.start.y, mid.x, mid.y) <= Circle.diameter * 0.8f) {
|
if (Utils.distance(c.start.x, c.start.y, mid.x, mid.y) <= GameObjectRenderer.instance.getCircleDiameter() * 0.8f) {
|
||||||
isCurrentLazySlider = true;
|
isCurrentLazySlider = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
package yugecin.opsudance;
|
package yugecin.opsudance;
|
||||||
|
|
||||||
import itdelatrisu.opsu.Options;
|
import itdelatrisu.opsu.Options;
|
||||||
import itdelatrisu.opsu.objects.Circle;
|
|
||||||
import itdelatrisu.opsu.objects.GameObject;
|
import itdelatrisu.opsu.objects.GameObject;
|
||||||
import itdelatrisu.opsu.objects.Slider;
|
import itdelatrisu.opsu.objects.Slider;
|
||||||
|
import yugecin.opsudance.render.GameObjectRenderer;
|
||||||
|
|
||||||
public class Pippi {
|
public class Pippi {
|
||||||
|
|
||||||
|
@ -37,14 +37,14 @@ public class Pippi {
|
||||||
|
|
||||||
public static void setRadiusPercent(int radiusPercent) {
|
public static void setRadiusPercent(int radiusPercent) {
|
||||||
Pippi.radiusPercent = radiusPercent;
|
Pippi.radiusPercent = radiusPercent;
|
||||||
pippiminrad = pippirad = (Circle.diameter / 2d - 10d) * radiusPercent / 100d;
|
pippiminrad = pippirad = (GameObjectRenderer.instance.getCircleDiameter() / 2d - 10d) * radiusPercent / 100d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reset() {
|
public static void reset() {
|
||||||
angle = 0;
|
angle = 0;
|
||||||
currentdelta = 0;
|
currentdelta = 0;
|
||||||
setRadiusPercent(radiusPercent);
|
setRadiusPercent(radiusPercent);
|
||||||
pippimaxrad = Circle.diameter - 10d;
|
pippimaxrad = GameObjectRenderer.instance.getCircleDiameter() - 10d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dance(int time, GameObject c, boolean isCurrentLazySlider) {
|
public static void dance(int time, GameObject c, boolean isCurrentLazySlider) {
|
||||||
|
@ -91,7 +91,7 @@ public class Pippi {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldPreventWobblyStream(double distance) {
|
public static boolean shouldPreventWobblyStream(double distance) {
|
||||||
return Options.isPippiEnabled() && distance < Circle.diameter * 0.93f && Options.isPippiPreventWobblyStreams();
|
return Options.isPippiEnabled() && distance < GameObjectRenderer.instance.getCircleDiameter() * 0.93f && Options.isPippiPreventWobblyStreams();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import yugecin.opsudance.core.state.transitions.EmptyTransitionState;
|
||||||
import yugecin.opsudance.core.state.transitions.FadeInTransitionState;
|
import yugecin.opsudance.core.state.transitions.FadeInTransitionState;
|
||||||
import yugecin.opsudance.core.state.transitions.FadeOutTransitionState;
|
import yugecin.opsudance.core.state.transitions.FadeOutTransitionState;
|
||||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||||
|
import yugecin.opsudance.render.GameObjectRenderer;
|
||||||
|
|
||||||
public class OpsuDanceInjector extends Injector {
|
public class OpsuDanceInjector extends Injector {
|
||||||
|
|
||||||
|
@ -44,6 +45,8 @@ public class OpsuDanceInjector extends Injector {
|
||||||
bind(FadeInTransitionState.class).asEagerSingleton();
|
bind(FadeInTransitionState.class).asEagerSingleton();
|
||||||
bind(FadeOutTransitionState.class).asEagerSingleton();
|
bind(FadeOutTransitionState.class).asEagerSingleton();
|
||||||
|
|
||||||
|
bind(GameObjectRenderer.class).asEagerSingleton();
|
||||||
|
|
||||||
bind(Splash.class).asEagerSingleton();
|
bind(Splash.class).asEagerSingleton();
|
||||||
bind(MainMenu.class).asEagerSingleton();
|
bind(MainMenu.class).asEagerSingleton();
|
||||||
bind(ButtonMenu.class).asEagerSingleton();
|
bind(ButtonMenu.class).asEagerSingleton();
|
||||||
|
|
|
@ -20,10 +20,10 @@ package yugecin.opsudance.movers.factories;
|
||||||
import itdelatrisu.opsu.Options;
|
import itdelatrisu.opsu.Options;
|
||||||
import itdelatrisu.opsu.Utils;
|
import itdelatrisu.opsu.Utils;
|
||||||
import itdelatrisu.opsu.beatmap.HitObject;
|
import itdelatrisu.opsu.beatmap.HitObject;
|
||||||
import itdelatrisu.opsu.objects.Circle;
|
|
||||||
import itdelatrisu.opsu.objects.GameObject;
|
import itdelatrisu.opsu.objects.GameObject;
|
||||||
import yugecin.opsudance.Pippi;
|
import yugecin.opsudance.Pippi;
|
||||||
import yugecin.opsudance.movers.*;
|
import yugecin.opsudance.movers.*;
|
||||||
|
import yugecin.opsudance.render.GameObjectRenderer;
|
||||||
|
|
||||||
public class AutoMoverFactory implements MoverFactory {
|
public class AutoMoverFactory implements MoverFactory {
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class AutoMoverFactory implements MoverFactory {
|
||||||
|
|
||||||
// stacked: circles if not too quick
|
// stacked: circles if not too quick
|
||||||
int circle_stream = Options.isCircleStreams() ? 58: 85;
|
int circle_stream = Options.isCircleStreams() ? 58: 85;
|
||||||
if (distance < Circle.diameter && ((dt > circle_stream && !Options.isOnlyCircleStacks()) || distance < HitObject.getStackOffset() * 5.2f)) { // TODO get the correct multiplier for stackoffsets
|
if (distance < GameObjectRenderer.instance.getCircleDiameter() && ((dt > circle_stream && !Options.isOnlyCircleStacks()) || distance < HitObject.getStackOffset() * 5.2f)) { // TODO get the correct multiplier for stackoffsets
|
||||||
return new CircleMover(start, end, dir);
|
return new CircleMover(start, end, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
103
src/yugecin/opsudance/render/GameObjectRenderer.java
Normal file
103
src/yugecin/opsudance/render/GameObjectRenderer.java
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
/*
|
||||||
|
* opsu!dance - fork of opsu! with cursordance auto
|
||||||
|
* Copyright (C) 2017 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.render;
|
||||||
|
|
||||||
|
import itdelatrisu.opsu.GameData;
|
||||||
|
import itdelatrisu.opsu.GameImage;
|
||||||
|
import itdelatrisu.opsu.GameMod;
|
||||||
|
import itdelatrisu.opsu.Options;
|
||||||
|
import itdelatrisu.opsu.beatmap.HitObject;
|
||||||
|
import itdelatrisu.opsu.ui.Colors;
|
||||||
|
import org.newdawn.slick.Color;
|
||||||
|
import org.newdawn.slick.Image;
|
||||||
|
import yugecin.opsudance.core.DisplayContainer;
|
||||||
|
import yugecin.opsudance.core.inject.Inject;
|
||||||
|
|
||||||
|
public class GameObjectRenderer {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private DisplayContainer displayContainer;
|
||||||
|
|
||||||
|
private GameData gameData;
|
||||||
|
|
||||||
|
private float circleDiameter;
|
||||||
|
|
||||||
|
private Image hitcircle;
|
||||||
|
private Image hitcircleOverlay;
|
||||||
|
private Image approachCircle;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static GameObjectRenderer instance;
|
||||||
|
|
||||||
|
public GameObjectRenderer() {
|
||||||
|
instance = this; // TODO get rid of this
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initForGame(GameData gameData, float circleDiameter) {
|
||||||
|
this.gameData = gameData;
|
||||||
|
this.circleDiameter = circleDiameter * HitObject.getXMultiplier(); // convert from Osupixels (640x480)
|
||||||
|
int diameterInt = (int) this.circleDiameter;
|
||||||
|
GameImage.HITCIRCLE.setImage(GameImage.HITCIRCLE.getImage().getScaledCopy(diameterInt, diameterInt));
|
||||||
|
GameImage.HITCIRCLE_OVERLAY.setImage(GameImage.HITCIRCLE_OVERLAY.getImage().getScaledCopy(diameterInt, diameterInt));
|
||||||
|
GameImage.APPROACHCIRCLE.setImage(GameImage.APPROACHCIRCLE.getImage().getScaledCopy(diameterInt, diameterInt));
|
||||||
|
hitcircle = GameImage.HITCIRCLE.getImage();
|
||||||
|
hitcircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage();
|
||||||
|
approachCircle = GameImage.APPROACHCIRCLE.getImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getCircleDiameter() {
|
||||||
|
return circleDiameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGameData(GameData gameData) {
|
||||||
|
this.gameData = gameData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderHitCircle(float x, float y, Color color, int comboNumber, float comboNumberAlpha) {
|
||||||
|
renderHitCircleOnly(x, y, color);
|
||||||
|
boolean overlayAboveNumber = Options.getSkin().isHitCircleOverlayAboveNumber();
|
||||||
|
if (!overlayAboveNumber) {
|
||||||
|
renderHitCircleOverlayOnly(x, y, Colors.WHITE_FADE);
|
||||||
|
}
|
||||||
|
renderComboNumberOnly(x, y, comboNumber, comboNumberAlpha);
|
||||||
|
if (overlayAboveNumber) {
|
||||||
|
renderHitCircleOverlayOnly(x, y, Colors.WHITE_FADE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderHitCircleOnly(float x, float y, Color color) {
|
||||||
|
hitcircle.drawCentered(x, y, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderHitCircleOverlayOnly(float x, float y, Color color) {
|
||||||
|
hitcircleOverlay.drawCentered(x, y, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderComboNumberOnly(float x, float y, int number, float alpha) {
|
||||||
|
if (number > 0) {
|
||||||
|
gameData.drawSymbolNumber(number, x, y, GameImage.HITCIRCLE.getImage().getWidth() * 0.40f / gameData.getDefaultSymbolImage(0).getHeight(), alpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderApproachCircle(float x, float y, Color color, float approachScale) {
|
||||||
|
if (!GameMod.HIDDEN.isActive() && Options.isDrawApproach()) {
|
||||||
|
approachCircle.getScaledCopy(approachScale).drawCentered(x, y, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user