mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 05:41:45 +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;
|
||||
CANBLAST;
|
||||
NOBLOCKMONST;
|
||||
ALLOWTHRUFLAGS;
|
||||
THRUGHOST;
|
||||
THRUACTORS;
|
||||
THRUSPECIES;
|
||||
|
|
|
@ -292,21 +292,20 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This loads all data resources
|
||||
internal void Load(DataLocationList configlist, DataLocationList maplist, DataLocation maplocation)
|
||||
{
|
||||
DataLocationList all = DataLocationList.Combined(configlist, maplist);
|
||||
all.Remove(maplocation); //mxd. If maplocation was already added as a resource, make sure it's singular and is last in the list
|
||||
all.Add(maplocation);
|
||||
Load(all);
|
||||
//mxd. Don't modify original lists
|
||||
DataLocationList configlistcopy = new DataLocationList(configlist);
|
||||
DataLocationList maplistcopy = new DataLocationList(maplist);
|
||||
|
||||
//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
|
||||
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> colormapsonly = new Dictionary<long, ImageData>();
|
||||
|
@ -355,6 +354,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
resourcetextures = new List<ResourceTextureSet>();
|
||||
|
||||
// Go for all locations
|
||||
DataLocationList locations = DataLocationList.Combined(configlist, maplist); //mxd
|
||||
string prevofficialiwad = string.Empty; //mxd
|
||||
foreach(DataLocation dl in locations)
|
||||
{
|
||||
|
@ -372,7 +372,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
{
|
||||
// WAD file container
|
||||
case DataLocation.RESOURCE_WAD:
|
||||
c = new WADReader(dl);
|
||||
c = new WADReader(dl, configlist.Contains(dl));
|
||||
if(((WADReader)c).WadFile.IsOfficialIWAD) //mxd
|
||||
{
|
||||
if(!string.IsNullOrEmpty(prevofficialiwad))
|
||||
|
@ -383,12 +383,12 @@ namespace CodeImp.DoomBuilder.Data
|
|||
|
||||
// Directory container
|
||||
case DataLocation.RESOURCE_DIRECTORY:
|
||||
c = new DirectoryReader(dl);
|
||||
c = new DirectoryReader(dl, configlist.Contains(dl));
|
||||
break;
|
||||
|
||||
// PK3 file container
|
||||
case DataLocation.RESOURCE_PK3:
|
||||
c = new PK3Reader(dl);
|
||||
c = new PK3Reader(dl, configlist.Contains(dl));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using CodeImp.DoomBuilder.Compilers;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
using CodeImp.DoomBuilder.GZBuilder.Data;
|
||||
using CodeImp.DoomBuilder.ZDoom;
|
||||
|
@ -94,6 +95,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
protected DataLocation location;
|
||||
protected bool issuspended;
|
||||
protected bool isdisposed;
|
||||
protected bool isreadonly; //mxd
|
||||
protected ResourceTextureSet textureset;
|
||||
|
||||
#endregion
|
||||
|
@ -103,6 +105,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
public DataLocation Location { get { return location; } }
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
public bool IsSuspended { get { return issuspended; } }
|
||||
public bool IsReadOnly { get { return isreadonly; } } //mxd
|
||||
public ResourceTextureSet TextureSet { get { return textureset; } }
|
||||
|
||||
#endregion
|
||||
|
@ -110,10 +113,11 @@ namespace CodeImp.DoomBuilder.Data
|
|||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
protected DataReader(DataLocation dl)
|
||||
protected DataReader(DataLocation dl, bool asreadonly)
|
||||
{
|
||||
// Keep information
|
||||
location = dl;
|
||||
isreadonly = asreadonly;
|
||||
textureset = new ResourceTextureSet(GetTitle(), dl);
|
||||
}
|
||||
|
||||
|
@ -256,9 +260,23 @@ namespace CodeImp.DoomBuilder.Data
|
|||
//mxd. When implemented, this returns the voxel lump
|
||||
public abstract Stream GetVoxelData(string name);
|
||||
|
||||
//mxd
|
||||
#endregion
|
||||
|
||||
#region ================== Load/Save (mxd)
|
||||
|
||||
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, 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
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using CodeImp.DoomBuilder.Compilers;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
|
||||
#endregion
|
||||
|
@ -36,7 +37,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public DirectoryReader(DataLocation dl) : base(dl)
|
||||
public DirectoryReader(DataLocation dl, bool asreadonly) : base(dl, asreadonly)
|
||||
{
|
||||
General.WriteLogLine("Opening directory resource \"" + location.location + "\"");
|
||||
|
||||
|
@ -57,7 +58,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
foreach(string wadfile in wadfiles)
|
||||
{
|
||||
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
|
||||
internal override bool FileExists(string filename, int unused) { return files.FileExists(filename); } //mxd
|
||||
internal override bool FileExists(string filename)
|
||||
{
|
||||
return files.FileExists(filename);
|
||||
|
@ -473,6 +475,28 @@ namespace CodeImp.DoomBuilder.Data
|
|||
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
|
||||
// NOTE: Callers are responsible for removing the temp file when done!
|
||||
protected override string CreateTempFile(string filename)
|
||||
|
@ -484,5 +508,17 @@ namespace CodeImp.DoomBuilder.Data
|
|||
}
|
||||
|
||||
#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.Collections.Generic;
|
||||
using System.IO;
|
||||
using CodeImp.DoomBuilder.Compilers;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
using SharpCompress.Archive; //mxd
|
||||
using SharpCompress.Archive.Zip;
|
||||
using SharpCompress.Common; //mxd
|
||||
using SharpCompress.Reader; //mxd
|
||||
|
||||
|
@ -49,7 +51,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
#region ================== Constructor / Disposer
|
||||
|
||||
// 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 + "\"");
|
||||
|
||||
|
@ -66,6 +68,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// Random access of 7z archives works TERRIBLY slow in SharpCompress
|
||||
if(archivetype == ArchiveType.SevenZip)
|
||||
{
|
||||
isreadonly = true; // Unsaveable...
|
||||
sevenzipentries = new Dictionary<string, byte[]>(StringComparer.Ordinal);
|
||||
|
||||
IReader reader = archive.ExtractAllEntries();
|
||||
|
@ -410,6 +413,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
return files.FileExists(filename);
|
||||
|
@ -514,6 +518,26 @@ namespace CodeImp.DoomBuilder.Data
|
|||
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
|
||||
// NOTE: Callers are responsible for removing the temp file when done!
|
||||
protected override string CreateTempFile(string filename)
|
||||
|
@ -551,5 +575,17 @@ namespace CodeImp.DoomBuilder.Data
|
|||
}
|
||||
|
||||
#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
|
||||
|
||||
// Constructor
|
||||
protected PK3StructuredReader(DataLocation dl) : base(dl)
|
||||
protected PK3StructuredReader(DataLocation dl, bool asreadonly) : base(dl, asreadonly)
|
||||
{
|
||||
// Initialize
|
||||
this.roottextures = dl.option1;
|
||||
|
@ -79,7 +79,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
{
|
||||
string tempfile = CreateTempFile(w);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -874,6 +874,12 @@ namespace CodeImp.DoomBuilder.Data
|
|||
return anypath;
|
||||
}
|
||||
}
|
||||
|
||||
//mxd. Archives and Folders don't have lump indices
|
||||
internal override MemoryStream LoadFile(string name, int unused)
|
||||
{
|
||||
return LoadFile(name);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -20,10 +20,11 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using CodeImp.DoomBuilder.Compilers;
|
||||
using CodeImp.DoomBuilder.GZBuilder.Data;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
using CodeImp.DoomBuilder.ZDoom;
|
||||
using CodeImp.DoomBuilder.GZBuilder.Data;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -50,17 +51,17 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// Source
|
||||
private WAD file;
|
||||
private bool is_iwad;
|
||||
private readonly bool strictpatches;
|
||||
private bool strictpatches;
|
||||
|
||||
// Lump ranges
|
||||
private readonly List<LumpRange> flatranges;
|
||||
private readonly List<LumpRange> invertedflatranges; //mxd
|
||||
private readonly List<LumpRange> patchranges;
|
||||
private readonly List<LumpRange> spriteranges;
|
||||
private readonly List<LumpRange> textureranges;
|
||||
private readonly List<LumpRange> hiresranges; //mxd
|
||||
private readonly List<LumpRange> colormapranges;
|
||||
private readonly List<LumpRange> voxelranges; //mxd
|
||||
private List<LumpRange> flatranges;
|
||||
private List<LumpRange> invertedflatranges; //mxd
|
||||
private List<LumpRange> patchranges;
|
||||
private List<LumpRange> spriteranges;
|
||||
private List<LumpRange> textureranges;
|
||||
private List<LumpRange> hiresranges; //mxd
|
||||
private List<LumpRange> colormapranges;
|
||||
private List<LumpRange> voxelranges; //mxd
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -74,17 +75,49 @@ namespace CodeImp.DoomBuilder.Data
|
|||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public WADReader(DataLocation dl) : base(dl)
|
||||
public WADReader(DataLocation dl, bool asreadonly) : base(dl, asreadonly)
|
||||
{
|
||||
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(); //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
|
||||
file = new WAD(location.location, true);
|
||||
is_iwad = file.IsIWAD;
|
||||
strictpatches = dl.option1;
|
||||
patchranges = new List<LumpRange>();
|
||||
spriteranges = 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};
|
||||
invertedflatranges.Add(range);
|
||||
}
|
||||
|
||||
// We have no destructor
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
// Disposer
|
||||
|
@ -1081,7 +1111,10 @@ namespace CodeImp.DoomBuilder.Data
|
|||
return result;
|
||||
}
|
||||
|
||||
//mxd
|
||||
#endregion
|
||||
|
||||
#region ================== IO (mxd)
|
||||
|
||||
internal override MemoryStream LoadFile(string name)
|
||||
{
|
||||
Lump l = file.FindLump(name);
|
||||
|
@ -1095,10 +1128,93 @@ namespace CodeImp.DoomBuilder.Data
|
|||
return null;
|
||||
}
|
||||
|
||||
//mxd
|
||||
internal override bool FileExists(string name)
|
||||
internal override MemoryStream LoadFile(string name, int lumpindex)
|
||||
{
|
||||
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
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace CodeImp.DoomBuilder
|
|||
private D3DDevice graphics;
|
||||
private Renderer2D renderer2d;
|
||||
private Renderer3D renderer3d;
|
||||
private WAD tempwad;
|
||||
private WADReader tempwadreader;
|
||||
private GridSetup grid;
|
||||
private UndoManager undoredo;
|
||||
private CopyPasteManager copypaste;
|
||||
|
@ -122,6 +122,7 @@ namespace CodeImp.DoomBuilder
|
|||
internal ScriptEditorForm ScriptEditor { get { return scriptwindow; } }
|
||||
public VisualCamera VisualCamera { get { return visualcamera; } set { visualcamera = value; } }
|
||||
public bool IsScriptsWindowOpen { get { return (scriptwindow != null) && !scriptwindow.IsDisposed; } }
|
||||
internal WADReader TemporaryMapFile { get { return tempwadreader; } } //mxd
|
||||
|
||||
//mxd. Map format
|
||||
public bool UDMF { get { return config.UDMF; } }
|
||||
|
@ -193,7 +194,7 @@ namespace CodeImp.DoomBuilder
|
|||
General.WriteLogLine("Unloading data resources...");
|
||||
if(data != null) data.Dispose();
|
||||
General.WriteLogLine("Closing temporary file...");
|
||||
if(tempwad != null) tempwad.Dispose();
|
||||
if(tempwadreader != null) tempwadreader.Dispose(); //mxd
|
||||
General.WriteLogLine("Unloading map data...");
|
||||
if(map != null) map.Dispose();
|
||||
General.WriteLogLine("Stopping graphics device...");
|
||||
|
@ -206,7 +207,7 @@ namespace CodeImp.DoomBuilder
|
|||
copypaste = null;
|
||||
undoredo = null;
|
||||
data = null;
|
||||
tempwad = null;
|
||||
tempwadreader = null; //mxd
|
||||
map = null;
|
||||
renderer2d = null;
|
||||
renderer3d = null;
|
||||
|
@ -278,12 +279,12 @@ namespace CodeImp.DoomBuilder
|
|||
map = new MapSet();
|
||||
|
||||
// Create temp wadfile
|
||||
string tempfile = General.MakeTempFilename(temppath);
|
||||
General.WriteLogLine("Creating temporary file: " + tempfile);
|
||||
DataLocation templocation = new DataLocation(DataLocation.RESOURCE_WAD, General.MakeTempFilename(temppath), false, false, false); //mxd
|
||||
General.WriteLogLine("Creating temporary file: " + templocation.location);
|
||||
#if DEBUG
|
||||
tempwad = new WAD(tempfile);
|
||||
tempwadreader = new WADReader(templocation, false, true);
|
||||
#else
|
||||
try { tempwad = new WAD(tempfile); }
|
||||
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);
|
||||
|
@ -293,13 +294,13 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// Read the map from temp file
|
||||
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
|
||||
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);
|
||||
CreateRequiredLumps(tempwad, TEMP_MAP_HEADER);
|
||||
CreateRequiredLumps(tempwadreader.WadFile, TEMP_MAP_HEADER);
|
||||
|
||||
// Load data manager
|
||||
General.WriteLogLine("Loading data resources...");
|
||||
|
@ -373,12 +374,12 @@ namespace CodeImp.DoomBuilder
|
|||
map = new MapSet();
|
||||
|
||||
// Create temp wadfile
|
||||
string tempfile = General.MakeTempFilename(temppath);
|
||||
General.WriteLogLine("Creating temporary file: " + tempfile);
|
||||
DataLocation templocation = new DataLocation(DataLocation.RESOURCE_WAD, General.MakeTempFilename(temppath), false, false, false); //mxd
|
||||
General.WriteLogLine("Creating temporary file: " + templocation.location);
|
||||
#if DEBUG
|
||||
tempwad = new WAD(tempfile);
|
||||
tempwadreader = new WADReader(templocation, false, true);
|
||||
#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);
|
||||
return false;
|
||||
|
@ -399,7 +400,7 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// Copy the map lumps to the temp 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
|
||||
mapwad.Dispose();
|
||||
|
@ -466,14 +467,14 @@ namespace CodeImp.DoomBuilder
|
|||
WAD mapwad;
|
||||
|
||||
// Create temp wadfile
|
||||
string tempfile = General.MakeTempFilename(temppath);
|
||||
General.WriteLogLine("Creating temporary file: " + tempfile);
|
||||
if(tempwad != null) tempwad.Dispose();
|
||||
DataLocation templocation = new DataLocation(DataLocation.RESOURCE_WAD, General.MakeTempFilename(temppath), false, false, false); //mxd
|
||||
General.WriteLogLine("Creating temporary file: " + templocation.location);
|
||||
if(tempwadreader != null) tempwadreader.Dispose();
|
||||
|
||||
#if DEBUG
|
||||
tempwad = new WAD(tempfile);
|
||||
tempwadreader = new WADReader(templocation, false, true);
|
||||
#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);
|
||||
return false;
|
||||
|
@ -495,7 +496,7 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// Copy the map lumps to the temp 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
|
||||
mapwad.Dispose();
|
||||
|
@ -559,7 +560,7 @@ namespace CodeImp.DoomBuilder
|
|||
+ "Would you like to restore the map from the backup?", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
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 + "\"...");
|
||||
|
||||
#if DEBUG
|
||||
|
@ -591,7 +592,7 @@ namespace CodeImp.DoomBuilder
|
|||
{
|
||||
newmap.BeginAddRemove();
|
||||
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...");
|
||||
#if DEBUG
|
||||
newmap = io.Read(newmap, TEMP_MAP_HEADER);
|
||||
|
@ -699,7 +700,7 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// Write to temporary 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);
|
||||
outputset.Dispose();
|
||||
|
||||
|
@ -772,7 +773,7 @@ namespace CodeImp.DoomBuilder
|
|||
else
|
||||
{
|
||||
// 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?
|
||||
|
@ -969,7 +970,7 @@ namespace CodeImp.DoomBuilder
|
|||
}
|
||||
|
||||
// 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?
|
||||
if(options.LevelNameChanged)
|
||||
|
@ -1172,14 +1173,14 @@ namespace CodeImp.DoomBuilder
|
|||
#endif
|
||||
|
||||
// Determine source file
|
||||
string sourcefile = (filepathname.Length > 0 ? filepathname : tempwad.Filename);
|
||||
string sourcefile = (filepathname.Length > 0 ? filepathname : tempwadreader.WadFile.Filename);
|
||||
|
||||
//mxd.
|
||||
RemoveUnneededLumps(tempwad, TEMP_MAP_HEADER, true);
|
||||
RemoveUnneededLumps(tempwadreader.WadFile, TEMP_MAP_HEADER, true);
|
||||
|
||||
// Copy lumps to buildwad
|
||||
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
|
||||
buildwad.Dispose();
|
||||
|
@ -1224,7 +1225,7 @@ namespace CodeImp.DoomBuilder
|
|||
{
|
||||
// Copy nodebuilder lumps to temp 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
|
||||
{
|
||||
|
@ -1309,7 +1310,7 @@ namespace CodeImp.DoomBuilder
|
|||
// This is copied from the temp wad file and returns null when the lump is not found
|
||||
public MemoryStream GetLumpData(string lumpname)
|
||||
{
|
||||
Lump l = tempwad.FindLump(lumpname);
|
||||
Lump l = tempwadreader.WadFile.FindLump(lumpname);
|
||||
if(l != null)
|
||||
{
|
||||
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
|
||||
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
|
||||
int li = tempwad.FindLumpIndex(lumpname);
|
||||
int li = tempwadreader.WadFile.FindLumpIndex(lumpname);
|
||||
if(li > -1)
|
||||
{
|
||||
insertindex = li;
|
||||
tempwad.RemoveAt(li);
|
||||
tempwadreader.WadFile.RemoveAt(li);
|
||||
}
|
||||
|
||||
// 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);
|
||||
lumpdata.WriteTo(l.Stream);
|
||||
|
||||
|
@ -1343,7 +1344,7 @@ namespace CodeImp.DoomBuilder
|
|||
// This checks if the specified lump exists in the temp file
|
||||
public bool LumpExists(string lumpname)
|
||||
{
|
||||
return (tempwad.FindLumpIndex(lumpname) > -1);
|
||||
return (tempwadreader.WadFile.FindLumpIndex(lumpname) > -1);
|
||||
}
|
||||
|
||||
// This creates empty lumps for those required
|
||||
|
@ -2002,11 +2003,11 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// Find the lump
|
||||
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 + "\".");
|
||||
|
||||
// Determine source file
|
||||
string sourcefile = (filepathname.Length > 0 ? filepathname : tempwad.Filename);
|
||||
string sourcefile = (filepathname.Length > 0 ? filepathname : tempwadreader.WadFile.Filename);
|
||||
|
||||
// New list of errors
|
||||
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
|
||||
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);
|
||||
if(parser.Parse(data, scriptconfig.Compiler.Files, true, AcsParserSE.IncludeType.NONE, false))
|
||||
{
|
||||
|
@ -2431,14 +2432,14 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// Setup new map format IO
|
||||
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.
|
||||
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
|
||||
CreateRequiredLumps(tempwad, TEMP_MAP_HEADER);
|
||||
CreateRequiredLumps(tempwadreader.WadFile, TEMP_MAP_HEADER);
|
||||
|
||||
// Let the plugins know
|
||||
General.Plugins.MapReconfigure();
|
||||
|
|
|
@ -249,9 +249,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//render hint
|
||||
if(horizontalslices > 1 || verticalslices > 1)
|
||||
{
|
||||
hintlabel.Text = "H: " + (slicesH - 1) + "; V: " + (slicesV - 1);
|
||||
if(width > hintlabel.Text.Length * vsize && height > 16 * vsize)
|
||||
string text = "H: " + (slicesH - 1) + "; V: " + (slicesV - 1);
|
||||
if(width > text.Length * vsize && height > 16 * vsize)
|
||||
{
|
||||
hintlabel.Text = text;
|
||||
hintlabel.Move(start, end);
|
||||
renderer.RenderText(hintlabel.TextLabel);
|
||||
}
|
||||
|
|
|
@ -656,7 +656,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
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++)
|
||||
{
|
||||
// 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);
|
||||
|
@ -249,7 +250,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
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];
|
||||
}
|
||||
|
||||
torender.Add(l);
|
||||
if(!string.IsNullOrEmpty(l.Text)) torender.Add(l);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue