/// <summary> /// Handles the TextChanged event of the txtDialogText 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 txtDialogText_TextChanged(object sender, EventArgs e) { if (_doNotUpdateObj) { return; } if (EditingObjAsDialogItem != null) { EditingObjAsDialogItem.SetText(txtDialogText.Text); } }
/// <summary> /// Handles the TextChanged event of the txtTitle 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 txtTitle_TextChanged(object sender, EventArgs e) { if (_doNotUpdateObj) { return; } if (EditingObjAsDialogItem != null) { EditingObjAsDialogItem.SetTitle(txtTitle.Text); } else if (EditingObjAsResponse != null) { EditingObjAsResponse.SetText(txtTitle.Text); } }
/// <summary> /// Handles the CheckedChanged event of the chkIsBranch 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 chkIsBranch_CheckedChanged(object sender, EventArgs e) { if (_doNotUpdateObj) { return; } if (EditingObjAsDialogItem == null) { return; } if (EditingObjAsDialogItem.IsBranch == chkIsBranch.Checked) { Debug.Fail("Uh-oh - an inconsistency!"); return; } _doNotUpdateObj = true; const string msgSetAsNonBranch = "Are you sure you wish to change this dialog to a normal dialog?" + " Changing to a normal dialog will result in all conditionals for this dialog characterID to be lost."; const string msgSetAsBranch = "Are you sure you wish to change this dialog to a conditional branch?" + " Changing to a conditional branch will result in some alterations being made to your existing responses."; try { string error; bool success; if (EditingObjAsDialogItem.IsBranch) { if (MessageBox.Show(msgSetAsNonBranch, "Accept changes?", MessageBoxButtons.YesNo) == DialogResult.No) { return; } success = EditingObjAsDialogItem.TrySetAsNonBranch(out error); } else { if (MessageBox.Show(msgSetAsBranch, "Accept changes?", MessageBoxButtons.YesNo) == DialogResult.No) { return; } success = EditingObjAsDialogItem.TrySetAsBranch(out error); } if (!success) { const string errmsg = "Failed to apply changes. Reason: {0}"; MessageBox.Show(string.Format(errmsg, error)); } } finally { chkIsBranch.Checked = EditingObjAsDialogItem.IsBranch; _doNotUpdateObj = false; } // TODO: Proper updating btnRefresh_Click(this, null); }
/// <summary> /// Sets the NPC chat object being edited. /// </summary> /// <param name="obj">The NPC chat object.</param> void SetEditingObject(object obj) { if (_editingObj == obj) { return; } _doNotUpdateObj = true; _editingObj = obj; SetConditionalsEnabled(false); if (obj is EditorNPCChatDialogItem) { DisableAllTabsExcept(tcChatDialogItem, tpDialog); txtTitle.Enabled = true; txtTitle.Text = EditingObjAsDialogItem.Title; txtDialogText.Text = EditingObjAsDialogItem.Text; txtDialogPage.Text = EditingObjAsDialogItem.ID.ToString(); chkIsBranch.Checked = EditingObjAsDialogItem.IsBranch; if (EditingObjAsDialogItem.IsBranch) { SetConditionalsEnabled(true); lstConditionals.SetConditionalCollection(EditingObjAsDialogItem.Conditionals); EditingObjAsDialogItem.SetConditionals(lstConditionals.ConditionalCollection); } } else if (obj is EditorNPCChatResponse) { DisableAllTabsExcept(tcChatDialogItem, tpResponse); txtTitle.Enabled = true; txtTitle.Text = EditingObjAsResponse.Text; txtDialogText.Text = EditingObjAsResponse.Text; txtResponseIndex.Text = EditingObjAsResponse.Page.ToString(); txtResponseValue.Text = EditingObjAsResponse.Value.ToString(); SetConditionalsEnabled(true); lstConditionals.SetConditionalCollection(EditingObjAsResponse.Conditionals); EditingObjAsResponse.SetConditionals(lstConditionals.ConditionalCollection); lstActions.Items.Clear(); lstActions.Items.AddRange(EditingObjAsResponse.Actions.ToArray()); } else if (obj is TreeNode) { DisableAllTabsExcept(tcChatDialogItem, tpRedirect); txtTitle.Enabled = false; var redirectTo = (EditorNPCChatDialogItem)EditingObjAsTreeNode.Tag; txtTitle.Text = redirectTo.Text; txtRedirectID.Text = redirectTo.ID.ToString(); } else { SetAllChildrenEnabled(tcChatDialogItem.Controls, false); } _doNotUpdateObj = false; }