示例#1
0
        private void WldView_MouseDown(object sender, MouseEventArgs e)
        {
            int x = (e.X / 16) / WldView.Zoom;
            int y = (e.Y / 16) / WldView.Zoom;
            PnlView.Focus();

            if (x < 0 || x >= CurrentWorld.Width || y < 0 || y >= CurrentWorld.Height) return;

            if (_PlacingPointer)
            {
                _PlacingPointer = false;
                CurrentWorld.AddPointer();
                PntEditor.CurrentPointer = CurrentWorld.Pointers[CurrentWorld.Pointers.Count - 1];
                CurrentPointer = PntEditor.CurrentPointer;
                CurrentPointer.X = x;
                CurrentPointer.Y = y;
                PnlDrawing.Enabled = TabLevelInfo.Enabled = true;
                WldView.SelectionRectangle = new Rectangle(x, y, 1, 1);
                WldView.UpdatePoint(x, y);
                PntEditor.UpdatePosition();
            }

            else if (EditMode == EditMode.Tiles)
            {
                if (ModifierKeys == Keys.Shift)
                {
                    BlsSelector.SelectedTileIndex = CurrentWorld.LevelData[x, y];
                    BlsSelector_SelectionChanged(this, new TEventArgs<MouseButtons>(e.Button));
                }
                else
                {
                    WldView.ClearSelection();
                    if (TileDrawMode == TileDrawMode.Selection)
                    {
                        TileDrawMode = PreviousMode;
                    }

                    if (e.Button == MouseButtons.Right && MouseMode == MouseMode.RightClickSelection)
                    {
                        PreviousMode = TileDrawMode;
                        TileDrawMode = TileDrawMode.Selection;
                    }

                    switch (TileDrawMode)
                    {
                        case TileDrawMode.Pencil:
                            CurrentMultiTile = new MultiTileAction();
                            CurrentMultiTile.AddTileChange(x, y, CurrentWorld.LevelData[x, y]);
                            CurrentWorld.SetTile(x, y, (byte)(DrawingTile));
                            ContinueDrawing = true;
                            break;

                        case TileDrawMode.Outline:
                        case TileDrawMode.Rectangle:
                        case TileDrawMode.Selection:
                            StartX = x;
                            StartY = y;
                            ContinueDrawing = true;
                            WldView.SelectionRectangle = new Rectangle(StartX, StartY, 1, 1);
                            break;

                        case TileDrawMode.Line:
                            StartX = x;
                            StartY = y;
                            ContinueDrawing = true;
                            WldView.SelectionLine = new Line(StartX, StartY, StartX, StartY);
                            break;

                        case TileDrawMode.Fill:
                            Point start = new Point(x, y);
                            Stack<Point> stack = new Stack<Point>();
                            stack.Push(start);
                            int checkValue = CurrentWorld.LevelData[x, y];
                            if (checkValue == DrawingTile) return;

                            CurrentMultiTile = new MultiTileAction();
                            while (stack.Count > 0)
                            {
                                Point p = stack.Pop();
                                int lowestX, highestX; ;
                                int lowestY, highestY;
                                lowestX = highestX = x;
                                lowestY = highestY = y;
                                int i = p.X;
                                int j = p.Y;

                                if (j < 0 || j >= CurrentWorld.Height || i < 0 || i >= CurrentWorld.Length * 16)
                                {
                                    continue;
                                }

                                WldView.DelayDrawing = true;
                                if (checkValue == CurrentWorld.LevelData[i, j])
                                {
                                    CurrentMultiTile.AddTileChange(i, j, CurrentWorld.LevelData[i, j]);
                                    CurrentWorld.SetTile(i, j, (byte)DrawingTile);
                                    if (i < lowestX) lowestX = i;
                                    if (i > highestX) highestX = i;
                                    if (j < lowestY) lowestY = j;
                                    if (j > highestY) highestY = j;

                                    stack.Push(new Point(i + 1, j));
                                    stack.Push(new Point(i - 1, j));
                                    stack.Push(new Point(i, j + 1));
                                    stack.Push(new Point(i, j - 1));
                                }
                                UndoBuffer.Add(CurrentMultiTile);
                                WldView.DelayDrawing = false;
                                WldView.UpdateArea(new Rectangle(lowestX, lowestY, highestX - lowestX + 1, highestY - lowestY + 1));
                            }

                            break;
                    }
                }
            }
            else if (EditMode == EditMode.Sprites)
            {
                CurrentSprite = SelectSprite(x, y);
                if (CurrentSprite != null && MouseButtons == MouseButtons.Left)
                {
                    WldView.SelectionRectangle = new Rectangle(CurrentSprite.X, CurrentSprite.Y, CurrentSprite.Width, CurrentSprite.Height);
                    ContinueDragging = true;
                    LblSprite.Text = "Current Sprite: " + CurrentSprite.InGameID.ToHexString() + " - " + CurrentSprite.Name + " - Item: " + CurrentSprite.Item;
                }
                else if (CurrentSprite != null && MouseButtons == MouseButtons.Right && CurrentSelectorSprite != null)
                {
                    CurrentSprite.InGameID = CurrentSelectorSprite.InGameID;
                    SpriteDefinition sp = ProjectController.SpriteManager.GetDefinition(CurrentSprite.InGameID);
                    int xDiff = x - CurrentSprite.X;
                    int yDiff = y - CurrentSprite.Y;
                    int rectX = xDiff >= 0 ? (CurrentSprite.X * 16) + sp.MaxLeftX : (x * 16) + sp.MaxLeftX;
                    int rectY = yDiff >= 0 ? (CurrentSprite.Y * 16) + sp.MaxTopY : (y * 16) + sp.MaxTopY;
                    int width = xDiff >= 0 ? ((x * 16) + sp.MaxRightX) - ((CurrentSprite.X * 16) + sp.MaxLeftX) : ((CurrentSprite.X * 16) + sp.MaxRightX) - ((x * 16) + sp.MaxLeftX);
                    int height = yDiff >= 0 ? ((y * 16) + sp.MaxBottomY) - ((CurrentSprite.Y * 16) + sp.MaxTopY) : ((CurrentSprite.Y * 16) + sp.MaxBottomY) - ((y * 16) + sp.MaxTopY);
                    Rectangle r = new Rectangle(rectX, rectY, width, height);
                    CurrentSprite.X = x;
                    CurrentSprite.Y = y;
                    WldView.DelayDrawing = true;
                    WldView.SelectionRectangle = new Rectangle(CurrentSprite.X, CurrentSprite.Y, CurrentSprite.Width, CurrentSprite.Height);
                    WldView.DelayDrawing = false;
                    WldView.UpdateSprites(r);
                }
                else if (CurrentSelectorSprite != null && MouseButtons == MouseButtons.Right)
                {
                    Sprite newSprite = new Sprite() { IsMapSprite = true, X = x, Y = y, InGameID = CurrentSelectorSprite.InGameID };
                    CurrentWorld.AddSprite(newSprite);
                    CurrentSprite = newSprite;
                    WldView.SelectionRectangle = new Rectangle(CurrentSprite.X, CurrentSprite.Y, CurrentSprite.Width, CurrentSprite.Height);
                    ContinueDragging = true;
                    LblSprite.Text = "Current Sprite: " + CurrentSprite.InGameID.ToHexString() + " - " + CurrentSprite.Name;
                }

                else
                {
                    WldView.ClearSelection();
                    ContinueDragging = false;
                    LblSprite.Text = "None";
                }
            }
            else if (EditMode == EditMode.Pointers)
            {
                WorldPointer p = CurrentWorld.Pointers.Find(pt => pt.X == x && pt.Y == y);
                PntEditor.CurrentPointer = p;
                CurrentPointer = p;
                if (p != null)
                {
                    WldView.SelectionRectangle = new Rectangle(p.X, p.Y, 1, 1);
                    ContinueDragging = true;
                    BtnDeletePointer.Enabled = true;
                }
                else
                {
                    BtnDeletePointer.Enabled = false;
                    WldView.ClearSelection();
                }
            }
        }
