コード例 #1
0
ファイル: IFFSaver.cs プロジェクト: gm-archive/chovy-gm
 private static void WriteBackgrounds(IList <KeyValuePair <string, GMBackground> > _data, Stream _s, IFF _iff)
 {
     WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair <string, GMBackground> _kvp, Stream __s, IFF __iff, long __index)
     {
         __s.PatchOffset(__index);
         __iff.AddString(__s, _kvp.Key);
         GMBackground value = _kvp.Value;
         __s.WriteBoolean(value.Transparent);
         __s.WriteBoolean(value.Smooth);
         __s.WriteBoolean(value.Preload);
         if (value.Bitmap != null && value.Bitmap.Width * value.Bitmap.Height > 0)
         {
             ms_tpageSprites.BeginGroup(_kvp.Key);
             TexturePageEntry texturePageEntry = ms_tpageSprites.AddImage(value.Bitmap.Bitmap, true, false);
             ms_tpageSprites.EndGroup();
             texturePageEntry.OriginalRepeatBorder = true;
             texturePageEntry.RepeatX = 2;
             texturePageEntry.RepeatY = 2;
             TextureOptions.SetTextureOptions(_kvp.Key, texturePageEntry);
             __iff.AddPatch(__s, texturePageEntry);
         }
         else
         {
             __s.WriteInteger(0);
         }
     });
 }
コード例 #2
0
        public bool Alloc(TexturePageEntry _entry, out int _X, out int _Y)
        {
            bool flag  = false;
            bool flag2 = false;

            _X = -1;
            _Y = -1;
            int num  = GridSizeX;
            int num2 = GridSizeY;
            int num3 = _entry.W;
            int num4 = _entry.H;

            if (_entry.OriginalRepeatBorder)
            {
                num  += _entry.RepeatX;
                num2 += _entry.RepeatY;
            }
            if (num3 < Bitmap.Width)
            {
                num3 += num;
                num3 += num;
                num3  = ((num3 + 3) & -4);
                flag  = true;
            }
            if (num4 < Bitmap.Height)
            {
                num4 += num2;
                num4 += num2;
                num4  = ((num4 + 3) & -4);
                flag2 = true;
            }
            _entry.RepeatBorder = _entry.OriginalRepeatBorder;
            if (!flag || !flag2)
            {
                _entry.RepeatBorder = false;
            }
            yyRect yyRect = TextureRects.Test(num3, num4);

            if (yyRect != null)
            {
                Point point = TextureRects.AddImage(yyRect, num3, num4);
                _X = point.X;
                _Y = point.Y;
                if (flag)
                {
                    _X += num;
                }
                if (flag2)
                {
                    _Y += num2;
                }
                AreaFree -= num3 * num4;
                return(true);
            }
            return(false);
        }
コード例 #3
0
ファイル: TexturePage.cs プロジェクト: gm-archive/chovy-gm
        public TexturePageEntry AddImage(Bitmap _image, bool _pack, bool _ignoreTextureScale)
        {
            int width       = _image.Width;
            int height      = _image.Height;
            int _XOffset    = 0;
            int _YOffset    = 0;
            int _CropWidth  = width;
            int _CropHeight = height;

            if (_pack)
            {
                _image = RemoveSpace(_image, out _XOffset, out _YOffset, out _CropWidth, out _CropHeight);
            }
            if (!_ignoreTextureScale && Program.TextureScale > 1)
            {
                _image = Scale(_image, Math.Max(1, _image.Width / Program.TextureScale), Math.Max(1, _image.Height / Program.TextureScale));
            }
            if (_image.Width > TextureSizeWidth || _image.Height > TextureSizeHeight)
            {
                int num  = _image.Width;
                int num2 = _image.Height;
                while (num > TextureSizeWidth || num2 > TextureSizeHeight)
                {
                    num  >>= 1;
                    num2 >>= 1;
                }
                _image = Scale(_image, num, num2);
            }
            TexturePageEntry texturePageEntry = null;
            uint             num3             = Loader.HashBitmap(_image);

            foreach (TexturePageEntry entry in Entries)
            {
                if (entry.W == _image.Width && entry.H == _image.Height && entry.Hash == num3 && entry.Name == GroupName && entry.XOffset == _XOffset && entry.YOffset == _YOffset)
                {
                    texturePageEntry = entry;
                    break;
                }
            }
            if (texturePageEntry == null)
            {
                texturePageEntry            = ((!string.IsNullOrEmpty(GroupName)) ? new TexturePageEntry(_image, GroupName, num3) : new TexturePageEntry(_image, num3));
                texturePageEntry.XOffset    = _XOffset;
                texturePageEntry.YOffset    = _YOffset;
                texturePageEntry.CropWidth  = _CropWidth;
                texturePageEntry.CropHeight = _CropHeight;
                texturePageEntry.OW         = width;
                texturePageEntry.OH         = height;
                texturePageEntry.DebugTag   = false;
                Entries.Add(texturePageEntry);
            }
            return(texturePageEntry);
        }
コード例 #4
0
ファイル: IFFSaver.cs プロジェクト: gm-archive/chovy-gm
 private static void WriteSprites(IList <KeyValuePair <string, GMSprite> > _data, Stream _s, IFF _iff)
 {
     WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair <string, GMSprite> _kvp, Stream __s, IFF __iff, long __index)
     {
         __s.Align(4);
         __s.PatchOffset(__index);
         __iff.AddString(__s, _kvp.Key);
         GMSprite value = _kvp.Value;
         __s.WriteInteger(value.Width);
         __s.WriteInteger(value.Height);
         __s.WriteInteger(value.BBoxLeft);
         __s.WriteInteger(value.BBoxRight);
         __s.WriteInteger(value.BBoxBottom);
         __s.WriteInteger(value.BBoxTop);
         __s.WriteBoolean(value.Transparent);
         __s.WriteBoolean(value.Smooth);
         __s.WriteBoolean(value.Preload);
         __s.WriteInteger(value.BBoxMode);
         __s.WriteBoolean(value.ColCheck);
         __s.WriteInteger(value.XOrig);
         __s.WriteInteger(value.YOrig);
         __s.WriteInteger(value.Images.Count);
         ms_tpageSprites.BeginGroup(_kvp.Key);
         for (int i = 0; i < value.Images.Count; i++)
         {
             if (value.Images[i].Width * value.Images[i].Height > 0)
             {
                 TexturePageEntry o = ms_tpageSprites.AddImage(value.Images[i].Bitmap, true, false);
                 __iff.AddPatch(__s, o);
             }
             else
             {
                 __s.WriteInteger(0);
             }
         }
         ms_tpageSprites.EndGroup();
         IList <byte[]> masks = value.Masks;
         if (masks != null)
         {
             __s.WriteInteger(value.Masks.Count);
             foreach (byte[] item in masks)
             {
                 __s.Write(item, 0, item.Length);
             }
         }
         else
         {
             __s.WriteInteger(0);
         }
     });
 }
コード例 #5
0
ファイル: IFFSaver.cs プロジェクト: gm-archive/chovy-gm
 private static void WriteFonts(IList <KeyValuePair <string, GMFont> > _data, Stream _s, IFF _iff)
 {
     WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair <string, GMFont> _kvp, Stream __s, IFF __iff, long __index)
     {
         __s.PatchOffset(__index);
         __iff.AddString(__s, _kvp.Key);
         GMFont value = _kvp.Value;
         __iff.AddString(__s, value.Name);
         __s.WriteInteger(value.Size);
         __s.WriteBoolean(value.Bold);
         __s.WriteBoolean(value.Italic);
         //__s.WriteInteger(value.First | (value.CharSet << 16) | (value.AntiAlias << 24));
         //CharSet and AntiAliasing are NOT supported by PSP runner!
         __s.WriteInteger(value.First);
         __s.WriteInteger(value.Last);
         ms_tpageSprites.BeginGroup(_kvp.Key);
         TexturePageEntry texturePageEntry = ms_tpageSprites.AddImage(value.Bitmap, false, true);
         ms_tpageSprites.EndGroup();
         __iff.AddPatch(__s, texturePageEntry);
         double num  = 1.0;
         double num2 = 1.0;
         if (texturePageEntry.W != value.Bitmap.Width || texturePageEntry.H != value.Bitmap.Height)
         {
             num  = (double)texturePageEntry.W / (double)value.Bitmap.Width;
             num2 = (double)texturePageEntry.H / (double)value.Bitmap.Height;
         }
         num  = 1.0 / num;
         num2 = 1.0 / num2;
         __s.WriteSingle((float)num);
         __s.WriteSingle((float)num2);
         __s.WriteInteger(value.Glyphs.Count);
         foreach (GMGlyph glyph in value.Glyphs)
         {
             __s.WriteInteger((int)(((double)glyph.X + num - 1.0) / num));
             __s.WriteInteger((int)(((double)glyph.Y + num2 - 1.0) / num2));
             __s.WriteInteger((int)(((double)glyph.W + num - 1.0) / num));
             __s.WriteInteger((int)(((double)glyph.H + num2 - 1.0) / num2));
             __s.WriteInteger((int)(((double)glyph.Shift + num - 1.0) / num));
             __s.WriteInteger((int)(((double)glyph.Offset + num - 1.0) / num));
         }
     });
 }
