Exemplo n.º 1
0
        public static void UpdateRoomOrder(GMWAD w)
        {
            var l_int = w.Header.RoomOrderInt;
            var l_rm  = w.Header.RoomOrder;
            var num   = w.Header.RoomOrderCount;

            for (int r = 0; r < num; r++)
            {
                l_rm.Add(w.Rooms.Items[l_int[r]]);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets GMTextureBlob reference in all classes that have it.
        /// </summary>
        /// <param name="w">GMWAD class</param>
        public static void SetTextureReference(GMWAD w)
        {
            int i; // iterator integer.

            // Sprites.
            for (i = 0; i < w.Sprites.Items.Count; i++)
            {
                var _s = w.Sprites.Items[i];
                if (_s == null)
                {
                    continue;
                }

                // Loop through all sprite frames.
                for (int j = 0; j < _s.ImageCount; j++)
                {
                    var _t = _s.ImageTextures[j];
                    _t.Texture = w.TextureBlobs.Items[_t.TexID];
                    _t.Crop();
                }
            }

            // Backgrounds.
            for (i = 0; i < w.Backgrounds.Items.Count; i++)
            {
                var _b = w.Backgrounds.Items[i];
                if (_b == null)
                {
                    continue;
                }

                _b.Texture.Texture = w.TextureBlobs.Items[_b.Texture.TexID];
                _b.Texture.Crop();
            }

            // Fonts.
            for (i = 0; i < w.Fonts.Items.Count; i++)
            {
                var _f = w.Fonts.Items[i];
                if (_f == null)
                {
                    continue;
                }

                _f.Texture.Texture = w.TextureBlobs.Items[_f.Texture.TexID];
                _f.Texture.Crop();
            }
        }
Exemplo n.º 3
0
        public static void UpdateParents(GMWAD w)
        {
            for (int o = 0; o < w.Objects.Items.Count; o++)
            {
                var oo = w.Objects.Items[o];
                if (oo == null)
                {
                    continue;
                }

                if (oo.ParentIndex > -1)
                {
                    oo.Parent = w.Objects.Items[oo.ParentIndex];
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Tags all backgrounds in GMWAD as tilesets if they are used in rooms' tiles.
        /// </summary>
        /// <param name="w">GMWAD class</param>
        public static void TagBackgroundTilesets(GMWAD w)
        {
            for (int i = 0; i < w.Rooms.Items.Count; i++)
            {
                var r = w.Rooms.Items[i];
                if (r == null)
                {
                    continue;
                }

                for (int j = 0; j < r.Tiles.Count; j++)
                {
                    var t = r.Tiles[j];
                    t.Background.IsTileset = true;
                }
            }
        }
Exemplo n.º 5
0
        public GMTPAGEntry(BinaryReader binaryReader, GMWAD w)
        {
            X          = binaryReader.ReadInt16();
            Y          = binaryReader.ReadInt16();
            Width      = binaryReader.ReadInt16();
            Height     = binaryReader.ReadInt16();
            XOffset    = binaryReader.ReadInt16();
            YOffset    = binaryReader.ReadInt16();
            CropWidth  = binaryReader.ReadInt16();
            CropHeight = binaryReader.ReadInt16();
            OWidth     = binaryReader.ReadInt16();
            OHeight    = binaryReader.ReadInt16();
            TexID      = binaryReader.ReadInt16();

            //Does when calling Crop()
            //Texture = w.TextureBlobs.Items[TexID];
        }
Exemplo n.º 6
0
        public GMKVPChunkBase(BinaryReader binaryReader, GMWAD p = null) : base(binaryReader)
        {
            WADPtr = p;
            MakeList();
            int num_items = binaryReader.ReadInt32();

            for (int i = 0; i < num_items; i++)
            {
                uint pos  = binaryReader.ReadUInt32();
                long addr = binaryReader.BaseStream.Position;
                if (pos != 0)
                {
                    binaryReader.BaseStream.Position = pos;
                    ReadItem(binaryReader);
                    binaryReader.BaseStream.Position = addr;
                }
                else
                {
                    Output.Print("Pointer is 0???");
                    NullItem();
                    // IT IS INTENTIONALLY ZERO WHEN THE RESOURCE IS F*****G UNALIGNED!
                }
            }
        }
Exemplo n.º 7
0
 public GMSprites(BinaryReader binaryReader, GMWAD g) : base(binaryReader, g)
 {
     CheckHeader("SPRT");
     FixChunkAddr(binaryReader);
 }
Exemplo n.º 8
0
        public GMSprite(BinaryReader binaryReader, GMWAD w)
        {
            Name        = new GMString(binaryReader);
            Width       = binaryReader.ReadInt32();
            Height      = binaryReader.ReadInt32();
            BBoxLeft    = binaryReader.ReadInt32();
            BBoxRight   = binaryReader.ReadInt32();
            BBoxBottom  = binaryReader.ReadInt32();
            BBoxTop     = binaryReader.ReadInt32();
            Transparent = ReadBool(binaryReader);
            Smooth      = ReadBool(binaryReader);
            Preload     = ReadBool(binaryReader);
            int mode = binaryReader.ReadInt32();

            BBoxMode   = (MaskShape)mode;
            ColCheck   = ReadBool(binaryReader);
            XOrigin    = binaryReader.ReadInt32();
            YOrigin    = binaryReader.ReadInt32();
            ImageCount = binaryReader.ReadInt32();
            if (ImageCount != 0)
            {
                ImageTextures = new List <GMTPAGEntry>(ImageCount);
                for (int img = 0; img < ImageCount; img++)
                {
                    uint addr = binaryReader.ReadUInt32();
                    if (addr != 0)
                    {
                        long prev_addr = binaryReader.BaseStream.Position;
                        binaryReader.BaseStream.Position = addr;
                        var item = new GMTPAGEntry(binaryReader, w);
                        binaryReader.BaseStream.Position = prev_addr;
                        ImageTextures.Add(item);
                    }
                    else
                    {
                        ImageTextures.Add(null);
                    }
                }
            }
            else
            {
                ImageTextures = null;
            }
            MasksCount = binaryReader.ReadInt32();
            if (MasksCount != 0)
            {
                MaskData = new List <byte[]>(MasksCount);
                for (int msk = 0; msk < MasksCount; msk++)
                {
                    int    size = CalculateMaskSize(Width, Height);
                    byte[] data = binaryReader.ReadBytes(size);
                    MaskData.Add(data);
                }
            }
            else
            {
                MaskData = null;
            }

            // this is happening in Karoshi...
            if (ImageCount != MasksCount)
            {
                Output.Print($"Sprite {Name}'s ImageCount and MaskCount do not match. {ImageCount} | {MasksCount}");
            }
        }