Merge pull request #210 from yugecin/slider-improvements
Slider improvements (hidden, followcircle, ticks, reversearrow)
This commit is contained in:
commit
3dad0c93a9
|
@ -901,6 +901,7 @@ public class GameData {
|
||||||
float scale = (!hitResult.expand) ? 1f : 1f + (HITCIRCLE_ANIM_SCALE - 1f) * progress;
|
float scale = (!hitResult.expand) ? 1f : 1f + (HITCIRCLE_ANIM_SCALE - 1f) * progress;
|
||||||
float alpha = 1f - progress;
|
float alpha = 1f - progress;
|
||||||
|
|
||||||
|
if (!GameMod.HIDDEN.isActive()) {
|
||||||
// slider curve
|
// slider curve
|
||||||
if (hitResult.curve != null) {
|
if (hitResult.curve != null) {
|
||||||
float oldWhiteAlpha = Colors.WHITE_FADE.a;
|
float oldWhiteAlpha = Colors.WHITE_FADE.a;
|
||||||
|
@ -913,8 +914,6 @@ public class GameData {
|
||||||
}
|
}
|
||||||
|
|
||||||
// hit circles
|
// hit circles
|
||||||
if (!(hitResult.hitResultType == HitObjectType.CIRCLE && GameMod.HIDDEN.isActive())) {
|
|
||||||
// "hidden" mod: expanding animation for only circles not drawn
|
|
||||||
Image scaledHitCircle = GameImage.HITCIRCLE.getImage().getScaledCopy(scale);
|
Image scaledHitCircle = GameImage.HITCIRCLE.getImage().getScaledCopy(scale);
|
||||||
Image scaledHitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage().getScaledCopy(scale);
|
Image scaledHitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage().getScaledCopy(scale);
|
||||||
scaledHitCircle.setAlpha(alpha);
|
scaledHitCircle.setAlpha(alpha);
|
||||||
|
|
|
@ -104,6 +104,12 @@ public class Slider implements GameObject {
|
||||||
/** Number of ticks hit and tick intervals so far. */
|
/** Number of ticks hit and tick intervals so far. */
|
||||||
private int ticksHit = 0, tickIntervals = 1;
|
private int ticksHit = 0, tickIntervals = 1;
|
||||||
|
|
||||||
|
/** The current tick expanded time */
|
||||||
|
private int tickExpand = 0;
|
||||||
|
|
||||||
|
/** The duration of the tick expand */
|
||||||
|
private final int TICKEXPANDTIME = 200;
|
||||||
|
|
||||||
/** Container dimensions. */
|
/** Container dimensions. */
|
||||||
private static int containerWidth, containerHeight;
|
private static int containerWidth, containerHeight;
|
||||||
|
|
||||||
|
@ -188,9 +194,14 @@ public class Slider implements GameObject {
|
||||||
Image hitCircle = GameImage.HITCIRCLE.getImage();
|
Image hitCircle = GameImage.HITCIRCLE.getImage();
|
||||||
Vec2f endPos = curve.pointAt(1);
|
Vec2f endPos = curve.pointAt(1);
|
||||||
|
|
||||||
|
float oldWHITE_FADEalpha = Colors.WHITE_FADE.a;
|
||||||
|
float sliderAlpha = 1f;
|
||||||
|
if (GameMod.HIDDEN.isActive() && trackPosition > hitObject.getTime()) {
|
||||||
|
Colors.WHITE_FADE.a = color.a = sliderAlpha = Math.max(0f, 1f - ((float) (trackPosition - hitObject.getTime()) / (getEndTime() - hitObject.getTime())) * 1.05f);
|
||||||
|
}
|
||||||
|
|
||||||
float curveInterval = Options.isSliderSnaking() ? alpha : 1f;
|
float curveInterval = Options.isSliderSnaking() ? alpha : 1f;
|
||||||
curve.draw(color,curveInterval);
|
curve.draw(color,curveInterval);
|
||||||
color.a = alpha;
|
|
||||||
|
|
||||||
// end circle
|
// end circle
|
||||||
Vec2f endCircPos = curve.pointAt(curveInterval);
|
Vec2f endCircPos = curve.pointAt(curveInterval);
|
||||||
|
@ -202,17 +213,14 @@ public class Slider implements GameObject {
|
||||||
if (!overlayAboveNumber)
|
if (!overlayAboveNumber)
|
||||||
hitCircleOverlay.drawCentered(x, y, Colors.WHITE_FADE);
|
hitCircleOverlay.drawCentered(x, y, Colors.WHITE_FADE);
|
||||||
|
|
||||||
|
color.a = alpha;
|
||||||
|
|
||||||
// ticks
|
// ticks
|
||||||
if (ticksT != null) {
|
if (ticksT != null) {
|
||||||
float tickScale = 0.5f + 0.5f * AnimationEquation.OUT_BACK.calc(decorationsAlpha);
|
drawSliderTicks(g, trackPosition, sliderAlpha, decorationsAlpha);
|
||||||
Image tick = GameImage.SLIDER_TICK.getImage().getScaledCopy(tickScale);
|
Colors.WHITE_FADE.a = oldWHITE_FADEalpha;
|
||||||
for (int i = 0; i < ticksT.length; i++) {
|
|
||||||
Vec2f c = curve.pointAt(ticksT[i]);
|
|
||||||
Colors.WHITE_FADE.a = decorationsAlpha;
|
|
||||||
tick.drawCentered(c.x, c.y, Colors.WHITE_FADE);
|
|
||||||
Colors.WHITE_FADE.a = alpha;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameMod.HIDDEN.isActive()) {
|
if (GameMod.HIDDEN.isActive()) {
|
||||||
final int hiddenDecayTime = game.getHiddenDecayTime();
|
final int hiddenDecayTime = game.getHiddenDecayTime();
|
||||||
final int hiddenTimeDiff = game.getHiddenTimeDiff();
|
final int hiddenTimeDiff = game.getHiddenTimeDiff();
|
||||||
|
@ -226,14 +234,20 @@ public class Slider implements GameObject {
|
||||||
else
|
else
|
||||||
data.drawSymbolNumber(hitObject.getComboNumber(), x, y,
|
data.drawSymbolNumber(hitObject.getComboNumber(), x, y,
|
||||||
hitCircle.getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight(), alpha);
|
hitCircle.getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight(), alpha);
|
||||||
if (overlayAboveNumber)
|
|
||||||
|
if (overlayAboveNumber) {
|
||||||
|
oldWHITE_FADEalpha = Colors.WHITE_FADE.a;
|
||||||
|
Colors.WHITE_FADE.a = sliderAlpha;
|
||||||
hitCircleOverlay.drawCentered(x, y, Colors.WHITE_FADE);
|
hitCircleOverlay.drawCentered(x, y, Colors.WHITE_FADE);
|
||||||
|
Colors.WHITE_FADE.a = oldWHITE_FADEalpha;
|
||||||
|
}
|
||||||
|
|
||||||
// repeats
|
// repeats
|
||||||
if (curveInterval == 1.0f) {
|
if (curveInterval == 1.0f) {
|
||||||
for (int tcurRepeat = currentRepeats; tcurRepeat <= currentRepeats + 1; tcurRepeat++) {
|
for (int tcurRepeat = currentRepeats; tcurRepeat <= currentRepeats + 1; tcurRepeat++) {
|
||||||
if (hitObject.getRepeatCount() - 1 > tcurRepeat) {
|
if (hitObject.getRepeatCount() - 1 > tcurRepeat) {
|
||||||
Image arrow = GameImage.REVERSEARROW.getImage();
|
Image arrow = GameImage.REVERSEARROW.getImage();
|
||||||
|
arrow = arrow.getScaledCopy((float) (1 + 0.2d * ((trackPosition + sliderTime * tcurRepeat) % 292) / 292));
|
||||||
float colorLuminance = 0.299f*color.r + 0.587f*color.g + 0.114f*color.b;
|
float colorLuminance = 0.299f*color.r + 0.587f*color.g + 0.114f*color.b;
|
||||||
Color arrowColor = colorLuminance < 0.8f ? Color.white : Color.black;
|
Color arrowColor = colorLuminance < 0.8f ? Color.white : Color.black;
|
||||||
if (tcurRepeat != currentRepeats) {
|
if (tcurRepeat != currentRepeats) {
|
||||||
|
@ -283,7 +297,7 @@ public class Slider implements GameObject {
|
||||||
|
|
||||||
// follow circle
|
// follow circle
|
||||||
if (followCircleActive) {
|
if (followCircleActive) {
|
||||||
GameImage.SLIDER_FOLLOWCIRCLE.getImage().drawCentered(c.x, c.y);
|
GameImage.SLIDER_FOLLOWCIRCLE.getImage().getScaledCopy(1f + (tickExpand / (float) TICKEXPANDTIME) * 0.1f).drawCentered(c.x, c.y);
|
||||||
|
|
||||||
// "flashlight" mod: dim the screen
|
// "flashlight" mod: dim the screen
|
||||||
if (GameMod.FLASHLIGHT.isActive()) {
|
if (GameMod.FLASHLIGHT.isActive()) {
|
||||||
|
@ -299,6 +313,33 @@ public class Slider implements GameObject {
|
||||||
Colors.WHITE_FADE.a = oldAlpha;
|
Colors.WHITE_FADE.a = oldAlpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void drawSliderTicks(Graphics g, int trackPosition, float curveAlpha, float decorationsAlpha) {
|
||||||
|
float tickScale = 0.5f + 0.5f * AnimationEquation.OUT_BACK.calc(decorationsAlpha);
|
||||||
|
Image tick = GameImage.SLIDER_TICK.getImage().getScaledCopy(tickScale);
|
||||||
|
|
||||||
|
// calculate which ticks need to be drawn (don't draw if sliderball crossed it)
|
||||||
|
int min = 0;
|
||||||
|
int max = ticksT.length;
|
||||||
|
if (trackPosition > hitObject.getTime()) {
|
||||||
|
for (int i = 0; i < ticksT.length; ) {
|
||||||
|
if (((trackPosition - hitObject.getTime()) % sliderTime) / sliderTime < ticksT[i]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
min = ++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (currentRepeats % 2 == 1) {
|
||||||
|
max -= min;
|
||||||
|
min = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = min; i < max; i++) {
|
||||||
|
Vec2f c = curve.pointAt(ticksT[i]);
|
||||||
|
Colors.WHITE_FADE.a = Math.min(curveAlpha, decorationsAlpha);
|
||||||
|
tick.drawCentered(c.x, c.y, Colors.WHITE_FADE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the slider hit result.
|
* Calculates the slider hit result.
|
||||||
* @return the hit result (GameData.HIT_* constants)
|
* @return the hit result (GameData.HIT_* constants)
|
||||||
|
@ -443,9 +484,17 @@ public class Slider implements GameObject {
|
||||||
mousePressed(mouseX, mouseY, trackPosition);
|
mousePressed(mouseX, mouseY, trackPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tickExpand > 0) {
|
||||||
|
tickExpand -= delta;
|
||||||
|
if (tickExpand < 0) {
|
||||||
|
tickExpand = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// end of slider
|
// end of slider
|
||||||
if (trackPosition > hitObject.getTime() + sliderTimeTotal) {
|
if (trackPosition > hitObject.getTime() + sliderTimeTotal) {
|
||||||
tickIntervals++;
|
tickIntervals++;
|
||||||
|
tickExpand = TICKEXPANDTIME;
|
||||||
|
|
||||||
// check if cursor pressed and within end circle
|
// check if cursor pressed and within end circle
|
||||||
if (keyPressed || GameMod.RELAX.isActive()) {
|
if (keyPressed || GameMod.RELAX.isActive()) {
|
||||||
|
@ -474,8 +523,9 @@ public class Slider implements GameObject {
|
||||||
float t = getT(trackPosition, true);
|
float t = getT(trackPosition, true);
|
||||||
if (Math.floor(t) > currentRepeats) {
|
if (Math.floor(t) > currentRepeats) {
|
||||||
currentRepeats++;
|
currentRepeats++;
|
||||||
tickIntervals++;
|
tickExpand = TICKEXPANDTIME;
|
||||||
isNewRepeat = true;
|
isNewRepeat = true;
|
||||||
|
tickIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,6 +538,7 @@ public class Slider implements GameObject {
|
||||||
if (t - Math.floor(t) >= ticksT[tickIndex]) {
|
if (t - Math.floor(t) >= ticksT[tickIndex]) {
|
||||||
tickIntervals++;
|
tickIntervals++;
|
||||||
tickIndex = (tickIndex + 1) % ticksT.length;
|
tickIndex = (tickIndex + 1) % ticksT.length;
|
||||||
|
tickExpand = TICKEXPANDTIME;
|
||||||
isNewTick = true;
|
isNewTick = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user