コード例 #6
0
ファイル: IFFSaver.cs プロジェクト: gm-archive/chovy-gm
        private static void WriteOptions(GMOptions _data, Stream _s, IFF _iff)
        {
            _s.WriteBoolean(_data.FullScreen);
            _s.WriteBoolean(_data.InterpolatePixels);
            _s.WriteBoolean(_data.NoBorder);
            _s.WriteBoolean(_data.ShowCursor);
            _s.WriteInteger(_data.Scale);
            _s.WriteBoolean(_data.Sizeable);
            _s.WriteBoolean(_data.StayOnTop);
            _s.WriteInteger(_data.WindowColour);
            _s.WriteBoolean(_data.ChangeResolution);
            _s.WriteInteger(_data.ColorDepth);
            _s.WriteInteger(_data.Resolution);
            _s.WriteInteger(_data.Frequency);
            _s.WriteBoolean(_data.NoButtons);
            _s.WriteInteger(_data.Sync_Vertex);
            _s.WriteBoolean(_data.ScreenKey);
            _s.WriteBoolean(_data.HelpKey);
            _s.WriteBoolean(_data.QuitKey);
            _s.WriteBoolean(_data.SaveKey);
            _s.WriteBoolean(_data.ScreenShotKey);
            _s.WriteBoolean(_data.CloseSec);
            _s.WriteInteger(_data.Priority);
            _s.WriteBoolean(_data.Freeze);
            _s.WriteBoolean(_data.ShowProgress);
            if (_data.BackImage != null && !Program.SplashOmit)
            {
                TexturePageEntry o = ms_tpageSprites.AddImage(_data.BackImage, true, false);
                _iff.AddPatch(_s, o);
            }
            else
            {
                _s.WriteInteger(0);
            }
            if (_data.FrontImage != null && !Program.SplashOmit)
            {
                TexturePageEntry o2 = ms_tpageSprites.AddImage(_data.FrontImage, true, false);
                _iff.AddPatch(_s, o2);
            }
            else
            {
                _s.WriteInteger(0);
            }
            if (_data.LoadImage != null && !Program.SplashOmit)
            {
                TexturePageEntry o3 = ms_tpageSprites.AddImage(_data.LoadImage, true, false);
                _iff.AddPatch(_s, o3);
            }
            else
            {
                _s.WriteInteger(0);
            }
            _s.WriteBoolean(_data.LoadTransparent);
            _s.WriteInteger(_data.LoadAlpha);
            _s.WriteBoolean(_data.ScaleProgress);
            _s.WriteBoolean(_data.DisplayErrors);
            _s.WriteBoolean(_data.WriteErrors);
            _s.WriteBoolean(_data.AbortErrors);
            _s.WriteBoolean(_data.VariableErrors);
            _s.WriteBoolean(_data.CreationEventOrder);
            int num = 0;

            foreach (KeyValuePair <string, string> constant in _data.Constants)
            {
                int value = 0;
                if (GMLCompile.ms_ConstantCount.TryGetValue(constant.Key, out value) && value > 0)
                {
                    num++;
                }
            }
            _s.WriteInteger(num);
            foreach (KeyValuePair <string, string> constant2 in _data.Constants)
            {
                int value2 = 0;
                if (GMLCompile.ms_ConstantCount.TryGetValue(constant2.Key, out value2) && value2 > 0)
                {
                    _iff.AddString(_s, constant2.Key);
                    _iff.AddString(_s, constant2.Value);
                }
            }
        }