Skip to content

Commit

Permalink
Merge pull request #656 from smoogipooo/taiko-fixes
Browse files Browse the repository at this point in the history
Taiko fixes
  • Loading branch information
peppy authored Apr 20, 2017
2 parents 1af2cf3 + 3342a97 commit 6e3125e
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 37 deletions.
5 changes: 2 additions & 3 deletions osu.Game.Rulesets.Osu/OsuAutoReplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ private void createAutoReplay()

if (h is Spinner)
{
targetPosition.X = Frames[Frames.Count - 1].MouseX;
targetPosition.Y = Frames[Frames.Count - 1].MouseY;
targetPosition = Frames[Frames.Count - 1].Position;

Vector2 difference = spinner_centre - targetPosition;

Expand Down Expand Up @@ -193,7 +192,7 @@ private void createAutoReplay()
addFrameToReplay(lastFrame);
}

Vector2 lastPosition = new Vector2(lastFrame.MouseX, lastFrame.MouseY);
Vector2 lastPosition = lastFrame.Position;

double timeDifference = applyModsToTime(h.StartTime - lastFrame.Time);

Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ protected override IEnumerable<TaikoHitObject> ConvertHitObject(HitObject obj, B
double osuDuration = distance / osuVelocity;

// If the drum roll is to be split into hit circles, assume the ticks are 1/8 spaced within the duration of one beat
double tickSpacing = Math.Min(speedAdjustedBeatLength / beatmap.BeatmapInfo.Difficulty.SliderTickRate, taikoDuration / repeats) / 8;
double tickSpacing = Math.Min(speedAdjustedBeatLength / beatmap.BeatmapInfo.Difficulty.SliderTickRate, taikoDuration / repeats);

if (tickSpacing > 0 && osuDuration < 2 * speedAdjustedBeatLength)
{
for (double j = obj.StartTime; j <= distanceData.EndTime + tickSpacing; j += tickSpacing)
for (double j = obj.StartTime; j <= obj.StartTime + taikoDuration + tickSpacing / 8; j += tickSpacing)
{
// Todo: This should generate different type of hits (including strongs)
// depending on hitobject sound additions (not implemented fully yet)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ public DrawableDrumRollTick(DrumRollTick tick)
protected override void CheckJudgement(bool userTriggered)
{
if (!userTriggered)
{
if (Judgement.TimeOffset > HitObject.HitWindow)
Judgement.Result = HitResult.Miss;
return;
}

if (Math.Abs(Judgement.TimeOffset) < HitObject.HitWindow)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class TickPiece : TaikoPiece
/// <summary>
/// The size of a tick.
/// </summary>
private const float tick_size = TaikoHitObject.DEFAULT_CIRCLE_DIAMETER / 4;
private const float tick_size = TaikoHitObject.DEFAULT_CIRCLE_DIAMETER / 6;

private bool filled;
public bool Filled
Expand Down
14 changes: 7 additions & 7 deletions osu.Game.Rulesets.Taiko/Replays/TaikoAutoReplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ private void createAutoReplay()
{
bool hitButton = true;

Frames.Add(new ReplayFrame(-100000, 320, 240, ReplayButtonState.None));
Frames.Add(new ReplayFrame(beatmap.HitObjects[0].StartTime - 1000, 320, 240, ReplayButtonState.None));
Frames.Add(new ReplayFrame(-100000, null, null, ReplayButtonState.None));
Frames.Add(new ReplayFrame(beatmap.HitObjects[0].StartTime - 1000, null, null, ReplayButtonState.None));

for (int i = 0; i < beatmap.HitObjects.Count; i++)
{
Expand Down Expand Up @@ -64,7 +64,7 @@ private void createAutoReplay()
break;
}

Frames.Add(new ReplayFrame(j, 0, 0, button));
Frames.Add(new ReplayFrame(j, null, null, button));
d = (d + 1) % 4;
if (++count > req)
break;
Expand All @@ -74,7 +74,7 @@ private void createAutoReplay()
{
foreach (var tick in drumRoll.Ticks)
{
Frames.Add(new ReplayFrame(tick.StartTime, 0, 0, hitButton ? ReplayButtonState.Left1 : ReplayButtonState.Left2));
Frames.Add(new ReplayFrame(tick.StartTime, null, null, hitButton ? ReplayButtonState.Left1 : ReplayButtonState.Left2));
hitButton = !hitButton;
}
}
Expand All @@ -95,18 +95,18 @@ private void createAutoReplay()
button = hitButton ? ReplayButtonState.Left1 : ReplayButtonState.Left2;
}

Frames.Add(new ReplayFrame(h.StartTime, 0, 0, button));
Frames.Add(new ReplayFrame(h.StartTime, null, null, button));
}
else
throw new Exception("Unknown hit object type.");

Frames.Add(new ReplayFrame(endTime + KEY_UP_DELAY, 0, 0, ReplayButtonState.None));
Frames.Add(new ReplayFrame(endTime + KEY_UP_DELAY, null, null, ReplayButtonState.None));

if (i < beatmap.HitObjects.Count - 1)
{
double waitTime = beatmap.HitObjects[i + 1].StartTime - 1000;
if (waitTime > endTime)
Frames.Add(new ReplayFrame(waitTime, 0, 0, ReplayButtonState.None));
Frames.Add(new ReplayFrame(waitTime, null, null, ReplayButtonState.None));
}

hitButton = !hitButton;
Expand Down
8 changes: 4 additions & 4 deletions osu.Game/Database/ScoreDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,19 @@ public Score ReadReplayFile(string replayFilename)

using (var lzma = new LzmaStream(properties, replayInStream, compressedSize, outSize))
using (var reader = new StreamReader(lzma))
score.Replay = createReplay(reader);
score.Replay = createLegacyReplay(reader);
}
}

return score;
}

