Example #1
0
		public static string ReplaceVars(this string command, VarCollection vars)
		{
			bool quoted = false;

			for (int i = 0; i < command.Length; i++)
			{
				if (command[i] == '\"')
					quoted = !quoted;
				if (!quoted && command[i] == '$')
				{
					string vr = string.Empty;
					for (int j = i + 1; j < command.Length && command[j] != ' ' && command[j] != ';' && command[j] != '\n'; j++)
						vr += command[j];

					if (vars.GetVar(vr) != null)
					{
						string value = vars.GetVar(vr);
						command = command.Replace("$" + vr, value);
						i += value.Length;
					}
					else
						command = command.Replace("$" + vr, string.Empty);
				}
			}

			return command;
		}
Example #2
0
 static string indexCheck(VarCollection vars, int index, string label, bool checkChildren)
 {
     for (int i = 0; i < vars.Count; i++)
     {
         if (i == index)
         {
             continue;
         }
         if (vars[i].ID == index)
         {
             return(label + vars[i].ToString() + ".ID");
         }
         if (!label.Contains(",") && vars[i].ContainsDynamicMarker(index))                           // comma ensures only top-level checked
         {
             return(label + vars[i].ToString() + " dynamics");
         }
         if (checkChildren && vars[i].Values != null)
         {
             string check = indexCheck(vars[i].Values, index, label + vars[i].ToString() + ", ", true);
             if (check != "")
             {
                 return(check);
             }
         }
     }
     return("");
 }
Example #3
0
 static void dynamicsFix(VarCollection vars, int oldIndex, int newIndex)
 {
     for (int i = 0; i < vars.Count; i++)
     {
         vars[i].ReplaceDynamicIndex(oldIndex, newIndex);
     }
 }
Example #4
0
        public static void ReadSettings(
            VarCollection vc,
            KeyVal kv,
            Settings currSettings)
        {
            while ((kv = vc.ReadLine()) != null)
            {
                switch (kv.Keyword)
                {
                case "}":                         // all done
                    return;

                case "{":                         // starting out
                    break;

                default:
                    if (currSettings [kv.Keyword] != null)
                    {
                        currSettings[kv.Keyword].Value = kv.Rest;
                        currSettings[kv.Keyword].FireUpdate(kv.Keyword);
                    }
                    break;
                }
            }
        }
Example #5
0
		public ItemInfo(Stream file,VarCollection v):this()
		{
			StreamReader sr = new StreamReader(file);
			VarCollection vars = new VarCollection(sr,v);
			KeyVal line=null;

			while((line=vars.ReadLine())!=null)
			{
				switch(line.Keyword.ToLower())
				{
					case "ground":
						groundImg = line.Rest;
						break;
					case "hand":
						handImg = line.Rest;
						break;
					case "weapon":
						items[line.Rest] = new WeaponDescriptor(line.Rest,vars);
						break;
//					case "item":
//						break;
				}
			}

			sr.Close();
		}
Example #6
0
 public virtual void ParseLine(
     string keyword,
     string line,
     StreamReader sr,
     VarCollection vars)
 {
 }
