mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-27 22:31:23 +00:00
Internal: some DataReaders refactoring.
Updated ZDoom_DECORATE.cfg (ALLOWTHRUFLAGS flag).
This commit is contained in:
parent
70586e3538
commit
6e4540b314
12 changed files with 307 additions and 91 deletions
|
@ -868,6 +868,7 @@ constants
|
||||||
STAYMORPHED;
|
STAYMORPHED;
|
||||||
CANBLAST;
|
CANBLAST;
|
||||||
NOBLOCKMONST;
|
NOBLOCKMONST;
|
||||||
|
ALLOWTHRUFLAGS;
|
||||||
THRUGHOST;
|
THRUGHOST;
|
||||||
THRUACTORS;
|
THRUACTORS;
|
||||||
THRUSPECIES;
|
THRUSPECIES;
|
||||||
|
|
|
@ -292,21 +292,20 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
// This loads all data resources
|
// This loads all data resources
|
||||||
internal void Load(DataLocationList configlist, DataLocationList maplist, DataLocation maplocation)
|
internal void Load(DataLocationList configlist, DataLocationList maplist, DataLocation maplocation)
|
||||||
{
|
{
|
||||||
DataLocationList all = DataLocationList.Combined(configlist, maplist);
|
//mxd. Don't modify original lists
|
||||||
all.Remove(maplocation); //mxd. If maplocation was already added as a resource, make sure it's singular and is last in the list
|
DataLocationList configlistcopy = new DataLocationList(configlist);
|
||||||
all.Add(maplocation);
|
DataLocationList maplistcopy = new DataLocationList(maplist);
|
||||||
Load(all);
|
|
||||||
|
//mxd. If maplocation was already added as a resource, make sure it's singular and is the last in the list
|
||||||
|
configlistcopy.Remove(maplocation);
|
||||||
|
maplistcopy.Remove(maplocation);
|
||||||
|
maplistcopy.Add(maplocation);
|
||||||
|
|
||||||
|
Load(configlistcopy, maplistcopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This loads all data resources
|
// This loads all data resources
|
||||||
internal void Load(DataLocationList configlist, DataLocationList maplist)
|
internal void Load(DataLocationList configlist, DataLocationList maplist)
|
||||||
{
|
|
||||||
DataLocationList all = DataLocationList.Combined(configlist, maplist);
|
|
||||||
Load(all);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This loads all data resources
|
|
||||||
private void Load(DataLocationList locations)
|
|
||||||
{
|
{
|
||||||
Dictionary<long, ImageData> texturesonly = new Dictionary<long, ImageData>();
|
Dictionary<long, ImageData> texturesonly = new Dictionary<long, ImageData>();
|
||||||
Dictionary<long, ImageData> colormapsonly = new Dictionary<long, ImageData>();
|
Dictionary<long, ImageData> colormapsonly = new Dictionary<long, ImageData>();
|
||||||
|
@ -355,6 +354,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
resourcetextures = new List<ResourceTextureSet>();
|
resourcetextures = new List<ResourceTextureSet>();
|
||||||
|
|
||||||
// Go for all locations
|
// Go for all locations
|
||||||
|
DataLocationList locations = DataLocationList.Combined(configlist, maplist); //mxd
|
||||||
string prevofficialiwad = string.Empty; //mxd
|
string prevofficialiwad = string.Empty; //mxd
|
||||||
foreach(DataLocation dl in locations)
|
foreach(DataLocation dl in locations)
|
||||||
{
|
{
|
||||||
|
@ -372,7 +372,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
{
|
{
|
||||||
// WAD file container
|
// WAD file container
|
||||||
case DataLocation.RESOURCE_WAD:
|
case DataLocation.RESOURCE_WAD:
|
||||||
c = new WADReader(dl);
|
c = new WADReader(dl, configlist.Contains(dl));
|
||||||
if(((WADReader)c).WadFile.IsOfficialIWAD) //mxd
|
if(((WADReader)c).WadFile.IsOfficialIWAD) //mxd
|
||||||
{
|
{
|
||||||
if(!string.IsNullOrEmpty(prevofficialiwad))
|
if(!string.IsNullOrEmpty(prevofficialiwad))
|
||||||
|
@ -383,12 +383,12 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
|
|
||||||
// Directory container
|
// Directory container
|
||||||
case DataLocation.RESOURCE_DIRECTORY:
|
case DataLocation.RESOURCE_DIRECTORY:
|
||||||
c = new DirectoryReader(dl);
|
c = new DirectoryReader(dl, configlist.Contains(dl));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// PK3 file container
|
// PK3 file container
|
||||||
case DataLocation.RESOURCE_PK3:
|
case DataLocation.RESOURCE_PK3:
|
||||||
c = new PK3Reader(dl);
|
c = new PK3Reader(dl, configlist.Contains(dl));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using CodeImp.DoomBuilder.Compilers;
|
||||||
using CodeImp.DoomBuilder.Config;
|
using CodeImp.DoomBuilder.Config;
|
||||||
using CodeImp.DoomBuilder.GZBuilder.Data;
|
using CodeImp.DoomBuilder.GZBuilder.Data;
|
||||||
using CodeImp.DoomBuilder.ZDoom;
|
using CodeImp.DoomBuilder.ZDoom;
|
||||||
|
@ -94,6 +95,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
protected DataLocation location;
|
protected DataLocation location;
|
||||||
protected bool issuspended;
|
protected bool issuspended;
|
||||||
protected bool isdisposed;
|
protected bool isdisposed;
|
||||||
|
protected bool isreadonly; //mxd
|
||||||
protected ResourceTextureSet textureset;
|
protected ResourceTextureSet textureset;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -103,6 +105,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
public DataLocation Location { get { return location; } }
|
public DataLocation Location { get { return location; } }
|
||||||
public bool IsDisposed { get { return isdisposed; } }
|
public bool IsDisposed { get { return isdisposed; } }
|
||||||
public bool IsSuspended { get { return issuspended; } }
|
public bool IsSuspended { get { return issuspended; } }
|
||||||
|
public bool IsReadOnly { get { return isreadonly; } } //mxd
|
||||||
public ResourceTextureSet TextureSet { get { return textureset; } }
|
public ResourceTextureSet TextureSet { get { return textureset; } }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -110,10 +113,11 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
#region ================== Constructor / Disposer
|
#region ================== Constructor / Disposer
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
protected DataReader(DataLocation dl)
|
protected DataReader(DataLocation dl, bool asreadonly)
|
||||||
{
|
{
|
||||||
// Keep information
|
// Keep information
|
||||||
location = dl;
|
location = dl;
|
||||||
|
isreadonly = asreadonly;
|
||||||
textureset = new ResourceTextureSet(GetTitle(), dl);
|
textureset = new ResourceTextureSet(GetTitle(), dl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,9 +260,23 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
//mxd. When implemented, this returns the voxel lump
|
//mxd. When implemented, this returns the voxel lump
|
||||||
public abstract Stream GetVoxelData(string name);
|
public abstract Stream GetVoxelData(string name);
|
||||||
|
|
||||||
//mxd
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Load/Save (mxd)
|
||||||
|
|
||||||
internal abstract MemoryStream LoadFile(string name);
|
internal abstract MemoryStream LoadFile(string name);
|
||||||
|
internal abstract MemoryStream LoadFile(string name, int lumpindex);
|
||||||
|
internal abstract bool SaveFile(MemoryStream stream, string name);
|
||||||
|
internal abstract bool SaveFile(MemoryStream stream, string name, int lumpindex);
|
||||||
internal abstract bool FileExists(string filename);
|
internal abstract bool FileExists(string filename);
|
||||||
|
internal abstract bool FileExists(string filename, int lumpindex);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Compiling (mxd)
|
||||||
|
|
||||||
|
internal abstract bool CompileLump(string lumpname, out List<CompilerError> errors);
|
||||||
|
internal abstract bool CompileLump(string lumpname, int lumpindex, out List<CompilerError> errors);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using CodeImp.DoomBuilder.Compilers;
|
||||||
using CodeImp.DoomBuilder.IO;
|
using CodeImp.DoomBuilder.IO;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -36,7 +37,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
#region ================== Constructor / Disposer
|
#region ================== Constructor / Disposer
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
public DirectoryReader(DataLocation dl) : base(dl)
|
public DirectoryReader(DataLocation dl, bool asreadonly) : base(dl, asreadonly)
|
||||||
{
|
{
|
||||||
General.WriteLogLine("Opening directory resource \"" + location.location + "\"");
|
General.WriteLogLine("Opening directory resource \"" + location.location + "\"");
|
||||||
|
|
||||||
|
@ -57,7 +58,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
foreach(string wadfile in wadfiles)
|
foreach(string wadfile in wadfiles)
|
||||||
{
|
{
|
||||||
DataLocation wdl = new DataLocation(DataLocation.RESOURCE_WAD, Path.Combine(location.location, wadfile), false, false, true);
|
DataLocation wdl = new DataLocation(DataLocation.RESOURCE_WAD, Path.Combine(location.location, wadfile), false, false, true);
|
||||||
wads.Add(new WADReader(wdl));
|
wads.Add(new WADReader(wdl, isreadonly));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,6 +398,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
}
|
}
|
||||||
|
|
||||||
// This returns true if the specified file exists
|
// This returns true if the specified file exists
|
||||||
|
internal override bool FileExists(string filename, int unused) { return files.FileExists(filename); } //mxd
|
||||||
internal override bool FileExists(string filename)
|
internal override bool FileExists(string filename)
|
||||||
{
|
{
|
||||||
return files.FileExists(filename);
|
return files.FileExists(filename);
|
||||||
|
@ -473,6 +475,28 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//mxd
|
||||||
|
internal override bool SaveFile(MemoryStream stream, string filename, int unused) { return SaveFile(stream, filename); }
|
||||||
|
internal override bool SaveFile(MemoryStream stream, string filename)
|
||||||
|
{
|
||||||
|
if(isreadonly) return false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock(this)
|
||||||
|
{
|
||||||
|
File.WriteAllBytes(Path.Combine(location.location, filename), stream.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
General.ErrorLogger.Add(ErrorType.Error, "Unable to save file: " + e.Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// This creates a temp file for the speciied file and return the absolute path to the temp file
|
// This creates a temp file for the speciied file and return the absolute path to the temp file
|
||||||
// NOTE: Callers are responsible for removing the temp file when done!
|
// NOTE: Callers are responsible for removing the temp file when done!
|
||||||
protected override string CreateTempFile(string filename)
|
protected override string CreateTempFile(string filename)
|
||||||
|
@ -484,5 +508,17 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Compiling (mxd)
|
||||||
|
|
||||||
|
// This compiles a script lump and returns any errors that may have occurred
|
||||||
|
// Returns true when our code worked properly (even when the compiler returned errors)
|
||||||
|
internal override bool CompileLump(string filename, int unused, out List<CompilerError> errors) { return CompileLump(filename, out errors); }
|
||||||
|
internal override bool CompileLump(string lumpname, out List<CompilerError> errors)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using CodeImp.DoomBuilder.Compilers;
|
||||||
using CodeImp.DoomBuilder.IO;
|
using CodeImp.DoomBuilder.IO;
|
||||||
using SharpCompress.Archive; //mxd
|
using SharpCompress.Archive; //mxd
|
||||||
|
using SharpCompress.Archive.Zip;
|
||||||
using SharpCompress.Common; //mxd
|
using SharpCompress.Common; //mxd
|
||||||
using SharpCompress.Reader; //mxd
|
using SharpCompress.Reader; //mxd
|
||||||
|
|
||||||
|
@ -49,7 +51,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
#region ================== Constructor / Disposer
|
#region ================== Constructor / Disposer
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
public PK3Reader(DataLocation dl) : base(dl)
|
public PK3Reader(DataLocation dl, bool asreadonly) : base(dl, asreadonly)
|
||||||
{
|
{
|
||||||
General.WriteLogLine("Opening " + Path.GetExtension(location.location).ToUpper().Replace(".", "") + " resource \"" + location.location + "\"");
|
General.WriteLogLine("Opening " + Path.GetExtension(location.location).ToUpper().Replace(".", "") + " resource \"" + location.location + "\"");
|
||||||
|
|
||||||
|
@ -66,6 +68,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
// Random access of 7z archives works TERRIBLY slow in SharpCompress
|
// Random access of 7z archives works TERRIBLY slow in SharpCompress
|
||||||
if(archivetype == ArchiveType.SevenZip)
|
if(archivetype == ArchiveType.SevenZip)
|
||||||
{
|
{
|
||||||
|
isreadonly = true; // Unsaveable...
|
||||||
sevenzipentries = new Dictionary<string, byte[]>(StringComparer.Ordinal);
|
sevenzipentries = new Dictionary<string, byte[]>(StringComparer.Ordinal);
|
||||||
|
|
||||||
IReader reader = archive.ExtractAllEntries();
|
IReader reader = archive.ExtractAllEntries();
|
||||||
|
@ -410,6 +413,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
}
|
}
|
||||||
|
|
||||||
// This returns true if the specified file exists
|
// This returns true if the specified file exists
|
||||||
|
internal override bool FileExists(string filename, int unused) { return files.FileExists(filename); }
|
||||||
internal override bool FileExists(string filename)
|
internal override bool FileExists(string filename)
|
||||||
{
|
{
|
||||||
return files.FileExists(filename);
|
return files.FileExists(filename);
|
||||||
|
@ -514,6 +518,26 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
return filedata;
|
return filedata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//mxd. TODO: test this
|
||||||
|
internal override bool SaveFile(MemoryStream stream, string filename, int unused) { return SaveFile(stream, filename); }
|
||||||
|
internal override bool SaveFile(MemoryStream stream, string filename)
|
||||||
|
{
|
||||||
|
// Not implemented in SevenZipArchive...
|
||||||
|
if(isreadonly || archivetype == ArchiveType.SevenZip) return false;
|
||||||
|
|
||||||
|
// Re-open the archive
|
||||||
|
using(ZipArchive za = (ZipArchive)ArchiveFactory.Open(location.location))
|
||||||
|
{
|
||||||
|
if(za == null) return false;
|
||||||
|
|
||||||
|
// Replace entry
|
||||||
|
//TODO: Do we need to remove the old entry?
|
||||||
|
za.AddEntry(filename, stream, stream.Length, DateTime.Now);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// This creates a temp file for the speciied file and return the absolute path to the temp file
|
// This creates a temp file for the speciied file and return the absolute path to the temp file
|
||||||
// NOTE: Callers are responsible for removing the temp file when done!
|
// NOTE: Callers are responsible for removing the temp file when done!
|
||||||
protected override string CreateTempFile(string filename)
|
protected override string CreateTempFile(string filename)
|
||||||
|
@ -551,5 +575,17 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Compiling (mxd)
|
||||||
|
|
||||||
|
// This compiles a script lump and returns any errors that may have occurred
|
||||||
|
// Returns true when our code worked properly (even when the compiler returned errors)
|
||||||
|
internal override bool CompileLump(string filename, int unused, out List<CompilerError> errors) { return CompileLump(filename, out errors); }
|
||||||
|
internal override bool CompileLump(string filename, out List<CompilerError> errors)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
#region ================== Constructor / Disposer
|
#region ================== Constructor / Disposer
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
protected PK3StructuredReader(DataLocation dl) : base(dl)
|
protected PK3StructuredReader(DataLocation dl, bool asreadonly) : base(dl, asreadonly)
|
||||||
{
|
{
|
||||||
// Initialize
|
// Initialize
|
||||||
this.roottextures = dl.option1;
|
this.roottextures = dl.option1;
|
||||||
|
@ -79,7 +79,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
{
|
{
|
||||||
string tempfile = CreateTempFile(w);
|
string tempfile = CreateTempFile(w);
|
||||||
DataLocation wdl = new DataLocation(DataLocation.RESOURCE_WAD, tempfile, Path.Combine(location.GetDisplayName(), Path.GetFileName(w)), false, false, true);
|
DataLocation wdl = new DataLocation(DataLocation.RESOURCE_WAD, tempfile, Path.Combine(location.GetDisplayName(), Path.GetFileName(w)), false, false, true);
|
||||||
wads.Add(new WADReader(wdl));
|
wads.Add(new WADReader(wdl, location.type != DataLocation.RESOURCE_DIRECTORY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -875,6 +875,12 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//mxd. Archives and Folders don't have lump indices
|
||||||
|
internal override MemoryStream LoadFile(string name, int unused)
|
||||||
|
{
|
||||||
|
return LoadFile(name);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,10 +20,11 @@ using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using CodeImp.DoomBuilder.Compilers;
|
||||||
|
using CodeImp.DoomBuilder.GZBuilder.Data;
|
||||||
using CodeImp.DoomBuilder.IO;
|
using CodeImp.DoomBuilder.IO;
|
||||||
using CodeImp.DoomBuilder.ZDoom;
|
using CodeImp.DoomBuilder.ZDoom;
|
||||||
using CodeImp.DoomBuilder.GZBuilder.Data;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -50,17 +51,17 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
// Source
|
// Source
|
||||||
private WAD file;
|
private WAD file;
|
||||||
private bool is_iwad;
|
private bool is_iwad;
|
||||||
private readonly bool strictpatches;
|
private bool strictpatches;
|
||||||
|
|
||||||
// Lump ranges
|
// Lump ranges
|
||||||
private readonly List<LumpRange> flatranges;
|
private List<LumpRange> flatranges;
|
||||||
private readonly List<LumpRange> invertedflatranges; //mxd
|
private List<LumpRange> invertedflatranges; //mxd
|
||||||
private readonly List<LumpRange> patchranges;
|
private List<LumpRange> patchranges;
|
||||||
private readonly List<LumpRange> spriteranges;
|
private List<LumpRange> spriteranges;
|
||||||
private readonly List<LumpRange> textureranges;
|
private List<LumpRange> textureranges;
|
||||||
private readonly List<LumpRange> hiresranges; //mxd
|
private List<LumpRange> hiresranges; //mxd
|
||||||
private readonly List<LumpRange> colormapranges;
|
private List<LumpRange> colormapranges;
|
||||||
private readonly List<LumpRange> voxelranges; //mxd
|
private List<LumpRange> voxelranges; //mxd
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
#region ================== Constructor / Disposer
|
#region ================== Constructor / Disposer
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
public WADReader(DataLocation dl) : base(dl)
|
public WADReader(DataLocation dl, bool asreadonly) : base(dl, asreadonly)
|
||||||
{
|
{
|
||||||
General.WriteLogLine("Opening WAD resource \"" + location.location + "\"");
|
General.WriteLogLine("Opening WAD resource \"" + location.location + "\"");
|
||||||
|
|
||||||
|
@ -82,9 +83,41 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
throw new FileNotFoundException("Could not find the file \"" + location.location + "\"", location.location);
|
throw new FileNotFoundException("Could not find the file \"" + location.location + "\"", location.location);
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
file = new WAD(location.location, true);
|
file = new WAD(location.location, asreadonly);
|
||||||
is_iwad = file.IsIWAD;
|
|
||||||
strictpatches = dl.option1;
|
strictpatches = dl.option1;
|
||||||
|
Initialize(); //mxd
|
||||||
|
|
||||||
|
// We have no destructor
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//mxd. Constructor
|
||||||
|
internal WADReader(DataLocation dl, bool asreadonly, bool create) : base(dl, asreadonly)
|
||||||
|
{
|
||||||
|
if(!create)
|
||||||
|
{
|
||||||
|
General.WriteLogLine("Opening WAD resource \"" + location.location + "\"");
|
||||||
|
|
||||||
|
if(!File.Exists(location.location))
|
||||||
|
throw new FileNotFoundException("Could not find the file \"" + location.location + "\"", location.location);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize
|
||||||
|
file = new WAD(location.location, asreadonly);
|
||||||
|
strictpatches = dl.option1;
|
||||||
|
Initialize();
|
||||||
|
|
||||||
|
// We have no destructor
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//mxd
|
||||||
|
private void Initialize()
|
||||||
|
{
|
||||||
|
is_iwad = file.IsIWAD;
|
||||||
|
isreadonly = file.IsReadOnly; // I guess opening an official IWAD in write-enabled mode is possible
|
||||||
|
|
||||||
|
// Initialize
|
||||||
patchranges = new List<LumpRange>();
|
patchranges = new List<LumpRange>();
|
||||||
spriteranges = new List<LumpRange>();
|
spriteranges = new List<LumpRange>();
|
||||||
flatranges = new List<LumpRange>();
|
flatranges = new List<LumpRange>();
|
||||||
|
@ -133,9 +166,6 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
LumpRange range = new LumpRange {start = 0, end = file.Lumps.Count - 1};
|
LumpRange range = new LumpRange {start = 0, end = file.Lumps.Count - 1};
|
||||||
invertedflatranges.Add(range);
|
invertedflatranges.Add(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have no destructor
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disposer
|
// Disposer
|
||||||
|
@ -1081,7 +1111,10 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd
|
#endregion
|
||||||
|
|
||||||
|
#region ================== IO (mxd)
|
||||||
|
|
||||||
internal override MemoryStream LoadFile(string name)
|
internal override MemoryStream LoadFile(string name)
|
||||||
{
|
{
|
||||||
Lump l = file.FindLump(name);
|
Lump l = file.FindLump(name);
|
||||||
|
@ -1095,10 +1128,93 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd
|
internal override MemoryStream LoadFile(string name, int lumpindex)
|
||||||
internal override bool FileExists(string name)
|
|
||||||
{
|
{
|
||||||
return file.FindLumpIndex(name) != -1;
|
if(lumpindex < 0 || file.Lumps.Count <= lumpindex || file.Lumps[lumpindex].Name != name)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
Lump l = file.Lumps[lumpindex];
|
||||||
|
l.Stream.Seek(0, SeekOrigin.Begin);
|
||||||
|
return new MemoryStream(l.Stream.ReadAllBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override bool SaveFile(MemoryStream lumpdata, string lumpname)
|
||||||
|
{
|
||||||
|
if(isreadonly) return false;
|
||||||
|
int insertindex = file.Lumps.Count;
|
||||||
|
|
||||||
|
// Remove the lump if it already exists
|
||||||
|
int li = file.FindLumpIndex(lumpname);
|
||||||
|
if(li > -1)
|
||||||
|
{
|
||||||
|
insertindex = li;
|
||||||
|
file.RemoveAt(li);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert new lump
|
||||||
|
Lump l = file.Insert(lumpname, insertindex, (int)lumpdata.Length);
|
||||||
|
l.Stream.Seek(0, SeekOrigin.Begin);
|
||||||
|
lumpdata.WriteTo(l.Stream);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override bool SaveFile(MemoryStream lumpdata, string lumpname, int lumpindex)
|
||||||
|
{
|
||||||
|
if(isreadonly || lumpindex < 0 || file.Lumps.Count <= lumpindex || file.Lumps[lumpindex].Name != lumpname)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Remove the lump
|
||||||
|
file.RemoveAt(lumpindex);
|
||||||
|
|
||||||
|
// Insert new lump
|
||||||
|
Lump l = file.Insert(lumpname, lumpindex, (int)lumpdata.Length);
|
||||||
|
l.Stream.Seek(0, SeekOrigin.Begin);
|
||||||
|
lumpdata.WriteTo(l.Stream);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override bool FileExists(string lumpname)
|
||||||
|
{
|
||||||
|
return file.FindLumpIndex(lumpname) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override bool FileExists(string lumpname, int lumpindex)
|
||||||
|
{
|
||||||
|
return file.FindLumpIndex(lumpname) == lumpindex;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Compiling (mxd)
|
||||||
|
|
||||||
|
// This compiles a script lump and returns any errors that may have occurred
|
||||||
|
// Returns true when our code worked properly (even when the compiler returned errors)
|
||||||
|
internal override bool CompileLump(string lumpname, out List<CompilerError> errors)
|
||||||
|
{
|
||||||
|
int index = file.FindLumpIndex(lumpname);
|
||||||
|
if(index == -1)
|
||||||
|
{
|
||||||
|
errors = new List<CompilerError>
|
||||||
|
{
|
||||||
|
new CompilerError
|
||||||
|
{
|
||||||
|
description = "Lump \"" + lumpname + "\" does not exist",
|
||||||
|
filename = this.location.GetDisplayName()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CompileLump(lumpname, index, out errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This compiles a script lump and returns any errors that may have occurred
|
||||||
|
// Returns true when our code worked properly (even when the compiler returned errors)
|
||||||
|
internal override bool CompileLump(string lumpname, int lumpindex, out List<CompilerError> errors)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -75,7 +75,7 @@ namespace CodeImp.DoomBuilder
|
||||||
private D3DDevice graphics;
|
private D3DDevice graphics;
|
||||||
private Renderer2D renderer2d;
|
private Renderer2D renderer2d;
|
||||||
private Renderer3D renderer3d;
|
private Renderer3D renderer3d;
|
||||||
private WAD tempwad;
|
private WADReader tempwadreader;
|
||||||
private GridSetup grid;
|
private GridSetup grid;
|
||||||
private UndoManager undoredo;
|
private UndoManager undoredo;
|
||||||
private CopyPasteManager copypaste;
|
private CopyPasteManager copypaste;
|
||||||
|
@ -122,6 +122,7 @@ namespace CodeImp.DoomBuilder
|
||||||
internal ScriptEditorForm ScriptEditor { get { return scriptwindow; } }
|
internal ScriptEditorForm ScriptEditor { get { return scriptwindow; } }
|
||||||
public VisualCamera VisualCamera { get { return visualcamera; } set { visualcamera = value; } }
|
public VisualCamera VisualCamera { get { return visualcamera; } set { visualcamera = value; } }
|
||||||
public bool IsScriptsWindowOpen { get { return (scriptwindow != null) && !scriptwindow.IsDisposed; } }
|
public bool IsScriptsWindowOpen { get { return (scriptwindow != null) && !scriptwindow.IsDisposed; } }
|
||||||
|
internal WADReader TemporaryMapFile { get { return tempwadreader; } } //mxd
|
||||||
|
|
||||||
//mxd. Map format
|
//mxd. Map format
|
||||||
public bool UDMF { get { return config.UDMF; } }
|
public bool UDMF { get { return config.UDMF; } }
|
||||||
|
@ -193,7 +194,7 @@ namespace CodeImp.DoomBuilder
|
||||||
General.WriteLogLine("Unloading data resources...");
|
General.WriteLogLine("Unloading data resources...");
|
||||||
if(data != null) data.Dispose();
|
if(data != null) data.Dispose();
|
||||||
General.WriteLogLine("Closing temporary file...");
|
General.WriteLogLine("Closing temporary file...");
|
||||||
if(tempwad != null) tempwad.Dispose();
|
if(tempwadreader != null) tempwadreader.Dispose(); //mxd
|
||||||
General.WriteLogLine("Unloading map data...");
|
General.WriteLogLine("Unloading map data...");
|
||||||
if(map != null) map.Dispose();
|
if(map != null) map.Dispose();
|
||||||
General.WriteLogLine("Stopping graphics device...");
|
General.WriteLogLine("Stopping graphics device...");
|
||||||
|
@ -206,7 +207,7 @@ namespace CodeImp.DoomBuilder
|
||||||
copypaste = null;
|
copypaste = null;
|
||||||
undoredo = null;
|
undoredo = null;
|
||||||
data = null;
|
data = null;
|
||||||
tempwad = null;
|
tempwadreader = null; //mxd
|
||||||
map = null;
|
map = null;
|
||||||
renderer2d = null;
|
renderer2d = null;
|
||||||
renderer3d = null;
|
renderer3d = null;
|
||||||
|
@ -278,12 +279,12 @@ namespace CodeImp.DoomBuilder
|
||||||
map = new MapSet();
|
map = new MapSet();
|
||||||
|
|
||||||
// Create temp wadfile
|
// Create temp wadfile
|
||||||
string tempfile = General.MakeTempFilename(temppath);
|
DataLocation templocation = new DataLocation(DataLocation.RESOURCE_WAD, General.MakeTempFilename(temppath), false, false, false); //mxd
|
||||||
General.WriteLogLine("Creating temporary file: " + tempfile);
|
General.WriteLogLine("Creating temporary file: " + templocation.location);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
tempwad = new WAD(tempfile);
|
tempwadreader = new WADReader(templocation, false, true);
|
||||||
#else
|
#else
|
||||||
try { tempwad = new WAD(tempfile); }
|
try { tempwadreader = new WADReader(templocation, false, true); }
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
General.ShowErrorMessage("Error while creating a temporary wad file:\n" + e.GetType().Name + ": " + e.Message, MessageBoxButtons.OK);
|
General.ShowErrorMessage("Error while creating a temporary wad file:\n" + e.GetType().Name + ": " + e.Message, MessageBoxButtons.OK);
|
||||||
|
@ -293,13 +294,13 @@ namespace CodeImp.DoomBuilder
|
||||||
|
|
||||||
// Read the map from temp file
|
// Read the map from temp file
|
||||||
General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "...");
|
General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "...");
|
||||||
io = MapSetIO.Create(config.FormatInterface, tempwad, this);
|
io = MapSetIO.Create(config.FormatInterface, tempwadreader.WadFile, this);
|
||||||
|
|
||||||
// Create required lumps
|
// Create required lumps
|
||||||
General.WriteLogLine("Creating map data structures...");
|
General.WriteLogLine("Creating map data structures...");
|
||||||
tempwad.Insert(TEMP_MAP_HEADER, 0, 0);
|
tempwadreader.WadFile.Insert(TEMP_MAP_HEADER, 0, 0);
|
||||||
io.Write(map, TEMP_MAP_HEADER, 1);
|
io.Write(map, TEMP_MAP_HEADER, 1);
|
||||||
CreateRequiredLumps(tempwad, TEMP_MAP_HEADER);
|
CreateRequiredLumps(tempwadreader.WadFile, TEMP_MAP_HEADER);
|
||||||
|
|
||||||
// Load data manager
|
// Load data manager
|
||||||
General.WriteLogLine("Loading data resources...");
|
General.WriteLogLine("Loading data resources...");
|
||||||
|
@ -373,12 +374,12 @@ namespace CodeImp.DoomBuilder
|
||||||
map = new MapSet();
|
map = new MapSet();
|
||||||
|
|
||||||
// Create temp wadfile
|
// Create temp wadfile
|
||||||
string tempfile = General.MakeTempFilename(temppath);
|
DataLocation templocation = new DataLocation(DataLocation.RESOURCE_WAD, General.MakeTempFilename(temppath), false, false, false); //mxd
|
||||||
General.WriteLogLine("Creating temporary file: " + tempfile);
|
General.WriteLogLine("Creating temporary file: " + templocation.location);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
tempwad = new WAD(tempfile);
|
tempwadreader = new WADReader(templocation, false, true);
|
||||||
#else
|
#else
|
||||||
try { tempwad = new WAD(tempfile); } catch(Exception e)
|
try { tempwadreader = new WADReader(templocation, false, true); } catch(Exception e)
|
||||||
{
|
{
|
||||||
General.ShowErrorMessage("Error while creating a temporary wad file:\n" + e.GetType().Name + ": " + e.Message, MessageBoxButtons.OK);
|
General.ShowErrorMessage("Error while creating a temporary wad file:\n" + e.GetType().Name + ": " + e.Message, MessageBoxButtons.OK);
|
||||||
return false;
|
return false;
|
||||||
|
@ -399,7 +400,7 @@ namespace CodeImp.DoomBuilder
|
||||||
|
|
||||||
// Copy the map lumps to the temp file
|
// Copy the map lumps to the temp file
|
||||||
General.WriteLogLine("Copying map lumps to temporary file...");
|
General.WriteLogLine("Copying map lumps to temporary file...");
|
||||||
CopyLumpsByType(mapwad, options.CurrentName, tempwad, TEMP_MAP_HEADER, REPLACE_TARGET_MAP, true, true, true, true);
|
CopyLumpsByType(mapwad, options.CurrentName, tempwadreader.WadFile, TEMP_MAP_HEADER, REPLACE_TARGET_MAP, true, true, true, true);
|
||||||
|
|
||||||
// Close the map file
|
// Close the map file
|
||||||
mapwad.Dispose();
|
mapwad.Dispose();
|
||||||
|
@ -466,14 +467,14 @@ namespace CodeImp.DoomBuilder
|
||||||
WAD mapwad;
|
WAD mapwad;
|
||||||
|
|
||||||
// Create temp wadfile
|
// Create temp wadfile
|
||||||
string tempfile = General.MakeTempFilename(temppath);
|
DataLocation templocation = new DataLocation(DataLocation.RESOURCE_WAD, General.MakeTempFilename(temppath), false, false, false); //mxd
|
||||||
General.WriteLogLine("Creating temporary file: " + tempfile);
|
General.WriteLogLine("Creating temporary file: " + templocation.location);
|
||||||
if(tempwad != null) tempwad.Dispose();
|
if(tempwadreader != null) tempwadreader.Dispose();
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
tempwad = new WAD(tempfile);
|
tempwadreader = new WADReader(templocation, false, true);
|
||||||
#else
|
#else
|
||||||
try { tempwad = new WAD(tempfile); } catch(Exception e)
|
try { tempwadreader = new WADReader(templocation, false, true); } catch(Exception e)
|
||||||
{
|
{
|
||||||
General.ShowErrorMessage("Error while creating a temporary wad file:\n" + e.GetType().Name + ": " + e.Message, MessageBoxButtons.OK);
|
General.ShowErrorMessage("Error while creating a temporary wad file:\n" + e.GetType().Name + ": " + e.Message, MessageBoxButtons.OK);
|
||||||
return false;
|
return false;
|
||||||
|
@ -495,7 +496,7 @@ namespace CodeImp.DoomBuilder
|
||||||
|
|
||||||
// Copy the map lumps to the temp file
|
// Copy the map lumps to the temp file
|
||||||
General.WriteLogLine("Copying map lumps to temporary file...");
|
General.WriteLogLine("Copying map lumps to temporary file...");
|
||||||
CopyLumpsByType(mapwad, options.CurrentName, tempwad, TEMP_MAP_HEADER, REPLACE_TARGET_MAP, true, true, true, true);
|
CopyLumpsByType(mapwad, options.CurrentName, tempwadreader.WadFile, TEMP_MAP_HEADER, REPLACE_TARGET_MAP, true, true, true, true);
|
||||||
|
|
||||||
// Close the map file
|
// Close the map file
|
||||||
mapwad.Dispose();
|
mapwad.Dispose();
|
||||||
|
@ -559,7 +560,7 @@ namespace CodeImp.DoomBuilder
|
||||||
+ "Would you like to restore the map from the backup?", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
+ "Would you like to restore the map from the backup?", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "...");
|
General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "...");
|
||||||
io = MapSetIO.Create(config.FormatInterface, tempwad, this);
|
io = MapSetIO.Create(config.FormatInterface, tempwadreader.WadFile, this);
|
||||||
General.WriteLogLine("Restoring map from \"" + backuppath + "\"...");
|
General.WriteLogLine("Restoring map from \"" + backuppath + "\"...");
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
@ -591,7 +592,7 @@ namespace CodeImp.DoomBuilder
|
||||||
{
|
{
|
||||||
newmap.BeginAddRemove();
|
newmap.BeginAddRemove();
|
||||||
General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "...");
|
General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "...");
|
||||||
io = MapSetIO.Create(config.FormatInterface, tempwad, this);
|
io = MapSetIO.Create(config.FormatInterface, tempwadreader.WadFile, this);
|
||||||
General.WriteLogLine("Reading map data from file...");
|
General.WriteLogLine("Reading map data from file...");
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
newmap = io.Read(newmap, TEMP_MAP_HEADER);
|
newmap = io.Read(newmap, TEMP_MAP_HEADER);
|
||||||
|
@ -699,7 +700,7 @@ namespace CodeImp.DoomBuilder
|
||||||
|
|
||||||
// Write to temporary file
|
// Write to temporary file
|
||||||
General.WriteLogLine("Writing map data structures to file...");
|
General.WriteLogLine("Writing map data structures to file...");
|
||||||
int index = Math.Max(0, tempwad.FindLumpIndex(TEMP_MAP_HEADER));
|
int index = Math.Max(0, tempwadreader.WadFile.FindLumpIndex(TEMP_MAP_HEADER));
|
||||||
io.Write(outputset, TEMP_MAP_HEADER, index);
|
io.Write(outputset, TEMP_MAP_HEADER, index);
|
||||||
outputset.Dispose();
|
outputset.Dispose();
|
||||||
|
|
||||||
|
@ -772,7 +773,7 @@ namespace CodeImp.DoomBuilder
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Check if we have nodebuilder lumps
|
// Check if we have nodebuilder lumps
|
||||||
includenodes = VerifyNodebuilderLumps(tempwad, TEMP_MAP_HEADER);
|
includenodes = VerifyNodebuilderLumps(tempwadreader.WadFile, TEMP_MAP_HEADER);
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd. Target file is read-only?
|
//mxd. Target file is read-only?
|
||||||
|
@ -969,7 +970,7 @@ namespace CodeImp.DoomBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy map lumps to target file
|
// Copy map lumps to target file
|
||||||
CopyLumpsByType(tempwad, TEMP_MAP_HEADER, targetwad, origmapname, mapheaderindex, true, true, includenodes, true);
|
CopyLumpsByType(tempwadreader.WadFile, TEMP_MAP_HEADER, targetwad, origmapname, mapheaderindex, true, true, includenodes, true);
|
||||||
|
|
||||||
// mxd. Was the map renamed?
|
// mxd. Was the map renamed?
|
||||||
if(options.LevelNameChanged)
|
if(options.LevelNameChanged)
|
||||||
|
@ -1172,14 +1173,14 @@ namespace CodeImp.DoomBuilder
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Determine source file
|
// Determine source file
|
||||||
string sourcefile = (filepathname.Length > 0 ? filepathname : tempwad.Filename);
|
string sourcefile = (filepathname.Length > 0 ? filepathname : tempwadreader.WadFile.Filename);
|
||||||
|
|
||||||
//mxd.
|
//mxd.
|
||||||
RemoveUnneededLumps(tempwad, TEMP_MAP_HEADER, true);
|
RemoveUnneededLumps(tempwadreader.WadFile, TEMP_MAP_HEADER, true);
|
||||||
|
|
||||||
// Copy lumps to buildwad
|
// Copy lumps to buildwad
|
||||||
General.WriteLogLine("Copying map lumps to temporary build file...");
|
General.WriteLogLine("Copying map lumps to temporary build file...");
|
||||||
CopyLumpsByType(tempwad, TEMP_MAP_HEADER, buildwad, BUILD_MAP_HEADER, REPLACE_TARGET_MAP, true, false, false, true);
|
CopyLumpsByType(tempwadreader.WadFile, TEMP_MAP_HEADER, buildwad, BUILD_MAP_HEADER, REPLACE_TARGET_MAP, true, false, false, true);
|
||||||
|
|
||||||
// Close buildwad
|
// Close buildwad
|
||||||
buildwad.Dispose();
|
buildwad.Dispose();
|
||||||
|
@ -1224,7 +1225,7 @@ namespace CodeImp.DoomBuilder
|
||||||
{
|
{
|
||||||
// Copy nodebuilder lumps to temp file
|
// Copy nodebuilder lumps to temp file
|
||||||
General.WriteLogLine("Copying nodebuilder lumps to temporary file...");
|
General.WriteLogLine("Copying nodebuilder lumps to temporary file...");
|
||||||
CopyLumpsByType(buildwad, BUILD_MAP_HEADER, tempwad, TEMP_MAP_HEADER, REPLACE_TARGET_MAP, false, false, true, false);
|
CopyLumpsByType(buildwad, BUILD_MAP_HEADER, tempwadreader.WadFile, TEMP_MAP_HEADER, REPLACE_TARGET_MAP, false, false, true, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1309,7 +1310,7 @@ namespace CodeImp.DoomBuilder
|
||||||
// This is copied from the temp wad file and returns null when the lump is not found
|
// This is copied from the temp wad file and returns null when the lump is not found
|
||||||
public MemoryStream GetLumpData(string lumpname)
|
public MemoryStream GetLumpData(string lumpname)
|
||||||
{
|
{
|
||||||
Lump l = tempwad.FindLump(lumpname);
|
Lump l = tempwadreader.WadFile.FindLump(lumpname);
|
||||||
if(l != null)
|
if(l != null)
|
||||||
{
|
{
|
||||||
l.Stream.Seek(0, SeekOrigin.Begin);
|
l.Stream.Seek(0, SeekOrigin.Begin);
|
||||||
|
@ -1321,18 +1322,18 @@ namespace CodeImp.DoomBuilder
|
||||||
// This writes a copy of the data to a lump in the temp file
|
// This writes a copy of the data to a lump in the temp file
|
||||||
public void SetLumpData(string lumpname, MemoryStream lumpdata)
|
public void SetLumpData(string lumpname, MemoryStream lumpdata)
|
||||||
{
|
{
|
||||||
int insertindex = tempwad.Lumps.Count;
|
int insertindex = tempwadreader.WadFile.Lumps.Count;
|
||||||
|
|
||||||
// Remove the lump if it already exists
|
// Remove the lump if it already exists
|
||||||
int li = tempwad.FindLumpIndex(lumpname);
|
int li = tempwadreader.WadFile.FindLumpIndex(lumpname);
|
||||||
if(li > -1)
|
if(li > -1)
|
||||||
{
|
{
|
||||||
insertindex = li;
|
insertindex = li;
|
||||||
tempwad.RemoveAt(li);
|
tempwadreader.WadFile.RemoveAt(li);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert new lump
|
// Insert new lump
|
||||||
Lump l = tempwad.Insert(lumpname, insertindex, (int)lumpdata.Length);
|
Lump l = tempwadreader.WadFile.Insert(lumpname, insertindex, (int)lumpdata.Length);
|
||||||
l.Stream.Seek(0, SeekOrigin.Begin);
|
l.Stream.Seek(0, SeekOrigin.Begin);
|
||||||
lumpdata.WriteTo(l.Stream);
|
lumpdata.WriteTo(l.Stream);
|
||||||
|
|
||||||
|
@ -1343,7 +1344,7 @@ namespace CodeImp.DoomBuilder
|
||||||
// This checks if the specified lump exists in the temp file
|
// This checks if the specified lump exists in the temp file
|
||||||
public bool LumpExists(string lumpname)
|
public bool LumpExists(string lumpname)
|
||||||
{
|
{
|
||||||
return (tempwad.FindLumpIndex(lumpname) > -1);
|
return (tempwadreader.WadFile.FindLumpIndex(lumpname) > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This creates empty lumps for those required
|
// This creates empty lumps for those required
|
||||||
|
@ -2002,11 +2003,11 @@ namespace CodeImp.DoomBuilder
|
||||||
|
|
||||||
// Find the lump
|
// Find the lump
|
||||||
if(lumpname == CONFIG_MAP_HEADER) reallumpname = TEMP_MAP_HEADER;
|
if(lumpname == CONFIG_MAP_HEADER) reallumpname = TEMP_MAP_HEADER;
|
||||||
Lump lump = tempwad.FindLump(reallumpname);
|
Lump lump = tempwadreader.WadFile.FindLump(reallumpname);
|
||||||
if(lump == null) throw new Exception("No such lump in temporary wad file \"" + reallumpname + "\".");
|
if(lump == null) throw new Exception("No such lump in temporary wad file \"" + reallumpname + "\".");
|
||||||
|
|
||||||
// Determine source file
|
// Determine source file
|
||||||
string sourcefile = (filepathname.Length > 0 ? filepathname : tempwad.Filename);
|
string sourcefile = (filepathname.Length > 0 ? filepathname : tempwadreader.WadFile.Filename);
|
||||||
|
|
||||||
// New list of errors
|
// New list of errors
|
||||||
if(clearerrors) errors.Clear();
|
if(clearerrors) errors.Clear();
|
||||||
|
@ -2183,7 +2184,7 @@ namespace CodeImp.DoomBuilder
|
||||||
};
|
};
|
||||||
|
|
||||||
//INFO: CompileLump() prepends lumpname with "?" to distinguish between temporary files and files compiled in place
|
//INFO: CompileLump() prepends lumpname with "?" to distinguish between temporary files and files compiled in place
|
||||||
DataLocation location = new DataLocation { location = tempwad.Filename, type = DataLocation.RESOURCE_WAD };
|
DataLocation location = new DataLocation { location = tempwadreader.WadFile.Filename, type = DataLocation.RESOURCE_WAD };
|
||||||
TextResourceData data = new TextResourceData(stream, location, "?SCRIPTS", false);
|
TextResourceData data = new TextResourceData(stream, location, "?SCRIPTS", false);
|
||||||
if(parser.Parse(data, scriptconfig.Compiler.Files, true, AcsParserSE.IncludeType.NONE, false))
|
if(parser.Parse(data, scriptconfig.Compiler.Files, true, AcsParserSE.IncludeType.NONE, false))
|
||||||
{
|
{
|
||||||
|
@ -2431,14 +2432,14 @@ namespace CodeImp.DoomBuilder
|
||||||
|
|
||||||
// Setup new map format IO
|
// Setup new map format IO
|
||||||
General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "...");
|
General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "...");
|
||||||
io = MapSetIO.Create(config.FormatInterface, tempwad, this);
|
io = MapSetIO.Create(config.FormatInterface, tempwadreader.WadFile, this);
|
||||||
|
|
||||||
//mxd. Some lumps may've become unneeded during map format conversion.
|
//mxd. Some lumps may've become unneeded during map format conversion.
|
||||||
if(oldiotype != io.GetType())
|
if(oldiotype != io.GetType())
|
||||||
RemoveUnneededLumps(tempwad, TEMP_MAP_HEADER, false);
|
RemoveUnneededLumps(tempwadreader.WadFile, TEMP_MAP_HEADER, false);
|
||||||
|
|
||||||
// Create required lumps if they don't exist yet
|
// Create required lumps if they don't exist yet
|
||||||
CreateRequiredLumps(tempwad, TEMP_MAP_HEADER);
|
CreateRequiredLumps(tempwadreader.WadFile, TEMP_MAP_HEADER);
|
||||||
|
|
||||||
// Let the plugins know
|
// Let the plugins know
|
||||||
General.Plugins.MapReconfigure();
|
General.Plugins.MapReconfigure();
|
||||||
|
|
|
@ -249,9 +249,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
//render hint
|
//render hint
|
||||||
if(horizontalslices > 1 || verticalslices > 1)
|
if(horizontalslices > 1 || verticalslices > 1)
|
||||||
{
|
{
|
||||||
hintlabel.Text = "H: " + (slicesH - 1) + "; V: " + (slicesV - 1);
|
string text = "H: " + (slicesH - 1) + "; V: " + (slicesV - 1);
|
||||||
if(width > hintlabel.Text.Length * vsize && height > 16 * vsize)
|
if(width > text.Length * vsize && height > 16 * vsize)
|
||||||
{
|
{
|
||||||
|
hintlabel.Text = text;
|
||||||
hintlabel.Move(start, end);
|
hintlabel.Move(start, end);
|
||||||
renderer.RenderText(hintlabel.TextLabel);
|
renderer.RenderText(hintlabel.TextLabel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -656,7 +656,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
l.Text = group.Value[0];
|
l.Text = group.Value[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
torender.Add(l);
|
if(!string.IsNullOrEmpty(l.Text)) torender.Add(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
for(int i = 0; i < s.Labels.Count; i++)
|
for(int i = 0; i < s.Labels.Count; i++)
|
||||||
{
|
{
|
||||||
// Render only when enough space for the label to see
|
// Render only when enough space for the label to see
|
||||||
if(requiredsize < s.Labels[i].radius) torender.Add(labelarray[i]);
|
if(!string.IsNullOrEmpty(labelarray[i].Text) && requiredsize < s.Labels[i].radius)
|
||||||
|
torender.Add(labelarray[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
renderer.RenderText(torender);
|
renderer.RenderText(torender);
|
||||||
|
@ -249,7 +250,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
l.Text = group.Value[0];
|
l.Text = group.Value[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
torender.Add(l);
|
if(!string.IsNullOrEmpty(l.Text)) torender.Add(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -289,7 +289,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
l.Text = group.Value[0];
|
l.Text = group.Value[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
torender.Add(l);
|
if(!string.IsNullOrEmpty(l.Text)) torender.Add(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue