mirror of
https://github.com/ppy/osu.git
synced 2024-12-16 11:13:02 +08:00
Merge branch 'master' into select-tool
This commit is contained in:
commit
7d05840ee0
@ -1,146 +1,15 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editor
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneTimelineBlueprintContainer : EditorClockTestScene
|
||||
public class TestSceneTimelineBlueprintContainer : TimelineTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(TimelineArea),
|
||||
typeof(Timeline),
|
||||
typeof(TimelineButton),
|
||||
typeof(CentreMarker)
|
||||
};
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
Beatmap.Value = new WaveformTestBeatmap(audio);
|
||||
|
||||
var editorBeatmap = new EditorBeatmap((Beatmap<HitObject>)Beatmap.Value.Beatmap, BeatDivisor);
|
||||
|
||||
Dependencies.Cache(editorBeatmap);
|
||||
Dependencies.CacheAs<IBeatSnapProvider>(editorBeatmap);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new StartStopButton(),
|
||||
new AudioVisualiser(),
|
||||
}
|
||||
},
|
||||
new TimelineArea
|
||||
{
|
||||
Child = new TimelineBlueprintContainer(),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Size = new Vector2(0.8f, 100)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private class AudioVisualiser : CompositeDrawable
|
||||
{
|
||||
private readonly Drawable marker;
|
||||
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IAdjustableClock adjustableClock { get; set; }
|
||||
|
||||
public AudioVisualiser()
|
||||
{
|
||||
Size = new Vector2(250, 25);
|
||||
|
||||
InternalChildren = new[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0.25f,
|
||||
},
|
||||
marker = new Box
|
||||
{
|
||||
RelativePositionAxes = Axes.X,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 2,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (beatmap.Value.Track.IsLoaded)
|
||||
marker.X = (float)(adjustableClock.CurrentTime / beatmap.Value.Track.Length);
|
||||
}
|
||||
}
|
||||
|
||||
private class StartStopButton : OsuButton
|
||||
{
|
||||
private IAdjustableClock adjustableClock;
|
||||
private bool started;
|
||||
|
||||
public StartStopButton()
|
||||
{
|
||||
BackgroundColour = Color4.SlateGray;
|
||||
Size = new Vector2(100, 50);
|
||||
Text = "Start";
|
||||
|
||||
Action = onClick;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IAdjustableClock adjustableClock)
|
||||
{
|
||||
this.adjustableClock = adjustableClock;
|
||||
}
|
||||
|
||||
private void onClick()
|
||||
{
|
||||
if (started)
|
||||
{
|
||||
adjustableClock.Stop();
|
||||
Text = "Start";
|
||||
}
|
||||
else
|
||||
{
|
||||
adjustableClock.Start();
|
||||
Text = "Stop";
|
||||
}
|
||||
|
||||
started = !started;
|
||||
}
|
||||
}
|
||||
public override Drawable CreateTestComponent() => new TimelineBlueprintContainer();
|
||||
}
|
||||
}
|
||||
|
32
osu.Game.Tests/Visual/Editor/TestSceneTimelineTickDisplay.cs
Normal file
32
osu.Game.Tests/Visual/Editor/TestSceneTimelineTickDisplay.cs
Normal file
@ -0,0 +1,32 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editor
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneTimelineTickDisplay : TimelineTestScene
|
||||
{
|
||||
public override Drawable CreateTestComponent() => new TimelineTickDisplay();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
BeatDivisor.Value = 4;
|
||||
|
||||
Add(new BeatDivisorControl(BeatDivisor)
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Margin = new MarginPadding(30),
|
||||
Size = new Vector2(90)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
148
osu.Game.Tests/Visual/Editor/TimelineTestScene.cs
Normal file
148
osu.Game.Tests/Visual/Editor/TimelineTestScene.cs
Normal file
@ -0,0 +1,148 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editor
|
||||
{
|
||||
public abstract class TimelineTestScene : EditorClockTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(TimelineArea),
|
||||
typeof(Timeline),
|
||||
typeof(TimelineButton),
|
||||
typeof(CentreMarker)
|
||||
};
|
||||
|
||||
protected TimelineArea TimelineArea { get; private set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
Beatmap.Value = new WaveformTestBeatmap(audio);
|
||||
|
||||
var editorBeatmap = new EditorBeatmap((Beatmap<HitObject>)Beatmap.Value.Beatmap, BeatDivisor);
|
||||
|
||||
Dependencies.Cache(editorBeatmap);
|
||||
Dependencies.CacheAs<IBeatSnapProvider>(editorBeatmap);
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new StartStopButton(),
|
||||
new AudioVisualiser(),
|
||||
}
|
||||
},
|
||||
TimelineArea = new TimelineArea
|
||||
{
|
||||
Child = CreateTestComponent(),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Size = new Vector2(0.8f, 100),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public abstract Drawable CreateTestComponent();
|
||||
|
||||
private class AudioVisualiser : CompositeDrawable
|
||||
{
|
||||
private readonly Drawable marker;
|
||||
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IAdjustableClock adjustableClock { get; set; }
|
||||
|
||||
public AudioVisualiser()
|
||||
{
|
||||
Size = new Vector2(250, 25);
|
||||
|
||||
InternalChildren = new[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0.25f,
|
||||
},
|
||||
marker = new Box
|
||||
{
|
||||
RelativePositionAxes = Axes.X,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 2,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (beatmap.Value.Track.IsLoaded)
|
||||
marker.X = (float)(adjustableClock.CurrentTime / beatmap.Value.Track.Length);
|
||||
}
|
||||
}
|
||||
|
||||
private class StartStopButton : OsuButton
|
||||
{
|
||||
private IAdjustableClock adjustableClock;
|
||||
private bool started;
|
||||
|
||||
public StartStopButton()
|
||||
{
|
||||
BackgroundColour = Color4.SlateGray;
|
||||
Size = new Vector2(100, 50);
|
||||
Text = "Start";
|
||||
|
||||
Action = onClick;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IAdjustableClock adjustableClock)
|
||||
{
|
||||
this.adjustableClock = adjustableClock;
|
||||
}
|
||||
|
||||
private void onClick()
|
||||
{
|
||||
if (started)
|
||||
{
|
||||
adjustableClock.Stop();
|
||||
Text = "Start";
|
||||
}
|
||||
else
|
||||
{
|
||||
adjustableClock.Start();
|
||||
Text = "Stop";
|
||||
}
|
||||
|
||||
started = !started;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -52,30 +52,52 @@ namespace osu.Game.Screens.Edit
|
||||
{
|
||||
switch (beatDivisor)
|
||||
{
|
||||
case 1:
|
||||
return Color4.White;
|
||||
|
||||
case 2:
|
||||
return colours.BlueLight;
|
||||
return colours.Red;
|
||||
|
||||
case 4:
|
||||
return colours.Blue;
|
||||
|
||||
case 8:
|
||||
return colours.BlueDarker;
|
||||
return colours.Yellow;
|
||||
|
||||
case 16:
|
||||
return colours.PurpleDark;
|
||||
|
||||
case 3:
|
||||
return colours.YellowLight;
|
||||
return colours.Purple;
|
||||
|
||||
case 6:
|
||||
return colours.Yellow;
|
||||
return colours.YellowDark;
|
||||
|
||||
case 12:
|
||||
return colours.YellowDarker;
|
||||
|
||||
default:
|
||||
return Color4.White;
|
||||
return Color4.Red;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the applicable divisor for a specific beat index.
|
||||
/// </summary>
|
||||
/// <param name="index">The 0-based beat index.</param>
|
||||
/// <param name="beatDivisor">The beat divisor.</param>
|
||||
/// <returns>The applicable divisor.</returns>
|
||||
public static int GetDivisorForBeatIndex(int index, int beatDivisor)
|
||||
{
|
||||
int beat = index % beatDivisor;
|
||||
|
||||
foreach (var divisor in BindableBeatDivisor.VALID_DIVISORS)
|
||||
{
|
||||
if ((beat * divisor) % beatDivisor == 0)
|
||||
return divisor;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations
|
||||
/// </summary>
|
||||
public class PointVisualisation : Box
|
||||
{
|
||||
protected PointVisualisation(double startTime)
|
||||
public PointVisualisation(double startTime)
|
||||
{
|
||||
Origin = Anchor.TopCentre;
|
||||
|
||||
|
@ -130,19 +130,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// <returns>The applicable colour.</returns>
|
||||
protected ColourInfo GetColourForBeatIndex(int index)
|
||||
{
|
||||
int beat = (index + 1) % beatDivisor.Value;
|
||||
ColourInfo colour = Colours.Gray5;
|
||||
|
||||
for (int i = 0; i < BindableBeatDivisor.VALID_DIVISORS.Length; i++)
|
||||
{
|
||||
int divisor = BindableBeatDivisor.VALID_DIVISORS[i];
|
||||
|
||||
if ((beat * divisor) % beatDivisor.Value == 0)
|
||||
{
|
||||
colour = BindableBeatDivisor.GetColourFor(divisor, Colours);
|
||||
break;
|
||||
}
|
||||
}
|
||||
var colour = BindableBeatDivisor.GetColourFor(BindableBeatDivisor.GetDivisorForBeatIndex(index + 1, beatDivisor.Value), Colours);
|
||||
|
||||
int repeatIndex = index / beatDivisor.Value;
|
||||
return colour.MultiplyAlpha(0.5f / (repeatIndex + 1));
|
||||
|
@ -30,7 +30,10 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
ZoomDuration = 200;
|
||||
ZoomEasing = Easing.OutQuint;
|
||||
Zoom = 10;
|
||||
|
||||
Zoom = 60;
|
||||
MaxZoom = 240;
|
||||
|
||||
ScrollbarVisible = false;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,90 @@
|
||||
// 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.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
|
||||
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
public class TimelineTickDisplay : TimelinePart
|
||||
{
|
||||
[Resolved]
|
||||
private EditorBeatmap beatmap { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private Bindable<WorkingBeatmap> working { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private BindableBeatDivisor beatDivisor { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
public TimelineTickDisplay()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
beatDivisor.BindValueChanged(_ => createLines(), true);
|
||||
}
|
||||
|
||||
private void createLines()
|
||||
{
|
||||
Clear();
|
||||
|
||||
for (var i = 0; i < beatmap.ControlPointInfo.TimingPoints.Count; i++)
|
||||
{
|
||||
var point = beatmap.ControlPointInfo.TimingPoints[i];
|
||||
var until = beatmap.ControlPointInfo.TimingPoints.Count < i + 1 ? beatmap.ControlPointInfo.TimingPoints[i + 1].Time : working.Value.Track.Length;
|
||||
|
||||
int beat = 0;
|
||||
|
||||
for (double t = point.Time; t < until; t += point.BeatLength / beatDivisor.Value)
|
||||
{
|
||||
var indexInBeat = beat % beatDivisor.Value;
|
||||
|
||||
if (indexInBeat == 0)
|
||||
{
|
||||
Add(new PointVisualisation(t)
|
||||
{
|
||||
Colour = BindableBeatDivisor.GetColourFor(1, colours),
|
||||
Origin = Anchor.TopCentre,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var divisor = BindableBeatDivisor.GetDivisorForBeatIndex(beat, beatDivisor.Value);
|
||||
var colour = BindableBeatDivisor.GetColourFor(divisor, colours);
|
||||
var height = 0.1f - (float)divisor / BindableBeatDivisor.VALID_DIVISORS.Last() * 0.08f;
|
||||
|
||||
Add(new PointVisualisation(t)
|
||||
{
|
||||
Colour = colour,
|
||||
Height = height,
|
||||
Origin = Anchor.TopCentre,
|
||||
});
|
||||
|
||||
Add(new PointVisualisation(t)
|
||||
{
|
||||
Colour = colour,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Height = height,
|
||||
});
|
||||
}
|
||||
|
||||
beat++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -102,7 +102,11 @@ namespace osu.Game.Screens.Edit
|
||||
LoadComponentAsync(new TimelineArea
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = CreateTimelineContent()
|
||||
Children = new[]
|
||||
{
|
||||
new TimelineTickDisplay(),
|
||||
CreateTimelineContent(),
|
||||
}
|
||||
}, timelineContainer.Add);
|
||||
});
|
||||
}
|
||||
|
@ -117,9 +117,20 @@ namespace osu.Game.Screens.Select.Details
|
||||
mod.ApplyToDifficulty(adjustedDifficulty);
|
||||
}
|
||||
|
||||
// Account for mania differences
|
||||
firstValue.Title = (Beatmap?.Ruleset?.ID ?? 0) == 3 ? "Key Amount" : "Circle Size";
|
||||
firstValue.Value = (baseDifficulty?.CircleSize ?? 0, adjustedDifficulty?.CircleSize);
|
||||
switch (Beatmap?.Ruleset?.ID ?? 0)
|
||||
{
|
||||
case 3:
|
||||
// Account for mania differences locally for now
|
||||
// Eventually this should be handled in a more modular way, allowing rulesets to return arbitrary difficulty attributes
|
||||
firstValue.Title = "Key Count";
|
||||
firstValue.Value = (baseDifficulty?.CircleSize ?? 0, null);
|
||||
break;
|
||||
|
||||
default:
|
||||
firstValue.Title = "Circle Size";
|
||||
firstValue.Value = (baseDifficulty?.CircleSize ?? 0, adjustedDifficulty?.CircleSize);
|
||||
break;
|
||||
}
|
||||
|
||||
starDifficulty.Value = ((float)(Beatmap?.StarDifficulty ?? 0), null);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user