Exemple #1
0
 public static void renderBox(pr2.IRenderImage img, int x0, int y0, int w, int h, int color, Render.PixelOp op)
 {
     renderSolid(img, x0, y0, w, 1, color, op);
     renderSolid(img, x0, y0 + h - 1, w, 1, color, op);
     renderSolid(img, x0, y0, 1, h, color, op);
     renderSolid(img, x0 + w - 1, y0, 1, h, color, op);
 }
Exemple #2
0
        private void renderObstructionLayer(pr2.IRenderImage backBuffer, MapLayer mapLayer, int px, int py)
        {
            int mtx  = px / 16;
            int mty  = py / 16;
            int mtox = px & 15;
            int mtoy = py & 15;



            //we add 2; one for the case where we are scrolled a little bit
            //(and so parts of two tiles are drawn instead of one complete)
            //and one for the case where the screen is a funny size and a remainder bit is shown
            int tw = backBuffer.Width / 16 + 2;
            int th = backBuffer.Height / 16 + 2;

            int layerWidth  = mapLayer.Width;
            int layerHeight = mapLayer.Height;
            int cpx         = -mtox;
            int cpy         = -mtoy;

            tw = System.Math.Min(tw, layerWidth - mtx);
            th = System.Math.Min(th, layerHeight - mty);

            int tp;
            int tile;
            int xmin = -mtox;
            int xmax = xmin + tw * 16;

            short[] tileMap = mapLayer.Data;
            if (Global.RenderOptions.bTranslucentEffects)
            {
                for (int ty = 0; ty < th; ty++, cpy += 16)
                {
                    tp = (ty + mty) * layerWidth + mtx;
                    for (cpx = xmin; cpx < xmax; cpx += 16)
                    {
                        tile = tileMap[tp++];
                        if (0 < tile && tile < ParentMap.vsp.ObstructionTiles.Count)
                        {
                            Render.renderObsTile(backBuffer, cpx, cpy, ((VspObstructionTile)ParentMap.vsp.ObstructionTiles[tile]).Image, false, Preferences.Current.ObsColor);
                        }
                    }
                }
            }
            else
            {
                for (int ty = 0; ty < th; ty++, cpy += 16)
                {
                    tp = (ty + mty) * layerWidth + mtx;
                    for (cpx = xmin; cpx < xmax; cpx += 16)
                    {
                        tile = tileMap[tp++];
                        if (0 < tile && tile < ParentMap.vsp.ObstructionTiles.Count)
                        {
                            Render.renderObsTileFast(backBuffer, cpx, cpy, ((VspObstructionTile)ParentMap.vsp.ObstructionTiles[tile]).Image, false);
                        }
                    }
                }
            }
        }
Exemple #3
0
        public void copy()
        {
            if (!bSelection)
            {
                return;
            }

            Selection s = originalSelection;

            if (s.height > 0 && s.width > 0)
            {
                using (pr2.IRenderImage img = pr2.RenderImage.Create(s.width * 16, s.height * 16)) {
                    int y0 = s.y;
                    int x0 = s.x;
                    for (int y = 0; y < s.height; y++)
                    {
                        for (int x = 0; x < s.width; x++)
                        {
                            if (!s.getPoint(x0 + x, y0 + y))
                            {
                                continue;
                            }
                            int tileIndex = (y0 + y) * TilesWide + x + x0;
                            Render.render(img, x * 16, y * 16, Global.ActiveVsp.GetTile(tileIndex).Image, true);
                        }
                    }

                    WindowsClipboard.setImage(img);
                }
            }
        }
Exemple #4
0
        public unsafe static void renderColoredStippleTile(pr2.IRenderImage img, int x0, int y0, int color1, int color2)
        {
            int xlen = 16;
            int ylen = 16;

            int *s = null;
            int *d = img.Buffer;

            int dpitch = img.Pitch;

            if (clip(ref x0, ref y0, ref xlen, ref ylen, ref s, ref d, 0, dpitch, 0, img.Width, 0, img.Height))
            {
                return;
            }

            for (; ylen > 0; ylen--)
            {
                for (int x = 0; x < xlen; x++)
                {
                    if (((ylen ^ x) & 1) != 0)
                    {
                        d[x] = color1;
                    }
                    else
                    {
                        d[x] = color2;
                    }
                }
                d += dpitch;
            }
        }
Exemple #5
0
        public unsafe static void renderColoredTile_50Alpha(pr2.IRenderImage img, int x0, int y0, int color)
        {
            int xlen = 16;
            int ylen = 16;

            int *s = null;
            int *d = img.Buffer;

            int dpitch = img.Pitch;

            if (clip(ref x0, ref y0, ref xlen, ref ylen, ref s, ref d, 0, dpitch, 0, img.Width, 0, img.Height))
            {
                return;
            }

            for (; ylen > 0; ylen--)
            {
                for (int x = 0; x < xlen; x++)
                {
                    handlePixel(color, ref d[x], (int)Render.PixelOp.Alpha50, true, true);
                }

                d += dpitch;
            }
        }
Exemple #6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (cds != null)
            {
                cds.repaint();
            }
            if (cdlg != null)
            {
                cdlg.update();
            }
            if (redraw_image)
            {
                pr2.IRenderImage img = pr2.RenderImage.LockBitmap(bmpDisplay);
                Render.renderColorPicker(img, _bhue);
                img.Dispose();
                redraw_image = false;
            }

            e.Graphics.DrawImage(bmpDisplay, 0, 0, Width, Height);
            e.Graphics.DrawEllipse(Pens.Black, mx - 5, my - 5, 10, 10);
            e.Graphics.DrawEllipse(Pens.White, mx - 4, my - 4, 8, 8);
            e.Graphics.DrawEllipse(Pens.Black, mx - 3, my - 3, 6, 6);

            PaintFunctions.PaintFrame(e.Graphics, 0, 0, Width, Height);
        }
Exemple #7
0
        public unsafe static void renderAlpha(pr2.IRenderImage dest, int x, int y, pr2.IRenderImage src, int opacity, bool drawZero)
        {
            int  xlen = src.Width;
            int  ylen = src.Height;
            int *s    = src.Buffer;
            int *d    = dest.Buffer;

            int spitch = xlen;
            int dpitch = dest.Pitch;

            if (clip(ref x, ref y, ref xlen, ref ylen, ref s, ref d, spitch, dpitch, 0, dest.Width, 0, dest.Height))
            {
                return;
            }

            for (; ylen != 0; ylen--)
            {
                for (int xx = 0; xx < xlen; xx++)
                {
                    handlePixelAlpha(s[xx], ref d[xx], opacity, drawZero);
                }

                s += spitch;
                d += dpitch;
            }
        }
Exemple #8
0
        public static void setImage(pr2.IRenderImage img)
        {
            Bitmap bmp = img.ConvertToBitmap();

            setBitmap(bmp);
            bmp.Dispose();
        }
Exemple #9
0
        private void renderZoneLayer(pr2.IRenderImage backBuffer, MapLayer mapLayer, int px, int py)
        {
            int mtx  = px / 16;
            int mty  = py / 16;
            int mtox = px & 15;
            int mtoy = py & 15;

            //we add 2; one for the case where we are scrolled a little bit
            //(and so parts of two tiles are drawn instead of one complete)
            //and one for the case where the screen is a funny size and a remainder bit is shown
            int tw = backBuffer.Width / 16 + 2;
            int th = backBuffer.Height / 16 + 2;

            int layerWidth  = mapLayer.Width;
            int layerHeight = mapLayer.Height;
            int cpx         = -mtox;
            int cpy         = -mtoy;

            tw = System.Math.Min(tw, layerWidth - mtx);
            th = System.Math.Min(th, layerHeight - mty);

            int tp;
            int tile;
            int xmin = -mtox;
            int xmax = xmin + tw * 16;

            const int WHITE = unchecked ((int)0xFFFFFFFF);

            short[] tileMap = mapLayer.Data;
            for (int ty = 0; ty < th; ty++, cpy += 16)
            {
                tp = (ty + mty) * layerWidth + mtx;
                if (Global.RenderOptions.bTranslucentEffects)
                {
                    for (cpx = xmin; cpx < xmax; cpx += 16)
                    {
                        if ((tile = tileMap[tp++]) != 0)
                        {
                            Render.renderColoredTile_50Alpha(backBuffer, cpx, cpy, Preferences.Current.ZonesColor);
                            Render.renderNumber(backBuffer, cpx, cpy, tile, WHITE);
                        }
                    }
                }
                else
                {
                    for (cpx = xmin; cpx < xmax; cpx += 16)
                    {
                        if ((tile = tileMap[tp++]) != 0)
                        {
                            Render.renderColoredTile(backBuffer, cpx, cpy, Preferences.Current.ZonesColor);
                            Render.renderNumber(backBuffer, cpx, cpy, tile, WHITE);
                        }
                    }
                }
            }
        }
