Ejemplo n.º 1
0
        public Task VisitButtonDialog(ButtonDialog buttonDialog)
        {
            log.Debug($"{buttonDialog.Caption}, cols:{buttonDialog.Columns.SJoin()}");
            buttonDialog.Buttons.ForEach(async b => await VisitButton(b));

            return(Task.CompletedTask);
        }
Ejemplo n.º 2
0
    private void SideMenu(ButtonDialog option)
    {
        GenericMenu menu = new GenericMenu();

        sideItem = _target.options.IndexOf(option);

        menu.AddItem(new GUIContent("Insert after"), false, Callback, "Insert after");
        if (_target.options.Count > 0)
        {
            menu.AddItem(new GUIContent("Delete"), false, Callback, "Delete");
        }
        if (sideItem > 0 || sideItem < _target.options.Count - 1)
        {
            menu.AddSeparator("");
        }
        if (sideItem > 0)
        {
            menu.AddItem(new GUIContent("Move up"), false, Callback, "Move up");
        }
        if (sideItem < _target.options.Count - 1)
        {
            menu.AddItem(new GUIContent("Move down"), false, Callback, "Move down");
        }

        menu.ShowAsContext();
    }
Ejemplo n.º 3
0
 protected override void InitBindings()
 {
     ButtonChoose.SetOnClickCommand(ViewModel.AskUserAboutFancyThingsCommand);
     ButtonShow.SetOnClickCommand(ViewModel.ShowLastFanciedThingCommand);
     ButtonNavigate.SetOnClickCommand(ViewModel.NavigateSomewhereElseCommand);
     ButtonReset.SetOnClickCommand(ViewModel.ResetFanciness);
     ButtonDialog.SetOnClickCommand(ViewModel.ShowDialogCommand);
     ButtonDialogB.SetOnClickCommand(ViewModel.ShowDialogBCommand);
     ButtonInput.SetOnClickCommand(ViewModel.InputFanciness);
     FancyLoading.SetOnClickCommand(ViewModel.ShowLoadingDialogCommand);
 }
Ejemplo n.º 4
0
        protected override async Task DeleteEntity()
        {
            var entityId    = GetEntityId();
            var tagToDelete = Service.Tags.First(d => d.Id == entityId);
            var dialog      = new ButtonDialog(ButtonEnum.OkCancel, Properties.Resources.RemoveTag, string.Format(Properties.Resources.ConfirmRemoveTag, tagToDelete.Name));

            if (await dialog.Open() == ButtonResult.Ok)
            {
                Service.DeleteTag(entityId);
                TagsUpdated();
            }
        }
Ejemplo n.º 5
0
 public async Task VisitButtonDialog(ButtonDialog buttonDialog)
 {
     await SendDialog(buttonDialog.Caption,
                      new InlineKeyboardMarkup(
                          buttonDialog.Buttons
                          .ByIndex()
                          .GroupBy(i => buttonDialog.Columns.ToGroupValue(i))
                          .Select(gi => gi.Select(i => buttonDialog.Buttons[i]).Select(button =>
                                                                                       InlineKeyboardButton.WithCallbackData(button.Name, $"{button.Go}")).ToArray())
                          .ToArray()
                          ));
 }
Ejemplo n.º 6
0
    private void CreateOptionsGUI()
    {
        EditorGUILayout.LabelField("Dialogue options", EditorStyles.boldLabel);

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(Mathf.Min(_target.options.Count * 21, 130f) + 5));
        foreach (ButtonDialog option in _target.options)
        {
            EditorGUILayout.BeginHorizontal();

            string buttonLabel = option.ID + ": " + option.label;
            if (option.label == "")
            {
                buttonLabel += "(Untitled)";
            }
            if (_target.isTimed && _target.options.IndexOf(option) == _target.defaultOption)
            {
                buttonLabel += " (Default)";
            }

            if (GUILayout.Toggle(option.isEditing, buttonLabel, "Button"))
            {
                if (_target.selectedOption != option)
                {
                    DeactivateAllOptions();
                    ActivateOption(option);
                }
            }

            if (GUILayout.Button(sideIcon, GUILayout.Width(20f), GUILayout.Height(15f)))
            {
                SideMenu(option);
            }

            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndScrollView();

        if (GUILayout.Button("Add new dialogue option"))
        {
            Undo.RecordObject(_target, "Create dialogue option");
            ButtonDialog newOption = new ButtonDialog(_target.GetIDArray());
            _target.options.Add(newOption);
            DeactivateAllOptions();
            ActivateOption(newOption);
        }
    }
