Beispiel #1
0
        public void OnGUI()
        {
            GUIHelper.Init();

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
            GUILayout.BeginVertical(GUIHelper.windowStyle);

            if (Controller.Instance.Options.characterList.Length <= 0)
            {
                EditorGUILayout.HelpBox("No characters yet.", MessageType.Info);
            }

            for (int i = 0; i < Controller.Instance.Options.characterList.Length; i++)
            {
                var name      = Controller.Instance.Options.characterList[i];
                var character = Character.Find(Controller.Instance.Characters, name);

                if (character.SetId())
                {
                    CharactersController.Save(character, Controller.Instance.Options.jsonPrettyPrint);
                }

                GUILayout.BeginHorizontal();
                GUILayout.BeginHorizontal();

                if (EditorGUIUtility.isProSkin)
                {
                    GUIHelper.labelStyle.normal.textColor = Color.white;
                }

                GUIHelper.labelStyle.alignment = TextAnchor.MiddleLeft;
                GUILayout.Label(name, GUIHelper.labelStyle);

                GUIHelper.labelStyle.alignment = TextAnchor.MiddleRight;
                if (Controller.Instance.Options.playerCharacterName == name)
                {
                    GUILayout.Label("<b>[Player]</b>", GUIHelper.labelStyle);
                }

                GUILayout.EndHorizontal();

                GUILayout.Space(10.0f);

                GUILayout.BeginHorizontal(GUILayout.MaxWidth(position.width / 2));

                if (GUILayout.Button("Edit", GUILayout.Height(GUIHelper.BUTTON_HEIGHT_SMALL)))
                {
                    CharacterEditor.Edit(character);
                    Close();
                }

                if (GUILayout.Button("Edit Messages", GUILayout.Height(GUIHelper.BUTTON_HEIGHT_SMALL)))
                {
                    TalkableMessagesEditor.OpenContextMenu(character);
                    Close();
                }

                if (GUILayout.Button("Delete", GUILayout.Height(GUIHelper.BUTTON_HEIGHT_SMALL)))
                {
                    if (EditorUtility.DisplayDialog("Are you sure?", "Do you really want to delete?\nThis data will be lost forever.", "Yes", "No"))
                    {
                        var isPlayer = false;

                        if (name == Controller.Instance.Options.playerCharacterName)
                        {
                            isPlayer = true;
                        }

                        Controller.Instance.Characters.Remove(character);
                        Controller.Instance.Options.characterList = ArrayHelper.Remove(Controller.Instance.Options.characterList, name);

                        JSONHelper.Delete(name, "Diplomata/Characters/");

                        if (isPlayer && Controller.Instance.Options.characterList.Length > 0)
                        {
                            Controller.Instance.Options.playerCharacterName = Controller.Instance.Options.characterList[0];
                        }

                        OptionsController.Save(Controller.Instance.Options, Controller.Instance.Options.jsonPrettyPrint);
                        Controller.Instance.Characters = CharactersController.GetCharacters(Controller.Instance.Options);

                        CharacterEditor.Reset(name);
                        TalkableMessagesEditor.Reset(name);
                        ContextEditor.Reset(name);
                    }
                }

                GUILayout.EndHorizontal();
                GUILayout.EndHorizontal();

                if (i < Controller.Instance.Options.characterList.Length - 1)
                {
                    GUIHelper.Separator();
                }
            }

            EditorGUILayout.Separator();

            if (GUILayout.Button("Create", GUILayout.Height(GUIHelper.BUTTON_HEIGHT)))
            {
                CharacterEditor.OpenCreate();
                Close();
            }

            GUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
        }
Beispiel #2
0
        public override void OnInspectorGUI()
        {
            GUIHelper.Init();
            serializedObject.Update();
            GUILayout.BeginVertical(GUIHelper.windowStyle);

            if (interactables.Count > 0)
            {
                if (TalkableId.stringValue != null)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Id: ");
                    EditorGUILayout.SelectableLabel(string.Format("{0}", TalkableId.stringValue));
                    GUILayout.EndHorizontal();
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label("Interactable: ");

                if (!Application.isPlaying)
                {
                    var selected = 0;

                    for (var i = 0; i < interactables.Count; i++)
                    {
                        if (interactables[i].Id == TalkableId.stringValue)
                        {
                            selected = i;
                            break;
                        }
                    }

                    var selectedBefore = selected;
                    selected = EditorGUILayout.Popup(selected, options.interactableList);

                    for (var i = 0; i < interactables.Count; i++)
                    {
                        if (selected == i)
                        {
                            TalkableId.stringValue = interactables[i].Id;
                            interactables[selectedBefore].onScene = false;
                            if (GetTalkable() != null)
                            {
                                GetTalkable().onScene = true;
                            }
                            break;
                        }
                    }
                }

                else
                {
                    if (GetTalkable() != null)
                    {
                        GUILayout.Label(GetTalkable().name);
                    }
                }

                GUILayout.EndHorizontal();

                if (GUILayout.Button("Refresh", GUILayout.Height(GUIHelper.BUTTON_HEIGHT_SMALL)))
                {
                    Refresh();
                }

                GUIHelper.Separator();

                if (GUILayout.Button("Edit Interactable", GUILayout.Height(GUIHelper.BUTTON_HEIGHT)))
                {
                    InteractableEditor.Edit(Interactable.Find(Controller.Instance.Interactables,
                                                              TalkableId.stringValue));
                }

                if (GUILayout.Button("Edit Messages", GUILayout.Height(GUIHelper.BUTTON_HEIGHT)))
                {
                    TalkableMessagesEditor.OpenContextMenu(Interactable.Find(Controller.Instance.Interactables,
                                                                             TalkableId.stringValue));
                }

                GUIHelper.Separator();
                GUILayout.BeginHorizontal();

                if (GUILayout.Button("Create Interactable", GUILayout.Height(GUIHelper.BUTTON_HEIGHT_BIG)))
                {
                    InteractableEditor.OpenCreate();
                }

                EditorGUILayout.HelpBox("Create does not interfe in this interactable.", MessageType.Info);
                GUILayout.EndHorizontal();
            }

            else
            {
                if (GUILayout.Button("Create Interactable", GUILayout.Height(GUIHelper.BUTTON_HEIGHT)))
                {
                    InteractableEditor.OpenCreate();
                }
            }

            GUILayout.EndVertical();
            serializedObject.ApplyModifiedProperties();
        }
