supervisor-simulator/scenes/ui-elements/InfoBlock.cs
2025-12-08 23:31:22 +08:00

35 lines
911 B
C#

using Godot;
using System;
public partial class InfoBlock : PanelContainer
{
[Export]
public Texture2D IconTexture { get; set; }
[Export]
public string DisplayName { get; set; } = "资金";
[Export]
public string Value { get; set; } = "999.9 M";
private TextureRect _icon;
private Label _displayLabel;
private Label _valueLabel;
// 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;
}
}