Beispiel #1
0
        /// <summary>
        /// Reads the <see cref="BackgroundImage"/> from an <see cref="IValueReader"/>.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read from.</param>
        protected override void Read(IValueReader reader)
        {
            base.Read(reader);

            HorizontalLayout = reader.ReadEnum <BackgroundLayerLayout>(_horizontalLayoutKey);
            VerticalLayout   = reader.ReadEnum <BackgroundLayerLayout>(_verticalLayoutKey);
        }
Beispiel #2
0
        /// <summary>
        /// Reads the items order for a <see cref="ToolBar"/>.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read from.</param>
        /// <returns>The <see cref="KeyValuePair{T,U}"/> where the key is the <see cref="ToolBarVisibility"/> and the value
        /// is an ordered list of the control names.</returns>
        static KeyValuePair <ToolBarVisibility, IEnumerable <string> > ReadToolBarItems(IValueReader reader)
        {
            var kvpKey   = reader.ReadEnum <ToolBarVisibility>(_toolBarItemsKeyName);
            var kvpValue = reader.ReadMany(_toolBarItemsValueName, (r, name) => r.ReadString(name));

            return(new KeyValuePair <ToolBarVisibility, IEnumerable <string> >(kvpKey, kvpValue));
        }
        /// <summary>
        /// Reads a <see cref="KeyValuePair{Key, Value}"/>.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read from.</param>
        /// <returns>The read <see cref="KeyValuePair{Key, Value}"/>.</returns>
        static KeyValuePair <StatType, Int32> ReadValueHandler(IValueReader reader)
        {
            var key   = reader.ReadEnum <StatType>(_keyKeyName);
            var value = (Int32)reader.ReadShort(_valueKeyName);

            return(new KeyValuePair <StatType, Int32>(key, value));
        }
Beispiel #4
0
        /// <summary>
        /// Reads the state of the object from an <see cref="IValueReader"/>. Values should be read in the exact
        /// same order as they were written.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param>
        public void ReadState(IValueReader reader)
        {
            // Read the primary values
            Name            = reader.ReadString(_nameKeyName);
            BlendMode       = reader.ReadEnum <BlendMode>(_blendModeKeyName);
            Budget          = reader.ReadInt(_budgetKeyName);
            EmitterLife     = reader.ReadInt(_emitterLifeKeyName);
            ParticleLife    = reader.ReadVariableInt(_particleLifeKeyName);
            Origin          = reader.ReadVector2(_originKeyName);
            ReleaseAmount   = reader.ReadVariableUShort(_releaseAmountKeyName);
            ReleaseColor    = reader.ReadVariableColor(_releaseColorKeyName);
            ReleaseRate     = reader.ReadVariableUShort(_releaseRateKeyName);
            ReleaseRotation = reader.ReadVariableFloat(_releaseRotationKeyName);
            ReleaseScale    = reader.ReadVariableFloat(_releaseScaleKeyName);
            ReleaseSpeed    = reader.ReadVariableFloat(_releaseSpeedKeyName);
            Sprite.SetGrh(reader.ReadGrhIndex(_grhIndexKeyName));

            // Read the custom values
            var customValuesReader = reader.ReadNode(_customValuesNodeName);

            ReadCustomValues(customValuesReader);

            // Read the modifier collection
            ParticleModifiers.Read(_particleModifiersNodeName, reader);
            EmitterModifiers.Read(_emitterModifiersNodeName, reader);
        }
