documents
This commit is contained in:
@@ -3,8 +3,16 @@ using FileAccess = Godot.FileAccess;
|
||||
|
||||
namespace Polonium.DataStructures;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a complete set of textures for UI button states.
|
||||
/// Automatically loads textures for Normal, Pressed, Disabled, Hover, and Focused states from a directory.
|
||||
/// </summary>
|
||||
public class TextureSet
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TextureSet"/> class by loading textures from the specified path.
|
||||
/// </summary>
|
||||
/// <param name="path">The base path where texture files are located.</param>
|
||||
public TextureSet(string path)
|
||||
{
|
||||
Normal = LoadTexture($"{path}/Normal");
|
||||
@@ -13,12 +21,37 @@ public class TextureSet
|
||||
Hover = LoadTexture($"{path}/Hover");
|
||||
Focused = LoadTexture($"{path}/Focused");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the texture for the normal button state.
|
||||
/// </summary>
|
||||
public Texture2D Normal { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the texture for the pressed button state.
|
||||
/// </summary>
|
||||
public Texture2D Pressed { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the texture for the hover button state.
|
||||
/// </summary>
|
||||
public Texture2D Hover { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the texture for the disabled button state.
|
||||
/// </summary>
|
||||
public Texture2D Disabled { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the texture for the focused button state.
|
||||
/// </summary>
|
||||
public Texture2D Focused { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Loads a texture from the specified path, supporting both static PNG files and animated texture directories.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to the texture file or directory.</param>
|
||||
/// <returns>The loaded texture, or an empty texture if not found.</returns>
|
||||
private static Texture2D LoadTexture(string path)
|
||||
{
|
||||
Texture2D res = new();
|
||||
@@ -28,6 +61,4 @@ public class TextureSet
|
||||
res = Utils.LoadAnimatedTextureFromDirectory($"{path}.at_dir");
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user