Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slider improvements (hidden, followcircle, ticks, reversearrow) #210

Merged
merged 6 commits into from
Dec 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions src/itdelatrisu/opsu/GameData.java
Original file line number Diff line number Diff line change
Expand Up @@ -901,20 +901,19 @@ else if (Options.isHitLightingEnabled() && !hitResult.hideResult && hitResult.re
float scale = (!hitResult.expand) ? 1f : 1f + (HITCIRCLE_ANIM_SCALE - 1f) * progress;
float alpha = 1f - progress;

// slider curve
if (hitResult.curve != null) {
float oldWhiteAlpha = Colors.WHITE_FADE.a;
float oldColorAlpha = hitResult.color.a;
Colors.WHITE_FADE.a = alpha;
hitResult.color.a = alpha;
hitResult.curve.draw(hitResult.color);
Colors.WHITE_FADE.a = oldWhiteAlpha;
hitResult.color.a = oldColorAlpha;
}

// hit circles
if (!(hitResult.hitResultType == HitObjectType.CIRCLE && GameMod.HIDDEN.isActive())) {
// "hidden" mod: expanding animation for only circles not drawn
if (!GameMod.HIDDEN.isActive()) {
// slider curve
if (hitResult.curve != null) {
float oldWhiteAlpha = Colors.WHITE_FADE.a;
float oldColorAlpha = hitResult.color.a;
Colors.WHITE_FADE.a = alpha;
hitResult.color.a = alpha;
hitResult.curve.draw(hitResult.color);
Colors.WHITE_FADE.a = oldWhiteAlpha;
hitResult.color.a = oldColorAlpha;
}

// hit circles
Image scaledHitCircle = GameImage.HITCIRCLE.getImage().getScaledCopy(scale);
Image scaledHitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage().getScaledCopy(scale);
scaledHitCircle.setAlpha(alpha);
Expand Down
75 changes: 63 additions & 12 deletions src/itdelatrisu/opsu/objects/Slider.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ public class Slider implements GameObject {
/** Number of ticks hit and tick intervals so far. */
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. */
private static int containerWidth, containerHeight;

Expand Down Expand Up @@ -188,9 +194,14 @@ public void draw(Graphics g, int trackPosition) {
Image hitCircle = GameImage.HITCIRCLE.getImage();
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;
curve.draw(color,curveInterval);
color.a = alpha;

// end circle
Vec2f endCircPos = curve.pointAt(curveInterval);
Expand All @@ -202,17 +213,14 @@ public void draw(Graphics g, int trackPosition) {
if (!overlayAboveNumber)
hitCircleOverlay.drawCentered(x, y, Colors.WHITE_FADE);

color.a = alpha;

// ticks
if (ticksT != null) {
float tickScale = 0.5f + 0.5f * AnimationEquation.OUT_BACK.calc(decorationsAlpha);
Image tick = GameImage.SLIDER_TICK.getImage().getScaledCopy(tickScale);
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;
}
drawSliderTicks(g, trackPosition, sliderAlpha, decorationsAlpha);
Colors.WHITE_FADE.a = oldWHITE_FADEalpha;
}

if (GameMod.HIDDEN.isActive()) {
final int hiddenDecayTime = game.getHiddenDecayTime();
final int hiddenTimeDiff = game.getHiddenTimeDiff();
Expand All @@ -226,14 +234,20 @@ public void draw(Graphics g, int trackPosition) {
else
data.drawSymbolNumber(hitObject.getComboNumber(), x, y,
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);
Colors.WHITE_FADE.a = oldWHITE_FADEalpha;
}

// repeats
if (curveInterval == 1.0f) {
for (int tcurRepeat = currentRepeats; tcurRepeat <= currentRepeats + 1; tcurRepeat++) {
if (hitObject.getRepeatCount() - 1 > tcurRepeat) {
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;
Color arrowColor = colorLuminance < 0.8f ? Color.white : Color.black;
if (tcurRepeat != currentRepeats) {
Expand Down Expand Up @@ -283,7 +297,7 @@ public void draw(Graphics g, int trackPosition) {

// follow circle
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
if (GameMod.FLASHLIGHT.isActive()) {
Expand All @@ -299,6 +313,33 @@ public void draw(Graphics g, int trackPosition) {
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.
* @return the hit result (GameData.HIT_* constants)
Expand Down Expand Up @@ -443,9 +484,17 @@ else if (GameMod.RELAX.isActive() && trackPosition >= time)
mousePressed(mouseX, mouseY, trackPosition);
}

if (tickExpand > 0) {
tickExpand -= delta;
if (tickExpand < 0) {
tickExpand = 0;
}
}

// end of slider
if (trackPosition > hitObject.getTime() + sliderTimeTotal) {
tickIntervals++;
tickExpand = TICKEXPANDTIME;

// check if cursor pressed and within end circle
if (keyPressed || GameMod.RELAX.isActive()) {
Expand Down Expand Up @@ -474,8 +523,9 @@ else if (GameMod.RELAX.isActive() && trackPosition >= time)
float t = getT(trackPosition, true);
if (Math.floor(t) > currentRepeats) {
currentRepeats++;
tickIntervals++;
tickExpand = TICKEXPANDTIME;
isNewRepeat = true;
tickIndex = 0;
}
}

Expand All @@ -488,6 +538,7 @@ else if (GameMod.RELAX.isActive() && trackPosition >= time)
if (t - Math.floor(t) >= ticksT[tickIndex]) {
tickIntervals++;
tickIndex = (tickIndex + 1) % ticksT.length;
tickExpand = TICKEXPANDTIME;
isNewTick = true;
}
}
Expand Down