Beispiel #5
0
            /// <summary>
            /// Reads a <see cref="QuickBarSlotValues"/> from an <see cref="IValueReader"/>.
            /// </summary>
            /// <param name="r">The <see cref="IValueReader"/> to read the values from.</param>
            /// <returns>The <see cref="QuickBarSlotValues"/> read from the <paramref name="r"/>.</returns>
            public static QuickBarSlotValues Read(IValueReader r)
            {
                var slot  = r.ReadByte("Slot");
                var type  = r.ReadEnum <QuickBarItemType>("Type");
                var value = r.ReadInt("Value");

                return(new QuickBarSlotValues(slot, type, value));
            }
 /// <summary>
 /// Reads an <see cref="Stat{StatType}"/> from an <see cref="IValueReader"/>.
 /// </summary>
 /// <typeparam name="TStatType">The type of the stat.</typeparam>
 /// <param name="reader"><see cref="IValueReader"/> to read from.</param>
 /// <param name="name">The unique name of the value to read.</param>
 /// <returns>The <see cref="Stat{TStatType}"/> read from the <paramref name="reader"/>.</returns>
 public static Stat <TStatType> ReadStat <TStatType>(this IValueReader reader, string name)
     where TStatType : struct, IComparable, IConvertible, IFormattable
 {
     if (reader.SupportsNodes)
     {
         reader = reader.ReadNode(name);
         var statType = reader.ReadEnum <TStatType>("StatType");
         var value    = reader.ReadStatValueType("Value");
         return(new Stat <TStatType>(statType, value));
     }
     else
     {
         var statType = reader.ReadEnum <TStatType>(name + "_StatType");
         var value    = reader.ReadStatValueType(name + "_Value");
         return(new Stat <TStatType>(statType, value));
     }
 }
 /// <summary>
 /// When overridden in the derived class, reads all custom state values from the <paramref name="reader"/>.
 /// </summary>
 /// <param name="reader">The <see cref="IValueReader"/> to read the state values from.</param>
 protected override void ReadCustomValues(IValueReader reader)
 {
     Closed        = reader.ReadBool(_closedKeyName);
     Scale         = reader.ReadFloat(_scaleKeyName);
     Rotation      = reader.ReadFloat(_rotationKeyName);
     PolygonOrigin = reader.ReadEnum <PolygonOrigin>(_polygonOriginKeyName);
     Points.Read(_pointsNodeName, reader);
 }
Beispiel #8
0
        /// <summary>
        /// Reads the <see cref="BackgroundImage"/> from an <see cref="IValueReader"/>.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read from.</param>
        protected virtual void Read(IValueReader reader)
        {
            Name      = reader.ReadString(_valueKeyName);
            Alignment = reader.ReadEnum <Alignment>(_valueKeyAlignment);
            Color     = reader.ReadColor(_valueKeyColor);
            Depth     = reader.ReadFloat(_valueKeyDepth);
            Offset    = reader.ReadVector2(_valueKeyOffset);
            var grhIndex = reader.ReadGrhIndex(_valueKeyGrhIndex);

            _sprite = new Grh(grhIndex, AnimType.Loop, Map.GetTime());
        }
        void Read(IValueReader r)
        {
            var position = r.ReadVector2(_positionValueKey);
            var size     = r.ReadVector2(_sizeValueKey);

            IsPlatform       = r.ReadBool(_isPlatformValueKey);
            BoundGrhIndex    = r.ReadGrhIndex(_boundGrhIndexValueKey);
            DirectionalBlock = r.ReadEnum <Direction>(_directionBlockValueKey);

            SetPositionRaw(position);
            SetSizeRaw(size);
        }
Beispiel #10
0
            /// <summary>
            /// Reads a <see cref="QuickBarSlotValues"/> from an <see cref="IValueReader"/>.
            /// </summary>
            /// <param name="r">The <see cref="IValueReader"/> to read the values from.</param>
            /// <returns>The <see cref="QuickBarSlotValues"/> read from the <paramref name="r"/>.</returns>
            public static QuickBarSlotValues Read(IValueReader r)
            {
                var slot = r.ReadByte("Slot");
                var type = r.ReadEnum<QuickBarItemType>("Type");
                var value = r.ReadInt("Value");

                return new QuickBarSlotValues(slot, type, value);
            }
