mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +00:00
completed saving, also 'save as' works
This commit is contained in:
parent
61e78baf10
commit
6c5fae98b0
33 changed files with 388 additions and 115 deletions
|
@ -154,7 +154,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -166,6 +166,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -149,6 +149,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -160,6 +161,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -149,7 +149,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -161,6 +161,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -152,7 +152,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -164,6 +164,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -149,7 +149,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -161,6 +161,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -150,7 +150,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -162,6 +162,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -149,7 +149,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -161,6 +161,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -138,7 +138,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -150,9 +150,9 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~
|
||||
~MAP
|
||||
{
|
||||
required = false;
|
||||
required = true;
|
||||
nodebuild = false;
|
||||
script = "Legacy_FS.cfg";
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -162,6 +162,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -154,7 +154,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -166,6 +166,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -154,7 +154,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -166,6 +166,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -149,7 +149,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -161,6 +161,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -149,7 +149,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -161,6 +161,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -154,7 +154,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -166,6 +166,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -154,7 +154,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -166,6 +166,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -154,7 +154,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -166,6 +166,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -154,7 +154,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -166,6 +166,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -153,7 +153,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -165,6 +165,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -150,7 +150,7 @@ MAP LUMP NAMES
|
|||
Map lumps are loaded with the map as long as they are right after each other. When the editor
|
||||
meets a lump which is not defined in this list it will ignore the map if not satisfied.
|
||||
The order of items defines the order in which lumps will be written to WAD file on save.
|
||||
To indicate the map header lump, use tilde: ~
|
||||
To indicate the map header lump, use ~MAP
|
||||
|
||||
Legenda:
|
||||
required = Lump is required to exist.
|
||||
|
@ -162,6 +162,13 @@ script = This lump is a text-based script. Specify the filename of the script co
|
|||
|
||||
maplumpnames
|
||||
{
|
||||
~MAP
|
||||
{
|
||||
required = true;
|
||||
blindcopy = true;
|
||||
nodebuild = false;
|
||||
}
|
||||
|
||||
THINGS
|
||||
{
|
||||
required = true;
|
||||
|
|
|
@ -621,6 +621,10 @@ namespace CodeImp.DoomBuilder
|
|||
openfile = new OpenFileDialog();
|
||||
openfile.Filter = "Doom WAD Files (*.wad)|*.wad";
|
||||
openfile.Title = "Open Map";
|
||||
openfile.AddExtension = false;
|
||||
openfile.CheckFileExists = true;
|
||||
openfile.Multiselect = false;
|
||||
openfile.ValidateNames = true;
|
||||
if(openfile.ShowDialog(mainwindow) == DialogResult.OK)
|
||||
{
|
||||
// Update main window
|
||||
|
@ -685,7 +689,8 @@ namespace CodeImp.DoomBuilder
|
|||
// Check if a wad file is known
|
||||
if(map.FilePathName == "")
|
||||
{
|
||||
// TODO: Call to SaveMapAs!
|
||||
// Call to SaveMapAs
|
||||
SaveMapAs();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -693,6 +698,27 @@ namespace CodeImp.DoomBuilder
|
|||
map.SaveMap(map.FilePathName, MapManager.SAVE_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
// This saves the current map as a different file
|
||||
[Action(Action.SAVEMAPAS)]
|
||||
public static void SaveMapAs()
|
||||
{
|
||||
SaveFileDialog savefile;
|
||||
|
||||
// Show save as dialog
|
||||
savefile = new SaveFileDialog();
|
||||
savefile.Filter = "Doom WAD Files (*.wad)|*.wad";
|
||||
savefile.Title = "Save Map As";
|
||||
savefile.AddExtension = true;
|
||||
savefile.CheckPathExists = true;
|
||||
savefile.OverwritePrompt = true;
|
||||
savefile.ValidateNames = true;
|
||||
if(savefile.ShowDialog(mainwindow) == DialogResult.OK)
|
||||
{
|
||||
// Save the map
|
||||
map.SaveMap(savefile.FileName, MapManager.SAVE_AS);
|
||||
}
|
||||
}
|
||||
|
||||
// This asks to save the map if needed
|
||||
// Returns false when action was cancelled
|
||||
|
|
|
@ -43,6 +43,7 @@ namespace CodeImp.DoomBuilder
|
|||
// Map header name in temporary file
|
||||
private const string TEMP_MAP_HEADER = "TEMPMAP";
|
||||
private const string BUILD_MAP_HEADER = "MAP01";
|
||||
public const string CONFIG_MAP_HEADER = "~MAP";
|
||||
|
||||
// Save modes
|
||||
public const int SAVE_NORMAL = 0;
|
||||
|
@ -137,7 +138,7 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
#endregion
|
||||
|
||||
#region ================== Initialize
|
||||
#region ================== New / Open
|
||||
|
||||
// Initializes for a new map
|
||||
public bool InitializeNewMap(MapOptions options)
|
||||
|
@ -274,11 +275,12 @@ namespace CodeImp.DoomBuilder
|
|||
#region ================== Save
|
||||
|
||||
// Initializes for an existing map
|
||||
public bool SaveMap(string filepathname, int savemode)
|
||||
public bool SaveMap(string newfilepathname, int savemode)
|
||||
{
|
||||
MapSet outputset;
|
||||
int insertindex;
|
||||
string nodebuildername;
|
||||
WAD targetwad;
|
||||
int index;
|
||||
|
||||
// Make a copy of the map data
|
||||
outputset = map.Clone();
|
||||
|
@ -302,9 +304,9 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// Write to temporary file
|
||||
General.WriteLogLine("Writing map data structures to file...");
|
||||
insertindex = tempwad.FindLumpIndex(TEMP_MAP_HEADER);
|
||||
if(insertindex == -1) insertindex = 0;
|
||||
io.Write(outputset, TEMP_MAP_HEADER, insertindex);
|
||||
index = tempwad.FindLumpIndex(TEMP_MAP_HEADER);
|
||||
if(index == -1) index = 0;
|
||||
io.Write(outputset, TEMP_MAP_HEADER, index);
|
||||
|
||||
// Get the corresponding nodebuilder
|
||||
if(savemode == SAVE_TEST) nodebuildername = configinfo.NodebuilderTest;
|
||||
|
@ -317,11 +319,52 @@ namespace CodeImp.DoomBuilder
|
|||
// Suspend data resources
|
||||
data.Suspend();
|
||||
|
||||
// On save AS we have to copy the previous file to the new file
|
||||
if((savemode == SAVE_AS) && (filepathname != ""))
|
||||
{
|
||||
// Copy if oriignal file still exists
|
||||
if(File.Exists(filepathname))
|
||||
File.Copy(filepathname, newfilepathname, true);
|
||||
}
|
||||
|
||||
// Open the target file
|
||||
targetwad = new WAD(newfilepathname);
|
||||
|
||||
// Copy map lumps to target file
|
||||
CopyLumpsByType(tempwad, TEMP_MAP_HEADER, targetwad, options.CurrentName, true, true, true, true);
|
||||
|
||||
// Was the map lump name renamed?
|
||||
if((options.PreviousName != options.CurrentName) &&
|
||||
(options.PreviousName != ""))
|
||||
{
|
||||
General.WriteLogLine("Renaming map lump name from " + options.PreviousName + " to " + options.CurrentName);
|
||||
|
||||
// Find the map header in target
|
||||
index = targetwad.FindLumpIndex(options.PreviousName);
|
||||
if(index > -1)
|
||||
{
|
||||
// Rename the map lump name
|
||||
targetwad.Lumps[index].Rename(options.CurrentName);
|
||||
options.PreviousName = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Houston, we've got a problem!
|
||||
General.ShowErrorMessage("Error renaming map lump name: the original map lump could not be found!", MessageBoxButtons.OK);
|
||||
options.CurrentName = options.PreviousName;
|
||||
options.PreviousName = "";
|
||||
}
|
||||
}
|
||||
|
||||
// Done with the target file
|
||||
targetwad.Dispose();
|
||||
|
||||
// Resume data resources
|
||||
data.Resume();
|
||||
|
||||
// Success!
|
||||
filepathname = newfilepathname;
|
||||
filetitle = Path.GetFileName(filepathname);
|
||||
changed = false;
|
||||
return true;
|
||||
}
|
||||
|
@ -448,7 +491,7 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
#region ================== Lumps
|
||||
|
||||
// This copies specific map lumps from one WAD to another
|
||||
private void CopyLumpsByType(WAD source, string sourcemapname,
|
||||
|
@ -457,33 +500,30 @@ namespace CodeImp.DoomBuilder
|
|||
bool copynodebuild, bool copyscript)
|
||||
{
|
||||
bool lumprequired, lumpblindcopy, lumpnodebuild;
|
||||
string lumpscript;
|
||||
int srcindex, tgtindex;
|
||||
string lumpscript, srclumpname, tgtlumpname;
|
||||
int srcheaderindex, tgtheaderindex, targetindex, sourceindex, lumpindex;
|
||||
IDictionary maplumps;
|
||||
Lump lump, newlump;
|
||||
|
||||
// Find the map header in target
|
||||
tgtindex = target.FindLumpIndex(targetmapname);
|
||||
if(tgtindex > -1)
|
||||
{
|
||||
// Remove the lumps from target
|
||||
RemoveLumpsByType(target, targetmapname, copyrequired,
|
||||
copyblindcopy, copynodebuild, copyscript);
|
||||
}
|
||||
else
|
||||
tgtheaderindex = target.FindLumpIndex(targetmapname);
|
||||
if(tgtheaderindex == -1)
|
||||
{
|
||||
// If this header doesnt exists in the target
|
||||
// then insert at the end of the target
|
||||
tgtindex = target.Lumps.Count;
|
||||
tgtheaderindex = target.Lumps.Count;
|
||||
}
|
||||
|
||||
// Begin inserting at target header index
|
||||
targetindex = tgtheaderindex;
|
||||
|
||||
// Find the map header in source
|
||||
srcindex = source.FindLumpIndex(sourcemapname);
|
||||
if(srcindex > -1)
|
||||
srcheaderindex = source.FindLumpIndex(sourcemapname);
|
||||
if(srcheaderindex > -1)
|
||||
{
|
||||
// Copy the map header from source to target
|
||||
newlump = target.Insert(targetmapname, tgtindex++, source.Lumps[srcindex].Length);
|
||||
source.Lumps[srcindex].CopyTo(newlump);
|
||||
//newlump = target.Insert(targetmapname, tgtindex++, source.Lumps[srcindex].Length);
|
||||
//source.Lumps[srcindex].CopyTo(newlump);
|
||||
|
||||
// Go for all the map lump names
|
||||
maplumps = config.ReadSetting("maplumpnames", new Hashtable());
|
||||
|
@ -499,13 +539,29 @@ namespace CodeImp.DoomBuilder
|
|||
if((lumprequired && copyrequired) || (lumpblindcopy && copyblindcopy) ||
|
||||
(lumpnodebuild && copynodebuild) || ((lumpscript != "") && copyscript))
|
||||
{
|
||||
// Get the lump name
|
||||
srclumpname = ml.Key.ToString();
|
||||
tgtlumpname = ml.Key.ToString();
|
||||
if(srclumpname == CONFIG_MAP_HEADER) srclumpname = sourcemapname;
|
||||
if(tgtlumpname == CONFIG_MAP_HEADER) tgtlumpname = targetmapname;
|
||||
|
||||
// Find the lump in the source
|
||||
lump = source.FindLump(ml.Key.ToString(), srcindex, srcindex + maplumps.Count + 2);
|
||||
if(lump != null)
|
||||
sourceindex = FindSpecificLump(source, srclumpname, srcheaderindex, sourcemapname, maplumps);
|
||||
if(sourceindex > -1)
|
||||
{
|
||||
// Remove lump at target
|
||||
lumpindex = RemoveSpecificLump(target, tgtlumpname, tgtheaderindex, targetmapname, maplumps);
|
||||
|
||||
// Determine target index
|
||||
// When original lump was found and removed then insert at that position
|
||||
// otherwise insert after last insertion position
|
||||
if(lumpindex > -1) targetindex = lumpindex; else targetindex++;
|
||||
if(targetindex > target.Lumps.Count) targetindex = target.Lumps.Count;
|
||||
|
||||
// Copy the lump to the target
|
||||
//General.WriteLogLine(ml.Key.ToString() + " copying");
|
||||
newlump = target.Insert(ml.Key.ToString(), tgtindex++, lump.Length);
|
||||
//General.WriteLogLine(srclumpname + " copying as " + tgtlumpname);
|
||||
lump = source.Lumps[sourceindex];
|
||||
newlump = target.Insert(tgtlumpname, targetindex, lump.Length);
|
||||
lump.CopyTo(newlump);
|
||||
}
|
||||
else
|
||||
|
@ -517,55 +573,69 @@ namespace CodeImp.DoomBuilder
|
|||
}
|
||||
}
|
||||
|
||||
// This copies specific map lumps from one WAD to another
|
||||
private void RemoveLumpsByType(WAD source, string sourcemapname,
|
||||
bool removerequired, bool removeblindcopy,
|
||||
bool removenodebuild, bool removescript)
|
||||
// This finds a lump within the range of known lump names
|
||||
// Returns -1 when the lump cannot be found
|
||||
private int FindSpecificLump(WAD source, string lumpname, int mapheaderindex, string mapheadername, IDictionary maplumps)
|
||||
{
|
||||
bool lumprequired, lumpblindcopy, lumpnodebuild;
|
||||
string nextlumpname, lumpscript;
|
||||
int index;
|
||||
|
||||
// Find the map header in target
|
||||
index = source.FindLumpIndex(sourcemapname);
|
||||
if(index > -1)
|
||||
// Use the configured map lump names to find the specific lump within range,
|
||||
// because when an unknown lump is met, this search must stop.
|
||||
|
||||
// Go for all lumps in order to find the specified lump
|
||||
for(int i = 0; i < maplumps.Count + 1; i++)
|
||||
{
|
||||
// Remove the header from target
|
||||
source.RemoveAt(index);
|
||||
|
||||
// Get the name of the next lump
|
||||
if(index < source.Lumps.Count) nextlumpname = source.Lumps[index].Name;
|
||||
else nextlumpname = "";
|
||||
|
||||
// Do we recognize this lump type?
|
||||
while(config.ReadSetting("maplumpnames." + nextlumpname, (IDictionary)null) != null)
|
||||
// Still within bounds?
|
||||
if((mapheaderindex + i) < source.Lumps.Count)
|
||||
{
|
||||
// Read lump settings from map config
|
||||
lumprequired = config.ReadSetting("maplumpnames." + nextlumpname + ".required", false);
|
||||
lumpblindcopy = config.ReadSetting("maplumpnames." + nextlumpname + ".blindcopy", false);
|
||||
lumpnodebuild = config.ReadSetting("maplumpnames." + nextlumpname + ".nodebuild", false);
|
||||
lumpscript = config.ReadSetting("maplumpnames." + nextlumpname + ".script", "");
|
||||
|
||||
// Check if this lump will be removed from target
|
||||
if((lumprequired && removerequired) || (lumpblindcopy && removeblindcopy) ||
|
||||
(lumpnodebuild && removenodebuild) || ((lumpscript != "") && removescript))
|
||||
// Check if this is a known lump name
|
||||
if(maplumps.Contains(source.Lumps[mapheaderindex + i].Name) ||
|
||||
(maplumps.Contains(CONFIG_MAP_HEADER) && (source.Lumps[mapheaderindex + i].Name == mapheadername)))
|
||||
{
|
||||
// Then remove it from target
|
||||
//General.WriteLogLine(nextlumpname + " removing");
|
||||
source.RemoveAt(index);
|
||||
// Is this the lump we are looking for?
|
||||
if(source.Lumps[mapheaderindex + i].Name == lumpname)
|
||||
{
|
||||
// Return this index
|
||||
return mapheaderindex + i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Advance to the next lump
|
||||
index++;
|
||||
// Unknown lump hit, abort search
|
||||
break;
|
||||
}
|
||||
|
||||
// Get the name of the next lump
|
||||
if(index < source.Lumps.Count) nextlumpname = source.Lumps[index].Name;
|
||||
else nextlumpname = "";
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing found
|
||||
return -1;
|
||||
}
|
||||
|
||||
// This removes a specific lump and returns the position where the lump was removed
|
||||
// Returns -1 when the lump could not be found
|
||||
private int RemoveSpecificLump(WAD source, string lumpname, int mapheaderindex, string mapheadername, IDictionary maplumps)
|
||||
{
|
||||
int lumpindex;
|
||||
|
||||
// Find the specific lump index
|
||||
lumpindex = FindSpecificLump(source, lumpname, mapheaderindex, mapheadername, maplumps);
|
||||
if(lumpindex > -1)
|
||||
{
|
||||
// Remove this lump
|
||||
//General.WriteLogLine(lumpname + " removed");
|
||||
source.RemoveAt(lumpindex);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Lump not found
|
||||
General.WriteLogLine("WARNING: " + lumpname + " should be removed but was not found!");
|
||||
}
|
||||
|
||||
// Return result
|
||||
return lumpindex;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This changes editing mode
|
||||
public void ChangeMode(Type modetype, params object[] args)
|
||||
|
@ -580,7 +650,7 @@ namespace CodeImp.DoomBuilder
|
|||
// Redraw the display
|
||||
General.MainWindow.RedrawDisplay();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
|
||||
// Create new item
|
||||
s = map.CreateSector();
|
||||
s.Update(hfloor, hceil, tfloor, tceil, special, tag);
|
||||
s.Update(hfloor, hceil, tfloor, tceil, special, tag, bright);
|
||||
|
||||
// Add it to the lookup table
|
||||
link.Add(i, s);
|
||||
|
@ -340,9 +340,9 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// Write properties to stream
|
||||
writer.Write((Int16)t.Position.x);
|
||||
writer.Write((Int16)t.Position.y);
|
||||
writer.Write((Int16)0); // TODO: Fix this!
|
||||
writer.Write((Int16)t.Angle); // TODO: Fix this!
|
||||
writer.Write((UInt16)t.Type);
|
||||
writer.Write((UInt16)0); // TODO: Fix this!
|
||||
writer.Write((UInt16)t.Flags);
|
||||
}
|
||||
|
||||
// Find insert position and remove old lump
|
||||
|
@ -404,9 +404,9 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// Write properties to stream
|
||||
writer.Write((UInt16)vertexids[l.Start]);
|
||||
writer.Write((UInt16)vertexids[l.End]);
|
||||
writer.Write((UInt16)0); // TODO: Fix this!
|
||||
writer.Write((UInt16)0); // TODO: Fix this!
|
||||
writer.Write((UInt16)0); // TODO: Fix this!
|
||||
writer.Write((UInt16)l.Flags);
|
||||
writer.Write((UInt16)l.Action);
|
||||
writer.Write((UInt16)l.Tag);
|
||||
|
||||
// Front sidedef
|
||||
if(l.Front == null) sid = ushort.MaxValue;
|
||||
|
@ -445,11 +445,11 @@ namespace CodeImp.DoomBuilder.IO
|
|||
foreach(Sidedef sd in map.Sidedefs)
|
||||
{
|
||||
// Write properties to stream
|
||||
writer.Write((Int16)0); // TODO: Fix this!
|
||||
writer.Write((Int16)0); // TODO: Fix this!
|
||||
writer.Write(Lump.MakeFixedName("", WAD.ENCODING)); // TODO: Fix this!
|
||||
writer.Write(Lump.MakeFixedName("", WAD.ENCODING)); // TODO: Fix this!
|
||||
writer.Write(Lump.MakeFixedName("", WAD.ENCODING)); // TODO: Fix this!
|
||||
writer.Write((Int16)sd.OffsetX);
|
||||
writer.Write((Int16)sd.OffsetY);
|
||||
writer.Write(Lump.MakeFixedName(sd.HighTexture, WAD.ENCODING));
|
||||
writer.Write(Lump.MakeFixedName(sd.MiddleTexture, WAD.ENCODING));
|
||||
writer.Write(Lump.MakeFixedName(sd.LowTexture, WAD.ENCODING));
|
||||
writer.Write((UInt16)sectorids[sd.Sector]);
|
||||
}
|
||||
|
||||
|
@ -479,13 +479,13 @@ namespace CodeImp.DoomBuilder.IO
|
|||
foreach(Sector s in map.Sectors)
|
||||
{
|
||||
// Write properties to stream
|
||||
writer.Write((Int16)0); // TODO: Fix this!
|
||||
writer.Write((Int16)0); // TODO: Fix this!
|
||||
writer.Write(Lump.MakeFixedName("", WAD.ENCODING)); // TODO: Fix this!
|
||||
writer.Write(Lump.MakeFixedName("", WAD.ENCODING)); // TODO: Fix this!
|
||||
writer.Write((Int16)0); // TODO: Fix this!
|
||||
writer.Write((UInt16)0); // TODO: Fix this!
|
||||
writer.Write((UInt16)0); // TODO: Fix this!
|
||||
writer.Write((Int16)s.FloorHeight);
|
||||
writer.Write((Int16)s.CeilHeight);
|
||||
writer.Write(Lump.MakeFixedName(s.FloorTexture, WAD.ENCODING));
|
||||
writer.Write(Lump.MakeFixedName(s.CeilTexture, WAD.ENCODING));
|
||||
writer.Write((Int16)s.Brightness);
|
||||
writer.Write((UInt16)s.Special);
|
||||
writer.Write((UInt16)s.Tag);
|
||||
}
|
||||
|
||||
// Find insert position and remove old lump
|
||||
|
|
|
@ -162,6 +162,18 @@ namespace CodeImp.DoomBuilder.IO
|
|||
return name;
|
||||
}
|
||||
|
||||
// This renames the lump
|
||||
public void Rename(string newname)
|
||||
{
|
||||
// Make name
|
||||
this.fixedname = MakeFixedName(newname, WAD.ENCODING);
|
||||
this.name = MakeNormalName(this.fixedname, WAD.ENCODING).ToUpperInvariant();
|
||||
this.longname = MakeLongName(newname);
|
||||
|
||||
// Write changes
|
||||
owner.WriteHeaders();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
}
|
||||
|
||||
// This reads the WAD header and lumps table
|
||||
private void WriteHeaders()
|
||||
public void WriteHeaders()
|
||||
{
|
||||
// Seek to beginning
|
||||
file.Seek(0, SeekOrigin.Begin);
|
||||
|
@ -312,7 +312,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// Write the new headers
|
||||
WriteHeaders();
|
||||
}
|
||||
|
||||
|
||||
// This finds a lump by name, returns null when not found
|
||||
public Lump FindLump(string name)
|
||||
{
|
||||
|
|
7
Source/Interface/MainForm.Designer.cs
generated
7
Source/Interface/MainForm.Designer.cs
generated
|
@ -178,6 +178,7 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
//
|
||||
this.itemsavemapas.Name = "itemsavemapas";
|
||||
this.itemsavemapas.Size = new System.Drawing.Size(201, 22);
|
||||
this.itemsavemapas.Tag = "savemapas";
|
||||
this.itemsavemapas.Text = "Save Map As...";
|
||||
this.itemsavemapas.Click += new System.EventHandler(this.InvokeTaggedAction);
|
||||
//
|
||||
|
@ -263,7 +264,7 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.buttonnewmap.Name = "buttonnewmap";
|
||||
this.buttonnewmap.Size = new System.Drawing.Size(23, 22);
|
||||
this.buttonnewmap.Tag = "newmap";
|
||||
this.buttonnewmap.Text = "toolStripButton1";
|
||||
this.buttonnewmap.Text = "New Map";
|
||||
this.buttonnewmap.Click += new System.EventHandler(this.InvokeTaggedAction);
|
||||
//
|
||||
// buttonopenmap
|
||||
|
@ -274,7 +275,7 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.buttonopenmap.Name = "buttonopenmap";
|
||||
this.buttonopenmap.Size = new System.Drawing.Size(23, 22);
|
||||
this.buttonopenmap.Tag = "openmap";
|
||||
this.buttonopenmap.Text = "toolStripButton1";
|
||||
this.buttonopenmap.Text = "Open Map";
|
||||
this.buttonopenmap.Click += new System.EventHandler(this.InvokeTaggedAction);
|
||||
//
|
||||
// buttonsavemap
|
||||
|
@ -285,7 +286,7 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.buttonsavemap.Name = "buttonsavemap";
|
||||
this.buttonsavemap.Size = new System.Drawing.Size(23, 22);
|
||||
this.buttonsavemap.Tag = "savemap";
|
||||
this.buttonsavemap.Text = "toolStripButton1";
|
||||
this.buttonsavemap.Text = "Save Map";
|
||||
this.buttonsavemap.Click += new System.EventHandler(this.InvokeTaggedAction);
|
||||
//
|
||||
// statusbar
|
||||
|
|
|
@ -492,6 +492,11 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
itemsavemap.Enabled = (General.Map != null);
|
||||
itemsavemapas.Enabled = (General.Map != null);
|
||||
itemsavemapinto.Enabled = (General.Map != null);
|
||||
|
||||
// Toolbar icons
|
||||
buttonnewmap.Enabled = itemnewmap.Enabled;
|
||||
buttonopenmap.Enabled = itemopenmap.Enabled;
|
||||
buttonsavemap.Enabled = itemsavemap.Enabled;
|
||||
}
|
||||
|
||||
// This sets the recent files from configuration
|
||||
|
|
|
@ -210,8 +210,12 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
// Count how many required lumps we have to find
|
||||
foreach(DictionaryEntry ml in maplumpnames)
|
||||
{
|
||||
// Read lump setting and count it
|
||||
if(cfg.ReadSetting("maplumpnames." + ml.Key + ".required", false)) lumpsrequired++;
|
||||
// Ignore the map header (it will not be found because the name is different)
|
||||
if(ml.Key.ToString() != MapManager.CONFIG_MAP_HEADER)
|
||||
{
|
||||
// Read lump setting and count it
|
||||
if(cfg.ReadSetting("maplumpnames." + ml.Key + ".required", false)) lumpsrequired++;
|
||||
}
|
||||
}
|
||||
|
||||
// Go for all the lumps in the wad
|
||||
|
|
|
@ -83,6 +83,9 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public Sidedef Front { get { return front; } }
|
||||
public Sidedef Back { get { return back; } }
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
public int Flags { get { return flags; } }
|
||||
public int Action { get { return action; } }
|
||||
public int Tag { get { return tag; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
// Map header name
|
||||
private string currentname;
|
||||
private string previousname;
|
||||
private string previousname; // When zero length string, map has not renamed
|
||||
|
||||
// Additional resources
|
||||
private DataLocationList resources;
|
||||
|
@ -53,7 +53,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
public string ConfigFile { get { return configfile; } set { configfile = value; } }
|
||||
public DataLocationList Resources { get { return resources; } }
|
||||
public string PreviousName { get { return previousname; } }
|
||||
public string PreviousName { get { return previousname; } set { previousname = value; } }
|
||||
public string CurrentName
|
||||
{
|
||||
get { return currentname; }
|
||||
|
|
|
@ -53,6 +53,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private string ceiltexname;
|
||||
private int special;
|
||||
private int tag;
|
||||
private int brightness;
|
||||
|
||||
// Disposing
|
||||
private bool isdisposed = false;
|
||||
|
@ -63,6 +64,13 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
public MapSet Map { get { return map; } }
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
public int FloorHeight { get { return floorheight; } }
|
||||
public int CeilHeight { get { return ceilheight; } }
|
||||
public string FloorTexture { get { return floortexname; } }
|
||||
public string CeilTexture { get { return ceiltexname; } }
|
||||
public int Special { get { return special; } }
|
||||
public int Tag { get { return tag; } }
|
||||
public int Brightness { get { return brightness; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -156,7 +164,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Changes
|
||||
|
||||
// This updates all properties
|
||||
public void Update(int hfloor, int hceil, string tfloor, string tceil, int special, int tag)
|
||||
public void Update(int hfloor, int hceil, string tfloor, string tceil, int special, int tag, int brightness)
|
||||
{
|
||||
// Apply changes
|
||||
this.floorheight = hfloor;
|
||||
|
@ -165,6 +173,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
this.ceiltexname = tceil;
|
||||
this.special = special;
|
||||
this.tag = tag;
|
||||
this.brightness = brightness;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -67,7 +67,12 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public Sidedef Other { get { if(this == linedef.Front) return linedef.Back; else return linedef.Front; } }
|
||||
public Sector Sector { get { return sector; } }
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
|
||||
public int OffsetX { get { return offsetx; } }
|
||||
public int OffsetY { get { return offsety; } }
|
||||
public string HighTexture { get { return texnamehigh; } }
|
||||
public string MiddleTexture { get { return texnamemid; } }
|
||||
public string LowTexture { get { return texnamelow; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
|
|
@ -67,6 +67,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public int Type { get { return type; } }
|
||||
public Vector3D Position { get { return pos; } }
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
public float Angle { get { return angle; } }
|
||||
public int Flags { get { return flags; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -41,6 +41,15 @@ savemap
|
|||
allowscroll = false;
|
||||
}
|
||||
|
||||
savemapas
|
||||
{
|
||||
title = "File: Save Map As";
|
||||
description = "Saves the current map and all resources from the source WAD file to a new WAD file.";
|
||||
allowkeys = true;
|
||||
allowmouse = false;
|
||||
allowscroll = false;
|
||||
}
|
||||
|
||||
scrollwest
|
||||
{
|
||||
title = "2D: Scroll West";
|
||||
|
|
Loading…
Reference in a new issue