Esempio n. 1
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();
        }
Esempio n. 2
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);
            }
        }