Beispiel #3
0
        /// <summary>
        /// The inspector graphic loop
        /// </summary>
        public override void OnInspectorGUI()
        {
            GUIHelper.Init();
            serializedObject.Update();
            GUILayout.BeginVertical(GUIHelper.windowStyle);

            if (characters.Count > 0)
            {
                if (TalkableId.stringValue != null)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Id: ");
                    EditorGUILayout.SelectableLabel(string.Format("{0}", TalkableId.stringValue));
                    GUILayout.EndHorizontal();
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label("Character: ");

                if (!Application.isPlaying)
                {
                    var selected = 0;

                    for (var i = 0; i < characters.Count; i++)
                    {
                        if (characters[i].Id == TalkableId.stringValue)
                        {
                            selected = i;
                            break;
                        }
                    }

                    var selectedBefore = selected;
                    selected = EditorGUILayout.Popup(selected, options.characterList);

                    for (var i = 0; i < characters.Count; i++)
                    {
                        if (selected == i)
                        {
                            TalkableId.stringValue             = characters[i].Id;
                            characters[selectedBefore].onScene = false;
                            if (GetTalkable() != null)
                            {
                                GetTalkable().onScene = true;
                            }
                            break;
                        }
                    }
                }

                else
                {
                    if (GetTalkable() != null)
                    {
                        GUILayout.Label(GetTalkable().name);
                    }
                }

                GUILayout.EndHorizontal();

                if (GUILayout.Button("Refresh", GUILayout.Height(GUIHelper.BUTTON_HEIGHT_SMALL)))
                {
                    Refresh();
                }

                GUIHelper.Separator();

                var showInfluence = true;

                if (GetTalkable() != null)
                {
                    if (GetTalkable().name == options.playerCharacterName)
                    {
                        EditorGUILayout.HelpBox(
                            "\nThis character is the player, he doesn't influence himself, use his messages only in the case he speaks with himself.\n",
                            MessageType.Info);
                        showInfluence = false;
                    }
                }

                if (GUILayout.Button("Edit Character", GUILayout.Height(GUIHelper.BUTTON_HEIGHT)))
                {
                    CharacterEditor.Edit(Character.Find(Controller.Instance.Characters, TalkableId.stringValue));
                }

                if (GUILayout.Button("Edit Messages", GUILayout.Height(GUIHelper.BUTTON_HEIGHT)))
                {
                    TalkableMessagesEditor.OpenContextMenu(Character.Find(Controller.Instance.Characters,
                                                                          TalkableId.stringValue));
                }

                if (showInfluence)
                {
                    GUIHelper.labelStyle.alignment = TextAnchor.UpperCenter;
                    EditorGUILayout.Separator();

                    if (EditorGUIUtility.isProSkin)
                    {
                        GUIHelper.labelStyle.normal.textColor = GUIHelper.proTextColor;
                    }

                    else
                    {
                        GUIHelper.labelStyle.normal.textColor = GUIHelper.freeTextColor;
                    }

                    if (GetTalkable() != null)
                    {
                        if (GetTalkable().GetType() == typeof(Character))
                        {
                            GUILayout.Label("Influence: <b>" + GetTalkable().influence + "</b>", GUIHelper.labelStyle);
                        }
                    }
                }

                GUIHelper.Separator();
                GUILayout.BeginHorizontal();

                if (GUILayout.Button("Create Character", GUILayout.Height(GUIHelper.BUTTON_HEIGHT_BIG)))
                {
                    CharacterEditor.OpenCreate();
                }

                EditorGUILayout.HelpBox("Create does not interfere in this character.", MessageType.Info);
                GUILayout.EndHorizontal();
            }

            else
            {
                if (GUILayout.Button("Create Character", GUILayout.Height(GUIHelper.BUTTON_HEIGHT)))
                {
                    CharacterEditor.OpenCreate();
                }
            }

            GUILayout.EndVertical();
            serializedObject.ApplyModifiedProperties();
        }