Exemple #1
0
        private void OnPackageChanged(object sender, EventArgs e)
        {
            if (!ready)
            {
                return;
            }

            if (currentPackage.Name == textBoxPackage.Text)     //Since I use the validated event, this may be called even without modifications
            {
                return;
            }

            DialogResult result = MessageBox.Show("Renaming a Package will update all dialogues associated.\nDo you wish to continue ?", "Rename Package...", MessageBoxButtons.OKCancel, MessageBoxIcon.None, MessageBoxDefaultButton.Button2);

            if (result == DialogResult.Cancel)
            {
                ready = false;
                textBoxPackage.Text = currentPackage.Name;
                ready = true;
                return;
            }

            currentPackage.Name = textBoxPackage.Text;
            (listBoxPackages.DataSource as BindingSource).ResetBindings(false);

            List <Dialogue> dialogues = ResourcesHandler.GetAllDialogues();

            foreach (Dialogue dialogue in dialogues)
            {
                if (dialogue.Package == currentPackage)
                {
                    ResourcesHandler.SetDirty(dialogue);
                }
            }

            SetDirty();

            if (EditorCore.MainWindow != null)
            {
                EditorCore.MainWindow.RefreshDirtyFlags();
            }

            if (EditorCore.ProjectExplorer != null)
            {
                EditorCore.ProjectExplorer.ResyncAllFiles();
            }
        }
        private void ProcessSearchName()
        {
            tree.Visible = false;
            listBoxSearchResults.Visible = true;

            listBoxSearchResults.BeginUpdate();

            listBoxSearchResults.Items.Clear();

            string fileName  = textBoxSearchName.Text;
            string sceneType = comboBoxSearchSceneType.SelectedValue as string;
            string actor     = comboBoxSearchActor.SelectedValue as string;

            var dialogues = ResourcesHandler.GetAllDialogues();

            foreach (var dialogue in dialogues)
            {
                bool validActor = true;
                if (actor != String.Empty)
                {
                    validActor = false;
                    foreach (var node in dialogue.ListNodes)
                    {
                        var sentence = node as DialogueNodeSentence;
                        if (sentence != null && (sentence.SpeakerID == actor || sentence.ListenerID == actor))
                        {
                            validActor = true;
                            break;
                        }
                    }
                }

                if ((fileName == String.Empty || dialogue.GetName().ContainsIgnoreCase(fileName)) &&
                    (sceneType == String.Empty || dialogue.SceneType == sceneType) &&
                    validActor)
                {
                    listBoxSearchResults.Items.Add(dialogue.GetName());
                }
            }

            if (listBoxSearchResults.Items.Count == 0)
            {
                listBoxSearchResults.Items.Add("No Result");
            }

            listBoxSearchResults.EndUpdate();
        }
Exemple #3
0
        private void OnRemoveActor(object sender, EventArgs e)
        {
            int index = listBoxActors.SelectedIndex;

            if (project.ListActors.Count == 0)
            {
                return;
            }

            string oldID = currentActor.ID;

            currentActor = null;
            project.ListActors.RemoveAt(index);
            (listBoxActors.DataSource as BindingSource).ResetBindings(false);

            if (project.ListActors.Count > 0)
            {
                listBoxActors.SelectedIndex = 0;

                if (currentActor == null)
                {
                    currentActor = listBoxActors.SelectedItem as Actor;
                    RefreshActorView();
                }
            }

            List <Dialogue> dialogues = ResourcesHandler.GetAllDialogues();

            foreach (Dialogue dialogue in dialogues)
            {
                if (dialogue.UpdateActorID(oldID, ""))
                {
                    ResourcesHandler.SetDirty(dialogue);
                }
            }

            SetDirty();

            if (EditorCore.MainWindow != null)
            {
                EditorCore.MainWindow.RefreshDirtyFlags();
            }
        }