Example #7
0
        public ItemInfo(Stream file, VarCollection v) : this()
        {
            StreamReader  sr   = new StreamReader(file);
            VarCollection vars = new VarCollection(sr, v);
            KeyVal        line = null;

            while ((line = vars.ReadLine()) != null)
            {
                switch (line.Keyword.ToLower())
                {
                case "ground":
                    groundImg = line.Rest;
                    break;

                case "hand":
                    handImg = line.Rest;
                    break;

                case "weapon":
                    items[line.Rest] = new WeaponDescriptor(line.Rest, vars);
                    break;
//					case "item":
//						break;
                }
            }

            sr.Close();
        }
        static MethodResult RandomValuesInArray(bool isGlobal, VarCollection varCollection, object[] parameters)
        {
            Element array = parameters[0] as Element;
            Element count = parameters[1] as Element;

            return(new MethodResult(null, Element.Part <V_ArraySlice>(Element.Part <V_RandomizedArray>(array), count), CustomMethodType.Value));
        }
        static MethodResult GetMapID(bool isGlobal, VarCollection varCollection, object[] parameters)
        {
            /*
             * All credit to https://us.forums.blizzard.com/en/overwatch/t/workshop-resource-get-the-current-map-name-updated-1-action/
             * Based off code: 5VAQA
             */

            int mapcount = 0;

            for (int i = 0; i < Constants.MapChecks.Length; i++)
            {
                mapcount += Constants.MapChecks[i].Length;
            }

            V_Append prev    = null;
            V_Append current = null;

            for (int s = 0; s < Constants.MapChecks.Length; s++)
            {
                for (int i = 0; i < Constants.MapChecks[s].Length; i++)
                {
                    current = new V_Append()
                    {
                        ParameterValues = new IWorkshopTree[2]
                    };

                    if (prev != null)
                    {
                        current.ParameterValues[0] = prev;
                    }
                    else
                    {
                        current.ParameterValues[0] = new V_EmptyArray();
                    }

                    // Set the map ID
                    current.ParameterValues[1] = new V_Number(Constants.MapChecks[s][i]);
                    prev = current;
                }
            }

            return(new MethodResult(null,
                                    Element.Part <V_IndexOfArrayValue>(current,
                                                                       Element.Part <V_RoundToInteger>(Element.Part <V_Divide>(
                                                                                                           Element.Part <V_RoundToInteger>(
                                                                                                               Element.Part <V_Multiply>(
                                                                                                                   Element.Part <V_DistanceBetween>(
                                                                                                                       Element.Part <V_Vector>(new V_Number(0), new V_Number(0), new V_Number(0)),
                                                                                                                       Element.Part <V_NearestWalkablePosition>(Element.Part <V_Vector>(new V_Number(100), new V_Number(100), new V_Number(100)))
                                                                                                                       ),
                                                                                                                   new V_Number(100)
                                                                                                                   ),
                                                                                                               EnumData.GetEnumValue(Rounding.Down)
                                                                                                               ),
                                                                                                           new V_Number(4)
                                                                                                           ),
                                                                                                       EnumData.GetEnumValue(Rounding.Down))
                                                                       ), CustomMethodType.Value));
        }
Example #10
0
 /// <summary>Initializes a new item</summary>
 /// <param name="parent">The collection the item belongs to</param>
 /// <param name="id">The ID of the definition used</param>
 /// <exception cref="ArgumentOutOfRangeException">No <see cref="ProjectFile.Properties"/> with an ID of <i>id</i> were found</exception>
 public CollectionVar(VarCollection parent, int id)
 {
     if (!parent.isLoading && parent.parentFile.Types.GetIndexByID(id) == -1)
     {
         throw new ArgumentOutOfRangeException("ProjectFile Type definition with specified ID not found");
     }
     _parent = parent;
     _type   = VarType.Collection;
     _id     = id;
 }
Example #11
0
            /// <summary>Initializes a new placeholder item</summary>
            /// <param name="parent">The <see cref="VarCollection"/> containing the item.</param>
            /// <param name="name">The name of the item for identification purposes.</param>
            public ErrorVar(VarCollection parent, string name)
            {
                _parent = parent;
                _type   = VarType.Error;
                bool loading = _parent.isLoading;

                _parent.isLoading = true;
                Name = name;
                _parent.isLoading = loading;
            }
Example #12
0
			/// <summary>Initializes a new item.</summary>
			/// <param name="parent">The <see cref="VarCollection"/> containing the item.</param>
			/// <remarks><see cref="NullTermed"/> defaults to <b>false</b>, <see cref="RawLength"/> defaults to <b>0</b>.</remarks>
			public StringVar(VarCollection parent)
			{
				_parent = parent;
				_type = VarType.String;
				bool loading = _parent.isLoading;
				_parent.isLoading = true;
				RawValue = "";
                _length = "0";
				_parent.isLoading = loading;
			}
Example #13
0
            /// <summary>Initializes a new item.</summary>
            /// <param name="parent">The <see cref="VarCollection"/> containing the item.</param>
            /// <remarks><see cref="RawValue"/> initializes to <b>false</b>.</remarks>
            public BoolVar(VarCollection parent)
            {
                _parent = parent;
                _type   = VarType.Bool;
                bool loading = _parent.isLoading;

                _parent.isLoading = true;
                RawValue          = false;
                _parent.isLoading = loading;
            }
