22 lines
1 KiB
C#
22 lines
1 KiB
C#
|
|
using Godot;
|
||
|
|
|
||
|
|
namespace PokePurple.Library.Singletons;
|
||
|
|
|
||
|
|
public class GifManager
|
||
|
|
{
|
||
|
|
private static GifManager? _instance;
|
||
|
|
public static GifManager Instance => _instance ?? (_instance = new GifManager());
|
||
|
|
|
||
|
|
private Node _gifManager;
|
||
|
|
|
||
|
|
public GifManager()
|
||
|
|
{
|
||
|
|
_gifManager = ((SceneTree)Engine.GetMainLoop()).GetRoot().GetNode("GifManager");
|
||
|
|
}
|
||
|
|
|
||
|
|
public AnimatedTexture AnimatedTextureFromBuffer(byte[] data, int max_frames = 0) => _gifManager.Call("animated_texture_from_buffer", data, max_frames).As<AnimatedTexture>();
|
||
|
|
public AnimatedTexture AnimatedTextureFromFile(string file, int max_frames = 0) => _gifManager.Call("animated_texture_from_file", file, max_frames).As<AnimatedTexture>();
|
||
|
|
|
||
|
|
public SpriteFrames SpriteFramesFromBuffer(byte[] data, int max_frames = 0) => _gifManager.Call("sprite_frames_from_buffer", data, max_frames).As<SpriteFrames>();
|
||
|
|
public SpriteFrames SpriteFramesFromFile(string file, int max_frames = 0) => _gifManager.Call("sprite_frames_from_file", file, max_frames).As<SpriteFrames>();
|
||
|
|
}
|