Skip to content

Commit bd4902a

Browse files
authored
Merge pull request #358 from peppy/spinners
Add spinners and improve TestCaseHitObjects.
2 parents ba7b615 + d570a6d commit bd4902a

26 files changed

Lines changed: 579 additions & 82 deletions

osu-framework

Submodule osu-framework updated 266 files
Lines changed: 105 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,148 @@
11
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
22
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
33

4+
using System.Collections.Generic;
45
using osu.Framework;
56
using osu.Framework.GameModes.Testing;
67
using osu.Framework.Graphics;
78
using osu.Framework.Timing;
89
using OpenTK;
910
using osu.Framework.Allocation;
11+
using osu.Framework.Configuration;
1012
using osu.Game.Modes.Objects;
1113
using osu.Game.Modes.Objects.Drawables;
1214
using osu.Game.Modes.Osu.Objects;
1315
using osu.Game.Modes.Osu.Objects.Drawables;
1416
using osu.Framework.Graphics.Containers;
17+
using osu.Framework.Graphics.Sprites;
18+
using osu.Framework.Graphics.UserInterface;
1519
using osu.Game.Modes;
20+
using OpenTK.Graphics;
1621

1722
namespace osu.Desktop.VisualTests.Tests
1823
{
1924
class TestCaseHitObjects : TestCase
2025
{
2126
public override string Name => @"Hit Objects";
2227

28+
private StopwatchClock rateAdjustClock;
29+
private FramedClock framedClock;
30+
31+
bool auto = false;
32+
2333
public TestCaseHitObjects()
2434
{
25-
var swClock = new StopwatchClock(true) { Rate = 0.2f };
26-
Clock = new FramedClock(swClock);
35+
rateAdjustClock = new StopwatchClock(true);
36+
framedClock = new FramedClock(rateAdjustClock);
37+
playbackSpeed.ValueChanged += delegate { rateAdjustClock.Rate = playbackSpeed.Value; };
38+
}
39+
40+
HitObjectType mode = HitObjectType.Spinner;
41+
42+
BindableNumber<double> playbackSpeed = new BindableDouble(0.5) { MinValue = 0, MaxValue = 1 };
43+
private Container playfieldContainer;
44+
private Container approachContainer;
45+
46+
private void load(HitObjectType mode)
47+
{
48+
this.mode = mode;
49+
50+
switch (mode)
51+
{
52+
case HitObjectType.Circle:
53+
const int count = 10;
54+
55+
for (int i = 0; i < count; i++)
56+
{
57+
var h = new HitCircle
58+
{
59+
StartTime = framedClock.CurrentTime + 600 + i * 80,
60+
Position = new Vector2((i - count / 2) * 14),
61+
};
62+
63+
add(new DrawableHitCircle(h));
64+
}
65+
break;
66+
case HitObjectType.Slider:
67+
add(new DrawableSlider(new Slider
68+
{
69+
StartTime = framedClock.CurrentTime + 600,
70+
ControlPoints = new List<Vector2>()
71+
{
72+
new Vector2(-200, 0),
73+
new Vector2(400, 0),
74+
},
75+
Length = 400,
76+
Position = new Vector2(-200, 0),
77+
Velocity = 1,
78+
}));
79+
break;
80+
case HitObjectType.Spinner:
81+
add(new DrawableSpinner(new Spinner
82+
{
83+
StartTime = framedClock.CurrentTime + 600,
84+
Length = 1000,
85+
Position = new Vector2(0, 0),
86+
}));
87+
break;
88+
}
2789
}
2890

2991
public override void Reset()
3092
{
3193
base.Reset();
3294

33-
Clock.ProcessFrame();
95+
playbackSpeed.TriggerChange();
3496

35-
Container approachContainer = new Container { Depth = float.MinValue, };
97+
AddButton(@"circles", () => load(HitObjectType.Circle));
98+
AddButton(@"slider", () => load(HitObjectType.Slider));
99+
AddButton(@"spinner", () => load(HitObjectType.Spinner));
36100

37-
Add(approachContainer);
101+
AddToggle(@"auto", () => { auto = !auto; load(mode); });
38102

39-
const int count = 10;
103+
ButtonsContainer.Add(new SpriteText { Text = "Playback Speed" });
104+
ButtonsContainer.Add(new BasicSliderBar<double>
105+
{
106+
Width = 150,
107+
Height = 10,
108+
SelectionColor = Color4.Orange,
109+
Bindable = playbackSpeed
110+
});
40111

41-
for (int i = 0; i < count; i++)
112+
framedClock.ProcessFrame();
113+
114+
var clockAdjustContainer = new Container
42115
{
43-
var h = new HitCircle
116+
RelativeSizeAxes = Axes.Both,
117+
Clock = framedClock,
118+
Children = new[]
44119
{
45-
StartTime = Clock.CurrentTime + 600 + i * 80,
46-
Position = new Vector2((i - count / 2) * 14),
47-
};
120+
playfieldContainer = new Container { RelativeSizeAxes = Axes.Both },
121+
approachContainer = new Container { RelativeSizeAxes = Axes.Both }
122+
}
123+
};
48124

49-
DrawableHitCircle d = new DrawableHitCircle(h)
50-
{
51-
Anchor = Anchor.Centre,
52-
Depth = i,
53-
State = ArmedState.Hit,
54-
Judgement = new OsuJudgementInfo { Result = HitResult.Hit }
55-
};
125+
Add(clockAdjustContainer);
56126

127+
load(mode);
128+
}
129+
130+
int depth;
131+
void add(DrawableHitObject h)
132+
{
133+
h.Anchor = Anchor.Centre;
134+
h.Depth = depth++;
57135

58-
approachContainer.Add(d.ApproachCircle.CreateProxy());
59-
Add(d);
136+
if (auto)
137+
{
138+
h.State = ArmedState.Hit;
139+
h.Judgement = new OsuJudgementInfo { Result = HitResult.Hit };
60140
}
141+
142+
playfieldContainer.Add(h);
143+
var proxyable = h as IDrawableHitObjectWithProxiedApproach;
144+
if (proxyable != null)
145+
approachContainer.Add(proxyable.ProxiedLayer.CreateProxy());
61146
}
62147
}
63148
}

