mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Add GetTexture method to ISkinSource
Used to shortcut lookup checks without potentially expensive drawable creation overhead.
This commit is contained in:
parent
9ad4e9284a
commit
f03abb3145
@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
@ -26,6 +27,8 @@ namespace osu.Game.Skinning
|
||||
|
||||
public override Drawable GetDrawableComponent(string componentName) => null;
|
||||
|
||||
public override Texture GetTexture(string componentName) => null;
|
||||
|
||||
public override SampleChannel GetSample(string sampleName) => null;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
@ -18,6 +19,8 @@ namespace osu.Game.Skinning
|
||||
|
||||
Drawable GetDrawableComponent(string componentName);
|
||||
|
||||
Texture GetTexture(string componentName);
|
||||
|
||||
SampleChannel GetSample(string sampleName);
|
||||
|
||||
Color4? GetComboColour(IHasComboIndex comboObject);
|
||||
|
@ -57,12 +57,14 @@ namespace osu.Game.Skinning
|
||||
break;
|
||||
}
|
||||
|
||||
var texture = Textures.Get(componentName);
|
||||
var texture = GetTexture(componentName);
|
||||
if (texture == null) return null;
|
||||
|
||||
return new Sprite { Texture = texture };
|
||||
}
|
||||
|
||||
public override Texture GetTexture(string componentName) => Textures.Get(componentName);
|
||||
|
||||
public override SampleChannel GetSample(string sampleName) => Samples.Get(sampleName);
|
||||
|
||||
protected class LegacySkinResourceStore<T> : IResourceStore<byte[]>
|
||||
|
@ -6,6 +6,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
@ -17,6 +18,8 @@ namespace osu.Game.Skinning
|
||||
|
||||
public Drawable GetDrawableComponent(string componentName) => source.GetDrawableComponent(componentName) ?? fallbackSource?.GetDrawableComponent(componentName);
|
||||
|
||||
public Texture GetTexture(string componentName) => source.GetTexture(componentName) ?? fallbackSource.GetTexture(componentName);
|
||||
|
||||
public SampleChannel GetSample(string sampleName) => source.GetSample(sampleName) ?? fallbackSource?.GetSample(sampleName);
|
||||
|
||||
public Color4? GetComboColour(IHasComboIndex comboObject) => source.GetComboColour(comboObject) ?? fallbackSource?.GetComboColour(comboObject);
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
@ -21,6 +22,8 @@ namespace osu.Game.Skinning
|
||||
|
||||
public abstract SampleChannel GetSample(string sampleName);
|
||||
|
||||
public abstract Texture GetTexture(string componentName);
|
||||
|
||||
public virtual Color4? GetComboColour(IHasComboIndex comboObject) =>
|
||||
Configuration.ComboColours.Count == 0 ? (Color4?)null : Configuration.ComboColours[comboObject.ComboIndex % Configuration.ComboColours.Count];
|
||||
|
||||
|
@ -10,6 +10,7 @@ using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.IO.Archives;
|
||||
@ -119,6 +120,8 @@ namespace osu.Game.Skinning
|
||||
|
||||
public Drawable GetDrawableComponent(string componentName) => CurrentSkin.Value.GetDrawableComponent(componentName);
|
||||
|
||||
public Texture GetTexture(string componentName)=> CurrentSkin.Value.GetTexture(componentName);
|
||||
|
||||
public SampleChannel GetSample(string sampleName) => CurrentSkin.Value.GetSample(sampleName);
|
||||
|
||||
public Color4? GetComboColour(IHasComboIndex comboObject) => CurrentSkin.Value.GetComboColour(comboObject);
|
||||
|
Loading…
Reference in New Issue
Block a user