Ejemplo n.º 1
0
    void OnGUI()
    {
        //VIEW
        for (int i = 0; i < definitions.list.Count; i++)
        {
            FactDefinition fd = definitions.list[i];

            GUILayout.BeginHorizontal(GUILayout.Width(200));

            //Name

            GUILayout.Label("Name", GUILayout.Width(40));

            List <string> names = new List <string> ();

            try {
                names = AtomsContainer.Load(AtomListWindow.path).list;
            }

            catch (Exception e) {
                Debug.Log(e.Message);
            }



            selectedName = names.IndexOf(fd.name);

            selectedName = EditorGUILayout.Popup(selectedName, names.ToArray(), GUILayout.Width(50));

            if (selectedName == -1)
            {
                selectedName = 0;
            }

            fd.name = names [selectedName];



            //Type
            GUILayout.Label("Type");

            if (fd.factType == "Property")
            {
                selectedFactType = 0;
            }

            else if (fd.factType == "Relation")
            {
                selectedFactType = 1;
            }

            selectedFactType = EditorGUILayout.Popup(selectedFactType, factTypes, GUILayout.Width(100));
            fd.factType      = factTypes[selectedFactType];

            GUILayout.Space(20);


            //Arguments of expression
            GUILayout.Label("Arguments");

            int j;

            for (j = 0; j < argsTypes.list.Count; j++)
            {
                if (fd.argsType == argsTypes.list[j])
                {
                    selectedArgType = j;
                    break;
                }
            }



            selectedArgType = EditorGUILayout.Popup(selectedArgType, argsTypes.list.ToArray(), GUILayout.Width(100));
            fd.argsType     = argsTypes.list[selectedArgType];

            //MODEL/CONTROLLER
            if (GUILayout.Button("Edit", GUILayout.Width(50)))
            {
                AddArgumentWindow.ShowWindow();
            }


            GUILayout.Space(20);


            //Expression
            GUILayout.Label("Expression");
            fd.expression = EditorGUILayout.TextField(fd.expression, GUILayout.Width(300));


            definitions.list[i] = fd;



            GUILayout.Space(20);

            if (GUILayout.Button("Delete", GUILayout.Width(100)))
            {
                definitions.Remove(definitions.list[i]);
            }

            GUILayout.EndHorizontal();
        }


        //MODEL/CONTROLLER
        if (GUILayout.Button("Add Definition", GUILayout.Width(200)))
        {
            if (AtomListWindow.atomNames.list.Count > 0)
            {
                definitions.Add(new FactDefinition("New Fact"));
            }
            else
            {
                EditorUtility.DisplayDialog("", "No names in atom names list. Please, fill the list before adding a definition", "OK");
            }
        }
    }