mirror of
https://github.com/ppy/osu.git
synced 2025-03-11 15:27:20 +08:00
Move back to using load(), fix testcase
This commit is contained in:
parent
d998936e9e
commit
ab762045d6
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -18,26 +19,10 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(SelectionLayer) };
|
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(SelectionLayer) };
|
||||||
|
|
||||||
public TestCaseEditorSelectionLayer()
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
{
|
{
|
||||||
var playfield = new OsuEditPlayfield
|
var playfield = new OsuEditPlayfield();
|
||||||
{
|
|
||||||
new DrawableHitCircle(new HitCircle { Position = new Vector2(256, 192), Scale = 0.5f }),
|
|
||||||
new DrawableHitCircle(new HitCircle { Position = new Vector2(344, 148), Scale = 0.5f }),
|
|
||||||
new DrawableSlider(new Slider
|
|
||||||
{
|
|
||||||
ControlPoints = new List<Vector2>
|
|
||||||
{
|
|
||||||
new Vector2(128, 256),
|
|
||||||
new Vector2(344, 256),
|
|
||||||
},
|
|
||||||
Distance = 400,
|
|
||||||
Position = new Vector2(128, 256),
|
|
||||||
Velocity = 1,
|
|
||||||
TickDistance = 100,
|
|
||||||
Scale = 0.5f
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -49,6 +34,22 @@ namespace osu.Game.Tests.Visual
|
|||||||
},
|
},
|
||||||
new SelectionLayer(playfield)
|
new SelectionLayer(playfield)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
playfield.Add(new DrawableHitCircle(new HitCircle { Position = new Vector2(256, 192), Scale = 0.5f }));
|
||||||
|
playfield.Add(new DrawableHitCircle(new HitCircle { Position = new Vector2(344, 148), Scale = 0.5f }));
|
||||||
|
playfield.Add(new DrawableSlider(new Slider
|
||||||
|
{
|
||||||
|
ControlPoints = new List<Vector2>
|
||||||
|
{
|
||||||
|
new Vector2(128, 256),
|
||||||
|
new Vector2(344, 256),
|
||||||
|
},
|
||||||
|
Distance = 400,
|
||||||
|
Position = new Vector2(128, 256),
|
||||||
|
Velocity = 1,
|
||||||
|
TickDistance = 100,
|
||||||
|
Scale = 0.5f
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -13,7 +13,6 @@ using osu.Game.Rulesets.Objects.Drawables;
|
|||||||
using osu.Game.Rulesets.Timing;
|
using osu.Game.Rulesets.Timing;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
using OpenTK.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
@ -21,39 +20,29 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Playfield) };
|
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Playfield) };
|
||||||
|
|
||||||
private readonly List<TestPlayfield> playfields = new List<TestPlayfield>();
|
private readonly TestPlayfield[] playfields = new TestPlayfield[4];
|
||||||
|
|
||||||
public TestCaseScrollingHitObjects()
|
public TestCaseScrollingHitObjects()
|
||||||
{
|
{
|
||||||
playfields.Add(new TestPlayfield(ScrollingDirection.Down));
|
Add(new GridContainer
|
||||||
playfields.Add(new TestPlayfield(ScrollingDirection.Right));
|
|
||||||
|
|
||||||
playfields.ForEach(p => p.HitObjects.AddControlPoint(new MultiplierControlPoint(double.MinValue)));
|
|
||||||
|
|
||||||
Add(new Container
|
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Size = new Vector2(0.85f),
|
Content = new[]
|
||||||
Masking = true,
|
|
||||||
BorderColour = Color4.White,
|
|
||||||
BorderThickness = 2,
|
|
||||||
MaskingSmoothness = 1,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
new Box
|
new Drawable[]
|
||||||
{
|
{
|
||||||
Name = "Background",
|
playfields[0] = new TestPlayfield(ScrollingDirection.Up),
|
||||||
RelativeSizeAxes = Axes.Both,
|
playfields[1] = new TestPlayfield(ScrollingDirection.Down)
|
||||||
Alpha = 0.35f,
|
|
||||||
},
|
},
|
||||||
playfields[0],
|
new Drawable[]
|
||||||
playfields[1]
|
{
|
||||||
|
playfields[2] = new TestPlayfield(ScrollingDirection.Left),
|
||||||
|
playfields[3] = new TestPlayfield(ScrollingDirection.Right)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AddSliderStep("Time range", 100, 10000, 5000, v => playfields.ForEach(p => p.TimeRange.Value = v));
|
AddSliderStep("Time range", 100, 10000, 5000, v => playfields.ForEach(p => p.VisibleTimeRange.Value = v));
|
||||||
AddStep("Add control point", () => addControlPoint(Time.Current + 5000));
|
AddStep("Add control point", () => addControlPoint(Time.Current + 5000));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,6 +50,8 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
|
playfields.ForEach(p => p.HitObjects.AddControlPoint(new MultiplierControlPoint(0)));
|
||||||
|
|
||||||
for (int i = 0; i <= 5000; i += 1000)
|
for (int i = 0; i <= 5000; i += 1000)
|
||||||
addHitObject(Time.Current + i);
|
addHitObject(Time.Current + i);
|
||||||
|
|
||||||
@ -71,10 +62,10 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
playfields.ForEach(p =>
|
playfields.ForEach(p =>
|
||||||
{
|
{
|
||||||
p.Add(new TestDrawableHitObject(time)
|
var hitObject = new TestDrawableHitObject(time);
|
||||||
{
|
setAnchor(hitObject, p);
|
||||||
Anchor = p.Direction == ScrollingDirection.Right ? Anchor.CentreRight : Anchor.BottomCentre
|
|
||||||
});
|
p.Add(hitObject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,10 +77,12 @@ namespace osu.Game.Tests.Visual
|
|||||||
p.HitObjects.AddControlPoint(new MultiplierControlPoint(time + 2000) { DifficultyPoint = { SpeedMultiplier = 2 } });
|
p.HitObjects.AddControlPoint(new MultiplierControlPoint(time + 2000) { DifficultyPoint = { SpeedMultiplier = 2 } });
|
||||||
p.HitObjects.AddControlPoint(new MultiplierControlPoint(time + 3000) { DifficultyPoint = { SpeedMultiplier = 1 } });
|
p.HitObjects.AddControlPoint(new MultiplierControlPoint(time + 3000) { DifficultyPoint = { SpeedMultiplier = 1 } });
|
||||||
|
|
||||||
TestDrawableControlPoint createDrawablePoint(double t) => new TestDrawableControlPoint(t)
|
TestDrawableControlPoint createDrawablePoint(double t)
|
||||||
{
|
{
|
||||||
Anchor = p.Direction == ScrollingDirection.Right ? Anchor.CentreRight : Anchor.BottomCentre
|
var obj = new TestDrawableControlPoint(p.Direction, t);
|
||||||
};
|
setAnchor(obj, p);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
p.Add(createDrawablePoint(time));
|
p.Add(createDrawablePoint(time));
|
||||||
p.Add(createDrawablePoint(time + 2000));
|
p.Add(createDrawablePoint(time + 2000));
|
||||||
@ -97,12 +90,28 @@ namespace osu.Game.Tests.Visual
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setAnchor(DrawableHitObject obj, TestPlayfield playfield)
|
||||||
|
{
|
||||||
|
switch (playfield.Direction)
|
||||||
|
{
|
||||||
|
case ScrollingDirection.Up:
|
||||||
|
obj.Anchor = Anchor.TopCentre;
|
||||||
|
break;
|
||||||
|
case ScrollingDirection.Down:
|
||||||
|
obj.Anchor = Anchor.BottomCentre;
|
||||||
|
break;
|
||||||
|
case ScrollingDirection.Left:
|
||||||
|
obj.Anchor = Anchor.CentreLeft;
|
||||||
|
break;
|
||||||
|
case ScrollingDirection.Right:
|
||||||
|
obj.Anchor = Anchor.CentreRight;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private class TestPlayfield : ScrollingPlayfield
|
private class TestPlayfield : ScrollingPlayfield
|
||||||
{
|
{
|
||||||
public readonly BindableDouble TimeRange = new BindableDouble(5000);
|
|
||||||
|
|
||||||
public readonly ScrollingDirection Direction;
|
public readonly ScrollingDirection Direction;
|
||||||
|
|
||||||
public TestPlayfield(ScrollingDirection direction)
|
public TestPlayfield(ScrollingDirection direction)
|
||||||
@ -110,34 +119,45 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
Direction = direction;
|
Direction = direction;
|
||||||
|
|
||||||
HitObjects.TimeRange.BindTo(TimeRange);
|
Padding = new MarginPadding(2);
|
||||||
|
ScaledContent.Masking = true;
|
||||||
|
|
||||||
|
AddInternal(new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0.5f,
|
||||||
|
Depth = float.MaxValue
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestDrawableControlPoint : DrawableHitObject<HitObject>
|
private class TestDrawableControlPoint : DrawableHitObject<HitObject>
|
||||||
{
|
{
|
||||||
private readonly Box box;
|
public TestDrawableControlPoint(ScrollingDirection direction, double time)
|
||||||
|
|
||||||
public TestDrawableControlPoint(double time)
|
|
||||||
: base(new HitObject { StartTime = time })
|
: base(new HitObject { StartTime = time })
|
||||||
{
|
{
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
Add(box = new Box
|
Add(new Box
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
switch (direction)
|
||||||
{
|
{
|
||||||
base.Update();
|
case ScrollingDirection.Up:
|
||||||
|
case ScrollingDirection.Down:
|
||||||
RelativeSizeAxes = (Anchor & Anchor.x2) > 0 ? Axes.Y : Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Size = new Vector2(1);
|
Height = 2;
|
||||||
|
break;
|
||||||
box.Size = DrawSize;
|
case ScrollingDirection.Left:
|
||||||
|
case ScrollingDirection.Right:
|
||||||
|
RelativeSizeAxes = Axes.Y;
|
||||||
|
Width = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateState(ArmedState state)
|
protected override void UpdateState(ArmedState state)
|
||||||
|
@ -49,14 +49,14 @@ namespace osu.Game.Rulesets.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
HitObjects = CreateHitObjectContainer();
|
|
||||||
HitObjects.RelativeSizeAxes = Axes.Both;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
|
HitObjects = CreateHitObjectContainer();
|
||||||
|
HitObjects.RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
Add(HitObjects);
|
Add(HitObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user