mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +00:00
happy birthday doom!
This commit is contained in:
parent
5db0757020
commit
53a1f085ab
15 changed files with 129 additions and 122 deletions
Binary file not shown.
BIN
Resources/UnknownThing.png
Normal file
BIN
Resources/UnknownThing.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 558 B |
|
@ -399,6 +399,22 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
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
|
||||
|
||||
|
|
|
@ -237,20 +237,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
|
||||
// After undo
|
||||
public override void OnUndoEnd()
|
||||
// After resources were reloaded
|
||||
protected override void ResourcesReloaded()
|
||||
{
|
||||
base.OnUndoEnd();
|
||||
base.ResourcesReloaded();
|
||||
PickTarget();
|
||||
}
|
||||
|
||||
// After redo
|
||||
public override void OnRedoEnd()
|
||||
{
|
||||
base.OnRedoEnd();
|
||||
PickTarget();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Actions
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
#region ================== Constructor / Setup
|
||||
|
||||
// Constructor
|
||||
public BaseVisualThing(Thing t) : base(t)
|
||||
|
@ -80,11 +80,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
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
|
||||
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
|
||||
isloaded = sprite.IsImageLoaded;
|
||||
|
@ -148,7 +159,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
if(!IsDisposed)
|
||||
{
|
||||
if(sprite != null) sprite.RemoveReference();
|
||||
if(sprite != null)
|
||||
{
|
||||
sprite.RemoveReference();
|
||||
sprite = null;
|
||||
}
|
||||
}
|
||||
|
||||
base.Dispose();
|
||||
|
|
|
@ -130,7 +130,6 @@ namespace CodeImp.DoomBuilder.Data
|
|||
|
||||
// Done
|
||||
usedinmap = false;
|
||||
references = 0;
|
||||
imagestate = ImageLoadState.None;
|
||||
previewstate = ImageLoadState.None;
|
||||
isdisposed = true;
|
||||
|
|
|
@ -204,6 +204,9 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
// Processing events
|
||||
public virtual void OnProcess(double deltatime) { }
|
||||
|
||||
// Generic events
|
||||
public virtual void OnReloadResources() { }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1226,7 +1226,9 @@ namespace CodeImp.DoomBuilder
|
|||
// This shows a major failure
|
||||
public static void Fail(string message)
|
||||
{
|
||||
General.WriteLogLine("FAIL: " + message);
|
||||
Debug.Fail(message);
|
||||
Terminate(false);
|
||||
}
|
||||
|
||||
// This outputs log information
|
||||
|
|
|
@ -1293,9 +1293,12 @@ namespace CodeImp.DoomBuilder
|
|||
// Re-link the background image
|
||||
grid.LinkBackground();
|
||||
|
||||
// Inform all plugins that the resource are reloaded
|
||||
// Inform all plugins that the resources are reloaded
|
||||
General.Plugins.ReloadResources();
|
||||
|
||||
// Inform editing mode that the resources are reloaded
|
||||
if(General.Editing.Mode != null) General.Editing.Mode.OnReloadResources();
|
||||
|
||||
// Reset status
|
||||
General.MainWindow.DisplayStatus(oldstatus);
|
||||
Cursor.Current = oldcursor;
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private LinkedList<Sidedef> sidedefs;
|
||||
|
||||
// Things
|
||||
private LinkedList<Thing> things;
|
||||
//private LinkedList<Thing> things;
|
||||
|
||||
// Properties
|
||||
private int index;
|
||||
|
@ -85,7 +85,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
public MapSet Map { get { return map; } }
|
||||
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 FloorHeight { get { return floorheight; } set { floorheight = value; } }
|
||||
public int CeilHeight { get { return ceilheight; } set { ceilheight = value; } }
|
||||
|
@ -117,7 +117,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
this.map = map;
|
||||
this.mainlistitem = listitem;
|
||||
this.sidedefs = new LinkedList<Sidedef>();
|
||||
this.things = new LinkedList<Thing>();
|
||||
//this.things = new LinkedList<Thing>();
|
||||
this.index = index;
|
||||
this.floortexname = "-";
|
||||
this.ceiltexname = "-";
|
||||
|
@ -138,7 +138,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
this.map = map;
|
||||
this.mainlistitem = listitem;
|
||||
this.sidedefs = new LinkedList<Sidedef>();
|
||||
this.things = new LinkedList<Thing>();
|
||||
//this.things = new LinkedList<Thing>();
|
||||
this.triangulationneeded = true;
|
||||
|
||||
ReadWrite(stream);
|
||||
|
@ -177,7 +177,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
flatfloorbuffer = null;
|
||||
mainlistitem = null;
|
||||
sidedefs = null;
|
||||
things = null;
|
||||
//things = null;
|
||||
map = null;
|
||||
|
||||
// Dispose base
|
||||
|
@ -252,10 +252,10 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
|
||||
// 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
|
||||
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
|
||||
public void UpdateCache()
|
||||
|
|
|
@ -116,7 +116,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
mainlistitem.List.Remove(mainlistitem);
|
||||
|
||||
// Remove from sector
|
||||
if(sector != null) sector.DetachThing(sectorlistitem);
|
||||
//if(sector != null) sector.DetachThing(sectorlistitem);
|
||||
|
||||
// Clean up
|
||||
mainlistitem = null;
|
||||
|
@ -215,7 +215,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if((sector != null) && (newsector != sector))
|
||||
{
|
||||
// Remove from current sector
|
||||
sector.DetachThing(sectorlistitem);
|
||||
//sector.DetachThing(sectorlistitem);
|
||||
sectorlistitem = null;
|
||||
sector = null;
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
{
|
||||
// Attach to new sector
|
||||
sector = newsector;
|
||||
sectorlistitem = sector.AttachThing(this);
|
||||
//sectorlistitem = sector.AttachThing(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -444,7 +444,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
foreach(VisualThing t in group.Value)
|
||||
{
|
||||
// Update buffer if needed
|
||||
if(t.NeedsUpdateGeo) t.Update();
|
||||
t.Update();
|
||||
|
||||
// Only do this sector when a vertexbuffer is created
|
||||
if(t.GeometryBuffer != null)
|
||||
|
|
|
@ -174,7 +174,14 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
public override void 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?
|
||||
if(modething != null)
|
||||
|
@ -197,31 +204,13 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
{
|
||||
renderer.SetCrosshairBusy(true);
|
||||
General.Interface.RedrawDisplay();
|
||||
|
||||
return base.OnUndoBegin();
|
||||
}
|
||||
|
||||
public override void OnUndoEnd()
|
||||
{
|
||||
base.OnUndoEnd();
|
||||
|
||||
DisposeVisuals();
|
||||
visiblesectors.Clear();
|
||||
visibleblocks.Clear();
|
||||
visiblegeometry.Clear();
|
||||
visiblethings.Clear();
|
||||
|
||||
// Make new blockmap
|
||||
if(blockmap != null)
|
||||
{
|
||||
blockmap.Dispose();
|
||||
blockmap = new VisualBlockMap();
|
||||
FillBlockMap();
|
||||
}
|
||||
|
||||
// Visibility culling
|
||||
DoCulling();
|
||||
|
||||
ResourcesReloaded();
|
||||
renderer.SetCrosshairBusy(false);
|
||||
}
|
||||
|
||||
|
@ -229,34 +218,22 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
{
|
||||
renderer.SetCrosshairBusy(true);
|
||||
General.Interface.RedrawDisplay();
|
||||
|
||||
return base.OnRedoBegin();
|
||||
}
|
||||
|
||||
public override void OnRedoEnd()
|
||||
{
|
||||
base.OnRedoEnd();
|
||||
|
||||
DisposeVisuals();
|
||||
visiblesectors.Clear();
|
||||
visibleblocks.Clear();
|
||||
visiblegeometry.Clear();
|
||||
visiblethings.Clear();
|
||||
|
||||
// Make new blockmap
|
||||
if(blockmap != null)
|
||||
{
|
||||
blockmap.Dispose();
|
||||
blockmap = new VisualBlockMap();
|
||||
FillBlockMap();
|
||||
}
|
||||
|
||||
// Visibility culling
|
||||
DoCulling();
|
||||
|
||||
ResourcesReloaded();
|
||||
renderer.SetCrosshairBusy(false);
|
||||
}
|
||||
|
||||
public override void OnReloadResources()
|
||||
{
|
||||
base.OnReloadResources();
|
||||
ResourcesReloaded();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Input
|
||||
|
@ -653,17 +630,37 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
|
||||
#region ================== Processing
|
||||
|
||||
// This disposes all visual sectors and things
|
||||
private void DisposeVisuals()
|
||||
/// <summary>
|
||||
/// 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)
|
||||
vs.Value.Dispose();
|
||||
|
||||
foreach(KeyValuePair<Thing, VisualThing> vt in allthings)
|
||||
vt.Value.Dispose();
|
||||
|
||||
// Clear collections
|
||||
allsectors.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>
|
||||
|
@ -679,34 +676,22 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
/// <summary>
|
||||
/// This returns the VisualSector for the given Sector.
|
||||
/// </summary>
|
||||
protected VisualSector GetVisualSector(Sector s)
|
||||
{
|
||||
return allsectors[s];
|
||||
}
|
||||
protected VisualSector GetVisualSector(Sector s) { return allsectors[s]; }
|
||||
|
||||
/// <summary>
|
||||
/// This returns the VisualThing for the given Thing.
|
||||
/// </summary>
|
||||
protected VisualThing GetVisualThing(Thing t)
|
||||
{
|
||||
return allthings[t];
|
||||
}
|
||||
protected VisualThing GetVisualThing(Thing t) { return allthings[t]; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns True when a VisualSector has been created for the specified Sector.
|
||||
/// </summary>
|
||||
protected bool VisualSectorExists(Sector s)
|
||||
{
|
||||
return allsectors.ContainsKey(s);
|
||||
}
|
||||
protected bool VisualSectorExists(Sector s) { return allsectors.ContainsKey(s); }
|
||||
|
||||
/// <summary>
|
||||
/// Returns True when a VisualThing has been created for the specified Thing.
|
||||
/// </summary>
|
||||
protected bool VisualThingExists(Thing t)
|
||||
{
|
||||
return allthings.ContainsKey(t);
|
||||
}
|
||||
protected bool VisualThingExists(Thing t) { return allthings.ContainsKey(t); }
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
foreach(VisualThing t in visiblethings)
|
||||
renderer.AddThingGeometry(t);
|
||||
|
||||
General.WriteLogLine("Things: " + visiblethings.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#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
|
||||
}
|
||||
|
|
|
@ -193,26 +193,30 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
// This updates the visual thing
|
||||
public virtual void Update()
|
||||
{
|
||||
// Trash geometry buffer
|
||||
if(geobuffer != null) geobuffer.Dispose();
|
||||
geobuffer = null;
|
||||
|
||||
// Any vertics?
|
||||
if(vertices.Length > 0)
|
||||
// Do we need to update the geometry buffer?
|
||||
if(updategeo)
|
||||
{
|
||||
// Make a new buffer
|
||||
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();
|
||||
// Trash geometry buffer
|
||||
if(geobuffer != null) geobuffer.Dispose();
|
||||
geobuffer = null;
|
||||
|
||||
// Any vertics?
|
||||
if(vertices.Length > 0)
|
||||
{
|
||||
// Make a new buffer
|
||||
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>
|
||||
|
|
|
@ -259,8 +259,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
string asmname;
|
||||
|
||||
this.Update();
|
||||
General.Actions[(sender as ToolStripItem).Tag.ToString()].Begin();
|
||||
General.Actions[(sender as ToolStripItem).Tag.ToString()].End();
|
||||
General.Actions.InvokeAction((sender as ToolStripItem).Tag.ToString());
|
||||
this.Update();
|
||||
}
|
||||
|
||||
|
@ -1367,7 +1366,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
|
||||
this.Update();
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -1795,7 +1794,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
General.Plugins.ProgramReconfigure();
|
||||
|
||||
// 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
|
||||
RedrawDisplay();
|
||||
|
@ -1825,11 +1824,11 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// Map opened?
|
||||
if(General.Map != null)
|
||||
{
|
||||
// Setup and reload stuff
|
||||
// Reload resources!
|
||||
if(General.Map.ScriptEditor != null) General.Map.ScriptEditor.Editor.RefreshSettings();
|
||||
General.Map.Graphics.SetupSettings();
|
||||
General.Map.UpdateConfiguration();
|
||||
General.Map.ReloadResources();
|
||||
General.Actions.InvokeAction("builder_reloadresources");
|
||||
}
|
||||
|
||||
// Redraw display
|
||||
|
|
Loading…
Reference in a new issue