Exemplo n.º 1
0
        private void btnInsertRow_Click(object sender, System.EventArgs e)
        {
            int todo = tilesetViewer.TilesWide - (vsp.tileCount % tilesetViewer.TilesWide);

            if (todo == 0)
            {
                todo = tilesetViewer.TilesWide;
            }

            int startInsert = vsp.tileCount;

            Ops.AddRemoveTilesGroup artg = new Ops.AddRemoveTilesGroup(0);

            Operations.OperationManager om = Global.opManager;
            om.beginGroup("VSP Manager: Insert Row");

            for (int i = 0; i < todo; i++)
            {
                artg.addRecord(startInsert, 0);
            }

            om.addExec(artg);
            om.endGroup();

            updateScrollbar();
            tilesetViewer.Invalidate();
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
0
 private void btnInsertTile_Click(object sender, System.EventArgs e)
 {
     Operations.OperationManager om = Global.opManager;
     om.beginGroup("VSP Manager: Insert Tile");
     Ops.AddRemoveTilesGroup artg = new Ops.AddRemoveTilesGroup(0);
     artg.addRecord(Global.ActiveVsp.tileCount, 0);
     om.addExec(artg);
     om.endGroup();
     updateScrollbar();
     tilesetViewer.Invalidate();
 }
Exemplo n.º 5
0
        private void btnDeleteRow_Click(object sender, System.EventArgs e)
        {
            int toDelete = vsp.tileCount % tilesetViewer.TilesWide;

            if (toDelete == 0)
            {
                toDelete = tilesetViewer.TilesWide;
            }
            if (vsp.tileCount == 0)
            {
                toDelete = 0;
            }

            if (toDelete == 0)
            {
                return;
            }

            int startDelete = (vsp.tileCount / tilesetViewer.TilesWide) * tilesetViewer.TilesWide;

            if (toDelete == tilesetViewer.TilesWide)
            {
                startDelete -= tilesetViewer.TilesWide;
            }
            Ops.AddRemoveTilesGroup artg = new Ops.AddRemoveTilesGroup(0);

            Operations.OperationManager om = Global.opManager;
            om.beginGroup("VSP Manager: Delete Row");

            for (int i = 0; i < toDelete; i++)
            {
                artg.addRecord(startDelete, 1);
            }

            om.addExec(artg);
            om.endGroup();

            updateScrollbar();
            tilesetViewer.Invalidate();
        }
Exemplo n.º 6
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();
        }