Example #14
0
            /// <summary>Initializes a new item.</summary>
            /// <param name="parent">The <see cref="VarCollection"/> containing the item.</param>
            /// <param name="defaultValue">The starting value of the item</param>
            /// <remarks><see cref="RawValue"/> initializes to <b>false</b>.<br/>
            /// For <see cref="DefaultValue"/> to be set to <b>true</b>, <i>defaultValue</i> must match <see cref="TrueValue"/> or "<b>true</b>" (case-insensitive).  All other inputs will be read as <b>false</b>.</remarks>
            public BoolVar(VarCollection parent, string defaultValue)
            {
                _parent = parent;
                _type   = VarType.Bool;
                bool loading = _parent.isLoading;

                _parent.isLoading = true;
                RawValue          = false;
                DefaultValue      = (defaultValue != null && (defaultValue == TrueValue.ToString() || defaultValue.ToString().ToLower() == "true"));
                _parent.isLoading = loading;
            }
        static MethodResult AngleOfVectorsCom(bool isGlobal, VarCollection varCollection, object[] parameters)
        {
            Element zeroVec = Element.Part <V_Vector>(new V_Number(0), new V_Number(0), new V_Number(0));
            Element a       = (Element)parameters[0];
            Element b       = (Element)parameters[1];
            Element c       = (Element)parameters[2];

            Element ab = Element.Part <V_Vector>
                         (
                Element.Part <V_Subtract>(Element.Part <V_XOf>(b), Element.Part <V_XOf>(a)),
                Element.Part <V_Subtract>(Element.Part <V_YOf>(b), Element.Part <V_YOf>(a)),
                Element.Part <V_Subtract>(Element.Part <V_ZOf>(b), Element.Part <V_ZOf>(a))
                         );
            Element bc = Element.Part <V_Vector>
                         (
                Element.Part <V_Subtract>(Element.Part <V_XOf>(c), Element.Part <V_XOf>(b)),
                Element.Part <V_Subtract>(Element.Part <V_YOf>(c), Element.Part <V_YOf>(b)),
                Element.Part <V_Subtract>(Element.Part <V_ZOf>(c), Element.Part <V_ZOf>(b))
                         );
            Element abVec = Element.Part <V_DistanceBetween>
                            (
                ab,
                zeroVec
                            );
            Element bcVec = Element.Part <V_DistanceBetween>
                            (
                bc,
                zeroVec
                            );
            Element abNorm = Element.Part <V_Vector>
                             (
                Element.Part <V_Divide>(Element.Part <V_XOf>(ab), abVec),
                Element.Part <V_Divide>(Element.Part <V_YOf>(ab), abVec),
                Element.Part <V_Divide>(Element.Part <V_ZOf>(ab), abVec)
                             );
            Element bcNorm = Element.Part <V_Vector>
                             (
                Element.Part <V_Divide>(Element.Part <V_XOf>(bc), bcVec),
                Element.Part <V_Divide>(Element.Part <V_YOf>(bc), bcVec),
                Element.Part <V_Divide>(Element.Part <V_ZOf>(bc), bcVec)
                             );
            Element res = Element.Part <V_Add>
                          (
                Element.Part <V_Add>
                (
                    Element.Part <V_Multiply>(Element.Part <V_XOf>(abNorm), Element.Part <V_XOf>(bcNorm)),
                    Element.Part <V_Multiply>(Element.Part <V_YOf>(abNorm), Element.Part <V_YOf>(bcNorm))
                ),
                Element.Part <V_Multiply>(Element.Part <V_ZOf>(abNorm), Element.Part <V_ZOf>(bcNorm))
                          );

            return(new MethodResult(null, res, CustomMethodType.MultiAction_Value));
        }
