51 lines
902 B
C#
51 lines
902 B
C#
|
using Godot;
|
||
|
|
||
|
namespace BITKit;
|
||
|
|
||
|
public interface IUXContainer
|
||
|
{
|
||
|
string Text { get; set; }
|
||
|
void SetText(string text);
|
||
|
Texture2D Icon { get; set; }
|
||
|
void SetIcon(Texture2D texture);
|
||
|
}
|
||
|
public partial class UXContainer:Control,IUXContainer
|
||
|
{
|
||
|
[Export] public Label label;
|
||
|
[Export] public RichTextLabel richTextLabel;
|
||
|
[Export] public Label titleLabel;
|
||
|
[Export] public TextureRect icon;
|
||
|
[Export] public Button button;
|
||
|
|
||
|
public string Text
|
||
|
{
|
||
|
get =>label is not null ? label.Text : richTextLabel.Text;
|
||
|
set
|
||
|
{
|
||
|
switch (label, richTextLabel)
|
||
|
{
|
||
|
case (not null, null):
|
||
|
label.Text = value;
|
||
|
break;
|
||
|
case (null, not null):
|
||
|
richTextLabel.Text = value;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
public void SetText(string text)
|
||
|
{
|
||
|
Text=text;
|
||
|
}
|
||
|
|
||
|
public Texture2D Icon
|
||
|
{
|
||
|
get => icon.Texture;
|
||
|
set => icon.Texture=value;
|
||
|
}
|
||
|
|
||
|
public void SetIcon(Texture2D texture)
|
||
|
{
|
||
|
Icon = texture;
|
||
|
}
|
||
|
}
|