/// <summary>
/// Creates a replay which is read from a stream.
/// Creates a legacy replay which is read from a stream.
/// </summary>
/// <param name="reader">The stream reader.</param>
/// <returns>The replay.</returns>
private Replay createReplay(StreamReader reader)
/// <returns>The legacy replay.</returns>
private Replay createLegacyReplay(StreamReader reader)
{
var frames = new List<ReplayFrame>();

Expand Down
6 changes: 5 additions & 1 deletion osu.Game/Graphics/OsuColour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public static Color4 FromHex(string hex)
public Color4 GrayE = FromHex(@"eee");
public Color4 GrayF = FromHex(@"fff");

public Color4 Red = FromHex(@"fc4549");
public Color4 RedLighter = FromHex(@"ffeded");
public Color4 RedLight = FromHex(@"ed7787");
public Color4 Red = FromHex(@"ed1121");
public Color4 RedDark = FromHex(@"ba0011");
public Color4 RedDarker = FromHex(@"870000");
}
}
14 changes: 7 additions & 7 deletions osu.Game/Rulesets/Replays/ReplayFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ namespace osu.Game.Rulesets.Replays
{
public class ReplayFrame
{
public Vector2 Position => new Vector2(MouseX, MouseY);
public Vector2 Position => new Vector2(MouseX ?? 0, MouseY ?? 0);

public bool IsImportant => MouseLeft || MouseRight;
public bool IsImportant => MouseX.HasValue && MouseY.HasValue && (MouseLeft || MouseRight);

public float MouseX;
public float MouseY;
public float? MouseX;
public float? MouseY;

public bool MouseLeft => MouseLeft1 || MouseLeft2;
public bool MouseRight => MouseRight1 || MouseRight2;
Expand Down Expand Up @@ -55,10 +55,10 @@ protected ReplayFrame()

}

public ReplayFrame(double time, float posX, float posY, ReplayButtonState buttonState)
public ReplayFrame(double time, float? mouseX, float? mouseY, ReplayButtonState buttonState)
{
MouseX = posX;
MouseY = posY;
MouseX = mouseX;
MouseY = mouseY;
ButtonState = buttonState;
Time = time;
}
Expand Down
16 changes: 16 additions & 0 deletions osu.Game/Rulesets/Scoring/ScoreProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public abstract class ScoreProcessor
/// </summary>
public event Action Failed;

/// <summary>
/// Invoked when a new judgement has occurred. This occurs after the judgement has been processed by the <see cref="ScoreProcessor"/>.
/// </summary>
public event Action<Judgement> NewJudgement;

/// <summary>
/// The current total score.
/// </summary>
Expand Down Expand Up @@ -105,6 +110,15 @@ protected void UpdateFailed()
Failed?.Invoke();
}

/// <summary>
/// Notifies subscribers of <see cref="NewJudgement"/> that a new judgement has occurred.
/// </summary>
/// <param name="judgement">The judgement to notify subscribers of.</param>
protected void NotifyNewJudgement(Judgement judgement)
{
NewJudgement?.Invoke(judgement);
}