Example #16
0
            /// <summary>Initializes a new item.</summary>
            /// <param name="parent">The <see cref="VarCollection"/> containing the item.</param>
            /// <param name="trueValue">The raw value stored in the file for <b>true</b>. Default is <b>1</b>.</param>
            /// <param name="falseValue">The raw value stored in the file for <b>false</b>. Default is <b>0</b>.</param>
            /// <remarks><see cref="RawValue"/> initializes to <b>false</b>.</remarks>
            public BoolVar(VarCollection parent, byte trueValue, byte falseValue)
            {
                _parent = parent;
                _type   = VarType.Bool;
                bool loading = _parent.isLoading;

                _parent.isLoading = true;
                TrueValue         = trueValue;
                FalseValue        = falseValue;
                RawValue          = false;
                _parent.isLoading = loading;
            }
Example #17
0
            /// <summary>Initializes an Undefined item.</summary>
            /// <param name="parent">The <see cref="VarCollection"/> containing the item.</param>
            /// <exception cref="ArgumentNullException"><i>parent</i> is <b>null</b>.</exception>
            internal Var(VarCollection parent)
            {
                _parent = parent;
                if (parent == null)
                {
                    throw new ArgumentNullException("parent cannot be null");
                }
                bool loading = _parent.isLoading;

                _parent.isLoading = true;
                RawValue          = 0;
                _parent.isLoading = loading;
            }
Example #18
0
			/// <summary>Initializes a new item.</summary>
			/// <param name="parent">The <see cref="VarCollection"/> containing the item.</param>
			/// <param name="length">The number of characters in the string including null term if applicable, can also be a dynamic value.</param>
			/// <param name="nullTermed">Whether or not the string is terminated with a null character (<b>\0</b>).</param>
			/// <param name="defaultValue">The starting value of the item.</param>
			/// <param name="encoding">The raw encoding method of the string.</param>
			/// <remarks>Any value except <b>"true"</b> (case-insensitive) for <i>nullTermed</i> is interpreted as <b>false</b>.<br/>
			/// A <b>null</> or empty value for <i>length/> results in the default length of <b>0</b>.</remarks>
			public StringVar(VarCollection parent, string nullTermed, string length, string defaultValue, string encoding)
			{
				_parent = parent;
				_type = VarType.String;
				bool loading = _parent.isLoading;
				_parent.isLoading = true;
				RawValue = "";
				_length = length;
				DefaultValue = defaultValue;
				if (encoding != null && encoding != "") _encoding = Encoding.GetEncoding(encoding);	// mind asplode
				_nullTermed = (nullTermed != null && nullTermed.ToLower() == "true");
				_parent.isLoading = loading;
			}
Example #19
0
            /// <summary>Initializes a blank type definition.</summary>
            /// <param name="parent">The <see cref="VarCollection"/> that contains the item, should always be <see cref="ProjectFile.Types"/>.</param>
            /// <remarks><see cref="ID"/> is initialized to the next available value per <i>parent</i>. <see cref="Values"/> is initalized as empty, <see cref="Name"/> defaults to "NewDefinition".</remarks>
            public DefinitionVar(VarCollection parent)
            {
                _parent = parent;
                _type   = VarType.Definition;
                bool loading = _parent.isLoading;

                _parent.isLoading = true;
                Name    = "NewDefinition";
                Values  = new VarCollection(this);
                _length = "-1";
                _id     = _parent.parentFile._nextID;
                _parent.parentFile._nextID++;
                _parent.isLoading = loading;
            }
Example #20
0
 /// <summary>Initializes a new item.</summary>
 /// <param name="parent">The <see cref="VarCollection"/> containing the item.</param>
 /// <param name="minValue">The lower bound of the item.</param>
 /// <param name="maxValue">The upper bound of the item.</param>
 /// <param name="defaultValue">The starting value of the item</param>
 /// <exception cref="ArgumentOutOfRangeException"><i>minValue</i>, <i>maxValue</i> or <i>defaultValue</i> fall outside the range of <see cref="int"/>.</exception>
 /// <remarks><see cref="RawValue"/> initializes to <b>0</b>.<br>
 /// If <i>minValue</i> or <i>maxValue</i> are empty or <b>null</b>, they default to the limits of <see cref="int"/>.</remarks>
 public IntVar(VarCollection parent, string minValue, string maxValue, string defaultValue) : base(parent, defaultValue)
 {
     if (minValue != null && minValue != "")
     {
         _minValue = int.Parse(minValue);
     }
     if (maxValue != null && maxValue != "")
     {
         _maxValue = int.Parse(maxValue);
     }
     if (defaultValue != null)
     {
         int.Parse(defaultValue);
     }
     _type = VarType.Int;
 }
Example #21
0
 /// <summary>Initializes a new item.</summary>
 /// <param name="parent">The <see cref="VarCollection"/> containing the item.</param>
 /// <param name="minValue">The lower bound of the item.</param>
 /// <param name="maxValue">The upper bound of the item.</param>
 /// <param name="defaultValue">The starting value of the item</param>
 /// <exception cref="ArgumentOutOfRangeException"><i>minValue</i>, <i>maxValue</i> or <i>defaultValue</i> fall outside <b>±1.8e308</b> (approx).</exception>
 /// <remarks><see cref="RawValue"/> initializes to <b>0</b>.</remarks>
 public DoubleVar(VarCollection parent, string minValue, string maxValue, string defaultValue) : base(parent, defaultValue)
 {
     if (minValue != null && minValue != "")
     {
         _minValue = double.Parse(minValue);
     }
     if (maxValue != null && maxValue != "")
     {
         _maxValue = double.Parse(maxValue);
     }
     if (defaultValue != null)
     {
         double.Parse(defaultValue);
     }
     _type = VarType.Double;
 }
Example #22
0
 /// <summary>Initializes a new item.</summary>
 /// <param name="parent">The <see cref="VarCollection"/> containing the item.</param>
 /// <param name="minValue">The lower bound of the item.</param>
 /// <param name="maxValue">The upper bound of the item.</param>
 /// <param name="defaultValue">The starting value of the item</param>
 /// <exception cref="ArgumentOutOfRangeException"><i>minValue</i>, <i>maxValue</i> or <i>defaultValue</i> fall outside the range of <see cref="ulong"/>.</exception>
 /// <remarks><see cref="RawValue"/> initializes to <b>0</b>.<br>
 /// If <i>minValue</i> or <i>maxValue</i> are empty or <b>null</b>, they default to the limits of <see cref="ulong"/>.</remarks>
 public ULongVar(VarCollection parent, string minValue, string maxValue, string defaultValue) : base(parent, defaultValue)
 {
     if (minValue != null && minValue != "")
     {
         _minValue = ulong.Parse(minValue);
     }
     if (maxValue != null && maxValue != "")
     {
         _maxValue = ulong.Parse(maxValue);
     }
     if (defaultValue != null)
     {
         ulong.Parse(defaultValue);
     }
     _type = VarType.ULong;
 }
Example #23
0
 /// <summary>Initializes a new item.</summary>
 /// <param name="parent">The <see cref="VarCollection"/> containing the item.</param>
 /// <param name="minValue">The lower bound of the item.</param>
 /// <param name="maxValue">The upper bound of the item.</param>
 /// <param name="defaultValue">The starting value of the item</param>
 /// <exception cref="ArgumentOutOfRangeException"><i>minValue</i>, <i>maxValue</i> or <i>defaultValue</i> fall outside <b>-128 to 127</b>.</exception>
 /// <remarks><see cref="RawValue"/> initializes to <b>0</b>.<br>
 /// If <i>minValue</i> or <i>maxValue</i> are empty or <b>null</b>, they default to <b>-128</b> and <b>127</b>, respectively.</remarks>
 public SByteVar(VarCollection parent, string minValue, string maxValue, string defaultValue) : base(parent, defaultValue)
 {
     if (minValue != null && minValue != "")
     {
         _minValue = sbyte.Parse(minValue);
     }
     if (maxValue != null && maxValue != "")
     {
         _maxValue = sbyte.Parse(maxValue);
     }
     if (defaultValue != null)
     {
         sbyte.Parse(defaultValue);
     }
     _type = VarType.SByte;
 }
