Пример #1
0
 public void Reload(Effects effectsEditor)
 {
     this.effectsEditor = effectsEditor;
     this.commandStack  = new CommandStack(true);
     this.overlay.Select.Clear();
     this.overlay.SelectTS.Clear();
     this.selectedTiles = null;
     this.draggedTiles  = null;
     this.copiedTiles   = null;
     this.selection     = null;
     this.Updating      = true;
     this.e_molds.Items.Clear();
     for (int i = 0; i < animation.Molds.Count; i++)
     {
         this.e_molds.Items.Add("Mold " + i.ToString());
     }
     this.e_molds.SelectedIndex = 0;
     e_moldWidth.Value          = animation.Width;
     e_moldHeight.Value         = animation.Height;
     e_tileSetSize.Value        = animation.TilesetLength;
     this.Updating = false;
     SetTilesetImage();
     SetTilemapImage();
     LoadTileEditor();
 }
Пример #2
0
        private void pictureBoxTileset_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                return;
            }
            if (overlay.SelectTS.Empty)
            {
                return;
            }
            int x_ = overlay.SelectTS.Location.X / 16;
            int y_ = overlay.SelectTS.Location.Y / 16;

            if (this.selectedTiles == null)
            {
                this.selectedTiles = new CopyBuffer(overlay.SelectTS.Width, overlay.SelectTS.Height);
            }
            int[][] selectedTiles = new int[3][];
            selectedTiles[Layer] = new int[(overlay.SelectTS.Width / 16) * (overlay.SelectTS.Height / 16)];
            for (int y = 0; y < overlay.SelectTS.Height / 16; y++)
            {
                for (int x = 0; x < overlay.SelectTS.Width / 16; x++)
                {
                    selectedTiles[Layer][y * (overlay.SelectTS.Width / 16) + x] = (y + y_) * 16 + x + x_;
                }
            }
            this.selectedTiles.Copies = selectedTiles;
            pictureBox.Focus();
        }
Пример #3
0
        /// <summary>
        /// "Cements" either a dragged selection or a newly pasted selection.
        /// </summary>
        /// <param name="buffer">The dragged selection or the newly pasted selection.</param>
        private void Defloat(CopyBuffer buffer)
        {
            byte[] oldTileset = Bits.Copy(tileset.Tileset_bytes);
            //
            selection = null;
            int x_ = overlay.SelectTS.X / 16;
            int y_ = overlay.SelectTS.Y / 16;

            for (int y = 0; y < buffer.Height / 16; y++)
            {
                for (int x = 0; x < buffer.Width / 16; x++)
                {
                    if (y + y_ < 0 || y + y_ >= 16 ||
                        x + x_ < 0 || x + x_ >= 16)
                    {
                        continue;
                    }
                    Tile tile = buffer.Tiles[y * (buffer.Width / 16) + x];
                    tileset.Tileset_tiles[(y + y_) * 16 + x + x_]       = tile.Copy();
                    tileset.Tileset_tiles[(y + y_) * 16 + x + x_].Index = (y + y_) * 16 + x + x_;
                }
            }
            tileset.DrawTileset(tileset.Tileset_tiles, tileset.Tileset_bytes);
            commandStack.Push(commandCount + 1);
            commandCount = 0;
            SetWorldMapImage();
            defloating = true;
            //
            commandStack.Push(new TilesetCommand(tileset, oldTileset, Model.WorldMapGraphics, 0x20, worldMapName));
        }
        /// <summary>
        /// Start dragging a selection.
        /// </summary>
        private void Drag()
        {
            if (overlay.SelectTS.Empty)
            {
                return;
            }
            // make the copy
            int x_ = overlay.SelectTS.Location.X / 16;
            int y_ = overlay.SelectTS.Location.Y / 16;

            this.draggedTiles = new CopyBuffer(overlay.SelectTS.Width, overlay.SelectTS.Height);
            Tile[] draggedTiles = new Tile[(overlay.SelectTS.Width / 16) * (overlay.SelectTS.Height / 16)];
            for (int y = 0; y < overlay.SelectTS.Height / 16; y++)
            {
                for (int x = 0; x < overlay.SelectTS.Width / 16; x++)
                {
                    int x__   = (x + x_) & 15;
                    int y__   = (y + y_) & 15;
                    int index = y__ * 16 + x__;
                    index += ((x + x_) >> 4) * 256;
                    index += ((y + y_) >> 4) * 512;
                    if (index >= tileset.Tileset_tiles.Length)
                    {
                        continue;
                    }
                    draggedTiles[y * (overlay.SelectTS.Width / 16) + x] =
                        tileset.Tileset_tiles[index].Copy();
                }
            }
            this.draggedTiles.Tiles = draggedTiles;
            selection = new Bitmap(this.draggedTiles.Image);
            Delete();
        }
