supervisor-simulator/scenes/ui-elements/TopBar.cs

29 lines
728 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);
}
}