Example #24
0
 /// <summary>Initializes a new item.</summary>
 /// <param name="parent">The collection the item belongs to.</param>
 /// <param name="id">The ID of the definition used.</param>
 /// <exception cref="ArgumentNullException"><i>id</i> is <b>null</b>.</exception>
 /// <exception cref="FormatException"><i>id</i> is not a valid integer value.</exception>
 /// <exception cref="OverflowException"><i>id</i> represents a number outside the range of Int32.</exception>
 /// <exception cref="ArgumentOutOfRangeException">No <see cref="ProjectFile.Properties"/> with an ID of <i>id</i> were found.</exception>
 public CollectionVar(VarCollection parent, string id)
 {
     if (id == "" || id == null)
     {
         throw new ArgumentNullException("Collection items require 'id' attribute", "id");
     }
     try { _id = int.Parse(id); }
     catch (FormatException x) { throw new FormatException("'id' is not a valid integer", x); }
     catch (OverflowException x) { throw new OverflowException("'id' must be lower than " + int.MaxValue, x); }
     // TODO: redo the read process so the IDs are stored, but the types aren't checked until after the entire thing is read
     // projects have to be written with child definitions at the top. IDs can be whatever, but new child Collections must be inserted above whatever parent wants to use it
     // ie: if I have a Square, and I decide that I want to make it out of Lines, the new Line definition must be inserted before Square in _parent
     if (!parent.isLoading && parent.parentFile.Types.GetIndexByID(_id) == -1)
     {
         throw new ArgumentOutOfRangeException("ProjectFile Type definition with specified ID not found");
     }
     _parent = parent;
     _type   = VarType.Collection;
 }
Example #25
0
            /// <summary>Initializes a new item.</summary>
            /// <param name="parent">The <see cref="VarCollection"/> containing the item.</param>
            /// <param name="trueValue">The raw byte value stored in the file for <b>true</b>. Accepted values are <b>-1</b> to <b>255</b>. Default is <b>1</b>.</param>
            /// <param name="falseValue">The raw byte value stored in the file for <b>false</b>. Accepted values are <b>-1</b> to <b>255</b>. Default is <b>0</b>.</param>
            /// <param name="defaultValue">The starting value of the item</param>
            /// <exception cref="OverflowException"><i>trueValue</i> or <i>falseValue</i> is less than <b>-1</b> or greater than <b>255</b>.</exception>
            /// <remarks><see cref="RawValue"/> initializes to <b>false</b>.<br/>
            /// If <i>trueValue</i> or <i>falseValue</i> are <b>null</b> or cannot parsed, default values are used.<br/>
            /// Values of <b>-1</b> are converted to <b>255</b>.<br/>
            /// For <see cref="DefaultValue"/> to be set to <b>true</b>, <i>defaultValue</i> must match <see cref="TrueValue"/> or "<b>true</b>" (case-insensitive).  All other inputs will be read as <b>false</b>.</remarks>
            public BoolVar(VarCollection parent, string trueValue, string falseValue, string defaultValue)
            {
                _parent = parent;
                _type   = VarType.Bool;
                bool loading = _parent.isLoading;

                _parent.isLoading = true;
                try { TrueValue = byte.Parse(trueValue); }
                catch (FormatException) { /* do nothing */ }
                catch (ArgumentNullException) { /* do nothing */ }
                catch (OverflowException x)
                {
                    if (trueValue == "-1")
                    {
                        TrueValue = 255;
                    }
                    else
                    {
                        throw x;
                    }
                }
                try { FalseValue = byte.Parse(falseValue); }
                catch (FormatException) { /* do nothing */ }
                catch (ArgumentNullException) { /* do nothing */ }
                catch (OverflowException x)
                {
                    if (falseValue == "-1")
                    {
                        FalseValue = 255;
                    }
                    else
                    {
                        throw x;
                    }
                }
                RawValue          = false;
                DefaultValue      = (defaultValue != null && (defaultValue == TrueValue.ToString() || defaultValue.ToString().ToLower() == "true"));
                _parent.isLoading = loading;
            }
