using UnityEngine;
using VRC.SDKBase;
#if UNITY_EDITOR
using UnityEditor;
#endif

namespace gay.lilyy.EditorNotes {

[AddComponentMenu("LillithRosePup/Editor Note")]
public class EditorNote : MonoBehaviour, IEditorOnly
{
    public enum ValueType { Int, Float, Vector3, String, All, None }

    public ValueType valueType = ValueType.Int;

    public int intValue;
    public float floatValue;
    public Vector3 vector3Value;

    public string stringValue;

    [TextArea]
    public string note;
}

#if UNITY_EDITOR

[CustomEditor(typeof(EditorNote))]
public class EditorNoteInspector : Editor
{
    public override void OnInspectorGUI()
    {
        var script = (EditorNote)target;

        script.valueType = (EditorNote.ValueType)EditorGUILayout.EnumPopup("Type", script.valueType);

        switch (script.valueType)
        {
            case EditorNote.ValueType.Int:
                script.intValue = EditorGUILayout.IntField("Int Value", script.intValue);
                break;
            case EditorNote.ValueType.Float:
                script.floatValue = EditorGUILayout.FloatField("Float Value", script.floatValue);
                break;
            case EditorNote.ValueType.Vector3:
                script.vector3Value = EditorGUILayout.Vector3Field("Vector3 Value", script.vector3Value);
                break;
            case EditorNote.ValueType.String:
                script.stringValue = EditorGUILayout.TextField("String Value", script.stringValue);
                break;
        }
        if (script.valueType == EditorNote.ValueType.All) {
            script.intValue = EditorGUILayout.IntField("Int Value", script.intValue);
            script.floatValue = EditorGUILayout.FloatField("Float Value", script.floatValue);
            script.vector3Value = EditorGUILayout.Vector3Field("Vector3 Value", script.vector3Value);
            script.stringValue = EditorGUILayout.TextField("String Value", script.stringValue);
        }

        EditorGUILayout.LabelField("Note");
        script.note = EditorGUILayout.TextArea(script.note);

        if (GUI.changed)
            EditorUtility.SetDirty(script);
    }
}
#endif

}