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

[CustomEditor(typeof(DialogueObject))]
public class DialogueInspector : Editor
{
    DialogueObject obj;
    public void OnEnable()
    {
        obj = (DialogueObject)target;
    }
    public override void OnInspectorGUI()
    {
        EditorGUILayout.BeginHorizontal();
        obj.dialogueName = EditorGUILayout.TextField(obj.dialogueName);
        obj.once = EditorGUILayout.Toggle(obj.once);
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(8);
        for(int i=0; i < obj.dialogues.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(i.ToString());
            if (GUILayout.Button("Remove"))
            {
                obj.dialogues.RemoveAt(i);
                i--;
                continue;
            }
            EditorGUILayout.EndHorizontal();
            obj.dialogues[i] = EditorGUILayout.TextArea(obj.dialogues[i]);
        }
        if (GUILayout.Button("Add dialogue section"))
        {
            obj.dialogues.Add("");
        }
        EditorUtility.SetDirty(target);
    }
}
  /*  dm_MapTiles comp;
    static bool showTileEditor = false;

    public void OnEnable()
    {
        comp = (dm_MapTiles)target;
        if (comp.mapSprites == null)
        {
            comp.mapSprites = new Sprite[1, 1];
        }
    }

    public override void OnInspectorGUI()
    {

        //MAP DEFAULT INFORMATION
        comp.mapName = EditorGUILayout.TextField("Name", comp.mapName);

        //WIDTH - HEIGHT
        int width = EditorGUILayout.IntField("Map Sprite Width", comp.mapSprites.GetLength(0));
        int height = EditorGUILayout.IntField("Map Sprite Height", comp.mapSprites.GetLength(1));

        if (width != comp.mapSprites.GetLength(0) || height != comp.mapSprites.GetLength(1))
        {
            comp.mapSprites = new Sprite[width, height];
        }

        showTileEditor = EditorGUILayout.Foldout(showTileEditor, "Tile Editor");

        if (showTileEditor)
        {
            for (int h = 0; h < height; h++)
            {
                EditorGUILayout.BeginHorizontal();
                for (int w = 0; w < width; w++)
                {
                    comp.mapSprites[w, h] = (Sprite)EditorGUILayout.ObjectField(comp.mapSprites[w, h], typeof(Sprite), false, GUILayout.Width(65f), GUILayout.Height(65f));
                }
                EditorGUILayout.EndHorizontal();
            }
        }
    }

}*/