mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 04:32:55 +08:00
Simplify available file lookup and include file extension
This commit is contained in:
parent
2b7105ac4f
commit
314ad63c6e
@ -350,7 +350,7 @@ namespace osu.Game.Skinning.Editor
|
|||||||
// place component
|
// place component
|
||||||
placeComponent(new SkinnableSprite
|
placeComponent(new SkinnableSprite
|
||||||
{
|
{
|
||||||
SpriteName = { Value = Path.GetFileNameWithoutExtension(file.Name) }
|
SpriteName = { Value = file.Name }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// 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.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -31,13 +30,6 @@ namespace osu.Game.Skinning
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private ISkinSource source { get; set; }
|
private ISkinSource source { get; set; }
|
||||||
|
|
||||||
public IEnumerable<string> AvailableFiles => (source.AllSources.First() as Skin)?.SkinInfo.PerformRead(s => s.Files
|
|
||||||
.Where(f =>
|
|
||||||
f.Filename.EndsWith(".png", StringComparison.Ordinal)
|
|
||||||
|| f.Filename.EndsWith(".jpg", StringComparison.Ordinal)
|
|
||||||
)
|
|
||||||
.Select(f => f.Filename).Distinct());
|
|
||||||
|
|
||||||
public SkinnableSprite(string textureName, ConfineMode confineMode = ConfineMode.NoScaling)
|
public SkinnableSprite(string textureName, ConfineMode confineMode = ConfineMode.NoScaling)
|
||||||
: base(new SpriteComponent(textureName), confineMode)
|
: base(new SpriteComponent(textureName), confineMode)
|
||||||
{
|
{
|
||||||
@ -88,14 +80,22 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
public class SpriteSelectorControl : SettingsDropdown<string>
|
public class SpriteSelectorControl : SettingsDropdown<string>
|
||||||
{
|
{
|
||||||
public SkinnableSprite Source { get; set; }
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
if (Source.AvailableFiles.Any())
|
// Round-about way of getting the user's skin to find available resources.
|
||||||
Items = Source.AvailableFiles;
|
// In the future we'll probably want to allow access to resources from the fallbacks, or potentially other skins
|
||||||
|
// but that requires further thought.
|
||||||
|
var highestPrioritySkin = ((SkinnableSprite)Source).source.AllSources.First() as Skin;
|
||||||
|
|
||||||
|
string[] availableFiles = highestPrioritySkin?.SkinInfo.PerformRead(s => s.Files
|
||||||
|
.Where(f => f.Filename.EndsWith(".png", StringComparison.Ordinal)
|
||||||
|
|| f.Filename.EndsWith(".jpg", StringComparison.Ordinal))
|
||||||
|
.Select(f => f.Filename).Distinct()).ToArray();
|
||||||
|
|
||||||
|
if (availableFiles?.Length > 0)
|
||||||
|
Items = availableFiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user