Esempio n. 1
0
        /// <summary>
        /// Handles the Click event of the btnDelete 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 btnDelete_Click(object sender, EventArgs e)
        {
            // Check for a valid dialog
            if (CurrentDialog == null)
            {
                const string msg = "You must first select a chat dialog to delete it.";
                MessageBox.Show(msg, "Delete chat", MessageBoxButtons.OK);
                return;
            }

            if (CurrentDialog != EditorNPCChatManager.GetDialog(CurrentDialog.ID))
            {
                const string msg = "The selected dialog ({0}) seems to be invalid. Cannot delete.";
                MessageBox.Show(msg, "Delete chat", MessageBoxButtons.OK);
                return;
            }

            // Confirm deletion
            const string deleteMsg = "Are you sure you wish to delete the NPC chat dialog `{0}`?";

            if (MessageBox.Show(string.Format(deleteMsg, CurrentDialog), "Delete chat", MessageBoxButtons.YesNo) ==
                DialogResult.No)
            {
                return;
            }

            // Delete
            EditorNPCChatManager.DeleteDialog(CurrentDialog);

            UpdateSelectedDialogList();
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the Click event of the btnSave 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 btnSave_Click(object sender, EventArgs e)
        {
            const string msg =
                "Save changes to the NPC chat dialogs? This will save all dialogs, not just the currently visible one.";

            if (MessageBox.Show(msg, "Save changes", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            EditorNPCChatManager.SaveDialogs();

            MessageBox.Show("NPC chat dialogs saved.", "Saved", MessageBoxButtons.OK);
        }
Esempio n. 3
0
        /// <summary>
        /// Handles the Click event of the btnNew 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 btnNew_Click(object sender, EventArgs e)
        {
            const string msg = "Do you wish to create a new NPC chat dialog?";

            if (MessageBox.Show(msg, "Create new dialog", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            var dialog = EditorNPCChatManager.CreateNewDialog();

            UpdateSelectedDialogList();

            cmbSelectedDialog.SelectedItem = dialog;
        }
Esempio n. 4
0
        /// <summary>
        /// Updates the <see cref="cmbSelectedDialog"/> while retaining the selected item.
        /// </summary>
        void UpdateSelectedDialogList()
        {
            // Remove itemsthat need to be removed
            foreach (var dialog in cmbSelectedDialog.Items.OfType <NPCChatDialogBase>().ToImmutable())
            {
                var fromManager = EditorNPCChatManager.GetDialog(dialog.ID);
                if (fromManager == null || fromManager != dialog)
                {
                    cmbSelectedDialog.Items.Remove(dialog);
                }
            }

            // Re-add the dialogs to make sure none are missing
            foreach (var dialog in EditorNPCChatManager.Dialogs.OfType <NPCChatDialogBase>())
            {
                if (!cmbSelectedDialog.Items.Contains(dialog))
                {
                    cmbSelectedDialog.Items.Add(dialog);
                }
            }
        }