Ejemplo n.º 7
0
    private void Callback(object obj)
    {
        if (sideItem >= 0)
        {
            ButtonDialog tempItem = _target.options[sideItem];

            switch (obj.ToString())
            {
            case "Insert after":
                Undo.RecordObject(_target, "Insert option");
                _target.options.Insert(sideItem + 1, new ButtonDialog(_target.GetIDArray()));
                break;

            case "Delete":
                Undo.RecordObject(_target, "Delete option");
                DeactivateAllOptions();
                _target.options.RemoveAt(sideItem);
                break;

            case "Move up":
                Undo.RecordObject(_target, "Move option up");
                _target.options.RemoveAt(sideItem);
                _target.options.Insert(sideItem - 1, tempItem);
                break;

            case "Move down":
                Undo.RecordObject(_target, "Move option down");
                _target.options.RemoveAt(sideItem);
                _target.options.Insert(sideItem + 1, tempItem);
                break;
            }
        }

        EditorUtility.SetDirty(_target);

        sideItem = -1;
    }
Ejemplo n.º 8
0
    private void OptionsGUI()
    {
        if (conversation == null)
        {
            return;
        }

        scrollPosition = GUI.BeginScrollView(new Rect(0, 0, position.width, position.height), scrollPosition, new Rect(0, 0, 1100, 77 * (conversation.options.Count + 2)), false, false);
        BeginWindows();

        convRect = new Rect(20, 100, 150, 50);
        convRect = GUI.Window(-1, convRect, NodeWindow, "Conversation");

        if (GUI.Button(convRect, ""))
        {
            Selection.activeGameObject = conversation.gameObject;
            foreach (ButtonDialog option in conversation.options)
            {
                option.isEditing = false;
            }
            conversation.selectedOption = null;
        }

        if (lastConversation != null)
        {
            lastRect = new Rect(20, 20, 150, 50);
            lastRect = GUI.Window(-2, lastRect, NodeWindow, "Previous conversation");

            if (GUI.Button(lastRect, ""))
            {
                Selection.activeGameObject = lastConversation.gameObject;
            }
        }

        for (int i = 0; i < conversation.options.Count; i++)
        {
            optionRect = new Rect(220, 20 + (i * 80), 200, 50);
            optionRect = GUI.Window(i, optionRect, NodeWindow, "Dialogue option");

            if (conversation.options[i].label == "")
            {
                DrawNodeCurve(convRect, optionRect, Color.red);
            }
            else
            {
                DrawNodeCurve(convRect, optionRect, Color.blue);
            }

            if (GUI.Button(optionRect, ""))
            {
                Selection.activeGameObject = conversation.gameObject;
                foreach (ButtonDialog option in conversation.options)
                {
                    option.isEditing = false;
                }
                conversation.options[i].isEditing = true;
                conversation.selectedOption       = conversation.options[i];
            }

            interactionRect = new Rect(440, 20 + (i * 80), 200, 50);
            interactionRect = GUI.Window(i + conversation.options.Count, interactionRect, NodeWindow, "Interaction");

            if (conversation.options[i].dialogueOption == null)
            {
                DrawNodeCurve(optionRect, interactionRect, Color.red);
            }
            else
            {
                DrawNodeCurve(optionRect, interactionRect, Color.blue);
            }

            if (conversation.options[i].dialogueOption != null)
            {
                finishRect = new Rect(660, 20 + (i * 80), 200, 50);
                finishRect = GUI.Window(i + (conversation.options.Count * 2), finishRect, NodeWindow, "When finished");
                DrawNodeCurve(interactionRect, finishRect, Color.blue);

                if (GUI.Button(finishRect, ""))
                {
                    Selection.activeGameObject = conversation.gameObject;
                    foreach (ButtonDialog option in conversation.options)
                    {
                        option.isEditing = false;
                    }
                    conversation.options[i].isEditing = true;
                    conversation.selectedOption       = conversation.options[i];
                }

                if (conversation.options[i].conversationAction == AC.ConversationAction.RunOtherConversation)
                {
                    newRect = new Rect(880, 20 + (i * 80), 200, 50);
                    newRect = GUI.Window(i + (conversation.options.Count * 3), newRect, NodeWindow, "Conversation");

                    if (conversation.options[i].newConversation == null)
                    {
                        DrawNodeCurve(finishRect, newRect, Color.red);
                    }
                    else
                    {
                        DrawNodeCurve(finishRect, newRect, Color.blue);
                    }

                    if (conversation.options[i].newConversation != null)
                    {
                        if (GUI.Button(newRect, ""))
                        {
                            lastConversation           = conversation;
                            Selection.activeGameObject = conversation.options[i].newConversation.gameObject;
                        }
                    }
                }
            }
        }

        EndWindows();

        if (GUI.Button(new Rect(260, 10 + (conversation.options.Count * 80), 120, 20), "Add new option"))
        {
            Undo.RecordObject(conversation, "Create dialogue option");
            ButtonDialog newOption = new ButtonDialog(conversation.GetIDArray());
            conversation.options.Add(newOption);

            Selection.activeGameObject = conversation.gameObject;
            foreach (ButtonDialog option in conversation.options)
            {
                option.isEditing = false;
            }
            newOption.isEditing         = true;
            conversation.selectedOption = newOption;
        }

        GUI.EndScrollView();
    }
