コード例 #1
0
        /// <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;
        }
コード例 #2
0
ファイル: NPCChatDialogItemID.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// Tries to parse the <see cref="NPCChatDialogItemID"/> from a string.
        /// </summary>
        /// <param name="parser">The <see cref="Parser"/> to use.</param>
        /// <param name="value">The string to parse.</param>
        /// <param name="outValue">If this method returns true, contains the parsed <see cref="NPCChatDialogItemID"/>.</param>
        /// <returns>True if the parsing was successfully; otherwise false.</returns>
        public static bool TryParse(this Parser parser, string value, out NPCChatDialogItemID outValue)
        {
            ushort tmp;
            var    ret = parser.TryParse(value, out tmp);

            outValue = new NPCChatDialogItemID(tmp);
            return(ret);
        }
コード例 #3
0
        /// <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), "Values were already set?");

            _value        = value;
            _page         = page;
            _conditionals = conditionals;
            _actions      = actions;
        }
コード例 #4
0
        /// <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;
        }
コード例 #5
0
ファイル: EditorNPCChatResponse.cs プロジェクト: wtfcolt/game
        /// <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();
        }
コード例 #6
0
ファイル: EditorNPCChatResponse.cs プロジェクト: wtfcolt/game
        /// <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);
            }
        }
コード例 #7
0
        /// <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));
        }
コード例 #8
0
        /// <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();
        }
コード例 #9
0
ファイル: NPCChatDialogItemID.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// Tries to get the value in the <paramref name="dict"/> entry at the given <paramref name="key"/> as a
        /// <see cref="NPCChatDialogItemID"/>.
        /// </summary>
        /// <typeparam name="T">The key Type.</typeparam>
        /// <param name="dict">The <see cref="IDictionary{TKey, TValue}"/>.</param>
        /// <param name="key">The key for the value to get.</param>
        /// <param name="defaultValue">The value to use if the value at the <paramref name="key"/> could not be parsed.</param>
        /// <returns>The value at the given <paramref name="key"/> parsed as an int, or the
        /// <paramref name="defaultValue"/> if the <paramref name="key"/> did not exist in the <paramref name="dict"/>
        /// or the value at the given <paramref name="key"/> could not be parsed.</returns>
        public static NPCChatDialogItemID AsNPCChatDialogItemID <T>(this IDictionary <T, string> dict, T key,
                                                                    NPCChatDialogItemID defaultValue)
        {
            string value;

            if (!dict.TryGetValue(key, out value))
            {
                return(defaultValue);
            }

            NPCChatDialogItemID parsed;

            if (!Parser.Invariant.TryParse(value, out parsed))
            {
                return(defaultValue);
            }

            return(parsed);
        }
コード例 #10
0
        /// <summary>
        /// When overridden in the derived class, gets the NPCChatDialogItemBase for the given page number.
        /// </summary>
        /// <param name="chatDialogItemID">The page number of the NPCChatDialogItemBase to get.</param>
        /// <returns>The NPCChatDialogItemBase for the given <paramref name="chatDialogItemID"/>, or null if
        /// no valid NPCChatDialogItemBase existed for the given <paramref name="chatDialogItemID"/> or if
        /// the <paramref name="chatDialogItemID"/> is equal to
        /// <see cref="NPCChatResponseBase.EndConversationPage"/>.</returns>
        public override NPCChatDialogItemBase GetDialogItem(NPCChatDialogItemID chatDialogItemID)
        {
            if (chatDialogItemID == NPCChatResponseBase.EndConversationPage)
            {
                return(null);
            }

            if (chatDialogItemID < 0 || chatDialogItemID >= _items.Length)
            {
                const string errmsg = "Invalid NPCChatDialogItemBase ID `{0}`.";
                Debug.Fail(string.Format(errmsg, chatDialogItemID));
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat(errmsg, chatDialogItemID);
                }
                return(null);
            }

            return(_items[(int)chatDialogItemID]);
        }
コード例 #11
0
ファイル: NPCChatDialogItemID.cs プロジェクト: wtfcolt/game
 /// <summary>
 /// Reads the <see cref="NPCChatDialogItemID"/> from an IValueReader.
 /// </summary>
 /// <param name="valueReader"><see cref="IValueReader"/> to read the <see cref="NPCChatDialogItemID"/> from.</param>
 /// <param name="name">The unique name of the value to read.</param>
 /// <returns>The <see cref="NPCChatDialogItemID"/> read from the IValueReader.</returns>
 public static NPCChatDialogItemID ReadNPCChatDialogItemID(this IValueReader valueReader, string name)
 {
     return(NPCChatDialogItemID.Read(valueReader, name));
 }
