using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace EvolutStudio
{
    namespace tinysAPI
    {
        namespace BaseClasses
        {
            abstract public class BaseClassView : BaseClass
            {
                // private array list of components
                protected ArrayList _components = new ArrayList();

                #region Interface Functions

                // public function to add a new sub view, returns array id
                public int RegisterComponent(BaseClassComponent component)
                {
                    // init sub view via presenter
                    modulInstance.Presenter.InitComponent(component);

                    // add sub view to array and return index
                    return _components.Add(component);
                }

                // public function to call ValidationSucceeded from all registered subviews
                public void FireValidationSucceededEvent(string notification)
                {
                    foreach (BaseClassComponent component in _components)
                    {
                        // update all values
                        modulInstance.Presenter.UpdateComponent(component);

                        // call delegate
                        component.ValidationSucceeded(notification);
                    }
                }

                // public function to call ValidationFailed from all registered subviews
                public void FireValidationFailedEvent(string notification)
                {
                    foreach (BaseClassComponent component in _components)
                    {
                        // update all values
                        modulInstance.Presenter.UpdateComponent(component);

                        // call delegate
                        component.ValidationSucceeded(notification);
                    }
                }

                #endregion
            }
        }
    }
}
