private void parseLine(XCom.KeyVal line, XCom.VarCollection vars) { switch (line.Keyword.ToLower()) { case "cursor": if (line.Rest.EndsWith("/")) { SharedSpace.Instance.GetObj("cursorFile", line.Rest + "CURSOR"); } else { SharedSpace.Instance.GetObj("cursorFile", line.Rest + "/CURSOR"); } break; case "logfile": try { LogFile.DebugOn = bool.Parse(line.Rest); } catch { Console.WriteLine("Could not parse logfile line"); } break; } }
// public IFont Font // { // get // { // if(myFont==null) // myFont = new xFont("",fontPath,fontColor); // return myFont; // } // } //public XCImage Background //{ // get // { // if(background==null) // background=new SCRImage(GameInfo.DefaultPalette,backPath); // return background; // } //} public ConsoleArgs(VarCollection vars, string fontPath, string backPath) { KeyVal line; fontColor = Color.Lavender; while ((line = vars.ReadLine()) != null) { switch (line.Keyword) { case "end": return; case "logfile": logPath = @line.Rest; break; case "font": myFont = fontPath + line.Rest; break; case "color": string[] val = line.Rest.Split(','); fontColor = Color.FromArgb(int.Parse(val[0]), int.Parse(val[1]), int.Parse(val[2])); break; case "back": this.backPath = backPath + line.Rest; break; } } }
//public static string debug = ""; public ItemDescriptor(string name, VarCollection vars) { this.name = name; KeyVal line = null; while ((line = vars.ReadLine()).Keyword.ToLower() != "end") { switch (line.Keyword.ToLower()) { case "hand": handIndex = int.Parse(line.Rest); break; case "ground": groundIndex = int.Parse(line.Rest); break; case "numhands": numHands = int.Parse(line.Rest); break; default: ParseLine(line, vars); break; } } }
// public IFont Font // { // get // { // if(myFont==null) // myFont = new xFont("",fontPath,fontColor); // return myFont; // } // } //public XCImage Background //{ // get // { // if(background==null) // background=new SCRImage(GameInfo.DefaultPalette,backPath); // return background; // } //} public ConsoleArgs(VarCollection vars,string fontPath,string backPath) { KeyVal line; fontColor = Color.Lavender; while((line=vars.ReadLine())!=null) { switch(line.Keyword) { case "end": return; case "logfile": [email protected]; break; case "font": myFont=fontPath+line.Rest; break; case "color": string[] val = line.Rest.Split(','); fontColor = Color.FromArgb(int.Parse(val[0]),int.Parse(val[1]),int.Parse(val[2])); break; case "back": this.backPath=backPath+line.Rest; break; } } }
//public static string debug = ""; public ItemDescriptor(string name, VarCollection vars) { this.name=name; KeyVal line=null; while((line=vars.ReadLine()).Keyword.ToLower()!="end") { switch(line.Keyword.ToLower()) { case "hand": handIndex = int.Parse(line.Rest); break; case "ground": groundIndex = int.Parse(line.Rest); break; case "numhands": numHands = int.Parse(line.Rest); break; default: ParseLine(line,vars); break; } } }
public ShipInfo(Stream file, VarCollection v) : this() { StreamReader sr = new StreamReader(file); //string line="",keyword="",rest=""; VarCollection vars = new VarCollection(sr, v); KeyVal kv = null; while ((kv = vars.ReadLine()) != null) { if (kv.Keyword == "end") { continue; } // int idx = line.IndexOf(':'); // keyword = line.Substring(0,idx); // rest = line.Substring(idx+1); switch (kv.Keyword) { case "ship": ships[kv.Rest] = new ShipDescriptor(kv.Rest, sr, vars); break; default: xConsole.AddLine("Unknown line in ship: " + kv); break; } } sr.Close(); }
public MiscInfo(Stream s,VarCollection v):this() { StreamReader sr = new StreamReader(s); VarCollection vars = new VarCollection(sr,v); KeyVal line; while((line=vars.ReadLine())!=null) { switch(line.Keyword) { case "cursor": stuff["cursor"] = @line.Rest; break; case "font": stuff["font"] = @line.Rest; break; case "geograph": stuff["geograph"][email protected]; break; case "ufograph": stuff["ufograph"][email protected]; break; #if !MAPEDIT case "console": stuff["console"] = new ConsoleArgs(vars,(string)stuff["font"],(string)stuff["geograph"]); break; #endif } } }
public MiscInfo(Stream s, VarCollection v) : this() { StreamReader sr = new StreamReader(s); VarCollection vars = new VarCollection(sr, v); KeyVal line; while ((line = vars.ReadLine()) != null) { switch (line.Keyword) { case "cursor": stuff["cursor"] = @line.Rest; break; case "font": stuff["font"] = @line.Rest; break; case "geograph": stuff["geograph"] = @line.Rest; break; case "ufograph": stuff["ufograph"] = @line.Rest; break; #if !MAPEDIT case "console": stuff["console"] = new ConsoleArgs(vars, (string)stuff["font"], (string)stuff["geograph"]); break; #endif } } }
public ShipInfo(Stream file,VarCollection v):this() { StreamReader sr = new StreamReader(file); //string line="",keyword="",rest=""; VarCollection vars = new VarCollection(sr,v); KeyVal kv = null; while((kv = vars.ReadLine())!=null) { if(kv.Keyword=="end") continue; // int idx = line.IndexOf(':'); // keyword = line.Substring(0,idx); // rest = line.Substring(idx+1); switch(kv.Keyword) { case "ship": ships[kv.Rest] = new ShipDescriptor(kv.Rest,sr,vars); break; default: xConsole.AddLine("Unknown line in ship: "+kv); break; } } sr.Close(); }
public ImageInfo(string inFile, VarCollection v) : base(inFile) { _images = new Dictionary <string, ImageDescriptor>(); Load(inFile, v); }
public override void Save(string outFile) { // iterate thru each tileset, call save on them VarCollection vc = new VarCollection("Path"); StreamWriter sw = new StreamWriter(outFile); foreach (string s in tilesets.Keys) { IXCTileset ts = (IXCTileset)tilesets[s]; if (ts != null) { vc.AddVar("rootPath", ts.MapPath); vc.AddVar("rmpPath", ts.RmpPath); vc.AddVar("blankPath", ts.BlankPath); } } foreach (string v in vc.Variables) { Variable var = (Variable)vc.Vars[v]; sw.WriteLine(var.Name + ":" + var.Value); } foreach (string s in tilesets.Keys) { if (tilesets[s] != null) { ((IXCTileset)tilesets[s]).Save(sw, vc); } } sw.Close(); }
//public override IMap GetMap(ShipDescriptor xCom,ShipDescriptor alien){return new Type1Map(this,xCom,alien);} public override void Save(StreamWriter sw, VarCollection vars) { sw.WriteLine("Tileset:" + name); sw.WriteLine("\ttype:1"); if (vars.Vars[rootPath] == null) sw.WriteLine("\trootpath:" + rootPath); else sw.WriteLine("\trootpath:" + ((Variable)vars.Vars[rootPath]).Name); if (vars.Vars[rmpPath] == null) sw.WriteLine("\trmpPath:" + rootPath); else sw.WriteLine("\trmpPath:" + ((Variable)vars.Vars[rmpPath]).Name); if (vars.Vars[blankPath] == null) sw.WriteLine("\tblankPath:" + blankPath); else sw.WriteLine("\tblankPath:" + ((Variable)vars.Vars[blankPath]).Name); sw.WriteLine("\tpalette:" + myPal.Name); foreach (string str in subsets.Keys) { Dictionary<string, IMapDesc> h = subsets[str]; if (h == null) continue; VarCollection vc = new VarCollection("Deps"); foreach (string s in h.Keys) { XCMapDesc id = (XCMapDesc)maps[s]; if (id == null) continue; string depList = ""; if (id.Dependencies.Length > 0) { int i = 0; for (; i < id.Dependencies.Length - 1; i++) depList += id.Dependencies[i] + " "; depList += id.Dependencies[i]; } vc.AddVar(id.Name, depList); } sw.WriteLine("\tfiles:" + str); foreach (string vKey in vc.Variables) ((Variable)vc.Vars[vKey]).Write(sw, "\t\t"); sw.WriteLine("\tend"); } sw.WriteLine("end\n"); sw.Flush(); }
protected override void ParseLine(string keyword, string rest, StreamReader sr, VarCollection vars) { switch(keyword) { case "nozombie": zombie=false; break; } }
protected override void ParseLine(string keyword, string rest,StreamReader sr, VarCollection vars) { switch(keyword) { case "yoffset": offset = int.Parse(rest); break; } }
public UnitInfo(Stream file,VarCollection v):this() { StreamReader sr = new StreamReader(file); VarCollection vars = new VarCollection(sr,v); KeyVal line=vars.ReadLine(); if(line==null) return; groundImages = line.Rest; while((line=vars.ReadLine())!=null) { if(line.Keyword=="unit") { string name = line.Rest; line = vars.ReadLine(); if(line.Keyword=="type") { int type = int.Parse(line.Rest); switch(type) { case 0: units[name] = new Type0Descriptor(name,sr,vars); break; case 1: units[name] = new Type1Descriptor(name,sr,vars); break; case 2: units[name] = new Type2Descriptor(name,sr,vars); break; case 3: units[name] = new Type3Descriptor(name,sr,vars); break; case 4: units[name] = new Type4Descriptor(name,sr,vars); break; case 5: units[name] = new Type5Descriptor(name,sr,vars); break; case 6: units[name] = new Type6Descriptor(name,sr,vars); break; case 7: units[name] = new Type7Descriptor(name,sr,vars); break; } } } else { xConsole.AddLine("Unknown keyword parsing unit file(1): "+line.Keyword+"->"+line.Rest); } } sr.Close(); }
public ShipDescriptor(string name, StreamReader sr, VarCollection vars) : base(null, null, null, null, null, null, null) { string line = "", keyword = "", rest = ""; alienShip = true; useTanks = true; startLocUL = new MapLocation(0, 0, 0); while ((line = vars.ReadLine(sr)) != null) { if (line == "end" || line == "END") { return; } int idx = line.IndexOf(':'); keyword = line.Substring(0, idx).ToLower(); rest = line.Substring(idx + 1); switch (keyword) { case "path": basePath = @rest; break; case "blankpath": blankPath = @rest; break; case "rmppath": rmpPath = @rest; break; case "file": basename = rest; break; case "dependencies": dependencies = rest.Split(' '); break; case "xcomship": alienShip = false; break; case "notanks": useTanks = false; break; default: Console.WriteLine("Unknown line in ship: {0} -> {1}", name, line); break; } } }
public TilesetDesc(string inFile, VarCollection v) : base(inFile) { tilesets = new Dictionary <string, ITileset>(); StreamReader sr = new StreamReader(File.OpenRead(inFile)); string line = "", keyword = "", name = ""; VarCollection vars = new VarCollection(sr, v); while ((line = vars.ReadLine(sr)) != null) { int idx = line.IndexOf(':'); keyword = line.Substring(0, idx); string keywordLow = keyword.ToLower(); name = line.Substring(idx + 1); switch (keywordLow) { case "tileset": line = VarCollection.ReadLine(sr, vars); idx = line.IndexOf(':'); keyword = line.Substring(0, idx).ToLower(); string rest = line.Substring(idx + 1); switch (keyword) { case "type": int type = int.Parse(rest); switch (type) { // case 0: // tilesets[name] = new Type0Tileset(name, sr, new VarCollection(vars)); // break; case 1: tilesets[name] = new XCTileset(name, sr, new VarCollection(vars)); break; } break; default: Console.WriteLine("Type line not found: " + line); break; } break; case "version": version = double.Parse(name); break; default: Console.WriteLine("Unknown line: " + line); break; } } sr.Close(); }
protected override void ParseLine(string keyword,string rest, StreamReader sr, VarCollection vars) { switch(keyword) { case "start": start = int.Parse(rest); break; case "numdeath": numDeath=int.Parse(rest); break; } }
public TilesetDesc(string inFile,VarCollection v):base(inFile) { tilesets = new Dictionary<string, ITileset>(); StreamReader sr = new StreamReader(File.OpenRead(inFile)); string line="",keyword="",name=""; VarCollection vars = new VarCollection(sr,v); while((line = vars.ReadLine(sr))!=null) { int idx = line.IndexOf(':'); keyword = line.Substring(0,idx); string keywordLow = keyword.ToLower(); name = line.Substring(idx+1); switch(keywordLow) { case "tileset": line = VarCollection.ReadLine(sr,vars); idx = line.IndexOf(':'); keyword = line.Substring(0,idx).ToLower(); string rest = line.Substring(idx+1); switch(keyword) { case "type": int type = int.Parse(rest); switch(type) { //case 0: // tilesets[name] = new Type0Tileset(name,sr,new VarCollection(vars)); // break; case 1: tilesets[name] = new XCTileset(name,sr,new VarCollection(vars)); break; } break; default: Console.WriteLine("Type line not found: "+line); break; } break; case "version": version = double.Parse(name); break; default: Console.WriteLine("Unknown line: "+line); break; } } sr.Close(); }
public ImageInfo(string inFile,VarCollection v):base(inFile) { images = new Dictionary<string, ImageDescriptor>(); StreamReader sr = new StreamReader(File.OpenRead(inFile)); VarCollection vars = new VarCollection(sr,v); KeyVal kv = null; while((kv=vars.ReadLine())!=null) { ImageDescriptor img = new ImageDescriptor(kv.Keyword.ToUpper(),kv.Rest); images[kv.Keyword.ToUpper()] = img; } sr.Close(); }
public void Load(string inFile, VarCollection v) { using (var sr = new StreamReader(File.OpenRead(inFile))) { var vars = new VarCollection(sr, v); KeyVal kv; while ((kv = vars.ReadLine()) != null) { var img = new ImageDescriptor(kv.Keyword.ToUpper(), kv.Rest); _images[kv.Keyword.ToUpper()] = img; } sr.Close(); } }
public ShipDescriptor(string name, StreamReader sr,VarCollection vars):base(null,null,null,null,null,null,null) { string line="",keyword="",rest=""; alienShip=true; useTanks=true; startLocUL=new MapLocation(0,0,0); while((line=vars.ReadLine(sr))!=null) { if(line=="end" || line=="END") return; int idx = line.IndexOf(':'); keyword = line.Substring(0,idx).ToLower(); rest = line.Substring(idx+1); switch(keyword) { case "path": basePath=@rest; break; case "blankpath": blankPath=@rest; break; case "rmppath": rmpPath=@rest; break; case "file": basename = rest; break; case "dependencies": dependencies = rest.Split(' '); break; case "xcomship": alienShip=false; break; case "notanks": useTanks=false; break; default: Console.WriteLine("Unknown line in ship: {0} -> {1}",name,line); break; } } }
public InstallWindow() { // runPath = Directory.GetCurrentDirectory(); InitializeComponent(); DialogResult = DialogResult.Cancel; vars = new XCom.VarCollection(); ufoDirs = new List <string>(); ufoDirs.Add(@"C:\ufo"); ufoDirs.Add(@"C:\ufo enemy unknown"); ufoDirs.Add(@"C:\mps\ufo"); ufoDirs.Add(@"C:\mps\ufo enemy unknown"); ufoDirs.Add(@"d:\xcompro\mapedit\ufo"); ufoDirs.Add(@"c:\program files\ufo enemy unknown"); ufoDirs.Add(@"C:\Documents and Settings\Ben\Desktop\XCFiles\ufo"); tftdDirs = new List <string>(); tftdDirs.Add(@"C:\tftd"); tftdDirs.Add(@"C:\mps\tftd"); tftdDirs.Add(@"C:\terror"); tftdDirs.Add(@"C:\mps\tftd"); tftdDirs.Add(@"d:\xcompro\mapedit\tftd"); tftdDirs.Add(@"c:\program files\Terror From the Deep"); tftdDirs.Add(@"C:\Documents and Settings\Ben\Desktop\XCFiles\tftd"); foreach (string path in ufoDirs) { if (Directory.Exists(path)) { txtUFO.Text = path; break; } } foreach (string path in tftdDirs) { if (Directory.Exists(path)) { txtTFTD.Text = path; break; } } }
protected override void ParseLine(string keyword, string rest, StreamReader sr, VarCollection vars) { switch(keyword) { case "weapon": string[]dat = rest.Split(','); weapons[dat[0]]=int.Parse(dat[1]); break; case "start": start=int.Parse(rest); break; case "frames": numFrames=int.Parse(rest); break; default: Console.WriteLine("Unknown line in unit description "+this.Name); break; } }
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; } } }
public InstallWindow() { //runPath = Directory.GetCurrentDirectory(); InitializeComponent(); DialogResult = DialogResult.Cancel; vars = new XCom.VarCollection(); ufoDirs = new List<string>(); ufoDirs.Add(@"C:\ufo"); ufoDirs.Add(@"C:\ufo enemy unknown"); ufoDirs.Add(@"C:\mps\ufo"); ufoDirs.Add(@"C:\mps\ufo enemy unknown"); ufoDirs.Add(@"d:\xcompro\mapedit\ufo"); ufoDirs.Add(@"c:\program files\ufo enemy unknown"); ufoDirs.Add(@"C:\Documents and Settings\Ben\Desktop\XCFiles\ufo"); tftdDirs = new List<string>(); tftdDirs.Add(@"C:\tftd"); tftdDirs.Add(@"C:\mps\tftd"); tftdDirs.Add(@"C:\terror"); tftdDirs.Add(@"C:\mps\tftd"); tftdDirs.Add(@"d:\xcompro\mapedit\tftd"); tftdDirs.Add(@"c:\program files\Terror From the Deep"); tftdDirs.Add(@"C:\Documents and Settings\Ben\Desktop\XCFiles\tftd"); foreach(string path in ufoDirs) if(Directory.Exists(path)) { txtUFO.Text=path; break; } foreach(string path in tftdDirs) if(Directory.Exists(path)) { txtTFTD.Text=path; break; } }
public static void Init(Palette p, DSShared.PathInfo paths) { currentPalette = p; pckHash = new Dictionary <Palette, Dictionary <string, PckFile> >(); VarCollection vars = new VarCollection(new StreamReader(File.OpenRead(paths.ToString()))); Directory.SetCurrentDirectory(paths.Path); xConsole.Init(20); KeyVal kv = null; while ((kv = vars.ReadLine()) != null) { switch (kv.Keyword) { case "mapdata": /* mapedit */ tileInfo = new TilesetDesc(kv.Rest, vars); break; case "images": /* mapedit */ imageInfo = new ImageInfo(kv.Rest, vars); break; default: if (ParseLine != null) { ParseLine(kv, vars); } else { xConsole.AddLine("Error in paths file: " + kv); } break; } } vars.BaseStream.Close(); }
public static string ReadLine(StreamReader sr, VarCollection vars) { string line = ""; while (true) { do //get a good line - not a comment or empty string { if (sr.Peek() != -1) { line = sr.ReadLine().Trim(); } else { return(null); } }while(line.Length == 0 || line[0] == '#'); if (line[0] == '$') //cache variable, get another line { int idx = line.IndexOf(':'); string var = line.Substring(0, idx); string val = vars.ParseVar(line.Substring(idx + 1)); vars[var] = val; } else //got a line { break; } } if (line.IndexOf("$") > 0) //replace any variables the line might have { line = vars.ParseVar(line); } return(line); }
public static void Init(Palette p, DSShared.PathInfo paths) { currentPalette = p; pckHash = new Dictionary<Palette, Dictionary<string, PckFile>>(); VarCollection vars = new VarCollection(new StreamReader(File.OpenRead(paths.ToString()))); Directory.SetCurrentDirectory(paths.Path); xConsole.Init(20); KeyVal kv = null; while((kv=vars.ReadLine())!=null) { switch (kv.Keyword) { /* mapedit */case "mapdata": tileInfo = new TilesetDesc(kv.Rest, vars); break; /* mapedit */case "images": imageInfo = new ImageInfo(kv.Rest, vars); break; case "useBlanks": Globals.UseBlanks = bool.Parse(kv.Rest); break; default: if (ParseLine != null) ParseLine(kv, vars); else xConsole.AddLine("Error in paths file: " + kv); break; } } vars.BaseStream.Close(); }
public VarCollection(VarCollection other) : this() { this.other = other; }
protected override void ParseLine(string keyword, string rest, StreamReader sr, VarCollection vars) { switch (keyword) { case "start": start = int.Parse(rest); break; case "numdeath": numDeath = int.Parse(rest); break; } }
public VarCollection(StreamReader sr) { this.sr = sr; vars = new Hashtable(); other = null; }
public override void ParseLine(KeyVal line, VarCollection vars) { }
public VarCollection() { vars = new Hashtable(); other = null; baseVar = ""; }
public abstract void ParseLine(KeyVal line, VarCollection vars);
public override void ParseLine( string keyword, string rest, StreamReader sr, VarCollection vars) { switch (keyword) { case "files": { Dictionary <string, IMapDesc> subset = new Dictionary <string, IMapDesc>(); subsets[rest] = subset; string line = VarCollection.ReadLine(sr, vars); while (line != "end" && line != "END") { int idx = line.IndexOf(':'); string fName = line.Substring(0, idx); string[] deps = line.Substring(idx + 1).Split(' '); XCMapDesc imd = new XCMapDesc( fName, rootPath, blankPath, rmpPath, deps, myPal); maps[fName] = imd; subset[fName] = imd; line = VarCollection.ReadLine(sr, vars); } break; } case "order": mapOrder = rest.Split(' '); break; case "starttile": startTile = int.Parse(rest); break; case "startloc": { string[] locs = rest.Split(' '); startLoc = new MapLocation[locs.Length]; for (int i = 0; i < locs.Length; i++) { string[] loc = locs[i].Split(','); int r = int.Parse(loc[0]); int c = int.Parse(loc[1]); int h = int.Parse(loc[2]); startLoc[i] = new MapLocation(r, c, h); } break; } case "endtile": endTile = int.Parse(rest); break; default: xConsole.AddLine(string.Format( "Unknown line in tileset {0}-> {1}:{2}", name, keyword, rest)); break; } }
public UnitInfo(Stream file, VarCollection v) : this() { StreamReader sr = new StreamReader(file); VarCollection vars = new VarCollection(sr, v); KeyVal line = vars.ReadLine(); if (line == null) { return; } groundImages = line.Rest; while ((line = vars.ReadLine()) != null) { if (line.Keyword == "unit") { string name = line.Rest; line = vars.ReadLine(); if (line.Keyword == "type") { int type = int.Parse(line.Rest); switch (type) { case 0: units[name] = new Type0Descriptor(name, sr, vars); break; case 1: units[name] = new Type1Descriptor(name, sr, vars); break; case 2: units[name] = new Type2Descriptor(name, sr, vars); break; case 3: units[name] = new Type3Descriptor(name, sr, vars); break; case 4: units[name] = new Type4Descriptor(name, sr, vars); break; case 5: units[name] = new Type5Descriptor(name, sr, vars); break; case 6: units[name] = new Type6Descriptor(name, sr, vars); break; case 7: units[name] = new Type7Descriptor(name, sr, vars); break; } } } else { xConsole.AddLine("Unknown keyword parsing unit file(1): " + line.Keyword + "->" + line.Rest); } } sr.Close(); }
public WeaponDescriptor(string name, VarCollection vars) : base(name, vars) { }
public XCTileset(string name, StreamReader sr,VarCollection vars):base(name,sr,vars) { }
public override void ParseLine(string keyword, string rest,StreamReader sr,VarCollection vars) { switch(keyword) { case "files": { Dictionary<string, IMapDesc> subset = new Dictionary<string, IMapDesc>(); subsets[rest]=subset; string line = VarCollection.ReadLine(sr,vars); while(line!="end" && line!="END") { int idx = line.IndexOf(':'); string fName = line.Substring(0,idx); string[] deps = line.Substring(idx+1).Split(' '); XCMapDesc imd = new XCMapDesc(fName, rootPath, blankPath, rmpPath, deps, myPal); maps[fName] =imd; subset[fName]=imd; line = VarCollection.ReadLine(sr,vars); } } break; case "order": mapOrder = rest.Split(' '); break; case "starttile": startTile = int.Parse(rest); break; case "startloc": string[] locs = rest.Split(' '); startLoc = new MapLocation[locs.Length]; for(int i=0;i<locs.Length;i++) { string[] loc = locs[i].Split(','); int r = int.Parse(loc[0]); int c = int.Parse(loc[1]); int h = int.Parse(loc[2]); startLoc[i] = new MapLocation(r,c,h); } break; case "endtile": endTile = int.Parse(rest); break; default: xConsole.AddLine(string.Format("Unknown line in tileset {0}-> {1}:{2}",name,keyword,rest)); break; } }
public ImageInfo():base("") { images = new Dictionary<string, ImageDescriptor>(); vars = new VarCollection(); }
public VarCollection(StreamReader sr, VarCollection vars) { this.vars = new Hashtable(); this.sr = sr; other = vars; }
protected override void ParseLine(string keyword, string rest, StreamReader sr, VarCollection vars) { switch (keyword) { case "yoffset": offset = int.Parse(rest); break; } }
protected override void ParseLine(string keyword, string rest, StreamReader sr, VarCollection vars) { switch (keyword) { case "nozombie": zombie = false; break; } }
public XCTileset(string name, StreamReader sr, VarCollection vars) : base(name, sr, vars) { }
public Type2Descriptor(string name, StreamReader sr,VarCollection vars) :base(name,sr,vars){}
public VarCollection() { vars = new Hashtable(); other=null; baseVar=""; }
public VarCollection(VarCollection other):this() { this.other=other; }
// public override IMap GetMap(ShipDescriptor xCom, ShipDescriptor alien) // { return new Type1Map(this, xCom, alien); } public override void Save(StreamWriter sw, VarCollection vars) { sw.WriteLine("Tileset:" + name); sw.WriteLine("\ttype:1"); if (vars.Vars[rootPath] == null) { sw.WriteLine("\trootpath:" + rootPath); } else { sw.WriteLine("\trootpath:" + ((Variable)vars.Vars[rootPath]).Name); } if (vars.Vars[rmpPath] == null) { sw.WriteLine("\trmpPath:" + rootPath); } else { sw.WriteLine("\trmpPath:" + ((Variable)vars.Vars[rmpPath]).Name); } if (vars.Vars[blankPath] == null) { sw.WriteLine("\tblankPath:" + blankPath); } else { sw.WriteLine("\tblankPath:" + ((Variable)vars.Vars[blankPath]).Name); } sw.WriteLine("\tpalette:" + myPal.Name); foreach (string str in subsets.Keys) { Dictionary <string, IMapDesc> h = subsets[str]; if (h != null) { VarCollection vc = new VarCollection("Deps"); foreach (string s in h.Keys) { XCMapDesc id = (XCMapDesc)maps[s]; if (id == null) { continue; } string depList = ""; if (id.Dependencies.Length > 0) { int i = 0; for (; i < id.Dependencies.Length - 1; i++) { depList += id.Dependencies[i] + " "; } depList += id.Dependencies[i]; } vc.AddVar(id.Name, depList); } sw.WriteLine("\tfiles:" + str); foreach (string vKey in vc.Variables) { ((Variable)vc.Vars[vKey]).Write(sw, "\t\t"); } sw.WriteLine("\tend"); } } sw.WriteLine("end\n"); sw.Flush(); }
public Type4Descriptor(string name, StreamReader sr, VarCollection vars) : base(name, sr, vars) { fly = false; }
private void readMapViewSettings(StreamReader sr) { XCom.VarCollection vc = new XCom.VarCollection(sr); XCom.KeyVal kv = null; while ((kv = vc.ReadLine()) != null) { try { Settings.ReadSettings(vc, kv, settingsHash[kv.Keyword]); } catch { } } sr.Close(); }
public static string ReadLine(StreamReader sr,VarCollection vars) { string line = ""; while(true) { do //get a good line - not a comment or empty string { if(sr.Peek()!=-1) line = sr.ReadLine().Trim(); else return null; }while(line.Length==0 || line[0]=='#'); if(line[0]=='$') //cache variable, get another line { int idx = line.IndexOf(':'); string var = line.Substring(0,idx); string val = vars.ParseVar(line.Substring(idx+1)); vars[var]=val; } else //got a line break; } if(line.IndexOf("$")>0) //replace any variables the line might have line = vars.ParseVar(line); return line; }
public WeaponDescriptor(string name, VarCollection vars):base(name,vars) { }
public VarCollection(StreamReader sr) { this.sr=sr; vars = new Hashtable(); other=null; }
protected override void ParseLine(string keyword, string rest, StreamReader sr, VarCollection vars) { switch (keyword) { case "weapon": string[] dat = rest.Split(','); weapons[dat[0]] = int.Parse(dat[1]); break; case "start": start = int.Parse(rest); break; case "frames": numFrames = int.Parse(rest); break; default: Console.WriteLine("Unknown line in unit description " + this.Name); break; } }
public VarCollection(StreamReader sr,VarCollection vars) { this.vars=new Hashtable(); this.sr=sr; other=vars; }
protected override void ParseLine(string keyword, string line, StreamReader sr, VarCollection vars) {}