This commit is contained in:
codeimp 2007-10-05 11:17:58 +00:00
parent d59f65d5dc
commit 1d46b7d654
12 changed files with 178 additions and 35 deletions

View file

@ -71,6 +71,7 @@ namespace CodeImp.DoomBuilder.Data
if(!isdisposed)
{
// Clean up
Unload();
// Done
isdisposed = true;
@ -81,6 +82,31 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Loading / Unloading
// This loads all data resources
public void Load(DataLocationList configlist, DataLocationList maplist, DataLocation maplocation)
{
DataLocationList all;
// Create complete list
all = DataLocationList.Combined(configlist, maplist);
all.Add(maplocation);
// Load resources
Load(all);
}
// This loads all data resources
public void Load(DataLocationList configlist, DataLocationList maplist)
{
DataLocationList all;
// Create complete list
all = DataLocationList.Combined(configlist, maplist);
// Load resources
Load(all);
}
// This loads all data resources
public void Load(DataLocationList locations)
{
@ -125,6 +151,44 @@ namespace CodeImp.DoomBuilder.Data
containers.Clear();
}
// This suspends a data resource location
public void SuspendLocation(string location)
{
// Go for all containers
foreach(IDataReader d in containers)
{
// Check if this is the location to suspend
if(string.Compare(d.Location, location, true) == 0)
{
// Suspend
General.WriteLogLine("Suspended data resource '" + location + "'");
d.Suspend();
return;
}
}
General.WriteLogLine("WARNING: Cannot suspended data resource '" + location + "', no such location opened!");
}
// This resume a data resource location
public void ResumeLocation(string location)
{
// Go for all containers
foreach(IDataReader d in containers)
{
// Check if this is the location to resume
if(string.Compare(d.Location, location, true) == 0)
{
// Resume
General.WriteLogLine("Resumed data resource '" + location + "'");
d.Resume();
return;
}
}
General.WriteLogLine("WARNING: Cannot resume data resource '" + location + "', no such location opened!");
}
#endregion
}
}

View file

