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

24 lines
802 B
C#

using Godot;
public partial class TopBar : PanelContainer {
private ProgressBar _progressBar;
// Called when the node enters the scene tree for the first time.
public override void _Ready() {
_progressBar = GetNode<ProgressBar>("HBox/YearProgress/ProgressBar");
}
public void ResetRound(float durationSeconds) {
if (_progressBar == null) return;
_progressBar.MinValue = 0;
_progressBar.MaxValue = durationSeconds;
_progressBar.Value = 0;
}
public void UpdateRoundProgress(float elapsedSeconds, float durationSeconds) {
if (_progressBar == null) return;
_progressBar.MinValue = 0;
_progressBar.MaxValue = durationSeconds;
_progressBar.Value = Mathf.Clamp(elapsedSeconds, 0, durationSeconds);
}
}