Exemple #4
0
        private void OnEditIDClicked(object sender, EventArgs e)
        {
            if (!ready)
            {
                return;
            }

            DialogRename dialog = new DialogRename(currentActor.ID);

            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                string oldID = currentActor.ID;
                if (project.ChangeActorID(currentActor, dialog.NewID))
                {
                    List <Dialogue> dialogues = ResourcesHandler.GetAllDialogues();
                    foreach (Dialogue dialogue in dialogues)
                    {
                        if (dialogue.UpdateActorID(oldID, currentActor.ID))
                        {
                            ResourcesHandler.SetDirty(dialogue);
                        }
                    }

                    textBoxID.Text = currentActor.ID;

                    SetDirty();

                    if (EditorCore.MainWindow != null)
                    {
                        EditorCore.MainWindow.RefreshDirtyFlags();
                    }
                }
            }
        }
        public void ResyncAllFiles()
        {
            Clear();

            Project project = ResourcesHandler.Project;

            if (project == null)
            {
                return;
            }

            if (EditorCore.CustomLists["SceneTypes"].Count > 0)
            {
                var sceneTypes = new Dictionary <string, string>();
                sceneTypes.Add("", "");
                foreach (var kvp in EditorCore.CustomLists["SceneTypes"])
                {
                    sceneTypes.Add(kvp.Key, kvp.Value);
                }

                comboBoxSearchSceneType.DataSource    = new BindingSource(sceneTypes, null);
                comboBoxSearchSceneType.ValueMember   = "Key";
                comboBoxSearchSceneType.DisplayMember = "Value";

                comboBoxSearchSceneType.Enabled = true;
            }

            if (project.ListActors.Count > 0)
            {
                var actors = new Dictionary <string, string>();
                actors.Add("", "");
                foreach (var actor in project.ListActors)
                {
                    actors.Add(actor.ID, actor.Name);
                }

                comboBoxSearchActor.DataSource    = new BindingSource(actors, null);
                comboBoxSearchActor.ValueMember   = "Key";
                comboBoxSearchActor.DisplayMember = "Value";

                comboBoxSearchActor.Enabled = true;
            }

            tree.BeginUpdate();

            TreeNode nodeProject = tree.Nodes.Add("Project", String.Format("Project {0}", project.GetName()));

            nodeProject.Tag = project;
            EditorHelper.SetNodeIcon(nodeProject, ENodeIcon.Project);

            foreach (Package package in project.ListPackages)
            {
                TreeNode nodePackage = tree.Nodes.Add(GetPackageKey(package.Name), package.Name);
                nodePackage.Tag = package;
                nodePackage.ContextMenuStrip = menuPackage;
                EditorHelper.SetNodeIcon(nodePackage, ENodeIcon.Package);
            }

            foreach (Dialogue dialogue in ResourcesHandler.GetAllDialogues())
            {
                ResyncFile(dialogue, false);
            }

            tree.EndUpdate();

            //tree.CollapseAll();
            foreach (TreeNode node in tree.Nodes)
            {
                node.Expand();
            }
        }
