Пример #1
0
        public void Read(FileReader reader)
        {
            string Signature = reader.ReadString(4, Encoding.ASCII);

            if (Signature != "FINF")
            {
                throw new Exception($"Invalid signature {Signature}! Expected FINF.");
            }
            Size              = reader.ReadUInt32();
            Type              = reader.ReadByte();
            Height            = reader.ReadByte();
            Width             = reader.ReadByte();
            Ascend            = reader.ReadByte();
            LineFeed          = reader.ReadUInt16();
            AlterCharIndex    = reader.ReadUInt16();
            DefaultLeftWidth  = reader.ReadByte();
            DefaultGlyphWidth = reader.ReadByte();
            DefaultCharWidth  = reader.ReadByte();
            CharEncoding      = reader.ReadByte();
            uint tglpOffset = reader.ReadUInt32();
            uint cwdhOffset = reader.ReadUInt32();
            uint cmapOffset = reader.ReadUInt32();

            tglp = new TGLP();
            using (reader.TemporarySeek(tglpOffset - 8, SeekOrigin.Begin))
            {
                tglp.Read(reader);
            }
        }
Пример #2
0
        public void Load(TGLP texture, int Index)
        {
            CanReplace = true;

            SheetIndex  = Index;
            TextureTGLP = texture;
            Height      = TextureTGLP.SheetHeight;
            Width       = TextureTGLP.SheetWidth;
            var BFNTFormat = (CTR_3DS.PICASurfaceFormat)TextureTGLP.Format;

            Format = CTR_3DS.ConvertPICAToGenericFormat(BFNTFormat);

            if (Format == TEX_FORMAT.A4)
            {
                RedChannel   = STChannelType.Alpha;
                GreenChannel = STChannelType.Alpha;
                BlueChannel  = STChannelType.Alpha;
                AlphaChannel = STChannelType.Alpha;
            }

            PlatformSwizzle = PlatformSwizzle.Platform_3DS;

            ImageKey         = "Texture";
            SelectedImageKey = "Texture";
        }
Пример #3
0
        public void Load(TGLP texture, int Index)
        {
            CanReplace = true;

            SheetIndex  = Index;
            TextureTGLP = texture;
            Height      = TextureTGLP.SheetHeight;
            Width       = TextureTGLP.SheetWidth;
            var BFNTFormat = (Gx2ImageFormats)TextureTGLP.Format;

            Format = ConvertToGeneric(BFNTFormat);

            ImageKey         = "Texture";
            SelectedImageKey = "Texture";
        }
Пример #4
0
        private static YamlMappingNode SaveTextureGlyph(TGLP texInfo)
        {
            YamlMappingNode mapping = new YamlMappingNode();

            mapping.Add("Cell_Height", texInfo.CellHeight.ToString());
            mapping.Add("Cell_Width", texInfo.CellWidth.ToString());
            mapping.Add("Format", texInfo.Format.ToString());
            mapping.Add("BaseLinePos", texInfo.BaseLinePos.ToString());
            mapping.Add("MaxCharWidth", texInfo.MaxCharWidth.ToString());
            mapping.Add("Sheet_Height", texInfo.SheetHeight.ToString());
            mapping.Add("Sheet_Width", texInfo.SheetWidth.ToString());
            mapping.Add("RowCount", texInfo.RowCount.ToString());
            mapping.Add("ColumnCount", texInfo.ColumnCount.ToString());
            return(mapping);
        }
Пример #5
0
        public void Load(System.IO.Stream stream)
        {
            FFNT bffnt = new FFNT();

            bffnt.Read(new FileReader(stream));

            TGLP tglp = bffnt.finf.tglp;

            int i = 0;

            foreach (byte[] texture in tglp.SheetDataList)
            {
                SheetEntry sheet = new SheetEntry();
                sheet.data = texture;
                sheet.Text = "Sheet" + i++;
            }
        }
Пример #6
0
        public void Load()
        {
            IsActive = true;
            FFNT bffnt = new FFNT();

            bffnt.Read(new FileReader(new MemoryStream(Data)));

            TGLP tglp = bffnt.finf.tglp;

            int i = 0;

            foreach (byte[] texture in tglp.SheetDataList)
            {
                SheetEntry sheet = new SheetEntry();
                sheet.data = texture;
                sheet.Text = "Sheet" + i++;
            }
        }
Пример #7
0
        public void Load(System.IO.Stream stream)
        {
            Text = FileName;

            bffnt = new FFNT();
            bffnt.Read(new FileReader(stream));

            TGLP tglp = bffnt.GetFontSection().tglp;

            var textureFolder = new TreeNode("Textures");

            Nodes.Add(textureFolder);
            if (tglp.SheetDataList.Count > 0)
            {
                var bntx = STFileLoader.OpenFileFormat("Sheet_0", Utils.CombineByteArray(tglp.SheetDataList.ToArray()));
                if (bntx != null)
                {
                    textureFolder.Nodes.Add((BNTX)bntx);
                }
                else
                {
                    for (int s = 0; s < tglp.SheetDataList.Count; s++)
                    {
                        var surface = new Gx2ImageBlock();
                        surface.Text = $"Sheet_{s}";
                        surface.Load(tglp, s);
                        textureFolder.Nodes.Add(surface);
                    }
                }
            }


            int i = 0;

            foreach (byte[] texture in tglp.SheetDataList)
            {
                //   BNTX file = (BNTX)STFileLoader.OpenFileFormat("Sheet" + i++, texture);
                //  Nodes.Add(file);
            }
        }
Пример #8
0
        public void Load()
        {
            IsActive = true;
            FFNT bffnt = new FFNT();

            bffnt.Read(new FileReader(new MemoryStream(Data)));

            TGLP tglp = bffnt.finf.tglp;

            EditorRoot = new TreeNodeFile(FileName, this);

            int i = 0;

            foreach (byte[] texture in tglp.SheetDataList)
            {
                SheetEntry sheet = new SheetEntry();
                sheet.data = texture;
                sheet.Text = "Sheet" + i++;

                EditorRoot.Nodes.Add(sheet);
            }
        }
Пример #9
0
        public void Load(TGLP texture, int Index)
        {
            CanReplace = true;

            SheetIndex  = Index;
            TextureTGLP = texture;
            Height      = TextureTGLP.SheetHeight;
            Width       = TextureTGLP.SheetWidth;
            var BFNTFormat = (Decode_Gamecube.TextureFormats)TextureTGLP.Format;

            Format = Decode_Gamecube.ToGenericFormat(BFNTFormat);

            if (Format == TEX_FORMAT.A4)
            {
                AlphaChannel = STChannelType.Red;
            }

            PlatformSwizzle = PlatformSwizzle.Platform_Gamecube;

            ImageKey         = "Texture";
            SelectedImageKey = "Texture";
        }
Пример #10
0
        public void Load(TGLP texture, int Index)
        {
            CanReplace = true;

            SheetIndex  = Index;
            TextureTGLP = texture;
            Height      = TextureTGLP.SheetHeight;
            Width       = TextureTGLP.SheetWidth;
            MipCount    = 1;
            var BFNTFormat = (Gx2ImageFormats)TextureTGLP.Format;

            Format = ConvertToGeneric(BFNTFormat);
            if (Format == TEX_FORMAT.BC4_UNORM)
            {
                RedChannel   = STChannelType.One;
                GreenChannel = STChannelType.One;
                BlueChannel  = STChannelType.One;
                AlphaChannel = STChannelType.Red;
            }

            ImageKey         = "Texture";
            SelectedImageKey = "Texture";
        }
Пример #11
0
        public void Load(System.IO.Stream stream)
        {
            CanSave = true;

            bffnt = new FFNT();
            bffnt.Read(new FileReader(stream));

            TGLP tglp = bffnt.FontSection.TextureGlyph;

            if (tglp.SheetDataList.Count > 0)
            {
                var bntx = STFileLoader.OpenFileFormat("Sheet_0", Utils.CombineByteArray(tglp.SheetDataList.ToArray()));
                if (bntx != null)
                {
                    tglp.BinaryTextureFile = (BNTX)bntx;
                }
                else
                {
                    for (int s = 0; s < tglp.SheetDataList.Count; s++)
                    {
                        var surface = new Gx2ImageBlock();
                        surface.Text = $"Sheet_{s}";
                        surface.Load(tglp, s);
                        tglp.Gx2Textures.Add(surface);
                    }
                }
            }

            int i = 0;

            foreach (byte[] texture in tglp.SheetDataList)
            {
                //   BNTX file = (BNTX)STFileLoader.OpenFileFormat("Sheet" + i++, texture);
                //  Nodes.Add(file);
            }
        }
