using RothenburgAR.Common;
using RothenburgAR.Exhibition;
using RothenburgAR.PointOfInterest;
using RothenburgAR.UI;
using UnityEngine;
using Vuforia;

namespace RothenburgAR
{
    public class AppInitializerBehaviour : MonoBehaviour
    {
        public Camera UICamera;

        // Use this for initialization
        void Start()
        {
            LanguageManager.Instance.LoadLanguagesFromXml();
            UIColorSchemeManager.Instance.Initialize();

            VuforiaARController.Instance.RegisterVuforiaInitializedCallback(InitializeData);

            UIManager.Instance.Initialize();
            UIManager.Instance.SetUiCamera(UICamera);
            UIManager.Instance.InitStartView();

            InputManager.Instance.Initialize();
        }

        void InitializeData()
        {
            PoiDataManager.Instance.AddPoiDataSourcePath(PathHelper.POIPath);
            PoiDataManager.Instance.AddPoiPreloader(new PoiXmlPreloader());
            PoiDataManager.Instance.LoadEverySourcePath();

            ExhibitionManager.Instance.AddExhibitionSourcePath(PathHelper.ExhibitionPath);
            ExhibitionManager.Instance.AddExhibitionPreloader(new ExhibitionXmlPreloader());
            ExhibitionManager.Instance.LoadEverySourcePath(
                (int maxPaths, int currentPaths, int subMaxExhibitions, int subCurrentExhibition) =>
                {
                    Debug.Log("<color=green>Done " + subCurrentExhibition + " of " + subMaxExhibitions +
                              " Exhibitions of Path " + currentPaths + " of " + maxPaths + " paths.</color>");
                });
        }
    }
}