From d65fb7bbab44ca1aa265f67e6c8bf3d62d8dd09f Mon Sep 17 00:00:00 2001 From: biwa <6475593+biwa@users.noreply.github.com> Date: Sun, 31 Jan 2021 00:12:07 +0100 Subject: [PATCH] Fixed a bug where map elements could be selected multiple times when paint selecting in visual mode. Fixes #519. Fixes #520 --- .../VisualModes/BaseVisualGeometrySector.cs | 19 ++++++++++++------- .../VisualModes/BaseVisualGeometrySidedef.cs | 18 ++++++++++++------ .../VisualModes/BaseVisualThing.cs | 18 ++++++++++++------ 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs index 60766462..b897c7a5 100755 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs @@ -1001,23 +1001,28 @@ namespace CodeImp.DoomBuilder.BuilderModes // toggle selected state if (General.Interface.ShiftState ^ BuilderPlug.Me.AdditivePaintSelect) { - this.selected = true; - mode.AddSelectedObject(this); + if (!selected) + { + selected = true; + mode.AddSelectedObject(this); + } } else if (General.Interface.CtrlState) { - this.selected = false; - mode.RemoveSelectedObject(this); - + if (selected) + { + selected = false; + mode.RemoveSelectedObject(this); + } } else { - if (this.selected) + if (selected) mode.RemoveSelectedObject(this); else mode.AddSelectedObject(this); - this.selected = !this.selected; + selected = !selected; } } diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs index 73d1eda3..ad93d9d3 100755 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs @@ -1716,22 +1716,28 @@ namespace CodeImp.DoomBuilder.BuilderModes // toggle selected state if (General.Interface.ShiftState ^ BuilderPlug.Me.AdditivePaintSelect) { - this.selected = true; - mode.AddSelectedObject(this); + if (!selected) + { + selected = true; + mode.AddSelectedObject(this); + } } else if (General.Interface.CtrlState) { - this.selected = false; - mode.RemoveSelectedObject(this); + if (selected) + { + selected = false; + mode.RemoveSelectedObject(this); + } } else { - if (this.selected) + if (selected) mode.RemoveSelectedObject(this); else mode.AddSelectedObject(this); - this.selected = !this.selected; + selected = !selected; } } diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs index 69fcfdb1..03288c29 100755 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs @@ -908,22 +908,28 @@ namespace CodeImp.DoomBuilder.BuilderModes // toggle selected state if (General.Interface.ShiftState ^ BuilderPlug.Me.AdditivePaintSelect) { - this.selected = true; - mode.AddSelectedObject(this); + if (!selected) + { + selected = true; + mode.AddSelectedObject(this); + } } else if (General.Interface.CtrlState) { - this.selected = false; - mode.RemoveSelectedObject(this); + if (selected) + { + selected = false; + mode.RemoveSelectedObject(this); + } } else { - if (this.selected) + if (selected) mode.RemoveSelectedObject(this); else mode.AddSelectedObject(this); - this.selected = !this.selected; + selected = !selected; } }