@ -43,15 +43,16 @@ namespace CodeImp.DoomBuilder.Data
private bool readtextures;
private bool readflats;
// Disposing
private bool issuspended = false;
private bool isdisposed = false;
#endregion
#region ================== Properties
// Disposing
public string Location { get { return path; } }
public bool IsDisposed { get { return isdisposed; } }
public bool IsSuspended { get { return issuspended; } }
#endregion
@ -65,6 +66,8 @@ namespace CodeImp.DoomBuilder.Data
this.readtextures = dl.textures;
this.readflats = dl.flats;
General.WriteLogLine("Opening directory resource '" + dl.location + "'");
// We have no destructor
GC.SuppressFinalize(this);
}
@ -75,6 +78,8 @@ namespace CodeImp.DoomBuilder.Data
// Not already disposed?
if(!isdisposed)
{
General.WriteLogLine("Closing directory resource '" + path + "'");
// Clean up
// Done
@ -84,6 +89,22 @@ namespace CodeImp.DoomBuilder.Data
#endregion
#region ================== Management
// This suspends use of this resource
public void Suspend()
{
issuspended = true;
}
// This resumes use of this resource
public void Resume()
{
issuspended = false;
}
#endregion
#region ================== Textures
#endregion

View file

@ -15,7 +15,7 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Variables
private IDataReader source;
private int lumpindex;
private string lumpname;
#endregion
@ -26,11 +26,11 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Constructor / Disposer
// Constructor
public FlatImage(string name, IDataReader source, int lumpindex)
public FlatImage(string name, IDataReader source, string lumpname)
{
// Initialize
this.source = source;
this.lumpindex = lumpindex;
this.lumpname = lumpname;
SetName(name);
// We have no destructor

View file

@ -34,9 +34,13 @@ namespace CodeImp.DoomBuilder.Data
internal unsafe interface IDataReader : IDisposable
{
// Properties
string Location { get; }
bool IsDisposed { get; }
bool IsSuspended { get; }
// Methods
void Dispose();
void Suspend();
void Resume();
}
}

View file

@ -15,7 +15,7 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Variables
private IDataReader source;
private int lumpindex;
private string lumpname;
#endregion
@ -26,11 +26,11 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Constructor / Disposer
// Constructor
public SpriteImage(string name, IDataReader source, int lumpindex)
public SpriteImage(string name, IDataReader source, string lumpname)
{
// Initialize
this.source = source;
this.lumpindex = lumpindex;
this.lumpname = lumpname;
SetName(name);
// We have no destructor

View file

@ -33,7 +33,7 @@ namespace CodeImp.DoomBuilder.Data
internal struct TexturePatch
{
private IDataReader source;
private int lumpindex;
private string lumpname;
private Point position;
private Size size;
}

View file

@ -40,17 +40,19 @@ namespace CodeImp.DoomBuilder.Data
// Source
private WAD file;
private string location;
private bool managefile;
// Disposing
private bool issuspended = false;
private bool isdisposed = false;
#endregion
#region ================== Properties
// Disposing
public string Location { get { return location; } }
public bool IsDisposed { get { return isdisposed; } }
public bool IsSuspended { get { return issuspended; } }
#endregion
@ -60,9 +62,12 @@ namespace CodeImp.DoomBuilder.Data
public WADReader(DataLocation dl)
{
// Initialize
file = new WAD(dl.location, true);
this.location = dl.location;
file = new WAD(location, true);
managefile = true;
General.WriteLogLine("Opening WAD resource '" + file.Filename + "'");
// We have no destructor
GC.SuppressFinalize(this);
}
@ -74,6 +79,8 @@ namespace CodeImp.DoomBuilder.Data
file = wadfile;
managefile = false;
General.WriteLogLine("Opening WAD resource '" + file.Filename + "' (file already open)");
// We have no destructor
GC.SuppressFinalize(this);
}
@ -84,6 +91,8 @@ namespace CodeImp.DoomBuilder.Data
// Not already disposed?
if(!isdisposed)
{
General.WriteLogLine("Closing WAD resource '" + file.Filename + "'");
// Clean up
if(managefile) file.Dispose();
@ -94,7 +103,25 @@ namespace CodeImp.DoomBuilder.Data
#endregion
#region ================== Methods
#region ================== Management
// This suspends use of this resource
public void Suspend()
{
issuspended = true;
if(managefile) file.Dispose();
}
// This resumes use of this resource
public void Resume()
{
issuspended = false;
if(managefile) file = new WAD(location, true);
}
#endregion
#region ================== Textures
#endregion
}

View file

@ -77,8 +77,8 @@ namespace CodeImp.DoomBuilder.Editing
{
if(renderer.StartRendering())
{
renderer.RenderLinedefs(General.Map.Data, General.Map.Data.Linedefs);
renderer.RenderVertices(General.Map.Data, General.Map.Data.Vertices);
renderer.RenderLinedefs(General.Map.Map, General.Map.Map.Linedefs);
renderer.RenderVertices(General.Map.Map, General.Map.Map.Vertices);
renderer.FinishRendering();
}
}

View file

@ -175,7 +175,7 @@ namespace CodeImp.DoomBuilder.Editing
// Zoom now
renderer.PositionView(renderer.OffsetX - diff.x, renderer.OffsetY + diff.y);
renderer.ScaleView(newscale);
General.Map.Data.Update();
General.Map.Map.Update();
General.MainWindow.RedrawDisplay();
// Determine new unprojected mouse coordinates
@ -188,7 +188,7 @@ namespace CodeImp.DoomBuilder.Editing
{
// Zoom now
renderer.ScaleView(newscale);
General.Map.Data.Update();
General.Map.Map.Update();
General.MainWindow.RedrawDisplay();
// Determine new unprojected mouse coordinates
@ -207,7 +207,7 @@ namespace CodeImp.DoomBuilder.Editing
float width, height;
// Go for all vertices
foreach(Vertex v in General.Map.Data.Vertices)
foreach(Vertex v in General.Map.Map.Vertices)
{
// Adjust boundaries by vertices
if(v.Position.x < left) left = v.Position.x;
@ -228,7 +228,7 @@ namespace CodeImp.DoomBuilder.Editing
// Change the view to see the whole map
renderer.ScaleView(scale);
renderer.PositionView(left + (right - left) * 0.5f, top + (bottom - top) * 0.5f);
General.Map.Data.Update();
General.Map.Map.Update();
General.MainWindow.RedrawDisplay();
// Determine new unprojected mouse coordinates

View file

@ -30,6 +30,7 @@ using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Editing;
using System.Diagnostics;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Data;
#endregion
@ -51,10 +52,11 @@ namespace CodeImp.DoomBuilder
// Map information
private string filetitle;
private string filepathname;
private MapSet data;
private MapSet map;
private MapOptions options;
private ConfigurationInfo configinfo;
private Configuration config;
private DataManager data;
private EditMode mode;
private D3DGraphics graphics;
private WAD tempwad;
@ -69,7 +71,7 @@ namespace CodeImp.DoomBuilder
public string FilePathName { get { return filepathname; } }
public string FileTitle { get { return filetitle; } }
public MapOptions Options { get { return options; } }
public MapSet Data { get { return data; } }
public MapSet Map { get { return map; } }
public EditMode Mode { get { return mode; } }
public bool IsChanged { get { return changed; } set { changed = value; } }
public bool IsDisposed { get { return isdisposed; } }
@ -93,12 +95,19 @@ namespace CodeImp.DoomBuilder
if(!isdisposed)
{
// Dispose
tempwad.Dispose();
General.WriteLogLine("Unloading data resources...");
data.Dispose();
General.WriteLogLine("Closing temporary file...");
tempwad.Dispose();
General.WriteLogLine("Unloading map data...");
map.Dispose();
General.WriteLogLine("Stopping edit mode...");
mode.Dispose();
General.WriteLogLine("Stopping graphics device...");
graphics.Dispose();
// Remove temp file
General.WriteLogLine("Removing temporary file...");
try { File.Delete(tempwad.Filename); } catch(Exception) { }
// We may spend some time to clean things up here
@ -137,13 +146,18 @@ namespace CodeImp.DoomBuilder
config = General.LoadGameConfiguration(options.ConfigFile);
// Create map data
data = new MapSet();
map = new MapSet();
// Create temp wadfile
tempfile = General.MakeTempFilename();
General.WriteLogLine("Creating temporary file: " + tempfile);
tempwad = new WAD(tempfile);
// Load data manager
General.WriteLogLine("Loading data resources...");
data = new DataManager();
data.Load(configinfo.Resources, options.Resources);
// Set default mode
ChangeMode(typeof(FrozenOverviewMode));
@ -159,6 +173,7 @@ namespace CodeImp.DoomBuilder
MapSetIO mapio;
string tempfile;
string iointerface;
DataLocation maplocation;
// Apply settings
this.filetitle = Path.GetFileName(filepathname);
@ -179,7 +194,7 @@ namespace CodeImp.DoomBuilder
config = General.LoadGameConfiguration(options.ConfigFile);
// Create map data
data = new MapSet();
map = new MapSet();
// Create temp wadfile
tempfile = General.MakeTempFilename();
@ -203,10 +218,16 @@ namespace CodeImp.DoomBuilder
General.WriteLogLine("Initializing map format interface " + iointerface + "...");
mapio = MapSetIO.Create(iointerface, tempwad);
General.WriteLogLine("Reading map data...");
data = mapio.Read(data, TEMP_MAP_HEADER);
map = mapio.Read(map, TEMP_MAP_HEADER);
// Update structures
data.Update();
map.Update();
// Load data manager
General.WriteLogLine("Loading data resources...");
data = new DataManager();
maplocation = new DataLocation(DataLocation.RESOURCE_WAD, filepathname, false, false);
data.Load(configinfo.Resources, options.Resources, maplocation);
// Set default mode
ChangeMode(typeof(FrozenOverviewMode));
@ -270,9 +291,14 @@ namespace CodeImp.DoomBuilder
if(lump != null)
{
// Copy the lump to the target
General.WriteLogLine(ml.Key.ToString() + " copying");
newlump = target.Insert(ml.Key.ToString(), tgtindex++, lump.Length);
lump.CopyTo(newlump);
}
else
{
General.WriteLogLine("WARNING: " + ml.Key.ToString() + " should be copied but was not found!");
}
}
}
}
@ -307,11 +333,12 @@ namespace CodeImp.DoomBuilder
lumpnodebuild = config.ReadSetting("maplumpnames." + nextlumpname + ".nodebuild", false);
lumpscript = config.ReadSetting("maplumpnames." + nextlumpname + ".script", "");
// Check if this lump will be copied from source
// Check if this lump will be removed from target
if((lumprequired && copyrequired) || (lumpblindcopy && copyblindcopy) ||
(lumpnodebuild && copynodebuild) || ((lumpscript != "") && copyscript))
{
// Then remove it from target
General.WriteLogLine(nextlumpname + " removing");
source.RemoveAt(index);
}
else

View file

@ -172,7 +172,7 @@ namespace CodeImp.DoomBuilder.Rendering
General.MainWindow.UpdateZoom(scale);
// Recalculate linedefs (normal lengths must be adjusted)
foreach(Linedef l in General.Map.Data.Linedefs) l.NeedUpdate();
foreach(Linedef l in General.Map.Map.Linedefs) l.NeedUpdate();
}
// This unprojects mouse coordinates into map coordinates