internal void UpdateText() { EditorNPCChatDialogItem asDialogItem; string text; Color foreColor; switch (ChatItemType) { case NPCChatDialogViewNodeItemType.Redirect: asDialogItem = ChatItemAsDialogItem; text = "[GOTO " + asDialogItem.ID + ": " + GetText(asDialogItem) + "]"; foreColor = TreeViewCasted.NodeForeColorGoTo; break; case NPCChatDialogViewNodeItemType.DialogItem: asDialogItem = ChatItemAsDialogItem; text = asDialogItem.ID + ": " + GetText(asDialogItem); foreColor = asDialogItem.IsBranch ? TreeViewCasted.NodeForeColorBranch : TreeViewCasted.NodeForeColorNormal; break; case NPCChatDialogViewNodeItemType.Response: EditorNPCChatResponse asResponse = ChatItemAsResponse; text = "[" + asResponse.Value + ": " + asResponse.Text + "]"; foreColor = TreeViewCasted.NodeForeColorResponse; break; default: const string errmsg = "Invalid ChatItemType `{0}`."; throw new InvalidOperationException(string.Format(errmsg, ChatItemType)); } Text = text; ForeColor = foreColor; }
/// <summary> /// Adds a <see cref="EditorNPCChatResponse"/>. /// </summary> /// <param name="response">The <see cref="EditorNPCChatResponse"/> to add.</param> /// <exception cref="ArgumentNullException"><paramref name="response" /> is <c>null</c>.</exception> public void AddResponse(EditorNPCChatResponse response) { if (response == null) { throw new ArgumentNullException("response"); } _responses.Add(response); var index = _responses.IndexOf(response); response.SetValue((byte)index); EnsureResponseValuesAreValid(); }
/// <summary> /// Handles when a <see cref="EditorNPCChatResponse"/> changes. /// </summary> /// <param name="response">The <see cref="EditorNPCChatResponse"/> that changed.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void EditorNPCChatResponse_Changed(EditorNPCChatResponse response, EventArgs e) { List <NPCChatDialogViewNode> l; if (!_objToTreeNode.TryGetValue(response, out l)) { return; } foreach (var node in l) { node.Update(false); } }
/// <summary> /// Handles when a <see cref="EditorNPCChatResponse"/> changes. /// </summary> /// <param name="response">The <see cref="EditorNPCChatResponse"/> that changed.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void EditorNPCChatResponse_Changed(EditorNPCChatResponse response, EventArgs e) { List<NPCChatDialogViewNode> l; if (!_objToTreeNode.TryGetValue(response, out l)) return; foreach (var node in l) { node.Update(false); } }
/// <summary> /// Handles the Click event of the btnAddResponse 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 btnAddResponse_Click(object sender, EventArgs e) { if (_doNotUpdateObj) return; if (EditingObjAsDialogItem == null) return; var response = new EditorNPCChatResponse("<New Response>"); EditingObjAsDialogItem.ResponseList.Add(response); npcChatDialogView.UpdateTree(); // TODO: Auto-select the new node for the response }
/// <summary> /// Adds a <see cref="EditorNPCChatResponse"/>. /// </summary> /// <param name="response">The <see cref="EditorNPCChatResponse"/> to add.</param> /// <exception cref="ArgumentNullException"><paramref name="response" /> is <c>null</c>.</exception> public void AddResponse(EditorNPCChatResponse response) { if (response == null) throw new ArgumentNullException("response"); _responses.Add(response); var index = _responses.IndexOf(response); response.SetValue((byte)index); EnsureResponseValuesAreValid(); }