Пример #5
0
        private void Flip(string type)
        {
            if (draggedTiles != null)
            {
                Defloat(draggedTiles);
            }
            if (overlay.SelectTS.Empty)
            {
                return;
            }
            int        x_     = overlay.SelectTS.Location.X / 16;
            int        y_     = overlay.SelectTS.Location.Y / 16;
            CopyBuffer buffer = new CopyBuffer(overlay.SelectTS.Width, overlay.SelectTS.Height);

            Tile[] copiedTiles = new Tile[(overlay.SelectTS.Width / 16) * (overlay.SelectTS.Height / 16)];
            for (int y = 0; y < overlay.SelectTS.Height / 16; y++)
            {
                for (int x = 0; x < overlay.SelectTS.Width / 16; x++)
                {
                    copiedTiles[y * (overlay.SelectTS.Width / 16) + x] =
                        tileset.Tilesets_tiles[Layer][(y + y_) * 16 + x + x_].Copy();
                }
            }
            if (type == "mirror")
            {
                Do.FlipHorizontal(copiedTiles, overlay.SelectTS.Width / 16, overlay.SelectTS.Height / 16);
            }
            else if (type == "invert")
            {
                Do.FlipVertical(copiedTiles, overlay.SelectTS.Width / 16, overlay.SelectTS.Height / 16);
            }
            buffer.Tiles = copiedTiles;
            Defloat(buffer);
        }
Пример #6
0
        private void pictureBoxEffectTileset_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                return;
            }
            int x_ = overlay.SelectTS.Location.X / 16;
            int y_ = overlay.SelectTS.Location.Y / 16;

            if (this.selectedTiles == null)
            {
                this.selectedTiles = new CopyBuffer(overlay.SelectTS.Width, overlay.SelectTS.Height);
            }
            int[] selectedTiles = new int[(overlay.SelectTS.Width / 16) * (overlay.SelectTS.Height / 16)];
            for (int y = 0; y < overlay.SelectTS.Height / 16; y++)
            {
                for (int x = 0; x < overlay.SelectTS.Width / 16; x++)
                {
                    int tileX = overlay.SelectTS.X + (x * 16);
                    int tileY = overlay.SelectTS.Y + (y * 16);
                    selectedTiles[y * (overlay.SelectTS.Width / 16) + x] = (y + y_) * 8 + x + x_;
                }
            }
            this.selectedTiles.Copy = selectedTiles;
            pictureBoxEffectTileset.Focus();
        }
Пример #7
0
        /// <summary>
        /// Defloats either a dragged selection or a newly pasted selection.
        /// </summary>
        /// <param name="buffer">The dragged selection or the newly pasted selection.</param>
        private void Defloat(CopyBuffer buffer)
        {
            if (buffer == null)
            {
                return;
            }
            if (overlay.Select.Empty)
            {
                return;
            }
            Point location = new Point();

            location.X = overlay.Select.X / 16;
            location.Y = overlay.Select.Y / 16;
            commandStack.Push(new TilemapCommand(
                                  mold.Mold, width / 16, height / 16, buffer.BYTE_copy,
                                  location.X, location.Y, buffer.Width / 16, buffer.Height / 16));
            commandStack.Push(commandCount + 1);
            commandCount = 0;
            SetTilemapImage();
            if (sequences != null)
            {
                sequences.SetSequenceFrameImages();
                sequences.RealignFrames();
            }
            defloating = true;
            animation.Assemble();
        }
