public GMBackground(ProjectReader reader)
        {
            Name         = reader.ReadString();
            LastChanged  = reader.ReadDate();
            Version      = reader.ReadInt32(); // version that we don't care about here.
            UseAsTileset = reader.ReadBoolean();
            TileWidth    = reader.ReadInt32();
            TileHeight   = reader.ReadInt32();
            OffsetH      = reader.ReadInt32();
            OffsetV      = reader.ReadInt32();
            SepH         = reader.ReadInt32();
            SepV         = reader.ReadInt32();
            FrameVersion = reader.ReadInt32(); // frame version
            int Width, Height;

            Width      = reader.ReadInt32();
            Height     = reader.ReadInt32();
            Background = null;
            if (Width * Height != 0)
            {
                Background = reader.ReadBGRAImage(Width, Height);
            }

            reader.Dispose();
        }
Exemple #2
0
        public GMPath(ProjectReader reader)
        {
            Name            = reader.ReadString();
            LastChanged     = reader.ReadDate();
            Version         = reader.ReadInt32();
            Smooth          = reader.ReadBoolean();
            Closed          = reader.ReadBoolean();
            Precision       = reader.ReadUInt32();
            _BackgroundRoom = reader.ReadInt32();

            int _x = reader.ReadInt32();
            int _y = reader.ReadInt32();

            Snap = new Point(_x, _y);

            int pointcnt = reader.ReadInt32();

            Points = new List <PathPoint>(pointcnt);
            for (int i = 0; i < pointcnt; i++)
            {
                double _px     = reader.ReadDouble();
                double _py     = reader.ReadDouble();
                double _pspeed = reader.ReadDouble();
                Points.Add(new PathPoint(_px, _py, _pspeed));
            }

            reader.Dispose();
        }
Exemple #3
0
        public GMObject(ProjectReader reader, GMProject proj)
        {
            Name        = reader.ReadString();
            LastChanged = reader.ReadDate();
            Version     = reader.ReadInt32();
            if (Version != 430)
            {
                throw new InvalidDataException("Invalid Object version, got " + Version);
            }
            Sprite = null;
            int spr = reader.ReadInt32();

            if (spr > -1)
            {
                Sprite = proj.Sprites[spr];
            }

            Solid      = reader.ReadBoolean();
            Visible    = reader.ReadBoolean();
            Depth      = reader.ReadInt32();
            Persistent = reader.ReadBoolean();
            Parent     = null;
            _ParentInd = reader.ReadInt32();
            Mask       = null;
            int mask = reader.ReadInt32();

            if (mask > -1)
            {
                Mask = proj.Sprites[mask];
            }

            int ev_count = reader.ReadInt32();

            Events = new List <List <GMEvent> >(ev_count + 1);
            for (int i = 0; i <= ev_count; i++)
            {
                var  l    = new List <GMEvent>();
                bool done = false;
                while (!done)
                {
                    int first = reader.ReadInt32();
                    if (first != -1)
                    {
                        var ev = new GMEvent(reader);
                        ev.Key = first;
                        l.Add(ev);
                    }
                    else
                    {
                        done = true;
                    }
                }
                Events.Add(l);
            }

            reader.Dispose();
        }
Exemple #4
0
        public GMScript(ProjectReader reader)
        {
            Name        = reader.ReadString();
            LastChanged = reader.ReadDate();
            Version     = reader.ReadInt32();
            if (Version != 800)
            {
                throw new InvalidDataException("This library only supports .gmk GM8.0 files.");
            }
            Code = reader.ReadString();

            reader.Dispose();
        }
