mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2025-01-31 05:00:34 +00:00
Fixed: Nodebuilder is no longer invoked twice when entering Visual Mode.
Fixed: Nodebuilder is no longer invoked with "Save" settings when entering Visual Mode. Fixed: Editor no longer crashes when entering Visual Mode with one or no sector.
This commit is contained in:
parent
83a0f0a53f
commit
6405af2fea
4 changed files with 52 additions and 41 deletions
|
@ -28,6 +28,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private Subsector[] ssectors;
|
||||
private bool deactivate;
|
||||
private bool isdisposed;
|
||||
private string errormessage;
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -36,6 +37,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public Node[] Nodes { get { return nodes; } }
|
||||
public Vector2D[] Vertices { get { return verts; } }
|
||||
public Subsector[] Subsectors { get { return ssectors; } }
|
||||
public bool IsDeactivated { get { return deactivate; } }
|
||||
public string ErrorMessage { get { return errormessage; } }
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Destructor
|
||||
|
@ -44,12 +47,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public BSP(bool deactivate)
|
||||
{
|
||||
this.deactivate = deactivate;
|
||||
if (!deactivate)
|
||||
{
|
||||
if (General.Map.IsChanged && !General.Map.RebuildNodes(General.Map.ConfigSettings.NodebuilderSave, true)) return;
|
||||
LoadStructures();
|
||||
}
|
||||
|
||||
this.errormessage = "";
|
||||
if (!deactivate && !General.Map.IsChanged) LoadStructures();
|
||||
}
|
||||
|
||||
// Disposer
|
||||
|
@ -72,11 +71,11 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
#region ================== Methods
|
||||
|
||||
public void Update()
|
||||
public void Build()
|
||||
{
|
||||
if (!deactivate && General.Map.IsChanged)
|
||||
{
|
||||
if (!General.Map.RebuildNodes(General.Map.ConfigSettings.NodebuilderSave, true)) return;
|
||||
if (!General.Map.RebuildNodes(General.Map.ConfigSettings.NodebuilderTest, true)) return;
|
||||
LoadStructures();
|
||||
}
|
||||
}
|
||||
|
@ -86,16 +85,21 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// </summary>
|
||||
private bool LoadStructures()
|
||||
{
|
||||
errormessage = "";
|
||||
// Load the nodes structure
|
||||
MemoryStream nodesstream = General.Map.GetLumpData("NODES");
|
||||
if (nodesstream == null)
|
||||
{
|
||||
deactivate = true;
|
||||
return false;
|
||||
}
|
||||
int numnodes = (int)nodesstream.Length / 28;
|
||||
|
||||
//mxd. Boilerplate!
|
||||
if(numnodes < 1)
|
||||
{
|
||||
// Cancel mode
|
||||
MessageBox.Show("The map has only one subsector. Please add more sectors, then try running this mode again.", "THY NODETH ARETH BROKH!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
General.Editing.CancelMode();
|
||||
errormessage = "The map has only one subsector.";
|
||||
deactivate = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -140,9 +144,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
//mxd. Boilerplate!
|
||||
if(numsegs < 1)
|
||||
{
|
||||
// Cancel mode
|
||||
MessageBox.Show("The map has empty SEGS lump. Please rebuild the nodes, then try running this mode again.", "THY SEGS HATH SINNETH!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
General.Editing.CancelMode();
|
||||
errormessage = "The map has an empty SEGS lump.";
|
||||
deactivate = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -168,9 +171,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
//mxd. Boilerplate!
|
||||
if(numverts < 1)
|
||||
{
|
||||
// Cancel mode
|
||||
MessageBox.Show("The map has empty VERTEXES lump. Please rebuild the nodes, then try running this mode again.", "THY VERTEXES ARETH FOUL!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
General.Editing.CancelMode();
|
||||
errormessage = "The map has an empty VERTEXES lump.";
|
||||
deactivate = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -192,9 +194,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
//mxd. Boilerplate!
|
||||
if(numssec < 1)
|
||||
{
|
||||
// Cancel mode
|
||||
MessageBox.Show("The map has empty SSECTORS lump. Please rebuild the nodes, then try running this mode again.", "THY SSECTORS ARETH HERETYSH!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
General.Editing.CancelMode();
|
||||
errormessage = "The map has an empty SSECTORS lump.";
|
||||
deactivate = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,6 +96,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private Type lasthighlighttype;
|
||||
|
||||
private BSP bsp;
|
||||
private bool useblockmap;
|
||||
|
||||
//mxd. Moved here from Tools
|
||||
private struct SidedefAlignJob
|
||||
|
@ -166,6 +167,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public bool IsSingleSelection { get { return singleselection; } }
|
||||
public bool SelectionChanged { get { return selectionchanged; } set { selectionchanged |= value; } }
|
||||
public BSP BSP { get { return bsp; } }
|
||||
public bool UseBlockmap { get { return useblockmap; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -185,6 +187,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
selectioninfoupdatetimer.Tick += SelectioninfoupdatetimerOnTick;
|
||||
|
||||
bsp = new BSP(BuilderPlug.Me.DontUseNodes);
|
||||
useblockmap = bsp.IsDeactivated;
|
||||
if (useblockmap && bsp.ErrorMessage != "")
|
||||
MessageBox.Show("Could not load the map's nodes: " + bsp.ErrorMessage + " Defaulting to blockmap.", "Error loading nodes!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
// We have no destructor
|
||||
GC.SuppressFinalize(this);
|
||||
|
@ -527,7 +532,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
//mxd. Update event lines (still better than updating them on every frame redraw)
|
||||
renderer.SetEventLines(LinksCollector.GetThingLinks(General.Map.ThingsFilter.VisibleThings, blockmap, bsp, BuilderPlug.Me.DontUseNodes));
|
||||
renderer.SetEventLines(LinksCollector.GetThingLinks(General.Map.ThingsFilter.VisibleThings, blockmap, bsp, useblockmap));
|
||||
}
|
||||
|
||||
//mxd
|
||||
|
@ -756,7 +761,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
//mxd
|
||||
Sector[] sectorsWithEffects = null;
|
||||
bsp.Update();
|
||||
bsp.Build();
|
||||
useblockmap = bsp.IsDeactivated;
|
||||
|
||||
if (!General.Settings.GZDoomRenderingEffects)
|
||||
{
|
||||
|
@ -781,8 +787,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
sectordata = new Dictionary<Sector, SectorData>(General.Map.Map.Sectors.Count);
|
||||
thingdata = new Dictionary<Thing, ThingData>(General.Map.Map.Things.Count);
|
||||
|
||||
if (bsp.IsDeactivated && bsp.ErrorMessage != "")
|
||||
MessageBox.Show("Could not load the map's nodes: " + bsp.ErrorMessage + " Defaulting to blockmap.", "Error loading nodes!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
|
||||
//mxd. rebuild all sectors with effects
|
||||
if(sectorsWithEffects != null)
|
||||
if (sectorsWithEffects != null)
|
||||
{
|
||||
for(int i = 0; i < sectorsWithEffects.Length; i++)
|
||||
{
|
||||
|
@ -1207,7 +1217,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
RebuildElementData();
|
||||
|
||||
//mxd. Update event lines
|
||||
renderer.SetEventLines(LinksCollector.GetThingLinks(General.Map.ThingsFilter.VisibleThings, blockmap, bsp, BuilderPlug.Me.DontUseNodes));
|
||||
renderer.SetEventLines(LinksCollector.GetThingLinks(General.Map.ThingsFilter.VisibleThings, blockmap, bsp, useblockmap));
|
||||
}
|
||||
|
||||
// When returning to another mode
|
||||
|
@ -3340,7 +3350,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Map.ThingsFilter.Update();
|
||||
|
||||
// Update event lines
|
||||
renderer.SetEventLines(LinksCollector.GetThingLinks(General.Map.ThingsFilter.VisibleThings, blockmap, bsp, BuilderPlug.Me.DontUseNodes));
|
||||
renderer.SetEventLines(LinksCollector.GetThingLinks(General.Map.ThingsFilter.VisibleThings, blockmap, bsp, useblockmap));
|
||||
}
|
||||
|
||||
//mxd. We'll just use currently selected objects
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public bool Setup()
|
||||
{
|
||||
// Find the sector in which the thing resides
|
||||
if (BuilderPlug.Me.DontUseNodes)
|
||||
if (mode.UseBlockmap)
|
||||
Thing.DetermineSector(mode.BlockMap);
|
||||
else
|
||||
Thing.DetermineSector(mode.BSP);
|
||||
|
|
|
@ -24,15 +24,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private BSP bsp;
|
||||
|
||||
// Constructor
|
||||
public EffectSRB2ThingVertexSlope(SectorData data, List<Thing> sourcethings, bool floor, VisualBlockMap bmap, BSP bsptree) : base(data)
|
||||
public EffectSRB2ThingVertexSlope(SectorData data, List<Thing> sourcethings, bool floor, VisualBlockMap blockmap, BSP bsp) : base(data)
|
||||
{
|
||||
things = sourcethings;
|
||||
slopefloor = floor;
|
||||
blockmap = bmap;
|
||||
bsp = bsptree;
|
||||
this.blockmap = blockmap;
|
||||
this.bsp = bsp;
|
||||
|
||||
// New effect added: This sector needs an update!
|
||||
if(data.Mode.VisualSectorExists(data.Sector))
|
||||
if (data.Mode.VisualSectorExists(data.Sector))
|
||||
{
|
||||
BaseVisualSector vs = (BaseVisualSector)data.Mode.GetVisualSector(data.Sector);
|
||||
vs.UpdateSectorGeometry(true);
|
||||
|
@ -50,7 +50,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
ThingData td = data.Mode.GetThingData(t);
|
||||
td.AddUpdateSector(data.Sector, true);
|
||||
Vector3D position = t.Position;
|
||||
if (BuilderPlug.Me.DontUseNodes)
|
||||
if (data.Mode.UseBlockmap)
|
||||
t.DetermineSector(blockmap);
|
||||
else
|
||||
t.DetermineSector(bsp);
|
||||
|
|
Loading…
Reference in a new issue