Store raw hit object coordinates instead of scaled ones.
Fixes a bug where a resolution change (by restarting through the app) wouldn't re-scale hit object coordinates. Scaled coordinates are now stored in HitObject fields. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -37,6 +37,9 @@ public class Circle implements HitObject {
|
||||
/** The associated OsuHitObject. */
|
||||
private OsuHitObject hitObject;
|
||||
|
||||
/** The scaled starting x, y coordinates. */
|
||||
private float x, y;
|
||||
|
||||
/** The associated Game object. */
|
||||
private Game game;
|
||||
|
||||
@@ -72,6 +75,8 @@ public class Circle implements HitObject {
|
||||
*/
|
||||
public Circle(OsuHitObject hitObject, Game game, GameData data, Color color, boolean comboEnd) {
|
||||
this.hitObject = hitObject;
|
||||
this.x = hitObject.getScaledX();
|
||||
this.y = hitObject.getScaledY();
|
||||
this.game = game;
|
||||
this.data = data;
|
||||
this.color = color;
|
||||
@@ -84,7 +89,6 @@ public class Circle implements HitObject {
|
||||
|
||||
if (timeDiff >= 0) {
|
||||
float oldAlpha = color.a;
|
||||
float x = hitObject.getX(), y = hitObject.getY();
|
||||
float scale = timeDiff / (float)game.getApproachTime();
|
||||
|
||||
float approachScale = 1 + scale * 3;
|
||||
@@ -129,7 +133,7 @@ public class Circle implements HitObject {
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(int x, int y) {
|
||||
double distance = Math.hypot(hitObject.getX() - x, hitObject.getY() - y);
|
||||
double distance = Math.hypot(this.x - x, this.y - y);
|
||||
int circleRadius = GameImage.HITCIRCLE.getImage().getWidth() / 2;
|
||||
if (distance < circleRadius) {
|
||||
int trackPosition = MusicController.getPosition();
|
||||
@@ -138,11 +142,7 @@ public class Circle implements HitObject {
|
||||
|
||||
if (result > -1) {
|
||||
data.addHitError(hitObject.getTime(), x, y, timeDiff);
|
||||
data.hitResult(
|
||||
hitObject.getTime(), result,
|
||||
hitObject.getX(), hitObject.getY(),
|
||||
color, comboEnd, hitObject, 0
|
||||
);
|
||||
data.hitResult(hitObject.getTime(), result, this.x, this.y, color, comboEnd, hitObject, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,6 @@ public class Circle implements HitObject {
|
||||
@Override
|
||||
public boolean update(boolean overlap, int delta, int mouseX, int mouseY, boolean keyPressed) {
|
||||
int time = hitObject.getTime();
|
||||
float x = hitObject.getX(), y = hitObject.getY();
|
||||
|
||||
int trackPosition = MusicController.getPosition();
|
||||
int[] hitResultOffset = game.getHitResultOffsets();
|
||||
|
||||
@@ -52,6 +52,9 @@ public class Slider implements HitObject {
|
||||
/** The associated OsuHitObject. */
|
||||
private OsuHitObject hitObject;
|
||||
|
||||
/** The scaled starting x, y coordinates. */
|
||||
protected float x, y;
|
||||
|
||||
/** The associated Game object. */
|
||||
private Game game;
|
||||
|
||||
@@ -130,6 +133,8 @@ public class Slider implements HitObject {
|
||||
*/
|
||||
public Slider(OsuHitObject hitObject, Game game, GameData data, Color color, boolean comboEnd) {
|
||||
this.hitObject = hitObject;
|
||||
this.x = hitObject.getScaledX();
|
||||
this.y = hitObject.getScaledY();
|
||||
this.game = game;
|
||||
this.data = data;
|
||||
this.color = color;
|
||||
@@ -147,7 +152,6 @@ public class Slider implements HitObject {
|
||||
int timeDiff = hitObject.getTime() - trackPosition;
|
||||
float scale = timeDiff / (float) game.getApproachTime();
|
||||
float approachScale = 1 + scale * 3;
|
||||
float x = hitObject.getX(), y = hitObject.getY();
|
||||
float alpha = Utils.clamp(1 - scale, 0, 1);
|
||||
|
||||
float oldAlpha = color.a;
|
||||
@@ -256,7 +260,7 @@ public class Slider implements HitObject {
|
||||
lastPos[0], lastPos[1], color, comboEnd, hitObject, currentRepeats + 1);
|
||||
} else { // first circle
|
||||
data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result,
|
||||
hitObject.getX(), hitObject.getY(), color, comboEnd, hitObject, currentRepeats + 1);
|
||||
x, y, color, comboEnd, hitObject, currentRepeats + 1);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -267,7 +271,7 @@ public class Slider implements HitObject {
|
||||
if (sliderClickedInitial) // first circle already processed
|
||||
return false;
|
||||
|
||||
double distance = Math.hypot(hitObject.getX() - x, hitObject.getY() - y);
|
||||
double distance = Math.hypot(this.x - x, this.y - y);
|
||||
int circleRadius = GameImage.HITCIRCLE.getImage().getWidth() / 2;
|
||||
if (distance < circleRadius) {
|
||||
int trackPosition = MusicController.getPosition();
|
||||
@@ -285,8 +289,7 @@ public class Slider implements HitObject {
|
||||
if (result > -1) {
|
||||
data.addHitError(hitObject.getTime(), x,y,trackPosition - hitObject.getTime());
|
||||
sliderClickedInitial = true;
|
||||
data.sliderTickResult(hitObject.getTime(), result,
|
||||
hitObject.getX(), hitObject.getY(), hitObject, currentRepeats);
|
||||
data.sliderTickResult(hitObject.getTime(), result, this.x, this.y, hitObject, currentRepeats);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -317,7 +320,6 @@ public class Slider implements HitObject {
|
||||
|
||||
int trackPosition = MusicController.getPosition();
|
||||
int[] hitResultOffset = game.getHitResultOffsets();
|
||||
int lastIndex = hitObject.getSliderX().length - 1;
|
||||
boolean isAutoMod = GameMod.AUTO.isActive();
|
||||
|
||||
if (!sliderClickedInitial) {
|
||||
@@ -328,11 +330,9 @@ public class Slider implements HitObject {
|
||||
sliderClickedInitial = true;
|
||||
if (isAutoMod) { // "auto" mod: catch any missed notes due to lag
|
||||
ticksHit++;
|
||||
data.sliderTickResult(time, GameData.HIT_SLIDER30,
|
||||
hitObject.getX(), hitObject.getY(), hitObject, currentRepeats);
|
||||
data.sliderTickResult(time, GameData.HIT_SLIDER30, x, y, hitObject, currentRepeats);
|
||||
} else
|
||||
data.sliderTickResult(time, GameData.HIT_MISS,
|
||||
hitObject.getX(), hitObject.getY(), hitObject, currentRepeats);
|
||||
data.sliderTickResult(time, GameData.HIT_MISS, x, y, hitObject, currentRepeats);
|
||||
}
|
||||
|
||||
// "auto" mod: send a perfect hit result
|
||||
@@ -340,8 +340,7 @@ public class Slider implements HitObject {
|
||||
if (Math.abs(trackPosition - time) < hitResultOffset[GameData.HIT_300]) {
|
||||
ticksHit++;
|
||||
sliderClickedInitial = true;
|
||||
data.sliderTickResult(time, GameData.HIT_SLIDER30,
|
||||
hitObject.getX(), hitObject.getY(), hitObject, currentRepeats);
|
||||
data.sliderTickResult(time, GameData.HIT_SLIDER30, x, y, hitObject, currentRepeats);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,11 +411,11 @@ public class Slider implements HitObject {
|
||||
// held during new repeat
|
||||
if (isNewRepeat) {
|
||||
ticksHit++;
|
||||
if (currentRepeats % 2 > 0) // last circle
|
||||
if (currentRepeats % 2 > 0) { // last circle
|
||||
int lastIndex = hitObject.getSliderX().length;
|
||||
data.sliderTickResult(trackPosition, GameData.HIT_SLIDER30,
|
||||
hitObject.getSliderX()[lastIndex], hitObject.getSliderY()[lastIndex],
|
||||
hitObject, currentRepeats);
|
||||
else // first circle
|
||||
curve.getX(lastIndex), curve.getY(lastIndex), hitObject, currentRepeats);
|
||||
} else // first circle
|
||||
data.sliderTickResult(trackPosition, GameData.HIT_SLIDER30,
|
||||
c[0], c[1], hitObject, currentRepeats);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,12 @@ public abstract class Curve {
|
||||
/** The color of this curve. */
|
||||
protected Color color;
|
||||
|
||||
/** The scaled starting x, y coordinates. */
|
||||
protected float x, y;
|
||||
|
||||
/** The scaled slider x, y coordinate lists. */
|
||||
protected float[] sliderX, sliderY;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param hitObject the associated OsuHitObject
|
||||
@@ -41,6 +47,10 @@ public abstract class Curve {
|
||||
*/
|
||||
protected Curve(OsuHitObject hitObject, Color color) {
|
||||
this.hitObject = hitObject;
|
||||
this.x = hitObject.getScaledX();
|
||||
this.y = hitObject.getScaledY();
|
||||
this.sliderX = hitObject.getScaledSliderX();
|
||||
this.sliderY = hitObject.getScaledSliderY();
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@@ -67,18 +77,16 @@ public abstract class Curve {
|
||||
public abstract float getStartAngle();
|
||||
|
||||
/**
|
||||
* Returns the x coordinate of the control point at index i.
|
||||
* Returns the scaled x coordinate of the control point at index i.
|
||||
* @param i the control point index
|
||||
*/
|
||||
protected float getX(int i) {
|
||||
return (i == 0) ? hitObject.getX() : hitObject.getSliderX()[i - 1];
|
||||
}
|
||||
public float getX(int i) { return (i == 0) ? x : sliderX[i - 1]; }
|
||||
|
||||
/**
|
||||
* Returns the y coordinate of the control point at index i.
|
||||
* Returns the scaled y coordinate of the control point at index i.
|
||||
* @param i the control point index
|
||||
*/
|
||||
protected float getY(int i) {
|
||||
return (i == 0) ? hitObject.getY() : hitObject.getSliderY()[i - 1];
|
||||
}
|
||||
public float getY(int i) { return (i == 0) ? y : sliderY[i - 1]; }
|
||||
|
||||
/**
|
||||
* Linear interpolation of a and b at t.
|
||||
|
||||
Reference in New Issue
Block a user