예제 #1
0
        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;
            }
        }
예제 #2
0
//		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;
                }
            }
        }
예제 #3
0
        //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;
                }
            }
        }
예제 #4
0
//		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;
				}
			}
		}
예제 #5
0
		//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;
				}
			}		
		}
예제 #6
0
        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();
        }
예제 #7
0
		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
				}
			}
		}
예제 #8
0
        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
                }
            }
        }
예제 #9
0
		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();
		}
예제 #10
0
 public ImageInfo(string inFile, VarCollection v)
     :
     base(inFile)
 {
     _images = new Dictionary <string, ImageDescriptor>();
     Load(inFile, v);
 }
예제 #11
0
        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();
        }
예제 #12
0
		//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();
		}
예제 #13
0
		protected override void ParseLine(string keyword, string rest, StreamReader sr, VarCollection vars)
		{
			switch(keyword)
			{
				case "nozombie":
					zombie=false;
					break;
			}
		}
예제 #14
0
		protected override void ParseLine(string keyword, string rest,StreamReader sr, VarCollection vars)
		{
			switch(keyword)
			{
				case "yoffset":
					offset = int.Parse(rest);
					break;
			}
		}
예제 #15
0
		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();
		}
예제 #16
0
        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;
                }
            }
        }
예제 #17
0
        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();
        }
예제 #18
0
		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;
			}
		}
예제 #19
0
		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();
		}
예제 #20
0
		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();
		}
예제 #21
0
        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();
            }
        }
예제 #22
0
		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;
				}
			}
		}
예제 #23
0
        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;
                }
            }
        }
예제 #24
0
		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;
			}
		}
예제 #25
0
		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;
				}
			}
		}
예제 #26
0
		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;
				}
		}
예제 #27
0
        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();
        }
예제 #28
0
        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);
        }
예제 #29
0
		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();
		}
예제 #30
0
 public VarCollection(VarCollection other) : this()
 {
     this.other = other;
 }
예제 #31
0
        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;
            }
        }
예제 #32
0
 public VarCollection(StreamReader sr)
 {
     this.sr = sr;
     vars    = new Hashtable();
     other   = null;
 }
예제 #33
0
		public override void ParseLine(KeyVal line, VarCollection vars)
		{

		}
예제 #34
0
 public VarCollection()
 {
     vars    = new Hashtable();
     other   = null;
     baseVar = "";
 }
예제 #35
0
		public abstract void ParseLine(KeyVal line, VarCollection vars);
예제 #36
0
        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;
            }
        }
예제 #37
0
 public abstract void ParseLine(KeyVal line, VarCollection vars);
예제 #38
0
        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();
        }
예제 #39
0
 public WeaponDescriptor(string name, VarCollection vars) : base(name, vars)
 {
 }
예제 #40
0
 public override void ParseLine(KeyVal line, VarCollection vars)
 {
 }
예제 #41
0
		public XCTileset(string name, StreamReader sr,VarCollection vars):base(name,sr,vars)
		{
		}
예제 #42
0
		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;
			}
		}
예제 #43
0
		public ImageInfo():base("")
		{
			images = new Dictionary<string, ImageDescriptor>();
			vars = new VarCollection();
		}
예제 #44
0
 public VarCollection(StreamReader sr, VarCollection vars)
 {
     this.vars = new Hashtable();
     this.sr   = sr;
     other     = vars;
 }
예제 #45
0
 protected override void ParseLine(string keyword, string rest, StreamReader sr, VarCollection vars)
 {
     switch (keyword)
     {
     case "yoffset":
         offset = int.Parse(rest);
         break;
     }
 }
예제 #46
0
 protected override void ParseLine(string keyword, string rest, StreamReader sr, VarCollection vars)
 {
     switch (keyword)
     {
     case "nozombie":
         zombie = false;
         break;
     }
 }
예제 #47
0
 public XCTileset(string name, StreamReader sr, VarCollection vars)
     :
     base(name, sr, vars)
 {
 }
예제 #48
0
		public Type2Descriptor(string name, StreamReader sr,VarCollection vars)
			:base(name,sr,vars){}
예제 #49
0
		public VarCollection()
		{
			vars = new Hashtable();
			other=null;
			baseVar="";
		}
예제 #50
0
		public VarCollection(VarCollection other):this()
		{
			this.other=other;
		}
예제 #51
0
//		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();
        }
예제 #52
0
 public Type4Descriptor(string name, StreamReader sr, VarCollection vars)
     : base(name, sr, vars)
 {
     fly = false;
 }
예제 #53
0
		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();
		}
예제 #54
0
		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;
		}
예제 #55
0
  		public WeaponDescriptor(string name, VarCollection vars):base(name,vars)
		{

		}
예제 #56
0
		public VarCollection(StreamReader sr)
		{
			this.sr=sr;
			vars = new Hashtable();
			other=null;
		}
예제 #57
0
        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;
            }
        }
예제 #58
0
		public VarCollection(StreamReader sr,VarCollection vars)
		{
			this.vars=new Hashtable();
			this.sr=sr;
			other=vars;
		}
예제 #59
0
		protected override void ParseLine(string keyword, string line, StreamReader sr, VarCollection vars)
		{}