Skip to content

Commit

Permalink
Merge pull request #126 from goodtrailer/fix-hold-statistics
Browse files Browse the repository at this point in the history
Statistics: Fix statistics hit distribution graph for Hold objects
  • Loading branch information
goodtrailer authored May 3, 2023
2 parents a726337 + a0f109f commit 4fea45f
Show file tree
Hide file tree
Showing 7 changed files with 449 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Alden Wu <[email protected]>. Licensed under the MIT Licence.
// See the LICENSE file in the repository root for full licence text.

using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Soyokaze.Objects;

namespace osu.Game.Rulesets.Soyokaze.Judgements
{
public class SoyokazeHoldJudgementResult : JudgementResult
{
public double TrueTimeOffset { get; set; }

public SoyokazeHoldJudgementResult(Hold hitObject, Judgement judgement)
: base(hitObject, judgement)
{
}
}
}
14 changes: 13 additions & 1 deletion osu.Game.Rulesets.Soyokaze/Objects/Drawables/DrawableHold.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (c) Alden Wu <[email protected]>. Licensed under the MIT Licence.
// See the LICENSE file in the repository root for full licence text.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
Expand All @@ -11,6 +13,7 @@
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Soyokaze.Judgements;
using osu.Game.Rulesets.Soyokaze.Skinning;
using osu.Game.Rulesets.Soyokaze.UI;
using osu.Game.Skinning;
Expand Down Expand Up @@ -169,6 +172,8 @@ protected override void UpdateHitStateTransforms(ArmedState state)
}
}

protected override JudgementResult CreateResult(Judgement judgement) => new SoyokazeHoldJudgementResult(HitObject, judgement);

protected override void CheckForResult(bool userTriggered, double timeOffset)
{
if (userTriggered || Time.Current < HitObject.EndTime)
Expand Down Expand Up @@ -207,7 +212,14 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
else
result = HitResult.Miss;

ApplyResult(r => r.Type = result);
ApplyResult(r =>
{
if (!(r is SoyokazeHoldJudgementResult hr))
throw new InvalidOperationException($"Expected result of type {nameof(SoyokazeHoldJudgementResult)}");

hr.Type = result;
hr.TrueTimeOffset = HoldCircle.TrueTimeOffset;
});
}

public override bool Hit(SoyokazeAction action)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public partial class DrawableHoldCircle : DrawableHitCircle
public new HoldCircle HitObject => (HoldCircle)base.HitObject;
public override bool DisplayResult => false;
public JudgementResult TrueResult { get; private set; }
public double TrueTimeOffset { get; private set; }

protected DrawableHold Hold => (DrawableHold)ParentHitObject;

Expand Down Expand Up @@ -43,6 +44,7 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
if (!HitObject.HitWindows.CanBeHit(timeOffset))
{
TrueResult = new JudgementResult(HitObject, new SoyokazeJudgement()) { Type = HitResult.Miss };
TrueTimeOffset = timeOffset;
ApplyResult(r => r.Type = HitResult.IgnoreMiss);
}
return;
Expand All @@ -58,6 +60,7 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
}

TrueResult = new JudgementResult(HitObject, new SoyokazeJudgement()) { Type = result };
TrueTimeOffset = timeOffset;
ApplyResult(r => r.Type = HitResult.IgnoreHit);
}

Expand Down
27 changes: 27 additions & 0 deletions osu.Game.Rulesets.Soyokaze/Scoring/SoyokazeScoreProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Alden Wu <[email protected]>. Licensed under the MIT Licence.
// See the LICENSE file in the repository root for full licence text.

using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Soyokaze.Judgements;

namespace osu.Game.Rulesets.Soyokaze.Scoring
{
public partial class SoyokazeScoreProcessor : ScoreProcessor
{
public SoyokazeScoreProcessor(Ruleset ruleset)
: base(ruleset)
{
}

protected override HitEvent CreateHitEvent(JudgementResult result)
{
var hitEvent = base.CreateHitEvent(result);

if (result is SoyokazeHoldJudgementResult hr)
hitEvent = new HitEvent(hr.TrueTimeOffset, hitEvent.Result, hitEvent.HitObject, hitEvent.LastHitObject, hitEvent.Position);

return hitEvent;
}
}
}
8 changes: 7 additions & 1 deletion osu.Game.Rulesets.Soyokaze/SoyokazeRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input.Bindings;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
Expand All @@ -25,6 +26,7 @@
using osu.Game.Rulesets.Soyokaze.Mods;
using osu.Game.Rulesets.Soyokaze.Objects;
using osu.Game.Rulesets.Soyokaze.Replays;
using osu.Game.Rulesets.Soyokaze.Scoring;
using osu.Game.Rulesets.Soyokaze.Skinning.Legacy;
using osu.Game.Rulesets.Soyokaze.Statistics;
using osu.Game.Rulesets.Soyokaze.UI;
Expand All @@ -51,6 +53,8 @@ public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) =>

public override IRulesetConfigManager CreateConfig(SettingsStore settings) => new SoyokazeConfigManager(settings, RulesetInfo);

public override ScoreProcessor CreateScoreProcessor() => new SoyokazeScoreProcessor(this);

public override RulesetSettingsSubsection CreateSettings() => new SoyokazeSettingsSubsection(this);

public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) =>
Expand Down Expand Up @@ -84,6 +88,8 @@ public override StatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatma
if (!(hitEvent.HitObject is SoyokazeHitObject soyokazeObject))
continue;

Logger.Log("OBJECT: " + hitEvent.HitObject.GetType());

HitEventsLists[(int)soyokazeObject.Button].Add(hitEvent);
}

Expand All @@ -101,7 +107,7 @@ public override StatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatma
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
};
Vector2[] positions = PositionExtensions.GetPositions(250, 130, true, Anchor.Centre);
Vector2[] positions = PositionExtensions.GetPositions(220, 110, true, Anchor.Centre);
for (int i = 0; i < positions.Length; i++)
accuracyGraphsContainer.Add(new AccuracyGraph(HitEventsLists[i]) { Position = positions[i] });
return accuracyGraphsContainer;
Expand Down
9 changes: 2 additions & 7 deletions osu.Game.Rulesets.Soyokaze/Statistics/AccuracyGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@ public AccuracyGraph(List<HitEvent> hitEvents)
{
Text = (calculateAccuracy(hitEvents) * 100).ToString("0.00") + "%",
Colour = Color4Extensions.FromHex("#66FFCC"),
Font = OsuFont.Torus.With(size: 56),
MaxWidth = 170f,
Font = OsuFont.Torus.With(size: 42),
AllowMultiline = false,

Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.8f, 0.4f),
},
new UnstableRate(hitEvents)
{
Expand All @@ -47,7 +44,7 @@ public AccuracyGraph(List<HitEvent> hitEvents)
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.8f, 0.13f),
},
new HitEventTimingDistributionGraph(hitEvents)
new MiniHitEventTimingDistributionGraph(hitEvents)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Expand All @@ -63,8 +60,6 @@ public AccuracyGraph(List<HitEvent> hitEvents)

Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.3f, 0.07f),
},
});
}
Expand Down
Loading

0 comments on commit 4fea45f

Please sign in to comment.