Пример #1
0
        public Format Read2(sFile file)
        {
            string ext = "";

            if (file.size >= 4)
            {
                using (BinaryReader br = new BinaryReader(File.OpenRead(file.path)))
                {
                    ext = new String(Encoding.ASCII.GetChars(br.ReadBytes(4)));
                    br.Close();
                }
            }

            // Palette
            if (file.name.ToUpper().EndsWith(".NTFP") || file.name.ToUpper().EndsWith(".PLT"))
            {
                RawPalette palette = new RawPalette(file.path, file.id, true, 0, -1, file.name);
                pluginHost.Set_Palette(palette);
                return(Format.Palette);
            }
            else if (ext == "RLCN")
            {
                PaletteBase palette = new NCLR(file.path, file.id, file.name);
                pluginHost.Set_Palette(palette);
                return(Format.Palette);
            }
            else if (ext == "NCCL")
            {
                NCCL palette = new NCCL(file.path, file.id, file.name);
                pluginHost.Set_Palette(palette);
                return(Format.Palette);
            }
            else if (file.name.ToUpper().EndsWith(".NBFP"))
            {
                RawPalette palette = new RawPalette(file.path, file.id, true, 0, -1, file.name);
                pluginHost.Set_Palette(palette);
                return(Format.Palette);
            }
            else if (file.name.ToUpper().EndsWith(".NCL.L") && ext[0] != '\x10')
            {
                RawPalette palette = new RawPalette(file.path, file.id, true, 0, -1, file.name);
                pluginHost.Set_Palette(palette);
                return(Format.Palette);
            }


            // Tile
            ColorFormat depth = ColorFormat.colors256;

            if (pluginHost.Get_Palette().Loaded)
            {
                depth = pluginHost.Get_Palette().Depth;
            }

            if (file.name.ToUpper().EndsWith(".NTFT"))
            {
                RawImage image = new RawImage(file.path, file.id, TileForm.Lineal, depth, true, 0, -1, file.name);
                pluginHost.Set_Image(image);
                return(Format.Tile);
            }
            else if (ext == "RGCN" || ext == "RBCN")
            {
                NCGR ncgr = new NCGR(file.path, file.id, file.name);
                pluginHost.Set_Image(ncgr);
                return(Format.Tile);
            }
            else if (ext == "NCCG")
            {
                NCCG image = new NCCG(file.path, file.id, file.name);
                pluginHost.Set_Image(image);
                return(Format.Tile);
            }
            else if (file.name.ToUpper().EndsWith(".NBFC") || file.name.ToUpper().EndsWith(".CHAR"))
            {
                RawImage image = new RawImage(file.path, file.id, TileForm.Horizontal, depth, true, 0, -1, file.name);
                pluginHost.Set_Image(image);
                return(Format.Tile);
            }
            else if (file.name.ToUpper().EndsWith(".NCG.L") && ext[0] != '\x10')
            {
                RawImage image = new RawImage(file.path, file.id, TileForm.Horizontal, depth, true, 0, -1, file.name);
                pluginHost.Set_Image(image);
                return(Format.Tile);
            }

            // Map
            if (file.name.ToUpper().EndsWith(".NBFS"))
            {
                RawMap map = new RawMap(file.path, file.id, 0, -1, true, file.name);
                pluginHost.Set_Map(map);
                return(Format.Map);
            }
            else if (ext == "RCSN")
            {
                NSCR nscr = new NSCR(file.path, file.id, file.name);
                pluginHost.Set_Map(nscr);
                return(Format.Map);
            }
            else if (ext == "NCSC")
            {
                NCSC map = new NCSC(file.path, file.id, file.name);
                pluginHost.Set_Map(map);
                return(Format.Map);
            }
            else if (file.name.ToUpper().EndsWith(".NSC.L") && ext[0] != '\x10')
            {
                RawMap map = new RawMap(file.path, file.id, 0, -1, true, file.name);
                pluginHost.Set_Map(map);
                return(Format.Map);
            }

            // Sprite
            if (ext == "NCOB")
            {
                NCOB sprite = new NCOB(file.path, file.id, file.name);
                pluginHost.Set_Sprite(sprite);
                pluginHost.Set_Image(sprite.Image);
                return(Format.Cell);
            }
            else if (ext == "RECN")
            {
                NCER ncer = new NCER(file.path, file.id, file.name);
                pluginHost.Set_Sprite(ncer);
                return(Format.Cell);
            }

            // Animation
            if (ext == "RNAN")
            {
                nanr = new NANR(pluginHost, file.path, file.id);
                return(Format.Animation);
            }

            return(Format.Unknown);
        }