Exemple #5
0
        public GMSprite(ProjectReader reader)
        {
            Name        = reader.ReadString();
            LastChanged = reader.ReadDate();
            Version     = reader.ReadInt32();
            if (Version != 800)
            {
                throw new InvalidDataException("This library only supports .gmk GM8.0 files.");
            }

            int _x = reader.ReadInt32();
            int _y = reader.ReadInt32();

            Origin = new Point(_x, _y);

            int framenum = reader.ReadInt32();

            Subimages = new List <Image>(framenum);
            for (int i = 0; i < framenum; i++)
            {
                int framever = reader.ReadInt32();
                if (framever != 800)
                {
                    throw new InvalidDataException("This library only supports .gmk GM8.0 files.");
                }
                Width  = reader.ReadInt32();
                Height = reader.ReadInt32();
                if (Width * Height != 0)
                {
                    Subimages.Add(reader.ReadBGRAImage(Width, Height));
                }
                else
                {
                    Subimages.Add(null);  // ????
                }
            }

            MaskMode       = (SpriteMaskMode)reader.ReadInt32();
            AlphaTolerance = reader.ReadInt32();
            SeparateMasks  = reader.ReadBoolean();
            BBoxMode       = (SpriteBBoxMode)reader.ReadInt32();

            int _l = reader.ReadInt32();
            int _r = reader.ReadInt32();
            int _b = reader.ReadInt32();
            int _t = reader.ReadInt32();

            BBox = new Rectangle(_l, _r, _b, _t);

            reader.Dispose();
        }
Exemple #6
0
        public void Load(ProjectReader reader)
        {
            int magic = reader.ReadInt32();

            if (magic != GMProject.GMMagic)
            {
                throw new Exception("Invalid GEX magic, got " + magic);
            }

            Version = reader.ReadInt32();
            if (Version != 701)
            {
                throw new Exception("Invalid GEX version, got " + Version);
            }

            Seed = reader.ReadInt32();
            Lookup(Seed);

            // Decrypt GED/DAT
            var gedStream = new MemoryStream();

            gedStream.WriteByte((byte)reader.ReadByte()); // first byte is never encrypted.

            while (true)
            {
                int bb = reader.ReadByte();
                if (bb < 0)
                {
                    break;
                }

                // non-additive mode.
                gedStream.WriteByte(GMKrypt[1][(byte)bb]);
            }

            gedStream.Seek(0, SeekOrigin.Begin);
            var gedReader = new ProjectReader(gedStream);

            Package = new GED();
            Package.Load(gedReader);

            RawDATs = new List <byte[]>(Package.Files.Count);
            for (int i = 0; i < Package.Files.Count; i++)
            {
                //if (Package.Files[i].Kind != GEDFile.GEDFileKind.ActionLib) // ???????????????????????????
                RawDATs.Add(gedReader.ReadCompressedStream());
            }

            gedStream.Dispose();
            gedReader.Dispose();
        }
Exemple #7
0
        public GMTimeline(ProjectReader reader)
        {
            Name        = reader.ReadString();
            LastChanged = reader.ReadDate();
            Version     = reader.ReadInt32();

            int momentcount = reader.ReadInt32();

            Moments = new List <TimelineMoment>(momentcount);
            for (int i = 0; i < momentcount; i++)
            {
                Moments.Add(new TimelineMoment(reader));
            }

            reader.Dispose();
        }
        public GMGameInformation(ProjectReader reader)
        {
            BackgroundColor = reader.ReadColor();
            SeparateWindow  = reader.ReadBoolean();
            Caption         = reader.ReadString();
            int _l, _t, _w, _h;

            _l          = reader.ReadInt32();
            _t          = reader.ReadInt32();
            _w          = reader.ReadInt32();
            _h          = reader.ReadInt32();
            Position    = new Rectangle(_l, _t, _w, _h);
            ShowBorder  = reader.ReadBoolean();
            AllowResize = reader.ReadBoolean();
            AlwaysOnTop = reader.ReadBoolean();
            Freeze      = reader.ReadBoolean();
            LastChanged = reader.ReadDate();
            Text        = reader.ReadString();

            reader.Dispose();
        }