Пример #8
0
        private void Copy()
        {
            if (overlay.SelectTS.Empty)
            {
                return;
            }
            if (draggedTiles != null)
            {
                this.copiedTiles = draggedTiles;
                return;
            }
            // make the copy
            int x_ = overlay.SelectTS.Location.X / 16;
            int y_ = overlay.SelectTS.Location.Y / 16;

            this.copiedTiles = new CopyBuffer(overlay.SelectTS.Width, overlay.SelectTS.Height);
            Tile[] copiedTiles = new Tile[(overlay.SelectTS.Width / 16) * (overlay.SelectTS.Height / 16)];
            for (int y = 0; y < overlay.SelectTS.Height / 16; y++)
            {
                for (int x = 0; x < overlay.SelectTS.Width / 16; x++)
                {
                    copiedTiles[y * (overlay.SelectTS.Width / 16) + x] =
                        tileset.Tilesets_tiles[Layer][(y + y_) * 16 + x + x_].Copy();
                }
            }
            this.copiedTiles.Tiles = copiedTiles;
        }
 private void buttonEditPaste_Click(object sender, EventArgs e)
 {
     if (draggedTiles != null)
     {
         Defloat(draggedTiles);
         draggedTiles = null;
     }
     Paste(new Point(0, 0), copiedTiles);
 }
Пример #10
0
 private void Paste(Point location, CopyBuffer buffer)
 {
     if (buffer == null)
     {
         return;
     }
     moving = true;
     // now dragging a new selection
     draggedTiles = buffer;
     selection    = buffer.Image;
     overlay.SelectTS.Refresh(16, location, buffer.Size, PictureBox);
     this.pictureBox.Invalidate();
 }
Пример #11
0
 private void Paste(Point location, CopyBuffer buffer)
 {
     if (buffer == null)
     {
         return;
     }
     moving = true;
     // now dragging a new selection
     draggedTiles = buffer;
     overlay.Select.Refresh(16, location, buffer.Size, pictureBoxE_Mold);
     pictureBoxE_Mold.Invalidate();
     defloating = false;
 }
Пример #12
0
        private void pictureBoxTileset_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Clicks > 1)
            {
                return;
            }
            if (e.Button == MouseButtons.Right)
            {
                return;
            }
            mouseDownObject = null;
            // set a floor and ceiling for the coordinates
            int x = Math.Max(0, Math.Min(e.X, pictureBox.Width));
            int y = Math.Max(0, Math.Min(e.Y, pictureBox.Height));

            pictureBox.Focus();
            // if moving an object and outside of it, paste it
            if (moving && mouseOverObject != "selection")
            {
                // if copied tiles were pasted and not dragging a non-copied selection
                if (copiedTiles != null && draggedTiles == null)
                {
                    Defloat(copiedTiles);
                }
                if (draggedTiles != null)
                {
                    Defloat(draggedTiles);
                    draggedTiles = null;
                }
                selection = null;
                moving    = false;
            }
            // if making a new selection
            if (e.Button == MouseButtons.Left && mouseOverObject == null)
            {
                overlay.SelectTS.Refresh(16, x / 16 * 16, y / 16 * 16, 16, 16, pictureBox);
            }
            // if moving a current selection
            if (!lockEditing.Checked && e.Button == MouseButtons.Left && mouseOverObject == "selection")
            {
                mouseDownObject   = "selection";
                mouseDownPosition = overlay.SelectTS.MousePosition(x, y);
                if (!moving)    // only do this if the current selection has not been initially moved
                {
                    moving = true;
                    Drag();
                }
            }
            mouseDownTile = y / 16 * 16 + (x / 16);
            LoadTileEditor();
        }
