From 914fb7ea346179bc7e718f8749f0a09603acff08 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 cffb61e..a57e872 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs @@ -1009,23 +1009,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 bac8643..af5868e 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs @@ -1580,22 +1580,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 454fcd0..dbbe627 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs @@ -931,22 +931,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; } }