diff --git a/Help/gzdb/features/all_modes/synch_camera.html b/Help/gzdb/features/all_modes/synch_camera.html index 60b8db3cb7caf765fb27d6cee9390b2bf44c6328..2fc50f9a1f65eb2a075d1c42e98ce778d426007c 100644 --- a/Help/gzdb/features/all_modes/synch_camera.html +++ b/Help/gzdb/features/all_modes/synch_camera.html @@ -27,6 +27,9 @@ <p><img src="synch_cam3.jpg" alt="" width="740" height="515" /></p> <p>If you leave Visual mode now, the map will be centered at Visual camera's location:</p> <p><img src="synch_cam4.jpg" alt="" width="736" height="512" /></p> - <p>If you don't like this behaviour, you can disable it in the <a href="../../../w_preferences.html">Preferences window</a>.</p> + <p>If you don't like this behaviour, disable "<b>Synchronize camera position between 2D and 3D modes</b>" <a href="../../../w_preferences.html">Preferences</a> option.</p> + <h2>Additional keys:</h2> + <p>Holding <b>Shift</b> while switching to/from Visual mode will also synchronize selected map elements.<br /> + Holding <b>Ctrl</b> while switching to/from Visual mode will temporarily disable camera synchronization (works only when "<b>Synchronize camera position between 2D and 3D modes</b>" <a href="../../../w_preferences.html">Preferences</a> option is enabled).</p> </div> </body> diff --git a/Source/Core/Controls/ScriptDocumentTab.cs b/Source/Core/Controls/ScriptDocumentTab.cs index eb9d076c5e950964daf0e42f3f6cb00fb2ebfb79..b0ca1aa67fe211b0c0868cf02a99ba931e7518c2 100644 --- a/Source/Core/Controls/ScriptDocumentTab.cs +++ b/Source/Core/Controls/ScriptDocumentTab.cs @@ -48,7 +48,6 @@ namespace CodeImp.DoomBuilder.Controls // The script edit control protected readonly ScriptEditorControl editor; - private bool preventchanges; //mxd private string title; //mxd // Derived classes must set this! @@ -437,7 +436,7 @@ namespace CodeImp.DoomBuilder.Controls //mxd private void functionbar_DropDown(object sender, EventArgs e) { - if(!preventchanges && editor.IsChanged) panel.ShowErrors(UpdateNavigator()); + if(editor.IsChanged) panel.ShowErrors(UpdateNavigator()); } //mxd diff --git a/Source/Core/Editing/ClassicMode.cs b/Source/Core/Editing/ClassicMode.cs index 6442946e3a1921be9699c4ded6732a32ac64a299..2063fd09babb732193f931abf254ef2b207a395c 100644 --- a/Source/Core/Editing/ClassicMode.cs +++ b/Source/Core/Editing/ClassicMode.cs @@ -653,7 +653,8 @@ namespace CodeImp.DoomBuilder.Editing if(renderer.StartOverlay(true)) { //mxd. Center 2d view on camera position in 3d view - if(General.Settings.GZSynchCameras && General.Editing.PreviousMode != null && General.Editing.PreviousMode.IsSubclassOf(typeof (VisualMode))) + if(General.Settings.GZSynchCameras && !General.Interface.CtrlState + && General.Editing.PreviousMode != null && General.Editing.PreviousMode.IsSubclassOf(typeof(VisualMode))) { Vector2D campos = new Vector2D(General.Map.VisualCamera.Position.x, General.Map.VisualCamera.Position.y); renderer2d.PositionView(campos.x, campos.y); diff --git a/Source/Core/Geometry/Tools.cs b/Source/Core/Geometry/Tools.cs index 9a4bf3951c3c5c92efc0fc3fa82e82c4b3118083..4cd256afeee8da440a8e40497811c85ba23ba8d2 100644 --- a/Source/Core/Geometry/Tools.cs +++ b/Source/Core/Geometry/Tools.cs @@ -2254,7 +2254,7 @@ namespace CodeImp.DoomBuilder.Geometry } //mxd. Try to create/remove/reassign outer sidedefs. Selected linedefs and verts are marked - public static void AdjustOuterSidedefs(HashSet<Sector> selectedsectors, ICollection<Linedef> selectedlines) + public static void AdjustOuterSidedefs(HashSet<Sector> selectedsectors, HashSet<Linedef> selectedlines) { HashSet<Sidedef> outersides = new HashSet<Sidedef>(); HashSet<Linedef> singlesidedlines = new HashSet<Linedef>(); diff --git a/Source/Core/Map/MapSet.cs b/Source/Core/Map/MapSet.cs index fe86c109e95cf01f05c46561e3d288a7eb10376f..f3aa7fa0f05552b5ce34eb576019eded6c43ae74 100644 --- a/Source/Core/Map/MapSet.cs +++ b/Source/Core/Map/MapSet.cs @@ -2588,7 +2588,7 @@ namespace CodeImp.DoomBuilder.Map } /// <summary>mxd. This finds the line closest to the specified position excluding given list of linedefs.</summary> - public Linedef NearestLinedef(Vector2D pos, ICollection<Linedef> linesToExclude) + public Linedef NearestLinedef(Vector2D pos, HashSet<Linedef> linesToExclude) { Linedef closest = null; float distance = float.MaxValue; @@ -2596,7 +2596,7 @@ namespace CodeImp.DoomBuilder.Map // Go for all linedefs in selection foreach(Linedef l in linedefs) { - if(linesToExclude.Contains(l)) continue; + if(linesToExclude.Contains(l)) continue; // Calculate distance and check if closer than previous find float d = l.SafeDistanceToSq(pos, true); if(d < distance) diff --git a/Source/Core/VisualModes/VisualMode.cs b/Source/Core/VisualModes/VisualMode.cs index c9c70de055bd3301937a79dda5e2a3fd9df9e217..0373721d9f6fd44a56c6090f32a5f8e2baff2f4e 100644 --- a/Source/Core/VisualModes/VisualMode.cs +++ b/Source/Core/VisualModes/VisualMode.cs @@ -170,33 +170,37 @@ namespace CodeImp.DoomBuilder.VisualModes //mxd. Synch camera position to cursor position or center of the screen in 2d-mode if(General.Settings.GZSynchCameras) { - //If initial position is inside or nearby a sector - adjust camera.z accordingly - float posz = General.Map.VisualCamera.Position.z; - Sector nearestsector = General.Map.Map.GetSectorByCoordinates(initialcameraposition, blockmap); - - if(nearestsector == null) + // Keep previous camera position if Control is held and camera was previously moved in Visual mode + if(!General.Interface.CtrlState || General.Map.VisualCamera.Position.GetLengthSq() == 0) { - Linedef nearestline = MapSet.NearestLinedef(General.Map.Map.Linedefs, initialcameraposition); - if(nearestline != null) + //If initial position is inside or nearby a sector - adjust camera.z accordingly + float posz = General.Map.VisualCamera.Position.z; + Sector nearestsector = General.Map.Map.GetSectorByCoordinates(initialcameraposition, blockmap); + + if(nearestsector == null) { - float side = nearestline.SideOfLine(initialcameraposition); - Sidedef nearestside = (side < 0.0f ? nearestline.Front : nearestline.Back) ?? (side < 0.0f ? nearestline.Back : nearestline.Front); - if(nearestside != null) nearestsector = nearestside.Sector; + Linedef nearestline = MapSet.NearestLinedef(General.Map.Map.Linedefs, initialcameraposition); + if(nearestline != null) + { + float side = nearestline.SideOfLine(initialcameraposition); + Sidedef nearestside = (side < 0.0f ? nearestline.Front : nearestline.Back) ?? (side < 0.0f ? nearestline.Back : nearestline.Front); + if(nearestside != null) nearestsector = nearestside.Sector; + } } - } - if(nearestsector != null) - { - int sectorheight = nearestsector.CeilHeight - nearestsector.FloorHeight; - if(sectorheight < 41) - posz = nearestsector.FloorHeight + Math.Max(16, sectorheight / 2); - else if(General.Map.VisualCamera.Position.z < nearestsector.FloorHeight + 41) - posz = nearestsector.FloorHeight + 41; // same as in doom - else if(General.Map.VisualCamera.Position.z > nearestsector.CeilHeight) - posz = nearestsector.CeilHeight - 4; - } + if(nearestsector != null) + { + int sectorheight = nearestsector.CeilHeight - nearestsector.FloorHeight; + if(sectorheight < 41) + posz = nearestsector.FloorHeight + Math.Max(16, sectorheight / 2); + else if(General.Map.VisualCamera.Position.z < nearestsector.FloorHeight + 41) + posz = nearestsector.FloorHeight + 41; // same as in doom + else if(General.Map.VisualCamera.Position.z > nearestsector.CeilHeight) + posz = nearestsector.CeilHeight - 4; + } - General.Map.VisualCamera.Position = new Vector3D(initialcameraposition.x, initialcameraposition.y, posz); + General.Map.VisualCamera.Position = new Vector3D(initialcameraposition.x, initialcameraposition.y, posz); + } } else { diff --git a/Source/Core/Windows/PreferencesForm.Designer.cs b/Source/Core/Windows/PreferencesForm.Designer.cs index 74e550679834e09ccf7a5f4b8e17d915bdba562a..492753e340fc394892a5880f9d8d240443ce4325 100644 --- a/Source/Core/Windows/PreferencesForm.Designer.cs +++ b/Source/Core/Windows/PreferencesForm.Designer.cs @@ -470,9 +470,9 @@ namespace CodeImp.DoomBuilder.Windows this.cbSynchCameras.AutoSize = true; this.cbSynchCameras.Location = new System.Drawing.Point(16, 371); this.cbSynchCameras.Name = "cbSynchCameras"; - this.cbSynchCameras.Size = new System.Drawing.Size(260, 17); + this.cbSynchCameras.Size = new System.Drawing.Size(294, 17); this.cbSynchCameras.TabIndex = 12; - this.cbSynchCameras.Text = "Sync camera position between 2D and 3D modes"; + this.cbSynchCameras.Text = "Synchronize camera position between 2D and 3D modes"; this.cbSynchCameras.UseVisualStyleBackColor = true; // // showtexturesizes diff --git a/Source/Plugins/BuilderModes/ClassicModes/DragLinedefsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/DragLinedefsMode.cs index ea97391797fb43c8db4dfdf678f3e6c3beffcd32..1670d26e28bad370350a51539a1818e22f7410f6 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/DragLinedefsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/DragLinedefsMode.cs @@ -119,7 +119,7 @@ namespace CodeImp.DoomBuilder.BuilderModes HashSet<Sector> toadjust = General.Map.Map.GetUnselectedSectorsFromLinedefs(selectedlines); // Process outer sidedefs - Tools.AdjustOuterSidedefs(toadjust, selectedlines); + Tools.AdjustOuterSidedefs(toadjust, new HashSet<Linedef>(selectedlines)); } // If only a single linedef was selected, deselect it now diff --git a/Source/Plugins/BuilderModes/ClassicModes/DragSectorsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/DragSectorsMode.cs index 1bbcec61d276b9dd7770d7abd862fd0cd65bf574..4235b5f8b92b205f7eddff85b8b53983aaeaeaf1 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/DragSectorsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/DragSectorsMode.cs @@ -128,7 +128,7 @@ namespace CodeImp.DoomBuilder.BuilderModes toadjust.UnionWith(General.Map.Map.GetUnselectedSectorsFromLinedefs(selectedlines)); // Process outer sidedefs - Tools.AdjustOuterSidedefs(toadjust, selectedlines); + Tools.AdjustOuterSidedefs(toadjust, new HashSet<Linedef>(selectedlines)); } // If only a single sector was selected, deselect it now diff --git a/Source/Plugins/BuilderModes/ClassicModes/DragVerticesMode.cs b/Source/Plugins/BuilderModes/ClassicModes/DragVerticesMode.cs index a455326da0bdbeebb718e1584d37852e0561c72b..59f6a963b39bb005d84b1e7987a5888d531a91e0 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/DragVerticesMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/DragVerticesMode.cs @@ -103,7 +103,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { // Add sectors, which have all their linedefs selected // (otherwise those would be destroyed after moving the selection) - ICollection<Linedef> selectedlines = General.Map.Map.LinedefsFromMarkedVertices(false, true, false); + HashSet<Linedef> selectedlines = new HashSet<Linedef>(General.Map.Map.LinedefsFromMarkedVertices(false, true, false)); HashSet<Sector> toadjust = General.Map.Map.GetUnselectedSectorsFromLinedefs(selectedlines); // Process outer sidedefs diff --git a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs index 6d57ac5d33e6f948078710515968003c9fdfe664..1d8c63c012e89dfb162c9636fc24da7cba80c6a6 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs @@ -1485,7 +1485,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // Update outer sides of the selection HashSet<Sector> affectedsectors = new HashSet<Sector>(General.Map.Map.GetSelectedSectors(true)); affectedsectors.UnionWith(General.Map.Map.GetUnselectedSectorsFromLinedefs(selectedlines)); - Tools.AdjustOuterSidedefs(affectedsectors, selectedlines); + Tools.AdjustOuterSidedefs(affectedsectors, new HashSet<Linedef>(selectedlines)); } // Stitch geometry diff --git a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs index 34ece983ca4855ac86d494f6de1dc6748bff27fb..de1892363a81f58790c68125eb833b8b43c23455 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs @@ -1428,11 +1428,9 @@ namespace CodeImp.DoomBuilder.BuilderModes } //align things - int thingsCount = General.Map.Map.Things.Count; - foreach(Thing t in toAlign) { - List<Linedef> excludedLines = new List<Linedef>(); + HashSet<Linedef> excludedLines = new HashSet<Linedef>(); bool aligned; do @@ -1443,7 +1441,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(!aligned) { excludedLines.Add(l); - if(excludedLines.Count == thingsCount) + if(excludedLines.Count == General.Map.Map.Linedefs.Count) { ThingTypeInfo tti = General.Map.Data.GetThingInfo(t.Type); General.ErrorLogger.Add(ErrorType.Warning, "Unable to align " + tti.Title + " (index " + t.Index + ") to any linedef!"); diff --git a/Source/Plugins/BuilderModes/ErrorChecks/ResultSectorInvalid.cs b/Source/Plugins/BuilderModes/ErrorChecks/ResultSectorInvalid.cs index 736a11bac24a6d4695e0773ac65f1d922f3bab3c..efe98c1aab40e0e04fd39dc135fe94f8b4545851 100644 --- a/Source/Plugins/BuilderModes/ErrorChecks/ResultSectorInvalid.cs +++ b/Source/Plugins/BuilderModes/ErrorChecks/ResultSectorInvalid.cs @@ -100,7 +100,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(!merged) { - List<Linedef> sectorlines = new List<Linedef>(sector.Sidedefs.Count); + HashSet<Linedef> sectorlines = new HashSet<Linedef>(); foreach(Sidedef side in sector.Sidedefs) sectorlines.Add(side.Line); if(sectorlines.Count > 0) diff --git a/Source/Plugins/BuilderModes/Resources/Actions.cfg b/Source/Plugins/BuilderModes/Resources/Actions.cfg index 04ca2188506a19e327ebf75627ff5174ebd3c162..fe2d12b8ae49246fa308664363fcb78e322bf6d2 100644 --- a/Source/Plugins/BuilderModes/Resources/Actions.cfg +++ b/Source/Plugins/BuilderModes/Resources/Actions.cfg @@ -1266,11 +1266,12 @@ gzdbvisualmode { title = "GZDB Visual Mode"; category = "modes"; - description = "Switches to the (G)ZDoom visual editing mode. Hold Shift key to invert 'Synhcronise selection between Visual and Classic modes' setting."; + description = "Switches to the (G)ZDoom visual editing mode. Hold Shift key to invert 'Synhcronise selection between Visual and Classic modes' setting. Hold Control key to disable position synchronization when 'Synchronize camera position between 2D and 3D modes' Preferences option is enabled."; allowkeys = true; allowmouse = true; allowscroll = true; disregardshift = true; + disregardcontrol = true; default = 81; //Q } diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index 5842c1ddee8dafd230fd0ed006138044d458409c..f283da49d5d65fdee03e98b859c9921765072ccc 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -3365,11 +3365,9 @@ namespace CodeImp.DoomBuilder.BuilderModes } //align things - int thingsCount = General.Map.Map.Things.Count; - foreach(Thing t in things) { - List<Linedef> excludedLines = new List<Linedef>(); + HashSet<Linedef> excludedLines = new HashSet<Linedef>(); bool aligned; do @@ -3381,7 +3379,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { excludedLines.Add(l); - if(excludedLines.Count == thingsCount) + if(excludedLines.Count == General.Map.Map.Linedefs.Count) { ThingTypeInfo tti = General.Map.Data.GetThingInfo(t.Type); General.ErrorLogger.Add(ErrorType.Warning, "Unable to align " + tti.Title + " (index " + t.Index + ") to any linedef!");