From 622ff71056395c676cc7704e070df521662ee77e Mon Sep 17 00:00:00 2001 From: codeimp Date: Sun, 17 May 2009 14:00:36 +0000 Subject: [PATCH] - Fixed Make Door crash when no sector is highlighted or selected - Added HighlightedObject property to the EditMode class, the object returned depends on the editing mode and the current highlight - Exposed several properties in the ClassicMode class --- Source/Core/Editing/ClassicMode.cs | 18 +++++++++++ Source/Core/Editing/EditMode.cs | 3 ++ .../ClassicModes/BrightnessMode.cs | 2 ++ .../ClassicModes/EditSelectionMode.cs | 2 ++ .../BuilderModes/ClassicModes/LinedefsMode.cs | 2 ++ .../BuilderModes/ClassicModes/SectorsMode.cs | 17 +++++----- .../BuilderModes/ClassicModes/ThingsMode.cs | 2 ++ .../BuilderModes/ClassicModes/VerticesMode.cs | 2 ++ .../VisualModes/BaseVisualMode.cs | 29 +++++++++++++++++ Tests/ErrorChecking/sectornotclosed_a.dbs | 30 ++++++++++++++++++ Tests/ErrorChecking/sectornotclosed_a.wad | Bin 0 -> 3288 bytes 11 files changed, 98 insertions(+), 9 deletions(-) create mode 100644 Tests/ErrorChecking/sectornotclosed_a.dbs create mode 100644 Tests/ErrorChecking/sectornotclosed_a.wad diff --git a/Source/Core/Editing/ClassicMode.cs b/Source/Core/Editing/ClassicMode.cs index fc53e5c8..f36c4b28 100644 --- a/Source/Core/Editing/ClassicMode.cs +++ b/Source/Core/Editing/ClassicMode.cs @@ -84,6 +84,24 @@ namespace CodeImp.DoomBuilder.Editing #region ================== Properties + // Mouse status + public Vector2D MousePos { get { return mousepos; } } + public Vector2D MouseLastPos { get { return mouselastpos; } } + public Vector2D MouseMapPos { get { return mousemappos; } } + public Vector2D MouseDownPos { get { return mousedownpos; } } + public Vector2D MouseDownMapPos { get { return mousedownmappos; } } + public MouseButtons MouseButtons { get { return mousebuttons; } } + public bool IsMouseInside { get { return mouseinside; } } + public MouseButtons MouseDragging { get { return mousedragging; } } + + // Selection + public bool IsSelecting { get { return selecting; } } + public Vector2D SelectionStart { get { return selectstart; } } + public RectangleF SelectionRect { get { return selectionrect; } } + + // Panning + public bool IsPanning { get { return panning; } } + #endregion #region ================== Constructor / Disposer diff --git a/Source/Core/Editing/EditMode.cs b/Source/Core/Editing/EditMode.cs index 97e10275..0d508992 100644 --- a/Source/Core/Editing/EditMode.cs +++ b/Source/Core/Editing/EditMode.cs @@ -67,6 +67,9 @@ namespace CodeImp.DoomBuilder.Editing // for checking the appropriate button on the toolbar. public virtual string EditModeButtonName { get { return GetType().Name; } } + // Override this to provide a highlighted object, if applicable + public virtual object HighlightedObject { get { return null; } } + #endregion #region ================== Constructor / Disposer diff --git a/Source/Plugins/BuilderModes/ClassicModes/BrightnessMode.cs b/Source/Plugins/BuilderModes/ClassicModes/BrightnessMode.cs index f6856aec..ab495997 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/BrightnessMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/BrightnessMode.cs @@ -83,6 +83,8 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Properties + public override object HighlightedObject { get { return highlighted; } } + #endregion #region ================== Constructor / Disposer diff --git a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs index e188fb6d..57955e24 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs @@ -138,6 +138,8 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Properties + public override object HighlightedObject { get { return highlighted; } } + // Just keep the base mode button checked public override string EditModeButtonName { get { return General.Editing.PreviousStableMode.Name; } } diff --git a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs index d59a3f48..df0211fc 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs @@ -67,6 +67,8 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Properties + public override object HighlightedObject { get { return highlighted; } } + #endregion #region ================== Constructor / Disposer diff --git a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs index 973170e7..5bef100e 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs @@ -68,6 +68,8 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Properties + public override object HighlightedObject { get { return highlighted; } } + #endregion #region ================== Constructor / Disposer @@ -853,16 +855,13 @@ namespace CodeImp.DoomBuilder.BuilderModes public void MakeDoor() { // Highlighted item not selected? - if(!highlighted.Selected) + if((highlighted != null) && !highlighted.Selected) { - if(highlighted != null) - { - // Make this the only selection - General.Map.Map.ClearSelectedSectors(); - General.Map.Map.ClearSelectedLinedefs(); - SelectSector(highlighted, true, false); - General.Interface.RedrawDisplay(); - } + // Make this the only selection + General.Map.Map.ClearSelectedSectors(); + General.Map.Map.ClearSelectedLinedefs(); + SelectSector(highlighted, true, false); + General.Interface.RedrawDisplay(); } // Anything selected? diff --git a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs index f3bbf801..813d113d 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs @@ -68,6 +68,8 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Properties + public override object HighlightedObject { get { return highlighted; } } + #endregion #region ================== Constructor / Disposer diff --git a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs index f03b4eef..e385230f 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs @@ -64,6 +64,8 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Properties + public override object HighlightedObject { get { return highlighted; } } + #endregion #region ================== Constructor / Disposer diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index e65334ee..65df0a20 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -88,6 +88,35 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Properties + public override object HighlightedObject + { + get + { + // Geometry picked? + if(target.picked is VisualGeometry) + { + VisualGeometry pickedgeo = (target.picked as VisualGeometry); + + if(pickedgeo.Sidedef != null) + return pickedgeo.Sidedef; + else if(pickedgeo.Sector != null) + return pickedgeo.Sector; + else + return null; + } + // Thing picked? + else if(target.picked is VisualThing) + { + VisualThing pickedthing = (target.picked as VisualThing); + return pickedthing.Thing; + } + else + { + return null; + } + } + } + public IRenderer3D Renderer { get { return renderer; } } public bool IsSingleSelection { get { return singleselection; } } diff --git a/Tests/ErrorChecking/sectornotclosed_a.dbs b/Tests/ErrorChecking/sectornotclosed_a.dbs new file mode 100644 index 00000000..78f0df99 --- /dev/null +++ b/Tests/ErrorChecking/sectornotclosed_a.dbs @@ -0,0 +1,30 @@ +type = "Doom Builder Map Settings Configuration"; +gameconfig = "ZDoom_Doom.cfg"; +strictpatches = 0; + +maps +{ + + MAP01 + { + + resources + { + } + + + grid + { + background = ""; + backsource = 0; + backoffsetx = 0; + backoffsety = 0; + backscalex = 100; + backscaley = 100; + gridsize = 32; + } + + } + +} + diff --git a/Tests/ErrorChecking/sectornotclosed_a.wad b/Tests/ErrorChecking/sectornotclosed_a.wad new file mode 100644 index 0000000000000000000000000000000000000000..f3ae992373656f10afef0ebf41495ad8bc5af7f9 GIT binary patch literal 3288 zcmd^BOKV$46#hm}%ko3AWlOUBxOS7&6iRIfE$T{Ebe$-E$VjGfyJ$slpqrFXT4+8gfecV_0g4-!GhG9yN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