Skip to content

Commit

Permalink
Only drag an object if the left mouse button is above the object when…
Browse files Browse the repository at this point in the history
… the button is first pressed down
  • Loading branch information
Rampastring committed Aug 21, 2024
1 parent 1aa4857 commit 7fd1d5c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/TSMapEditor/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace TSMapEditor
{
public static class Constants
{
public const string ReleaseVersion = "1.1.4";
public const string ReleaseVersion = "1.1.5";

public static int CellSizeX = 48;
public static int CellSizeY = 24;
Expand Down
49 changes: 25 additions & 24 deletions src/TSMapEditor/Rendering/MapView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,30 @@ public override void OnMouseOnControl()
}
}

// Attempt dragging or rotating an object
if (CursorAction == null && tileUnderCursor != null && Cursor.LeftPressedDown && !isDraggingObject && !isRotatingObject)
{
var cellObject = tileUnderCursor.GetObject();

if (cellObject != null)
{
draggedOrRotatedObject = tileUnderCursor.GetObject();

if (draggedOrRotatedObject != null)
{
if (KeyboardCommands.Instance.RotateUnit.AreKeysDown(Keyboard))
isRotatingObject = true;
else
isDraggingObject = true;
}
}
else if (tileUnderCursor.Waypoints.Count > 0)
{
draggedOrRotatedObject = tileUnderCursor.Waypoints[0];
isDraggingObject = true;
}
}

if (isRightClickScrolling)
{
if (Cursor.RightDown)
Expand Down Expand Up @@ -1373,30 +1397,7 @@ public override void OnMouseMove()
}
else
{
CursorAction.LeftUpOnMouseMove(tileUnderCursor == null ? new Point2D(-1, -1) : tileUnderCursor.CoordsToPoint());
}
}

if (CursorAction == null && tileUnderCursor != null && Cursor.LeftDown && !isDraggingObject && !isRotatingObject)
{
var cellObject = tileUnderCursor.GetObject();

if (cellObject != null)
{
draggedOrRotatedObject = tileUnderCursor.GetObject();

if (draggedOrRotatedObject != null)
{
if (KeyboardCommands.Instance.RotateUnit.AreKeysDown(Keyboard))
isRotatingObject = true;
else
isDraggingObject = true;
}
}
else if (tileUnderCursor.Waypoints.Count > 0)
{
draggedOrRotatedObject = tileUnderCursor.Waypoints[0];
isDraggingObject = true;
CursorAction.LeftUpOnMouseMove(tileUnderCursor == null ? Point2D.NegativeOne : tileUnderCursor.CoordsToPoint());
}
}

Expand Down

0 comments on commit 7fd1d5c

Please sign in to comment.