forked from ppy/osu-tools
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathOsuObjectInspectorRuleset.cs
More file actions
122 lines (99 loc) · 4.9 KB
/
OsuObjectInspectorRuleset.cs
File metadata and controls
122 lines (99 loc) · 4.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
using osu.Game.Rulesets.Osu.Edit;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Osu.UI;
using osu.Game.Rulesets.UI;
namespace PerformanceCalculatorGUI.Screens.ObjectInspection
{
public partial class OsuObjectInspectorRuleset : DrawableOsuEditorRuleset
{
private OsuDifficultyHitObject[] difficultyHitObjects = [];
[Resolved]
private ObjectDifficultyValuesContainer objectDifficultyValuesContainer { get; set; } = null!;
[Resolved]
private Bindable<DifficultyCalculator?> difficultyCalculator { get; set; } = null!;
public OsuObjectInspectorRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods)
: base(ruleset, beatmap, mods)
{
}
protected override void LoadComplete()
{
var extendedDifficultyCalculator = (IExtendedDifficultyCalculator?)difficultyCalculator.Value;
if (extendedDifficultyCalculator != null)
{
difficultyHitObjects = extendedDifficultyCalculator.GetDifficultyHitObjects().Cast<OsuDifficultyHitObject>().ToArray();
}
base.LoadComplete();
}
protected override void Update()
{
base.Update();
objectDifficultyValuesContainer.CurrentDifficultyHitObject.Value = difficultyHitObjects.LastOrDefault(x => x.BaseObject.StartTime <= Clock.CurrentTime);
}
public override bool PropagatePositionalInputSubTree => false;
public override bool PropagateNonPositionalInputSubTree => false;
protected override Playfield CreatePlayfield() => new OsuObjectInspectorPlayfield(difficultyHitObjects);
private partial class OsuObjectInspectorPlayfield : OsuPlayfield
{
private readonly IReadOnlyList<OsuDifficultyHitObject> difficultyHitObjects;
protected override GameplayCursorContainer? CreateCursor() => null;
public OsuObjectInspectorPlayfield(IReadOnlyList<OsuDifficultyHitObject> difficultyHitObjects)
{
this.difficultyHitObjects = difficultyHitObjects;
HitPolicy = new AnyOrderHitPolicy();
DisplayJudgements.Value = false;
}
protected override void OnNewDrawableHitObject(DrawableHitObject d)
{
base.OnNewDrawableHitObject(d);
d.ApplyCustomUpdateState += updateState;
}
private void updateState(DrawableHitObject hitObject, ArmedState state)
{
if (hitObject is DrawableSliderRepeat repeat)
{
repeat.Arrow.ApplyTransformsAt(hitObject.StateUpdateTime, true);
repeat.Arrow.ClearTransformsAfter(hitObject.StateUpdateTime, true);
}
// adjust the visuals of top-level object types to make them stay on screen for longer than usual.
switch (hitObject)
{
case DrawableSlider:
case DrawableHitCircle:
var nextHitObject = difficultyHitObjects.FirstOrDefault(x => x.BaseObject.StartTime > hitObject.StartTimeBindable.Value)?.BaseObject;
if (nextHitObject != null)
{
// Get the existing fade out transform
var existing = hitObject.Transforms.LastOrDefault(t => t.TargetMember == nameof(Alpha));
if (existing == null)
return;
hitObject.RemoveTransform(existing);
using (hitObject.BeginAbsoluteSequence(hitObject.StartTimeBindable.Value))
{
double hitObjectDuration = hitObject.HitObject.GetEndTime() - hitObject.StartTimeBindable.Value;
hitObject.Delay(hitObjectDuration)
.FadeTo(0.25f, 200f, Easing.Out)
.Delay(nextHitObject.StartTimeBindable.Value - hitObject.StartTimeBindable.Value - hitObjectDuration)
.FadeOut(100f, Easing.Out)
.Expire();
}
}
break;
}
}
}
}
}