mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:12:57 +08:00
Merge branch 'master' into taiko-drumroll-skinning
This commit is contained in:
commit
d4788e39bb
@ -15,15 +15,18 @@ namespace osu.Game.Tests.Editor
|
||||
{
|
||||
var handler = new EditorChangeHandler(new EditorBeatmap(new Beatmap()));
|
||||
|
||||
Assert.That(handler.HasUndoState, Is.False);
|
||||
Assert.That(handler.CanUndo.Value, Is.False);
|
||||
Assert.That(handler.CanRedo.Value, Is.False);
|
||||
|
||||
handler.SaveState();
|
||||
|
||||
Assert.That(handler.HasUndoState, Is.True);
|
||||
Assert.That(handler.CanUndo.Value, Is.True);
|
||||
Assert.That(handler.CanRedo.Value, Is.False);
|
||||
|
||||
handler.RestoreState(-1);
|
||||
|
||||
Assert.That(handler.HasUndoState, Is.False);
|
||||
Assert.That(handler.CanUndo.Value, Is.False);
|
||||
Assert.That(handler.CanRedo.Value, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -31,20 +34,20 @@ namespace osu.Game.Tests.Editor
|
||||
{
|
||||
var handler = new EditorChangeHandler(new EditorBeatmap(new Beatmap()));
|
||||
|
||||
Assert.That(handler.HasUndoState, Is.False);
|
||||
Assert.That(handler.CanUndo.Value, Is.False);
|
||||
|
||||
for (int i = 0; i < EditorChangeHandler.MAX_SAVED_STATES; i++)
|
||||
handler.SaveState();
|
||||
|
||||
Assert.That(handler.HasUndoState, Is.True);
|
||||
Assert.That(handler.CanUndo.Value, Is.True);
|
||||
|
||||
for (int i = 0; i < EditorChangeHandler.MAX_SAVED_STATES; i++)
|
||||
{
|
||||
Assert.That(handler.HasUndoState, Is.True);
|
||||
Assert.That(handler.CanUndo.Value, Is.True);
|
||||
handler.RestoreState(-1);
|
||||
}
|
||||
|
||||
Assert.That(handler.HasUndoState, Is.False);
|
||||
Assert.That(handler.CanUndo.Value, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -52,20 +55,20 @@ namespace osu.Game.Tests.Editor
|
||||
{
|
||||
var handler = new EditorChangeHandler(new EditorBeatmap(new Beatmap()));
|
||||
|
||||
Assert.That(handler.HasUndoState, Is.False);
|
||||
Assert.That(handler.CanUndo.Value, Is.False);
|
||||
|
||||
for (int i = 0; i < EditorChangeHandler.MAX_SAVED_STATES * 2; i++)
|
||||
handler.SaveState();
|
||||
|
||||
Assert.That(handler.HasUndoState, Is.True);
|
||||
Assert.That(handler.CanUndo.Value, Is.True);
|
||||
|
||||
for (int i = 0; i < EditorChangeHandler.MAX_SAVED_STATES; i++)
|
||||
{
|
||||
Assert.That(handler.HasUndoState, Is.True);
|
||||
Assert.That(handler.CanUndo.Value, Is.True);
|
||||
handler.RestoreState(-1);
|
||||
}
|
||||
|
||||
Assert.That(handler.HasUndoState, Is.False);
|
||||
Assert.That(handler.CanUndo.Value, Is.False);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
346
osu.Game.Tests/Gameplay/TestSceneHitObjectSamples.cs
Normal file
346
osu.Game.Tests/Gameplay/TestSceneHitObjectSamples.cs
Normal file
@ -0,0 +1,346 @@
|
||||
// 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 System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
[HeadlessTest]
|
||||
public class TestSceneHitObjectSamples : PlayerTestScene
|
||||
{
|
||||
private readonly SkinInfo userSkinInfo = new SkinInfo();
|
||||
|
||||
private readonly BeatmapInfo beatmapInfo = new BeatmapInfo
|
||||
{
|
||||
BeatmapSet = new BeatmapSetInfo(),
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Author = User.SYSTEM_USER
|
||||
}
|
||||
};
|
||||
|
||||
private readonly TestResourceStore userSkinResourceStore = new TestResourceStore();
|
||||
private readonly TestResourceStore beatmapSkinResourceStore = new TestResourceStore();
|
||||
|
||||
protected override bool HasCustomSteps => true;
|
||||
|
||||
public TestSceneHitObjectSamples()
|
||||
: base(new OsuRuleset())
|
||||
{
|
||||
}
|
||||
|
||||
private SkinSourceDependencyContainer dependencies;
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
=> new DependencyContainer(dependencies = new SkinSourceDependencyContainer(base.CreateChildDependencies(parent)));
|
||||
|
||||
/// <summary>
|
||||
/// Tests that a hitobject which provides no custom sample set retrieves samples from the user skin.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestDefaultSampleFromUserSkin()
|
||||
{
|
||||
const string expected_sample = "normal-hitnormal";
|
||||
|
||||
setupSkins(expected_sample, expected_sample);
|
||||
|
||||
createTestWithBeatmap("hitobject-skin-sample.osu");
|
||||
|
||||
assertUserLookup(expected_sample);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that a hitobject which provides a sample set of 1 retrieves samples from the beatmap skin.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestDefaultSampleFromBeatmap()
|
||||
{
|
||||
const string expected_sample = "normal-hitnormal";
|
||||
|
||||
setupSkins(expected_sample, expected_sample);
|
||||
|
||||
createTestWithBeatmap("hitobject-beatmap-sample.osu");
|
||||
|
||||
assertBeatmapLookup(expected_sample);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that a hitobject which provides a sample set of 1 retrieves samples from the user skin when the beatmap does not contain the sample.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestDefaultSampleFromUserSkinFallback()
|
||||
{
|
||||
const string expected_sample = "normal-hitnormal";
|
||||
|
||||
setupSkins(null, expected_sample);
|
||||
|
||||
createTestWithBeatmap("hitobject-beatmap-sample.osu");
|
||||
|
||||
assertUserLookup(expected_sample);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that a hitobject which provides a custom sample set of 2 retrieves the following samples from the beatmap skin:
|
||||
/// normal-hitnormal2
|
||||
/// normal-hitnormal
|
||||
/// </summary>
|
||||
[TestCase("normal-hitnormal2")]
|
||||
[TestCase("normal-hitnormal")]
|
||||
public void TestDefaultCustomSampleFromBeatmap(string expectedSample)
|
||||
{
|
||||
setupSkins(expectedSample, expectedSample);
|
||||
|
||||
createTestWithBeatmap("hitobject-beatmap-custom-sample.osu");
|
||||
|
||||
assertBeatmapLookup(expectedSample);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that a hitobject which provides a custom sample set of 2 retrieves the following samples from the user skin when the beatmap does not contain the sample:
|
||||
/// normal-hitnormal2
|
||||
/// normal-hitnormal
|
||||
/// </summary>
|
||||
[TestCase("normal-hitnormal2")]
|
||||
[TestCase("normal-hitnormal")]
|
||||
public void TestDefaultCustomSampleFromUserSkinFallback(string expectedSample)
|
||||
{
|
||||
setupSkins(string.Empty, expectedSample);
|
||||
|
||||
createTestWithBeatmap("hitobject-beatmap-custom-sample.osu");
|
||||
|
||||
assertUserLookup(expectedSample);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that a hitobject which provides a sample file retrieves the sample file from the beatmap skin.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestFileSampleFromBeatmap()
|
||||
{
|
||||
const string expected_sample = "hit_1.wav";
|
||||
|
||||
setupSkins(expected_sample, expected_sample);
|
||||
|
||||
createTestWithBeatmap("file-beatmap-sample.osu");
|
||||
|
||||
assertBeatmapLookup(expected_sample);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that a default hitobject and control point causes <see cref="TestDefaultSampleFromUserSkin"/>.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestControlPointSampleFromSkin()
|
||||
{
|
||||
const string expected_sample = "normal-hitnormal";
|
||||
|
||||
setupSkins(expected_sample, expected_sample);
|
||||
|
||||
createTestWithBeatmap("controlpoint-skin-sample.osu");
|
||||
|
||||
assertUserLookup(expected_sample);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that a control point that provides a custom sample set of 1 causes <see cref="TestDefaultSampleFromBeatmap"/>.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestControlPointSampleFromBeatmap()
|
||||
{
|
||||
const string expected_sample = "normal-hitnormal";
|
||||
|
||||
setupSkins(expected_sample, expected_sample);
|
||||
|
||||
createTestWithBeatmap("controlpoint-beatmap-sample.osu");
|
||||
|
||||
assertBeatmapLookup(expected_sample);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that a control point that provides a custom sample of 2 causes <see cref="TestDefaultCustomSampleFromBeatmap"/>.
|
||||
/// </summary>
|
||||
[TestCase("normal-hitnormal2")]
|
||||
[TestCase("normal-hitnormal")]
|
||||
public void TestControlPointCustomSampleFromBeatmap(string sampleName)
|
||||
{
|
||||
setupSkins(sampleName, sampleName);
|
||||
|
||||
createTestWithBeatmap("controlpoint-beatmap-custom-sample.osu");
|
||||
|
||||
assertBeatmapLookup(sampleName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that a hitobject's custom sample overrides the control point's.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestHitObjectCustomSampleOverride()
|
||||
{
|
||||
const string expected_sample = "normal-hitnormal3";
|
||||
|
||||
setupSkins(expected_sample, expected_sample);
|
||||
|
||||
createTestWithBeatmap("hitobject-beatmap-custom-sample-override.osu");
|
||||
|
||||
assertBeatmapLookup(expected_sample);
|
||||
}
|
||||
|
||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => currentTestBeatmap;
|
||||
|
||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
||||
=> new TestWorkingBeatmap(beatmapInfo, beatmapSkinResourceStore, beatmap, storyboard, Clock, Audio);
|
||||
|
||||
private IBeatmap currentTestBeatmap;
|
||||
|
||||
private void createTestWithBeatmap(string filename)
|
||||
{
|
||||
CreateTest(() =>
|
||||
{
|
||||
AddStep("clear performed lookups", () =>
|
||||
{
|
||||
userSkinResourceStore.PerformedLookups.Clear();
|
||||
beatmapSkinResourceStore.PerformedLookups.Clear();
|
||||
});
|
||||
|
||||
AddStep($"load {filename}", () =>
|
||||
{
|
||||
using (var reader = new LineBufferedReader(TestResources.OpenResource($"SampleLookups/{filename}")))
|
||||
currentTestBeatmap = Decoder.GetDecoder<Beatmap>(reader).Decode(reader);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void setupSkins(string beatmapFile, string userFile)
|
||||
{
|
||||
AddStep("setup skins", () =>
|
||||
{
|
||||
userSkinInfo.Files = new List<SkinFileInfo>
|
||||
{
|
||||
new SkinFileInfo
|
||||
{
|
||||
Filename = userFile,
|
||||
FileInfo = new IO.FileInfo { Hash = userFile }
|
||||
}
|
||||
};
|
||||
|
||||
beatmapInfo.BeatmapSet.Files = new List<BeatmapSetFileInfo>
|
||||
{
|
||||
new BeatmapSetFileInfo
|
||||
{
|
||||
Filename = beatmapFile,
|
||||
FileInfo = new IO.FileInfo { Hash = beatmapFile }
|
||||
}
|
||||
};
|
||||
|
||||
// Need to refresh the cached skin source to refresh the skin resource store.
|
||||
dependencies.SkinSource = new SkinProvidingContainer(new LegacySkin(userSkinInfo, userSkinResourceStore, Audio));
|
||||
});
|
||||
}
|
||||
|
||||
private void assertBeatmapLookup(string name) => AddAssert($"\"{name}\" looked up from beatmap skin",
|
||||
() => !userSkinResourceStore.PerformedLookups.Contains(name) && beatmapSkinResourceStore.PerformedLookups.Contains(name));
|
||||
|
||||
private void assertUserLookup(string name) => AddAssert($"\"{name}\" looked up from user skin",
|
||||
() => !beatmapSkinResourceStore.PerformedLookups.Contains(name) && userSkinResourceStore.PerformedLookups.Contains(name));
|
||||
|
||||
private class SkinSourceDependencyContainer : IReadOnlyDependencyContainer
|
||||
{
|
||||
public ISkinSource SkinSource;
|
||||
|
||||
private readonly IReadOnlyDependencyContainer fallback;
|
||||
|
||||
public SkinSourceDependencyContainer(IReadOnlyDependencyContainer fallback)
|
||||
{
|
||||
this.fallback = fallback;
|
||||
}
|
||||
|
||||
public object Get(Type type)
|
||||
{
|
||||
if (type == typeof(ISkinSource))
|
||||
return SkinSource;
|
||||
|
||||
return fallback.Get(type);
|
||||
}
|
||||
|
||||
public object Get(Type type, CacheInfo info)
|
||||
{
|
||||
if (type == typeof(ISkinSource))
|
||||
return SkinSource;
|
||||
|
||||
return fallback.Get(type, info);
|
||||
}
|
||||
|
||||
public void Inject<T>(T instance) where T : class
|
||||
{
|
||||
// Never used directly
|
||||
}
|
||||
}
|
||||
|
||||
private class TestResourceStore : IResourceStore<byte[]>
|
||||
{
|
||||
public readonly List<string> PerformedLookups = new List<string>();
|
||||
|
||||
public byte[] Get(string name)
|
||||
{
|
||||
markLookup(name);
|
||||
return Array.Empty<byte>();
|
||||
}
|
||||
|
||||
public Task<byte[]> GetAsync(string name)
|
||||
{
|
||||
markLookup(name);
|
||||
return Task.FromResult(Array.Empty<byte>());
|
||||
}
|
||||
|
||||
public Stream GetStream(string name)
|
||||
{
|
||||
markLookup(name);
|
||||
return new MemoryStream();
|
||||
}
|
||||
|
||||
private void markLookup(string name) => PerformedLookups.Add(name.Substring(name.LastIndexOf(Path.DirectorySeparatorChar) + 1));
|
||||
|
||||
public IEnumerable<string> GetAvailableResources() => Enumerable.Empty<string>();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class TestWorkingBeatmap : ClockBackedTestWorkingBeatmap
|
||||
{
|
||||
private readonly BeatmapInfo skinBeatmapInfo;
|
||||
private readonly IResourceStore<byte[]> resourceStore;
|
||||
|
||||
public TestWorkingBeatmap(BeatmapInfo skinBeatmapInfo, IResourceStore<byte[]> resourceStore, IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock referenceClock, AudioManager audio,
|
||||
double length = 60000)
|
||||
: base(beatmap, storyboard, referenceClock, audio, length)
|
||||
{
|
||||
this.skinBeatmapInfo = skinBeatmapInfo;
|
||||
this.resourceStore = resourceStore;
|
||||
}
|
||||
|
||||
protected override ISkin GetSkin() => new LegacyBeatmapSkin(skinBeatmapInfo, resourceStore, AudioManager);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
osu file format v14
|
||||
|
||||
[TimingPoints]
|
||||
0,300,4,0,2,100,1,0
|
||||
|
||||
[HitObjects]
|
||||
444,320,1000,5,0,0:0:0:0:
|
@ -0,0 +1,7 @@
|
||||
osu file format v14
|
||||
|
||||
[TimingPoints]
|
||||
0,300,4,0,1,100,1,0
|
||||
|
||||
[HitObjects]
|
||||
444,320,1000,5,0,0:0:0:0:
|
@ -0,0 +1,7 @@
|
||||
osu file format v14
|
||||
|
||||
[TimingPoints]
|
||||
0,300,4,0,0,100,1,0
|
||||
|
||||
[HitObjects]
|
||||
444,320,1000,5,0,0:0:0:0:
|
@ -0,0 +1,4 @@
|
||||
osu file format v14
|
||||
|
||||
[HitObjects]
|
||||
255,193,2170,1,0,0:0:0:0:hit_1.wav
|
@ -0,0 +1,7 @@
|
||||
osu file format v14
|
||||
|
||||
[TimingPoints]
|
||||
0,300,4,0,2,100,1,0
|
||||
|
||||
[HitObjects]
|
||||
444,320,1000,5,0,0:0:3:0:
|
@ -0,0 +1,4 @@
|
||||
osu file format v14
|
||||
|
||||
[HitObjects]
|
||||
444,320,1000,5,0,0:0:2:0:
|
@ -0,0 +1,4 @@
|
||||
osu file format v14
|
||||
|
||||
[HitObjects]
|
||||
444,320,1000,5,0,0:0:1:0:
|
@ -0,0 +1,4 @@
|
||||
osu file format v14
|
||||
|
||||
[HitObjects]
|
||||
444,320,1000,5,0,0:0:0:0:
|
91
osu.Game.Tests/Visual/UserInterface/TestSceneOsuMenu.cs
Normal file
91
osu.Game.Tests/Visual/UserInterface/TestSceneOsuMenu.cs
Normal file
@ -0,0 +1,91 @@
|
||||
// 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 System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneOsuMenu : OsuManualInputManagerTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(OsuMenu),
|
||||
typeof(DrawableOsuMenuItem)
|
||||
};
|
||||
|
||||
private OsuMenu menu;
|
||||
private bool actionPerformed;
|
||||
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
actionPerformed = false;
|
||||
|
||||
Child = menu = new OsuMenu(Direction.Vertical, true)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Items = new[]
|
||||
{
|
||||
new OsuMenuItem("standard", MenuItemType.Standard, performAction),
|
||||
new OsuMenuItem("highlighted", MenuItemType.Highlighted, performAction),
|
||||
new OsuMenuItem("destructive", MenuItemType.Destructive, performAction),
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestClickEnabledMenuItem()
|
||||
{
|
||||
AddStep("move to first menu item", () => InputManager.MoveMouseTo(menu.ChildrenOfType<DrawableOsuMenuItem>().First()));
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("action performed", () => actionPerformed);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDisableMenuItemsAndClick()
|
||||
{
|
||||
AddStep("disable menu items", () =>
|
||||
{
|
||||
foreach (var item in menu.Items)
|
||||
((OsuMenuItem)item).Action.Disabled = true;
|
||||
});
|
||||
|
||||
AddStep("move to first menu item", () => InputManager.MoveMouseTo(menu.ChildrenOfType<DrawableOsuMenuItem>().First()));
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("action not performed", () => !actionPerformed);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEnableMenuItemsAndClick()
|
||||
{
|
||||
AddStep("disable menu items", () =>
|
||||
{
|
||||
foreach (var item in menu.Items)
|
||||
((OsuMenuItem)item).Action.Disabled = true;
|
||||
});
|
||||
|
||||
AddStep("enable menu items", () =>
|
||||
{
|
||||
foreach (var item in menu.Items)
|
||||
((OsuMenuItem)item).Action.Disabled = false;
|
||||
});
|
||||
|
||||
AddStep("move to first menu item", () => InputManager.MoveMouseTo(menu.ChildrenOfType<DrawableOsuMenuItem>().First()));
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("action performed", () => actionPerformed);
|
||||
}
|
||||
|
||||
private void performAction() => actionPerformed = true;
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ using osu.Framework.Logging;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets.Objects.Legacy;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Formats
|
||||
@ -168,8 +169,11 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
var baseInfo = base.ApplyTo(hitSampleInfo);
|
||||
|
||||
if (string.IsNullOrEmpty(baseInfo.Suffix) && CustomSampleBank > 1)
|
||||
baseInfo.Suffix = CustomSampleBank.ToString();
|
||||
if (baseInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacy
|
||||
&& legacy.CustomSampleBank == 0)
|
||||
{
|
||||
legacy.CustomSampleBank = CustomSampleBank;
|
||||
}
|
||||
|
||||
return baseInfo;
|
||||
}
|
||||
|
@ -42,6 +42,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
BackgroundColourHover = Color4Extensions.FromHex(@"172023");
|
||||
|
||||
updateTextColour();
|
||||
|
||||
Item.Action.BindDisabledChanged(_ => updateState(), true);
|
||||
}
|
||||
|
||||
private void updateTextColour()
|
||||
@ -65,19 +67,33 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
sampleHover.Play();
|
||||
text.BoldText.FadeIn(transition_length, Easing.OutQuint);
|
||||
text.NormalText.FadeOut(transition_length, Easing.OutQuint);
|
||||
updateState();
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
text.BoldText.FadeOut(transition_length, Easing.OutQuint);
|
||||
text.NormalText.FadeIn(transition_length, Easing.OutQuint);
|
||||
updateState();
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
Alpha = Item.Action.Disabled ? 0.2f : 1;
|
||||
|
||||
if (IsHovered && !Item.Action.Disabled)
|
||||
{
|
||||
sampleHover.Play();
|
||||
text.BoldText.FadeIn(transition_length, Easing.OutQuint);
|
||||
text.NormalText.FadeOut(transition_length, Easing.OutQuint);
|
||||
}
|
||||
else
|
||||
{
|
||||
text.BoldText.FadeOut(transition_length, Easing.OutQuint);
|
||||
text.NormalText.FadeIn(transition_length, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
sampleClick.Play();
|
||||
|
@ -409,22 +409,34 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
||||
public SampleBankInfo Clone() => (SampleBankInfo)MemberwiseClone();
|
||||
}
|
||||
|
||||
private class LegacyHitSampleInfo : HitSampleInfo
|
||||
internal class LegacyHitSampleInfo : HitSampleInfo
|
||||
{
|
||||
private int customSampleBank;
|
||||
|
||||
public int CustomSampleBank
|
||||
{
|
||||
get => customSampleBank;
|
||||
set
|
||||
{
|
||||
if (value > 1)
|
||||
customSampleBank = value;
|
||||
|
||||
if (value >= 2)
|
||||
Suffix = value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class FileHitSampleInfo : HitSampleInfo
|
||||
private class FileHitSampleInfo : LegacyHitSampleInfo
|
||||
{
|
||||
public string Filename;
|
||||
|
||||
public FileHitSampleInfo()
|
||||
{
|
||||
// Make sure that the LegacyBeatmapSkin does not fall back to the user skin.
|
||||
// Note that this does not change the lookup names, as they are overridden locally.
|
||||
CustomSampleBank = 1;
|
||||
}
|
||||
|
||||
public override IEnumerable<string> LookupNames => new[]
|
||||
{
|
||||
Filename,
|
||||
|
@ -107,6 +107,8 @@ namespace osu.Game.Screens.Edit
|
||||
dependencies.CacheAs<IEditorChangeHandler>(changeHandler);
|
||||
|
||||
EditorMenuBar menuBar;
|
||||
OsuMenuItem undoMenuItem;
|
||||
OsuMenuItem redoMenuItem;
|
||||
|
||||
var fileMenuItems = new List<MenuItem>
|
||||
{
|
||||
@ -155,8 +157,8 @@ namespace osu.Game.Screens.Edit
|
||||
{
|
||||
Items = new[]
|
||||
{
|
||||
new EditorMenuItem("Undo", MenuItemType.Standard, undo),
|
||||
new EditorMenuItem("Redo", MenuItemType.Standard, redo)
|
||||
undoMenuItem = new EditorMenuItem("Undo", MenuItemType.Standard, undo),
|
||||
redoMenuItem = new EditorMenuItem("Redo", MenuItemType.Standard, redo)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -214,6 +216,9 @@ namespace osu.Game.Screens.Edit
|
||||
}
|
||||
});
|
||||
|
||||
changeHandler.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||
changeHandler.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||
|
||||
menuBar.Mode.ValueChanged += onModeChanged;
|
||||
|
||||
bottomBackground.Colour = colours.Gray2;
|
||||
|
@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
@ -15,8 +16,10 @@ namespace osu.Game.Screens.Edit
|
||||
/// </summary>
|
||||
public class EditorChangeHandler : IEditorChangeHandler
|
||||
{
|
||||
private readonly LegacyEditorBeatmapPatcher patcher;
|
||||
public readonly Bindable<bool> CanUndo = new Bindable<bool>();
|
||||
public readonly Bindable<bool> CanRedo = new Bindable<bool>();
|
||||
|
||||
private readonly LegacyEditorBeatmapPatcher patcher;
|
||||
private readonly List<byte[]> savedStates = new List<byte[]>();
|
||||
|
||||
private int currentState = -1;
|
||||
@ -45,8 +48,6 @@ namespace osu.Game.Screens.Edit
|
||||
SaveState();
|
||||
}
|
||||
|
||||
public bool HasUndoState => currentState > 0;
|
||||
|
||||
private void hitObjectAdded(HitObject obj) => SaveState();
|
||||
|
||||
private void hitObjectRemoved(HitObject obj) => SaveState();
|
||||
@ -90,6 +91,8 @@ namespace osu.Game.Screens.Edit
|
||||
}
|
||||
|
||||
currentState = savedStates.Count - 1;
|
||||
|
||||
updateBindables();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -114,6 +117,14 @@ namespace osu.Game.Screens.Edit
|
||||
currentState = newState;
|
||||
|
||||
isRestoring = false;
|
||||
|
||||
updateBindables();
|
||||
}
|
||||
|
||||
private void updateBindables()
|
||||
{
|
||||
CanUndo.Value = savedStates.Count > 0 && currentState > 0;
|
||||
CanRedo.Value = currentState < savedStates.Count - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,12 +49,13 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(SongSelect songSelect, BeatmapManager manager)
|
||||
private void load(BeatmapManager manager, SongSelect songSelect)
|
||||
{
|
||||
if (songSelect != null)
|
||||
{
|
||||
startRequested = b => songSelect.FinaliseSelection(b);
|
||||
editRequested = songSelect.Edit;
|
||||
if (songSelect.AllowEditing)
|
||||
editRequested = songSelect.Edit;
|
||||
}
|
||||
|
||||
if (manager != null)
|
||||
@ -187,15 +188,19 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
get
|
||||
{
|
||||
List<MenuItem> items = new List<MenuItem>
|
||||
{
|
||||
new OsuMenuItem("Play", MenuItemType.Highlighted, () => startRequested?.Invoke(beatmap)),
|
||||
new OsuMenuItem("Edit", MenuItemType.Standard, () => editRequested?.Invoke(beatmap)),
|
||||
new OsuMenuItem("Hide", MenuItemType.Destructive, () => hideRequested?.Invoke(beatmap)),
|
||||
};
|
||||
List<MenuItem> items = new List<MenuItem>();
|
||||
|
||||
if (beatmap.OnlineBeatmapID.HasValue)
|
||||
items.Add(new OsuMenuItem("Details", MenuItemType.Standard, () => beatmapOverlay?.FetchAndShowBeatmap(beatmap.OnlineBeatmapID.Value)));
|
||||
if (startRequested != null)
|
||||
items.Add(new OsuMenuItem("Play", MenuItemType.Highlighted, () => startRequested(beatmap)));
|
||||
|
||||
if (editRequested != null)
|
||||
items.Add(new OsuMenuItem("Edit", MenuItemType.Standard, () => editRequested(beatmap)));
|
||||
|
||||
if (hideRequested != null)
|
||||
items.Add(new OsuMenuItem("Hide", MenuItemType.Destructive, () => hideRequested(beatmap)));
|
||||
|
||||
if (beatmap.OnlineBeatmapID.HasValue && beatmapOverlay != null)
|
||||
items.Add(new OsuMenuItem("Details", MenuItemType.Standard, () => beatmapOverlay.FetchAndShowBeatmap(beatmap.OnlineBeatmapID.Value)));
|
||||
|
||||
return items.ToArray();
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
private void load(BeatmapManager manager, BeatmapSetOverlay beatmapOverlay)
|
||||
{
|
||||
restoreHiddenRequested = s => s.Beatmaps.ForEach(manager.Restore);
|
||||
|
||||
if (beatmapOverlay != null)
|
||||
viewDetails = beatmapOverlay.FetchAndShowBeatmapSet;
|
||||
|
||||
@ -131,13 +132,14 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
if (Item.State.Value == CarouselItemState.NotSelected)
|
||||
items.Add(new OsuMenuItem("Expand", MenuItemType.Highlighted, () => Item.State.Value = CarouselItemState.Selected));
|
||||
|
||||
if (beatmapSet.OnlineBeatmapSetID != null)
|
||||
items.Add(new OsuMenuItem("Details...", MenuItemType.Standard, () => viewDetails?.Invoke(beatmapSet.OnlineBeatmapSetID.Value)));
|
||||
if (beatmapSet.OnlineBeatmapSetID != null && viewDetails != null)
|
||||
items.Add(new OsuMenuItem("Details...", MenuItemType.Standard, () => viewDetails(beatmapSet.OnlineBeatmapSetID.Value)));
|
||||
|
||||
if (beatmapSet.Beatmaps.Any(b => b.Hidden))
|
||||
items.Add(new OsuMenuItem("Restore all hidden", MenuItemType.Standard, () => restoreHiddenRequested?.Invoke(beatmapSet)));
|
||||
items.Add(new OsuMenuItem("Restore all hidden", MenuItemType.Standard, () => restoreHiddenRequested(beatmapSet)));
|
||||
|
||||
items.Add(new OsuMenuItem("Delete", MenuItemType.Destructive, () => dialogOverlay?.Push(new BeatmapDeleteDialog(beatmapSet))));
|
||||
if (dialogOverlay != null)
|
||||
items.Add(new OsuMenuItem("Delete", MenuItemType.Destructive, () => dialogOverlay.Push(new BeatmapDeleteDialog(beatmapSet))));
|
||||
|
||||
return items.ToArray();
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
@ -71,9 +70,6 @@ namespace osu.Game.Screens.Select
|
||||
/// </summary>
|
||||
public virtual bool AllowEditing => true;
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private NotificationOverlay notificationOverlay { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private Bindable<IReadOnlyList<Mod>> selectedMods { get; set; }
|
||||
|
||||
@ -329,10 +325,7 @@ namespace osu.Game.Screens.Select
|
||||
public void Edit(BeatmapInfo beatmap = null)
|
||||
{
|
||||
if (!AllowEditing)
|
||||
{
|
||||
notificationOverlay?.Post(new SimpleNotification { Text = "Editing is not available from the current mode." });
|
||||
return;
|
||||
}
|
||||
throw new InvalidOperationException($"Attempted to edit when {nameof(AllowEditing)} is disabled");
|
||||
|
||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap ?? beatmapNoDebounce);
|
||||
this.Push(new Editor());
|
||||
|
@ -2,9 +2,12 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Objects.Legacy;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
@ -33,6 +36,17 @@ namespace osu.Game.Skinning
|
||||
return base.GetConfig<TLookup, TValue>(lookup);
|
||||
}
|
||||
|
||||
public override SampleChannel GetSample(ISampleInfo sampleInfo)
|
||||
{
|
||||
if (sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacy && legacy.CustomSampleBank == 0)
|
||||
{
|
||||
// When no custom sample bank is provided, always fall-back to the default samples.
|
||||
return null;
|
||||
}
|
||||
|
||||
return base.GetSample(sampleInfo);
|
||||
}
|
||||
|
||||
private static SkinInfo createSkinInfo(BeatmapInfo beatmap) =>
|
||||
new SkinInfo { Name = beatmap.ToString(), Creator = beatmap.Metadata.Author.ToString() };
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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 osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -18,8 +19,9 @@ namespace osu.Game.Tests.Beatmaps
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The beatmap.</param>
|
||||
/// <param name="storyboard">An optional storyboard.</param>
|
||||
public TestWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
||||
: base(beatmap.BeatmapInfo, null)
|
||||
/// <param name="audioManager">The <see cref="AudioManager"/>.</param>
|
||||
public TestWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null, AudioManager audioManager = null)
|
||||
: base(beatmap.BeatmapInfo, audioManager)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
this.storyboard = storyboard;
|
||||
|
@ -179,7 +179,7 @@ namespace osu.Game.Tests.Visual
|
||||
/// <param name="audio">Audio manager. Required if a reference clock isn't provided.</param>
|
||||
/// <param name="length">The length of the returned virtual track.</param>
|
||||
public ClockBackedTestWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock referenceClock, AudioManager audio, double length = 60000)
|
||||
: base(beatmap, storyboard)
|
||||
: base(beatmap, storyboard, audio)
|
||||
{
|
||||
if (referenceClock != null)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user