using Godot;

namespace ReactorMaintenance.Godot.Controls;

public partial class ForecastList : PanelContainer
{
    public override void _Ready()
    {
        AddChild(m_Items);
        SetForecasts(["Turn +1: Pressure stable", "Turn +2: No forecast warnings"]);
    }

    public void SetForecasts(IReadOnlyList<string> forecasts)
    {
        foreach (var child in m_Items.GetChildren())
            child.QueueFree();

        m_Items.AddChild(new Label { Text = "Forecasts" });
        foreach (var forecast in forecasts)
            m_Items.AddChild(new Label { Text = forecast, AutowrapMode = TextServer.AutowrapMode.WordSmart });
    }

    private readonly VBoxContainer m_Items = new();
}