Beispiel #11
0
        /// <summary>
        /// Reads the state of the object from an <see cref="IValueReader"/>. Values should be read in the exact
        /// same order as they were written.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param>
        public void ReadState(IValueReader reader)
        {
            // Read the primary values
            Name = reader.ReadString(_nameKeyName);
            BlendMode = reader.ReadEnum<BlendMode>(_blendModeKeyName);
            Budget = reader.ReadInt(_budgetKeyName);
            EmitterLife = reader.ReadInt(_emitterLifeKeyName);
            ParticleLife = reader.ReadVariableInt(_particleLifeKeyName);
            Origin = reader.ReadVector2(_originKeyName);
            ReleaseAmount = reader.ReadVariableUShort(_releaseAmountKeyName);
            ReleaseColor = reader.ReadVariableColor(_releaseColorKeyName);
            ReleaseRate = reader.ReadVariableUShort(_releaseRateKeyName);
            ReleaseRotation = reader.ReadVariableFloat(_releaseRotationKeyName);
            ReleaseScale = reader.ReadVariableFloat(_releaseScaleKeyName);
            ReleaseSpeed = reader.ReadVariableFloat(_releaseSpeedKeyName);
            Sprite.SetGrh(reader.ReadGrhIndex(_grhIndexKeyName));

            // Read the custom values
            var customValuesReader = reader.ReadNode(_customValuesNodeName);
            ReadCustomValues(customValuesReader);

            // Read the modifier collection
            ParticleModifiers.Read(_particleModifiersNodeName, reader);
            EmitterModifiers.Read(_emitterModifiersNodeName, reader);
        }
 /// <summary>
 /// When overridden in the derived class, reads a value with the specified name from an IValueReader.
 /// </summary>
 /// <param name="name">Name of the value.</param>
 /// <param name="reader">IValueReader to read from.</param>
 /// <returns>Value read from the IValueReader.</returns>
 protected override MapRenderLayer Read(string name, IValueReader reader)
 {
     return(reader.ReadEnum <MapRenderLayer>(name));
 }
Beispiel #13
0
        /// <summary>
        /// Reads the items order for a <see cref="ToolBar"/>.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read from.</param>
        /// <returns>The <see cref="KeyValuePair{T,U}"/> where the key is the <see cref="ToolBarVisibility"/> and the value
        /// is an ordered list of the control names.</returns>
        static KeyValuePair<ToolBarVisibility, IEnumerable<string>> ReadToolBarItems(IValueReader reader)
        {
            var kvpKey = reader.ReadEnum<ToolBarVisibility>(_toolBarItemsKeyName);
            var kvpValue = reader.ReadMany(_toolBarItemsValueName, (r, name) => r.ReadString(name));

            return new KeyValuePair<ToolBarVisibility, IEnumerable<string>>(kvpKey, kvpValue);
        }
Beispiel #14
0
 /// <summary>
 /// When overridden in the derived class, reads a value with the specified name from an IValueReader.
 /// </summary>
 /// <param name="name">Name of the value.</param>
 /// <param name="reader">IValueReader to read from.</param>
 /// <returns>Value read from the IValueReader.</returns>
 protected override Alignment Read(string name, IValueReader reader)
 {
     return(reader.ReadEnum <Alignment>(name));
 }
Beispiel #15
0
        /// <summary>
        /// Reads the <see cref="BackgroundImage"/> from an <see cref="IValueReader"/>.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read from.</param>
        protected virtual void Read(IValueReader reader)
        {
            Name = reader.ReadString(_valueKeyName);
            Alignment = reader.ReadEnum<Alignment>(_valueKeyAlignment);
            Color = reader.ReadColor(_valueKeyColor);
            Depth = reader.ReadFloat(_valueKeyDepth);
            Offset = reader.ReadVector2(_valueKeyOffset);
            var grhIndex = reader.ReadGrhIndex(_valueKeyGrhIndex);

            _sprite = new Grh(grhIndex, AnimType.Loop, Map.GetTime());
        }
Beispiel #16
0
 /// <summary>
 /// When overridden in the derived class, reads a value with the specified name from an IValueReader.
 /// </summary>
 /// <param name="name">Name of the value.</param>
 /// <param name="reader">IValueReader to read from.</param>
 /// <returns>Value read from the IValueReader.</returns>
 protected override Direction Read(string name, IValueReader reader)
 {
     return(reader.ReadEnum <Direction>(name));
 }
 /// <summary>
 /// When overridden in the derived class, reads a value with the specified name from an IValueReader.
 /// </summary>
 /// <param name="name">Name of the value.</param>
 /// <param name="reader">IValueReader to read from.</param>
 /// <returns>Value read from the IValueReader.</returns>
 protected override SpriteEffects Read(string name, IValueReader reader)
 {
     return(reader.ReadEnum <SpriteEffects>(name));
 }
