2019-02-24 16:14:19 +01:00
|
|
|
using JetBrains.Annotations;
|
2019-04-15 21:11:38 -06:00
|
|
|
using Robust.Client.Graphics;
|
|
|
|
|
using Robust.Client.ResourceManagement;
|
2023-09-11 19:18:06 +10:00
|
|
|
using Robust.Shared.Graphics;
|
2019-04-15 21:11:38 -06:00
|
|
|
using Robust.Shared.Utility;
|
2019-02-24 16:14:19 +01:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.Resources
|
2019-02-24 16:14:19 +01:00
|
|
|
{
|
|
|
|
|
[PublicAPI]
|
|
|
|
|
public static class ResourceCacheExtensions
|
|
|
|
|
{
|
2023-10-29 15:29:30 +11:00
|
|
|
public static Texture GetTexture(this IResourceCache cache, ResPath path)
|
2019-02-24 16:14:19 +01:00
|
|
|
{
|
|
|
|
|
return cache.GetResource<TextureResource>(path);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-29 15:29:30 +11:00
|
|
|
public static Texture GetTexture(this IResourceCache cache, string path)
|
2019-02-24 16:14:19 +01:00
|
|
|
{
|
2023-04-20 20:16:01 +10:00
|
|
|
return GetTexture(cache, new ResPath(path));
|
2019-02-24 16:14:19 +01:00
|
|
|
}
|
|
|
|
|
|
2023-10-29 15:29:30 +11:00
|
|
|
public static Font GetFont(this IResourceCache cache, ResPath path, int size)
|
2019-02-24 16:14:19 +01:00
|
|
|
{
|
|
|
|
|
return new VectorFont(cache.GetResource<FontResource>(path), size);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-29 15:29:30 +11:00
|
|
|
public static Font GetFont(this IResourceCache cache, string path, int size)
|
2019-02-24 16:14:19 +01:00
|
|
|
{
|
2023-04-20 20:16:01 +10:00
|
|
|
return cache.GetFont(new ResPath(path), size);
|
2019-02-24 16:14:19 +01:00
|
|
|
}
|
2021-11-04 03:32:03 +00:00
|
|
|
|
2023-10-29 15:29:30 +11:00
|
|
|
public static Font GetFont(this IResourceCache cache, ResPath[] path, int size)
|
2021-11-04 03:32:03 +00:00
|
|
|
{
|
|
|
|
|
var fs = new Font[path.Length];
|
|
|
|
|
for (var i = 0; i < path.Length; i++)
|
|
|
|
|
fs[i] = new VectorFont(cache.GetResource<FontResource>(path[i]), size);
|
|
|
|
|
|
|
|
|
|
return new StackedFont(fs);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-29 15:29:30 +11:00
|
|
|
public static Font GetFont(this IResourceCache cache, string[] path, int size)
|
2021-11-04 03:32:03 +00:00
|
|
|
{
|
2023-04-20 20:16:01 +10:00
|
|
|
var rp = new ResPath[path.Length];
|
2021-11-04 03:32:03 +00:00
|
|
|
for (var i = 0; i < path.Length; i++)
|
2023-04-20 20:16:01 +10:00
|
|
|
rp[i] = new ResPath(path[i]);
|
2021-11-04 03:32:03 +00:00
|
|
|
|
|
|
|
|
return cache.GetFont(rp, size);
|
|
|
|
|
}
|
2019-02-24 16:14:19 +01:00
|
|
|
}
|
|
|
|
|
}
|