Exemple #10
0
        public void paste()
        {
            if (!WindowsClipboard.IsImage)
            {
                return;
            }

            if (!bSelection)
            {
                return;
            }

            pr2.IRenderImage img = WindowsClipboard.getImage();

            int tx = img.Width / 16;
            int ty = img.Height / 16;

            Selection s = originalSelection;

            this.selection = originalSelection.copy();

            if (tx != s.width)
            {
                return;
            }
            if (ty != s.height)
            {
                return;
            }

            Operations.OperationManager om = Global.opManager;
            om.beginGroup("VSP Manager: Paste Tiledata");

            Ops.SetTiledataGroup stdg = new Ops.SetTiledataGroup(Global.ActiveVsp);

            int y0 = s.y;
            int x0 = s.x;

            int[] arrImg = img.GetArray();
            for (int y = 0; y < s.height; y++)
            {
                for (int x = 0; x < s.width; x++)
                {
                    int t = (s.y + y) * TilesWide + s.x + x;
                    stdg.addRecord(t, Global.Misc.sliceIntArrayImage(arrImg, img.Width, x * 16, y * 16, 16, 16));
                }
            }

            om.add(stdg);
            om.endGroupExec();


            img.Dispose();
            Invalidate();
        }
Exemple #11
0
        public unsafe static void renderColorPicker(pr2.IRenderImage img, float h)
        {
            int *dst = img.Buffer;

            for (int y = 0; y < 256; y++)
            {
                for (int x = 0; x < 256; x++)
                {
                    *dst = HsbToColor(h, (float)x / 256, (float)y / 256);
                    dst++;
                }
            }
        }
Exemple #12
0
        public unsafe static void renderObsTile(pr2.IRenderImage img, int x0, int y0, pr2.IRenderImage src, bool clearbuf, int color)
        {
            int xlen = 16;
            int ylen = 16;

            const int WHITE = unchecked ((int)0xFFFFFFFF);
            const int BLACK = unchecked ((int)0xFF000000);

            const int spitch = 16;
            int       dpitch = img.Pitch;

            int *ptr = src.Buffer;
            int *s   = ptr;
            int *d   = img.Buffer;

            if (clip(ref x0, ref y0, ref xlen, ref ylen, ref s, ref d, spitch, dpitch, 0, img.Width, 0, img.Height))
            {
                return;
            }

            if (clearbuf)
            {
                for (; ylen > 0; ylen--)
                {
                    for (int x = 0; x < xlen; x++)
                    {
                        d[x] = (s[x] != 0) ? WHITE : BLACK;
                    }
                    s += spitch;
                    d += dpitch;
                }
            }
            else
            {
                for (; ylen > 0; ylen--)
                {
                    for (int x = 0; x < xlen; x++)
                    {
                        if (s[x] != 0)
                        {
                            handlePixel(color, ref d[x], (int)Render.PixelOp.Alpha50, true, true);
                        }
                    }

                    s += spitch;
                    d += dpitch;
                }
            }
        }
Exemple #13
0
        public unsafe static void renderObsTileFast(pr2.IRenderImage img, int x0, int y0, pr2.IRenderImage src, bool clearbuf)
        {
            int xlen = 16;
            int ylen = 16;

            const int WHITE = unchecked ((int)0xFFFFFFFF);
            const int BLACK = unchecked ((int)0xFF000000);

            int *pixels = src.Buffer;
            int *s      = pixels;
            int *d      = img.Buffer;

            const int spitch = 16;
            int       dpitch = img.Pitch;

            if (clip(ref x0, ref y0, ref xlen, ref ylen, ref s, ref d, spitch, dpitch, 0, img.Width, 0, img.Height))
            {
                return;
            }

            if (clearbuf)
            {
                for (; ylen > 0; ylen--)
                {
                    for (int x = 0; x < xlen; x++)
                    {
                        d[x] = (s[x] != 0) ? WHITE : BLACK;
                    }
                    s += spitch;
                    d += dpitch;
                }
            }
            else
            {
                for (; ylen > 0; ylen--)
                {
                    for (int x = 0; x < xlen; x++)
                    {
                        if (s[x] != 0)
                        {
                            d[x] = WHITE;
                        }
                    }
                    s += spitch;
                    d += dpitch;
                }
            }
        }
Exemple #14
0
        private unsafe void paint(Graphics g)
        {
            const int BLACK = unchecked ((int)0xFF000000);

            g.PixelOffsetMode   = PixelOffsetMode.Half;
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
            Bitmap bmp = Render.createBitmap(16, 16);

            using (pr2.IRenderImage img = pr2.RenderImage.LockBitmap(bmp)) {
                if (TileSourceType == SourceType.Vsp)
                {
                    if (active_tile != null)
                    {
                        if (!bAnimate)
                        {
                            Render.render(img, 0, 0, active_tile.Image, true);
                        }
                        else
                        {
                            int frame = Global.FrameCalc.getframe(atx);
                            Render.render(img, 0, 0, Global.ActiveMap.vsp.GetTile(frame).Image, true);
                        }
                    }
                    else
                    {
                        img.Clear(BLACK);
                    }
                }
                else
                {
                    if (active_obstile != null)
                    {
                        Render.renderObsTile(img, 0, 0, active_obstile.Image, true, Preferences.Current.ObsColor);
                    }
                    else
                    {
                        img.Clear(BLACK);
                    }
                }
            }
            g.DrawImage(bmp, 0, 0, Width, Height);
            bmp.Dispose();
        }
Exemple #15
0
        public unsafe void ExportToClipboard(int GridSize)
        {
            int    th  = tileCount / 20 + 1;
            int    h   = th * (16 + GridSize) + GridSize;
            int    w   = 320 + (GridSize * 21);
            Bitmap bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);

            using (pr2.IRenderImage img = pr2.RenderImage.LockBitmap(bmp)) {
                // render stuffs
                for (int y = 0; y < th; y++)
                {
                    for (int x = 0; x < 20 && y * 20 + x < tileCount; x++)
                    {
                        Render.render(img, GridSize + x * (16 + GridSize), GridSize + y * (16 + GridSize), GetTile(y * 20 + x).Image, true);
                    }
                }
            }

            WindowsClipboard.setBitmap(bmp);
        }
Exemple #16
0
        public unsafe static void renderSolid(pr2.IRenderImage img, int x0, int y0, int w, int h, int color, Render.PixelOp op)
        {
            int bw = img.Width;
            int bh = img.Height;
            int bp = img.Pitch;

            for (int y = 0; y < h; y++)
            {
                if (y + y0 >= 0 && y + y0 < bh)
                {
                    for (int x = 0; x < w; x++)
                    {
                        if (x + x0 >= 0 && x + x0 < bw)
                        {
                            handlePixel(color, ref img.Buffer[(y0 + y) * bp + x0 + x], (int)op, true, true);
                        }
                    }
                }
            }
        }
Exemple #17
0
        void renderLayer(pr2.IRenderImage backBuffer, MapLayer mapLayer, int px, int py, bool drawZero)
        {
            switch (mapLayer.type)
            {
            case LayerType.Tile:
                renderTileLayer(backBuffer, mapLayer, ParentMap.vsp, px, py, drawZero);
                break;

            case LayerType.Zone:
                renderZoneLayer(backBuffer, mapLayer, px, py);
                break;

            case LayerType.Obs:
                renderObstructionLayer(backBuffer, mapLayer, px, py);
                break;

            default:
                break;
            }
        }
