using Godot;
using System;
using System.Dynamic;

public partial class ResourceRowDisplay : HBoxContainer
{
        private Label name;
        private Label resQuantity;
        private Label simResQuantity;
        private Label maxQuantity;

        private Tween tween;

        public override void _Ready()
        {
                // Labels
                name = GetNode<Label>("NamePanel/Margin/Name");
                resQuantity = GetNode<Label>("QuantityPanel/Margin/Quantity");
                simResQuantity = GetNode<Label>("SimPanel/Margin/SimQuantity");
                maxQuantity = GetNode<Label>("MaxPanel/Margin/MaxQuantity");

                tween = CreateTween();
                set_data("Default Name", -1, -1, -1);
        }

        public void update_value(int v)
        {
                resQuantity.Text = v.ToString();
        }
        public void update_simulated(int v)
        {
                simResQuantity.Text = "(" + v.ToString() + ")";
        }

        public void update_values(int v, int p, int m)
        {
                TweenPresets.ResetTween(this, ref tween);
                TweenPresets.BlinkProperty(ref tween, name, new Color(1.0f, 0.0f, 0.0f), 2.0, 4);
                resQuantity.Text = "V(" + v.ToString() + ")";
                simResQuantity.Text = "P(" + p.ToString() + ")";
                maxQuantity.Text = "M(" + m.ToString() + ")";
        }

        public void set_color(Color c)
        {
                GD.Print("Called Set Color");
                name.AddThemeColorOverride("font_color", c);
        }

        public void set_data(string n, int q, int s, int m)
        {
                name.Text = n;
                update_values(q, s, m);
        }
}
