mirror of
https://github.com/ppy/osu.git
synced 2025-01-07 22:22:59 +08:00
Merge branch 'master' into fix-batch-import-score-missing-notifications
This commit is contained in:
commit
0769d0f49f
@ -41,6 +41,7 @@ namespace osu.Game.Rulesets.Mania
|
|||||||
},
|
},
|
||||||
new SettingsCheckbox
|
new SettingsCheckbox
|
||||||
{
|
{
|
||||||
|
Keywords = new[] { "color" },
|
||||||
LabelText = RulesetSettingsStrings.TimingBasedColouring,
|
LabelText = RulesetSettingsStrings.TimingBasedColouring,
|
||||||
Current = config.GetBindable<bool>(ManiaRulesetSetting.TimingBasedNoteColouring),
|
Current = config.GetBindable<bool>(ManiaRulesetSetting.TimingBasedNoteColouring),
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,23 @@
|
|||||||
// 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.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Storyboards;
|
using osu.Game.Storyboards;
|
||||||
using osu.Game.Storyboards.Drawables;
|
using osu.Game.Storyboards.Drawables;
|
||||||
|
using osu.Game.Tests.Resources;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
@ -21,17 +27,21 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset();
|
protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset();
|
||||||
|
|
||||||
[Cached]
|
[Cached(typeof(Storyboard))]
|
||||||
private Storyboard storyboard { get; set; } = new Storyboard();
|
private TestStoryboard storyboard { get; set; } = new TestStoryboard();
|
||||||
|
|
||||||
private IEnumerable<DrawableStoryboardSprite> sprites => this.ChildrenOfType<DrawableStoryboardSprite>();
|
private IEnumerable<DrawableStoryboardSprite> sprites => this.ChildrenOfType<DrawableStoryboardSprite>();
|
||||||
|
|
||||||
|
private const string lookup_name = "hitcircleoverlay";
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestSkinSpriteDisallowedByDefault()
|
public void TestSkinSpriteDisallowedByDefault()
|
||||||
{
|
{
|
||||||
const string lookup_name = "hitcircleoverlay";
|
AddStep("disallow all lookups", () =>
|
||||||
|
{
|
||||||
AddStep("allow skin lookup", () => storyboard.UseSkinSprites = false);
|
storyboard.UseSkinSprites = false;
|
||||||
|
storyboard.AlwaysProvideTexture = false;
|
||||||
|
});
|
||||||
|
|
||||||
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
||||||
|
|
||||||
@ -40,11 +50,13 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestAllowLookupFromSkin()
|
public void TestLookupFromStoryboard()
|
||||||
{
|
{
|
||||||
const string lookup_name = "hitcircleoverlay";
|
AddStep("allow storyboard lookup", () =>
|
||||||
|
{
|
||||||
AddStep("allow skin lookup", () => storyboard.UseSkinSprites = true);
|
storyboard.UseSkinSprites = false;
|
||||||
|
storyboard.AlwaysProvideTexture = true;
|
||||||
|
});
|
||||||
|
|
||||||
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
||||||
|
|
||||||
@ -52,16 +64,54 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddAssert("sprite found texture", () =>
|
AddAssert("sprite found texture", () =>
|
||||||
sprites.Any(sprite => sprite.ChildrenOfType<Sprite>().All(s => s.Texture != null)));
|
sprites.Any(sprite => sprite.ChildrenOfType<Sprite>().All(s => s.Texture != null)));
|
||||||
|
|
||||||
AddAssert("skinnable sprite has correct size", () =>
|
assertStoryboardSourced();
|
||||||
sprites.Any(sprite => sprite.ChildrenOfType<Sprite>().All(s => s.Size == new Vector2(128))));
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSkinLookupPreferredOverStoryboard()
|
||||||
|
{
|
||||||
|
AddStep("allow all lookups", () =>
|
||||||
|
{
|
||||||
|
storyboard.UseSkinSprites = true;
|
||||||
|
storyboard.AlwaysProvideTexture = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
||||||
|
|
||||||
|
// Only checking for at least one sprite that succeeded, as not all skins in this test provide the hitcircleoverlay texture.
|
||||||
|
AddAssert("sprite found texture", () =>
|
||||||
|
sprites.Any(sprite => sprite.ChildrenOfType<Sprite>().All(s => s.Texture != null)));
|
||||||
|
|
||||||
|
assertSkinSourced();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAllowLookupFromSkin()
|
||||||
|
{
|
||||||
|
AddStep("allow skin lookup", () =>
|
||||||
|
{
|
||||||
|
storyboard.UseSkinSprites = true;
|
||||||
|
storyboard.AlwaysProvideTexture = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
||||||
|
|
||||||
|
// Only checking for at least one sprite that succeeded, as not all skins in this test provide the hitcircleoverlay texture.
|
||||||
|
AddAssert("sprite found texture", () =>
|
||||||
|
sprites.Any(sprite => sprite.ChildrenOfType<Sprite>().All(s => s.Texture != null)));
|
||||||
|
|
||||||
|
assertSkinSourced();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestFlippedSprite()
|
public void TestFlippedSprite()
|
||||||
{
|
{
|
||||||
const string lookup_name = "hitcircleoverlay";
|
AddStep("allow all lookups", () =>
|
||||||
|
{
|
||||||
|
storyboard.UseSkinSprites = true;
|
||||||
|
storyboard.AlwaysProvideTexture = true;
|
||||||
|
});
|
||||||
|
|
||||||
AddStep("allow skin lookup", () => storyboard.UseSkinSprites = true);
|
|
||||||
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
||||||
AddStep("flip sprites", () => sprites.ForEach(s =>
|
AddStep("flip sprites", () => sprites.ForEach(s =>
|
||||||
{
|
{
|
||||||
@ -74,9 +124,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestZeroScale()
|
public void TestZeroScale()
|
||||||
{
|
{
|
||||||
const string lookup_name = "hitcircleoverlay";
|
AddStep("allow all lookups", () =>
|
||||||
|
{
|
||||||
|
storyboard.UseSkinSprites = true;
|
||||||
|
storyboard.AlwaysProvideTexture = true;
|
||||||
|
});
|
||||||
|
|
||||||
AddStep("allow skin lookup", () => storyboard.UseSkinSprites = true);
|
|
||||||
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
||||||
AddAssert("sprites present", () => sprites.All(s => s.IsPresent));
|
AddAssert("sprites present", () => sprites.All(s => s.IsPresent));
|
||||||
AddStep("scale sprite", () => sprites.ForEach(s => s.VectorScale = new Vector2(0, 1)));
|
AddStep("scale sprite", () => sprites.ForEach(s => s.VectorScale = new Vector2(0, 1)));
|
||||||
@ -86,9 +139,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestNegativeScale()
|
public void TestNegativeScale()
|
||||||
{
|
{
|
||||||
const string lookup_name = "hitcircleoverlay";
|
AddStep("allow all lookups", () =>
|
||||||
|
{
|
||||||
|
storyboard.UseSkinSprites = true;
|
||||||
|
storyboard.AlwaysProvideTexture = true;
|
||||||
|
});
|
||||||
|
|
||||||
AddStep("allow skin lookup", () => storyboard.UseSkinSprites = true);
|
|
||||||
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
||||||
AddStep("scale sprite", () => sprites.ForEach(s => s.VectorScale = new Vector2(-1)));
|
AddStep("scale sprite", () => sprites.ForEach(s => s.VectorScale = new Vector2(-1)));
|
||||||
AddAssert("origin flipped", () => sprites.All(s => s.Origin == Anchor.BottomRight));
|
AddAssert("origin flipped", () => sprites.All(s => s.Origin == Anchor.BottomRight));
|
||||||
@ -97,9 +153,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestNegativeScaleWithFlippedSprite()
|
public void TestNegativeScaleWithFlippedSprite()
|
||||||
{
|
{
|
||||||
const string lookup_name = "hitcircleoverlay";
|
AddStep("allow all lookups", () =>
|
||||||
|
{
|
||||||
|
storyboard.UseSkinSprites = true;
|
||||||
|
storyboard.AlwaysProvideTexture = true;
|
||||||
|
});
|
||||||
|
|
||||||
AddStep("allow skin lookup", () => storyboard.UseSkinSprites = true);
|
|
||||||
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
||||||
AddStep("scale sprite", () => sprites.ForEach(s => s.VectorScale = new Vector2(-1)));
|
AddStep("scale sprite", () => sprites.ForEach(s => s.VectorScale = new Vector2(-1)));
|
||||||
AddAssert("origin flipped", () => sprites.All(s => s.Origin == Anchor.BottomRight));
|
AddAssert("origin flipped", () => sprites.All(s => s.Origin == Anchor.BottomRight));
|
||||||
@ -111,13 +170,78 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddAssert("origin back", () => sprites.All(s => s.Origin == Anchor.TopLeft));
|
AddAssert("origin back", () => sprites.All(s => s.Origin == Anchor.TopLeft));
|
||||||
}
|
}
|
||||||
|
|
||||||
private DrawableStoryboardSprite createSprite(string lookupName, Anchor origin, Vector2 initialPosition)
|
private DrawableStoryboard createSprite(string lookupName, Anchor origin, Vector2 initialPosition)
|
||||||
=> new DrawableStoryboardSprite(
|
{
|
||||||
new StoryboardSprite(lookupName, origin, initialPosition)
|
var layer = storyboard.GetLayer("Background");
|
||||||
).With(s =>
|
|
||||||
|
var sprite = new StoryboardSprite(lookupName, origin, initialPosition);
|
||||||
|
sprite.AddLoop(Time.Current, 100).Alpha.Add(Easing.None, 0, 10000, 1, 1);
|
||||||
|
|
||||||
|
layer.Elements.Clear();
|
||||||
|
layer.Add(sprite);
|
||||||
|
|
||||||
|
return storyboard.CreateDrawable().With(s => s.RelativeSizeAxes = Axes.Both);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertStoryboardSourced()
|
||||||
|
{
|
||||||
|
AddAssert("sprite came from storyboard", () =>
|
||||||
|
sprites.Any(sprite => sprite.ChildrenOfType<Sprite>().All(s => s.Size == new Vector2(200))));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertSkinSourced()
|
||||||
|
{
|
||||||
|
AddAssert("sprite came from skin", () =>
|
||||||
|
sprites.Any(sprite => sprite.ChildrenOfType<Sprite>().All(s => s.Size == new Vector2(128))));
|
||||||
|
}
|
||||||
|
|
||||||
|
private partial class TestStoryboard : Storyboard
|
||||||
|
{
|
||||||
|
public override DrawableStoryboard CreateDrawable(IReadOnlyList<Mod>? mods = null)
|
||||||
{
|
{
|
||||||
s.LifetimeStart = double.MinValue;
|
return new TestDrawableStoryboard(this, mods);
|
||||||
s.LifetimeEnd = double.MaxValue;
|
}
|
||||||
});
|
|
||||||
|
public bool AlwaysProvideTexture { get; set; }
|
||||||
|
|
||||||
|
public override string GetStoragePathFromStoryboardPath(string path) => AlwaysProvideTexture ? path : string.Empty;
|
||||||
|
|
||||||
|
private partial class TestDrawableStoryboard : DrawableStoryboard
|
||||||
|
{
|
||||||
|
private readonly bool alwaysProvideTexture;
|
||||||
|
|
||||||
|
public TestDrawableStoryboard(TestStoryboard storyboard, IReadOnlyList<Mod>? mods)
|
||||||
|
: base(storyboard, mods)
|
||||||
|
{
|
||||||
|
alwaysProvideTexture = storyboard.AlwaysProvideTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IResourceStore<byte[]> CreateResourceLookupStore() => alwaysProvideTexture
|
||||||
|
? new AlwaysReturnsTextureStore()
|
||||||
|
: new ResourceStore<byte[]>();
|
||||||
|
|
||||||
|
internal class AlwaysReturnsTextureStore : IResourceStore<byte[]>
|
||||||
|
{
|
||||||
|
private const string test_image = "Resources/Textures/test-image.png";
|
||||||
|
|
||||||
|
private readonly DllResourceStore store;
|
||||||
|
|
||||||
|
public AlwaysReturnsTextureStore()
|
||||||
|
{
|
||||||
|
store = TestResources.GetStore();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose() => store.Dispose();
|
||||||
|
|
||||||
|
public byte[] Get(string name) => store.Get(test_image);
|
||||||
|
|
||||||
|
public Task<byte[]> GetAsync(string name, CancellationToken cancellationToken = new CancellationToken()) => store.GetAsync(test_image, cancellationToken);
|
||||||
|
|
||||||
|
public Stream GetStream(string name) => store.GetStream(test_image);
|
||||||
|
|
||||||
|
public IEnumerable<string> GetAvailableResources() => store.GetAvailableResources();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ namespace osu.Game.Database
|
|||||||
return imported;
|
return imported;
|
||||||
}
|
}
|
||||||
|
|
||||||
notification.Text = $"{HumanisedModelName.Humanize(LetterCasing.Title)} import failed!";
|
notification.Text = $"{HumanisedModelName.Humanize(LetterCasing.Title)} import failed! Check logs for more information.";
|
||||||
notification.State = ProgressNotificationState.Cancelled;
|
notification.State = ProgressNotificationState.Cancelled;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
|||||||
},
|
},
|
||||||
new SettingsCheckbox
|
new SettingsCheckbox
|
||||||
{
|
{
|
||||||
Keywords = new[] { "combo", "override" },
|
Keywords = new[] { "combo", "override", "color" },
|
||||||
LabelText = SkinSettingsStrings.BeatmapColours,
|
LabelText = SkinSettingsStrings.BeatmapColours,
|
||||||
Current = config.GetBindable<bool>(OsuSetting.BeatmapColours)
|
Current = config.GetBindable<bool>(OsuSetting.BeatmapColours)
|
||||||
},
|
},
|
||||||
@ -47,6 +47,7 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
|||||||
},
|
},
|
||||||
new SettingsSlider<float>
|
new SettingsSlider<float>
|
||||||
{
|
{
|
||||||
|
Keywords = new[] { "color" },
|
||||||
LabelText = GraphicsSettingsStrings.ComboColourNormalisation,
|
LabelText = GraphicsSettingsStrings.ComboColourNormalisation,
|
||||||
Current = comboColourNormalisation,
|
Current = comboColourNormalisation,
|
||||||
DisplayAsPercentage = true,
|
DisplayAsPercentage = true,
|
||||||
|
@ -52,20 +52,25 @@ namespace osu.Game.Scoring
|
|||||||
{
|
{
|
||||||
return new DatabasedLegacyScoreDecoder(rulesets, beatmaps()).Parse(stream).ScoreInfo;
|
return new DatabasedLegacyScoreDecoder(rulesets, beatmaps()).Parse(stream).ScoreInfo;
|
||||||
}
|
}
|
||||||
catch (LegacyScoreDecoder.BeatmapNotFoundException e)
|
catch (LegacyScoreDecoder.BeatmapNotFoundException notFound)
|
||||||
{
|
{
|
||||||
Logger.Log($@"Score '{archive.Name}' failed to import: no corresponding beatmap with the hash '{e.Hash}' could be found.", LoggingTarget.Database);
|
Logger.Log($@"Score '{archive.Name}' failed to import: no corresponding beatmap with the hash '{notFound.Hash}' could be found.", LoggingTarget.Database);
|
||||||
|
|
||||||
if (!parameters.Batch)
|
if (!parameters.Batch)
|
||||||
{
|
{
|
||||||
// In the case of a missing beatmap, let's attempt to resolve it and show a prompt to the user to download the required beatmap.
|
// In the case of a missing beatmap, let's attempt to resolve it and show a prompt to the user to download the required beatmap.
|
||||||
var req = new GetBeatmapRequest(new BeatmapInfo { MD5Hash = e.Hash });
|
var req = new GetBeatmapRequest(new BeatmapInfo { MD5Hash = notFound.Hash });
|
||||||
req.Success += res => PostNotification?.Invoke(new MissingBeatmapNotification(res, archive, e.Hash));
|
req.Success += res => PostNotification?.Invoke(new MissingBeatmapNotification(res, archive, notFound.Hash));
|
||||||
api.Queue(req);
|
api.Queue(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Log($@"Failed to parse headers of score '{archive.Name}': {e}.", LoggingTarget.Database);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
// Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info
|
// Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info
|
||||||
var localBeatmap = beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineID == beatmap.OnlineID);
|
var localBeatmap = beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineID == beatmap.OnlineID);
|
||||||
|
|
||||||
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
|
UserModsSelectOverlay.Beatmap = Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void UpdateMods()
|
protected virtual void UpdateMods()
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
{
|
{
|
||||||
public partial class DrawableStoryboard : Container<DrawableStoryboardLayer>
|
public partial class DrawableStoryboard : Container<DrawableStoryboardLayer>
|
||||||
{
|
{
|
||||||
[Cached]
|
[Cached(typeof(Storyboard))]
|
||||||
public Storyboard Storyboard { get; }
|
public Storyboard Storyboard { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -94,25 +94,19 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IBeatSyncProvider beatSyncProvider { get; set; }
|
private IBeatSyncProvider beatSyncProvider { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private TextureStore textureStore { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(TextureStore textureStore, Storyboard storyboard)
|
private void load(Storyboard storyboard)
|
||||||
{
|
{
|
||||||
int frameIndex = 0;
|
if (storyboard.UseSkinSprites)
|
||||||
|
|
||||||
Texture frameTexture = textureStore.Get(getFramePath(frameIndex));
|
|
||||||
|
|
||||||
if (frameTexture != null)
|
|
||||||
{
|
{
|
||||||
// sourcing from storyboard.
|
|
||||||
for (frameIndex = 0; frameIndex < Animation.FrameCount; frameIndex++)
|
|
||||||
AddFrame(textureStore.Get(getFramePath(frameIndex)), Animation.FrameDelay);
|
|
||||||
}
|
|
||||||
else if (storyboard.UseSkinSprites)
|
|
||||||
{
|
|
||||||
// fallback to skin if required.
|
|
||||||
skin.SourceChanged += skinSourceChanged;
|
skin.SourceChanged += skinSourceChanged;
|
||||||
skinSourceChanged();
|
skinSourceChanged();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
addFramesFromStoryboardSource();
|
||||||
|
|
||||||
Animation.ApplyTransforms(this);
|
Animation.ApplyTransforms(this);
|
||||||
}
|
}
|
||||||
@ -135,11 +129,28 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
|
|
||||||
// When reading from a skin, we match stables weird behaviour where `FrameCount` is ignored
|
// When reading from a skin, we match stables weird behaviour where `FrameCount` is ignored
|
||||||
// and resources are retrieved until the end of the animation.
|
// and resources are retrieved until the end of the animation.
|
||||||
foreach (var texture in skin.GetTextures(Path.GetFileNameWithoutExtension(Animation.Path)!, default, default, true, string.Empty, null, out _))
|
var skinTextures = skin.GetTextures(Path.GetFileNameWithoutExtension(Animation.Path)!, default, default, true, string.Empty, null, out _);
|
||||||
AddFrame(texture, Animation.FrameDelay);
|
|
||||||
|
if (skinTextures.Length > 0)
|
||||||
|
{
|
||||||
|
foreach (var texture in skinTextures)
|
||||||
|
AddFrame(texture, Animation.FrameDelay);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addFramesFromStoryboardSource();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string getFramePath(int i) => Animation.Path.Replace(".", $"{i}.");
|
private void addFramesFromStoryboardSource()
|
||||||
|
{
|
||||||
|
int frameIndex;
|
||||||
|
// sourcing from storyboard.
|
||||||
|
for (frameIndex = 0; frameIndex < Animation.FrameCount; frameIndex++)
|
||||||
|
AddFrame(textureStore.Get(getFramePath(frameIndex)), Animation.FrameDelay);
|
||||||
|
|
||||||
|
string getFramePath(int i) => Animation.Path.Replace(".", $"{i}.");
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -30,10 +31,12 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
InternalChild = ElementContainer = new LayerElementContainer(layer);
|
InternalChild = ElementContainer = new LayerElementContainer(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected partial class LayerElementContainer : LifetimeManagementContainer
|
public partial class LayerElementContainer : LifetimeManagementContainer
|
||||||
{
|
{
|
||||||
private readonly StoryboardLayer storyboardLayer;
|
private readonly StoryboardLayer storyboardLayer;
|
||||||
|
|
||||||
|
public IEnumerable<Drawable> Elements => InternalChildren;
|
||||||
|
|
||||||
public LayerElementContainer(StoryboardLayer layer)
|
public LayerElementContainer(StoryboardLayer layer)
|
||||||
{
|
{
|
||||||
storyboardLayer = layer;
|
storyboardLayer = layer;
|
||||||
|
@ -74,6 +74,12 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
public override bool IsPresent
|
public override bool IsPresent
|
||||||
=> !float.IsNaN(DrawPosition.X) && !float.IsNaN(DrawPosition.Y) && base.IsPresent;
|
=> !float.IsNaN(DrawPosition.X) && !float.IsNaN(DrawPosition.Y) && base.IsPresent;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private ISkinSource skin { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private TextureStore textureStore { get; set; } = null!;
|
||||||
|
|
||||||
public DrawableStoryboardSprite(StoryboardSprite sprite)
|
public DrawableStoryboardSprite(StoryboardSprite sprite)
|
||||||
{
|
{
|
||||||
Sprite = sprite;
|
Sprite = sprite;
|
||||||
@ -84,24 +90,28 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
LifetimeEnd = sprite.EndTimeForDisplay;
|
LifetimeEnd = sprite.EndTimeForDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private ISkinSource skin { get; set; } = null!;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(TextureStore textureStore, Storyboard storyboard)
|
private void load(Storyboard storyboard)
|
||||||
{
|
{
|
||||||
Texture = textureStore.Get(Sprite.Path);
|
if (storyboard.UseSkinSprites)
|
||||||
|
|
||||||
if (Texture == null && storyboard.UseSkinSprites)
|
|
||||||
{
|
{
|
||||||
skin.SourceChanged += skinSourceChanged;
|
skin.SourceChanged += skinSourceChanged;
|
||||||
skinSourceChanged();
|
skinSourceChanged();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
Texture = textureStore.Get(Sprite.Path);
|
||||||
|
|
||||||
Sprite.ApplyTransforms(this);
|
Sprite.ApplyTransforms(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void skinSourceChanged() => Texture = skin.GetTexture(Sprite.Path);
|
private void skinSourceChanged()
|
||||||
|
{
|
||||||
|
Texture = skin.GetTexture(Sprite.Path) ?? textureStore.Get(Sprite.Path);
|
||||||
|
|
||||||
|
// Setting texture will only update the size if it's zero.
|
||||||
|
// So let's force an explicit update.
|
||||||
|
Size = new Vector2(Texture?.DisplayWidth ?? 0, Texture?.DisplayHeight ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Storyboards
|
|||||||
public BeatmapInfo BeatmapInfo = new BeatmapInfo();
|
public BeatmapInfo BeatmapInfo = new BeatmapInfo();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the storyboard can fall back to skin sprites in case no matching storyboard sprites are found.
|
/// Whether the storyboard should prefer textures from the current skin before using local storyboard textures.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UseSkinSprites { get; set; }
|
public bool UseSkinSprites { get; set; }
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ namespace osu.Game.Storyboards
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DrawableStoryboard CreateDrawable(IReadOnlyList<Mod>? mods = null) =>
|
public virtual DrawableStoryboard CreateDrawable(IReadOnlyList<Mod>? mods = null) =>
|
||||||
new DrawableStoryboard(this, mods);
|
new DrawableStoryboard(this, mods);
|
||||||
|
|
||||||
private static readonly string[] image_extensions = { @".png", @".jpg" };
|
private static readonly string[] image_extensions = { @".png", @".jpg" };
|
||||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Storyboards
|
|||||||
|
|
||||||
public double StartTime { get; }
|
public double StartTime { get; }
|
||||||
|
|
||||||
public StoryboardVideo(string path, int offset)
|
public StoryboardVideo(string path, double offset)
|
||||||
{
|
{
|
||||||
Path = path;
|
Path = path;
|
||||||
StartTime = offset;
|
StartTime = offset;
|
||||||
|
Loading…
Reference in New Issue
Block a user