Exemple #18
0
        private void renderEntities(pr2.IRenderImage backBuffer, MapLayer ml, int px, int py)
        {
            int mtx  = px / 16;
            int mty  = py / 16;
            int mtox = px & 15;
            int mtoy = py & 15;
            int tw   = backBuffer.Width / 16 + 2;
            int th   = backBuffer.Height / 16 + 2;

            foreach (MapEntity me in ParentMap.Entities)
            {
                int tx = me.TileX;
                int ty = me.TileY;

                if (tx >= mtx && tx <= mtx + tw && ty >= mty && ty <= mty + th)
                {
                    int cx = -mtox + (tx - mtx) * 16;
                    int cy = -mtoy + (ty - mty) * 16;
                    Render.renderColoredTile_50Alpha(backBuffer, cx, cy, Preferences.Current.EntsColor);
                    Render.renderNumber(backBuffer, cx + 4, cy + 4, me.ID, unchecked ((int)0xFFFFFFFF));
                }
            }
        }
Exemple #19
0
        public unsafe static void renderNumber(pr2.IRenderImage img, int x0, int y0, int number, int color)
        {
            int  height = img.Height;
            int  width  = img.Width;
            int *pixels = img.Buffer;

            char[] digits = number.ToString().ToCharArray();
            foreach (char c in digits)
            {
                int    cn = c - '0';
                byte[] ba = BiosFont.Number(cn);

                int glyphWidth  = ba[0];
                int glyphHeight = (ba.Length - 1) / glyphWidth;

                for (int y = 0; y < glyphHeight; y++)
                {
                    if (y0 + y < 0 || y0 + y >= height)
                    {
                        continue;
                    }
                    for (int x = 0; x < glyphWidth; x++)
                    {
                        if (x0 + x < 0 || x0 + x >= width)
                        {
                            continue;
                        }
                        if (ba[1 + (y * glyphWidth) + x] == 1)
                        {
                            pixels[(y0 + y) * width + (x0 + x)] = color;
                        }
                    }
                }
                x0 += glyphWidth + 1;
            }
        }
Exemple #20
0
 public VspObstructionTile(Vsp24 parent, int[] data)
 {
     this.parent = parent;
     this.image = new pr2.BufferImage(16, 16, data);
 }
Exemple #21
0
 public Vsp24Tile(Vsp24 parent, pr2.IRenderImage image)
 {
     this.parent = parent;
     this.image = image;
     this.avg = GetAverageColor();
 }
Exemple #22
0
 public VspObstructionTile(Vsp24 parent, int[] data)
 {
     this.parent = parent;
     this.image = new pr2.BufferImage(Global.TILE_SIZE, Global.TILE_SIZE, data);
 }
Exemple #23
0
 public Vsp24Tile(Vsp24 parent, pr2.IRenderImage image)
 {
     this.parent = parent;
     this.image  = image;
     this.avg    = GetAverageColor();
 }
Exemple #24
0
        private void renderTileLayer(pr2.IRenderImage backBuffer, MapLayer layer, Vsp24 vsp, int px, int py, bool drawZero)
        {
            int mtx  = px / 16;
            int mty  = py / 16;
            int mtox = px & 15;
            int mtoy = py & 15;

            //we add 2; one for the case where we are scrolled a little bit
            //(and so parts of two tiles are drawn instead of one complete)
            //and one for the case where the screen is a funny size and a remainder bit is shown
            int tw = backBuffer.Width / 16 + 2;
            int th = backBuffer.Height / 16 + 2;

            int layerWidth  = layer.Width;
            int layerHeight = layer.Height;
            int cpx         = -mtox;
            int cpy         = -mtoy;

            tw = System.Math.Min(tw, layerWidth - mtx);
            th = System.Math.Min(th, layerHeight - mty);

            int tp;
            int tile;
            int xmin = -mtox;
            int xmax = xmin + tw * 16;

            short[] tileMap = layer.Data;
            if (Global.RenderOptions.bTranslucentEffects)
            {
                for (int ty = 0; ty < th; ty++, cpy += 16)
                {
                    tp = (ty + mty) * layerWidth + mtx;
                    for (cpx = xmin; cpx < xmax; cpx += 16)
                    {
                        tile = tileMap[tp++];
                        if (Global.RenderOptions.bAnimate)
                        {
                            tile = Global.FrameCalc.getframe(tile);
                        }

                        if ((drawZero || tile != 0) && tile < vsp.tileCount)
                        {
                            Render.renderAlpha(backBuffer, cpx, cpy, vsp.GetTile(tile).Image, 100 - layer.Translucency, false);
                        }
                    }
                }
            }
            else
            {
                for (int ty = 0; ty < th; ty++, cpy += 16)
                {
                    tp = (ty + mty) * layerWidth + mtx;
                    for (cpx = xmin; cpx < xmax; cpx += 16)
                    {
                        tile = tileMap[tp++];
                        if (Global.RenderOptions.bAnimate)
                        {
                            tile = Global.FrameCalc.getframe(tile);
                        }

                        if (drawZero || tile != 0 && tile < vsp.tileCount)
                        {
                            Render.render(backBuffer, cpx, cpy, vsp.GetTile(tile).Image, false);
                        }
                    }
                }
            }
        }
