예제 #1
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();
        }
예제 #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;
                }
            }
        }
예제 #3
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;
            }
        }
예제 #4
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;
				}
			}
		}
예제 #5
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();
        }
예제 #6
0
		public abstract void ParseLine(KeyVal line, VarCollection vars);
예제 #7
0
 public abstract void ParseLine(KeyVal line, VarCollection vars);
예제 #8
0
 public override void ParseLine(KeyVal line, VarCollection vars)
 {
 }
예제 #9
0
		public override void ParseLine(KeyVal line, VarCollection vars)
		{

		}
예제 #10
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();
        }