Пример #12
0
        public void Load(System.IO.Stream stream)
        {
            PluginRuntime.BxfntFiles.Add(this);

            CanSave = true;

            bffnt = new FFNT();
            bffnt.Read(new FileReader(stream));

            TGLP tglp = bffnt.FontSection.TextureGlyph;

            if (tglp.SheetDataList.Count > 0)
            {
                if (bffnt.Platform == FFNT.PlatformType.NX)
                {
                    var bntx = STFileLoader.OpenFileFormat(
                        new MemoryStream(Utils.CombineByteArray(tglp.SheetDataList.ToArray())), "Sheet_0");
                    if (bntx != null)
                    {
                        tglp.BinaryTextureFile = (BNTX)bntx;
                    }
                }
                else if (bffnt.Platform == FFNT.PlatformType.Cafe)
                {
                    for (int s = 0; s < tglp.SheetDataList.Count; s++)
                    {
                        var surface = new Gx2ImageBlock();
                        surface.Text = $"Sheet_{s}";
                        surface.Load(tglp, s);
                        tglp.Textures.Add(surface);
                    }
                }
                else if (bffnt.Platform == FFNT.PlatformType.Ctr)
                {
                    for (int s = 0; s < tglp.SheetDataList.Count; s++)
                    {
                        var surface = new CtrImageBlock();
                        surface.Text = $"Sheet_{s}";
                        surface.Load(tglp, s);
                        surface.GetBitmap().Save($"Image{s}.png");
                        tglp.Textures.Add(surface);
                    }
                }
                else
                {
                    for (int s = 0; s < tglp.SheetDataList.Count; s++)
                    {
                        var surface = new RevImageBlock();
                        surface.Text = $"Sheet_{s}";
                        surface.Load(tglp, s);
                        surface.GetBitmap().Save($"Image{s}.png");
                        tglp.Textures.Add(surface);
                    }
                }
            }

            int i = 0;

            foreach (byte[] texture in tglp.SheetDataList)
            {
                //   BNTX file = (BNTX)STFileLoader.OpenFileFormat("Sheet" + i++, texture);
                //  Nodes.Add(file);
            }
        }
Пример #13
0
        public void Read(FileReader reader, FFNT header)
        {
            CharacterWidths = new List <CWDH>();
            CodeMaps        = new List <CMAP>();

            string Signature = reader.ReadString(4, Encoding.ASCII);

            if (Signature != "FINF")
            {
                throw new Exception($"Invalid signature {Signature}! Expected FINF.");
            }
            Size = reader.ReadUInt32();

            if (header.Platform <= FFNT.PlatformType.Ctr && header.Version < 0x04000000)
            {
                Type              = reader.ReadEnum <FontType>(true);
                LineFeed          = reader.ReadByte();
                AlterCharIndex    = reader.ReadUInt16();
                DefaultLeftWidth  = reader.ReadByte();
                DefaultGlyphWidth = reader.ReadByte();
                DefaultCharWidth  = reader.ReadByte();
                CharEncoding      = reader.ReadEnum <CharacterCode>(true);
                uint tglpOffset = reader.ReadUInt32();
                uint cwdhOffset = reader.ReadUInt32();
                uint cmapOffset = reader.ReadUInt32();

                Height = reader.ReadByte();
                Width  = reader.ReadByte();
                Ascent = reader.ReadByte();
                reader.ReadByte(); //Padding

                //Add counter for TGLP
                //Note the other counters are inside sections due to recusive setup
                header.BlockCounter += 1;

                TextureGlyph = new TGLP();
                using (reader.TemporarySeek(tglpOffset - 8, SeekOrigin.Begin))
                    TextureGlyph.Read(reader, header);

                CharacterWidth = new CWDH();
                CharacterWidths.Add(CharacterWidth);
                using (reader.TemporarySeek(cwdhOffset - 8, SeekOrigin.Begin))
                    CharacterWidth.Read(reader, header, CharacterWidths);

                CodeMap = new CMAP();
                CodeMaps.Add(CodeMap);
                using (reader.TemporarySeek(cmapOffset - 8, SeekOrigin.Begin))
                    CodeMap.Read(reader, header, CodeMaps);
            }
            else
            {
                Type              = reader.ReadEnum <FontType>(true);
                Height            = reader.ReadByte();
                Width             = reader.ReadByte();
                Ascent            = reader.ReadByte();
                LineFeed          = reader.ReadUInt16();
                AlterCharIndex    = reader.ReadUInt16();
                DefaultLeftWidth  = reader.ReadByte();
                DefaultGlyphWidth = reader.ReadByte();
                DefaultCharWidth  = reader.ReadByte();
                CharEncoding      = reader.ReadEnum <CharacterCode>(true);
                uint tglpOffset = reader.ReadUInt32();
                uint cwdhOffset = reader.ReadUInt32();
                uint cmapOffset = reader.ReadUInt32();

                //Add counter for TGLP
                //Note the other counters are inside sections due to recusive setup
                header.BlockCounter += 1;

                TextureGlyph = new TGLP();
                using (reader.TemporarySeek(tglpOffset - 8, SeekOrigin.Begin))
                    TextureGlyph.Read(reader, header);

                CharacterWidth = new CWDH();
                CharacterWidths.Add(CharacterWidth);
                using (reader.TemporarySeek(cwdhOffset - 8, SeekOrigin.Begin))
                    CharacterWidth.Read(reader, header, CharacterWidths);

                CodeMap = new CMAP();
                CodeMaps.Add(CodeMap);
                using (reader.TemporarySeek(cmapOffset - 8, SeekOrigin.Begin))
                    CodeMap.Read(reader, header, CodeMaps);
            }
        }