Example #1
0
        void executeMove()
        {
            Map   map = Global.ActiveMap;
            Vsp24 vsp = Global.ActiveVsp;

            Operations.OperationManager om = Global.opManager;

            om.beginGroup("VSP Manager: Smart Tile Move");

            Ops.SetTileGroup     stg  = new Ops.SetTileGroup(0);
            Ops.SetTiledataGroup stdg = new Ops.SetTiledataGroup(Global.ActiveVsp);

            //move tiles
            for (int y = 0; y < originalSelection.height; y++)
            {
                for (int x = 0; x < originalSelection.width; x++)
                {
                    int xs = x + originalSelection.x;
                    int ys = y + originalSelection.y;
                    int xd = x + selection.x;
                    int yd = y + selection.y;
                    int ts = ys * TilesWide + xs;
                    int td = yd * TilesWide + xd;

                    if (ts >= vsp.Tiles.Count || ts < 0)
                    {
                        continue;
                    }

                    stdg.addRecord(td, ((Vsp24Tile)vsp.Tiles[ts]).Image.GetArray());

                    for (int l = 0; l < map.Layers.Count; l++)
                    {
                        MapLayer ml = (MapLayer)map.Layers[l];
                        if (ml.type != LayerType.Tile)
                        {
                            continue;
                        }
                        for (int yi = 0; yi < ml.Height; yi++)
                        {
                            for (int xi = 0; xi < ml.Width; xi++)
                            {
                                int t = ml.getTile(xi, yi);
                                if (t == ts)
                                {
                                    stg.addRecord(l, xi, yi, td);
                                }
                            }
                        }
                    }
                }
            }

            om.add(stg);
            om.add(stdg);
            om.endGroupExec();
        }
Example #2
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();
        }
Example #3
0
        public void cut()
        {
            if (!bSelection)
            {
                return;
            }

            copy();

            Operations.OperationManager om = Global.opManager;
            om.beginGroup("VSP Manager: Cut Tiledata");
            Ops.SetTiledataGroup stdg = new Ops.SetTiledataGroup(Global.ActiveVsp);

            Selection s = originalSelection;

            if (s.width > 0 && s.height > 0)
            {
                int y0      = s.y;
                int x0      = s.x;
                int magenta = Render.makeColor(255, 0, 255);
                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;
                        int[] newData = new int[16 * 16];
                        for (int i = 0; i < 256; i++)
                        {
                            newData[i] = magenta;
                        }
                        stdg.addRecord(t, newData);
                    }
                }
                om.add(stdg);
            }
            om.endGroupExec();

            Invalidate();
        }