Beispiel #1
0
        public GMBackground(ProjectReader reader, bool _gmbck)
        {
            // Same as .gmspr...

            int magic = reader.ReadInt32();

            if (magic != 1234321)
            {
                throw new InvalidDataException("Wrong GMBCK magic, got " + magic);
            }

            var dec_reader = reader.MakeReaderZlib();

            Version = dec_reader.ReadInt32();
            if (Version != 710)
            {
                throw new InvalidDataException("Unknown GMBCK version, got " + magic);
            }

            UseAsTileset = dec_reader.ReadBoolean();
            TileWidth    = dec_reader.ReadInt32();
            TileHeight   = dec_reader.ReadInt32();
            OffsetH      = dec_reader.ReadInt32();
            OffsetV      = dec_reader.ReadInt32();
            SepH         = dec_reader.ReadInt32();
            SepV         = dec_reader.ReadInt32();

            FrameVersion = dec_reader.ReadInt32();
            if (FrameVersion != 800)
            {
                throw new InvalidDataException("Unknown GMBCK image version, got " + magic);
            }

            int Width, Height;

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

            dec_reader.Dispose();
        }
Beispiel #2
0
        public GMSprite(ProjectReader reader, bool _gmspr)
        {
            // Basically the same code except that we read the magic and uncompress data.

            int magic = reader.ReadInt32();

            if (magic != GMProject.GMMagic)
            {
                throw new InvalidDataException("Invalid GMSPR header, got " + magic);
            }

            // use the zlib compressed reader from now on.
            var dec_reader = reader.MakeReaderZlib();

            Version = dec_reader.ReadInt32();
            if (Version != 800)
            {
                throw new InvalidDataException("Unknown GMSPR version, got " + Version);
            }

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

            Origin = new Point(_x, _y);

            int framenum = dec_reader.ReadInt32();

            Subimages = new List <Image>(framenum);
            for (int i = 0; i < framenum; i++)
            {
                int framever = dec_reader.ReadInt32();
                if (framever != 800)
                {
                    throw new InvalidDataException("Unknown GMSPR frame version, got " + framever);
                }
                Width  = dec_reader.ReadInt32();
                Height = dec_reader.ReadInt32();
                if (Width * Height != 0)
                {
                    Subimages.Add(dec_reader.ReadBGRAImage(Width, Height));
                }
                else
                {
                    Subimages.Add(null);  // ????
                }
            }

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

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

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

            dec_reader.Dispose();
        }
Beispiel #3
0
        public GMOptions(ProjectReader reader)
        {
            int version = reader.ReadInt32();
            int val;

            if (version < 800)
            {
                throw new InvalidDataException("This library only supports .gmk GM8.0 files.");
            }

            FormatVersion = version;
            var dec_reader = reader.MakeReaderZlib();

            StartInFullscreen = dec_reader.ReadBoolean();
            InterpolatePixels = dec_reader.ReadBoolean();
            DontDrawBorder    = dec_reader.ReadBoolean();
            DisplayCursor     = dec_reader.ReadBoolean();
            Scaling           = dec_reader.ReadInt32();
            AllowWindowResize = dec_reader.ReadBoolean();
            AlwaysOnTop       = dec_reader.ReadBoolean();
            OutsideRoom       = dec_reader.ReadColor();
            SetResolution     = dec_reader.ReadBoolean();
            ColorDepth        = (ColourDepth)dec_reader.ReadInt32();
            ScreenResolution  = (Resolution)dec_reader.ReadInt32();
            Frequency         = (ScreenFrequency)dec_reader.ReadInt32();
            Borderless        = dec_reader.ReadBoolean();
            val                 = dec_reader.ReadInt32();
            VSync               = (val & 0x01) != 0;
            SoftwareVertex      = (val & 0x80000000) != 0;
            DisableScreensavers = dec_reader.ReadBoolean();

            LetF4Fullscreen = dec_reader.ReadBoolean();
            LetF1GameInfo   = dec_reader.ReadBoolean();
            LetESCEndGame   = dec_reader.ReadBoolean();
            LetF5F6SaveLoad = dec_reader.ReadBoolean();
            LetF9Screenshot = dec_reader.ReadBoolean();
            TreatCloseAsESC = dec_reader.ReadBoolean();

            Priority            = (GamePriority)dec_reader.ReadInt32();
            FreezeWhenFocusLost = dec_reader.ReadBoolean();
            LoadingBarMode      = (ProgBars)dec_reader.ReadInt32();
            BackLoadingBar      = null;
            FrontLoadingBar     = null;
            if (LoadingBarMode == ProgBars.BAR_CUSTOM)
            {
                if (dec_reader.ReadBoolean())
                {
                    BackLoadingBar = dec_reader.ReadZlibImage();
                }
                if (dec_reader.ReadBoolean())
                {
                    FrontLoadingBar = dec_reader.ReadZlibImage();
                }
            }
            ShowCustomLoadImage = dec_reader.ReadBoolean();
            LoadingImage        = null;
            if (ShowCustomLoadImage)
            {
                if (dec_reader.ReadBoolean())
                {
                    LoadingImage = dec_reader.ReadZlibImage();
                }
            }
            LoadimgImagePartTransparent = dec_reader.ReadBoolean();
            LoadImageAlpha   = dec_reader.ReadInt32();
            ScaleProgressBar = dec_reader.ReadBoolean();
            int icoSize = dec_reader.ReadInt32();

            RawIcon = dec_reader.ReadBytes(icoSize);
            if (icoSize > 0)
            {
                using (MemoryStream ims = new MemoryStream(RawIcon))
                {
                    GameIcon = new Icon(ims);
                }
            }
            DisplayErrors    = dec_reader.ReadBoolean();
            WriteToLog       = dec_reader.ReadBoolean();
            AbortOnAllErrors = dec_reader.ReadBoolean();
            val = dec_reader.ReadInt32();
            TreatUninitAsZero = (val & 0x01) != 0;
            ErrorOnArguments  = (val & 0x02) != 0;

            /*
             * if (version >= 820)
             * {
             *  WebGL = dec_reader.ReadInt32();
             *  SwapEventOrder = dec_reader.ReadBoolean();
             * }
             */

            Author             = dec_reader.ReadString();
            Version            = dec_reader.ReadString();
            LastChanged        = dec_reader.ReadDate();
            Information        = dec_reader.ReadString();
            GameVersion        = dec_reader.ReadVersion();
            Company            = dec_reader.ReadString();
            Product            = dec_reader.ReadString();
            Copyright          = dec_reader.ReadString();
            Description        = dec_reader.ReadString();
            OptionsLastChanged = dec_reader.ReadDate();
        }