Exemple #25
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (!live)
            {
                return;
            }

            int xScroll = hscrollbar.Value;
            int yScroll = vscrollbar.Value;

            Map currMap = ParentMap;

            pr2.IRenderImage img = pr2.RenderImage.LockBitmap(bmp);
            img.Clear(unchecked ((int)0xFF000000));

            Map      mOld  = null;
            MapLayer mlOld = null;

            if (currMapTool is Plugins.IMapTweaker)
            {
                mOld  = currMapEventInfo.editedMap;
                mlOld = currMapEventInfo.editedLayer;
                currMapEventInfo.editedMap   = mOld.tileCopy();
                currMapEventInfo.editedLayer = currMapEventInfo.editedMap.findLayer(mlOld.name);
                currMap = currMapEventInfo.editedMap;
                currMapEventInfo.bTweak = true;
                ((Plugins.IMapTweaker)currMapTool).tweakMap(currMapEventInfo);
                currMapEventInfo.bTweak = false;
            }

            bool bottomlayer = false;
            bool blayerfound = false;

            for (int c = 0; c < ParentMap.RenderManager.Layers.Count; c++)
            {
                MapLayer mlCurr = (MapLayer)ParentMap.RenderManager.Layers[c];

                if (!blayerfound && mlCurr.type == LayerType.Tile)
                {
                    bottomlayer = true;
                    blayerfound = true;
                }

                if (!ParentMap.IsBrush)
                {
                    if (!ParentMap.UIState[c].bRender)
                    {
                        continue;
                    }
                }

                if (mlCurr.type == LayerType.Entity)
                {
                    renderEntities(img, mlCurr, xScroll, yScroll);
                }

                if (mlCurr.type == LayerType.Tile || mlCurr.type == LayerType.Obs || mlCurr.type == LayerType.Zone)
                {
                    if (bDragging && currMapEventInfo.editedLayerIndex == c && currMapTool is Plugins.IMapPainter)
                    {
                        //if(Global.editedLayer == mlCurr && currMapTool is Plugins.IMapPainter) {
                        MapLayer mlOld2 = currMapEventInfo.editedLayer;
                        MapLayer mlTemp = mlOld2.copy();
                        currMapEventInfo.editedLayer = mlTemp;
                        currMapEventInfo.bTweak      = true;
                        ((Plugins.IMapPainter)currMapTool).tweakLayer(currMapEventInfo);
                        currMapEventInfo.editedLayer = mlOld2;
                        currMapEventInfo.bTweak      = false;
                        renderLayer(img, mlTemp, xScroll, yScroll, bottomlayer);

                        ((Plugins.IMapPainter)currMapTool).paintMap(currMapEventInfo, img);
                    }
                    else
                    {
                        renderLayer(img, mlCurr, xScroll, yScroll, bottomlayer);
                    }
                    if (bottomlayer)
                    {
                        bottomlayer = false;
                    }
                }
            }

            if (currMapTool is Plugins.IMapTweaker)
            {
                currMapEventInfo.editedMap   = mOld;
                currMapEventInfo.editedLayer = mlOld;
            }

            img.Dispose();
            e.Graphics.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
            e.Graphics.InterpolationMode  = InterpolationMode.NearestNeighbor;
            e.Graphics.CompositingMode    = CompositingMode.SourceCopy;
            e.Graphics.CompositingQuality = CompositingQuality.HighSpeed;


            e.Graphics.DrawImage(bmp, 0, 0, bmp.Width * ZoomLevel, bmp.Height * ZoomLevel);



            if (!bDragging && bMouseContained)
            {
                Pen p = new Pen(Color.White, 2.0f);

                Plugins.MapCursorLocation mcl = new winmaped2.Plugins.MapCursorLocation();
                setupMapCursorLocation(ref mcl, cursorX, cursorY);

                int dx = (mcl.tx * 16 - xScroll);
                int dy = (mcl.ty * 16 - yScroll);

                //				if(dx != last_cursorX || dy != last_cursorY)
                //if (cursorX > 0 && cursorX < Size.Width && cursorY>0 && cursorY<Size.Height)
                e.Graphics.DrawRectangle(p, dx * ZoomLevel, dy * ZoomLevel, 16 * ZoomLevel, 16 * ZoomLevel);

                //				last_cursorX = dx;
                //				last_cursorY = dy;
            }

            if (currMapTool is Plugins.IMapPainter)
            {
                ((Plugins.IMapPainter)currMapTool).paintWindow(currMapEventInfo, e.Graphics);
            }
        }
