mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 12:50:52 +00:00
- created MapSet serialization system for undo/redo
- added hourglass crosshair in visual mode for time consuming actions
This commit is contained in:
parent
9d8060be0c
commit
3daf9307e9
28 changed files with 1178 additions and 60 deletions
BIN
Resources/CrosshairBusy.png
Normal file
BIN
Resources/CrosshairBusy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
|
@ -650,10 +650,14 @@
|
||||||
<None Include="Resources\Close.png" />
|
<None Include="Resources\Close.png" />
|
||||||
<Compile Include="Editing\EditingManager.cs" />
|
<Compile Include="Editing\EditingManager.cs" />
|
||||||
<EmbeddedResource Include="Resources\Crosshair.png" />
|
<EmbeddedResource Include="Resources\Crosshair.png" />
|
||||||
|
<EmbeddedResource Include="Resources\CrosshairBusy.png" />
|
||||||
<Content Include="Resources\DB2.ico" />
|
<Content Include="Resources\DB2.ico" />
|
||||||
<Compile Include="General\BinaryHeap.cs" />
|
<Compile Include="General\BinaryHeap.cs" />
|
||||||
<Compile Include="Geometry\Plane.cs" />
|
<Compile Include="Geometry\Plane.cs" />
|
||||||
<Compile Include="Geometry\ProjectedFrustum2D.cs" />
|
<Compile Include="Geometry\ProjectedFrustum2D.cs" />
|
||||||
|
<Compile Include="IO\DeserializerStream.cs" />
|
||||||
|
<Compile Include="IO\IReadWriteStream.cs" />
|
||||||
|
<Compile Include="IO\SerializerStream.cs" />
|
||||||
<Compile Include="Rendering\RenderPasses.cs" />
|
<Compile Include="Rendering\RenderPasses.cs" />
|
||||||
<Compile Include="VisualModes\VisualBlockEntry.cs" />
|
<Compile Include="VisualModes\VisualBlockEntry.cs" />
|
||||||
<Compile Include="VisualModes\VisualPickResult.cs" />
|
<Compile Include="VisualModes\VisualPickResult.cs" />
|
||||||
|
|
|
@ -219,6 +219,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// After undo
|
||||||
|
public override void OnUndoEnd()
|
||||||
|
{
|
||||||
|
base.OnUndoEnd();
|
||||||
|
PickTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
// After redo
|
||||||
|
public override void OnRedoEnd()
|
||||||
|
{
|
||||||
|
base.OnRedoEnd();
|
||||||
|
PickTarget();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Actions
|
#region ================== Actions
|
||||||
|
|
|
@ -71,6 +71,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
private ImageData missingtexture3d;
|
private ImageData missingtexture3d;
|
||||||
private ImageData hourglass3d;
|
private ImageData hourglass3d;
|
||||||
private ImageData crosshair;
|
private ImageData crosshair;
|
||||||
|
private ImageData crosshairbusy;
|
||||||
|
|
||||||
// Used images
|
// Used images
|
||||||
private Dictionary<long, long> usedimages;
|
private Dictionary<long, long> usedimages;
|
||||||
|
@ -92,6 +93,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
public ImageData MissingTexture3D { get { return missingtexture3d; } }
|
public ImageData MissingTexture3D { get { return missingtexture3d; } }
|
||||||
public ImageData Hourglass3D { get { return hourglass3d; } }
|
public ImageData Hourglass3D { get { return hourglass3d; } }
|
||||||
public ImageData Crosshair3D { get { return crosshair; } }
|
public ImageData Crosshair3D { get { return crosshair; } }
|
||||||
|
public ImageData CrosshairBusy3D { get { return crosshairbusy; } }
|
||||||
internal ICollection<MatchingTextureSet> TextureSets { get { return texturesets; } }
|
internal ICollection<MatchingTextureSet> TextureSets { get { return texturesets; } }
|
||||||
internal OthersTextureSet OthersTextureSet { get { return othertextures; } }
|
internal OthersTextureSet OthersTextureSet { get { return othertextures; } }
|
||||||
|
|
||||||
|
@ -127,6 +129,8 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
hourglass3d.LoadImage();
|
hourglass3d.LoadImage();
|
||||||
crosshair = new ResourceImage("Crosshair.png");
|
crosshair = new ResourceImage("Crosshair.png");
|
||||||
crosshair.LoadImage();
|
crosshair.LoadImage();
|
||||||
|
crosshairbusy = new ResourceImage("CrosshairBusy.png");
|
||||||
|
crosshairbusy.LoadImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disposer
|
// Disposer
|
||||||
|
@ -143,6 +147,8 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
hourglass3d = null;
|
hourglass3d = null;
|
||||||
crosshair.Dispose();
|
crosshair.Dispose();
|
||||||
crosshair = null;
|
crosshair = null;
|
||||||
|
crosshairbusy.Dispose();
|
||||||
|
crosshairbusy = null;
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
isdisposed = true;
|
isdisposed = true;
|
||||||
|
|
|
@ -163,7 +163,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
public void RemoveReference()
|
public void RemoveReference()
|
||||||
{
|
{
|
||||||
references--;
|
references--;
|
||||||
if(references < 0) General.Fail("FAIL! (references < 0)", "Somewhere this image is dereferenced more than it was referenced.");
|
if(references < 0) General.Fail("FAIL! (references < 0) Somewhere this image is dereferenced more than it was referenced.");
|
||||||
if(references == 0) General.Map.Data.ProcessImage(this);
|
if(references == 0) General.Map.Data.ProcessImage(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,6 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
public enum UndoGroup : int
|
public enum UndoGroup : int
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
FloorTextureChange,
|
|
||||||
CeilingTextureChange,
|
|
||||||
FloorHeightChange,
|
FloorHeightChange,
|
||||||
CeilingHeightChange,
|
CeilingHeightChange,
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
private void ClearRedos()
|
private void ClearRedos()
|
||||||
{
|
{
|
||||||
// Dispose all redos
|
// Dispose all redos
|
||||||
foreach(UndoSnapshot u in redos) u.map.Dispose();
|
foreach(UndoSnapshot u in redos) u.mapdata.Dispose();
|
||||||
redos.Clear();
|
redos.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
private void ClearUndos()
|
private void ClearUndos()
|
||||||
{
|
{
|
||||||
// Dispose all undos
|
// Dispose all undos
|
||||||
foreach(UndoSnapshot u in undos) u.map.Dispose();
|
foreach(UndoSnapshot u in undos) u.mapdata.Dispose();
|
||||||
undos.Clear();
|
undos.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
{
|
{
|
||||||
// Remove one and dispose map
|
// Remove one and dispose map
|
||||||
u = list[list.Count - 1];
|
u = list[list.Count - 1];
|
||||||
u.map.Dispose();
|
u.mapdata.Dispose();
|
||||||
list.RemoveAt(list.Count - 1);
|
list.RemoveAt(list.Count - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
General.WriteLogLine("Creating undo snapshot \"" + description + "\", Group " + group + ", Tag " + grouptag + ", Ticket ID " + ticketid + "...");
|
General.WriteLogLine("Creating undo snapshot \"" + description + "\", Group " + group + ", Tag " + grouptag + ", Ticket ID " + ticketid + "...");
|
||||||
|
|
||||||
// Make a snapshot
|
// Make a snapshot
|
||||||
u = new UndoSnapshot(description, General.Map.Map.Clone(), ticketid);
|
u = new UndoSnapshot(description, General.Map.Map.Serialize(), ticketid);
|
||||||
|
|
||||||
// Put it on the stack
|
// Put it on the stack
|
||||||
undos.Insert(0, u);
|
undos.Insert(0, u);
|
||||||
|
@ -202,6 +202,7 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
General.WriteLogLine("Withdrawing undo snapshot \"" + undos[0].description + "\", Ticket ID " + ticket + "...");
|
General.WriteLogLine("Withdrawing undo snapshot \"" + undos[0].description + "\", Ticket ID " + ticket + "...");
|
||||||
|
|
||||||
// Remove the last made undo
|
// Remove the last made undo
|
||||||
|
undos[0].mapdata.Dispose();
|
||||||
undos.RemoveAt(0);
|
undos.RemoveAt(0);
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
|
@ -218,18 +219,18 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
Cursor oldcursor = Cursor.Current;
|
Cursor oldcursor = Cursor.Current;
|
||||||
Cursor.Current = Cursors.WaitCursor;
|
Cursor.Current = Cursors.WaitCursor;
|
||||||
|
|
||||||
// Let the plugins know
|
// Anything to undo?
|
||||||
if(General.Plugins.OnUndoBegin())
|
if(undos.Count > 0)
|
||||||
{
|
{
|
||||||
// Call UndoBegin event
|
// Let the plugins know
|
||||||
if(General.Editing.Mode.OnUndoBegin())
|
if(General.Plugins.OnUndoBegin())
|
||||||
{
|
{
|
||||||
// Cancel volatile mode, if any
|
// Call UndoBegin event
|
||||||
// This returns false when mode was not volatile
|
if(General.Editing.Mode.OnUndoBegin())
|
||||||
if(!General.CancelVolatileMode())
|
|
||||||
{
|
{
|
||||||
// Anything to undo?
|
// Cancel volatile mode, if any
|
||||||
if(undos.Count > 0)
|
// This returns false when mode was not volatile
|
||||||
|
if(!General.CancelVolatileMode())
|
||||||
{
|
{
|
||||||
// Get undo snapshot
|
// Get undo snapshot
|
||||||
u = undos[0];
|
u = undos[0];
|
||||||
|
@ -238,7 +239,7 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
General.WriteLogLine("Performing undo \"" + u.description + "\", Ticket ID " + u.ticketid + "...");
|
General.WriteLogLine("Performing undo \"" + u.description + "\", Ticket ID " + u.ticketid + "...");
|
||||||
|
|
||||||
// Make a snapshot for redo
|
// Make a snapshot for redo
|
||||||
r = new UndoSnapshot(u, General.Map.Map.Clone());
|
r = new UndoSnapshot(u, General.Map.Map.Serialize());
|
||||||
|
|
||||||
// Put it on the stack
|
// Put it on the stack
|
||||||
redos.Insert(0, r);
|
redos.Insert(0, r);
|
||||||
|
@ -247,12 +248,12 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
// Reset grouping
|
// Reset grouping
|
||||||
lastgroup = UndoGroup.None;
|
lastgroup = UndoGroup.None;
|
||||||
|
|
||||||
// Remove selection
|
|
||||||
u.map.ClearAllMarks(false);
|
|
||||||
u.map.ClearAllSelected();
|
|
||||||
|
|
||||||
// Change map set
|
// Change map set
|
||||||
General.Map.ChangeMapSet(u.map);
|
General.Map.ChangeMapSet(new MapSet(u.mapdata));
|
||||||
|
|
||||||
|
// Remove selection
|
||||||
|
General.Map.Map.ClearAllMarks(false);
|
||||||
|
General.Map.Map.ClearAllSelected();
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
General.Editing.Mode.OnUndoEnd();
|
General.Editing.Mode.OnUndoEnd();
|
||||||
|
@ -277,18 +278,18 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
Cursor oldcursor = Cursor.Current;
|
Cursor oldcursor = Cursor.Current;
|
||||||
Cursor.Current = Cursors.WaitCursor;
|
Cursor.Current = Cursors.WaitCursor;
|
||||||
|
|
||||||
// Let the plugins know
|
// Anything to redo?
|
||||||
if(General.Plugins.OnRedoBegin())
|
if(redos.Count > 0)
|
||||||
{
|
{
|
||||||
// Call RedoBegin event
|
// Let the plugins know
|
||||||
if(General.Editing.Mode.OnRedoBegin())
|
if(General.Plugins.OnRedoBegin())
|
||||||
{
|
{
|
||||||
// Cancel volatile mode, if any
|
// Call RedoBegin event
|
||||||
General.CancelVolatileMode();
|
if(General.Editing.Mode.OnRedoBegin())
|
||||||
|
|
||||||
// Anything to redo?
|
|
||||||
if(redos.Count > 0)
|
|
||||||
{
|
{
|
||||||
|
// Cancel volatile mode, if any
|
||||||
|
General.CancelVolatileMode();
|
||||||
|
|
||||||
// Get redo snapshot
|
// Get redo snapshot
|
||||||
r = redos[0];
|
r = redos[0];
|
||||||
redos.RemoveAt(0);
|
redos.RemoveAt(0);
|
||||||
|
@ -296,7 +297,7 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
General.WriteLogLine("Performing redo \"" + r.description + "\", Ticket ID " + r.ticketid + "...");
|
General.WriteLogLine("Performing redo \"" + r.description + "\", Ticket ID " + r.ticketid + "...");
|
||||||
|
|
||||||
// Make a snapshot for undo
|
// Make a snapshot for undo
|
||||||
u = new UndoSnapshot(r, General.Map.Map.Clone());
|
u = new UndoSnapshot(r, General.Map.Map.Serialize());
|
||||||
|
|
||||||
// Put it on the stack
|
// Put it on the stack
|
||||||
undos.Insert(0, u);
|
undos.Insert(0, u);
|
||||||
|
@ -305,12 +306,12 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
// Reset grouping
|
// Reset grouping
|
||||||
lastgroup = UndoGroup.None;
|
lastgroup = UndoGroup.None;
|
||||||
|
|
||||||
// Remove selection
|
|
||||||
r.map.ClearAllMarks(false);
|
|
||||||
r.map.ClearAllSelected();
|
|
||||||
|
|
||||||
// Change map set
|
// Change map set
|
||||||
General.Map.ChangeMapSet(r.map);
|
General.Map.ChangeMapSet(new MapSet(r.mapdata));
|
||||||
|
|
||||||
|
// Remove selection
|
||||||
|
General.Map.Map.ClearAllMarks(false);
|
||||||
|
General.Map.Map.ClearAllSelected();
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
General.Editing.Mode.OnRedoEnd();
|
General.Editing.Mode.OnRedoEnd();
|
||||||
|
|
|
@ -37,24 +37,24 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
{
|
{
|
||||||
internal class UndoSnapshot
|
internal class UndoSnapshot
|
||||||
{
|
{
|
||||||
public MapSet map;
|
public MemoryStream mapdata;
|
||||||
public string description;
|
public string description;
|
||||||
public int ticketid; // For safe withdrawing
|
public int ticketid; // For safe withdrawing
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
public UndoSnapshot(string description, MapSet map, int ticketid)
|
public UndoSnapshot(string description, MemoryStream mapdata, int ticketid)
|
||||||
{
|
{
|
||||||
this.ticketid = ticketid;
|
this.ticketid = ticketid;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.map = map;
|
this.mapdata = mapdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
public UndoSnapshot(UndoSnapshot info, MapSet map)
|
public UndoSnapshot(UndoSnapshot info, MemoryStream mapdata)
|
||||||
{
|
{
|
||||||
this.ticketid = info.ticketid;
|
this.ticketid = info.ticketid;
|
||||||
this.description = info.description;
|
this.description = info.description;
|
||||||
this.map = map;
|
this.mapdata = mapdata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1224,9 +1224,9 @@ namespace CodeImp.DoomBuilder
|
||||||
#region ================== Debug
|
#region ================== Debug
|
||||||
|
|
||||||
// This shows a major failure
|
// This shows a major failure
|
||||||
public static void Fail(string message, string detailedmessage)
|
public static void Fail(string message)
|
||||||
{
|
{
|
||||||
Debug.Fail(message, detailedmessage);
|
Debug.Fail(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This outputs log information
|
// This outputs log information
|
||||||
|
|
|
@ -1246,6 +1246,7 @@ namespace CodeImp.DoomBuilder
|
||||||
// Apply
|
// Apply
|
||||||
map.Dispose();
|
map.Dispose();
|
||||||
map = newmap;
|
map = newmap;
|
||||||
|
map.UpdateConfiguration();
|
||||||
map.Update();
|
map.Update();
|
||||||
thingsfilter.Update();
|
thingsfilter.Update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if(!normal.IsNormalized())
|
if(!normal.IsNormalized())
|
||||||
General.Fail("Attempt to create a plane with a vector that is not normalized!", "");
|
General.Fail("Attempt to create a plane with a vector that is not normalized!");
|
||||||
#endif
|
#endif
|
||||||
this.normal = normal;
|
this.normal = normal;
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
|
@ -75,7 +75,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if(!normal.IsNormalized())
|
if(!normal.IsNormalized())
|
||||||
General.Fail("Attempt to create a plane with a vector that is not normalized!", "");
|
General.Fail("Attempt to create a plane with a vector that is not normalized!");
|
||||||
#endif
|
#endif
|
||||||
this.normal = normal;
|
this.normal = normal;
|
||||||
this.offset = -Vector3D.DotProduct(normal, position);
|
this.offset = -Vector3D.DotProduct(normal, position);
|
||||||
|
|
|
@ -737,7 +737,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// No triangulation was made. FAIL!
|
// No triangulation was made. FAIL!
|
||||||
General.Fail("No triangulation exists for sector " + s, "Triangulation is required to create label positions for a sector.");
|
General.Fail("No triangulation exists for sector " + s + " Triangulation is required to create label positions for a sector.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
|
|
170
Source/IO/DeserializerStream.cs
Normal file
170
Source/IO/DeserializerStream.cs
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
|
||||||
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
||||||
|
* This program is released under GNU General Public License
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Namespaces
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
|
using CodeImp.DoomBuilder.Geometry;
|
||||||
|
using CodeImp.DoomBuilder.Rendering;
|
||||||
|
using SlimDX.Direct3D9;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace CodeImp.DoomBuilder.IO
|
||||||
|
{
|
||||||
|
internal sealed class DeserializerStream : IReadWriteStream
|
||||||
|
{
|
||||||
|
#region ================== Constants
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Variables
|
||||||
|
|
||||||
|
private Stream stream;
|
||||||
|
private BinaryReader reader;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Properties
|
||||||
|
|
||||||
|
public bool IsWriting { get { return false; } }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Constructor / Destructor
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
public DeserializerStream(Stream stream)
|
||||||
|
{
|
||||||
|
// Initialize
|
||||||
|
this.stream = stream;
|
||||||
|
this.reader = new BinaryReader(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Methods
|
||||||
|
|
||||||
|
// Bidirectional
|
||||||
|
public void rwInt(ref int v) { v = reader.ReadInt32(); }
|
||||||
|
|
||||||
|
public void rwByte(ref byte v) { v = reader.ReadByte(); }
|
||||||
|
|
||||||
|
public void rwShort(ref short v) { v = reader.ReadInt16(); }
|
||||||
|
|
||||||
|
public void rwString(ref string v) { v = reader.ReadString(); }
|
||||||
|
|
||||||
|
public void rwLong(ref long v) { v = reader.ReadInt64(); }
|
||||||
|
|
||||||
|
public void rwUInt(ref uint v) { v = reader.ReadUInt32(); }
|
||||||
|
|
||||||
|
public void rwUShort(ref ushort v) { v = reader.ReadUInt16(); }
|
||||||
|
|
||||||
|
public void rwULong(ref ulong v) { v = reader.ReadUInt64(); }
|
||||||
|
|
||||||
|
public void rwFloat(ref float v) { v = reader.ReadSingle(); }
|
||||||
|
|
||||||
|
public void rwBool(ref bool v) { v = reader.ReadBoolean(); }
|
||||||
|
|
||||||
|
public void rwVector2D(ref Vector2D v)
|
||||||
|
{
|
||||||
|
v.x = reader.ReadSingle();
|
||||||
|
v.y = reader.ReadSingle();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rwVector3D(ref Vector3D v)
|
||||||
|
{
|
||||||
|
v.x = reader.ReadSingle();
|
||||||
|
v.y = reader.ReadSingle();
|
||||||
|
v.z = reader.ReadSingle();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write-only is not supported
|
||||||
|
public void wInt(int v) { General.Fail("Write-only is not supported on deserialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void wByte(byte v) { General.Fail("Write-only is not supported on deserialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void wShort(short v) { General.Fail("Write-only is not supported on deserialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void wString(string v) { General.Fail("Write-only is not supported on deserialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void wLong(long v) { General.Fail("Write-only is not supported on deserialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void wUInt(uint v) { General.Fail("Write-only is not supported on deserialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void wUShort(ushort v) { General.Fail("Write-only is not supported on deserialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void wULong(ulong v) { General.Fail("Write-only is not supported on deserialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void wFloat(float v) { General.Fail("Write-only is not supported on deserialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void wBool(bool v) { General.Fail("Write-only is not supported on deserialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void wVector2D(Vector2D v)
|
||||||
|
{
|
||||||
|
General.Fail("Write-only is not supported on deserialization stream. Consider passing the element by reference for bidirectional support.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void wVector3D(Vector3D v)
|
||||||
|
{
|
||||||
|
General.Fail("Write-only is not supported on deserialization stream. Consider passing the element by reference for bidirectional support.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read-only
|
||||||
|
public void rInt(out int v) { v = reader.ReadInt32(); }
|
||||||
|
|
||||||
|
public void rByte(out byte v) { v = reader.ReadByte(); }
|
||||||
|
|
||||||
|
public void rShort(out short v) { v = reader.ReadInt16(); }
|
||||||
|
|
||||||
|
public void rString(out string v) { v = reader.ReadString(); }
|
||||||
|
|
||||||
|
public void rLong(out long v) { v = reader.ReadInt64(); }
|
||||||
|
|
||||||
|
public void rUInt(out uint v) { v = reader.ReadUInt32(); }
|
||||||
|
|
||||||
|
public void rUShort(out ushort v) { v = reader.ReadUInt16(); }
|
||||||
|
|
||||||
|
public void rULong(out ulong v) { v = reader.ReadUInt64(); }
|
||||||
|
|
||||||
|
public void rFloat(out float v) { v = reader.ReadSingle(); }
|
||||||
|
|
||||||
|
public void rBool(out bool v) { v = reader.ReadBoolean(); }
|
||||||
|
|
||||||
|
public void rVector2D(out Vector2D v)
|
||||||
|
{
|
||||||
|
v = new Vector2D();
|
||||||
|
v.x = reader.ReadSingle();
|
||||||
|
v.y = reader.ReadSingle();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rVector3D(out Vector3D v)
|
||||||
|
{
|
||||||
|
v = new Vector3D();
|
||||||
|
v.x = reader.ReadSingle();
|
||||||
|
v.y = reader.ReadSingle();
|
||||||
|
v.z = reader.ReadSingle();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
81
Source/IO/IReadWriteStream.cs
Normal file
81
Source/IO/IReadWriteStream.cs
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
|
||||||
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
||||||
|
* This program is released under GNU General Public License
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Namespaces
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
|
using CodeImp.DoomBuilder.Geometry;
|
||||||
|
using CodeImp.DoomBuilder.Rendering;
|
||||||
|
using SlimDX.Direct3D9;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace CodeImp.DoomBuilder.IO
|
||||||
|
{
|
||||||
|
internal interface IReadWriteStream
|
||||||
|
{
|
||||||
|
// Properties
|
||||||
|
bool IsWriting { get; }
|
||||||
|
|
||||||
|
// Bidirectional members
|
||||||
|
void rwInt(ref int v);
|
||||||
|
void rwByte(ref byte v);
|
||||||
|
void rwShort(ref short v);
|
||||||
|
void rwString(ref string v);
|
||||||
|
void rwLong(ref long v);
|
||||||
|
void rwUInt(ref uint v);
|
||||||
|
void rwUShort(ref ushort v);
|
||||||
|
void rwULong(ref ulong v);
|
||||||
|
void rwFloat(ref float v);
|
||||||
|
void rwVector2D(ref Vector2D v);
|
||||||
|
void rwVector3D(ref Vector3D v);
|
||||||
|
void rwBool(ref bool v);
|
||||||
|
|
||||||
|
// Write-only members
|
||||||
|
void wInt(int v);
|
||||||
|
void wByte(byte v);
|
||||||
|
void wShort(short v);
|
||||||
|
void wString(string v);
|
||||||
|
void wLong(long v);
|
||||||
|
void wUInt(uint v);
|
||||||
|
void wUShort(ushort v);
|
||||||
|
void wULong(ulong v);
|
||||||
|
void wFloat(float v);
|
||||||
|
void wVector2D(Vector2D v);
|
||||||
|
void wVector3D(Vector3D v);
|
||||||
|
void wBool(bool v);
|
||||||
|
|
||||||
|
// Read-only members
|
||||||
|
void rInt(out int v);
|
||||||
|
void rByte(out byte v);
|
||||||
|
void rShort(out short v);
|
||||||
|
void rString(out string v);
|
||||||
|
void rLong(out long v);
|
||||||
|
void rUInt(out uint v);
|
||||||
|
void rUShort(out ushort v);
|
||||||
|
void rULong(out ulong v);
|
||||||
|
void rFloat(out float v);
|
||||||
|
void rVector2D(out Vector2D v);
|
||||||
|
void rVector3D(out Vector3D v);
|
||||||
|
void rBool(out bool v);
|
||||||
|
}
|
||||||
|
}
|
170
Source/IO/SerializerStream.cs
Normal file
170
Source/IO/SerializerStream.cs
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
|
||||||
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
||||||
|
* This program is released under GNU General Public License
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Namespaces
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
|
using CodeImp.DoomBuilder.Geometry;
|
||||||
|
using CodeImp.DoomBuilder.Rendering;
|
||||||
|
using SlimDX.Direct3D9;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace CodeImp.DoomBuilder.IO
|
||||||
|
{
|
||||||
|
internal sealed class SerializerStream : IReadWriteStream
|
||||||
|
{
|
||||||
|
#region ================== Constants
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Variables
|
||||||
|
|
||||||
|
private Stream stream;
|
||||||
|
private BinaryWriter writer;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Properties
|
||||||
|
|
||||||
|
public bool IsWriting { get { return true; } }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Constructor / Destructor
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
public SerializerStream(Stream stream)
|
||||||
|
{
|
||||||
|
// Initialize
|
||||||
|
this.stream = stream;
|
||||||
|
this.writer = new BinaryWriter(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Methods
|
||||||
|
|
||||||
|
// Bidirectional
|
||||||
|
public void rwInt(ref int v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void rwByte(ref byte v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void rwShort(ref short v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void rwString(ref string v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void rwLong(ref long v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void rwUInt(ref uint v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void rwUShort(ref ushort v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void rwULong(ref ulong v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void rwFloat(ref float v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void rwBool(ref bool v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void rwVector2D(ref Vector2D v)
|
||||||
|
{
|
||||||
|
writer.Write(v.x);
|
||||||
|
writer.Write(v.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rwVector3D(ref Vector3D v)
|
||||||
|
{
|
||||||
|
writer.Write(v.x);
|
||||||
|
writer.Write(v.y);
|
||||||
|
writer.Write(v.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write-only
|
||||||
|
public void wInt(int v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void wByte(byte v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void wShort(short v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void wString(string v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void wLong(long v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void wUInt(uint v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void wUShort(ushort v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void wULong(ulong v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void wFloat(float v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void wBool(bool v) { writer.Write(v); }
|
||||||
|
|
||||||
|
public void wVector2D(Vector2D v)
|
||||||
|
{
|
||||||
|
writer.Write(v.x);
|
||||||
|
writer.Write(v.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void wVector3D(Vector3D v)
|
||||||
|
{
|
||||||
|
writer.Write(v.x);
|
||||||
|
writer.Write(v.y);
|
||||||
|
writer.Write(v.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read-only is not supported
|
||||||
|
public void rInt(out int v) { v = 0; General.Fail("Read-only is not supported on serialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void rByte(out byte v) { v = 0; General.Fail("Read-only is not supported on serialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void rShort(out short v) { v = 0; General.Fail("Read-only is not supported on serialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void rString(out string v) { v = ""; General.Fail("Read-only is not supported on serialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void rLong(out long v) { v = 0; General.Fail("Read-only is not supported on serialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void rUInt(out uint v) { v = 0; General.Fail("Read-only is not supported on serialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void rUShort(out ushort v) { v = 0; General.Fail("Read-only is not supported on serialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void rULong(out ulong v) { v = 0; General.Fail("Read-only is not supported on serialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void rFloat(out float v) { v = 0; General.Fail("Read-only is not supported on serialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void rBool(out bool v) { v = false; General.Fail("Read-only is not supported on serialization stream. Consider passing the element by reference for bidirectional support."); }
|
||||||
|
|
||||||
|
public void rVector2D(out Vector2D v)
|
||||||
|
{
|
||||||
|
v = new Vector2D();
|
||||||
|
General.Fail("Read-only is not supported on serialization stream. Consider passing the element by reference for bidirectional support.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rVector3D(out Vector3D v)
|
||||||
|
{
|
||||||
|
v = new Vector3D();
|
||||||
|
General.Fail("Read-only is not supported on serialization stream. Consider passing the element by reference for bidirectional support.");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,6 +25,7 @@ using CodeImp.DoomBuilder.Geometry;
|
||||||
using CodeImp.DoomBuilder.Rendering;
|
using CodeImp.DoomBuilder.Rendering;
|
||||||
using SlimDX.Direct3D9;
|
using SlimDX.Direct3D9;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using CodeImp.DoomBuilder.IO;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -74,6 +75,9 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
private int tag;
|
private int tag;
|
||||||
private int[] args;
|
private int[] args;
|
||||||
|
|
||||||
|
// Clone
|
||||||
|
private int serializedindex;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Properties
|
#region ================== Properties
|
||||||
|
@ -95,6 +99,7 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
public int AngleDeg { get { return (int)(angle * Angle2D.PIDEG); } }
|
public int AngleDeg { get { return (int)(angle * Angle2D.PIDEG); } }
|
||||||
public RectangleF Rect { get { return rect; } }
|
public RectangleF Rect { get { return rect; } }
|
||||||
public int[] Args { get { return args; } }
|
public int[] Args { get { return args; } }
|
||||||
|
internal int SerializedIndex { get { return serializedindex; } set { serializedindex = value; } }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -120,6 +125,27 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
internal Linedef(MapSet map, LinkedListNode<Linedef> listitem, Vertex start, Vertex end, IReadWriteStream stream)
|
||||||
|
{
|
||||||
|
// Initialize
|
||||||
|
this.map = map;
|
||||||
|
this.mainlistitem = listitem;
|
||||||
|
this.start = start;
|
||||||
|
this.end = end;
|
||||||
|
this.updateneeded = true;
|
||||||
|
this.args = new int[NUM_ARGS];
|
||||||
|
|
||||||
|
// Attach to vertices
|
||||||
|
startvertexlistitem = start.AttachLinedef(this);
|
||||||
|
endvertexlistitem = end.AttachLinedef(this);
|
||||||
|
|
||||||
|
ReadWrite(stream);
|
||||||
|
|
||||||
|
// We have no destructor
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Disposer
|
// Disposer
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
|
@ -159,6 +185,40 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
|
|
||||||
#region ================== Management
|
#region ================== Management
|
||||||
|
|
||||||
|
// Serialize / deserialize
|
||||||
|
internal void ReadWrite(IReadWriteStream s)
|
||||||
|
{
|
||||||
|
base.ReadWrite(s);
|
||||||
|
|
||||||
|
if(s.IsWriting)
|
||||||
|
{
|
||||||
|
s.wInt(flags.Count);
|
||||||
|
|
||||||
|
foreach(KeyValuePair<string, bool> f in flags)
|
||||||
|
{
|
||||||
|
s.wString(f.Key);
|
||||||
|
s.wBool(f.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int c; s.rInt(out c);
|
||||||
|
|
||||||
|
flags = new Dictionary<string, bool>(c);
|
||||||
|
for(int i = 0; i < c; i++)
|
||||||
|
{
|
||||||
|
string t; s.rString(out t);
|
||||||
|
bool b; s.rBool(out b);
|
||||||
|
flags.Add(t, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
s.rwInt(ref action);
|
||||||
|
s.rwInt(ref activate);
|
||||||
|
s.rwInt(ref tag);
|
||||||
|
for(int i = 0; i < NUM_ARGS; i++) s.rwInt(ref args[i]);
|
||||||
|
}
|
||||||
|
|
||||||
// This sets new start vertex
|
// This sets new start vertex
|
||||||
public void SetStartVertex(Vertex v)
|
public void SetStartVertex(Vertex v)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,7 @@ using CodeImp.DoomBuilder.Geometry;
|
||||||
using CodeImp.DoomBuilder.Rendering;
|
using CodeImp.DoomBuilder.Rendering;
|
||||||
using SlimDX.Direct3D9;
|
using SlimDX.Direct3D9;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using CodeImp.DoomBuilder.IO;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -83,6 +84,32 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
|
|
||||||
#region ================== Methods
|
#region ================== Methods
|
||||||
|
|
||||||
|
// Serialize / deserialize
|
||||||
|
internal void ReadWrite(IReadWriteStream s)
|
||||||
|
{
|
||||||
|
int c = fields.Count;
|
||||||
|
s.rwInt(ref c);
|
||||||
|
|
||||||
|
if(s.IsWriting)
|
||||||
|
{
|
||||||
|
foreach(KeyValuePair<string, UniValue> f in fields)
|
||||||
|
{
|
||||||
|
s.wString(f.Key);
|
||||||
|
f.Value.ReadWrite(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fields = new UniFields(c);
|
||||||
|
for(int i = 0; i < c; i++)
|
||||||
|
{
|
||||||
|
string t; s.rString(out t);
|
||||||
|
UniValue v = new UniValue(); v.ReadWrite(s);
|
||||||
|
fields.Add(t, v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This copies properties to any other element
|
// This copies properties to any other element
|
||||||
public void CopyPropertiesTo(MapElement element)
|
public void CopyPropertiesTo(MapElement element)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,6 +29,7 @@ using System.Drawing;
|
||||||
using CodeImp.DoomBuilder.Editing;
|
using CodeImp.DoomBuilder.Editing;
|
||||||
using CodeImp.DoomBuilder.IO;
|
using CodeImp.DoomBuilder.IO;
|
||||||
using CodeImp.DoomBuilder.Types;
|
using CodeImp.DoomBuilder.Types;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -107,6 +108,25 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Constructor for map to deserialize
|
||||||
|
internal MapSet(MemoryStream stream)
|
||||||
|
{
|
||||||
|
// Initialize
|
||||||
|
vertices = new LinkedList<Vertex>();
|
||||||
|
linedefs = new LinkedList<Linedef>();
|
||||||
|
sidedefs = new LinkedList<Sidedef>();
|
||||||
|
sectors = new LinkedList<Sector>();
|
||||||
|
things = new LinkedList<Thing>();
|
||||||
|
indexholes = new List<int>();
|
||||||
|
lastsectorindex = 0;
|
||||||
|
|
||||||
|
// Deserialize
|
||||||
|
Deserialize(stream);
|
||||||
|
|
||||||
|
// We have no destructor
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Disposer
|
// Disposer
|
||||||
internal void Dispose()
|
internal void Dispose()
|
||||||
{
|
{
|
||||||
|
@ -357,6 +377,26 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This creates a new vertex
|
||||||
|
private Vertex CreateVertex(IReadWriteStream stream)
|
||||||
|
{
|
||||||
|
LinkedListNode<Vertex> listitem;
|
||||||
|
Vertex v;
|
||||||
|
|
||||||
|
// Make a list item
|
||||||
|
listitem = new LinkedListNode<Vertex>(null);
|
||||||
|
|
||||||
|
// Make the vertex
|
||||||
|
v = new Vertex(this, listitem, stream);
|
||||||
|
listitem.Value = v;
|
||||||
|
|
||||||
|
// Add vertex to the list
|
||||||
|
vertices.AddLast(listitem);
|
||||||
|
|
||||||
|
// Return result
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
// This creates a new linedef
|
// This creates a new linedef
|
||||||
public Linedef CreateLinedef(Vertex start, Vertex end)
|
public Linedef CreateLinedef(Vertex start, Vertex end)
|
||||||
{
|
{
|
||||||
|
@ -377,6 +417,26 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This creates a new linedef
|
||||||
|
private Linedef CreateLinedef(Vertex start, Vertex end, IReadWriteStream stream)
|
||||||
|
{
|
||||||
|
LinkedListNode<Linedef> listitem;
|
||||||
|
Linedef l;
|
||||||
|
|
||||||
|
// Make a list item
|
||||||
|
listitem = new LinkedListNode<Linedef>(null);
|
||||||
|
|
||||||
|
// Make the linedef
|
||||||
|
l = new Linedef(this, listitem, start, end, stream);
|
||||||
|
listitem.Value = l;
|
||||||
|
|
||||||
|
// Add linedef to the list
|
||||||
|
linedefs.AddLast(listitem);
|
||||||
|
|
||||||
|
// Return result
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
// This creates a new sidedef
|
// This creates a new sidedef
|
||||||
public Sidedef CreateSidedef(Linedef l, bool front, Sector s)
|
public Sidedef CreateSidedef(Linedef l, bool front, Sector s)
|
||||||
{
|
{
|
||||||
|
@ -397,6 +457,26 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
return sd;
|
return sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This creates a new sidedef
|
||||||
|
private Sidedef CreateSidedef(Linedef l, bool front, Sector s, IReadWriteStream stream)
|
||||||
|
{
|
||||||
|
LinkedListNode<Sidedef> listitem;
|
||||||
|
Sidedef sd;
|
||||||
|
|
||||||
|
// Make a list item
|
||||||
|
listitem = new LinkedListNode<Sidedef>(null);
|
||||||
|
|
||||||
|
// Make the sidedef
|
||||||
|
sd = new Sidedef(this, listitem, l, front, s, stream);
|
||||||
|
listitem.Value = sd;
|
||||||
|
|
||||||
|
// Add sidedef to the list
|
||||||
|
sidedefs.AddLast(listitem);
|
||||||
|
|
||||||
|
// Return result
|
||||||
|
return sd;
|
||||||
|
}
|
||||||
|
|
||||||
// This creates a new sector
|
// This creates a new sector
|
||||||
public Sector CreateSector()
|
public Sector CreateSector()
|
||||||
{
|
{
|
||||||
|
@ -439,6 +519,26 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This creates a new sector
|
||||||
|
private Sector CreateSector(IReadWriteStream stream)
|
||||||
|
{
|
||||||
|
LinkedListNode<Sector> listitem;
|
||||||
|
Sector s;
|
||||||
|
|
||||||
|
// Make a list item
|
||||||
|
listitem = new LinkedListNode<Sector>(null);
|
||||||
|
|
||||||
|
// Make the sector
|
||||||
|
s = new Sector(this, listitem, stream);
|
||||||
|
listitem.Value = s;
|
||||||
|
|
||||||
|
// Add sector to the list
|
||||||
|
sectors.AddLast(listitem);
|
||||||
|
|
||||||
|
// Return result
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
// This creates a new thing
|
// This creates a new thing
|
||||||
public Thing CreateThing()
|
public Thing CreateThing()
|
||||||
{
|
{
|
||||||
|
@ -467,6 +567,227 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Serialization
|
||||||
|
|
||||||
|
// This serializes the MapSet
|
||||||
|
internal MemoryStream Serialize()
|
||||||
|
{
|
||||||
|
MemoryStream stream = new MemoryStream(1000000);
|
||||||
|
SerializerStream serializer = new SerializerStream(stream);
|
||||||
|
|
||||||
|
// Write private data
|
||||||
|
serializer.wInt(lastsectorindex);
|
||||||
|
serializer.wInt(indexholes.Count);
|
||||||
|
foreach(int i in indexholes) serializer.wInt(i);
|
||||||
|
|
||||||
|
// Write map data
|
||||||
|
WriteVertices(serializer);
|
||||||
|
WriteSectors(serializer);
|
||||||
|
WriteLinedefs(serializer);
|
||||||
|
WriteSidedefs(serializer);
|
||||||
|
WriteThings(serializer);
|
||||||
|
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This serializes things
|
||||||
|
private void WriteThings(SerializerStream stream)
|
||||||
|
{
|
||||||
|
stream.wInt(things.Count);
|
||||||
|
|
||||||
|
// Go for all things
|
||||||
|
foreach(Thing t in things)
|
||||||
|
{
|
||||||
|
t.ReadWrite(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This serializes vertices
|
||||||
|
private void WriteVertices(SerializerStream stream)
|
||||||
|
{
|
||||||
|
stream.wInt(vertices.Count);
|
||||||
|
|
||||||
|
// Go for all vertices
|
||||||
|
int index = 0;
|
||||||
|
foreach(Vertex v in vertices)
|
||||||
|
{
|
||||||
|
v.SerializedIndex = index++;
|
||||||
|
|
||||||
|
v.ReadWrite(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This serializes linedefs
|
||||||
|
private void WriteLinedefs(SerializerStream stream)
|
||||||
|
{
|
||||||
|
stream.wInt(linedefs.Count);
|
||||||
|
|
||||||
|
// Go for all lines
|
||||||
|
int index = 0;
|
||||||
|
foreach(Linedef l in linedefs)
|
||||||
|
{
|
||||||
|
l.SerializedIndex = index++;
|
||||||
|
|
||||||
|
stream.wInt(l.Start.SerializedIndex);
|
||||||
|
|
||||||
|
stream.wInt(l.End.SerializedIndex);
|
||||||
|
|
||||||
|
l.ReadWrite(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This serializes sidedefs
|
||||||
|
private void WriteSidedefs(SerializerStream stream)
|
||||||
|
{
|
||||||
|
stream.wInt(sidedefs.Count);
|
||||||
|
|
||||||
|
// Go for all sidedefs
|
||||||
|
foreach(Sidedef sd in sidedefs)
|
||||||
|
{
|
||||||
|
stream.wInt(sd.Line.SerializedIndex);
|
||||||
|
|
||||||
|
stream.wInt(sd.Sector.SerializedIndex);
|
||||||
|
|
||||||
|
stream.wBool(sd.IsFront);
|
||||||
|
|
||||||
|
sd.ReadWrite(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This serializes sectors
|
||||||
|
private void WriteSectors(SerializerStream stream)
|
||||||
|
{
|
||||||
|
stream.wInt(sectors.Count);
|
||||||
|
|
||||||
|
// Go for all sectors
|
||||||
|
int index = 0;
|
||||||
|
foreach(Sector s in sectors)
|
||||||
|
{
|
||||||
|
s.SerializedIndex = index++;
|
||||||
|
|
||||||
|
s.ReadWrite(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Deserialization
|
||||||
|
|
||||||
|
// This serializes the MapSet
|
||||||
|
private void Deserialize(MemoryStream stream)
|
||||||
|
{
|
||||||
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
|
DeserializerStream deserializer = new DeserializerStream(stream);
|
||||||
|
|
||||||
|
// Read private data
|
||||||
|
int c;
|
||||||
|
deserializer.rInt(out lastsectorindex);
|
||||||
|
deserializer.rInt(out c);
|
||||||
|
indexholes = new List<int>(c);
|
||||||
|
for(int i = 0; i < c; i++)
|
||||||
|
{
|
||||||
|
int index; deserializer.rInt(out index);
|
||||||
|
indexholes.Add(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read map data
|
||||||
|
Vertex[] verticesarray = ReadVertices(deserializer);
|
||||||
|
Sector[] sectorsarray = ReadSectors(deserializer);
|
||||||
|
Linedef[] linedefsarray = ReadLinedefs(deserializer, verticesarray);
|
||||||
|
ReadSidedefs(deserializer, linedefsarray, sectorsarray);
|
||||||
|
ReadThings(deserializer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This deserializes things
|
||||||
|
private void ReadThings(DeserializerStream stream)
|
||||||
|
{
|
||||||
|
int c; stream.rInt(out c);
|
||||||
|
|
||||||
|
// Go for all things
|
||||||
|
for(int i = 0; i < c; i++)
|
||||||
|
{
|
||||||
|
Thing t = CreateThing();
|
||||||
|
t.ReadWrite(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This deserializes vertices
|
||||||
|
private Vertex[] ReadVertices(DeserializerStream stream)
|
||||||
|
{
|
||||||
|
int c; stream.rInt(out c);
|
||||||
|
|
||||||
|
Vertex[] array = new Vertex[c];
|
||||||
|
|
||||||
|
// Go for all vertices
|
||||||
|
for(int i = 0; i < c; i++)
|
||||||
|
{
|
||||||
|
array[i] = CreateVertex(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This deserializes linedefs
|
||||||
|
private Linedef[] ReadLinedefs(DeserializerStream stream, Vertex[] verticesarray)
|
||||||
|
{
|
||||||
|
int c; stream.rInt(out c);
|
||||||
|
|
||||||
|
Linedef[] array = new Linedef[c];
|
||||||
|
|
||||||
|
// Go for all lines
|
||||||
|
for(int i = 0; i < c; i++)
|
||||||
|
{
|
||||||
|
int start, end;
|
||||||
|
|
||||||
|
stream.rInt(out start);
|
||||||
|
|
||||||
|
stream.rInt(out end);
|
||||||
|
|
||||||
|
array[i] = CreateLinedef(verticesarray[start], verticesarray[end], stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This deserializes sidedefs
|
||||||
|
private void ReadSidedefs(DeserializerStream stream, Linedef[] linedefsarray, Sector[] sectorsarray)
|
||||||
|
{
|
||||||
|
int c; stream.rInt(out c);
|
||||||
|
|
||||||
|
// Go for all sidedefs
|
||||||
|
for(int i = 0; i < c; i++)
|
||||||
|
{
|
||||||
|
int lineindex, sectorindex;
|
||||||
|
bool front;
|
||||||
|
|
||||||
|
stream.rInt(out lineindex);
|
||||||
|
|
||||||
|
stream.rInt(out sectorindex);
|
||||||
|
|
||||||
|
stream.rBool(out front);
|
||||||
|
|
||||||
|
CreateSidedef(linedefsarray[lineindex], front, sectorsarray[sectorindex], stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This deserializes sectors
|
||||||
|
private Sector[] ReadSectors(DeserializerStream stream)
|
||||||
|
{
|
||||||
|
int c; stream.rInt(out c);
|
||||||
|
|
||||||
|
Sector[] array = new Sector[c];
|
||||||
|
|
||||||
|
// Go for all sectors
|
||||||
|
for(int i = 0; i < c; i++)
|
||||||
|
{
|
||||||
|
array[i] = CreateSector(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region ================== Updating
|
#region ================== Updating
|
||||||
|
|
||||||
// This updates all structures if needed
|
// This updates all structures if needed
|
||||||
|
|
|
@ -67,6 +67,7 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
|
|
||||||
// Cloning
|
// Cloning
|
||||||
private Sector clone;
|
private Sector clone;
|
||||||
|
private int serializedindex;
|
||||||
|
|
||||||
// Triangulation
|
// Triangulation
|
||||||
private bool updateneeded;
|
private bool updateneeded;
|
||||||
|
@ -97,7 +98,8 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
public int Brightness { get { return brightness; } set { brightness = value; updateneeded = true; } }
|
public int Brightness { get { return brightness; } set { brightness = value; updateneeded = true; } }
|
||||||
public bool UpdateNeeded { get { return updateneeded; } set { updateneeded |= value; triangulationneeded |= value; } }
|
public bool UpdateNeeded { get { return updateneeded; } set { updateneeded |= value; triangulationneeded |= value; } }
|
||||||
public RectangleF BBox { get { return bbox; } }
|
public RectangleF BBox { get { return bbox; } }
|
||||||
public Sector Clone { get { return clone; } set { clone = value; } }
|
internal Sector Clone { get { return clone; } set { clone = value; } }
|
||||||
|
internal int SerializedIndex { get { return serializedindex; } set { serializedindex = value; } }
|
||||||
public Triangulation Triangles { get { return triangles; } }
|
public Triangulation Triangles { get { return triangles; } }
|
||||||
public FlatVertex[] FlatVertices { get { return flatvertices; } }
|
public FlatVertex[] FlatVertices { get { return flatvertices; } }
|
||||||
internal VertexBuffer FlatCeilingBuffer { get { return flatceilingbuffer; } }
|
internal VertexBuffer FlatCeilingBuffer { get { return flatceilingbuffer; } }
|
||||||
|
@ -129,6 +131,24 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
internal Sector(MapSet map, LinkedListNode<Sector> listitem, IReadWriteStream stream)
|
||||||
|
{
|
||||||
|
// Initialize
|
||||||
|
this.map = map;
|
||||||
|
this.mainlistitem = listitem;
|
||||||
|
this.sidedefs = new LinkedList<Sidedef>();
|
||||||
|
this.things = new LinkedList<Thing>();
|
||||||
|
this.triangulationneeded = true;
|
||||||
|
|
||||||
|
ReadWrite(stream);
|
||||||
|
|
||||||
|
General.Map.Graphics.RegisterResource(this);
|
||||||
|
|
||||||
|
// We have no destructor
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Disposer
|
// Disposer
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
|
@ -169,6 +189,23 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
|
|
||||||
#region ================== Management
|
#region ================== Management
|
||||||
|
|
||||||
|
// Serialize / deserialize
|
||||||
|
internal void ReadWrite(IReadWriteStream s)
|
||||||
|
{
|
||||||
|
base.ReadWrite(s);
|
||||||
|
|
||||||
|
s.rwInt(ref index);
|
||||||
|
s.rwInt(ref floorheight);
|
||||||
|
s.rwInt(ref ceilheight);
|
||||||
|
s.rwString(ref floortexname);
|
||||||
|
s.rwString(ref ceiltexname);
|
||||||
|
s.rwLong(ref longfloortexname);
|
||||||
|
s.rwLong(ref longceiltexname);
|
||||||
|
s.rwInt(ref effect);
|
||||||
|
s.rwInt(ref tag);
|
||||||
|
s.rwInt(ref brightness);
|
||||||
|
}
|
||||||
|
|
||||||
// This copies all properties to another sector
|
// This copies all properties to another sector
|
||||||
public void CopyPropertiesTo(Sector s)
|
public void CopyPropertiesTo(Sector s)
|
||||||
{
|
{
|
||||||
|
|
|
@ -107,6 +107,27 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
internal Sidedef(MapSet map, LinkedListNode<Sidedef> listitem, Linedef l, bool front, Sector s, IReadWriteStream stream)
|
||||||
|
{
|
||||||
|
// Initialize
|
||||||
|
this.map = map;
|
||||||
|
this.mainlistitem = listitem;
|
||||||
|
this.linedef = l;
|
||||||
|
this.sector = s;
|
||||||
|
|
||||||
|
// Attach to the linedef
|
||||||
|
if(front) l.AttachFront(this); else l.AttachBack(this);
|
||||||
|
|
||||||
|
// Attach to sector
|
||||||
|
sectorlistitem = s.AttachSidedef(this);
|
||||||
|
|
||||||
|
ReadWrite(stream);
|
||||||
|
|
||||||
|
// We have no destructor
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Disposer
|
// Disposer
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
|
@ -141,6 +162,21 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
|
|
||||||
#region ================== Management
|
#region ================== Management
|
||||||
|
|
||||||
|
// Serialize / deserialize
|
||||||
|
internal void ReadWrite(IReadWriteStream s)
|
||||||
|
{
|
||||||
|
base.ReadWrite(s);
|
||||||
|
|
||||||
|
s.rwInt(ref offsetx);
|
||||||
|
s.rwInt(ref offsety);
|
||||||
|
s.rwString(ref texnamehigh);
|
||||||
|
s.rwString(ref texnamemid);
|
||||||
|
s.rwString(ref texnamelow);
|
||||||
|
s.rwLong(ref longtexnamehigh);
|
||||||
|
s.rwLong(ref longtexnamemid);
|
||||||
|
s.rwLong(ref longtexnamelow);
|
||||||
|
}
|
||||||
|
|
||||||
// This copies all properties to another sidedef
|
// This copies all properties to another sidedef
|
||||||
public void CopyPropertiesTo(Sidedef s)
|
public void CopyPropertiesTo(Sidedef s)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,7 @@ using CodeImp.DoomBuilder.Geometry;
|
||||||
using CodeImp.DoomBuilder.Rendering;
|
using CodeImp.DoomBuilder.Rendering;
|
||||||
using CodeImp.DoomBuilder.Config;
|
using CodeImp.DoomBuilder.Config;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using CodeImp.DoomBuilder.IO;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -59,7 +60,6 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
private int tag;
|
private int tag;
|
||||||
private int action;
|
private int action;
|
||||||
private int[] args;
|
private int[] args;
|
||||||
private int x, y, zoffset;
|
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
private float size;
|
private float size;
|
||||||
|
@ -133,6 +133,42 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
|
|
||||||
#region ================== Management
|
#region ================== Management
|
||||||
|
|
||||||
|
// Serialize / deserialize
|
||||||
|
internal void ReadWrite(IReadWriteStream s)
|
||||||
|
{
|
||||||
|
base.ReadWrite(s);
|
||||||
|
|
||||||
|
if(s.IsWriting)
|
||||||
|
{
|
||||||
|
s.wInt(flags.Count);
|
||||||
|
|
||||||
|
foreach(KeyValuePair<string, bool> f in flags)
|
||||||
|
{
|
||||||
|
s.wString(f.Key);
|
||||||
|
s.wBool(f.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int c; s.rInt(out c);
|
||||||
|
|
||||||
|
flags = new Dictionary<string, bool>(c);
|
||||||
|
for(int i = 0; i < c; i++)
|
||||||
|
{
|
||||||
|
string t; s.rString(out t);
|
||||||
|
bool b; s.rBool(out b);
|
||||||
|
flags.Add(t, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
s.rwInt(ref type);
|
||||||
|
s.rwVector3D(ref pos);
|
||||||
|
s.rwFloat(ref angle);
|
||||||
|
s.rwInt(ref tag);
|
||||||
|
s.rwInt(ref action);
|
||||||
|
for(int i = 0; i < NUM_ARGS; i++) s.rwInt(ref args[i]);
|
||||||
|
}
|
||||||
|
|
||||||
// This copies all properties to another thing
|
// This copies all properties to another thing
|
||||||
public void CopyPropertiesTo(Thing t)
|
public void CopyPropertiesTo(Thing t)
|
||||||
{
|
{
|
||||||
|
@ -210,7 +246,7 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
public void Move(Vector2D newpos)
|
public void Move(Vector2D newpos)
|
||||||
{
|
{
|
||||||
// Change position
|
// Change position
|
||||||
this.pos = new Vector3D(newpos.x, newpos.y, zoffset);
|
this.pos = new Vector3D(newpos.x, newpos.y, pos.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This moves the thing
|
// This moves the thing
|
||||||
|
|
|
@ -17,6 +17,11 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New constructor
|
||||||
|
public UniFields(int capacity) : base(capacity)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// Copy constructor
|
// Copy constructor
|
||||||
public UniFields(UniFields copyfrom) : base(copyfrom)
|
public UniFields(UniFields copyfrom) : base(copyfrom)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,6 +26,7 @@ using CodeImp.DoomBuilder.Rendering;
|
||||||
using SlimDX.Direct3D9;
|
using SlimDX.Direct3D9;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using CodeImp.DoomBuilder.Types;
|
using CodeImp.DoomBuilder.Types;
|
||||||
|
using CodeImp.DoomBuilder.IO;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -102,6 +103,63 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
|
|
||||||
#region ================== Methods
|
#region ================== Methods
|
||||||
|
|
||||||
|
// Serialize / deserialize
|
||||||
|
internal void ReadWrite(IReadWriteStream s)
|
||||||
|
{
|
||||||
|
s.rwInt(ref type);
|
||||||
|
switch((UniversalType)type)
|
||||||
|
{
|
||||||
|
case UniversalType.AngleDegrees:
|
||||||
|
case UniversalType.Float:
|
||||||
|
{
|
||||||
|
float v = (float)value;
|
||||||
|
s.rwFloat(ref v);
|
||||||
|
value = v;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case UniversalType.AngleRadians:
|
||||||
|
case UniversalType.Color:
|
||||||
|
case UniversalType.EnumBits:
|
||||||
|
case UniversalType.EnumOption:
|
||||||
|
case UniversalType.EnumStrings:
|
||||||
|
case UniversalType.Integer:
|
||||||
|
case UniversalType.LinedefTag:
|
||||||
|
case UniversalType.LinedefType:
|
||||||
|
case UniversalType.SectorEffect:
|
||||||
|
case UniversalType.SectorTag:
|
||||||
|
case UniversalType.ThingTag:
|
||||||
|
{
|
||||||
|
int v = (int)value;
|
||||||
|
s.rwInt(ref v);
|
||||||
|
value = v;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case UniversalType.Boolean:
|
||||||
|
{
|
||||||
|
bool v = (bool)value;
|
||||||
|
s.rwBool(ref v);
|
||||||
|
value = v;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case UniversalType.Flat:
|
||||||
|
case UniversalType.String:
|
||||||
|
case UniversalType.Texture:
|
||||||
|
{
|
||||||
|
string v = (string)value;
|
||||||
|
s.rwString(ref v);
|
||||||
|
value = v;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
General.Fail("Unknown field type to read/write!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This validates a UDMF field name and returns the valid part
|
// This validates a UDMF field name and returns the valid part
|
||||||
public static string ValidateName(string name)
|
public static string ValidateName(string name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,7 @@ using CodeImp.DoomBuilder.Geometry;
|
||||||
using CodeImp.DoomBuilder.Rendering;
|
using CodeImp.DoomBuilder.Rendering;
|
||||||
using SlimDX.Direct3D9;
|
using SlimDX.Direct3D9;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using CodeImp.DoomBuilder.IO;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
|
|
||||||
// Cloning
|
// Cloning
|
||||||
private Vertex clone;
|
private Vertex clone;
|
||||||
|
private int serializedindex;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -63,7 +65,8 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
public MapSet Map { get { return map; } }
|
public MapSet Map { get { return map; } }
|
||||||
public ICollection<Linedef> Linedefs { get { return linedefs; } }
|
public ICollection<Linedef> Linedefs { get { return linedefs; } }
|
||||||
public Vector2D Position { get { return pos; } }
|
public Vector2D Position { get { return pos; } }
|
||||||
public Vertex Clone { get { return clone; } set { clone = value; } }
|
internal Vertex Clone { get { return clone; } set { clone = value; } }
|
||||||
|
internal int SerializedIndex { get { return serializedindex; } set { serializedindex = value; } }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -82,6 +85,20 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
internal Vertex(MapSet map, LinkedListNode<Vertex> listitem, IReadWriteStream stream)
|
||||||
|
{
|
||||||
|
// Initialize
|
||||||
|
this.map = map;
|
||||||
|
this.linedefs = new LinkedList<Linedef>();
|
||||||
|
this.mainlistitem = listitem;
|
||||||
|
|
||||||
|
ReadWrite(stream);
|
||||||
|
|
||||||
|
// We have no destructor
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Disposer
|
// Disposer
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
|
@ -133,6 +150,14 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Serialize / deserialize
|
||||||
|
internal void ReadWrite(IReadWriteStream s)
|
||||||
|
{
|
||||||
|
base.ReadWrite(s);
|
||||||
|
|
||||||
|
s.rwVector2D(ref pos);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Methods
|
#region ================== Methods
|
||||||
|
@ -170,7 +195,7 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
if(float.IsNaN(pos.x) || float.IsNaN(pos.y) ||
|
if(float.IsNaN(pos.x) || float.IsNaN(pos.y) ||
|
||||||
float.IsInfinity(pos.x) || float.IsInfinity(pos.y))
|
float.IsInfinity(pos.x) || float.IsInfinity(pos.y))
|
||||||
{
|
{
|
||||||
General.Fail("Invalid vertex position!", "The given vertex coordinates cannot be NaN or Infinite.");
|
General.Fail("Invalid vertex position! The given vertex coordinates cannot be NaN or Infinite.");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -57,5 +57,6 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
void AddGeometry(VisualGeometry g);
|
void AddGeometry(VisualGeometry g);
|
||||||
void RenderCrosshair();
|
void RenderCrosshair();
|
||||||
void SetFogMode(bool usefog);
|
void SetFogMode(bool usefog);
|
||||||
|
void SetCrosshairBusy(bool busy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
|
|
||||||
// Crosshair
|
// Crosshair
|
||||||
private FlatVertex[] crosshairverts;
|
private FlatVertex[] crosshairverts;
|
||||||
|
private bool crosshairbusy;
|
||||||
|
|
||||||
// Geometry to be rendered.
|
// Geometry to be rendered.
|
||||||
// Each Dictionary in the array is a render pass.
|
// Each Dictionary in the array is a render pass.
|
||||||
|
@ -445,11 +446,22 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
graphics.Device.SetTransform(TransformState.Projection, Matrix.Identity);
|
graphics.Device.SetTransform(TransformState.Projection, Matrix.Identity);
|
||||||
ApplyMatrices2D();
|
ApplyMatrices2D();
|
||||||
|
|
||||||
|
// Texture
|
||||||
|
if(crosshairbusy)
|
||||||
|
{
|
||||||
|
if(General.Map.Data.CrosshairBusy3D.Texture == null) General.Map.Data.CrosshairBusy3D.CreateTexture();
|
||||||
|
graphics.Device.SetTexture(0, General.Map.Data.CrosshairBusy3D.Texture);
|
||||||
|
graphics.Shaders.Display2D.Texture1 = General.Map.Data.CrosshairBusy3D.Texture;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(General.Map.Data.Crosshair3D.Texture == null) General.Map.Data.Crosshair3D.CreateTexture();
|
||||||
|
graphics.Device.SetTexture(0, General.Map.Data.Crosshair3D.Texture);
|
||||||
|
graphics.Shaders.Display2D.Texture1 = General.Map.Data.Crosshair3D.Texture;
|
||||||
|
}
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
graphics.Shaders.Display2D.Begin();
|
graphics.Shaders.Display2D.Begin();
|
||||||
if(General.Map.Data.Crosshair3D.Texture == null) General.Map.Data.Crosshair3D.CreateTexture();
|
|
||||||
graphics.Device.SetTexture(0, General.Map.Data.Crosshair3D.Texture);
|
|
||||||
graphics.Shaders.Display2D.Texture1 = General.Map.Data.Crosshair3D.Texture;
|
|
||||||
graphics.Shaders.Display2D.SetSettings(1.0f, 1.0f, 0.0f, 1.0f, true);
|
graphics.Shaders.Display2D.SetSettings(1.0f, 1.0f, 0.0f, 1.0f, true);
|
||||||
graphics.Shaders.Display2D.BeginPass(1);
|
graphics.Shaders.Display2D.BeginPass(1);
|
||||||
graphics.Device.DrawUserPrimitives<FlatVertex>(PrimitiveType.TriangleStrip, 0, 2, crosshairverts);
|
graphics.Device.DrawUserPrimitives<FlatVertex>(PrimitiveType.TriangleStrip, 0, 2, crosshairverts);
|
||||||
|
@ -463,6 +475,12 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
graphics.Device.SetRenderState(RenderState.FogEnable, usefog);
|
graphics.Device.SetRenderState(RenderState.FogEnable, usefog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This siwtches crosshair busy icon on and off
|
||||||
|
public void SetCrosshairBusy(bool busy)
|
||||||
|
{
|
||||||
|
crosshairbusy = busy;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
BIN
Source/Resources/CrosshairBusy.png
Normal file
BIN
Source/Resources/CrosshairBusy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
|
@ -186,10 +186,23 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
|
|
||||||
#region ================== Events
|
#region ================== Events
|
||||||
|
|
||||||
|
public override bool OnUndoBegin()
|
||||||
|
{
|
||||||
|
renderer.SetCrosshairBusy(true);
|
||||||
|
General.Interface.RedrawDisplay();
|
||||||
|
|
||||||
|
return base.OnUndoBegin();
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnUndoEnd()
|
public override void OnUndoEnd()
|
||||||
{
|
{
|
||||||
base.OnUndoEnd();
|
base.OnUndoEnd();
|
||||||
|
|
||||||
|
allsectors.Clear();
|
||||||
|
visiblesectors.Clear();
|
||||||
|
visibleblocks.Clear();
|
||||||
|
visiblegeometry.Clear();
|
||||||
|
|
||||||
// Make new blockmap
|
// Make new blockmap
|
||||||
if(blockmap != null)
|
if(blockmap != null)
|
||||||
{
|
{
|
||||||
|
@ -197,6 +210,42 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
blockmap = new VisualBlockMap();
|
blockmap = new VisualBlockMap();
|
||||||
FillBlockMap();
|
FillBlockMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Visibility culling
|
||||||
|
DoCulling();
|
||||||
|
|
||||||
|
renderer.SetCrosshairBusy(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool OnRedoBegin()
|
||||||
|
{
|
||||||
|
renderer.SetCrosshairBusy(true);
|
||||||
|
General.Interface.RedrawDisplay();
|
||||||
|
|
||||||
|
return base.OnRedoBegin();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnRedoEnd()
|
||||||
|
{
|
||||||
|
base.OnRedoEnd();
|
||||||
|
|
||||||
|
allsectors.Clear();
|
||||||
|
visiblesectors.Clear();
|
||||||
|
visibleblocks.Clear();
|
||||||
|
visiblegeometry.Clear();
|
||||||
|
|
||||||
|
// Make new blockmap
|
||||||
|
if(blockmap != null)
|
||||||
|
{
|
||||||
|
blockmap.Dispose();
|
||||||
|
blockmap = new VisualBlockMap();
|
||||||
|
FillBlockMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Visibility culling
|
||||||
|
DoCulling();
|
||||||
|
|
||||||
|
renderer.SetCrosshairBusy(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in a new issue