From 35ca4797c8cfdcb57bb5142432aec734ae32a39b Mon Sep 17 00:00:00 2001 From: spherallic Date: Mon, 29 Jul 2024 15:35:03 +0200 Subject: [PATCH] Prevent FOF sides from being offset/scaled multiple times at once --- .../VisualModes/BaseVisualMode.cs | 39 +++++++++++++++++-- .../VisualModes/VisualMiddle3D.cs | 13 ++++--- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index 67a732c3..5699ff16 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -3556,7 +3556,23 @@ namespace CodeImp.DoomBuilder.BuilderModes { PreAction(UndoGroup.TextureOffsetChange); IEnumerable objs = RemoveDuplicateSidedefs(GetSelectedObjects(true, true, false, false, false)); - foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(ox, oy, true); + + // sphere: Have to keep track of processed FOF sides, so they don't get Y offset moved multiple times + HashSet processed = new HashSet(); + foreach (IVisualEventReceiver i in objs) + { + if (i is VisualMiddle3D && oy != 0) + { + VisualMiddle3D vm = i as VisualMiddle3D; + if (!processed.Contains(vm.ExtraFloor.Linedef.Front)) + { + processed.Add(vm.ExtraFloor.Linedef.Front); + i.OnChangeTextureOffset(ox, oy, true); + } + } + else + i.OnChangeTextureOffset(ox, oy, true); + } PostAction(); } @@ -3577,8 +3593,25 @@ namespace CodeImp.DoomBuilder.BuilderModes private void ScaleTexture(int incrementx, int incrementy) { PreAction(UndoGroup.TextureScaleChange); - List objs = GetSelectedObjects(true, true, true, false, false); - foreach(IVisualEventReceiver i in objs) i.OnChangeScale(incrementx, incrementy); + IEnumerable objs = RemoveDuplicateSidedefs(GetSelectedObjects(true, true, true, false, false)); + + // sphere: Have to keep track of processed FOF sides, so they don't get scaled multiple times + HashSet processed = new HashSet(); + foreach (IVisualEventReceiver i in objs) + { + if (i is VisualMiddle3D) + { + VisualMiddle3D vm = i as VisualMiddle3D; + if (!processed.Contains(vm.ExtraFloor.Linedef.Front)) + { + processed.Add(vm.ExtraFloor.Linedef.Front); + i.OnChangeScale(incrementx, incrementy); + } + } + else + i.OnChangeScale(incrementx, incrementy); + } + PostAction(); } diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualMiddle3D.cs b/Source/Plugins/BuilderModes/VisualModes/VisualMiddle3D.cs index 012c2ddf..0175bf62 100755 --- a/Source/Plugins/BuilderModes/VisualModes/VisualMiddle3D.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualMiddle3D.cs @@ -42,15 +42,16 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Variables protected Effect3DFloor extrafloor; - - #endregion - - #region ================== Properties #endregion - + + #region ================== Properties + public Effect3DFloor ExtraFloor { get { return extrafloor; } } + + #endregion + #region ================== Constructor / Setup - + // Constructor public VisualMiddle3D(BaseVisualMode mode, VisualSector vs, Sidedef s) : base(mode, vs, s) {