Beispiel #1
0
 public void fromString(String str)
 {
     String[] subStrs = str.Split(SEPS);
     if (subStrs.Length == 4)
     {
         NumberParser.TryParse(subStrs[0], out left);
         NumberParser.TryParse(subStrs[1], out top);
         NumberParser.TryParse(subStrs[2], out width);
         NumberParser.TryParse(subStrs[3], out height);
     }
 }
        public DateTime getValue(String name, DateTime defaultVal)
        {
            DateTime retVal;
            String   strVal;

            if (!configValues.TryGetValue(name, out strVal) || !NumberParser.TryParse(strVal, out retVal))
            {
                retVal = defaultVal;
                setValue(name, defaultVal);
            }
            return(retVal);
        }
        private float readRestitution(XmlReader textReader)
        {
            float result = 0.0f;

            while (!(textReader.Name == RESTITUTION && textReader.NodeType == XmlNodeType.EndElement) && textReader.Read())
            {
                if (textReader.NodeType == XmlNodeType.Text)
                {
                    NumberParser.TryParse(textReader.Value, out result);
                }
            }
            return(result);
        }
        private float readStaticFriction(XmlReader textReader)
        {
            float result = 0.0f;

            while (!(textReader.Name == STATIC_FRICTION && textReader.NodeType == XmlNodeType.EndElement) && textReader.Read())
            {
                if (textReader.NodeType == XmlNodeType.Text)
                {
                    NumberParser.TryParse(textReader.Value, out result);
                }
            }
            return(result);
        }
        public double getValue(String name, double defaultVal)
        {
            String strVal;

            if (configValues.TryGetValue(name, out strVal))
            {
                double result;
                bool   success = NumberParser.TryParse(strVal, out result);
                if (success)
                {
                    return(result);
                }
            }
            setValue(name, defaultVal);
            return(defaultVal);
        }
Beispiel #6
0
        static public bool parseString(String value, out int width, out int height)
        {
            String[] nums    = value.Split(SEPS);
            bool     success = false;

            if (nums.Length == 2)
            {
                success  = NumberParser.TryParse(nums[0], out width);
                success &= NumberParser.TryParse(nums[1], out height);
            }
            else
            {
                width  = 0;
                height = 0;
            }
            return(success);
        }
Beispiel #7
0
        static public bool parseString(String value, out float x, out float y)
        {
            String[] nums    = value.Split(SEPS);
            bool     success = false;

            if (nums.Length == 2)
            {
                success  = NumberParser.TryParse(nums[0], out x);
                success &= NumberParser.TryParse(nums[1], out y);
            }
            else
            {
                x = 0f;
                y = 0f;
            }
            return(success);
        }
Beispiel #8
0
        /// <summary>
        /// Parse a string and set the value.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="r"></param>
        /// <param name="g"></param>
        /// <param name="b"></param>
        /// <param name="a"></param>
        /// <returns></returns>
        private static bool setValue(String value, out float r, out float g, out float b, out float a)
        {
            String[] nums    = value.Split(SEPS);
            bool     success = false;

            if (nums.Length == 4)
            {
                success  = NumberParser.TryParse(nums[0], out r);
                success &= NumberParser.TryParse(nums[1], out g);
                success &= NumberParser.TryParse(nums[2], out b);
                success &= NumberParser.TryParse(nums[3], out a);
            }
            else
            {
                r = 0f;
                g = 0f;
                b = 0f;
                a = 0f;
            }
            return(success);
        }
Beispiel #9
0
        private static bool setValue(String value, out float x, out float y, out float z, out float w)
        {
            String[] nums    = value.Split(SEPS);
            bool     success = false;

            if (nums.Length == 4)
            {
                success  = NumberParser.TryParse(nums[0], out x);
                success &= NumberParser.TryParse(nums[1], out y);
                success &= NumberParser.TryParse(nums[2], out z);
                success &= NumberParser.TryParse(nums[3], out w);
            }
            else
            {
                x = 0f;
                y = 0f;
                z = 0f;
                w = 0f;
            }
            return(success);
        }
        int[] readFaces(XmlReader textReader)
        {
            textReader.Read();
            String[] strVerts = textReader.Value.Split(SEPS);
            int[]    faces;
            int      junk;

            if (NumberParser.TryParse(strVerts[strVerts.Length - 1], out junk))
            {
                faces = new int[strVerts.Length];
            }
            else
            {
                faces = new int[strVerts.Length - 1];
            }
            for (uint i = 0; i < faces.Length; ++i)
            {
                faces[i] = NumberParser.ParseInt(strVerts[i]);
            }
            return(faces);
        }
        float[] readVertices(XmlReader textReader)
        {
            textReader.Read();
            String[] strVerts = textReader.Value.Split(SEPS);
            float[]  vertices;
            float    junk;

            if (NumberParser.TryParse(strVerts[strVerts.Length - 1], out junk))
            {
                vertices = new float[strVerts.Length];
            }
            else
            {
                vertices = new float[strVerts.Length - 1];
            }
            for (uint i = 0; i < vertices.Length; ++i)
            {
                vertices[i] = NumberParser.ParseFloat(strVerts[i]);
            }
            return(vertices);
        }