mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 03:02:54 +08:00
Merge remote-tracking branch 'refs/remotes/ppy/master' into overlay-headers-update-three
This commit is contained in:
commit
0f331e81f6
@ -33,8 +33,8 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
typeof(CircularDistanceSnapGrid)
|
typeof(CircularDistanceSnapGrid)
|
||||||
};
|
};
|
||||||
|
|
||||||
[Cached(typeof(IEditorBeatmap))]
|
[Cached(typeof(EditorBeatmap))]
|
||||||
private readonly EditorBeatmap<OsuHitObject> editorBeatmap;
|
private readonly EditorBeatmap editorBeatmap;
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor();
|
private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor();
|
||||||
@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
|
|
||||||
public TestSceneOsuDistanceSnapGrid()
|
public TestSceneOsuDistanceSnapGrid()
|
||||||
{
|
{
|
||||||
editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap());
|
editorBeatmap = new EditorBeatmap(new OsuBeatmap());
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
|
@ -91,10 +91,10 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
if (sourceIndex == -1)
|
if (sourceIndex == -1)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
OsuHitObject sourceObject = EditorBeatmap.HitObjects[sourceIndex];
|
HitObject sourceObject = EditorBeatmap.HitObjects[sourceIndex];
|
||||||
|
|
||||||
int targetIndex = sourceIndex + targetOffset;
|
int targetIndex = sourceIndex + targetOffset;
|
||||||
OsuHitObject targetObject = null;
|
HitObject targetObject = null;
|
||||||
|
|
||||||
// Keep advancing the target object while its start time falls before the end time of the source object
|
// Keep advancing the target object while its start time falls before the end time of the source object
|
||||||
while (true)
|
while (true)
|
||||||
@ -111,7 +111,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
targetIndex++;
|
targetIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new OsuDistanceSnapGrid(sourceObject, targetObject);
|
return new OsuDistanceSnapGrid((OsuHitObject)sourceObject, (OsuHitObject)targetObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,6 @@ namespace osu.Game.Rulesets.Taiko.Audio
|
|||||||
var centre = s.GetSampleInfo();
|
var centre = s.GetSampleInfo();
|
||||||
var rim = s.GetSampleInfo(HitSampleInfo.HIT_CLAP);
|
var rim = s.GetSampleInfo(HitSampleInfo.HIT_CLAP);
|
||||||
|
|
||||||
// todo: this is ugly
|
|
||||||
centre.Namespace = "taiko";
|
|
||||||
rim.Namespace = "taiko";
|
|
||||||
|
|
||||||
mappings[s.Time] = new DrumSample
|
mappings[s.Time] = new DrumSample
|
||||||
{
|
{
|
||||||
Centre = addSound(centre),
|
Centre = addSound(centre),
|
||||||
|
@ -166,8 +166,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
// Normal and clap samples are handled by the drum
|
// Normal and clap samples are handled by the drum
|
||||||
protected override IEnumerable<HitSampleInfo> GetSamples() => HitObject.Samples.Where(s => s.Name != HitSampleInfo.HIT_NORMAL && s.Name != HitSampleInfo.HIT_CLAP);
|
protected override IEnumerable<HitSampleInfo> GetSamples() => HitObject.Samples.Where(s => s.Name != HitSampleInfo.HIT_NORMAL && s.Name != HitSampleInfo.HIT_CLAP);
|
||||||
|
|
||||||
protected override string SampleNamespace => "taiko";
|
|
||||||
|
|
||||||
protected virtual TaikoPiece CreateMainPiece() => new CirclePiece();
|
protected virtual TaikoPiece CreateMainPiece() => new CirclePiece();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/normal-hitclap.wav
Executable file
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/normal-hitclap.wav
Executable file
Binary file not shown.
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/normal-hitfinish.wav
Executable file
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/normal-hitfinish.wav
Executable file
Binary file not shown.
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/normal-hitnormal.wav
Executable file
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/normal-hitnormal.wav
Executable file
Binary file not shown.
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/normal-hitwhistle.wav
Executable file
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/normal-hitwhistle.wav
Executable file
Binary file not shown.
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/soft-hitclap.wav
Executable file
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/soft-hitclap.wav
Executable file
Binary file not shown.
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/soft-hitfinish.wav
Executable file
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/soft-hitfinish.wav
Executable file
Binary file not shown.
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/soft-hitnormal.wav
Executable file
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/soft-hitnormal.wav
Executable file
Binary file not shown.
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/soft-hitwhistle.wav
Executable file
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/soft-hitwhistle.wav
Executable file
Binary file not shown.
@ -0,0 +1,55 @@
|
|||||||
|
// 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 osu.Framework.Audio.Sample;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Taiko.Skinning
|
||||||
|
{
|
||||||
|
public class TaikoLegacySkinTransformer : ISkin
|
||||||
|
{
|
||||||
|
private readonly ISkinSource source;
|
||||||
|
|
||||||
|
public TaikoLegacySkinTransformer(ISkinSource source)
|
||||||
|
{
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Drawable GetDrawableComponent(ISkinComponent component) => source.GetDrawableComponent(component);
|
||||||
|
|
||||||
|
public Texture GetTexture(string componentName) => source.GetTexture(componentName);
|
||||||
|
|
||||||
|
public SampleChannel GetSample(ISampleInfo sampleInfo) => source.GetSample(new LegacyTaikoSampleInfo(sampleInfo));
|
||||||
|
|
||||||
|
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => source.GetConfig<TLookup, TValue>(lookup);
|
||||||
|
|
||||||
|
private class LegacyTaikoSampleInfo : ISampleInfo
|
||||||
|
{
|
||||||
|
private readonly ISampleInfo source;
|
||||||
|
|
||||||
|
public LegacyTaikoSampleInfo(ISampleInfo source)
|
||||||
|
{
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<string> LookupNames
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
foreach (var name in source.LookupNames)
|
||||||
|
yield return $"taiko-{name}";
|
||||||
|
|
||||||
|
foreach (var name in source.LookupNames)
|
||||||
|
yield return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Volume => source.Volume;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -21,6 +21,8 @@ using osu.Game.Rulesets.Taiko.Difficulty;
|
|||||||
using osu.Game.Rulesets.Taiko.Scoring;
|
using osu.Game.Rulesets.Taiko.Scoring;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using System;
|
using System;
|
||||||
|
using osu.Game.Rulesets.Taiko.Skinning;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko
|
namespace osu.Game.Rulesets.Taiko
|
||||||
{
|
{
|
||||||
@ -34,6 +36,8 @@ namespace osu.Game.Rulesets.Taiko
|
|||||||
|
|
||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap, this);
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap, this);
|
||||||
|
|
||||||
|
public override ISkin CreateLegacySkinProvider(ISkinSource source) => new TaikoLegacySkinTransformer(source);
|
||||||
|
|
||||||
public const string SHORT_NAME = "taiko";
|
public const string SHORT_NAME = "taiko";
|
||||||
|
|
||||||
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
|
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
|
||||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestHitObjectAddEvent()
|
public void TestHitObjectAddEvent()
|
||||||
{
|
{
|
||||||
var editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap());
|
var editorBeatmap = new EditorBeatmap(new OsuBeatmap());
|
||||||
|
|
||||||
HitObject addedObject = null;
|
HitObject addedObject = null;
|
||||||
editorBeatmap.HitObjectAdded += h => addedObject = h;
|
editorBeatmap.HitObjectAdded += h => addedObject = h;
|
||||||
@ -38,7 +38,7 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
public void HitObjectRemoveEvent()
|
public void HitObjectRemoveEvent()
|
||||||
{
|
{
|
||||||
var hitCircle = new HitCircle();
|
var hitCircle = new HitCircle();
|
||||||
var editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap { HitObjects = { hitCircle } });
|
var editorBeatmap = new EditorBeatmap(new OsuBeatmap { HitObjects = { hitCircle } });
|
||||||
|
|
||||||
HitObject removedObject = null;
|
HitObject removedObject = null;
|
||||||
editorBeatmap.HitObjectRemoved += h => removedObject = h;
|
editorBeatmap.HitObjectRemoved += h => removedObject = h;
|
||||||
@ -55,7 +55,7 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
public void TestInitialHitObjectStartTimeChangeEvent()
|
public void TestInitialHitObjectStartTimeChangeEvent()
|
||||||
{
|
{
|
||||||
var hitCircle = new HitCircle();
|
var hitCircle = new HitCircle();
|
||||||
var editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap { HitObjects = { hitCircle } });
|
var editorBeatmap = new EditorBeatmap(new OsuBeatmap { HitObjects = { hitCircle } });
|
||||||
|
|
||||||
HitObject changedObject = null;
|
HitObject changedObject = null;
|
||||||
editorBeatmap.StartTimeChanged += h => changedObject = h;
|
editorBeatmap.StartTimeChanged += h => changedObject = h;
|
||||||
@ -71,7 +71,7 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestAddedHitObjectStartTimeChangeEvent()
|
public void TestAddedHitObjectStartTimeChangeEvent()
|
||||||
{
|
{
|
||||||
var editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap());
|
var editorBeatmap = new EditorBeatmap(new OsuBeatmap());
|
||||||
|
|
||||||
HitObject changedObject = null;
|
HitObject changedObject = null;
|
||||||
editorBeatmap.StartTimeChanged += h => changedObject = h;
|
editorBeatmap.StartTimeChanged += h => changedObject = h;
|
||||||
@ -92,7 +92,7 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
public void TestRemovedHitObjectStartTimeChangeEvent()
|
public void TestRemovedHitObjectStartTimeChangeEvent()
|
||||||
{
|
{
|
||||||
var hitCircle = new HitCircle();
|
var hitCircle = new HitCircle();
|
||||||
var editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap { HitObjects = { hitCircle } });
|
var editorBeatmap = new EditorBeatmap(new OsuBeatmap { HitObjects = { hitCircle } });
|
||||||
|
|
||||||
HitObject changedObject = null;
|
HitObject changedObject = null;
|
||||||
editorBeatmap.StartTimeChanged += h => changedObject = h;
|
editorBeatmap.StartTimeChanged += h => changedObject = h;
|
||||||
@ -110,7 +110,7 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestAddHitObjectInMiddle()
|
public void TestAddHitObjectInMiddle()
|
||||||
{
|
{
|
||||||
var editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap
|
var editorBeatmap = new EditorBeatmap(new OsuBeatmap
|
||||||
{
|
{
|
||||||
HitObjects =
|
HitObjects =
|
||||||
{
|
{
|
||||||
@ -134,7 +134,7 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
public void TestResortWhenStartTimeChanged()
|
public void TestResortWhenStartTimeChanged()
|
||||||
{
|
{
|
||||||
var hitCircle = new HitCircle { StartTime = 1000 };
|
var hitCircle = new HitCircle { StartTime = 1000 };
|
||||||
var editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap
|
var editorBeatmap = new EditorBeatmap(new OsuBeatmap
|
||||||
{
|
{
|
||||||
HitObjects =
|
HitObjects =
|
||||||
{
|
{
|
||||||
|
@ -2,11 +2,12 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||||
using osu.Game.Rulesets.Osu.Edit;
|
using osu.Game.Rulesets.Osu.Edit;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
@ -17,6 +18,9 @@ namespace osu.Game.Tests.Editor
|
|||||||
{
|
{
|
||||||
private TestHitObjectComposer composer;
|
private TestHitObjectComposer composer;
|
||||||
|
|
||||||
|
[Cached(typeof(EditorBeatmap))]
|
||||||
|
private readonly EditorBeatmap editorBeatmap = new EditorBeatmap(new OsuBeatmap());
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
@ -183,7 +187,7 @@ namespace osu.Game.Tests.Editor
|
|||||||
|
|
||||||
private class TestHitObjectComposer : OsuHitObjectComposer
|
private class TestHitObjectComposer : OsuHitObjectComposer
|
||||||
{
|
{
|
||||||
public new EditorBeatmap<OsuHitObject> EditorBeatmap => base.EditorBeatmap;
|
public new EditorBeatmap EditorBeatmap => base.EditorBeatmap;
|
||||||
|
|
||||||
public TestHitObjectComposer()
|
public TestHitObjectComposer()
|
||||||
: base(new OsuRuleset())
|
: base(new OsuRuleset())
|
||||||
|
74
osu.Game.Tests/Gameplay/TestSceneStoryboardSamples.cs
Normal file
74
osu.Game.Tests/Gameplay/TestSceneStoryboardSamples.cs
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
// 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.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Audio.Sample;
|
||||||
|
using osu.Framework.IO.Stores;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
using osu.Game.Tests.Resources;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Gameplay
|
||||||
|
{
|
||||||
|
public class TestSceneStoryboardSamples : OsuTestScene
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestRetrieveTopLevelSample()
|
||||||
|
{
|
||||||
|
ISkin skin = null;
|
||||||
|
SampleChannel channel = null;
|
||||||
|
|
||||||
|
AddStep("create skin", () => skin = new TestSkin("test-sample", Audio));
|
||||||
|
AddStep("retrieve sample", () => channel = skin.GetSample(new SampleInfo("test-sample")));
|
||||||
|
|
||||||
|
AddAssert("sample is non-null", () => channel != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRetrieveSampleInSubFolder()
|
||||||
|
{
|
||||||
|
ISkin skin = null;
|
||||||
|
SampleChannel channel = null;
|
||||||
|
|
||||||
|
AddStep("create skin", () => skin = new TestSkin("folder/test-sample", Audio));
|
||||||
|
AddStep("retrieve sample", () => channel = skin.GetSample(new SampleInfo("folder/test-sample")));
|
||||||
|
|
||||||
|
AddAssert("sample is non-null", () => channel != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestSkin : LegacySkin
|
||||||
|
{
|
||||||
|
public TestSkin(string resourceName, AudioManager audioManager)
|
||||||
|
: base(DefaultLegacySkin.Info, new TestResourceStore(resourceName), audioManager, "skin.ini")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestResourceStore : IResourceStore<byte[]>
|
||||||
|
{
|
||||||
|
private readonly string resourceName;
|
||||||
|
|
||||||
|
public TestResourceStore(string resourceName)
|
||||||
|
{
|
||||||
|
this.resourceName = resourceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] Get(string name) => name == resourceName ? TestResources.GetStore().Get("Resources/test-sample.mp3") : null;
|
||||||
|
|
||||||
|
public Task<byte[]> GetAsync(string name) => name == resourceName ? TestResources.GetStore().GetAsync("Resources/test-sample.mp3") : null;
|
||||||
|
|
||||||
|
public Stream GetStream(string name) => name == resourceName ? TestResources.GetStore().GetStream("Resources/test-sample.mp3") : null;
|
||||||
|
|
||||||
|
public IEnumerable<string> GetAvailableResources() => new[] { resourceName };
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
osu.Game.Tests/Resources/test-sample.mp3
Normal file
BIN
osu.Game.Tests/Resources/test-sample.mp3
Normal file
Binary file not shown.
@ -4,6 +4,8 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||||
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Compose;
|
using osu.Game.Screens.Edit.Compose;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Editor
|
namespace osu.Game.Tests.Visual.Editor
|
||||||
@ -11,10 +13,21 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneComposeScreen : EditorClockTestScene
|
public class TestSceneComposeScreen : EditorClockTestScene
|
||||||
{
|
{
|
||||||
|
[Cached(typeof(EditorBeatmap))]
|
||||||
|
private readonly EditorBeatmap editorBeatmap =
|
||||||
|
new EditorBeatmap(new OsuBeatmap
|
||||||
|
{
|
||||||
|
BeatmapInfo =
|
||||||
|
{
|
||||||
|
Ruleset = new OsuRuleset().RulesetInfo
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
|
||||||
|
|
||||||
Child = new ComposeScreen();
|
Child = new ComposeScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Compose.Components;
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -21,15 +20,15 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
private const double beat_length = 100;
|
private const double beat_length = 100;
|
||||||
private static readonly Vector2 grid_position = new Vector2(512, 384);
|
private static readonly Vector2 grid_position = new Vector2(512, 384);
|
||||||
|
|
||||||
[Cached(typeof(IEditorBeatmap))]
|
[Cached(typeof(EditorBeatmap))]
|
||||||
private readonly EditorBeatmap<OsuHitObject> editorBeatmap;
|
private readonly EditorBeatmap editorBeatmap;
|
||||||
|
|
||||||
[Cached(typeof(IDistanceSnapProvider))]
|
[Cached(typeof(IDistanceSnapProvider))]
|
||||||
private readonly SnapProvider snapProvider = new SnapProvider();
|
private readonly SnapProvider snapProvider = new SnapProvider();
|
||||||
|
|
||||||
public TestSceneDistanceSnapGrid()
|
public TestSceneDistanceSnapGrid()
|
||||||
{
|
{
|
||||||
editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap());
|
editorBeatmap = new EditorBeatmap(new OsuBeatmap());
|
||||||
editorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = beat_length });
|
editorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = beat_length });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
{
|
{
|
||||||
Beatmap.Value = new WaveformTestBeatmap(audio);
|
Beatmap.Value = new WaveformTestBeatmap(audio);
|
||||||
|
|
||||||
var editorBeatmap = new EditorBeatmap<HitObject>((Beatmap<HitObject>)Beatmap.Value.Beatmap);
|
var editorBeatmap = new EditorBeatmap((Beatmap<HitObject>)Beatmap.Value.Beatmap);
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
|
@ -16,6 +16,7 @@ using osu.Game.Rulesets.Osu.Edit;
|
|||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
|
||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Compose.Components;
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -59,9 +60,12 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var editorBeatmap = new EditorBeatmap(Beatmap.Value.GetPlayableBeatmap(new OsuRuleset().RulesetInfo));
|
||||||
|
|
||||||
var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||||
Dependencies.CacheAs<IAdjustableClock>(clock);
|
Dependencies.CacheAs<IAdjustableClock>(clock);
|
||||||
Dependencies.CacheAs<IFrameBasedClock>(clock);
|
Dependencies.CacheAs<IFrameBasedClock>(clock);
|
||||||
|
Dependencies.CacheAs(editorBeatmap);
|
||||||
|
|
||||||
Child = new OsuHitObjectComposer(new OsuRuleset());
|
Child = new OsuHitObjectComposer(new OsuRuleset());
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,8 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||||
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Timing;
|
using osu.Game.Screens.Edit.Timing;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Editor
|
namespace osu.Game.Tests.Visual.Editor
|
||||||
@ -25,10 +26,13 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
typeof(RowAttribute)
|
typeof(RowAttribute)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[Cached(typeof(EditorBeatmap))]
|
||||||
|
private readonly EditorBeatmap editorBeatmap = new EditorBeatmap(new OsuBeatmap());
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
|
||||||
Child = new TimingScreen();
|
Child = new TimingScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,6 @@ namespace osu.Game.Audio
|
|||||||
public const string HIT_NORMAL = @"hitnormal";
|
public const string HIT_NORMAL = @"hitnormal";
|
||||||
public const string HIT_CLAP = @"hitclap";
|
public const string HIT_CLAP = @"hitclap";
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// An optional ruleset namespace.
|
|
||||||
/// </summary>
|
|
||||||
public string Namespace;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The bank to load the sample from.
|
/// The bank to load the sample from.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -49,15 +44,6 @@ namespace osu.Game.Audio
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(Namespace))
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(Suffix))
|
|
||||||
yield return $"{Namespace}/{Bank}-{Name}{Suffix}";
|
|
||||||
|
|
||||||
yield return $"{Namespace}/{Bank}-{Name}";
|
|
||||||
}
|
|
||||||
|
|
||||||
// check non-namespace as a fallback even when we have a namespace
|
|
||||||
if (!string.IsNullOrEmpty(Suffix))
|
if (!string.IsNullOrEmpty(Suffix))
|
||||||
yield return $"{Bank}-{Name}{Suffix}";
|
yield return $"{Bank}-{Name}{Suffix}";
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
private readonly DrawableRuleset<TObject> drawableRuleset;
|
private readonly DrawableRuleset<TObject> drawableRuleset;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IEditorBeatmap<TObject> beatmap { get; set; }
|
private EditorBeatmap beatmap { get; set; }
|
||||||
|
|
||||||
public DrawableEditRulesetWrapper(DrawableRuleset<TObject> drawableRuleset)
|
public DrawableEditRulesetWrapper(DrawableRuleset<TObject> drawableRuleset)
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
@ -35,20 +34,20 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
{
|
{
|
||||||
protected IRulesetConfigManager Config { get; private set; }
|
protected IRulesetConfigManager Config { get; private set; }
|
||||||
|
|
||||||
protected new EditorBeatmap<TObject> EditorBeatmap { get; private set; }
|
|
||||||
|
|
||||||
protected readonly Ruleset Ruleset;
|
protected readonly Ruleset Ruleset;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
protected IFrameBasedClock EditorClock { get; private set; }
|
protected IFrameBasedClock EditorClock { get; private set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
protected EditorBeatmap EditorBeatmap { get; private set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IAdjustableClock adjustableClock { get; set; }
|
private IAdjustableClock adjustableClock { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BindableBeatDivisor beatDivisor { get; set; }
|
private BindableBeatDivisor beatDivisor { get; set; }
|
||||||
|
|
||||||
private Beatmap<TObject> playableBeatmap;
|
|
||||||
private IBeatmapProcessor beatmapProcessor;
|
private IBeatmapProcessor beatmapProcessor;
|
||||||
|
|
||||||
private DrawableEditRulesetWrapper<TObject> drawableRulesetWrapper;
|
private DrawableEditRulesetWrapper<TObject> drawableRulesetWrapper;
|
||||||
@ -68,9 +67,17 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(IFrameBasedClock framedClock)
|
private void load(IFrameBasedClock framedClock)
|
||||||
{
|
{
|
||||||
|
beatmapProcessor = Ruleset.CreateBeatmapProcessor(EditorBeatmap.PlayableBeatmap);
|
||||||
|
|
||||||
|
EditorBeatmap.HitObjectAdded += addHitObject;
|
||||||
|
EditorBeatmap.HitObjectRemoved += removeHitObject;
|
||||||
|
EditorBeatmap.StartTimeChanged += UpdateHitObject;
|
||||||
|
|
||||||
|
Config = Dependencies.Get<RulesetConfigCache>().GetConfigFor(Ruleset);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
drawableRulesetWrapper = new DrawableEditRulesetWrapper<TObject>(CreateDrawableRuleset(Ruleset, playableBeatmap))
|
drawableRulesetWrapper = new DrawableEditRulesetWrapper<TObject>(CreateDrawableRuleset(Ruleset, EditorBeatmap.PlayableBeatmap))
|
||||||
{
|
{
|
||||||
Clock = framedClock,
|
Clock = framedClock,
|
||||||
ProcessCustomClock = false
|
ProcessCustomClock = false
|
||||||
@ -140,28 +147,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
blueprintContainer.SelectionChanged += selectionChanged;
|
blueprintContainer.SelectionChanged += selectionChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
||||||
{
|
|
||||||
var parentWorkingBeatmap = parent.Get<IBindable<WorkingBeatmap>>().Value;
|
|
||||||
|
|
||||||
playableBeatmap = (Beatmap<TObject>)parentWorkingBeatmap.GetPlayableBeatmap(Ruleset.RulesetInfo);
|
|
||||||
|
|
||||||
beatmapProcessor = Ruleset.CreateBeatmapProcessor(playableBeatmap);
|
|
||||||
|
|
||||||
base.EditorBeatmap = EditorBeatmap = new EditorBeatmap<TObject>(playableBeatmap);
|
|
||||||
EditorBeatmap.HitObjectAdded += addHitObject;
|
|
||||||
EditorBeatmap.HitObjectRemoved += removeHitObject;
|
|
||||||
EditorBeatmap.StartTimeChanged += UpdateHitObject;
|
|
||||||
|
|
||||||
var dependencies = new DependencyContainer(parent);
|
|
||||||
dependencies.CacheAs<IEditorBeatmap>(EditorBeatmap);
|
|
||||||
dependencies.CacheAs<IEditorBeatmap<TObject>>(EditorBeatmap);
|
|
||||||
|
|
||||||
Config = dependencies.Get<RulesetConfigCache>().GetConfigFor(Ruleset);
|
|
||||||
|
|
||||||
return base.CreateChildDependencies(dependencies);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
@ -234,7 +219,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
scheduledUpdate = Schedule(() =>
|
scheduledUpdate = Schedule(() =>
|
||||||
{
|
{
|
||||||
beatmapProcessor?.PreProcess();
|
beatmapProcessor?.PreProcess();
|
||||||
hitObject?.ApplyDefaults(playableBeatmap.ControlPointInfo, playableBeatmap.BeatmapInfo.BaseDifficulty);
|
hitObject?.ApplyDefaults(EditorBeatmap.ControlPointInfo, EditorBeatmap.BeatmapInfo.BaseDifficulty);
|
||||||
beatmapProcessor?.PostProcess();
|
beatmapProcessor?.PostProcess();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -333,11 +318,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract IEnumerable<DrawableHitObject> HitObjects { get; }
|
public abstract IEnumerable<DrawableHitObject> HitObjects { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// An editor-specific beatmap, exposing mutation events.
|
|
||||||
/// </summary>
|
|
||||||
public IEditorBeatmap EditorBeatmap { get; protected set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the user's cursor is currently in an area of the <see cref="HitObjectComposer"/> that is valid for placement.
|
/// Whether the user's cursor is currently in an area of the <see cref="HitObjectComposer"/> that is valid for placement.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -31,9 +31,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly Bindable<Color4> AccentColour = new Bindable<Color4>(Color4.Gray);
|
public readonly Bindable<Color4> AccentColour = new Bindable<Color4>(Color4.Gray);
|
||||||
|
|
||||||
// Todo: Rulesets should be overriding the resources instead, but we need to figure out where/when to apply overrides first
|
|
||||||
protected virtual string SampleNamespace => null;
|
|
||||||
|
|
||||||
protected SkinnableSound Samples { get; private set; }
|
protected SkinnableSound Samples { get; private set; }
|
||||||
|
|
||||||
protected virtual IEnumerable<HitSampleInfo> GetSamples() => HitObject.Samples;
|
protected virtual IEnumerable<HitSampleInfo> GetSamples() => HitObject.Samples;
|
||||||
@ -154,11 +151,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
+ $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}.");
|
+ $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
samples = samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s)).ToArray();
|
AddInternal(Samples = new SkinnableSound(samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s))));
|
||||||
foreach (var s in samples)
|
|
||||||
s.Namespace = SampleNamespace;
|
|
||||||
|
|
||||||
AddInternal(Samples = new SkinnableSound(samples));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onDefaultsApplied() => apply(HitObject);
|
private void onDefaultsApplied() => apply(HitObject);
|
||||||
|
@ -40,7 +40,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
private HitObjectComposer composer { get; set; }
|
private HitObjectComposer composer { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IEditorBeatmap beatmap { get; set; }
|
private EditorBeatmap beatmap { get; set; }
|
||||||
|
|
||||||
public BlueprintContainer()
|
public BlueprintContainer()
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
protected IDistanceSnapProvider SnapProvider { get; private set; }
|
protected IDistanceSnapProvider SnapProvider { get; private set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IEditorBeatmap beatmap { get; set; }
|
private EditorBeatmap beatmap { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BindableBeatDivisor beatDivisor { get; set; }
|
private BindableBeatDivisor beatDivisor { get; set; }
|
||||||
|
@ -16,9 +16,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
{
|
{
|
||||||
internal class TimelineHitObjectDisplay : TimelinePart
|
internal class TimelineHitObjectDisplay : TimelinePart
|
||||||
{
|
{
|
||||||
private IEditorBeatmap beatmap { get; }
|
private EditorBeatmap beatmap { get; }
|
||||||
|
|
||||||
public TimelineHitObjectDisplay(IEditorBeatmap beatmap)
|
public TimelineHitObjectDisplay(EditorBeatmap beatmap)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
@ -32,6 +32,6 @@ namespace osu.Game.Screens.Edit.Compose
|
|||||||
return beatmapSkinProvider.WithChild(rulesetSkinProvider.WithChild(composer));
|
return beatmapSkinProvider.WithChild(rulesetSkinProvider.WithChild(composer));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Drawable CreateTimelineContent() => composer == null ? base.CreateTimelineContent() : new TimelineHitObjectDisplay(composer.EditorBeatmap);
|
protected override Drawable CreateTimelineContent() => composer == null ? base.CreateTimelineContent() : new TimelineHitObjectDisplay(EditorBeatmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ using osuTK.Input;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Screens.Edit.Compose;
|
using osu.Game.Screens.Edit.Compose;
|
||||||
@ -49,9 +50,11 @@ namespace osu.Game.Screens.Edit
|
|||||||
private EditorScreen currentScreen;
|
private EditorScreen currentScreen;
|
||||||
|
|
||||||
private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor();
|
private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor();
|
||||||
|
|
||||||
private EditorClock clock;
|
private EditorClock clock;
|
||||||
|
|
||||||
|
private IBeatmap playableBeatmap;
|
||||||
|
private EditorBeatmap editorBeatmap;
|
||||||
|
|
||||||
private DependencyContainer dependencies;
|
private DependencyContainer dependencies;
|
||||||
private GameHost host;
|
private GameHost host;
|
||||||
|
|
||||||
@ -73,9 +76,13 @@ namespace osu.Game.Screens.Edit
|
|||||||
clock = new EditorClock(Beatmap.Value, beatDivisor) { IsCoupled = false };
|
clock = new EditorClock(Beatmap.Value, beatDivisor) { IsCoupled = false };
|
||||||
clock.ChangeSource(sourceClock);
|
clock.ChangeSource(sourceClock);
|
||||||
|
|
||||||
|
playableBeatmap = Beatmap.Value.GetPlayableBeatmap(Beatmap.Value.BeatmapInfo.Ruleset);
|
||||||
|
editorBeatmap = new EditorBeatmap(playableBeatmap);
|
||||||
|
|
||||||
dependencies.CacheAs<IFrameBasedClock>(clock);
|
dependencies.CacheAs<IFrameBasedClock>(clock);
|
||||||
dependencies.CacheAs<IAdjustableClock>(clock);
|
dependencies.CacheAs<IAdjustableClock>(clock);
|
||||||
dependencies.Cache(beatDivisor);
|
dependencies.Cache(beatDivisor);
|
||||||
|
dependencies.CacheAs(editorBeatmap);
|
||||||
|
|
||||||
EditorMenuBar menuBar;
|
EditorMenuBar menuBar;
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -11,30 +12,30 @@ using osu.Game.Rulesets.Objects;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Edit
|
namespace osu.Game.Screens.Edit
|
||||||
{
|
{
|
||||||
public class EditorBeatmap<T> : IEditorBeatmap<T>
|
public class EditorBeatmap : IBeatmap
|
||||||
where T : HitObject
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when a <see cref="HitObject"/> is added to this <see cref="EditorBeatmap{T}"/>.
|
/// Invoked when a <see cref="HitObject"/> is added to this <see cref="EditorBeatmap"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action<HitObject> HitObjectAdded;
|
public event Action<HitObject> HitObjectAdded;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when a <see cref="HitObject"/> is removed from this <see cref="EditorBeatmap{T}"/>.
|
/// Invoked when a <see cref="HitObject"/> is removed from this <see cref="EditorBeatmap"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action<HitObject> HitObjectRemoved;
|
public event Action<HitObject> HitObjectRemoved;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when the start time of a <see cref="HitObject"/> in this <see cref="EditorBeatmap{T}"/> was changed.
|
/// Invoked when the start time of a <see cref="HitObject"/> in this <see cref="EditorBeatmap"/> was changed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action<HitObject> StartTimeChanged;
|
public event Action<HitObject> StartTimeChanged;
|
||||||
|
|
||||||
private readonly Dictionary<T, Bindable<double>> startTimeBindables = new Dictionary<T, Bindable<double>>();
|
public readonly IBeatmap PlayableBeatmap;
|
||||||
private readonly Beatmap<T> beatmap;
|
|
||||||
|
|
||||||
public EditorBeatmap(Beatmap<T> beatmap)
|
private readonly Dictionary<HitObject, Bindable<double>> startTimeBindables = new Dictionary<HitObject, Bindable<double>>();
|
||||||
|
|
||||||
|
public EditorBeatmap(IBeatmap playableBeatmap)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
PlayableBeatmap = playableBeatmap;
|
||||||
|
|
||||||
foreach (var obj in HitObjects)
|
foreach (var obj in HitObjects)
|
||||||
trackStartTime(obj);
|
trackStartTime(obj);
|
||||||
@ -42,82 +43,83 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
public BeatmapInfo BeatmapInfo
|
public BeatmapInfo BeatmapInfo
|
||||||
{
|
{
|
||||||
get => beatmap.BeatmapInfo;
|
get => PlayableBeatmap.BeatmapInfo;
|
||||||
set => beatmap.BeatmapInfo = value;
|
set => PlayableBeatmap.BeatmapInfo = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BeatmapMetadata Metadata => beatmap.Metadata;
|
public BeatmapMetadata Metadata => PlayableBeatmap.Metadata;
|
||||||
|
|
||||||
public ControlPointInfo ControlPointInfo => beatmap.ControlPointInfo;
|
public ControlPointInfo ControlPointInfo => PlayableBeatmap.ControlPointInfo;
|
||||||
|
|
||||||
public List<BreakPeriod> Breaks => beatmap.Breaks;
|
public List<BreakPeriod> Breaks => PlayableBeatmap.Breaks;
|
||||||
|
|
||||||
public double TotalBreakTime => beatmap.TotalBreakTime;
|
public double TotalBreakTime => PlayableBeatmap.TotalBreakTime;
|
||||||
|
|
||||||
public IReadOnlyList<T> HitObjects => beatmap.HitObjects;
|
public IReadOnlyList<HitObject> HitObjects => PlayableBeatmap.HitObjects;
|
||||||
|
|
||||||
IReadOnlyList<HitObject> IBeatmap.HitObjects => beatmap.HitObjects;
|
public IEnumerable<BeatmapStatistic> GetStatistics() => PlayableBeatmap.GetStatistics();
|
||||||
|
|
||||||
public IEnumerable<BeatmapStatistic> GetStatistics() => beatmap.GetStatistics();
|
public IBeatmap Clone() => (EditorBeatmap)MemberwiseClone();
|
||||||
|
|
||||||
public IBeatmap Clone() => (EditorBeatmap<T>)MemberwiseClone();
|
private IList mutableHitObjects => (IList)PlayableBeatmap.HitObjects;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a <see cref="HitObject"/> to this <see cref="EditorBeatmap{T}"/>.
|
/// Adds a <see cref="HitObject"/> to this <see cref="EditorBeatmap"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
|
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
|
||||||
public void Add(T hitObject)
|
public void Add(HitObject hitObject)
|
||||||
{
|
{
|
||||||
trackStartTime(hitObject);
|
trackStartTime(hitObject);
|
||||||
|
|
||||||
// Preserve existing sorting order in the beatmap
|
// Preserve existing sorting order in the beatmap
|
||||||
var insertionIndex = beatmap.HitObjects.FindLastIndex(h => h.StartTime <= hitObject.StartTime);
|
var insertionIndex = findInsertionIndex(PlayableBeatmap.HitObjects, hitObject.StartTime);
|
||||||
beatmap.HitObjects.Insert(insertionIndex + 1, hitObject);
|
mutableHitObjects.Insert(insertionIndex + 1, hitObject);
|
||||||
|
|
||||||
HitObjectAdded?.Invoke(hitObject);
|
HitObjectAdded?.Invoke(hitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes a <see cref="HitObject"/> from this <see cref="EditorBeatmap{T}"/>.
|
/// Removes a <see cref="HitObject"/> from this <see cref="EditorBeatmap"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
|
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
|
||||||
public void Remove(T hitObject)
|
public void Remove(HitObject hitObject)
|
||||||
{
|
{
|
||||||
if (beatmap.HitObjects.Remove(hitObject))
|
if (!mutableHitObjects.Contains(hitObject))
|
||||||
{
|
return;
|
||||||
var bindable = startTimeBindables[hitObject];
|
|
||||||
bindable.UnbindAll();
|
|
||||||
|
|
||||||
startTimeBindables.Remove(hitObject);
|
mutableHitObjects.Remove(hitObject);
|
||||||
HitObjectRemoved?.Invoke(hitObject);
|
|
||||||
}
|
var bindable = startTimeBindables[hitObject];
|
||||||
|
bindable.UnbindAll();
|
||||||
|
|
||||||
|
startTimeBindables.Remove(hitObject);
|
||||||
|
HitObjectRemoved?.Invoke(hitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void trackStartTime(T hitObject)
|
private void trackStartTime(HitObject hitObject)
|
||||||
{
|
{
|
||||||
startTimeBindables[hitObject] = hitObject.StartTimeBindable.GetBoundCopy();
|
startTimeBindables[hitObject] = hitObject.StartTimeBindable.GetBoundCopy();
|
||||||
startTimeBindables[hitObject].ValueChanged += _ =>
|
startTimeBindables[hitObject].ValueChanged += _ =>
|
||||||
{
|
{
|
||||||
// For now we'll remove and re-add the hitobject. This is not optimal and can be improved if required.
|
// For now we'll remove and re-add the hitobject. This is not optimal and can be improved if required.
|
||||||
beatmap.HitObjects.Remove(hitObject);
|
mutableHitObjects.Remove(hitObject);
|
||||||
|
|
||||||
var insertionIndex = beatmap.HitObjects.FindLastIndex(h => h.StartTime <= hitObject.StartTime);
|
var insertionIndex = findInsertionIndex(PlayableBeatmap.HitObjects, hitObject.StartTime);
|
||||||
beatmap.HitObjects.Insert(insertionIndex + 1, hitObject);
|
mutableHitObjects.Insert(insertionIndex + 1, hitObject);
|
||||||
|
|
||||||
StartTimeChanged?.Invoke(hitObject);
|
StartTimeChanged?.Invoke(hitObject);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private int findInsertionIndex(IReadOnlyList<HitObject> list, double startTime)
|
||||||
/// Adds a <see cref="HitObject"/> to this <see cref="EditorBeatmap{T}"/>.
|
{
|
||||||
/// </summary>
|
for (int i = 0; i < list.Count; i++)
|
||||||
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
|
{
|
||||||
public void Add(HitObject hitObject) => Add((T)hitObject);
|
if (list[i].StartTime > startTime)
|
||||||
|
return i - 1;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
return list.Count - 1;
|
||||||
/// Removes a <see cref="HitObject"/> from this <see cref="EditorBeatmap{T}"/>.
|
}
|
||||||
/// </summary>
|
|
||||||
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
|
|
||||||
public void Remove(HitObject hitObject) => Remove((T)hitObject);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,9 @@ namespace osu.Game.Screens.Edit
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
protected IBindable<WorkingBeatmap> Beatmap { get; private set; }
|
protected IBindable<WorkingBeatmap> Beatmap { get; private set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
protected EditorBeatmap EditorBeatmap { get; private set; }
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
|
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
// 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 osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Rulesets.Edit;
|
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Interface for the <see cref="IBeatmap"/> contained by the see <see cref="HitObjectComposer"/>.
|
|
||||||
/// Children of <see cref="HitObjectComposer"/> may resolve the beatmap via <see cref="IEditorBeatmap"/> or <see cref="IEditorBeatmap{T}"/>.
|
|
||||||
/// </summary>
|
|
||||||
public interface IEditorBeatmap : IBeatmap
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Invoked when a <see cref="HitObject"/> is added to this <see cref="IEditorBeatmap"/>.
|
|
||||||
/// </summary>
|
|
||||||
event Action<HitObject> HitObjectAdded;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Invoked when a <see cref="HitObject"/> is removed from this <see cref="IEditorBeatmap"/>.
|
|
||||||
/// </summary>
|
|
||||||
event Action<HitObject> HitObjectRemoved;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Invoked when the start time of a <see cref="HitObject"/> in this <see cref="EditorBeatmap{T}"/> was changed.
|
|
||||||
/// </summary>
|
|
||||||
event Action<HitObject> StartTimeChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Interface for the <see cref="IBeatmap"/> contained by the see <see cref="HitObjectComposer"/>.
|
|
||||||
/// Children of <see cref="HitObjectComposer"/> may resolve the beatmap via <see cref="IEditorBeatmap"/> or <see cref="IEditorBeatmap{T}"/>.
|
|
||||||
/// </summary>
|
|
||||||
public interface IEditorBeatmap<out T> : IEditorBeatmap, IBeatmap<T>
|
|
||||||
where T : HitObject
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -175,7 +175,7 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
foreach (var lookup in sampleInfo.LookupNames)
|
foreach (var lookup in sampleInfo.LookupNames)
|
||||||
{
|
{
|
||||||
var sample = Samples?.Get(getFallbackName(lookup));
|
var sample = Samples?.Get(lookup);
|
||||||
|
|
||||||
if (sample != null)
|
if (sample != null)
|
||||||
return sample;
|
return sample;
|
||||||
|
@ -105,7 +105,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private AudioManager audio { get; set; }
|
protected AudioManager Audio { get; private set; }
|
||||||
|
|
||||||
protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset);
|
protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset);
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
CreateWorkingBeatmap(CreateBeatmap(ruleset), null);
|
CreateWorkingBeatmap(CreateBeatmap(ruleset), null);
|
||||||
|
|
||||||
protected virtual WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) =>
|
protected virtual WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) =>
|
||||||
new ClockBackedTestWorkingBeatmap(beatmap, storyboard, Clock, audio);
|
new ClockBackedTestWorkingBeatmap(beatmap, storyboard, Clock, Audio);
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(RulesetStore rulesets)
|
private void load(RulesetStore rulesets)
|
||||||
|
Loading…
Reference in New Issue
Block a user