Пример #2
0
        public Format Read2(sFile file)
        {
            string ext = "";
            if (file.size >= 4)
            {
                using (BinaryReader br = new BinaryReader(File.OpenRead(file.path)))
                {
                    ext = new String(Encoding.ASCII.GetChars(br.ReadBytes(4)));
                    br.Close();
                }
            }

            // Palette
            if (file.name.ToUpper().EndsWith(".NTFP") || file.name.ToUpper().EndsWith(".PLT"))
            {
                RawPalette palette = new RawPalette(file.path, file.id, true, 0, -1, file.name);
                pluginHost.Set_Palette(palette);
                return Format.Palette;
            }
            else if (ext == "RLCN")
            {
                PaletteBase palette = new NCLR(file.path, file.id, file.name);
                pluginHost.Set_Palette(palette);
                return Format.Palette;
            }
            else if (ext == "NCCL")
            {
                NCCL palette = new NCCL(file.path, file.id, file.name);
                pluginHost.Set_Palette(palette);
                return Format.Palette;
            }
            else if (file.name.ToUpper().EndsWith(".NBFP"))
            {
                RawPalette palette = new RawPalette(file.path, file.id, true, 0, -1, file.name);
                pluginHost.Set_Palette(palette);
                return Format.Palette;
            }
            else if (file.name.ToUpper().EndsWith(".NCL.L") && ext[0] != '\x10')
            {
                RawPalette palette = new RawPalette(file.path, file.id, true, 0, -1, file.name);
                pluginHost.Set_Palette(palette);
                return Format.Palette;
            }

            // Tile
            ColorFormat depth = ColorFormat.colors256;
            if (pluginHost.Get_Palette().Loaded)
                depth = pluginHost.Get_Palette().Depth;

            if (file.name.ToUpper().EndsWith(".NTFT"))
            {

                RawImage image = new RawImage(file.path, file.id, TileForm.Lineal, depth, true, 0, -1, file.name);
                pluginHost.Set_Image(image);
                return Format.Tile;
            }
            else if (ext == "RGCN" || ext == "RBCN")
            {
                NCGR ncgr = new NCGR(file.path, file.id, file.name);
                pluginHost.Set_Image(ncgr);
                return Format.Tile;
            }
            else if (ext == "NCCG")
            {
                NCCG image = new NCCG(file.path, file.id, file.name);
                pluginHost.Set_Image(image);
                return Format.Tile;
            }
            else if (file.name.ToUpper().EndsWith(".NBFC") || file.name.ToUpper().EndsWith(".CHAR"))
            {
                RawImage image = new RawImage(file.path, file.id, TileForm.Horizontal, depth, true, 0, -1, file.name);
                pluginHost.Set_Image(image);
                return Format.Tile;
            }
            else if (file.name.ToUpper().EndsWith(".NCG.L") && ext[0] != '\x10')
            {
                RawImage image = new RawImage(file.path, file.id, TileForm.Horizontal, depth, true, 0, -1, file.name);
                pluginHost.Set_Image(image);
                return Format.Tile;
            }

            // Map
            if (file.name.ToUpper().EndsWith(".NBFS"))
            {
                RawMap map = new RawMap(file.path, file.id, 0, -1, true, file.name);
                pluginHost.Set_Map(map);
                return Format.Map;
            }
            else if (ext == "RCSN")
            {
                NSCR nscr = new NSCR(file.path, file.id, file.name);
                pluginHost.Set_Map(nscr);
                return Format.Map;
            }
            else if (ext == "NCSC")
            {
                NCSC map = new NCSC(file.path, file.id, file.name);
                pluginHost.Set_Map(map);
                return Format.Map;
            }
            else if (file.name.ToUpper().EndsWith(".NSC.L") && ext[0] != '\x10')
            {
                RawMap map = new RawMap(file.path, file.id, 0, -1, true, file.name);
                pluginHost.Set_Map(map);
                return Format.Map;
            }

            // Sprite
            if (ext == "NCOB")
            {
                NCOB sprite = new NCOB(file.path, file.id, file.name);
                pluginHost.Set_Sprite(sprite);
                pluginHost.Set_Image(sprite.Image);
                return Format.Cell;
            }
            else if (ext == "RECN")
            {
                NCER ncer = new NCER(file.path, file.id, file.name);
                pluginHost.Set_Sprite(ncer);
                return Format.Cell;
            }

            // Animation
            if (ext == "RNAN")
            {
                nanr = new NANR(pluginHost, file.path, file.id);
                return Format.Animation;
            }

            return Format.Unknown;
        }