/*
<copyright file="BGDBUiToolkitBindersWindow.cs" company="BansheeGz">
    Copyright (c) 2018-2021 All Rights Reserved
</copyright>
*/

using UnityEditor;
using UnityEngine;

namespace BansheeGz.BGDatabase.Editor
{
    public class BGDBUiToolkitBindersWindow : EditorWindow
    {
        private BGDataBinderUiToolkitGo toolkit;
        private BGDBUiToolkitBindersTable table;

        public BGDataBinderUiToolkitGo Toolkit => toolkit;

        public static void Open(BGDataBinderUiToolkitGo toolkit)
        {
            var instance = GetWindow<BGDBUiToolkitBindersWindow>();
            instance.titleContent = new GUIContent("BG: UIToolkit");
            instance.Init(toolkit);
            instance.Show();
        }

        private void Init(BGDataBinderUiToolkitGo toolkit)
        {
            this.toolkit = toolkit;
            table = new BGDBUiToolkitBindersTable(this);
        }

        private void OnGUI()
        {
            if (toolkit == null || table==null)
            {
                EditorGUILayout.HelpBox("Please, reopen this window, cause the context was lost", MessageType.Info);
                return;
            }
            BGEditorUtility.UniformStyle(() => table.Gui());
        }
    }
}