0
0
Fork 0
mirror of https://git.do.srb2.org/STJr/UltimateZoneBuilder.git synced 2025-02-26 13:50:56 +00:00

happy birthday doom!

This commit is contained in:
codeimp 2008-12-10 22:58:58 +00:00
parent 5db0757020
commit 53a1f085ab
15 changed files with 129 additions and 122 deletions

Binary file not shown.

BIN
Resources/UnknownThing.png Normal file

Binary file not shown.

After

(image error) Size: 558 B

View file

@ -399,6 +399,22 @@ namespace CodeImp.DoomBuilder.Actions
General.Settings.WriteSetting("shortcuts." + a.Key, a.Value.ShortcutKey); General.Settings.WriteSetting("shortcuts." + a.Key, a.Value.ShortcutKey);
} }
} }
// This invokes the Begin and End of the given action
public bool InvokeAction(string actionname)
{
if(Exists(actionname))
{
Action a = actions[actionname];
a.Begin();
a.End();
return true;
}
else
{
return false;
}
}
#endregion #endregion

View file

@ -237,20 +237,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
} }
// After undo // After resources were reloaded
public override void OnUndoEnd() protected override void ResourcesReloaded()
{ {
base.OnUndoEnd(); base.ResourcesReloaded();
PickTarget(); PickTarget();
} }
// After redo
public override void OnRedoEnd()
{
base.OnRedoEnd();
PickTarget();
}
#endregion #endregion
#region ================== Actions #region ================== Actions

View file

@ -56,7 +56,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#endregion #endregion
#region ================== Constructor / Disposer #region ================== Constructor / Setup
// Constructor // Constructor
public BaseVisualThing(Thing t) : base(t) public BaseVisualThing(Thing t) : base(t)
@ -80,11 +80,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
if(sprite != null) if(sprite != null)
{ {
// Color to modulate sprite with (god knows what we could use this for)
PixelColor pc = new PixelColor(255, 255, 255, 255);
// Find the sector in which the thing resides // Find the sector in which the thing resides
Thing.DetermineSector(); Thing.DetermineSector();
PixelColor pc;
if(Thing.Sector != null)
{
// Use sector brightness for color shading
pc = new PixelColor(255, unchecked((byte)Thing.Sector.Brightness),
unchecked((byte)Thing.Sector.Brightness),
unchecked((byte)Thing.Sector.Brightness));
}
else
{
// Full brightness
pc = new PixelColor(255, 255, 255, 255);
}
// Check if the texture is loaded // Check if the texture is loaded
isloaded = sprite.IsImageLoaded; isloaded = sprite.IsImageLoaded;
@ -148,7 +159,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
if(!IsDisposed) if(!IsDisposed)
{ {
if(sprite != null) sprite.RemoveReference(); if(sprite != null)
{
sprite.RemoveReference();
sprite = null;
}
} }
base.Dispose(); base.Dispose();

View file

@ -130,7 +130,6 @@ namespace CodeImp.DoomBuilder.Data
// Done // Done
usedinmap = false; usedinmap = false;
references = 0;
imagestate = ImageLoadState.None; imagestate = ImageLoadState.None;
previewstate = ImageLoadState.None; previewstate = ImageLoadState.None;
isdisposed = true; isdisposed = true;

View file

@ -204,6 +204,9 @@ namespace CodeImp.DoomBuilder.Editing
// Processing events // Processing events
public virtual void OnProcess(double deltatime) { } public virtual void OnProcess(double deltatime) { }
// Generic events
public virtual void OnReloadResources() { }
#endregion #endregion
} }
} }

View file

@ -1226,7 +1226,9 @@ namespace CodeImp.DoomBuilder
// This shows a major failure // This shows a major failure
public static void Fail(string message) public static void Fail(string message)
{ {
General.WriteLogLine("FAIL: " + message);
Debug.Fail(message); Debug.Fail(message);
Terminate(false);
} }
// This outputs log information // This outputs log information

