2017-06-12 16:31:24 +08:00
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
using OpenTK;
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-06-20 13:54:23 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-06-12 16:31:24 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
using osu.Framework.Testing;
|
2017-06-15 14:06:38 +08:00
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-06-12 16:31:24 +08:00
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.Timing;
|
|
|
|
|
|
|
|
namespace osu.Desktop.VisualTests.Tests
|
|
|
|
{
|
|
|
|
public class TestCaseScrollingHitObjects : TestCase
|
|
|
|
{
|
|
|
|
public override string Description => "SpeedAdjustmentContainer/DrawableTimingSection";
|
|
|
|
|
2017-07-08 17:17:47 +08:00
|
|
|
private readonly BindableDouble timeRangeBindable;
|
|
|
|
private readonly OsuSpriteText bottomLabel;
|
|
|
|
private readonly SpriteText topTime;
|
|
|
|
private readonly SpriteText bottomTime;
|
2017-06-12 16:31:24 +08:00
|
|
|
|
2017-07-07 20:05:55 +08:00
|
|
|
public TestCaseScrollingHitObjects()
|
2017-06-12 16:31:24 +08:00
|
|
|
{
|
2017-07-08 17:17:47 +08:00
|
|
|
OsuSpriteText timeRangeText;
|
|
|
|
SpeedAdjustmentCollection adjustmentCollection;
|
|
|
|
|
2017-06-12 16:31:24 +08:00
|
|
|
timeRangeBindable = new BindableDouble(2000)
|
|
|
|
{
|
2017-06-15 13:16:47 +08:00
|
|
|
MinValue = 200,
|
|
|
|
MaxValue = 4000,
|
2017-06-12 16:31:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
SliderBar<double> timeRange;
|
|
|
|
Add(timeRange = new BasicSliderBar<double>
|
|
|
|
{
|
|
|
|
Size = new Vector2(200, 20),
|
|
|
|
SelectionColor = Color4.Pink,
|
|
|
|
KeyboardStep = 100
|
|
|
|
});
|
|
|
|
|
2017-06-15 14:06:38 +08:00
|
|
|
Add(timeRangeText = new OsuSpriteText
|
2017-06-12 16:31:24 +08:00
|
|
|
{
|
|
|
|
X = 210,
|
|
|
|
TextSize = 16,
|
|
|
|
});
|
|
|
|
|
|
|
|
timeRange.Current.BindTo(timeRangeBindable);
|
2017-06-15 13:40:30 +08:00
|
|
|
timeRangeBindable.ValueChanged += v => timeRangeText.Text = $"Visible Range: {v:#,#.#}";
|
|
|
|
timeRangeBindable.ValueChanged += v => bottomLabel.Text = $"t minus {v:#,#}";
|
2017-06-12 16:31:24 +08:00
|
|
|
|
2017-07-11 21:58:06 +08:00
|
|
|
AddRange(new Drawable[]
|
2017-06-12 16:31:24 +08:00
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Size = new Vector2(100, 500),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Alpha = 0.25f
|
|
|
|
},
|
2017-06-16 12:00:08 +08:00
|
|
|
adjustmentCollection = new SpeedAdjustmentCollection(Axes.Y)
|
2017-06-12 16:31:24 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-06-15 14:06:38 +08:00
|
|
|
VisibleTimeRange = timeRangeBindable,
|
|
|
|
Masking = true,
|
2017-06-15 13:40:30 +08:00
|
|
|
},
|
2017-06-15 14:06:38 +08:00
|
|
|
new OsuSpriteText
|
2017-06-15 13:40:30 +08:00
|
|
|
{
|
|
|
|
Text = "t minus 0",
|
2017-06-15 14:06:38 +08:00
|
|
|
Margin = new MarginPadding(2),
|
2017-06-15 13:40:30 +08:00
|
|
|
TextSize = 14,
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
},
|
2017-06-15 14:06:38 +08:00
|
|
|
bottomLabel = new OsuSpriteText
|
2017-06-15 13:40:30 +08:00
|
|
|
{
|
|
|
|
Text = "t minus x",
|
2017-06-15 14:06:38 +08:00
|
|
|
Margin = new MarginPadding(2),
|
2017-06-15 13:40:30 +08:00
|
|
|
TextSize = 14,
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
},
|
2017-06-15 14:06:38 +08:00
|
|
|
topTime = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Margin = new MarginPadding(2),
|
|
|
|
TextSize = 14,
|
|
|
|
Anchor = Anchor.TopLeft,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
},
|
|
|
|
bottomTime = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Margin = new MarginPadding(2),
|
|
|
|
TextSize = 14,
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomRight,
|
|
|
|
},
|
2017-06-12 16:31:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-06-15 13:40:30 +08:00
|
|
|
timeRangeBindable.TriggerChange();
|
|
|
|
|
2017-06-12 16:31:24 +08:00
|
|
|
adjustmentCollection.Add(new TestSpeedAdjustmentContainer(new MultiplierControlPoint()));
|
|
|
|
|
2017-06-15 13:16:47 +08:00
|
|
|
AddStep("Add hit object", () => adjustmentCollection.Add(new TestDrawableHitObject(new HitObject { StartTime = Time.Current + 2000 })));
|
2017-06-12 16:31:24 +08:00
|
|
|
}
|
|
|
|
|
2017-06-15 14:06:38 +08:00
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
2017-06-15 14:17:05 +08:00
|
|
|
|
2017-06-15 14:06:38 +08:00
|
|
|
topTime.Text = Time.Current.ToString("#,#");
|
|
|
|
bottomTime.Text = (Time.Current + timeRangeBindable.Value).ToString("#,#");
|
|
|
|
}
|
|
|
|
|
2017-06-12 16:31:24 +08:00
|
|
|
private class TestSpeedAdjustmentContainer : SpeedAdjustmentContainer
|
|
|
|
{
|
2017-06-16 18:21:54 +08:00
|
|
|
public override bool RemoveWhenNotAlive => false;
|
|
|
|
|
2017-06-12 16:31:24 +08:00
|
|
|
public TestSpeedAdjustmentContainer(MultiplierControlPoint controlPoint)
|
2017-06-16 12:00:08 +08:00
|
|
|
: base(controlPoint)
|
2017-06-12 16:31:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-06-16 12:12:36 +08:00
|
|
|
protected override DrawableTimingSection CreateTimingSection() => new TestDrawableTimingSection(ControlPoint);
|
2017-06-12 16:31:24 +08:00
|
|
|
|
|
|
|
private class TestDrawableTimingSection : DrawableTimingSection
|
|
|
|
{
|
|
|
|
private readonly MultiplierControlPoint controlPoint;
|
|
|
|
|
|
|
|
public TestDrawableTimingSection(MultiplierControlPoint controlPoint)
|
|
|
|
{
|
|
|
|
this.controlPoint = controlPoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
Y = (float)(controlPoint.StartTime - Time.Current);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-19 09:54:23 +08:00
|
|
|
private class TestDrawableHitObject : DrawableHitObject, IScrollingHitObject
|
2017-06-12 16:31:24 +08:00
|
|
|
{
|
2017-06-15 14:17:05 +08:00
|
|
|
private readonly Box background;
|
2017-06-15 14:06:38 +08:00
|
|
|
private const float height = 14;
|
|
|
|
|
2017-06-19 09:54:23 +08:00
|
|
|
public BindableDouble LifetimeOffset { get; } = new BindableDouble();
|
|
|
|
|
2017-06-12 16:31:24 +08:00
|
|
|
public TestDrawableHitObject(HitObject hitObject)
|
|
|
|
: base(hitObject)
|
|
|
|
{
|
2017-06-15 13:36:41 +08:00
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2017-06-12 16:31:24 +08:00
|
|
|
RelativePositionAxes = Axes.Y;
|
2017-06-15 13:36:41 +08:00
|
|
|
|
2017-06-12 16:31:24 +08:00
|
|
|
Y = (float)hitObject.StartTime;
|
|
|
|
|
2017-06-15 14:06:38 +08:00
|
|
|
Children = new Drawable[]
|
2017-06-12 16:31:24 +08:00
|
|
|
{
|
2017-06-15 14:17:05 +08:00
|
|
|
background = new Box
|
2017-06-15 14:06:38 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = height,
|
|
|
|
},
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Colour = Color4.Cyan,
|
|
|
|
Height = 1,
|
|
|
|
},
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Colour = Color4.Black,
|
|
|
|
TextSize = height,
|
|
|
|
Font = @"Exo2.0-BoldItalic",
|
|
|
|
Text = $"{hitObject.StartTime:#,#}"
|
|
|
|
}
|
|
|
|
};
|
2017-06-12 16:31:24 +08:00
|
|
|
}
|
2017-06-15 14:17:05 +08:00
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
FadeInFromZero(250, EasingTypes.OutQuint);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
if (Time.Current >= HitObject.StartTime)
|
|
|
|
background.Colour = Color4.Red;
|
|
|
|
}
|
2017-06-12 16:31:24 +08:00
|
|
|
}
|
|
|
|
}
|
2017-06-15 14:06:38 +08:00
|
|
|
}
|