/// <summary> /// Initializes a new instance of the <see cref="EditorNPCChatDialogItem"/> class. /// </summary> /// <param name="id">The ID.</param> /// <param name="text">The text.</param> /// <param name="title">The title.</param> public EditorNPCChatDialogItem(NPCChatDialogItemID id, string text, string title) { SetText(text); SetTitle(title); _id = id; }
public static PacketWriter SetChatDialogPage(NPCChatDialogItemID pageID, IEnumerable <byte> responsesToSkip) { var pw = GetWriter(ServerPacketID.SetChatDialogPage); pw.Write(pageID); // Get the number of responses to skip byte skipCount; if (responsesToSkip == null) { skipCount = 0; } else { skipCount = (byte)responsesToSkip.Count(); } pw.Write(skipCount); // List off the responses to skip, if any if (skipCount > 0) { Debug.Assert(responsesToSkip != null); foreach (var responseToSkip in responsesToSkip) { pw.Write(responseToSkip); } } return(pw); }
public void SetPageIndex(NPCChatDialogItemID pageID, IEnumerable <byte> responsesToSkip) { _page = _dialog.GetDialogItem(pageID); if (_page == null) { const string errmsg = "Page `{0}` in dialog `{1}` is null. The Client should never be trying to set an invalid page."; if (log.IsErrorEnabled) { log.ErrorFormat(errmsg, pageID, _dialog); } Debug.Fail(string.Format(errmsg, pageID, _dialog)); EndDialog(); return; } if (responsesToSkip != null) { _responses = _page.Responses.Where(x => !responsesToSkip.Contains(x.Value)).OrderBy(x => x.Value).ToArray(); } else { _responses = _page.Responses.OrderBy(x => x.Value).ToArray(); } _dialogTextControl.Text = _page.Text; SetResponseOffset(0); IsVisible = true; }
/// <summary> /// When overridden in the derived class, gets the NPCChatDialogItemBase for the given page number. /// </summary> /// <param name="chatDialogItemIndex">The page number of the NPCChatDialogItemBase to get.</param> /// <returns>The NPCChatDialogItemBase for the given <paramref name="chatDialogItemIndex"/>, or null if /// no valid NPCChatDialogItemBase existed for the given <paramref name="chatDialogItemIndex"/> or if /// the <paramref name="chatDialogItemIndex"/> is equal to /// <see cref="NPCChatResponseBase.EndConversationPage"/>.</returns> public override NPCChatDialogItemBase GetDialogItem(NPCChatDialogItemID chatDialogItemIndex) { if (chatDialogItemIndex == NPCChatResponseBase.EndConversationPage) return null; if (chatDialogItemIndex < 0 || chatDialogItemIndex >= _items.Length) { const string errmsg = "Invalid NPCChatDialogItemBase index `{0}`."; Debug.Fail(string.Format(errmsg, chatDialogItemIndex)); if (log.IsWarnEnabled) log.ErrorFormat(errmsg, chatDialogItemIndex); return null; } return _items[(int)chatDialogItemIndex]; }
public void SetPageIndex(NPCChatDialogItemID pageID, IEnumerable<byte> responsesToSkip) { _page = _dialog.GetDialogItem(pageID); if (_page == null) { const string errmsg = "Page `{0}` in dialog `{1}` is null. The Client should never be trying to set an invalid page."; if (log.IsErrorEnabled) log.ErrorFormat(errmsg, pageID, _dialog); Debug.Fail(string.Format(errmsg, pageID, _dialog)); EndDialog(); return; } if (responsesToSkip != null) _responses = _page.Responses.Where(x => !responsesToSkip.Contains(x.Value)).OrderBy(x => x.Value).ToArray(); else _responses = _page.Responses.OrderBy(x => x.Value).ToArray(); _dialogTextControl.Text = _page.Text; SetResponseOffset(0); IsVisible = true; }
/// <summary> /// When overridden in the derived class, gets the <see cref="NPCChatDialogItemBase"/> for the given page number. /// </summary> /// <param name="chatDialogItemID">The page number of the <see cref="NPCChatDialogItemBase"/> to get.</param> /// <returns> /// The <see cref="NPCChatDialogItemBase"/> for the given <paramref name="chatDialogItemID"/>, or null if /// no valid <see cref="NPCChatDialogItemBase"/> existed for the given <paramref name="chatDialogItemID"/> or if /// the <paramref name="chatDialogItemID"/> is equal to /// <see cref="NPCChatResponseBase.EndConversationPage"/>. /// </returns> public abstract NPCChatDialogItemBase GetDialogItem(NPCChatDialogItemID chatDialogItemID);
/// <summary> /// Gets the NPCChatDialogViewNode for the given NPCChatDialogItemBase. Nodes that redirect to the /// given NPCChatDialogItemBase are not included. /// </summary> /// <param name="dialogItemID">The index of the NPCChatDialogItemBase to find the NPCChatDialogViewNode for.</param> /// <returns>The NPCChatDialogViewNode for the given <paramref name="dialogItemID"/>, or null if /// no NPCChatDialogViewNode was found that handles the given <paramref name="dialogItemID"/> or /// if the <paramref name="dialogItemID"/> was for an invalid NPCChatDialogItemBase.</returns> public NPCChatDialogViewNode GetNodeForDialogItem(NPCChatDialogItemID dialogItemID) { if (NPCChatDialog == null) return null; var dialogItem = NPCChatDialog.GetDialogItem(dialogItemID); if (dialogItem == null) return null; return GetNodeForDialogItem(dialogItem); }
/// <summary> /// Initializes a new instance of the <see cref="EditorNPCChatDialogItem"/> class. /// </summary> /// <param name="id">The ID.</param> /// <param name="text">The text.</param> public EditorNPCChatDialogItem(NPCChatDialogItemID id, string text) : this(id, text, string.Empty) { }
/// <summary> /// When overridden in the derived class, sets the values read from the Read method. /// </summary> /// <param name="page">The index.</param> /// <param name="title">The title.</param> /// <param name="text">The text.</param> /// <param name="isBranch">The IsBranch value.</param> /// <param name="responses">The responses.</param> /// <param name="conditionals">The conditionals.</param> protected override void SetReadValues(NPCChatDialogItemID page, string title, string text, bool isBranch, IEnumerable<NPCChatResponseBase> responses, NPCChatConditionalCollectionBase conditionals) { Debug.Assert(_id == default(NPCChatDialogItemID) && _responses == default(IEnumerable<NPCChatResponseBase>), "Values were already set?"); _id = page; _isBranch = isBranch; _responses = responses.ToArray(); _conditionals = conditionals; }
public static PacketWriter SetChatDialogPage(NPCChatDialogItemID pageID, IEnumerable<byte> responsesToSkip) { var pw = GetWriter(ServerPacketID.SetChatDialogPage); pw.Write(pageID); // Get the number of responses to skip byte skipCount; if (responsesToSkip == null) skipCount = 0; else skipCount = (byte)responsesToSkip.Count(); pw.Write(skipCount); // List off the responses to skip, if any if (skipCount > 0) { Debug.Assert(responsesToSkip != null); foreach (var responseToSkip in responsesToSkip) { pw.Write(responseToSkip); } } return pw; }
/// <summary> /// When overridden in the derived class, sets the values read from the Read method. /// </summary> /// <param name="value">The value.</param> /// <param name="page">The page.</param> /// <param name="text">The text.</param> /// <param name="conditionals">The conditionals.</param> /// <param name="actions">The actions.</param> protected override void SetReadValues(byte value, NPCChatDialogItemID page, string text, NPCChatConditionalCollectionBase conditionals, NPCChatResponseActionBase[] actions) { Debug.Assert(_value == default(byte) && _page == default(ushort) && _text == default(string), "Values were already set?"); _value = value; _page = page; _text = text; }
/// <summary> /// When overridden in the derived class, sets the values read from the Read method. /// </summary> /// <param name="value">The value.</param> /// <param name="page">The page.</param> /// <param name="text">The text.</param> /// <param name="conditionals">The conditionals.</param> /// <param name="actions">The actions.</param> protected abstract void SetReadValues(byte value, NPCChatDialogItemID page, string text, NPCChatConditionalCollectionBase conditionals, NPCChatResponseActionBase[] actions);
/// <summary> /// When overridden in the derived class, sets the values read from the Read method. /// </summary> /// <param name="page">The ID.</param> /// <param name="title">The title.</param> /// <param name="text">The text.</param> /// <param name="isBranch">The IsBranch value.</param> /// <param name="responses">The responses.</param> /// <param name="conditionals">The conditionals.</param> protected override void SetReadValues(NPCChatDialogItemID page, string title, string text, bool isBranch, IEnumerable<NPCChatResponseBase> responses, NPCChatConditionalCollectionBase conditionals) { _id = page; _isBranch = isBranch; SetTitle(title); SetText(text); _responses.Clear(); _responses.AddRange(responses.Cast<EditorNPCChatResponse>().OrderBy(x => x.Value)); EnsureResponseValuesAreValid(); var c = conditionals as EditorNPCChatConditionalCollection; _conditionals = c ?? new EditorNPCChatConditionalCollection(); }
/// <summary> /// Initializes a new instance of the <see cref="EditorNPCChatResponse"/> class. /// </summary> /// <param name="page">The page.</param> /// <param name="text">The text.</param> public EditorNPCChatResponse(NPCChatDialogItemID page, string text) { _page = page; _text = text; }
/// <summary> /// When overridden in the derived class, sets the values read from the Read method. /// </summary> /// <param name="value">The value.</param> /// <param name="page">The page.</param> /// <param name="text">The text.</param> /// <param name="conditionals">The conditionals.</param> /// <param name="actions">The actions.</param> protected override void SetReadValues(byte value, NPCChatDialogItemID page, string text, NPCChatConditionalCollectionBase conditionals, NPCChatResponseActionBase[] actions) { _value = value; _page = page; SetText(text); _actions.Clear(); _actions.AddRange(actions); var c = conditionals as EditorNPCChatConditionalCollection; _conditionals = c ?? new EditorNPCChatConditionalCollection(); }
/// <summary> /// Sets the Page property. /// </summary> /// <param name="page">The new page.</param> public void SetPage(NPCChatDialogItemID page) { if (_page == page) return; _page = page; if (Changed != null) Changed.Raise(this, EventArgs.Empty); }
/// <summary> /// When overridden in the derived class, sets the values read from the Read method. /// </summary> /// <param name="page">The index.</param> /// <param name="title">The title.</param> /// <param name="text">The text.</param> /// <param name="isBranch">The IsBranch value.</param> /// <param name="conditionals">The conditionals.</param> /// <param name="responses">The responses.</param> protected abstract void SetReadValues(NPCChatDialogItemID page, string title, string text, bool isBranch, IEnumerable<NPCChatResponseBase> responses, NPCChatConditionalCollectionBase conditionals);