osu.Game.Modes.Catch/CatchRuleset.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ public class CatchRuleset : Ruleset
2424

2525
public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => null;
2626

27-
public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();
27+
public override HitObjectParser CreateHitObjectParser() => new NullHitObjectParser();
2828
}
2929
}

osu.Game.Modes.Mania/ManiaRuleset.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public class ManiaRuleset : Ruleset
2525

2626
public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => null;
2727

28-
public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();
28+
public override HitObjectParser CreateHitObjectParser() => new NullHitObjectParser();
2929
}
3030
}

osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
33

44
using System;
5-
using System.ComponentModel;
65
using osu.Framework.Graphics;
76
using osu.Framework.Graphics.Transformations;
87
using osu.Game.Modes.Objects.Drawables;
@@ -11,9 +10,9 @@
1110

1211
namespace osu.Game.Modes.Osu.Objects.Drawables
1312
{
14-
public class DrawableHitCircle : DrawableOsuHitObject
13+
public class DrawableHitCircle : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach
1514
{
16-
private HitCircle osuObject;
15+
private OsuHitObject osuObject;
1716

1817
public ApproachCircle ApproachCircle;
1918
private CirclePiece circle;
@@ -23,11 +22,12 @@ public class DrawableHitCircle : DrawableOsuHitObject
2322
private NumberPiece number;
2423
private GlowPiece glow;
2524

26-
public DrawableHitCircle(HitCircle h) : base(h)
25+
public DrawableHitCircle(OsuHitObject h) : base(h)
2726
{
27+
Origin = Anchor.Centre;
28+
2829
osuObject = h;
2930

30-
Origin = Anchor.Centre;
3131
Position = osuObject.StackedPosition;
3232
Scale = new Vector2(osuObject.Scale);
3333

@@ -156,5 +156,7 @@ protected override void UpdateState(ArmedState state)
156156
break;
157157
}
158158
}
159+
160+
public Drawable ProxiedLayer => ApproachCircle;
159161
}
160162
}

osu.Game.Modes.Osu/Objects/Drawables/DrawableOsuHitObject.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.ComponentModel;
55
using osu.Game.Modes.Objects;
66
using osu.Game.Modes.Objects.Drawables;
7+
using osu.Framework.Graphics;
78

89
namespace osu.Game.Modes.Osu.Objects.Drawables
910
{

osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
using osu.Game.Modes.Objects.Drawables;
77
using osu.Game.Modes.Osu.Objects.Drawables.Pieces;
88
using OpenTK;
9-
using osu.Framework.Input;
109

1110
namespace osu.Game.Modes.Osu.Objects.Drawables
1211
{
13-
class DrawableSlider : DrawableOsuHitObject
12+
public class DrawableSlider : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach
1413
{
1514
private Slider slider;
1615

@@ -133,6 +132,8 @@ protected override void UpdateState(ArmedState state)
133132

134133
FadeOut(800);
135134
}
135+
136+
public Drawable ProxiedLayer => initialCircle.ApproachCircle;
136137
}
137138

138139
internal interface ISliderProgress

0 commit comments

Comments
 (0)