Example #26
0
            /// <summary>Initializes a new type definition.</summary>
            /// <param name="parent">The <see cref="VarCollection"/> that contains the item, should always be <see cref="Types"/>.</param>
            /// <param name="name">The name of the type.</param>
            /// <param name="count">The total number of items in the definition.</param>
            /// <param name="id">The ID number to be used with dynamics.</param>
            /// <exception cref="ArgumentNullException"><i>name</i>, <i>count</i> or <i>id</i> are <b>null</b> or empty.</exception>
            /// <exception cref="ArgumentException"><i>count</i> is not a constant.</exception>
            /// <remarks>Values is *not* populated, only the initial Capacity is set</remarks>
            public DefinitionVar(VarCollection parent, string name, string count, string id)
            {
                if (name == "" || name == null || id == "" || id == null || count == "" || count == null)
                {
                    throw new ArgumentNullException("Definition elements require 'name', 'id' and 'count' attributes", ((name == "" || name == null) ? "name" : ((id == "" || id == null)? "id" : "count")));
                }
                if (isDynamicText(count) || Equation.Evaluate(count) != count)
                {
                    throw new ArgumentException("'count' attribute must be constant", "count");
                }
                _parent = parent;
                _type   = VarType.Definition;
                bool loading = _parent.isLoading;

                _parent.isLoading = true;
                Name = name;
                try { Values = new VarCollection(this, int.Parse(count)); }
                catch (FormatException x) { throw new FormatException("'count' is not a valid integer", x); }
                catch (OverflowException x) { throw new ArgumentOutOfRangeException("'count' must be between zero and " + int.MaxValue, x); }
                try { _id = int.Parse(id); }
                catch (FormatException x) { throw new FormatException("'id' is not a valid integer", x); }
                catch (OverflowException x) { throw new OverflowException("'id' must be lower than " + int.MaxValue, x); }
                _parent.isLoading = loading;
            }
Example #27
0
		public virtual void ParseLine(string keyword, string line, StreamReader sr, VarCollection vars) { }
Example #28
0
 /// <summary>Initializes a new item.</summary>
 /// <param name="parent">The <see cref="VarCollection"/> containing the item.</param>
 /// <remarks><see cref="RawValue"/> initializes to <b>0</b>.</remarks>
 public DoubleVar(VarCollection parent) : base(parent)
 {
     _type = VarType.Double;
 }
Example #29
0
 /// <summary>Initializes a new item.</summary>
 /// <param name="parent">The <see cref="VarCollection"/> containing the item.</param>
 /// <remarks><see cref="RawValue"/> initializes to <b>0</b>.</remarks>
 public UShortVar(VarCollection parent) : base(parent)
 {
     _type = VarType.UShort;
 }
Example #30
0
		Dictionary<string, string> ServerAliases { get; set; } // Aliases set by the server

		void SetupVars()
		{
			#region Local
			Info = new VarCollection();
			Info.SetMember("Version", Quake2.Version);
			Info.SetMember("CurrentServer", null);

			UserVars = new Dictionary<string, VarCollection>
			           	{
			           		{"User", new VarCollection()},
							{"Net", new VarCollection()}
			           	};

			UserVars["User"].SetMember("Spectator", false);
			UserVars["User"].SetMember("Name","Player");
			UserVars["User"].SetMember("Password", string.Empty);
			UserVars["User"].SetMember("Hand", 0);
			UserVars["User"].SetMember("Fov", 90);

			
			UserVars["Net"].SetMember("PacketDup", 0);
			UserVars["Net"].SetMember("FlushSendBufferTime", 10);
			#endregion

			#region Server
			ServerAliases = new Dictionary<string, string>();
			ServerVars = new VarCollection
			{
				{"version", Info.GetMember("Version")},

				{"gl_driver", "opengl32"},
				{"cl_anglespeedkey", 1.5},
				{"cl_maxfps", 100},

				{"timescale", 1.0},
				{"cl_pitchspeed", 150},

				// UserInfo
				{"password", UserVars["User"].GetMember("Password")},
				{"spectator", new MapBoolToInt((Variable)UserVars["User"].GetMember("Spectator"))},
				{"name", UserVars["User"].GetMember("Name")},
				{"skin", "male/cop"},
				{"rate", 25000},
				{"msg", 1},
				{"hand", UserVars["User"].GetMember("Hand")},
				{"fov", 90},
				{"gender", "male"}
			};

			// UserInfo
			UserInfo = new UserInfo();
			UserInfo.UseVar(ServerVars.GetVar("password"));
			UserInfo.UseVar(ServerVars.GetVar("spectator"));
			UserInfo.UseVar(ServerVars.GetVar("name"));
			UserInfo.UseVar(ServerVars.GetVar("skin"));
			UserInfo.UseVar(ServerVars.GetVar("rate"));
			UserInfo.UseVar(ServerVars.GetVar("msg"));
			UserInfo.UseVar(ServerVars.GetVar("hand"));
			UserInfo.UseVar(ServerVars.GetVar("fov"));
			UserInfo.UseVar(ServerVars.GetVar("gender"));

			UserInfo.OnValueChanged += (s, e) => UserInfoModified = true;
			#endregion
		}
