示例#1
0
        public void parse(string mapfile)
        {
            FileParser reader = new FileParser(mapfile);

            for (int i = 0; i < 6; i++)
            {
                Header[i] = reader.getByte();
            }
            string path = Tools.filePath(mapfile) + "\\";

            ResourceFile = path + reader.getStringBlock(12);
            FileParser resreader = new FileParser(ResourceFile);

            Resources = reader.getWord();
            for (int i = 0; i < Resources; i++)
            {
                UInt32 bytes  = reader.getDWord();
                UInt32 offset = reader.getDWord();
                resreader.setOffset(offset);
                string name = resreader.getStringBlock(12);
                addEntry(bytes, offset, name);
            }
        }
        public static Resource.Resource get(string name)
        {
            if (resources.ContainsKey(name.ToLower()))
            {
                return(resources[name]);
            }
            else
            {
                if (map == null)
                {
                    map = new Map();

                    map.parse(resourcemap);
                }
                FileParser reader = new FileParser(SCRANTIC.ResourceManager.map.ResourceFile);
                int        index  = SCRANTIC.ResourceManager.map.getResourceIndex(name);
                if (index < 0)
                {
                    return(null);
                }
                UInt32 offset = SCRANTIC.ResourceManager.map.getOffset(index);
                reader.setOffset(offset);
                string filename = reader.getStringBlock(12);
                UInt32 size     = reader.getDWord();
                byte[] data     = reader.getBytes(size);
                string ext      = name.Substring(name.LastIndexOf(".") + 1).ToLower();
                switch (ext)
                {
                case "ads":
                    Resource.ADS adsres = new Resource.ADS(name);
                    adsres.parse(data);
                    resources.Add(name.ToLower(), adsres);
                    return(adsres);

                case "bmp":
                    Resource.BMP bmpres = new Resource.BMP(name);
                    bmpres.parse(data);
                    resources.Add(name.ToLower(), bmpres);
                    return(bmpres);

                case "pal":
                    Resource.PAL palres = new Resource.PAL(name);
                    palres.parse(data);
                    resources.Add(name.ToLower(), palres);
                    return(palres);

                case "scr":
                    Resource.SCR scrres = new Resource.SCR(name);
                    scrres.parse(data);
                    resources.Add(name.ToLower(), scrres);
                    return(scrres);

                case "ttm":
                    Resource.TTM ttmres = new Resource.TTM(name);
                    ttmres.parse(data);
                    resources.Add(name.ToLower(), ttmres);
                    return(ttmres);

                case "vin":
                    break;
                }
            }
            return(null);
        }