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(); }