Example #31
0
 /// <summary>Initializes a new item.</summary>
 /// <param name="parent">The <see cref="VarCollection"/> containing the item.</param>
 /// <remarks><see cref="RawValue"/> initializes to <b>0</b>.</remarks>
 public ULongVar(VarCollection parent) : base(parent)
 {
     _type = VarType.ULong;
 }
Example #32
0
 /// <summary>Initializes a new item</summary>
 /// <param name="parent">The collection the item belongs to</param>
 /// <remarks>ID must be set manually</remarks>
 internal CollectionVar(VarCollection parent)
 {
     _parent = parent;
     _type   = VarType.Collection;
 }
Example #33
0
 /// <summary>
 /// 既存の XML 要素から SettingKey インスタンスを作成します。
 /// </summary>
 /// <param name="elem">
 /// この SettingKey の元となる System.Xml.XmlElement を指定します。
 /// parent の OwnerDocument にはxmlns:key が設定されていなければなりません。
 /// </param>
 public SettingKey(System.Xml.XmlElement elem)
 {
     this.elem = elem;
     this.vars = new VarCollection(this);
 }
Example #34
0
		protected IXCTileset(string name, StreamReader sr, VarCollection vars)
			: this(name)
		{
			while (sr.Peek() != -1)
			{
				string line = VarCollection.ReadLine(sr, vars);

				if (line == "end" || line == "END")
					return;

				int idx = line.IndexOf(':');

				string keyword = line.Substring(0, idx);
				string keywordLow = keyword.ToLower();

				string rest = line.Substring(idx + 1);

				switch (keywordLow)
				{
					case "palette":
						if (rest.ToLower() == "ufo")
							myPal = Palette.UFOBattle;
						else if (rest.ToLower() == "tftd")
							myPal = Palette.TFTDBattle;
						else
							myPal = Palette.GetPalette(rest);
						break;
					case "dll":
						string dllName = rest.Substring(rest.LastIndexOf(@"\") + 1);
						Console.WriteLine(name + " is in dll " + dllName);
						break;
					case "rootpath":
						rootPath = @rest;
						break;
					case "rmppath":
						rmpPath = @rest;
						break;
					case "basestyle":
						baseStyle = true;
						break;
					case "ground":
						groundMaps = rest.Split(' ');
						break;
					case "size":
						string[] dim = rest.Split(',');
						int rows = int.Parse(dim[0]);
						int cols = int.Parse(dim[1]);
						int height = int.Parse(dim[2]);

						mapSize = new MapSize(rows, cols, height);
						break;
					case "landmap":
						underwater = false;
						break;
					case "depth":
						mapDepth = int.Parse(rest);
						break;
					case "blankpath":
						blankPath = @rest;
						break;
					case "scang":
						scanFile = @rest;
						break;
					case "loftemp":
						loftFile = @rest;
						break;
					default:
						{
							//user-defined keyword
							ParseLine(keywordLow, rest, sr, vars);
							break;
						}
				}
			}
		}
Example #35
0
 /// <summary>Initializes a new item.</summary>
 /// <param name="parent">The <see cref="VarCollection"/> containing the item.</param>
 /// <remarks><see cref="RawValue"/> initializes to <b>0</b>.</remarks>
 public SingleVar(VarCollection parent) : base(parent)
 {
     _type = VarType.Single;
 }
Example #36
0
		public virtual void Save(StreamWriter sw, VarCollection vars) { }