Пример #13
0
 private void Defloat()
 {
     if (copiedTiles != null && !defloating)
     {
         Defloat(copiedTiles);
     }
     if (draggedTiles != null)
     {
         Defloat(draggedTiles);
         draggedTiles = null;
     }
     moving = false;
     overlay.Select.Clear();
     Cursor.Position = Cursor.Position;
 }
Пример #14
0
 private void Defloat()
 {
     // if copied tiles were pasted and not dragging a non-copied selection
     if (copiedTiles != null && draggedTiles == null)
     {
         Defloat(copiedTiles);
     }
     if (draggedTiles != null)
     {
         Defloat(draggedTiles);
         draggedTiles = null;
     }
     moving    = false;
     selection = null;
     overlay.SelectTS.Clear();
     Cursor.Position = Cursor.Position;
 }
Пример #15
0
        private void Flip(string type)
        {
            if (draggedTiles != null)
            {
                Defloat(draggedTiles);
            }
            if (overlay.SelectTS.Empty)
            {
                return;
            }
            int        x_     = overlay.SelectTS.Location.X / 16;
            int        y_     = overlay.SelectTS.Location.Y / 16;
            CopyBuffer buffer = new CopyBuffer(overlay.SelectTS.Width, overlay.SelectTS.Height);

            Tile[] copiedTiles = new Tile[(overlay.SelectTS.Width / 16) * (overlay.SelectTS.Height / 16)];
            for (int y = 0; y < overlay.SelectTS.Height / 16; y++)
            {
                for (int x = 0; x < overlay.SelectTS.Width / 16; x++)
                {
                    int x__   = (x + x_) & 15;
                    int y__   = (y + y_) & 15;
                    int index = y__ * 16 + x__;
                    index += ((x + x_) >> 4) * 256;
                    index += ((y + y_) >> 4) * 512;
                    if (index >= tileset.Tileset_tiles.Length)
                    {
                        continue;
                    }
                    copiedTiles[y * (overlay.SelectTS.Width / 16) + x] =
                        tileset.Tileset_tiles[index].Copy();
                }
            }
            if (type == "mirror")
            {
                Do.FlipHorizontal(copiedTiles, overlay.SelectTS.Width / 16, overlay.SelectTS.Height / 16);
            }
            else if (type == "invert")
            {
                Do.FlipVertical(copiedTiles, overlay.SelectTS.Width / 16, overlay.SelectTS.Height / 16);
            }
            buffer.Tiles = copiedTiles;
            Defloat(buffer);
            tileset.DrawTileset(tileset.Tileset_tiles, tileset.Tileset_bytes);
            SetBattlefieldImage();
        }
Пример #16
0
 private void buttonEditDelete_Click(object sender, EventArgs e)
 {
     if (!moving)
     {
         Delete();
     }
     else
     {
         moving       = false;
         draggedTiles = null;
         pictureBoxBattlefield.Invalidate();
     }
     if (!moving && commandCount > 0)
     {
         commandStack.Push(commandCount);
         commandCount = 0;
     }
 }
Пример #17
0
 /// <summary>
 /// Start dragging a current selection.
 /// </summary>
 private void Drag()
 {
     if (overlay.Select.Empty || overlay.Select.Size == new Size(0, 0))
     {
         return;
     }
     selection = new Bitmap(tilemapImage.Clone(
                                new Rectangle(overlay.Select.Location, overlay.Select.Size), PixelFormat.DontCare));
     int[] copiedTiles = new int[(overlay.Select.Width / 16) * (overlay.Select.Height / 16)];
     this.draggedTiles = new CopyBuffer(overlay.Select.Width, overlay.Select.Height);
     for (int y = 0, y_ = overlay.Select.Y / 16; y < overlay.Select.Height / 16; y++, y_++)
     {
         for (int x = 0, x_ = overlay.Select.X / 16; x < overlay.Select.Width / 16; x++, x_++)
         {
             int tileX = overlay.Select.X + (x * 16);
             int tileY = overlay.Select.Y + (y * 16);
             copiedTiles[y * (overlay.Select.Width / 16) + x] = mold.Mold[y_ * (width / 16) + x_];
         }
     }
     this.draggedTiles.Copy = copiedTiles;
     Delete();
 }
