Ejemplo n.º 1
0
        private static TextureOffsets Write_Textures(Stream s, Theme b)
        {
            TextureOffsets offsets = new TextureOffsets();

            // Top
            if (b.Flags.TopDrawType == TopDrawType.Texture
                && b.Textures.Top.Format != RawTexture.DataFormat.Invalid)
            {
                offsets.Top = (uint) s.Position;
                var data = b.Textures.Top.Data;
                s.Write(data, 0, data.Length);
            }
            else if (b.Flags.TopDrawType == TopDrawType.SolidColorTexture
                     && b.Textures.Top.Format != RawTexture.DataFormat.Invalid)
            {
                offsets.Top = (uint) s.Position;
                var data = b.Textures.Top.Data;
                s.Write(data, 0, data.Length);
            }

            // Top Ext
            if (b.Flags.TopDrawType == TopDrawType.SolidColorTexture
                     && b.Textures.TopExt.Format != RawTexture.DataFormat.Invalid)
            {
                offsets.TopExt = (uint)s.Position;
                var data = b.Textures.TopExt.Data;
                s.Write(data, 0, data.Length);
            }

            // Bottom
            if (b.Flags.BottomDrawType == BottomDrawType.Texture
                && b.Textures.Bottom.Format != RawTexture.DataFormat.Invalid)
            {
                offsets.Bottom = (uint) s.Position;
                var data = b.Textures.Bottom.Data;
                s.Write(data, 0, data.Length);
            }

            // Folder
            if (b.Flags.FolderTexture
                && b.Textures.FolderClosed.Format != RawTexture.DataFormat.Invalid
                && b.Textures.FolderOpen.Format != RawTexture.DataFormat.Invalid)
            {
                offsets.FolderClosed = (uint) s.Position;
                var data = b.Textures.FolderClosed.Data;
                s.Write(data, 0, data.Length);

                offsets.FolderOpen = (uint) s.Position;
                data = b.Textures.FolderOpen.Data;
                s.Write(data, 0, data.Length);
            }

            // Files
            if (b.Flags.FileTexture
                && b.Textures.FileLarge.Format != RawTexture.DataFormat.Invalid
                && b.Textures.FileSmall.Format != RawTexture.DataFormat.Invalid)
            {
                offsets.FileLarge = (uint) s.Position;
                var data = b.Textures.FileLarge.Data;
                s.Write(data, 0, data.Length);

                offsets.FileSmall = (uint) s.Position;
                data = b.Textures.FileSmall.Data;
                s.Write(data, 0, data.Length);
            }

            return offsets;
        }
Ejemplo n.º 2
0
 private static void Write_Flags
     (Stream s, Theme body, TextureOffsets tOff, ColorOffsets cOff, uint wOff)
 {
     using (BinaryWriter bw = new BinaryWriter(s, Encoding.ASCII, true))
     {
         // Version
         bw.Write(1);
         // BGM Flag
         bw.Write((byte) 0);
         bw.Write((byte) (body.Flags.BackgroundMusic ? 1 : 0));
         bw.Write((byte) 0);
         bw.Write((byte) 0);
         // Unkown
         bw.Write((uint) 0);
         // Top Screen
         bw.Write((uint) body.Flags.TopDrawType);
         bw.Write((uint) body.Flags.TopFrameType);
         bw.Write((uint) cOff.TopBackground);
         bw.Write((uint) tOff.Top);
         bw.Write((uint) tOff.TopExt);
         // Bottom Screen
         bw.Write((uint) body.Flags.BottomDrawType);
         bw.Write((uint) body.Flags.BottomFrameType);
         bw.Write((uint) tOff.Bottom);
         // Cursor
         bw.Write((uint) (body.Flags.CursorColor ? 1 : 0));
         bw.Write((uint) cOff.Cursor);
         // 3D Folder
         bw.Write((uint) (body.Flags.FolderColor ? 1 : 0));
         bw.Write((uint) cOff.Folder);
         // 2D Folder
         bw.Write((uint) (body.Flags.FolderTexture ? 1 : 0));
         bw.Write((uint) tOff.FolderClosed);
         bw.Write((uint) tOff.FolderOpen);
         // 3D File
         bw.Write((uint) (body.Flags.FileColor ? 1 : 0));
         bw.Write((uint) cOff.File);
         // 2D File
         bw.Write((uint) (body.Flags.FileTexture ? 1 : 0));
         bw.Write((uint) tOff.FileLarge);
         bw.Write((uint) tOff.FileSmall);
         // Arrow Button
         bw.Write((uint) (body.Flags.ArrowButtonColor ? 1 : 0));
         bw.Write((uint) cOff.ArrowButton);
         // Arrow
         bw.Write((uint) (body.Flags.ArrowColor ? 1 : 0));
         bw.Write((uint) cOff.Arrow);
         // Open Close
         bw.Write((uint) (body.Flags.OpenCloseColor ? 1 : 0));
         bw.Write((uint) cOff.Open);
         bw.Write((uint) cOff.Close);
         // Game Text
         bw.Write((uint) body.Flags.GameTextDrawType);
         bw.Write((uint) cOff.GameText);
         // Bottom Solid
         bw.Write((uint) (body.Flags.BottomBackgroundInnerColor ? 1 : 0));
         bw.Write((uint) cOff.BottomSolid);
         // Bottom Outer
         bw.Write((uint) (body.Flags.BottomBackgroundOuterColor ? 1 : 0));
         bw.Write((uint) cOff.BottomOuter);
         // Folder BG
         bw.Write((uint) (body.Flags.FolderBackgroundColor ? 1 : 0));
         bw.Write((uint) cOff.FolderBackground);
         // Folder Arrow
         bw.Write((uint) (body.Flags.FolderArrowColor ? 1 : 0));
         bw.Write((uint) cOff.FolderArrow);
         // Bottom Corner
         bw.Write((uint) (body.Flags.BottomCornerButtonColor ? 1 : 0));
         bw.Write((uint) cOff.BottomCornerButton);
         // Top Corner
         bw.Write((uint) (body.Flags.TopCornerButtonColor ? 1 : 0));
         bw.Write((uint) cOff.TopCornerButton);
         // Demo Text
         bw.Write((uint) (body.Flags.DemoTextColor ? 1 : 0));
         bw.Write((uint) cOff.DemoText);
         // SFX
         bw.Write((uint) (body.Flags.SoundEffect ? 1 : 0));
         bw.Write((uint) body.CWAV.Length);
         bw.Write((uint) wOff);
     }
 }
Ejemplo n.º 3
0
        private static Textures Read_Textures(Stream s, Flags flags, TextureOffsets offsets)
        {
            var texes = new Textures();
            using (var br = new BinaryReader(s, Encoding.ASCII, true))
            {
                // Top
                if (flags.TopDrawType == TopDrawType.Texture)
                {
                    s.Position = offsets.Top;
                    switch (flags.TopFrameType)
                    {
                        case TopFrameType.Single:
                            texes.Top = new RawTexture(512, 256, RawTexture.DataFormat.Bgr565);
                            break;
                        case TopFrameType.SlowScroll:
                        case TopFrameType.FastScroll:
                            texes.Top = new RawTexture(1024, 256, RawTexture.DataFormat.Bgr565);
                            break;
                        default:
                            throw new ArgumentException("Invalid Texture Format",
                                nameof(flags) + "." + nameof(flags.TopFrameType));
                    }
                    texes.Top.Read(s);
                    texes.TopExt = new RawTexture();
                }
                else if (flags.TopDrawType == TopDrawType.SolidColorTexture)
                {
                    s.Position = offsets.Top;
                    texes.Top = new RawTexture(64, 64, RawTexture.DataFormat.A8);
                    texes.Top.Read(s);
                    if (offsets.TopExt != 0)
                    {
                        s.Position = offsets.TopExt;
                        texes.TopExt = new RawTexture(64, 64, RawTexture.DataFormat.A8);
                        texes.TopExt.Read(s);
                    }
                    else
                    {
                        texes.TopExt = new RawTexture();
                    }
                }
                else
                {
                    texes.Top = new RawTexture();
                    texes.TopExt = new RawTexture();
                }

                // Bottom
                if (flags.BottomDrawType == BottomDrawType.Texture)
                {
                    s.Position = offsets.Bottom;
                    switch (flags.BottomFrameType)
                    {
                        case BottomFrameType.Single:
                            texes.Bottom = new RawTexture(512, 256, RawTexture.DataFormat.Bgr565);
                            break;
                        case BottomFrameType.SlowScroll:
                        case BottomFrameType.FastScroll:
                        case BottomFrameType.BounceScroll:
                        case BottomFrameType.PageScroll:
                            texes.Bottom = new RawTexture(1024, 256, RawTexture.DataFormat.Bgr565);
                            break;
                        default:
                            throw new ArgumentException("Invalid Texture Format",
                                nameof(flags) + "." + nameof(flags.BottomFrameType));
                    }
                    texes.Bottom.Read(s);
                }
                else
                {
                    texes.Bottom = new RawTexture();
                }

                if (flags.FolderTexture)
                {
                    // Folder Closed
                    s.Position = offsets.FolderClosed;
                    texes.FolderClosed = new RawTexture(128, 64, RawTexture.DataFormat.Bgr888);
                    texes.FolderClosed.Read(s);

                    // Folder Open
                    s.Position = offsets.FolderOpen;
                    texes.FolderOpen = new RawTexture(128, 64, RawTexture.DataFormat.Bgr888);
                    texes.FolderOpen.Read(s);
                }
                else
                {
                    texes.FolderOpen = new RawTexture();
                    texes.FolderClosed = new RawTexture();
                }

                if (flags.FileTexture)
                {
                    // Folder Closed
                    s.Position = offsets.FileLarge;
                    texes.FileLarge = new RawTexture(64, 128, RawTexture.DataFormat.Bgr888);
                    texes.FileLarge.Read(s);

                    // Folder Open
                    s.Position = offsets.FileSmall;
                    texes.FileSmall = new RawTexture(32, 64, RawTexture.DataFormat.Bgr888);
                    texes.FileSmall.Read(s);
                }
                else
                {
                    texes.FileLarge = new RawTexture();
                    texes.FileSmall = new RawTexture();
                }
            }
            return texes;
        }
Ejemplo n.º 4
0
        private static TextureOffsets Read_TextureOffsets(Stream s, Flags flags)
        {
            var offsets = new TextureOffsets();

            using (var br = new BinaryReader(s, Encoding.ASCII, true))
            {

                {
                    s.Position = 0x18;
                    offsets.Top = br.ReadUInt32();
                    offsets.TopExt = br.ReadUInt32();
                }

                {
                    s.Position = 0x28;
                    offsets.Bottom = br.ReadUInt32();
                }

                {
                    s.Position = 0x40;
                    offsets.FolderClosed = br.ReadUInt32();
                    offsets.FolderOpen = br.ReadUInt32();
                }

                {
                    s.Position = 0x54;
                    offsets.FileLarge = br.ReadUInt32();
                    offsets.FileSmall = br.ReadUInt32();
                }
            }
            return offsets;
        }