From e2aa69bb4aae208962b67fdc252a0e276677e5cf Mon Sep 17 00:00:00 2001
From: Celeste Montero Salinas <20286979+monteroci@users.noreply.github.com>
Date: Tue, 20 Jun 2023 17:51:39 -0400
Subject: [PATCH 1/4] add snap-to-grid to object tool
---
Editor.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Editor.cs b/Editor.cs
index 6d54a53..245f21e 100644
--- a/Editor.cs
+++ b/Editor.cs
@@ -1118,7 +1118,8 @@ public void ButtonPress(short X, short Y, EditorModifiers mods) {
undoSet = false;
Fill(X, Y);
} else if (Tool == Tool.Object) {
- PlaceObject(X, Y);
+ Point p = GridAdjust(new Point(X, Y));
+ PlaceObject(p.X, p.Y);
} else if (Tool == Tool.Annotation) {
PlaceAnnotation(X, Y);
} else if (Tool == Tool.VisualMode) {
From 7333aa99da80b562e54c71738a29dbc4dae6c7aa Mon Sep 17 00:00:00 2001
From: Celeste Montero Salinas <20286979+monteroci@users.noreply.github.com>
Date: Wed, 12 Jul 2023 17:39:59 -0400
Subject: [PATCH 2/4] add preference for place object snap
---
Editor.cs | 7 ++++++-
glade/preferences.glade | 14 ++++++++++++++
gtk-sharp/PreferencesDialog.cs | 4 ++++
3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/Editor.cs b/Editor.cs
index 245f21e..bd3fbfe 100644
--- a/Editor.cs
+++ b/Editor.cs
@@ -133,12 +133,14 @@ public Tool Tool {
public int ObjectSnapDistance;
public int InertiaDistance;
public bool SplitPolygonLines;
+ public bool SnapPlaceObjects;
public void LoadSettings() {
DefaultSnapDistance = Weland.Settings.GetSetting("Distance/Select/Default", 4);
ObjectSnapDistance = Weland.Settings.GetSetting("Distance/Select/Object", 8);
InertiaDistance = Weland.Settings.GetSetting("Distance/Inertia/Default", 8);
SplitPolygonLines = Weland.Settings.GetSetting("Editor/SplitPolygonLines", false);
+ SnapPlaceObjects = Weland.Settings.GetSetting("Editor/SnapPlaceObjects", false);
}
public void SaveSettings() {
@@ -146,6 +148,7 @@ public void SaveSettings() {
Weland.Settings.PutSetting("Distance/Select/Object", ObjectSnapDistance);
Weland.Settings.PutSetting("Distance/Inertia/Default", InertiaDistance);
Weland.Settings.PutSetting("Editor/SplitPolygonLines", SplitPolygonLines);
+ Weland.Settings.PutSetting("Editor/SnapPlaceObjects", SnapPlaceObjects);
}
public Editor() {
@@ -1112,13 +1115,15 @@ public void ButtonPress(short X, short Y, EditorModifiers mods) {
Select(X, Y);
}
} else if (!RightClick(mods)) {
+ Point p = new Point(X, Y);
+
if (Tool == Tool.Line) {
StartLine(X, Y);
} else if (Tool == Tool.Fill) {
undoSet = false;
Fill(X, Y);
} else if (Tool == Tool.Object) {
- Point p = GridAdjust(new Point(X, Y));
+ if (SnapPlaceObjects) { p = GridAdjust(p); }
PlaceObject(p.X, p.Y);
} else if (Tool == Tool.Annotation) {
PlaceAnnotation(X, Y);
diff --git a/glade/preferences.glade b/glade/preferences.glade
index 20afb87..3b41f20 100644
--- a/glade/preferences.glade
+++ b/glade/preferences.glade
@@ -862,6 +862,20 @@
1
+
+
+ Snap When Placing Objects
+ True
+ True
+ False
+ True
+
+
+ True
+ True
+ 2
+
+
diff --git a/gtk-sharp/PreferencesDialog.cs b/gtk-sharp/PreferencesDialog.cs
index 8e6cfbe..8fed71a 100644
--- a/gtk-sharp/PreferencesDialog.cs
+++ b/gtk-sharp/PreferencesDialog.cs
@@ -49,6 +49,7 @@ public void Run() {
antialias.Active = Weland.Settings.GetSetting("Drawer/SmoothLines", true);
showHiddenVertices.Active = Weland.Settings.GetSetting("MapWindow/ShowHiddenVertices", true);
rememberDeletedSides.Active = Weland.Settings.GetSetting("Editor/RememberDeletedSides", false);
+ snapPlaceObjects.Active = Weland.Settings.GetSetting("Editor/SnapPlaceObjects", false);
LoadColors(area);
selectionDistance.Value = editor.DefaultSnapDistance;
@@ -66,6 +67,7 @@ public void Run() {
Weland.Settings.PutSetting("Drawer/SmoothLines", antialias.Active);
Weland.Settings.PutSetting("MapWindow/ShowHiddenVertices", showHiddenVertices.Active);
Weland.Settings.PutSetting("Editor/RememberDeletedSides", rememberDeletedSides.Active);
+ Weland.Settings.PutSetting("Editor/SnapPlaceObjects", snapPlaceObjects.Active);
if (Weland.Settings.GetSetting("ShapesFile/Path", "") != shapesFileButton.Filename) {
Weland.Settings.PutSetting("ShapesFile/Path", shapesFileButton.Filename);
ShapesFile shapes = new ShapesFile();
@@ -100,6 +102,7 @@ public void Run() {
editor.ObjectSnapDistance = (int) objectDistance.Value;
editor.InertiaDistance = (int) dragInertia.Value;
editor.SplitPolygonLines = splitPolygonLines.Active;
+ editor.SnapPlaceObjects = snapPlaceObjects.Active;
editor.SaveSettings();
}
dialog1.Destroy();
@@ -160,6 +163,7 @@ protected void OnEditPreferences(object o, EventArgs args) {
[Widget] ToggleButton showHiddenVertices;
[Widget] ToggleButton splitPolygonLines;
[Widget] ToggleButton rememberDeletedSides;
+ [Widget] ToggleButton snapPlaceObjects;
[Widget] ColorButton backgroundColor;
[Widget] ColorButton gridColor;
From 410c1eeb2ac1df6b043400ce19cf7f5690f53b17 Mon Sep 17 00:00:00 2001
From: Celeste Montero Salinas <20286979+monteroci@users.noreply.github.com>
Date: Sat, 15 Jul 2023 13:38:10 -0400
Subject: [PATCH 3/4] add snap objects with select, rename preference
---
Editor.cs | 9 +++++----
glade/preferences.glade | 4 ++--
gtk-sharp/PreferencesDialog.cs | 8 ++++----
3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/Editor.cs b/Editor.cs
index bd3fbfe..b36b018 100644
--- a/Editor.cs
+++ b/Editor.cs
@@ -133,14 +133,14 @@ public Tool Tool {
public int ObjectSnapDistance;
public int InertiaDistance;
public bool SplitPolygonLines;
- public bool SnapPlaceObjects;
+ public bool SnapObjects;
public void LoadSettings() {
DefaultSnapDistance = Weland.Settings.GetSetting("Distance/Select/Default", 4);
ObjectSnapDistance = Weland.Settings.GetSetting("Distance/Select/Object", 8);
InertiaDistance = Weland.Settings.GetSetting("Distance/Inertia/Default", 8);
SplitPolygonLines = Weland.Settings.GetSetting("Editor/SplitPolygonLines", false);
- SnapPlaceObjects = Weland.Settings.GetSetting("Editor/SnapPlaceObjects", false);
+ SnapObjects = Weland.Settings.GetSetting("Editor/SnapObjects", false);
}
public void SaveSettings() {
@@ -148,7 +148,7 @@ public void SaveSettings() {
Weland.Settings.PutSetting("Distance/Select/Object", ObjectSnapDistance);
Weland.Settings.PutSetting("Distance/Inertia/Default", InertiaDistance);
Weland.Settings.PutSetting("Editor/SplitPolygonLines", SplitPolygonLines);
- Weland.Settings.PutSetting("Editor/SnapPlaceObjects", SnapPlaceObjects);
+ Weland.Settings.PutSetting("Editor/SnapObjects", SnapObjects);
}
public Editor() {
@@ -708,6 +708,7 @@ void MoveSelected(short X, short Y) {
MapObject obj = Level.Objects[Selection.Object];
AddDirty(new Point(obj.X, obj.Y));
Point p = new Point((short) (X), (short) (Y));
+ if (SnapObjects) { p = GridAdjust(p); }
short polygon_index = Level.GetEnclosingPolygon(p);
if (polygon_index != -1) {
obj.X = p.X;
@@ -1123,7 +1124,7 @@ public void ButtonPress(short X, short Y, EditorModifiers mods) {
undoSet = false;
Fill(X, Y);
} else if (Tool == Tool.Object) {
- if (SnapPlaceObjects) { p = GridAdjust(p); }
+ if (SnapObjects) { p = GridAdjust(p); }
PlaceObject(p.X, p.Y);
} else if (Tool == Tool.Annotation) {
PlaceAnnotation(X, Y);
diff --git a/glade/preferences.glade b/glade/preferences.glade
index 3b41f20..d7f740b 100644
--- a/glade/preferences.glade
+++ b/glade/preferences.glade
@@ -863,8 +863,8 @@
-
- Snap When Placing Objects
+
+ Snap Objects To Grid
True
True
False
diff --git a/gtk-sharp/PreferencesDialog.cs b/gtk-sharp/PreferencesDialog.cs
index 8fed71a..45e2e9e 100644
--- a/gtk-sharp/PreferencesDialog.cs
+++ b/gtk-sharp/PreferencesDialog.cs
@@ -49,7 +49,7 @@ public void Run() {
antialias.Active = Weland.Settings.GetSetting("Drawer/SmoothLines", true);
showHiddenVertices.Active = Weland.Settings.GetSetting("MapWindow/ShowHiddenVertices", true);
rememberDeletedSides.Active = Weland.Settings.GetSetting("Editor/RememberDeletedSides", false);
- snapPlaceObjects.Active = Weland.Settings.GetSetting("Editor/SnapPlaceObjects", false);
+ snapObjects.Active = Weland.Settings.GetSetting("Editor/SnapObjects", false);
LoadColors(area);
selectionDistance.Value = editor.DefaultSnapDistance;
@@ -67,7 +67,7 @@ public void Run() {
Weland.Settings.PutSetting("Drawer/SmoothLines", antialias.Active);
Weland.Settings.PutSetting("MapWindow/ShowHiddenVertices", showHiddenVertices.Active);
Weland.Settings.PutSetting("Editor/RememberDeletedSides", rememberDeletedSides.Active);
- Weland.Settings.PutSetting("Editor/SnapPlaceObjects", snapPlaceObjects.Active);
+ Weland.Settings.PutSetting("Editor/SnapObjects", snapObjects.Active);
if (Weland.Settings.GetSetting("ShapesFile/Path", "") != shapesFileButton.Filename) {
Weland.Settings.PutSetting("ShapesFile/Path", shapesFileButton.Filename);
ShapesFile shapes = new ShapesFile();
@@ -102,7 +102,7 @@ public void Run() {
editor.ObjectSnapDistance = (int) objectDistance.Value;
editor.InertiaDistance = (int) dragInertia.Value;
editor.SplitPolygonLines = splitPolygonLines.Active;
- editor.SnapPlaceObjects = snapPlaceObjects.Active;
+ editor.SnapObjects = snapObjects.Active;
editor.SaveSettings();
}
dialog1.Destroy();
@@ -163,7 +163,7 @@ protected void OnEditPreferences(object o, EventArgs args) {
[Widget] ToggleButton showHiddenVertices;
[Widget] ToggleButton splitPolygonLines;
[Widget] ToggleButton rememberDeletedSides;
- [Widget] ToggleButton snapPlaceObjects;
+ [Widget] ToggleButton snapObjects;
[Widget] ColorButton backgroundColor;
[Widget] ColorButton gridColor;
From dfbbab2a5f5bc3739e24815ea51a85fbf15bb1b9 Mon Sep 17 00:00:00 2001
From: Celeste Montero Salinas <20286979+monteroci@users.noreply.github.com>
Date: Sat, 15 Jul 2023 14:20:48 -0400
Subject: [PATCH 4/4] remove preference
---
Editor.cs | 7 ++-----
glade/preferences.glade | 14 --------------
gtk-sharp/PreferencesDialog.cs | 4 ----
3 files changed, 2 insertions(+), 23 deletions(-)
diff --git a/Editor.cs b/Editor.cs
index b36b018..2580609 100644
--- a/Editor.cs
+++ b/Editor.cs
@@ -133,14 +133,12 @@ public Tool Tool {
public int ObjectSnapDistance;
public int InertiaDistance;
public bool SplitPolygonLines;
- public bool SnapObjects;
public void LoadSettings() {
DefaultSnapDistance = Weland.Settings.GetSetting("Distance/Select/Default", 4);
ObjectSnapDistance = Weland.Settings.GetSetting("Distance/Select/Object", 8);
InertiaDistance = Weland.Settings.GetSetting("Distance/Inertia/Default", 8);
SplitPolygonLines = Weland.Settings.GetSetting("Editor/SplitPolygonLines", false);
- SnapObjects = Weland.Settings.GetSetting("Editor/SnapObjects", false);
}
public void SaveSettings() {
@@ -148,7 +146,6 @@ public void SaveSettings() {
Weland.Settings.PutSetting("Distance/Select/Object", ObjectSnapDistance);
Weland.Settings.PutSetting("Distance/Inertia/Default", InertiaDistance);
Weland.Settings.PutSetting("Editor/SplitPolygonLines", SplitPolygonLines);
- Weland.Settings.PutSetting("Editor/SnapObjects", SnapObjects);
}
public Editor() {
@@ -708,7 +705,7 @@ void MoveSelected(short X, short Y) {
MapObject obj = Level.Objects[Selection.Object];
AddDirty(new Point(obj.X, obj.Y));
Point p = new Point((short) (X), (short) (Y));
- if (SnapObjects) { p = GridAdjust(p); }
+ p = GridAdjust(p);
short polygon_index = Level.GetEnclosingPolygon(p);
if (polygon_index != -1) {
obj.X = p.X;
@@ -1124,7 +1121,7 @@ public void ButtonPress(short X, short Y, EditorModifiers mods) {
undoSet = false;
Fill(X, Y);
} else if (Tool == Tool.Object) {
- if (SnapObjects) { p = GridAdjust(p); }
+ p = GridAdjust(p);
PlaceObject(p.X, p.Y);
} else if (Tool == Tool.Annotation) {
PlaceAnnotation(X, Y);
diff --git a/glade/preferences.glade b/glade/preferences.glade
index d7f740b..20afb87 100644
--- a/glade/preferences.glade
+++ b/glade/preferences.glade
@@ -862,20 +862,6 @@
1
-
-
- Snap Objects To Grid
- True
- True
- False
- True
-
-
- True
- True
- 2
-
-
diff --git a/gtk-sharp/PreferencesDialog.cs b/gtk-sharp/PreferencesDialog.cs
index 45e2e9e..8e6cfbe 100644
--- a/gtk-sharp/PreferencesDialog.cs
+++ b/gtk-sharp/PreferencesDialog.cs
@@ -49,7 +49,6 @@ public void Run() {
antialias.Active = Weland.Settings.GetSetting("Drawer/SmoothLines", true);
showHiddenVertices.Active = Weland.Settings.GetSetting("MapWindow/ShowHiddenVertices", true);
rememberDeletedSides.Active = Weland.Settings.GetSetting("Editor/RememberDeletedSides", false);
- snapObjects.Active = Weland.Settings.GetSetting("Editor/SnapObjects", false);
LoadColors(area);
selectionDistance.Value = editor.DefaultSnapDistance;
@@ -67,7 +66,6 @@ public void Run() {
Weland.Settings.PutSetting("Drawer/SmoothLines", antialias.Active);
Weland.Settings.PutSetting("MapWindow/ShowHiddenVertices", showHiddenVertices.Active);
Weland.Settings.PutSetting("Editor/RememberDeletedSides", rememberDeletedSides.Active);
- Weland.Settings.PutSetting("Editor/SnapObjects", snapObjects.Active);
if (Weland.Settings.GetSetting("ShapesFile/Path", "") != shapesFileButton.Filename) {
Weland.Settings.PutSetting("ShapesFile/Path", shapesFileButton.Filename);
ShapesFile shapes = new ShapesFile();
@@ -102,7 +100,6 @@ public void Run() {
editor.ObjectSnapDistance = (int) objectDistance.Value;
editor.InertiaDistance = (int) dragInertia.Value;
editor.SplitPolygonLines = splitPolygonLines.Active;
- editor.SnapObjects = snapObjects.Active;
editor.SaveSettings();
}
dialog1.Destroy();
@@ -163,7 +160,6 @@ protected void OnEditPreferences(object o, EventArgs args) {
[Widget] ToggleButton showHiddenVertices;
[Widget] ToggleButton splitPolygonLines;
[Widget] ToggleButton rememberDeletedSides;
- [Widget] ToggleButton snapObjects;
[Widget] ColorButton backgroundColor;
[Widget] ColorButton gridColor;