Exemple #9
0
        public GMSound(ProjectReader reader)
        {
            Name        = reader.ReadString();
            LastChanged = reader.ReadDate();
            Version     = reader.ReadInt32();
            if (Version != 800)
            {
                throw new InvalidDataException("This library only supports .gmk GM8.0 files.");
            }

            Kind     = (SoundKind)reader.ReadInt32();
            FileType = reader.ReadString();
            FileName = reader.ReadString();
            Data     = null;
            if (reader.ReadBoolean())
            {
                int size = reader.ReadInt32();
                Data = reader.ReadBytes(size);
            }

            int eff    = reader.ReadInt32();
            int efflen = (int)SoundEffects.__LENGTH;

            Effects = new bool[efflen];
            for (int i = 0; i < efflen; i++)
            {
                Effects[i] = (eff & 1) != 0;
                eff      >>= 1;
            }

            // to check for an effect you do:
            // if (Effects[(int)SoundEffects.CHORUS]) { }

            Volume  = reader.ReadDouble();
            Panning = reader.ReadDouble();
            Preload = reader.ReadBoolean();

            reader.Dispose();
        }
Exemple #10
0
        public GMRoom(ProjectReader reader, GMProject proj)
        {
            Name        = reader.ReadString();
            LastChanged = reader.ReadDate();
            Version     = reader.ReadInt32();
            Caption     = reader.ReadString();
            Width       = reader.ReadUInt32();
            Height      = reader.ReadUInt32();
            int _snx = reader.ReadInt32();
            int _sny = reader.ReadInt32();

            Snap            = new Point(_snx, _sny);
            Isometric       = reader.ReadBoolean();
            Speed           = reader.ReadUInt32();
            Persistent      = reader.ReadBoolean();
            BackgroundColor = reader.ReadColor();
            int val = reader.ReadInt32();

            DrawBackgroundColor    = (val & 1) != 0;
            ClearBGWithWindowColor = (val & 0b10) == 0;
            CreationCode           = reader.ReadString();

            // Read room backgrounds.
            int bgcount = reader.ReadInt32();

            Backgrounds = new List <RoomBackground>(bgcount);
            for (int i = 0; i < bgcount; i++)
            {
                var bgstruct = new RoomBackground();
                bgstruct.Load(reader, proj);
                Backgrounds.Add(bgstruct);
            }

            // Read views.
            EnableViews = reader.ReadBoolean();
            int viewcount = reader.ReadInt32();

            Views = new List <RoomView>(viewcount);
            for (int i = 0; i < viewcount; i++)
            {
                var viewstruct = new RoomView();
                viewstruct.Load(reader, proj);
                Views.Add(viewstruct);
            }

            // Read room instances.
            int instcount = reader.ReadInt32();

            Instances = new List <RoomInstance>(instcount);
            for (int i = 0; i < instcount; i++)
            {
                var inststruct = new RoomInstance();
                inststruct.Load(reader, proj);
                Instances.Add(inststruct);
            }

            // Read room tiles.
            int tilecount = reader.ReadInt32();

            Tiles = new List <RoomTile>(tilecount);
            for (int i = 0; i < tilecount; i++)
            {
                var tilestruct = new RoomTile();
                tilestruct.Load(reader, proj);
                Tiles.Add(tilestruct);
            }

            // weird editor settings (aren't really important unless you make an IDE)
            REI                 = reader.ReadBoolean();
            EditorWidth         = reader.ReadInt32();
            EditorHeight        = reader.ReadInt32();
            ShowGrid            = reader.ReadBoolean();
            ShowObjects         = reader.ReadBoolean();
            ShowTiles           = reader.ReadBoolean();
            ShowBGs             = reader.ReadBoolean();
            ShowFGs             = reader.ReadBoolean();
            ShowViews           = reader.ReadBoolean();
            DeleteUnderlyingObj = reader.ReadBoolean();
            DeleteUnderlyingTil = reader.ReadBoolean();
            Tab                 = (EditorTab)reader.ReadInt32();
            int _hx = reader.ReadInt32();
            int _hy = reader.ReadInt32();

            Scrollbar = new Point(_hx, _hy);

            reader.Dispose();
        }