示例#2
0
        private void WldView_MouseUp(object sender, MouseEventArgs e)
        {
            if (!ContinueDrawing) return;
            int _DrawTile = 0;
            int sX, sY;

            if (e.Button == MouseButtons.Middle)
            {
                _DrawTile = 0;
            }
            else if (TileDrawMode != TileDrawMode.Selection)
            {
                if (e.Button == MouseButtons.Left)
                {
                    _DrawTile = LeftMouseTile;
                }
                else
                {
                    _DrawTile = RightMouseTile;
                }
            }
            else
            {
                _DrawTile = LeftMouseTile;
            }

            if (EditMode == EditMode.Tiles)
            {
                if (TileDrawMode == TileDrawMode.Pencil)
                {
                    UndoBuffer.Add(CurrentMultiTile);
                }
                else if ((WldView.HasSelection || WldView.HasSelectionLine))
                {
                    switch (TileDrawMode)
                    {
                        case TileDrawMode.Rectangle:
                            sX = WldView.SelectionRectangle.X;
                            sY = WldView.SelectionRectangle.Y;

                            UndoBuffer.Add(new TileAreaAction(sX, sY, CurrentWorld.GetData(sX, sY, WldView.SelectionRectangle.Width, WldView.SelectionRectangle.Height)));

                            WldView.DelayDrawing = true;
                            for (int y = WldView.SelectionRectangle.Y, i = 0; i < WldView.SelectionRectangle.Height; y++, i++)
                            {
                                for (int x = WldView.SelectionRectangle.X, j = 0; j < WldView.SelectionRectangle.Width; x++, j++)
                                {
                                    CurrentWorld.SetTile(x, y, (byte)_DrawTile);
                                }
                            }
                            WldView.DelayDrawing = false;
                            WldView.UpdateArea();
                            break;

                        case TileDrawMode.Outline:
                            sX = WldView.SelectionRectangle.X;
                            sY = WldView.SelectionRectangle.Y;

                            UndoBuffer.Add(new TileAreaAction(sX, sY, CurrentWorld.GetData(sX, sY, WldView.SelectionRectangle.Width, WldView.SelectionRectangle.Height)));

                            WldView.DelayDrawing = true;
                            for (int x = WldView.SelectionRectangle.X, i = 0; i < WldView.SelectionRectangle.Width; i++, x++)
                            {
                                CurrentWorld.SetTile(x, WldView.SelectionRectangle.Y, (byte)_DrawTile);
                                CurrentWorld.SetTile(x, WldView.SelectionRectangle.Y + WldView.SelectionRectangle.Height - 1, (byte)_DrawTile);
                            }

                            for (int y = WldView.SelectionRectangle.Y, i = 1; i < WldView.SelectionRectangle.Height; i++, y++)
                            {
                                CurrentWorld.SetTile(WldView.SelectionRectangle.X, y, (byte)_DrawTile);
                                CurrentWorld.SetTile(WldView.SelectionRectangle.X + WldView.SelectionRectangle.Width - 1, y, (byte)_DrawTile);
                            }
                            WldView.DelayDrawing = false;
                            WldView.UpdateArea();
                            break;

                        case TileDrawMode.Line:

                            WldView.DelayDrawing = true;
                            CurrentMultiTile = new MultiTileAction();
                            int breakAt = Math.Abs(WldView.SelectionLine.End.X - WldView.SelectionLine.Start.X) + 1;
                            if (WldView.SelectionLine.End.X > WldView.SelectionLine.Start.X)
                            {
                                if (WldView.SelectionLine.End.Y > WldView.SelectionLine.Start.Y)
                                {
                                    for (int i = 0; i < breakAt; i++)
                                    {
                                        if (WldView.SelectionLine.Start.X + i >= CurrentWorld.Width || WldView.SelectionLine.Start.Y + i >= CurrentWorld.Height) continue;
                                        sX = WldView.SelectionLine.Start.X + i;
                                        sY = WldView.SelectionLine.Start.Y + i;
                                        CurrentMultiTile.AddTileChange(sX, sY, CurrentWorld.LevelData[sX, sY]);
                                        CurrentWorld.SetTile(sX, sY, (byte)_DrawTile);
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < breakAt; i++)
                                    {
                                        if (WldView.SelectionLine.Start.X + i >= CurrentWorld.Width || WldView.SelectionLine.Start.Y - i >= CurrentWorld.Height) continue;
                                        sX = WldView.SelectionLine.Start.X + i;
                                        sY = WldView.SelectionLine.Start.Y - i;
                                        CurrentMultiTile.AddTileChange(sX, sY, CurrentWorld.LevelData[sX, sY]);
                                        CurrentWorld.SetTile(sX, sY, (byte)_DrawTile);
                                    }
                                }
                            }
                            else
                            {
                                if (WldView.SelectionLine.End.Y > WldView.SelectionLine.Start.Y)
                                {
                                    for (int i = 0; i < breakAt; i++)
                                    {
                                        if (WldView.SelectionLine.Start.X - i >= CurrentWorld.Width || WldView.SelectionLine.Start.Y + i >= CurrentWorld.Height) continue;
                                        sX = WldView.SelectionLine.Start.X - i;
                                        sY = WldView.SelectionLine.Start.Y + i;
                                        CurrentMultiTile.AddTileChange(sX, sY, CurrentWorld.LevelData[sX, sY]);
                                        CurrentWorld.SetTile(sX, sY, (byte)_DrawTile);
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < breakAt; i++)
                                    {
                                        if (WldView.SelectionLine.Start.X - i >= CurrentWorld.Width || WldView.SelectionLine.Start.Y - i >= CurrentWorld.Height) continue;
                                        sX = WldView.SelectionLine.Start.X - i;
                                        sY = WldView.SelectionLine.Start.Y - i;
                                        CurrentMultiTile.AddTileChange(sX, sY, CurrentWorld.LevelData[sX, sY]);
                                        CurrentWorld.SetTile(sX, sY, (byte)_DrawTile);
                                    }
                                }
                            }

                            UndoBuffer.Add(CurrentMultiTile);
                            WldView.DelayDrawing = false;
                            WldView.ClearLine();
                            break;

                        case TileDrawMode.Selection:
                            useTransparentTile = e.Button == MouseButtons.Right;
                            break;
                    }
                }
            }
        }
