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); }
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(); }
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); }
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); } }
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); } } }