Ejemplo n.º 9
0
    private void EditOptionGUI(ButtonDialog option, InteractionSource source)
    {
        EditorGUILayout.BeginVertical("Button");

        if (option.lineID > -1)
        {
            EditorGUILayout.LabelField("Speech Manager ID:", option.lineID.ToString());
        }

        option.label = EditorGUILayout.TextField("Label:", option.label);

        if (source == InteractionSource.AssetFile)
        {
            option.assetFile = (ActionListAsset)EditorGUILayout.ObjectField("Interaction:", option.assetFile, typeof(ActionListAsset), false);
        }
        else if (source == InteractionSource.CustomScript)
        {
            option.customScriptObject   = (GameObject)EditorGUILayout.ObjectField("Object with script:", option.customScriptObject, typeof(GameObject), true);
            option.customScriptFunction = EditorGUILayout.TextField("Message to send:", option.customScriptFunction);
        }
        else if (source == InteractionSource.CustomScript)
        {
            EditorGUILayout.BeginHorizontal();
            option.dialogueOption = (DialogueOption)EditorGUILayout.ObjectField("Interaction:", option.dialogueOption, typeof(DialogueOption), true);
            if (option.dialogueOption == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    Undo.RecordObject(_target, "Auto-create dialogue option");
                    DialogueOption newDialogueOption = SceneManager.AddPrefab("Logic", "DialogueOption", true, false, true).GetComponent <DialogueOption>();

                    newDialogueOption.gameObject.name = AdvGame.UniqueName(_target.gameObject.name + "_Option");
                    newDialogueOption.Initialise();
                    EditorUtility.SetDirty(newDialogueOption);
                    option.dialogueOption = newDialogueOption;
                }
            }
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Icon texture:", GUILayout.Width(155f));
        option.icon = (Texture2D)EditorGUILayout.ObjectField(option.icon, typeof(Texture2D), false, GUILayout.Width(70f), GUILayout.Height(30f));
        EditorGUILayout.EndHorizontal();

        option.isOn = EditorGUILayout.Toggle("Is enabled?", option.isOn);
        if (source == InteractionSource.CustomScript)
        {
            EditorGUILayout.HelpBox("Using a custom script will cause the conversation to end when finished, unless it is re-run explicitly.", MessageType.Info);
        }
        else
        {
            option.conversationAction = (ConversationAction)EditorGUILayout.EnumPopup("When finished:", option.conversationAction);
            if (option.conversationAction == AC.ConversationAction.RunOtherConversation)
            {
                option.newConversation = (Conversation)EditorGUILayout.ObjectField("Conversation to run:", option.newConversation, typeof(Conversation), true);
            }
        }

        if (_target.isTimed)
        {
            if (_target.options.IndexOf(option) != _target.defaultOption)
            {
                if (GUILayout.Button("Make default", GUILayout.MaxWidth(80)))
                {
                    Undo.RecordObject(_target, "Change default conversation option");
                    _target.defaultOption = _target.options.IndexOf(option);
                    EditorUtility.SetDirty(_target);
                }
            }
        }

        EditorGUILayout.EndVertical();
    }
Ejemplo n.º 10
0
 private void ActivateOption(ButtonDialog option)
 {
     option.isEditing       = true;
     _target.selectedOption = option;
 }