Beispiel #1
0
        static void DrawBitmap64x64From4_32x32(AsyncGraphics gfx, Bitmap[] bitmaps, int x = 0, int y = 0)
        {
            /*
             * Topleft: 4
             * TopRight: 3
             * BottomLeft: 2
             * BottomRight: 1
             */

            if (bitmaps[3] != null)
            {
                gfx.DrawImage(bitmaps[3], x, y, 32, 32);
            }
            if (bitmaps[2] != null)
            {
                gfx.DrawImage(bitmaps[2], x + 32, y, 32, 32);
            }
            if (bitmaps[1] != null)
            {
                gfx.DrawImage(bitmaps[1], x, y + 32, 32, 32);
            }
            if (bitmaps[0] != null)
            {
                gfx.DrawImage(bitmaps[0], x + 32, y + 32, 32, 32);
            }
        }
Beispiel #2
0
        static void DrawBitmap32x32From1_32x32(AsyncGraphics gfx, Bitmap[] bitmaps, int x = 0, int y = 0)
        {
            /*
             * Fill: 1
             */

            if (bitmaps[0] != null)
            {
                gfx.DrawImage(bitmaps[0], x, y, 32, 32);
            }
        }
Beispiel #3
0
        static void DrawBitmap32x64From2_32x32(AsyncGraphics gfx, Bitmap[] bitmaps, int x = 0, int y = 0)
        {
            /*
             * Top: 2
             * Bottom: 1
             */

            if (bitmaps[1] != null)
            {
                gfx.DrawImage(bitmaps[1], x, y, 32, 32);
            }
            if (bitmaps[0] != null)
            {
                gfx.DrawImage(bitmaps[0], x, y + 32, 32, 32);
            }
        }
Beispiel #4
0
        static void DrawBitmap64x32From2_32x32(AsyncGraphics gfx, Bitmap[] bitmaps, int x = 0, int y = 0)
        {
            /*
             * Left: 2
             * Right: 1
             */

            if (bitmaps[1] != null)
            {
                gfx.DrawImage(bitmaps[1], x, y, 32, 32);
            }
            if (bitmaps[0] != null)
            {
                gfx.DrawImage(bitmaps[0], x + 32, y, 32, 32);
            }
        }
Beispiel #5
0
        static void InternalSaveStaticBitmaps(RepeatedField <uint> sprites, DrawBitmapsDelegate drawFunc, int layers, int spriteType, int localStart, Core.Sprites.ContentSprites sprParser, int dX, int dY, int clientVersion)
        {
            int singleSize = dX * dY;

            AsyncGraphics gfx = new AsyncGraphics(new Bitmap(SEGMENT_DIMENTION, SEGMENT_DIMENTION));
            string        filename;

            int x = 0, y = 0, z = 0;

            for (int i = 0; i < sprites.Count;)
            {
                Bitmap[] smallBitmaps = new Bitmap[layers];
                for (int m = 0; m < layers; m++)
                {
                    if (i + m >= sprites.Count)
                    {
                        break;
                    }

                    smallBitmaps[m] = sprParser.GetSprite(sprites[i + m]);
                }

                if (y >= SEGMENT_DIMENTION)
                {
                    filename = string.Format("sprites-{0}-{1}.png", localStart, localStart + (BITMAP_SIZE / singleSize) - 1);
                    tasks.Add(gfx.SaveAndDispose(Path.Combine(clientVersion.ToString() + "/sprites", filename)));

                    jsonTokens.Add(new SpritesToken()
                    {
                        file          = filename,
                        spritetype    = spriteType,
                        firstspriteid = localStart,
                        lastspriteid  = localStart + (BITMAP_SIZE / singleSize) - 1
                    });

                    localStart += BITMAP_SIZE / singleSize;

                    gfx = new AsyncGraphics(new Bitmap(SEGMENT_DIMENTION, SEGMENT_DIMENTION));
                    x   = y = z = 0;
                }

                var tmpSmallBitmaps = smallBitmaps;
                drawFunc(gfx, smallBitmaps, x, y);
                tasks.Add(gfx.DisposeOnDone(smallBitmaps));

                x += dX;
                if (x >= SEGMENT_DIMENTION)
                {
                    y += dY;
                    x  = 0;
                }

                if (i == sprites.Count)
                {
                    break;
                }

                i = Math.Min(i + layers, sprites.Count);
                z++;
            }

            // save the last gfx
            int end = localStart + z;

            filename = string.Format("sprites-{0}-{1}.png", localStart, end - 1);
            tasks.Add(gfx.SaveAndDispose(Path.Combine(clientVersion.ToString(), "sprites", filename)));

            jsonTokens.Add(new SpritesToken()
            {
                file          = filename,
                spritetype    = spriteType,
                firstspriteid = localStart,
                lastspriteid  = end - 1
            });
        }