Пример #18
0
        /// <summary>
        /// "Cements" either a dragged selection or a newly pasted selection.
        /// </summary>
        /// <param name="buffer">The dragged selection or the newly pasted selection.</param>
        private void Defloat(CopyBuffer buffer)
        {
            byte[] oldTileset = Bits.Copy(tileset.Tileset_bytes);
            //
            selection = null;
            int x_ = overlay.SelectTS.X / 16;
            int y_ = overlay.SelectTS.Y / 16;

            for (int y = 0; y < buffer.Height / 16; y++)
            {
                for (int x = 0; x < buffer.Width / 16; x++)
                {
                    int x__   = (x + x_) & 15;
                    int y__   = (y + y_) & 15;
                    int index = y__ * 16 + x__;
                    index += ((x + x_) >> 4) * 256;
                    index += ((y + y_) >> 4) * 512;
                    if (index >= tileset.Tileset_tiles.Length || index < 0)
                    {
                        continue;
                    }
                    if (y < 0 || x < 0)
                    {
                        continue;
                    }
                    Tile tile = buffer.Tiles[y * (buffer.Width / 16) + x];
                    tileset.Tileset_tiles[index]       = tile.Copy();
                    tileset.Tileset_tiles[index].Index = index;
                }
            }
            tileset.DrawTileset(tileset.Tileset_tiles, tileset.Tileset_bytes);
            commandStack.Push(commandCount + 1);
            commandCount = 0;
            SetBattlefieldImage();
            //
            commandStack.Push(new TilesetCommand(tileset, oldTileset, this));
        }
Пример #19
0
        /// <summary>
        /// "Cements" either a dragged selection or a newly pasted selection.
        /// </summary>
        /// <param name="buffer">The dragged selection or the newly pasted selection.</param>
        public void Defloat(CopyBuffer buffer)
        {
            if (buffer == null)
            {
                return;
            }
            if (overlay.SelectTS.Empty)
            {
                return;
            }
            selection = null;
            int x_ = overlay.SelectTS.X / 16;
            int y_ = overlay.SelectTS.Y / 16;

            for (int y = 0; y < buffer.Height / 16; y++)
            {
                for (int x = 0; x < buffer.Width / 16; x++)
                {
                    if (y + y_ < 0 || y + y_ >= tileset.Height ||
                        x + x_ < 0 || x + x_ >= 16)
                    {
                        continue;
                    }
                    int  index = (y + y_) * 16 + x + x_;
                    Tile tile  = buffer.Tiles[y * (buffer.Width / 16) + x];
                    tileset.Tilesets_tiles[Layer][index]       = tile.Copy();
                    tileset.Tilesets_tiles[Layer][index].Index = index;
                }
            }
            tileset.DrawTileset(tileset.Tilesets_tiles[Layer], tileset.Tilesets_bytes[Layer]);
            tileset.Assemble(16, Layer);
            SetTileSetImage();
            if (autoUpdate.Checked)
            {
                update.DynamicInvoke();
            }
        }
Пример #20
0
        /// <summary>
        /// Start dragging a selection.
        /// </summary>
        private void Drag()
        {
            if (overlay.SelectTS.Empty)
            {
                return;
            }
            // make the copy
            int x_ = overlay.SelectTS.Location.X / 16;
            int y_ = overlay.SelectTS.Location.Y / 16;

            this.draggedTiles = new CopyBuffer(overlay.SelectTS.Width, overlay.SelectTS.Height);
            Tile[] draggedTiles = new Tile[(overlay.SelectTS.Width / 16) * (overlay.SelectTS.Height / 16)];
            for (int y = 0; y < overlay.SelectTS.Height / 16; y++)
            {
                for (int x = 0; x < overlay.SelectTS.Width / 16; x++)
                {
                    draggedTiles[y * (overlay.SelectTS.Width / 16) + x] =
                        tileset.Tilesets_tiles[Layer][(y + y_) * 16 + x + x_].Copy();
                }
            }
            this.draggedTiles.Tiles = draggedTiles;
            selection = new Bitmap(this.draggedTiles.Image);
            Delete();
        }