View file

@ -1293,9 +1293,12 @@ namespace CodeImp.DoomBuilder
// Re-link the background image // Re-link the background image
grid.LinkBackground(); grid.LinkBackground();
// Inform all plugins that the resource are reloaded // Inform all plugins that the resources are reloaded
General.Plugins.ReloadResources(); General.Plugins.ReloadResources();
// Inform editing mode that the resources are reloaded
if(General.Editing.Mode != null) General.Editing.Mode.OnReloadResources();
// Reset status // Reset status
General.MainWindow.DisplayStatus(oldstatus); General.MainWindow.DisplayStatus(oldstatus);
Cursor.Current = oldcursor; Cursor.Current = oldcursor;

View file

@ -51,7 +51,7 @@ namespace CodeImp.DoomBuilder.Map
private LinkedList<Sidedef> sidedefs; private LinkedList<Sidedef> sidedefs;
// Things // Things
private LinkedList<Thing> things; //private LinkedList<Thing> things;
// Properties // Properties
private int index; private int index;
@ -85,7 +85,7 @@ namespace CodeImp.DoomBuilder.Map
public MapSet Map { get { return map; } } public MapSet Map { get { return map; } }
public ICollection<Sidedef> Sidedefs { get { return sidedefs; } } public ICollection<Sidedef> Sidedefs { get { return sidedefs; } }
public ICollection<Thing> Things { get { return things; } } //public ICollection<Thing> Things { get { return things; } }
public int Index { get { return index; } } public int Index { get { return index; } }
public int FloorHeight { get { return floorheight; } set { floorheight = value; } } public int FloorHeight { get { return floorheight; } set { floorheight = value; } }
public int CeilHeight { get { return ceilheight; } set { ceilheight = value; } } public int CeilHeight { get { return ceilheight; } set { ceilheight = value; } }
@ -117,7 +117,7 @@ namespace CodeImp.DoomBuilder.Map
this.map = map; this.map = map;
this.mainlistitem = listitem; this.mainlistitem = listitem;
this.sidedefs = new LinkedList<Sidedef>(); this.sidedefs = new LinkedList<Sidedef>();
this.things = new LinkedList<Thing>(); //this.things = new LinkedList<Thing>();
this.index = index; this.index = index;
this.floortexname = "-"; this.floortexname = "-";
this.ceiltexname = "-"; this.ceiltexname = "-";
@ -138,7 +138,7 @@ namespace CodeImp.DoomBuilder.Map
this.map = map; this.map = map;
this.mainlistitem = listitem; this.mainlistitem = listitem;
this.sidedefs = new LinkedList<Sidedef>(); this.sidedefs = new LinkedList<Sidedef>();
this.things = new LinkedList<Thing>(); //this.things = new LinkedList<Thing>();
this.triangulationneeded = true; this.triangulationneeded = true;
ReadWrite(stream); ReadWrite(stream);
@ -177,7 +177,7 @@ namespace CodeImp.DoomBuilder.Map
flatfloorbuffer = null; flatfloorbuffer = null;
mainlistitem = null; mainlistitem = null;
sidedefs = null; sidedefs = null;
things = null; //things = null;
map = null; map = null;
// Dispose base // Dispose base
@ -252,10 +252,10 @@ namespace CodeImp.DoomBuilder.Map
} }
// This attaches a thing and returns the listitem // This attaches a thing and returns the listitem
public LinkedListNode<Thing> AttachThing(Thing t) { return things.AddLast(t); } //public LinkedListNode<Thing> AttachThing(Thing t) { return things.AddLast(t); }
// This detaches a thing // This detaches a thing
public void DetachThing(LinkedListNode<Thing> l) { if(!isdisposed) things.Remove(l); } //public void DetachThing(LinkedListNode<Thing> l) { if(!isdisposed) things.Remove(l); }
// This updates the sector when changes have been made // This updates the sector when changes have been made
public void UpdateCache() public void UpdateCache()

