From 8c290a9e7cccf3b6b8dc1619be6d032d6ace66f3 Mon Sep 17 00:00:00 2001
From: sphere <spherallic@gmail.com>
Date: Wed, 10 Nov 2021 01:21:37 +0100
Subject: [PATCH] Edit Selection mode: add actions for moving the selection
 around the grid.

---
 .../ClassicModes/EditSelectionMode.cs         | 48 +++++++++++++++++++
 .../BuilderModes/Resources/Actions.cfg        | 40 ++++++++++++++++
 2 files changed, 88 insertions(+)

diff --git a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs
index 19578bca..87780cc3 100644
--- a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs
+++ b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs
@@ -1910,6 +1910,54 @@ namespace CodeImp.DoomBuilder.BuilderModes
 			General.Interface.RedrawDisplay();
 		}
 
+		[BeginAction("moveselectionup")]
+		public void MoveSelectionUp()
+		{
+			offset.y += General.Map.Grid.GridSize;
+
+			// Update
+			UpdateGeometry();
+			UpdateRectangleComponents();
+			General.Map.Map.Update();
+			General.Interface.RedrawDisplay();
+		}
+
+		[BeginAction("moveselectiondown")]
+		public void MoveSelectionDown()
+		{
+			offset.y -= General.Map.Grid.GridSize;
+
+			// Update
+			UpdateGeometry();
+			UpdateRectangleComponents();
+			General.Map.Map.Update();
+			General.Interface.RedrawDisplay();
+		}
+
+		[BeginAction("moveselectionleft")]
+		public void MoveSelectionLeft()
+		{
+			offset.x -= General.Map.Grid.GridSize;
+
+			// Update
+			UpdateGeometry();
+			UpdateRectangleComponents();
+			General.Map.Map.Update();
+			General.Interface.RedrawDisplay();
+		}
+
+		[BeginAction("moveselectionright")]
+		public void MoveSelectionRight()
+		{
+			offset.x += General.Map.Grid.GridSize;
+
+			// Update
+			UpdateGeometry();
+			UpdateRectangleComponents();
+			General.Map.Map.Update();
+			General.Interface.RedrawDisplay();
+		}
+
 		#endregion
 	}
 }
diff --git a/Source/Plugins/BuilderModes/Resources/Actions.cfg b/Source/Plugins/BuilderModes/Resources/Actions.cfg
index 03a8c5ae..c863886a 100644
--- a/Source/Plugins/BuilderModes/Resources/Actions.cfg
+++ b/Source/Plugins/BuilderModes/Resources/Actions.cfg
@@ -1325,6 +1325,46 @@ flipselectionh
 	allowscroll = true;
 }
 
+moveselectionup
+{
+	title = "Move Selection Up by grid size";
+	category = "edit";
+	description = "Moves the selection in Edit Selection mode up by the current grid size.";
+	allowkeys = true;
+	allowmouse = true;
+	allowscroll = true;
+}
+
+moveselectiondown
+{
+	title = "Move Selection Down by grid size";
+	category = "edit";
+	description = "Moves the selection in Edit Selection mode down by the current grid size.";
+	allowkeys = true;
+	allowmouse = true;
+	allowscroll = true;
+}
+
+moveselectionleft
+{
+	title = "Move Selection Left by grid size";
+	category = "edit";
+	description = "Moves the selection in Edit Selection mode left by the current grid size.";
+	allowkeys = true;
+	allowmouse = true;
+	allowscroll = true;
+}
+
+moveselectionright
+{
+	title = "Move Selection Right by grid size";
+	category = "edit";
+	description = "Moves the selection in Edit Selection mode right by the current grid size.";
+	allowkeys = true;
+	allowmouse = true;
+	allowscroll = true;
+}
+
 //mxd
 rotateclockwise
 {
-- 
GitLab