Exemple #26
0
 public void paintMap(MapEventInfo mei, pr2.IRenderImage img)
 {
     this.mei = mei;
     this.img = img;
     onPaint();
 }
Exemple #27
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (vsp == null)
            {
                return;
            }

            const int WHITE = unchecked ((int)0xFFFFFFFF);

            e.Graphics.PixelOffsetMode   = PixelOffsetMode.Half;
            e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;

            CalculateScrollValues();

            Bitmap bmp = new Bitmap(TilesWide * 16, TilesHigh * 16, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            using (pr2.IRenderImage qimg = pr2.RenderImage.LockBitmap(bmp)) {
                if (ControllerType == VSPController.ControllerType.VSP)
                {
                    int row = 0, col = 0;
                    for (int i = scrollOffset / 16 * 20; i < vsp.Tiles.Count; i++)
                    {
                        Render.render(qimg, col * 16, row * 16, vsp.GetTile(i).Image, true);
                        if (i == st0)
                        {
                            if (controller_mode != VSPController.ControllerMode.ViewOnly)
                            {
                                Render.renderBox(qimg, col * 16, row * 16, 16, 16, WHITE, Render.PixelOp.Src);
                                Render.renderBox(qimg, col * 16 + 1, row * 16 + 1, 14, 14, WHITE, Render.PixelOp.Src);
                            }
                        }
                        if (i == st1)
                        {
                            if (controller_mode == VSPController.ControllerMode.SelectorDual)
                            {
                                Render.renderBox(qimg, col * 16 + 2, row * 16 + 2, 12, 12, WHITE, Render.PixelOp.Src);
                                Render.renderBox(qimg, col * 16 + 3, row * 16 + 3, 10, 10, WHITE, Render.PixelOp.Src);
                            }
                        }
                        col++;
                        if (col == TilesWide)
                        {
                            col = 0;
                            row++;
                            if (row == TilesHigh)
                            {
                                break;
                            }
                        }
                    }
                }
                else if (ControllerType == VSPController.ControllerType.Obstruction)
                {
                    // render obs tiles
                    int row = 0, col = 0;
                    for (int i = scrollOffset / 16 * 20; i < vsp.ObstructionTiles.Count; i++)
                    {
                        VspObstructionTile vot = ((VspObstructionTile)vsp.ObstructionTiles[i]);
                        Render.renderObsTile(qimg, col * 16, row * 16, vot.Image, true, Preferences.Current.ObsColor);
                        if (i == st0)
                        {
                            if (controller_mode != VSPController.ControllerMode.ViewOnly)
                            {
                                Render.renderBox(qimg, col * 16, row * 16, 16, 16, WHITE, Render.PixelOp.Src);
                                Render.renderBox(qimg, col * 16 + 1, row * 16 + 1, 14, 14, WHITE, Render.PixelOp.Src);
                            }
                        }
                        col++;
                        if (col == TilesWide)
                        {
                            col = 0;
                            row++;
                            if (row == TilesHigh)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            e.Graphics.DrawImage(bmp, 0, 0, Size.Width, Size.Height);
            bmp.Dispose();
        }
Exemple #28
0
 public VspObstructionTile(Vsp24 parent, int[] data)
 {
     this.parent = parent;
     this.image  = new pr2.BufferImage(16, 16, data);
 }
Exemple #29
0
 public void paintMap(MapEventInfo mei, pr2.IRenderImage img)
 {
     this.mei = mei;
     this.img = img;
     onPaint();
 }
Exemple #30
0
 public void paintMap(MapEventInfo mei, pr2.IRenderImage img)
 {
 }
Exemple #31
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (parent == null)
            {
                e.Graphics.FillRectangle(System.Drawing.Brushes.Black, e.ClipRectangle.Left, e.ClipRectangle.Right, e.ClipRectangle.Width, e.ClipRectangle.Height);
                return;
            }

            e.Graphics.PixelOffsetMode   = PixelOffsetMode.Half;
            e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;

            Bitmap bmp = new Bitmap(TilesWide * 16, (TilesHigh + 1) * 16, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            pr2.IRenderImage qimg = pr2.RenderImage.LockBitmap(bmp);

            int row = 0, col = 0;

            for (int i = scrollOffset; i < parent.vsp.Tiles.Count; i++)
            {
                Render.render(qimg, col * 16, row * 16, parent.vsp.GetTile(i).Image, true);

                if (bSelection)
                {
                    int xx = col;
                    int yy = row + logicalRow;
                    if (selection.getPoint(xx, yy))
                    {
                        int tile = originalSelection.getPointIntegerValue(xx - selection.x + originalSelection.x, yy - selection.y + originalSelection.y, this);
                        if (tile != -1)
                        {
                            Render.render(qimg, col * 16, row * 16, parent.vsp.GetTile(tile).Image, true);
                        }
                    }
                }

                col++;
                if (col == TilesWide)
                {
                    col = 0;
                    row++;
                    if (row == TilesHigh)
                    {
                        break;
                    }
                }
            }

            //render the empty area
            while (row != TilesHigh + 1)
            {
                while (col != TilesWide)
                {
                    Render.renderColoredStippleTile(qimg, col * 16, row * 16, Render.makeColor(0, 0, 0), Render.makeColor(192, 192, 192));
                    col++;
                }
                col = 0;
                row++;
            }

            qimg.Dispose();
            e.Graphics.DrawImage(bmp, 0, 0, TilesWide * 16, (TilesHigh + 1) * 16);
            bmp.Dispose();


            e.Graphics.PixelOffsetMode = PixelOffsetMode.Default;

            if (bSelectingRect)
            {
                Point p0  = (new Point(Math.Min(mtx, mtx1), Math.Min(mty, mty1)));
                Point p1  = (new Point(Math.Max(mtx, mtx1), Math.Max(mty, mty1)));
                Pen   pen = new Pen(Color.White);
                pen.DashStyle = DashStyle.Dash;
                pen.Width     = 1;
                e.Graphics.DrawRectangle(pen, p0.X * 16, (p0.Y - logicalRow) * 16, (p1.X - p0.X) * 16, (p1.Y - p0.Y) * 16);
                pen.Dispose();
            }
            if (bSelection)
            {
                GraphicsPath gp = new GraphicsPath();

                selection.updateGraphicsPath(gp, 16, 0, -logicalRow * 16);
                Pen pen = new Pen(Color.FromArgb(128, 0, 0, 0));
                pen.Width     = 5;
                pen.DashStyle = DashStyle.Solid;
                e.Graphics.TranslateTransform(1.0f, 1.0f);
                e.Graphics.DrawPath(pen, gp);
                e.Graphics.TranslateTransform(-1.0f, -1.0f);

                pen.Color     = Color.White;
                pen.Width     = 1;
                pen.DashStyle = DashStyle.Dash;
                e.Graphics.DrawPath(pen, gp);
                pen.Dispose();
                gp.Dispose();
            }
        }