View file

@ -116,7 +116,7 @@ namespace CodeImp.DoomBuilder.Map
mainlistitem.List.Remove(mainlistitem); mainlistitem.List.Remove(mainlistitem);
// Remove from sector // Remove from sector
if(sector != null) sector.DetachThing(sectorlistitem); //if(sector != null) sector.DetachThing(sectorlistitem);
// Clean up // Clean up
mainlistitem = null; mainlistitem = null;
@ -215,7 +215,7 @@ namespace CodeImp.DoomBuilder.Map
if((sector != null) && (newsector != sector)) if((sector != null) && (newsector != sector))
{ {
// Remove from current sector // Remove from current sector
sector.DetachThing(sectorlistitem); //sector.DetachThing(sectorlistitem);
sectorlistitem = null; sectorlistitem = null;
sector = null; sector = null;
} }
@ -225,7 +225,7 @@ namespace CodeImp.DoomBuilder.Map
{ {
// Attach to new sector // Attach to new sector
sector = newsector; sector = newsector;
sectorlistitem = sector.AttachThing(this); //sectorlistitem = sector.AttachThing(this);
} }
} }

View file

@ -444,7 +444,7 @@ namespace CodeImp.DoomBuilder.Rendering
foreach(VisualThing t in group.Value) foreach(VisualThing t in group.Value)
{ {
// Update buffer if needed // Update buffer if needed
if(t.NeedsUpdateGeo) t.Update(); t.Update();
// Only do this sector when a vertexbuffer is created // Only do this sector when a vertexbuffer is created
if(t.GeometryBuffer != null) if(t.GeometryBuffer != null)

View file

@ -174,7 +174,14 @@ namespace CodeImp.DoomBuilder.VisualModes
public override void OnDisengage() public override void OnDisengage()
{ {
base.OnDisengage(); base.OnDisengage();
DisposeVisuals();
// Dispose
foreach(KeyValuePair<Sector, VisualSector> vs in allsectors)
vs.Value.Dispose();
// Dispose
foreach(KeyValuePair<Thing, VisualThing> vt in allthings)
vt.Value.Dispose();
// Do we have a 3D Mode thing? // Do we have a 3D Mode thing?
if(modething != null) if(modething != null)
@ -197,31 +204,13 @@ namespace CodeImp.DoomBuilder.VisualModes
{ {
renderer.SetCrosshairBusy(true); renderer.SetCrosshairBusy(true);
General.Interface.RedrawDisplay(); General.Interface.RedrawDisplay();
return base.OnUndoBegin(); return base.OnUndoBegin();
} }
public override void OnUndoEnd() public override void OnUndoEnd()
{ {
base.OnUndoEnd(); base.OnUndoEnd();
ResourcesReloaded();
DisposeVisuals();
visiblesectors.Clear();
visibleblocks.Clear();
visiblegeometry.Clear();
visiblethings.Clear();
// Make new blockmap
if(blockmap != null)
{
blockmap.Dispose();
blockmap = new VisualBlockMap();
FillBlockMap();
}
// Visibility culling
DoCulling();
renderer.SetCrosshairBusy(false); renderer.SetCrosshairBusy(false);
} }
@ -229,34 +218,22 @@ namespace CodeImp.DoomBuilder.VisualModes
{ {
renderer.SetCrosshairBusy(true); renderer.SetCrosshairBusy(true);
General.Interface.RedrawDisplay(); General.Interface.RedrawDisplay();
return base.OnRedoBegin(); return base.OnRedoBegin();
} }
public override void OnRedoEnd() public override void OnRedoEnd()
{ {
base.OnRedoEnd(); base.OnRedoEnd();
ResourcesReloaded();
DisposeVisuals();
visiblesectors.Clear();
visibleblocks.Clear();
visiblegeometry.Clear();
visiblethings.Clear();
// Make new blockmap
if(blockmap != null)
{
blockmap.Dispose();
blockmap = new VisualBlockMap();
FillBlockMap();
}
// Visibility culling
DoCulling();
renderer.SetCrosshairBusy(false); renderer.SetCrosshairBusy(false);
} }
public override void OnReloadResources()
{
base.OnReloadResources();
ResourcesReloaded();
}
#endregion #endregion
#region ================== Input #region ================== Input
@ -653,17 +630,37 @@ namespace CodeImp.DoomBuilder.VisualModes
#region ================== Processing #region ================== Processing
// This disposes all visual sectors and things /// <summary>
private void DisposeVisuals() /// This disposes all resources and rebuilds the ones needed.
/// This usually happens when geometry is changed by undo, redo, cut or paste actions.
/// </summary>
protected virtual void ResourcesReloaded()
{ {
// Dispose
foreach(KeyValuePair<Sector, VisualSector> vs in allsectors) foreach(KeyValuePair<Sector, VisualSector> vs in allsectors)
vs.Value.Dispose(); vs.Value.Dispose();
foreach(KeyValuePair<Thing, VisualThing> vt in allthings) foreach(KeyValuePair<Thing, VisualThing> vt in allthings)
vt.Value.Dispose(); vt.Value.Dispose();
// Clear collections
allsectors.Clear(); allsectors.Clear();
allthings.Clear(); allthings.Clear();
visiblesectors.Clear();
visibleblocks.Clear();
visiblegeometry.Clear();
visiblethings.Clear();
// Make new blockmap
if(blockmap != null)
{
blockmap.Dispose();
blockmap = new VisualBlockMap();
FillBlockMap();
}
// Visibility culling (this re-creates the needed resources)
DoCulling();
} }
/// <summary> /// <summary>
@ -679,34 +676,22 @@ namespace CodeImp.DoomBuilder.VisualModes
/// <summary> /// <summary>
/// This returns the VisualSector for the given Sector. /// This returns the VisualSector for the given Sector.
/// </summary> /// </summary>
protected VisualSector GetVisualSector(Sector s) protected VisualSector GetVisualSector(Sector s) { return allsectors[s]; }
{
return allsectors[s];
}
/// <summary> /// <summary>
/// This returns the VisualThing for the given Thing. /// This returns the VisualThing for the given Thing.
/// </summary> /// </summary>
protected VisualThing GetVisualThing(Thing t) protected VisualThing GetVisualThing(Thing t) { return allthings[t]; }
{
return allthings[t];
}
/// <summary> /// <summary>
/// Returns True when a VisualSector has been created for the specified Sector. /// Returns True when a VisualSector has been created for the specified Sector.
/// </summary> /// </summary>
protected bool VisualSectorExists(Sector s) protected bool VisualSectorExists(Sector s) { return allsectors.ContainsKey(s); }
{
return allsectors.ContainsKey(s);
}
/// <summary> /// <summary>
/// Returns True when a VisualThing has been created for the specified Thing. /// Returns True when a VisualThing has been created for the specified Thing.
/// </summary> /// </summary>
protected bool VisualThingExists(Thing t) protected bool VisualThingExists(Thing t) { return allthings.ContainsKey(t); }
{
return allthings.ContainsKey(t);
}
/// <summary> /// <summary>
/// This is called when the blockmap needs to be refilled, because it was invalidated. /// This is called when the blockmap needs to be refilled, because it was invalidated.
@ -766,23 +751,11 @@ namespace CodeImp.DoomBuilder.VisualModes
// Render all visible things // Render all visible things
foreach(VisualThing t in visiblethings) foreach(VisualThing t in visiblethings)
renderer.AddThingGeometry(t); renderer.AddThingGeometry(t);
General.WriteLogLine("Things: " + visiblethings.Count);
} }
#endregion #endregion
#region ================== Actions #region ================== Actions
[EndAction("reloadresources", BaseAction = true)]
public virtual void ReloadResources()
{
// Trash all visual sectors, because they are no longer valid
foreach(KeyValuePair<Sector, VisualSector> s in allsectors) s.Value.Dispose();
allsectors.Clear();
visiblesectors.Clear();
visiblegeometry.Clear();
}
#endregion #endregion
} }