/// <summary>
/// Retrieve a score populated with data for the current play this processor is responsible for.
/// </summary>
Expand Down Expand Up @@ -177,6 +191,8 @@ protected void AddJudgement(TJudgement judgement)

Judgements.Add(judgement);
OnNewJudgement(judgement);

NotifyNewJudgement(judgement);
}
else
OnJudgementChanged(judgement);
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Rulesets/UI/HudOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ private void load(OsuConfigManager config, NotificationManager notificationManag
}
}

public void BindProcessor(ScoreProcessor processor)
public virtual void BindProcessor(ScoreProcessor processor)
{
ScoreCounter?.Current.BindTo(processor.TotalScore);
AccuracyCounter?.Current.BindTo(processor.Accuracy);
ComboCounter?.Current.BindTo(processor.Combo);
HealthDisplay?.Current.BindTo(processor.Health);
}

public void BindHitRenderer(HitRenderer hitRenderer)
public virtual void BindHitRenderer(HitRenderer hitRenderer)
{
hitRenderer.InputManager.Add(KeyCounter.GetReceptor());
}
Expand Down
46 changes: 42 additions & 4 deletions osu.Game/Rulesets/UI/StandardHealthDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,42 @@

using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
using System;

namespace osu.Game.Rulesets.UI
{
public class StandardHealthDisplay : HealthDisplay, IHasAccentColour
{
/// <summary>
/// The base opacity of the glow.
/// </summary>
private const float base_glow_opacity = 0.6f;

/// <summary>
/// The number of sequential hits required within <see cref="glow_fade_delay"/> to reach the maximum glow opacity.
/// </summary>
private const int glow_max_hits = 8;

/// <summary>
/// The amount of time to delay before fading the glow opacity back to <see cref="base_glow_opacity"/>.
/// <para>
/// This is calculated to require a stream snapped to 1/4 at 150bpm to reach the maximum glow opacity with <see cref="glow_max_hits"/> hits.
/// </para>
/// </summary>
private const float glow_fade_delay = 100;

/// <summary>
/// The amount of time to fade the glow to <see cref="base_glow_opacity"/> after <see cref="glow_fade_delay"/>.
/// </summary>
private const double glow_fade_time = 500;

private readonly Container fill;

public Color4 AccentColour
Expand All @@ -32,9 +59,10 @@ public Color4 GlowColour

fill.EdgeEffect = new EdgeEffect
{
Colour = glowColour,
Colour = glowColour.Opacity(base_glow_opacity),
Radius = 8,
Type = EdgeEffectType.Glow
Roundness = 4,
Type = EdgeEffectType.Glow,
};
}
}
Expand All @@ -51,7 +79,7 @@ public StandardHealthDisplay()
fill = new Container
{
RelativeSizeAxes = Axes.Both,
Scale = new Vector2(0, 1),
Size = new Vector2(0, 1),
Masking = true,
Children = new[]
{
Expand All @@ -64,6 +92,16 @@ public StandardHealthDisplay()
};
}

protected override void SetHealth(float value) => fill.ScaleTo(new Vector2(value, 1), 200, EasingTypes.OutQuint);
public void Flash(Judgement judgement)
{
if (judgement.Result == HitResult.Miss)
return;

fill.FadeEdgeEffectTo(Math.Min(1, fill.EdgeEffect.Colour.Linear.A + (1f - base_glow_opacity) / glow_max_hits), 50, EasingTypes.OutQuint);
fill.Delay(glow_fade_delay);
fill.FadeEdgeEffectTo(base_glow_opacity, glow_fade_time, EasingTypes.OutQuint);
}

protected override void SetHealth(float value) => fill.ResizeTo(new Vector2(value, 1), 200, EasingTypes.OutQuint);
}
}
13 changes: 11 additions & 2 deletions osu.Game/Rulesets/UI/StandardHudOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play;

namespace osu.Game.Rulesets.UI
Expand Down Expand Up @@ -75,8 +75,17 @@ private void load(OsuColour colours)
if (shd != null)
{
shd.AccentColour = colours.BlueLighter;
shd.GlowColour = colours.BlueDarker.Opacity(0.6f);
shd.GlowColour = colours.BlueDarker;
}
}

public override void BindProcessor(ScoreProcessor processor)
{
base.BindProcessor(processor);

var shd = HealthDisplay as StandardHealthDisplay;
if (shd != null)
processor.NewJudgement += shd.Flash;
}
}
}

0 comments on commit 6e3125e

Please sign in to comment.