Beispiel #1
0
        public static HudResourceFile ParseHudResource(string path)
        {            
            if(!path.EndsWith("\\hudinfo.txt"))
                path += "hudinfo.txt";

            if(File.Exists(path))
            {
                HudResourceFile newRes = new HudResourceFile();                
                newRes = ParseHudResource(new StreamReader(path).BaseStream);
                newRes.FullName = path;                
                return newRes;
            }
            else return new HudResourceFile();
        }
Beispiel #2
0
        public static HudResourceFile ParseHudResource(Stream stream)
        {
            HudResourceFile hf = new HudResourceFile();
            StreamReader sr = new StreamReader(stream);
            string s = sr.ReadToEnd();
            sr.Close();
            RefLib.CleanUp(ref s,RefLib.cleanupModes.Comments);

            RefLib.Seek(ref s);
            string ss = s;
            ss = RefLib.GetLine(ref ss);
            hf.Name = ReadName(ss);
            s = s.Remove(0,ss.Length);
            RefLib.Seek(ref s);

            if(s.First() == '{')
            {
                s = s.Remove(0,1);
                while(true)
                {
                    RefLib.Seek(ref s);
                    ss = s;
                    if(ss.First() != '}')
                    {
                        ss = RefLib.GetLine(ref ss);
                        KeyValue kv = ParseKeyValue(ss);
                        s = s.Remove(0,ss.Length);

                        if(kv != new KeyValue())
                            hf.Add(kv);
                        else break;                        
                    }
                    else break;
                }
            }
            return hf;
        }