Esempio n. 1
0
        public static RTSUnitData ParseData(Dictionary <string, ReflectedScript> controllers, FileInfo infoFile, int index)
        {
            // Check File Existence
            if (infoFile == null || !infoFile.Exists)
            {
                return(null);
            }

            // Read The Entire File
            string mStr;

            using (FileStream fs = File.OpenRead(infoFile.FullName)) {
                StreamReader s = new StreamReader(fs);
                mStr = s.ReadToEnd();
            }

            // Set Environment Variables
            ZXParser.SetEnvironment("FILEROOTDIR", infoFile.Directory.FullName);
            ZXParser.SetEnvironment("DICTSCRIPTS", controllers);

            // Read Data
            RTSUnitData data = new RTSUnitData(index);

            ZXParser.ParseInto(mStr, data);
            data.InfoFile = PathHelper.GetRelativePath(infoFile.FullName);
            return(data);
        }
Esempio n. 2
0
        static void TestZXP()
        {
            string data =
                @"    MyValue [10]
    Add({10})
    Add({10})
    Add({10})
    Inner <RTSEngineTests.ZXPTestObj> {
        MyValue [12]
        Add({10})
        Add({10})
        Add({10})
        Inner <RTSEngineTests.ZXPTestObj> {
            MyValue [14]
            Add({10})
            Add({10})
            Add({10})
        }
    }"
            ;
            ZXPTestObj o = new ZXPTestObj();

            ZXParser.ParseInto(data, o);
            Console.WriteLine(o.Value);
            Console.WriteLine(o.Rec.Value);
            Console.WriteLine(o.Rec.Rec.Value);
            var sw = new StreamWriter("Test.txt");

            ZXParser.Write(sw, o);
            sw.Flush();
            sw.Dispose();
        }
Esempio n. 3
0
        public static RTSRace Parse(FileInfo infoFile, Dictionary <string, ReflectedScript> scripts)
        {
            // Check File Existence
            if (infoFile == null || !infoFile.Exists)
            {
                return(null);
            }

            // Read The Entire File
            string mStr;

            using (FileStream fs = File.OpenRead(infoFile.FullName)) {
                StreamReader s = new StreamReader(fs);
                mStr = s.ReadToEnd();
            }

            // Set Environment Variables
            ZXParser.SetEnvironment("FILEROOTDIR", infoFile.Directory.FullName);
            ZXParser.SetEnvironment("DICTSCRIPTS", scripts);

            // Read Data
            RTSRace data = new RTSRace();

            ZXParser.ParseInto(mStr, data);
            data.InfoFile = new FileInfo(PathHelper.GetRelativePath(infoFile.FullName));
            data.UpdateActiveUnits();
            data.UpdateActiveBuildings();
            return(data);
        }
Esempio n. 4
0
 public override void Build()
 {
     using (var fs = File.OpenRead(UIC_FILE)) {
         uic = new UICMainMenu();
         ZXParser.ParseInto(new StreamReader(fs).ReadToEnd(), uic);
     }
     using (var s = File.OpenRead(uic.SoundClick)) {
         seClick = SoundEffect.FromStream(s);
     }
 }
Esempio n. 5
0
        public static void Load(string path)
        {
            FileInfo fi = new FileInfo(path);

            if (!fi.Exists)
            {
                changeDetected = true;
                data           = new Args();
            }
            else
            {
                using (var s = fi.OpenRead()) {
                    var mStr = new StreamReader(s).ReadToEnd();
                    ZXParser.ParseInto(mStr, data);
                }
            }
        }