예제 #1
0
파일: mapView.cs 프로젝트: mcgrue/maped3
        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(Global.mainWindow.miViewNotes.Checked)
                foreach (var note in ParentMap.Notes)
                {
                    //Render.renderAlpha(backBuffer, cpx, cpy, vsp.GetTile(tile).Image, 100 - layer.Translucency, false);
                    int x = note.x - xScroll;
                    int y = note.y - yScroll;
                    int size = Render.measureText(note.note);
                    Render.renderSolid(img, x-1, y-1, size+2, 10, unchecked((int)0xFF000000), Render.PixelOp.Alpha50);
                    Render.renderText(img, x,y, note.note, unchecked((int)0xFFFFFFFF));
                }

            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);

            bool forbidCursor = false;
            if (Global.toolPalette.currMapPlugin is Plugins.IMapPluginNoTileCursorFlag)
                forbidCursor = true;

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

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

                int dx = (mcl.tx * Global.TILE_SIZE - xScroll);
                int dy = (mcl.ty * Global.TILE_SIZE - 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, Global.TILE_SIZE * ZoomLevel, Global.TILE_SIZE * ZoomLevel);

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

            }

            if (currMapTool is Plugins.IMapPainter)
            {
                ((Plugins.IMapPainter)currMapTool).paintWindow(currMapEventInfo, e.Graphics);
            }
        }
예제 #2
0
파일: mapView.cs 프로젝트: jder/verge3
        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);
            }
        }
예제 #3
0
파일: mapView.cs 프로젝트: salviati/verge3
        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);
            }
        }