예제 #1
0
        /// <summary>
        /// Not yet generic enough to call with custom derived classes other than XCMapFile
        /// </summary>
        /// <param name="file"></param>
        public void SaveGif(string file)
        {
            var palette = GetFirstGroundPalette();

            if (palette == null)
            {
                throw new ApplicationException("At least 1 ground tile is required");
            }

            var rowPlusCols = MapSize.Rows + MapSize.Cols;
            var b           = Bmp.MakeBitmap(
                rowPlusCols * (PckImage.Width / 2),
                (MapSize.Height - _currentHeight) * 24 + rowPlusCols * 8,
                palette.Colors);

            var start = new Point(
                (MapSize.Rows - 1) * (PckImage.Width / 2),
                -(24 * _currentHeight));

            int curr = 0;

            if (MapData != null)
            {
                var hWid    = Globals.HalfWidth;
                var hHeight = Globals.HalfHeight;
                for (int h = MapSize.Height - 1; h >= _currentHeight; h--)
                {
                    for (int row = 0, startX = start.X, startY = start.Y + (24 * h);
                         row < MapSize.Rows;
                         row++, startX -= hWid, startY += hHeight)
                    {
                        for (int col = 0, x = startX, y = startY;
                             col < MapSize.Cols;
                             col++, x += hWid, y += hHeight, curr++)
                        {
                            var tiles = this[row, col, h].UsedTiles;
                            foreach (var tileBase in tiles)
                            {
                                var t = (XCTile)tileBase;
                                Bmp.Draw(t[0].Image, b, x, y - t.Info.TileOffset);
                            }

                            Bmp.FireLoadingEvent(curr, (MapSize.Height - _currentHeight) * MapSize.Rows * MapSize.Cols);
                        }
                    }
                }
            }
            try
            {
                var rect = Bmp.GetBoundsRect(b, Bmp.DefaultTransparentIndex);
                var b2   = Bmp.Crop(b, rect);
                b2.Save(file, ImageFormat.Gif);
            }
            catch
            {
                b.Save(file, ImageFormat.Gif);
            }
        }
예제 #2
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     if (!IsShow)
     {
         return;
     }
     base.Draw(spriteBatch);
     _list.Draw(spriteBatch);
     _saveSnapshot.Draw(spriteBatch);
     _loadButton.Draw(spriteBatch);
     _saveButton.Draw(spriteBatch);
     _exitButton.Draw(spriteBatch);
     _saveTime.Draw(spriteBatch);
     _message.Draw(spriteBatch);
 }