supervisor-simulator/scenes/ui-elements/InfoBlock.cs
2026-01-18 20:05:23 +08:00

30 lines
968 B
C#

using Godot;
public partial class InfoBlock : PanelContainer {
private Label _displayLabel;
private TextureRect _icon;
private Label _valueLabel;
[Export] public Texture2D IconTexture { get; set; }
[Export] public string DisplayName { get; set; } = "资金";
[Export] public string Value { get; set; } = "999.9 M";
// Called when the node enters the scene tree for the first time.
public override void _Ready() {
_icon = GetNode<TextureRect>("VBoxContainer/HBoxContainer/Icon");
_displayLabel = GetNode<Label>("VBoxContainer/DisplayLabel");
_valueLabel = GetNode<Label>("VBoxContainer/HBoxContainer/ValueLabel");
_icon.Texture = IconTexture;
_displayLabel.Text = DisplayName;
_valueLabel.Text = Value;
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta) {
_valueLabel.Text = Value;
}
}