View file

@ -193,26 +193,30 @@ namespace CodeImp.DoomBuilder.VisualModes
// This updates the visual thing // This updates the visual thing
public virtual void Update() public virtual void Update()
{ {
// Trash geometry buffer // Do we need to update the geometry buffer?
if(geobuffer != null) geobuffer.Dispose(); if(updategeo)
geobuffer = null;
// Any vertics?
if(vertices.Length > 0)
{ {
// Make a new buffer // Trash geometry buffer
geobuffer = new VertexBuffer(General.Map.Graphics.Device, WorldVertex.Stride * vertices.Length, if(geobuffer != null) geobuffer.Dispose();
Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default); geobuffer = null;
// Fill the buffer // Any vertics?
DataStream bufferstream = geobuffer.Lock(0, WorldVertex.Stride * vertices.Length, LockFlags.Discard); if(vertices.Length > 0)
bufferstream.WriteRange<WorldVertex>(vertices); {
geobuffer.Unlock(); // Make a new buffer
bufferstream.Dispose(); geobuffer = new VertexBuffer(General.Map.Graphics.Device, WorldVertex.Stride * vertices.Length,
Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default);
// Fill the buffer
DataStream bufferstream = geobuffer.Lock(0, WorldVertex.Stride * vertices.Length, LockFlags.Discard);
bufferstream.WriteRange<WorldVertex>(vertices);
geobuffer.Unlock();
bufferstream.Dispose();
}
// Done
updategeo = false;
} }
// Done
updategeo = false;
} }
/// <summary> /// <summary>

