Exemplo n.º 1
0
        public void Load(FileReader fr)
        {
            string next;

            while (!(next = fr.readLine().Trim()).Equals("}"))
            {
                if (next.Length > 0 && next[0] != '#')
                {
                    string[] splt     = next.Split(':');
                    string   propname = splt[0];
                    Property adder;
                    if (splt[1].Equals(""))
                    {
                        if (fr.readLine().Trim().Equals("{"))
                        {
                            adder = new PropertyObject();
                            ((PropertyObject)adder).Load(fr);
                        }
                        else
                        {
                            throw new MalformedDataException("Tried to load object without data");
                        }
                    }
                    else
                    {
                        string otherside       = splt[1].Trim();
                        Regex  isOnlyNumbers   = new Regex("^\\-?[0-9]*$");
                        Regex  isDecimalNumber = new Regex("^\\-?[0-9]*\\.[0-9]*$");
                        Regex  isPoint         = new Regex("^\\-?[0-9]+, ?\\-?[0-9]+$");
                        Regex  isVector        = new Regex("^\\-?[0-9]*\\.[0-9]*, ?\\-?[0-9]*\\.[0-9]*$");
                        if (isOnlyNumbers.IsMatch(otherside))
                        {
                            adder = new IntProperty(int.Parse(otherside));
                        }
                        else if (isDecimalNumber.IsMatch(otherside))
                        {
                            adder = new DoubleProperty(double.Parse(otherside));
                        }
                        else if (isPoint.IsMatch(otherside))
                        {
                            adder = new PointProperty(new Point(int.Parse(otherside.Split(',')[0]), int.Parse(otherside.Split(',')[1].Trim())));
                        }
                        else if (isVector.IsMatch(otherside))
                        {
                            adder = new Vector2Property(new Vector2(float.Parse(otherside.Split(',')[0]), float.Parse(otherside.Split(',')[1].Trim())));
                        }
                        else
                        {
                            adder = new StringProperty(otherside);
                        }
                    }
                    MyProperties.Add(new PropertyDefinition(propname, adder));
                }
            }
        }
Exemplo n.º 2
0
        public static PropertyObject Load(string fileLocation)
        {
            FileReader fr = new FileReader("Content\\" + fileLocation);

            fr.readLine();
            PropertyObject toGlobal = new PropertyObject();

            toGlobal.Load(fr);
            fr.Finish();
            return(toGlobal);
        }
Exemplo n.º 3
0
        public static void Load(string fileLocation, string nameInGlobal)
        {
            FileReader fr = new FileReader("Content\\" + fileLocation);

            fr.readLine();
            PropertyObject toGlobal = new PropertyObject();

            toGlobal.Load(fr);
            Global.Add(new PropertyDefinition(nameInGlobal, toGlobal));
            fr.Finish();
        }
Exemplo n.º 4
0
 public static void Load(string fileLocation, string nameInGlobal)
 {
     PropertyObject.Load(fileLocation, nameInGlobal);
 }
Exemplo n.º 5
0
 public static PropertyObject Load(string fileLocation)
 {
     return(PropertyObject.Load(fileLocation));
 }