Пример #21
0
        private void pictureBoxE_Mold_MouseDown(object sender, MouseEventArgs e)
        {
            // set a floor and ceiling for the coordinates
            int x = Math.Max(0, Math.Min(e.X / zoom, width));
            int y = Math.Max(0, Math.Min(e.Y / zoom, height));

            #region Zooming
            Point p = new Point();
            p.X = Math.Abs(panelMoldImage.AutoScrollPosition.X);
            p.Y = Math.Abs(panelMoldImage.AutoScrollPosition.Y);
            if ((e_moldZoomIn.Checked && e.Button == MouseButtons.Left) || (e_moldZoomOut.Checked && e.Button == MouseButtons.Right))
            {
                pictureBoxE_Mold.ZoomIn(e.X, e.Y);
                return;
            }
            else if ((e_moldZoomOut.Checked && e.Button == MouseButtons.Left) || (e_moldZoomIn.Checked && e.Button == MouseButtons.Right))
            {
                pictureBoxE_Mold.ZoomOut(e.X, e.Y);
                return;
            }
            #endregion
            if (e.Button == MouseButtons.Right)
            {
                return;
            }
            #region Drawing, Erasing, Selecting
            // if moving an object and outside of it, paste it
            if (moving && mouseOverObject != "selection")
            {
                // if copied tiles were pasted and not dragging a non-copied selection
                if (copiedTiles != null && draggedTiles == null)
                {
                    Defloat(copiedTiles);
                }
                if (draggedTiles != null)
                {
                    Defloat(draggedTiles);
                    draggedTiles = null;
                }
                moving = false;
            }
            if (select.Checked)
            {
                // if we're not inside a current selection to move it, create a new selection
                if (mouseOverObject != "selection")
                {
                    overlay.Select.Refresh(16, x / 16 * 16, y / 16 * 16, 16, 16, pictureBoxE_Mold);
                }
                // otherwise, start dragging current selection
                else if (mouseOverObject == "selection")
                {
                    mouseDownObject   = "selection";
                    mouseDownPosition = overlay.Select.MousePosition(x, y);
                    if (!moving)    // only do this if the current selection has not been initially moved
                    {
                        moving = true;
                        Drag();
                    }
                }
            }
            if (e.Button == MouseButtons.Left)
            {
                if (draw.Checked)
                {
                    Draw(pictureBoxE_Mold.CreateGraphics(), x, y);
                    panelMoldImage.AutoScrollPosition = p;
                    return;
                }
                if (erase.Checked)
                {
                    Erase(x, y);
                    if (!showBG.Checked)
                    {
                        pictureBoxE_Mold.Erase(x / 16 * 16, y / 16 * 16, 16, 16);
                    }
                    else
                    {
                        pictureBoxE_Mold.Draw(x / 16 * 16, y / 16 * 16, 16, 16, bgcolor);
                    }
                    panelMoldImage.AutoScrollPosition = p;
                    return;
                }
            }
            #endregion
            panelMoldImage.AutoScrollPosition = p;
            pictureBoxE_Mold.Invalidate();
        }
