ReadLine() public méthode

public ReadLine ( ) : KeyVal
Résultat KeyVal
Exemple #1
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();
		}
Exemple #2
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;
                }
            }
        }
Exemple #3
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();
		}
		//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;
				}
			}		
		}
Exemple #5
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();
        }
Exemple #6
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
                }
            }
        }
Exemple #7
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;
                }
            }
        }
Exemple #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"][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
				}
			}
		}
Exemple #9
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;
				}
			}
		}
Exemple #10
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;
                }
            }
        }
Exemple #11
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();
        }
Exemple #12
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();
		}
Exemple #13
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();
            }
        }
Exemple #14
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();
		}
		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;
				}
			}
		}
Exemple #16
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;
				}
			}
		}
Exemple #17
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();
        }
Exemple #18
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();
		}
Exemple #19
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();
        }
Exemple #20
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;
            }
        }
Exemple #21
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();
		}