Exemple #6
0
        private void SearchClick(object sender, EventArgs e)
        {
            string workstring      = textBoxWorkstring.Text;
            bool   searchSentences = checkBoxSentences.Checked;
            bool   searchReplies   = checkBoxReplies.Checked;
            bool   searchChoices   = checkBoxChoices.Checked;

            List <Result> results = new List <Result>();

            var dialogues = ResourcesHandler.GetAllDialogues();

            foreach (var dialogue in dialogues)
            {
                foreach (var node in dialogue.ListNodes)
                {
                    foreach (var condition in node.Conditions)
                    {
                        if (Check(condition))
                        {
                            results.Add(Result.BuildResult(String.Format("{0} {1} - {2}", dialogue.GetName(), node.ID, (condition as NodeCondition).GetDisplayText()), dialogue, node));
                        }
                    }
                    foreach (var action in node.Actions)
                    {
                        if (Check(action))
                        {
                            results.Add(Result.BuildResult(String.Format("{0} {1} - {2}", dialogue.GetName(), node.ID, (action as NodeAction).GetDisplayText()), dialogue, node));
                        }
                    }
                    foreach (var flag in node.Flags)
                    {
                        if (Check(flag))
                        {
                            results.Add(Result.BuildResult(String.Format("{0} {1} - {2}", dialogue.GetName(), node.ID, (flag as NodeFlag).GetDisplayText()), dialogue, node));
                        }
                    }

                    if (workstring.Length > 0)
                    {
                        if (searchSentences)
                        {
                            var sentence = node as DialogueNodeSentence;
                            if (sentence != null && sentence.Sentence.IndexOf(workstring, StringComparison.CurrentCultureIgnoreCase) >= 0)
                            {
                                results.Add(Result.BuildResult(String.Format("{0} {1} - {2}", dialogue.GetName(), node.ID, FormatText(sentence.Sentence)), dialogue, node));
                            }
                        }

                        if (searchReplies)
                        {
                            var reply = node as DialogueNodeReply;
                            if (reply != null && reply.Reply.IndexOf(workstring, StringComparison.CurrentCultureIgnoreCase) >= 0)
                            {
                                results.Add(Result.BuildResult(String.Format("{0} {1} - {2}", dialogue.GetName(), node.ID, FormatText(reply.Reply)), dialogue, node));
                            }
                        }

                        if (searchChoices)
                        {
                            var choice = node as DialogueNodeChoice;
                            if (choice != null && choice.Choice.IndexOf(workstring, StringComparison.CurrentCultureIgnoreCase) >= 0)
                            {
                                results.Add(Result.BuildResult(String.Format("{0} {1} - {2}", dialogue.GetName(), node.ID, FormatText(choice.Choice)), dialogue, node));
                            }
                        }
                    }
                }
            }

            EditorCore.StartSearchResult();
            foreach (var result in results)
            {
                EditorCore.AddSearchResult(result.text, result.dialogue, result.node);
            }
            EditorCore.EndSearchResult();
        }
Exemple #7
0
        private void OnShowAllStats(object sender, EventArgs e)
        {
            DialogStats dialog = new DialogStats(ResourcesHandler.GetAllDialogues());

            dialog.ShowDialog();
        }
        private void populateDialogueTreeView(List <Dialogue> inCheckedDialogues)
        {
            var project = ResourcesHandler.Project;

            if (project == null)
            {
                return;
            }

            dialogueTreeView.BeginUpdate();

            foreach (Package package in project.ListPackages)
            {
                TreeNode nodePackage = dialogueTreeView.Nodes.Add(GetPackageKey(package.Name), package.Name);
                nodePackage.Tag = package;
                EditorHelper.SetNodeIcon(nodePackage, ENodeIcon.Package);
            }

            foreach (Dialogue dialogue in ResourcesHandler.GetAllDialogues())
            {
                if (dialogue == null)
                {
                    continue;
                }

                if (dialogue.Package == null)
                {
                    continue;
                }

                TreeNode[] nodePackages = dialogueTreeView.Nodes.Find(GetPackageKey(dialogue.Package.Name), false);
                if (nodePackages.Count() > 0)
                {
                    TreeNode nodeParent = nodePackages[0];

                    string   path       = dialogue.GetFilePath();
                    string[] folders    = path.Split(new char[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
                    string   folderPath = "";
                    foreach (string folder in folders)
                    {
                        folderPath = Path.Combine(folderPath, folder);

                        TreeNode[] nodeFolders = nodeParent.Nodes.Find(folder, false);
                        if (nodeFolders.Count() > 0)
                        {
                            nodeParent = nodeFolders[0];
                        }
                        else
                        {
                            nodeParent     = nodeParent.Nodes.Add(folder, folder);
                            nodeParent.Tag = new Folder()
                            {
                                Path = folderPath
                            };
                            EditorHelper.SetNodeIcon(nodeParent, ENodeIcon.Folder);
                        }
                    }

                    TreeNode nodeDialogue = nodeParent.Nodes.Add(dialogue.GetFileName(), dialogue.GetName());
                    nodeDialogue.Checked = checkedDialogues.Contains(dialogue);
                    nodeDialogue.Tag     = dialogue;
                    EditorHelper.SetNodeIcon(nodeDialogue, ENodeIcon.Dialogue);
                }
            }

            dialogueTreeView.EndUpdate();

            foreach (TreeNode node in dialogueTreeView.Nodes)
            {
                node.Expand();
            }
        }