/// <summary> /// Creates a new <see cref="EditorNPCChatDialog"/> and adds it to this collection. /// </summary> /// <returns>The new <see cref="EditorNPCChatDialog"/>.</returns> public static EditorNPCChatDialog CreateNewDialog() { _instance.Reorganize(); // Find the first free index var i = 0; while (_instance.DialogExists((NPCChatDialogID)i)) { ++i; } // Create the new instance var dialog = new EditorNPCChatDialog(); dialog.SetID(new NPCChatDialogID(i)); // Create the initial dialog item var dialogItem = new EditorNPCChatDialogItem(dialog.GetFreeDialogItemID(), "New dialog"); dialogItem.SetText("<Enter the initial text to display>"); dialog.Add(dialogItem); // Add to the collection AddDialog(dialog); return dialog; }
/// <summary> /// Creates a new <see cref="EditorNPCChatDialog"/> and adds it to this collection. /// </summary> /// <returns>The new <see cref="EditorNPCChatDialog"/>.</returns> public static EditorNPCChatDialog CreateNewDialog() { _instance.Reorganize(); // Find the first free index var i = 0; while (_instance.DialogExists((NPCChatDialogID)i)) { ++i; } // Create the new instance var dialog = new EditorNPCChatDialog(); dialog.SetID(new NPCChatDialogID(i)); // Create the initial dialog item var dialogItem = new EditorNPCChatDialogItem(dialog.GetFreeDialogItemID(), "New dialog"); dialogItem.SetText("<Enter the initial text to display>"); dialog.Add(dialogItem); // Add to the collection AddDialog(dialog); return(dialog); }
/// <summary> /// Handles when a <see cref="EditorNPCChatDialogItem"/> changes. /// </summary> /// <param name="sender">The <see cref="EditorNPCChatDialogItem"/> that changed.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void EditorNPCChatDialogItem_Changed(EditorNPCChatDialogItem sender, EventArgs e) { List <NPCChatDialogViewNode> l; if (!_objToTreeNode.TryGetValue(sender, out l)) { return; } foreach (var node in l) { node.Update(false); } }
/// <summary> /// Adds a <see cref="EditorNPCChatDialogItem"/> to this <see cref="EditorNPCChatDialog"/>. /// </summary> /// <param name="item">The <see cref="EditorNPCChatDialogItem"/> to add.</param> public void Add(EditorNPCChatDialogItem item) { ResizeArrayToFitIndex(ref _items, (int)item.ID); if (_items[(int)item.ID] == item) { return; } _items[(int)item.ID] = item; if (Changed != null) { Changed.Raise(this, EventArgs.Empty); } }
public bool RemoveDialogItem(EditorNPCChatDialogItem dialogItem) { // Find the responses that reference this dialog var sourceResponses = GetSourceResponses(dialogItem).Cast <EditorNPCChatResponse>(); // Remove the dialog from the collection if (_items[(int)dialogItem.ID] != dialogItem) { return(false); } _items[(int)dialogItem.ID] = null; // Remove references to the dialog foreach (var r in sourceResponses) { r.SetPage(NPCChatResponseBase.EndConversationPage); } return(true); }
/// <summary> /// Handles when a <see cref="EditorNPCChatDialogItem"/> changes. /// </summary> /// <param name="sender">The <see cref="EditorNPCChatDialogItem"/> that changed.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void EditorNPCChatDialogItem_Changed(EditorNPCChatDialogItem sender, EventArgs e) { List<NPCChatDialogViewNode> l; if (!_objToTreeNode.TryGetValue(sender, out l)) return; foreach (var node in l) { node.Update(false); } }
/// <summary> /// Creates the test dialog. /// </summary> /// <returns>The test dialog.</returns> // ReSharper disable UnusedMember.Local static EditorNPCChatDialog CreateTestDialog() // ReSharper restore UnusedMember.Local { var dialog = new EditorNPCChatDialog(); var haveYouDoneThisQuest = new EditorNPCChatDialogItem(new NPCChatDialogItemID(0), "Have you done this quest?"); haveYouDoneThisQuest.AddResponse(new EditorNPCChatResponse(new NPCChatDialogItemID(1), "False"), new EditorNPCChatResponse(new NPCChatDialogItemID(2), "True")); var hasNotDoneThisQuest = new EditorNPCChatDialogItem(new NPCChatDialogItemID(1), "Think you can help me out?"); hasNotDoneThisQuest.AddResponse(new EditorNPCChatResponse(new NPCChatDialogItemID(3), "Yes"), new EditorNPCChatResponse(new NPCChatDialogItemID(4), "No")); var acceptHelp = new EditorNPCChatDialogItem(new NPCChatDialogItemID(3), "Sweet, thanks!"); var declineHelp = new EditorNPCChatDialogItem(new NPCChatDialogItemID(4), "Fine. Screw you too, you selfish jerk!"); var hasDoneThisQuest = new EditorNPCChatDialogItem(new NPCChatDialogItemID(2), "Sorry dude, you already did this quest!"); hasDoneThisQuest.AddResponse(new EditorNPCChatResponse(new NPCChatDialogItemID(1), "So? Just let me do it!"), new EditorNPCChatResponse("Ok, fine, whatever. Dick.")); dialog.Add(new EditorNPCChatDialogItem[] { haveYouDoneThisQuest, hasNotDoneThisQuest, acceptHelp, declineHelp, hasDoneThisQuest }); return dialog; }
/// <summary> /// Handles the Click event of the btnAddDialog control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void btnAddDialog_Click(object sender, EventArgs e) { if (_doNotUpdateObj) return; if (EditingObjAsResponse == null) return; // Make sure there isn't already a dialog characterID if (EditingObjAsResponse.Page != NPCChatResponseBase.EndConversationPage) { MessageBox.Show("This response already has a dialog characterID."); return; } // Create the new dialog characterID var id = CurrentDialog.GetFreeDialogItemID(); var newDialogItem = new EditorNPCChatDialogItem(id, "New dialog characterID"); CurrentDialog.Add(newDialogItem); // Hook it to the response EditingObjAsResponse.SetPage(id); // Update the tree npcChatDialogView.UpdateTree(); // TODO: Select the new dialog characterID in the tree }