Files
mod_ui_base/src/Tool/ButtonModIconLoader.cs
T
cthangover c4c90116ed Line endings: LF everywhere
.gitattributes forces LF (CRLF only for .bat/.cmd), core.autocrlf is off;
files that differed only by CRLF are normalized.
2026-10-21 13:29:59 +02:00

31 lines
869 B
C#

using Cthangover.Core.Factories.Impls;
using Godot;
using Cthangover.Core.UI.Tool;
namespace Cthangover.Mods.Interface.Tool
{
/// <summary>
/// Mod-aware TextureButton: resolves IconId through UIIconFactory at _Ready
/// and applies the result to TextureNormal. Allows tool buttons to reference
/// icons by logical ID that mods can override.
/// </summary>
public partial class ButtonModIconLoader : TextureButton
{
/// <summary>
/// Logical icon ID resolved through <see cref="UIIconFactory"/>. Set in the editor
/// or via mod to reference a mod-overridable icon texture.
/// </summary>
[Export] public string IconId { get; set; }
public override void _Ready()
{
if (string.IsNullOrEmpty(IconId))
return;
var texture = UIIconFactory.Instance.Get(IconId);
if (texture != null)
TextureNormal = texture;
}
}
}