コード例 #12
0
ファイル: NPCChatDialogItemID.cs プロジェクト: wtfcolt/game
 /// <summary>
 /// Reads the <see cref="NPCChatDialogItemID"/> from a <see cref="BitStream"/>.
 /// </summary>
 /// <param name="bitStream"><see cref="BitStream"/> to read the <see cref="NPCChatDialogItemID"/> from.</param>
 /// <returns>The <see cref="NPCChatDialogItemID"/> read from the <see cref="BitStream"/>.</returns>
 public static NPCChatDialogItemID ReadNPCChatDialogItemID(this BitStream bitStream)
 {
     return(NPCChatDialogItemID.Read(bitStream));
 }
コード例 #13
0
ファイル: NPCChatDialogItemID.cs プロジェクト: wtfcolt/game
 /// <summary>
 /// Reads the <see cref="NPCChatDialogItemID"/> from an <see cref="IDataRecord"/>.
 /// </summary>
 /// <param name="r"><see cref="IDataRecord"/> to read the <see cref="NPCChatDialogItemID"/> from.</param>
 /// <param name="name">The name of the field to read the value from.</param>
 /// <returns>The <see cref="NPCChatDialogItemID"/> read from the <see cref="IDataRecord"/>.</returns>
 public static NPCChatDialogItemID GetNPCChatDialogItemID(this IDataRecord r, string name)
 {
     return(NPCChatDialogItemID.Read(r, name));
 }
コード例 #14
0
ファイル: NPCChatDialogItemID.cs プロジェクト: wtfcolt/game
 /// <summary>
 /// Reads the <see cref="NPCChatDialogItemID"/> from an <see cref="IDataRecord"/>.
 /// </summary>
 /// <param name="r"><see cref="IDataRecord"/> to read the <see cref="NPCChatDialogItemID"/> from.</param>
 /// <param name="i">The field index to read.</param>
 /// <returns>The <see cref="NPCChatDialogItemID"/> read from the <see cref="IDataRecord"/>.</returns>
 public static NPCChatDialogItemID GetNPCChatDialogItemID(this IDataRecord r, int i)
 {
     return(NPCChatDialogItemID.Read(r, i));
 }
コード例 #15
0
ファイル: NPCChatDialogItemID.cs プロジェクト: wtfcolt/game
 /// <summary>
 /// Writes a <see cref="NPCChatDialogItemID"/> to a <see cref="IValueWriter"/>.
 /// </summary>
 /// <param name="valueWriter"><see cref="IValueWriter"/> to write to.</param>
 /// <param name="name">Unique name of the <see cref="NPCChatDialogItemID"/> that will be used to distinguish it
 /// from other values when reading.</param>
 /// <param name="value"><see cref="NPCChatDialogItemID"/> to write.</param>
 public static void Write(this IValueWriter valueWriter, string name, NPCChatDialogItemID value)
 {
     value.Write(valueWriter, name);
 }
コード例 #16
0
 /// <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)
 {
 }
コード例 #17
0
ファイル: EditorNPCChatResponse.cs プロジェクト: wtfcolt/game
 /// <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;
 }
コード例 #18
0
 /// <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);
コード例 #19
0
ファイル: NPCChatDialogItemID.cs プロジェクト: wtfcolt/game
 /// <summary>
 /// Writes a <see cref="NPCChatDialogItemID"/> to a <see cref="BitStream"/>.
 /// </summary>
 /// <param name="bitStream"><see cref="BitStream"/> to write to.</param>
 /// <param name="value"><see cref="NPCChatDialogItemID"/> to write.</param>
 public static void Write(this BitStream bitStream, NPCChatDialogItemID value)
 {
     value.Write(bitStream);
 }
コード例 #20
0
ファイル: EditorNPCChatDialog.cs プロジェクト: wtfcolt/game
 /// <summary>
 /// When overridden in the derived class, gets the NPCChatDialogItemBase for the given page number.
 /// </summary>
 /// <param name="chatDialogItemID">The page number of the NPCChatDialogItemBase to get.</param>
 /// <returns>The NPCChatDialogItemBase for the given <paramref name="chatDialogItemID"/>, or null if
 /// no valid NPCChatDialogItemBase existed for the given <paramref name="chatDialogItemID"/> or if
 /// the <paramref name="chatDialogItemID"/> is equal to
 /// <see cref="NPCChatResponseBase.EndConversationPage"/>.</returns>
 public override NPCChatDialogItemBase GetDialogItem(NPCChatDialogItemID chatDialogItemID)
 {
     return(GetDialogItemCasted(chatDialogItemID));
 }
コード例 #21
0
 /// <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);
コード例 #22
0
 /// <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);