Beispiel #18
0
        /// <summary>
        /// Reads the <see cref="BackgroundImage"/> from an <see cref="IValueReader"/>.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read from.</param>
        protected override void Read(IValueReader reader)
        {
            base.Read(reader);

            HorizontalLayout = reader.ReadEnum<BackgroundLayerLayout>(_horizontalLayoutKey);
            VerticalLayout = reader.ReadEnum<BackgroundLayerLayout>(_verticalLayoutKey);
        }
Beispiel #19
0
 /// <summary>
 /// When overridden in the derived class, reads a value with the specified name from an IValueReader.
 /// </summary>
 /// <param name="name">Name of the value.</param>
 /// <param name="reader">IValueReader to read from.</param>
 /// <returns>Value read from the IValueReader.</returns>
 protected override Emoticon Read(string name, IValueReader reader)
 {
     return(reader.ReadEnum <Emoticon>(name));
 }
Beispiel #20
0
 /// <summary>
 /// When overridden in the derived class, reads a value with the specified name from an IValueReader.
 /// </summary>
 /// <param name="name">Name of the value.</param>
 /// <param name="reader">IValueReader to read from.</param>
 /// <returns>Value read from the IValueReader.</returns>
 protected override WeaponType Read(string name, IValueReader reader)
 {
     return(reader.ReadEnum <WeaponType>(name));
 }
Beispiel #21
0
 /// <summary>
 /// When overridden in the derived class, reads all custom state values from the <paramref name="reader"/>.
 /// </summary>
 /// <param name="reader">The <see cref="IValueReader"/> to read the state values from.</param>
 protected override void ReadCustomValues(IValueReader reader)
 {
     Closed = reader.ReadBool(_closedKeyName);
     Scale = reader.ReadFloat(_scaleKeyName);
     Rotation = reader.ReadFloat(_rotationKeyName);
     PolygonOrigin = reader.ReadEnum<PolygonOrigin>(_polygonOriginKeyName);
     Points.Read(_pointsNodeName, reader);
 }
Beispiel #22
0
 public static BlendMode ReadBlendMode(IValueReader reader, string name)
 {
     return(reader.ReadEnum <BlendMode>(name));
 }
Beispiel #23
0
 /// <summary>
 /// When overridden in the derived class, reads a value with the specified name from an IValueReader.
 /// </summary>
 /// <param name="name">Name of the value.</param>
 /// <param name="reader">IValueReader to read from.</param>
 /// <returns>Value read from the IValueReader.</returns>
 protected override ItemType Read(string name, IValueReader reader)
 {
     return(reader.ReadEnum <ItemType>(name));
 }
Beispiel #24
0
        void Read(IValueReader r)
        {
            var position = r.ReadVector2(_positionValueKey);
            var size = r.ReadVector2(_sizeValueKey);
            IsPlatform = r.ReadBool(_isPlatformValueKey);
            BoundGrhIndex = r.ReadGrhIndex(_boundGrhIndexValueKey);
            DirectionalBlock = r.ReadEnum<Direction>(_directionBlockValueKey);

            SetPositionRaw(position);
            SetSizeRaw(size);
        }
Beispiel #25
0
 /// <summary>
 /// Reads an Enum of type <typeparamref name="T"/>. Whether to use the Enum's underlying integer value or the
 /// name of the Enum value is determined from the <see cref="IValueReader.UseEnumNames"/> property.
 /// </summary>
 /// <typeparam name="T">The Type of Enum.</typeparam>
 /// <param name="name">Unique name of the value to read.</param>
 /// <returns>Value read from the reader.</returns>
 public T ReadEnum <T>(string name) where T : struct, IComparable, IConvertible, IFormattable
 {
     return(_reader.ReadEnum <T>(name));
 }