Пример #22
0
        private void pictureBoxTileset_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                return;
            }
            mouseDownObject = null;
            // set a floor and ceiling for the coordinates
            int x = Math.Max(0, Math.Min(e.X, pictureBoxTileset.Width));
            int y = Math.Max(0, Math.Min(e.Y, pictureBoxTileset.Height));

            pictureBoxTileset.Focus();
            if (buttonEditSelect.Checked)
            {
                // if moving an object and outside of it, paste it
                if (moving && mouseOverObject != "selection")
                {
                    // if copied tiles were pasted and not dragging a non-copied selection
                    if (copiedTiles != null && draggedTiles == null)
                    {
                        Defloat(copiedTiles);
                    }
                    if (draggedTiles != null)
                    {
                        Defloat(draggedTiles);
                        draggedTiles = null;
                    }
                    selection = null;
                    moving    = false;
                }
                // if making a new selection
                if (e.Button == MouseButtons.Left && mouseOverObject == null)
                {
                    overlay.SelectTS.Refresh(16, x / 16 * 16, y / 16 * 16, 16, 16, pictureBoxTileset);
                }
                // if moving a current selection
                if (e.Button == MouseButtons.Left && mouseOverObject == "selection")
                {
                    mouseDownObject   = "selection";
                    mouseDownPosition = overlay.SelectTS.MousePosition(x, y);
                    if (!moving)    // only do this if the current selection has not been initially moved
                    {
                        moving = true;
                        Drag();
                    }
                }
            }
            else if (showLocations.Checked)
            {
                if (pointActivePixels[y * 256 + x] != 0)
                {
                    locationNum.Value = pointActivePixels[y * 256 + x] - 1;
                    diffX             = (int)(x - locationXCoord.Value);
                    diffY             = (int)(y - locationYCoord.Value);
                    mouseDownObject   = "location";
                    SetLocationsImage();
                }
                else
                {
                    diffX           = (int)(x - worldMapXCoord.Value);
                    diffY           = (int)(y - worldMapYCoord.Value);
                    mouseDownObject = "tileset";
                }
            }
            mouseDownTile = y / 16 * 16 + (x / 16);
            LoadTileEditor();
        }
Пример #23
0
        private void pictureBoxBattlefield_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                return;
            }
            mouseDownObject = null;
            PictureBox pictureBox = (PictureBox)sender;

            pictureBox.Focus();
            // set a floor and ceiling for the coordinates
            int x = Math.Max(0, Math.Min(e.X, pictureBox.Width));
            int y = Math.Max(0, Math.Min(e.Y, pictureBox.Height));

            if (buttonEditSelect.Checked)
            {
                // if moving an object and outside of it, paste it
                if (moving && mouseOverObject != "selection")
                {
                    // if copied tiles were pasted and not dragging a non-copied selection
                    if (copiedTiles != null && draggedTiles == null)
                    {
                        Defloat(copiedTiles);
                    }
                    if (draggedTiles != null)
                    {
                        Defloat(draggedTiles);
                        draggedTiles = null;
                    }
                    selection = null;
                    moving    = false;
                }
                // if making a new selection
                if (e.Button == MouseButtons.Left && mouseOverObject == null)
                {
                    overlay.SelectTS.Refresh(16, x / 16 * 16, y / 16 * 16, 16, 16, pictureBoxBattlefield);
                }
                // if moving a current selection
                if (e.Button == MouseButtons.Left && mouseOverObject == "selection")
                {
                    mouseDownObject   = "selection";
                    mouseDownPosition = overlay.SelectTS.MousePosition(x, y);
                    if (!moving)    // only do this if the current selection has not been initially moved
                    {
                        moving = true;
                        Drag();
                    }
                }
            }
            int x_ = (x / 16) & 15;
            int y_ = (y / 16) & 15;

            if (x < 256 && y < 256) // 1st quad
            {
                mouseDownTile = y_ * 16 + x_;
            }
            if (x > 256 && y < 256) // 2nd quad
            {
                mouseDownTile = y_ * 16 + x_ + 256;
            }
            if (x < 256 && y > 256) // 3rd quad
            {
                mouseDownTile = y_ * 16 + x_ + 512;
            }
            if (x > 256 && y > 256) // 4th quad
            {
                mouseDownTile = y_ * 16 + x_ + 768;
            }
            LoadTileEditor();
        }