From 21c8379904f346c7c45286a5b763a568db7bb32f Mon Sep 17 00:00:00 2001 From: biwa <6475593+biwa@users.noreply.github.com> Date: Wed, 19 Feb 2020 21:59:42 +0100 Subject: [PATCH] Added action to toggle between picking slope handles or other map elements --- Source/Core/VisualModes/VisualMode.cs | 52 +++++++++++++------ .../BuilderModes/Resources/Actions.cfg | 10 ++++ .../VisualModes/BaseVisualMode.cs | 14 +++-- 3 files changed, 54 insertions(+), 22 deletions(-) diff --git a/Source/Core/VisualModes/VisualMode.cs b/Source/Core/VisualModes/VisualMode.cs index bf6eddfa..20c3aaaa 100755 --- a/Source/Core/VisualModes/VisualMode.cs +++ b/Source/Core/VisualModes/VisualMode.cs @@ -30,6 +30,12 @@ using CodeImp.DoomBuilder.Editing; namespace CodeImp.DoomBuilder.VisualModes { + public enum PickingMode + { + Default, + SlopeHandles + } + /// /// Provides specialized functionality for a visual (3D) Doom Builder editing mode. /// @@ -68,6 +74,9 @@ namespace CodeImp.DoomBuilder.VisualModes private Vector3D playerStartPosition; private float playerStartAngle; + // For picking + protected PickingMode pickingmode; + // Map protected VisualBlockMap blockmap; protected Dictionary allthings; @@ -113,6 +122,7 @@ namespace CodeImp.DoomBuilder.VisualModes this.processgeometry = true; this.processthings = true; this.vertices = new Dictionary(); //mxd + this.pickingmode = PickingMode.Default; //mxd. Synch camera position to cursor position or center of the screen in 2d-mode if(General.Settings.GZSynchCameras && General.Editing.Mode is ClassicMode) @@ -722,10 +732,11 @@ namespace CodeImp.DoomBuilder.VisualModes { VisualSector vs = allsectors[General.Map.VisualCamera.Sector]; sectors.Add(General.Map.VisualCamera.Sector, vs); - foreach(VisualGeometry g in vs.FixedGeometry) pickables.Add(g); + if(pickingmode == PickingMode.Default) + foreach(VisualGeometry g in vs.FixedGeometry) pickables.Add(g); // Add slope handles - if (General.Map.UDMF && General.Interface.AltState && allslopehandles.ContainsKey(General.Map.VisualCamera.Sector)) + if (General.Map.UDMF && (General.Interface.AltState || pickingmode == PickingMode.SlopeHandles) && allslopehandles.ContainsKey(General.Map.VisualCamera.Sector)) pickables.AddRange(allslopehandles[General.Map.VisualCamera.Sector]); } @@ -765,20 +776,23 @@ namespace CodeImp.DoomBuilder.VisualModes if(!sectors.ContainsKey(ld.Front.Sector)) { sectors.Add(ld.Front.Sector, vs); - foreach(VisualGeometry g in vs.FixedGeometry) + if (pickingmode == PickingMode.Default) { - // Must have content - if(g.Triangles > 0) - pickables.Add(g); + foreach (VisualGeometry g in vs.FixedGeometry) + { + // Must have content + if (g.Triangles > 0) + pickables.Add(g); + } } // Add slope handles - if (General.Map.UDMF /* && General.Settings.ShowVisualSlopeHandles */ && General.Interface.AltState && allslopehandles.ContainsKey(ld.Front.Sector)) + if (General.Map.UDMF /* && General.Settings.ShowVisualSlopeHandles */ && (General.Interface.AltState || pickingmode == PickingMode.SlopeHandles) && allslopehandles.ContainsKey(ld.Front.Sector)) pickables.AddRange(allslopehandles[ld.Front.Sector]); } // Add sidedef if on the front side - if(side < 0.0f) + if(side < 0.0f && pickingmode == PickingMode.Default) { List sidedefgeo = vs.GetSidedefGeometry(ld.Front); foreach(VisualGeometry g in sidedefgeo) @@ -806,20 +820,23 @@ namespace CodeImp.DoomBuilder.VisualModes if(!sectors.ContainsKey(ld.Back.Sector)) { sectors.Add(ld.Back.Sector, vs); - foreach(VisualGeometry g in vs.FixedGeometry) + if (pickingmode == PickingMode.Default) { - // Must have content - if(g.Triangles > 0) - pickables.Add(g); + foreach (VisualGeometry g in vs.FixedGeometry) + { + // Must have content + if (g.Triangles > 0) + pickables.Add(g); + } } // Add slope handles - if (General.Map.UDMF /* && General.Settings.ShowVisualSlopeHandles */ && General.Interface.AltState && allslopehandles.ContainsKey(ld.Back.Sector)) + if (General.Map.UDMF /* && General.Settings.ShowVisualSlopeHandles */ && (General.Interface.AltState || pickingmode == PickingMode.SlopeHandles) && allslopehandles.ContainsKey(ld.Back.Sector)) pickables.AddRange(allslopehandles[ld.Back.Sector]); } // Add sidedef if on the front side - if(side > 0.0f) + if(side > 0.0f && pickingmode == PickingMode.Default) { List sidedefgeo = vs.GetSidedefGeometry(ld.Back); foreach(VisualGeometry g in sidedefgeo) @@ -840,12 +857,13 @@ namespace CodeImp.DoomBuilder.VisualModes } // Add all the visible things - foreach(VisualThing vt in visiblethings) pickables.Add(vt); + if(pickingmode == PickingMode.Default) + foreach(VisualThing vt in visiblethings) pickables.Add(vt); //mxd. And all visual vertices - if(General.Map.UDMF && General.Settings.GZShowVisualVertices) + if (General.Map.UDMF && General.Settings.GZShowVisualVertices && pickingmode == PickingMode.Default) { - foreach(KeyValuePair pair in vertices) + foreach (KeyValuePair pair in vertices) pickables.AddRange(pair.Value.Vertices); } diff --git a/Source/Plugins/BuilderModes/Resources/Actions.cfg b/Source/Plugins/BuilderModes/Resources/Actions.cfg index f2967a15..1aa359de 100755 --- a/Source/Plugins/BuilderModes/Resources/Actions.cfg +++ b/Source/Plugins/BuilderModes/Resources/Actions.cfg @@ -1406,6 +1406,16 @@ visualpaintselect disregardalt = true; } +togglevisualslopepicking +{ + title = "Toggle Visual Slope Picking"; + category = "visual"; + description = "Toggles picking visual slope handles."; + allowkeys = true; + allowmouse = true; + allowscroll = false; +} + selectvisualslopepivot { title = "Select Visual Slope Pivot"; diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index 87b6e40f..8b7c24a0 100755 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -475,11 +475,6 @@ namespace CodeImp.DoomBuilder.BuilderModes // Apply new target target = newtarget; - if(target.picked is VisualSlope) - { - Debug.WriteLine("Up: " + ((VisualSidedefSlope)target.picked).ToString()); - } - // Show target info if(updateinfo) ShowTargetInfo(); } @@ -3994,6 +3989,15 @@ namespace CodeImp.DoomBuilder.BuilderModes } } + [BeginAction("togglevisualslopepicking")] + public void ToggleVisualSlopePicking() + { + if (pickingmode != PickingMode.SlopeHandles) + pickingmode = PickingMode.SlopeHandles; + else + pickingmode = PickingMode.Default; + } + #endregion #region ================== Texture Alignment