示例#3
0
        private void LvlView_MouseDown(object sender, MouseEventArgs e)
        {
            int x = (e.X / 16) / LvlView.Zoom;
            int y = (e.Y / 16) / LvlView.Zoom;
            PnlView.Focus();

            vMirrorButton.Enabled = hMirrorButton.Enabled = false;
            if (x < 0 || x >= CurrentLevel.Width || y < 0 || y >= CurrentLevel.Height)
                return;

            if (_SelectingStartPositionMode)
            {
                int oldX = CurrentLevel.XStart;
                int oldY = CurrentLevel.YStart;
                CurrentLevel.XStart = x;
                CurrentLevel.YStart = y;
                if (TsbStartPoint.Checked)
                {
                    LvlView.UpdatePoint(x, y);
                    LvlView.UpdatePoint(oldX, oldY);
                }
                _SelectingStartPositionMode = false;
                TlsTileCommands.Enabled = TlsDrawing.Enabled = TabLevelInfo.Enabled = true;
                SetHelpText(PreviousHelperText);
                LblStartPoint.Text = string.Format("X: {0} Y: {1}", CurrentLevel.XStart.ToHexString(), CurrentLevel.YStart.ToHexString());
            }
            else if (_PlacingPointer)
            {
                _PlacingPointer = false;
                CurrentLevel.AddPointer();
                CurrentPointer = PntEditor.CurrentPointer = CurrentLevel.Pointers[CurrentLevel.Pointers.Count - 1];
                CurrentPointer.XEnter = x;
                CurrentPointer.YEnter = y;
                LvlView.DelayDrawing = true;
                LvlView.UpdatePoint(x, y);
                LvlView.UpdatePoint(x + 1, y);
                LvlView.UpdatePoint(x, y + 1);
                LvlView.UpdatePoint(x + 1, y + 1);
                LvlView.DelayDrawing = false;
                LvlView.SelectionRectangle = new Rectangle(x, y, 2, 2);
                BtnAddPointer.Enabled = CurrentLevel.Pointers.Count <= 10;
                TabEditSelector.Enabled = PnlInfo.Enabled = true;
                SetHelpText(Reuben.Properties.Resources.PointerHelper);
            }

            else if (EditMode == EditMode.Tiles)
            {
                if (ModifierKeys == Keys.Shift)
                {
                    BlsSelector.SelectedTileIndex = CurrentLevel.LevelData[x, y];
                    BlsSelector_SelectionChanged(this, new TEventArgs<MouseButtons>(e.Button));
                }
                else
                {
                    LvlView.ClearSelection();
                    if (TileDrawMode == TileDrawMode.Selection)
                    {
                        TileDrawMode = PreviousMode;
                    }

                    if (e.Button == MouseButtons.Right && MouseMode == MouseMode.RightClickSelection)
                    {
                        PreviousMode = TileDrawMode;
                        TileDrawMode = TileDrawMode.Selection;
                    }

                    switch (TileDrawMode)
                    {
                        case TileDrawMode.Pencil:
                            CurrentMultiTile = new MultiTileAction();
                            CurrentMultiTile.AddTileChange(x, y, CurrentLevel.LevelData[x, y]);
                            CurrentLevel.SetTile(x, y, (byte)(DrawingTile));
                            ContinueDrawing = true;
                            break;

                        case TileDrawMode.Outline:
                        case TileDrawMode.Rectangle:
                        case TileDrawMode.Scatter:
                        case TileDrawMode.Selection:
                            StartX = x;
                            StartY = y;
                            ContinueDrawing = true;
                            LvlView.SelectionRectangle = new Rectangle(StartX, StartY, 1, 1);
                            break;

                        case TileDrawMode.Line:
                            StartX = x;
                            StartY = y;
                            ContinueDrawing = true;
                            LvlView.SelectionLine = new Line(StartX, StartY, StartX, StartY);
                            break;

                        case TileDrawMode.Fill:
                            Point start = new Point(x, y);
                            Stack<Point> stack = new Stack<Point>();
                            stack.Push(start);
                            int checkValue = CurrentLevel.LevelData[x, y];
                            if (checkValue == DrawingTile)
                                return;

                            CurrentMultiTile = new MultiTileAction();
                            while (stack.Count > 0)
                            {
                                Point p = stack.Pop();
                                int lowestX, highestX;
                                ;
                                int lowestY, highestY;
                                lowestX = highestX = x;
                                lowestY = highestY = y;
                                int i = p.X;
                                int j = p.Y;
                                if (CurrentLevel.LevelLayout == LevelLayout.Horizontal)
                                {
                                    if (j < 0 || j >= CurrentLevel.Height || i < 0 || i >= CurrentLevel.Length * 16)
                                    {
                                        continue;
                                    }
                                }
                                else
                                {
                                    if (j < 0 || j >= (CurrentLevel.Length * 15) - 4 || i < 0 || i >= CurrentLevel.Width)
                                    {
                                        continue;
                                    }
                                }

                                LvlView.DelayDrawing = true;
                                if (checkValue == CurrentLevel.LevelData[i, j])
                                {
                                    CurrentMultiTile.AddTileChange(i, j, CurrentLevel.LevelData[i, j]);
                                    CurrentLevel.SetTile(i, j, (byte)DrawingTile);
                                    if (i < lowestX)
                                        lowestX = i;
                                    if (i > highestX)
                                        highestX = i;
                                    if (j < lowestY)
                                        lowestY = j;
                                    if (j > highestY)
                                        highestY = j;

                                    stack.Push(new Point(i + 1, j));
                                    stack.Push(new Point(i - 1, j));
                                    stack.Push(new Point(i, j + 1));
                                    stack.Push(new Point(i, j - 1));
                                }
                                UndoBuffer.Add(CurrentMultiTile);
                                LvlView.DelayDrawing = false;
                                LvlView.UpdateArea(new Rectangle(lowestX, lowestY, highestX - lowestX + 1, highestY - lowestY + 1));
                            }

                            break;

                        case TileDrawMode.Replace:
                            LvlView.DelayDrawing = true;
                            int findTile = CurrentLevel.LevelData[x, y];
                            MultiTileAction mta = new MultiTileAction();
                            for (int i = 0; i < (15 * 16); i++)
                            {
                                for (int j = 0; j < 0x1B; j++)
                                {
                                    if (CurrentLevel.LevelData[i, j] == findTile)
                                    {
                                        mta.AddTileChange(i, j, CurrentLevel.LevelData[i, j]);
                                        CurrentLevel.LevelData[i, j] = (byte)DrawingTile;
                                    }
                                }
                            }

                            LvlView.DelayDrawing = false;
                            ;
                            LvlView.FullUpdate();
                            break;
                    }
                }
            }
            else if (EditMode == EditMode.Sprites)
            {
                previousSprite = CurrentSprite;
                CurrentSprite = SelectSprite(x, y);

                modifySpriteVisiblity = false;

                if (CurrentSprite == null)
                {
                    CmbSpriteProperty.Enabled = false;
                    CmbSpriteProperty.SelectedIndex = -1;
                    CmbSpriteProperty.DataSource = null;
                }

                if (CurrentSprite != null)
                {
                    SpriteDefinition def = ProjectController.SpriteManager.GetDefinition(CurrentSprite.InGameID);
                    if (def != null)
                    {
                        CmbSpriteProperty.DataSource = def.PropertyDescriptions;
                    }
                    else
                    {
                        CmbSpriteProperty.DataSource = null;
                    }
                }

                if (CurrentSprite != null && MouseButtons == MouseButtons.Left)
                {
                    if (CmbSpriteProperty.Items.Count > 0)
                    {
                        CmbSpriteProperty.SelectedIndex = CurrentSprite.Property;
                    }
                    CmbSpriteProperty.Enabled = true;

                    LvlView.SelectionRectangle = new Rectangle(CurrentSprite.X, CurrentSprite.Y, CurrentSprite.Width, CurrentSprite.Height);
                    ContinueDragging = true;
                    LblSprite.Text = "Current Sprite: " + CurrentSprite.InGameID.ToHexString() + " - " + CurrentSprite.Name;
                    if (ModifierKeys == Keys.Shift)
                    {
                        ((SpriteViewer)TabClass1.SelectedTab.Controls[0]).SelectedSprite = null;
                        ((SpriteViewer)TabClass2.SelectedTab.Controls[0]).SelectedSprite = null;
                        ((SpriteViewer)TabClass3.SelectedTab.Controls[0]).SelectedSprite = null;

                        SpriteDefinition sDef = ProjectController.SpriteManager.GetDefinition(CurrentSprite.InGameID);
                        switch (sDef.Class)
                        {
                            case 1:
                                foreach (TabPage t in TabClass1.TabPages)
                                {
                                    if (t.Text == sDef.Group)
                                    {
                                        TabClass1.SelectedTab = t;
                                    }
                                }
                                break;

                            case 2:
                                foreach (TabPage t in TabClass2.TabPages)
                                {
                                    if (t.Text == sDef.Group)
                                    {
                                        TabClass2.SelectedTab = t;
                                    }
                                }
                                break;

                            case 3:
                                foreach (TabPage t in TabClass3.TabPages)
                                {
                                    if (t.Text == sDef.Group)
                                    {
                                        TabClass3.SelectedTab = t;
                                    }
                                }
                                break;
                        }

                        SpriteViewer sv = SpriteViewers.Find(s => s.SpriteList.Find(c => c.InGameID == CurrentSprite.InGameID) != null);
                        sv.SetSelectedSprite(CurrentSprite);
                        CurrentSelectorSprite = sv.SelectedSprite;
                    }
                }
                else if (CurrentSprite != null && MouseButtons == MouseButtons.Right && CurrentSelectorSprite != null)
                {
                    CurrentSprite.InGameID = CurrentSelectorSprite.InGameID;
                    CurrentSprite.Property = 0;
                    CurrentSprite.Property = CurrentSelectorSprite.Property;
                    SpriteDefinition sp = ProjectController.SpriteManager.GetDefinition(CurrentSprite.InGameID);
                    int xDiff = x - CurrentSprite.X;
                    int yDiff = y - CurrentSprite.Y;
                    int rectX = xDiff >= 0 ? (CurrentSprite.X * 16) + sp.MaxLeftX : (x * 16) + sp.MaxLeftX;
                    int rectY = yDiff >= 0 ? (CurrentSprite.Y * 16) + sp.MaxTopY : (y * 16) + sp.MaxTopY;
                    int width = xDiff >= 0 ? ((x * 16) + sp.MaxRightX) - ((CurrentSprite.X * 16) + sp.MaxLeftX) : ((CurrentSprite.X * 16) + sp.MaxRightX) - ((x * 16) + sp.MaxLeftX);
                    int height = yDiff >= 0 ? ((y * 16) + sp.MaxBottomY) - ((CurrentSprite.Y * 16) + sp.MaxTopY) : ((CurrentSprite.Y * 16) + sp.MaxBottomY) - ((y * 16) + sp.MaxTopY);
                    Rectangle r = new Rectangle(rectX, rectY, width, height);
                    CurrentSprite.X = x;
                    CurrentSprite.Y = y;
                    LvlView.DelayDrawing = true;
                    LvlView.SelectionRectangle = new Rectangle(CurrentSprite.X, CurrentSprite.Y, CurrentSprite.Width, CurrentSprite.Height);
                    LvlView.DelayDrawing = false;
                    LvlView.UpdateSprites(r);
                }
                else if (CurrentSelectorSprite != null && MouseButtons == MouseButtons.Right)
                {
                    Sprite newSprite = new Sprite() { X = x, Y = y, InGameID = CurrentSelectorSprite.InGameID };
                    if (previousSprite != null && newSprite.InGameID == previousSprite.InGameID)
                    {
                        newSprite.Property = previousSprite.Property;
                    }
                    
                    CurrentLevel.AddSprite(newSprite);
                    CurrentSprite = newSprite;
                    LvlView.SelectionRectangle = new Rectangle(CurrentSprite.X, CurrentSprite.Y, CurrentSprite.Width, CurrentSprite.Height);
                    ContinueDragging = true;
                    LblSprite.Text = "Current Sprite: " + CurrentSprite.InGameID.ToHexString() + " - " + CurrentSprite.Name;
                    CmbSpriteProperty.DataSource = ProjectController.SpriteManager.GetDefinition(CurrentSprite.InGameID).PropertyDescriptions;
                    CmbSpriteProperty.Enabled = CmbSpriteProperty.DataSource != null && CmbSpriteProperty.Items.Count > 1;

                    if (CmbSpriteProperty.Enabled)
                    {
                        CmbSpriteProperty.SelectedIndex = CurrentSprite.Property;
                    }
                }
                else
                {
                    LvlView.ClearSelection();
                    ContinueDragging = false;
                    LblSprite.Text = "None";
                }

                modifySpriteVisiblity = true;
            }
            else if (EditMode == EditMode.Pointers)
            {
                LevelPointer p = CurrentLevel.Pointers.Find(pt => (pt.XEnter == x || pt.XEnter + 1 == x) && (pt.YEnter == y || pt.YEnter + 1 == y));
                PntEditor.CurrentPointer = p;
                CurrentPointer = p;
                if (p != null)
                {
                    LvlView.SelectionRectangle = new Rectangle(p.XEnter, p.YEnter, 2, 2);
                    ContinueDragging = true;
                    BtnDeletePointer.Enabled = true;
                }
                else
                {
                    BtnDeletePointer.Enabled = false;
                    LvlView.ClearSelection();
                }
            }
        }