View file

@ -259,8 +259,7 @@ namespace CodeImp.DoomBuilder.Windows
string asmname; string asmname;
this.Update(); this.Update();
General.Actions[(sender as ToolStripItem).Tag.ToString()].Begin(); General.Actions.InvokeAction((sender as ToolStripItem).Tag.ToString());
General.Actions[(sender as ToolStripItem).Tag.ToString()].End();
this.Update(); this.Update();
} }
@ -1367,7 +1366,7 @@ namespace CodeImp.DoomBuilder.Windows
this.Update(); this.Update();
modeinfo = (EditModeInfo)((sender as ToolStripItem).Tag); modeinfo = (EditModeInfo)((sender as ToolStripItem).Tag);
General.Actions[modeinfo.SwitchAction.GetFullActionName(modeinfo.Plugin.Assembly)].Begin(); General.Actions.InvokeAction(modeinfo.SwitchAction.GetFullActionName(modeinfo.Plugin.Assembly));
this.Update(); this.Update();
} }
@ -1795,7 +1794,7 @@ namespace CodeImp.DoomBuilder.Windows
General.Plugins.ProgramReconfigure(); General.Plugins.ProgramReconfigure();
// Reload resources if a map is open // Reload resources if a map is open
if(General.Map != null) General.Map.ReloadResources(); if(General.Map != null) General.Actions.InvokeAction("builder_reloadresources");
// Redraw display // Redraw display
RedrawDisplay(); RedrawDisplay();
@ -1825,11 +1824,11 @@ namespace CodeImp.DoomBuilder.Windows
// Map opened? // Map opened?
if(General.Map != null) if(General.Map != null)
{ {
// Setup and reload stuff // Reload resources!
if(General.Map.ScriptEditor != null) General.Map.ScriptEditor.Editor.RefreshSettings(); if(General.Map.ScriptEditor != null) General.Map.ScriptEditor.Editor.RefreshSettings();
General.Map.Graphics.SetupSettings(); General.Map.Graphics.SetupSettings();
General.Map.UpdateConfiguration(); General.Map.UpdateConfiguration();
General.Map.ReloadResources(); General.Actions.InvokeAction("builder_reloadresources");
} }
// Redraw display // Redraw display