draft: texture button

This commit is contained in:
h z
2025-02-15 08:25:01 +00:00
parent 0d75ed106d
commit 5a981c91ee
11 changed files with 193 additions and 18 deletions

View File

@@ -0,0 +1,33 @@
using Godot;
using FileAccess = Godot.FileAccess;
namespace Polonium.DataStructures;
public class TextureSet
{
public TextureSet(string path)
{
Normal = LoadTexture($"{path}/Normal");
Pressed = LoadTexture($"{path}/Pressed");
Disabled = LoadTexture($"{path}/Disabled");
Hover = LoadTexture($"{path}/Hover");
Focused = LoadTexture($"{path}/Focused");
}
public Texture2D Normal { get; init; }
public Texture2D Pressed { get; init; }
public Texture2D Hover { get; init; }
public Texture2D Disabled { get; init; }
public Texture2D Focused { get; init; }
private static Texture2D LoadTexture(string path)
{
Texture2D res = new();
if(FileAccess.FileExists($"{path}.png"))
res = ResourceLoader.Load<Texture2D>($"{path}.png");
else if(DirAccess.DirExistsAbsolute($"{path}.at_dir"))
res = Utils.LoadAnimatedTextureFromDirectory($"{path}.at_dir");
return res;
}
}