2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Copyright ( c ) 2007 Pascal vd Heiden
/ *
* Copyright ( c ) 2007 Pascal vd Heiden , www . codeimp . com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* /
#endregion
#region = = = = = = = = = = = = = = = = = = Namespaces
using System ;
using System.Collections.Generic ;
2015-09-08 14:54:53 +00:00
using System.Diagnostics ;
2014-02-26 14:11:06 +00:00
using System.Drawing ;
2009-04-19 18:07:22 +00:00
using System.IO ;
2014-11-11 11:47:10 +00:00
using System.Windows.Forms ;
using CodeImp.DoomBuilder.Actions ;
using CodeImp.DoomBuilder.Compilers ;
using CodeImp.DoomBuilder.Config ;
using CodeImp.DoomBuilder.Data ;
using CodeImp.DoomBuilder.Editing ;
2014-02-26 14:11:06 +00:00
using CodeImp.DoomBuilder.Geometry ;
2014-11-11 11:47:10 +00:00
using CodeImp.DoomBuilder.GZBuilder.Data ; //mxd
using CodeImp.DoomBuilder.GZBuilder.GZDoom ; //mxd
2009-04-19 18:07:22 +00:00
using CodeImp.DoomBuilder.IO ;
using CodeImp.DoomBuilder.Map ;
using CodeImp.DoomBuilder.Rendering ;
using CodeImp.DoomBuilder.VisualModes ;
2014-11-11 11:47:10 +00:00
using CodeImp.DoomBuilder.Windows ;
2012-04-17 19:13:47 +00:00
2009-04-19 18:07:22 +00:00
#endregion
2014-12-29 09:19:20 +00:00
namespace CodeImp.DoomBuilder
{
2016-02-01 22:04:00 +00:00
public sealed class MapManager : IDisposable
2014-12-29 09:19:20 +00:00
{
2013-09-11 09:47:53 +00:00
#region = = = = = = = = = = = = = = = = = = Constants
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Map header name in temporary file
internal const string TEMP_MAP_HEADER = "TEMPMAP" ;
internal const string BUILD_MAP_HEADER = "MAP01" ;
public const string CONFIG_MAP_HEADER = "~MAP" ;
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
#endregion
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
#region = = = = = = = = = = = = = = = = = = Variables
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Status
private bool changed ;
private bool scriptschanged ;
2015-10-02 23:15:29 +00:00
private bool maploading ; //mxd
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Map information
private string filetitle ;
private string filepathname ;
private string temppath ;
2014-02-18 14:04:14 +00:00
private string origmapconfigname ; //mxd. Map configuration, which was used to open the map.
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Main objects
private MapSet map ;
private MapSetIO io ;
private MapOptions options ;
private ConfigurationInfo configinfo ;
private GameConfiguration config ;
private DataManager data ;
private D3DDevice graphics ;
private Renderer2D renderer2d ;
private Renderer3D renderer3d ;
private WAD tempwad ;
private GridSetup grid ;
private UndoManager undoredo ;
private CopyPasteManager copypaste ;
private Launcher launcher ;
private ThingsFilter thingsfilter ;
private ScriptEditorForm scriptwindow ;
private List < CompilerError > errors ;
private VisualCamera visualcamera ;
//mxd
2015-07-27 09:02:28 +00:00
private Dictionary < string , ScriptItem > namedscripts ;
private Dictionary < int , ScriptItem > numberedscripts ;
2015-11-13 21:42:41 +00:00
private readonly HashSet < string > scriptincludes ;
2013-09-11 09:47:53 +00:00
// Disposing
2014-01-09 13:09:43 +00:00
private bool isdisposed ;
2013-09-11 09:47:53 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Properties
public string FilePathName { get { return filepathname ; } }
2015-07-30 23:48:16 +00:00
public string FileTitle { get { return filetitle ; } internal set { filetitle = value ; } } //mxd. Added setter
2013-09-11 09:47:53 +00:00
public string TempPath { get { return temppath ; } }
public MapOptions Options { get { return options ; } }
public MapSet Map { get { return map ; } }
public DataManager Data { get { return data ; } }
2015-10-02 23:15:29 +00:00
public bool IsChanged { get { return changed | CheckScriptChanged ( ) ; } set { changed | = value ; if ( ! maploading ) General . MainWindow . UpdateMapChangedStatus ( ) ; } }
2013-09-11 09:47:53 +00:00
public bool IsDisposed { get { return isdisposed ; } }
internal D3DDevice Graphics { get { return graphics ; } }
public IRenderer2D Renderer2D { get { return renderer2d ; } }
public IRenderer3D Renderer3D { get { return renderer3d ; } }
internal Renderer2D CRenderer2D { get { return renderer2d ; } }
internal Renderer3D CRenderer3D { get { return renderer3d ; } }
public GameConfiguration Config { get { return config ; } }
public ConfigurationInfo ConfigSettings { get { return configinfo ; } }
public GridSetup Grid { get { return grid ; } }
public UndoManager UndoRedo { get { return undoredo ; } }
internal CopyPasteManager CopyPaste { get { return copypaste ; } }
public IMapSetIO FormatInterface { get { return io ; } }
internal Launcher Launcher { get { return launcher ; } }
public ThingsFilter ThingsFilter { get { return thingsfilter ; } }
internal List < CompilerError > Errors { get { return errors ; } }
internal ScriptEditorForm ScriptEditor { get { return scriptwindow ; } }
public VisualCamera VisualCamera { get { return visualcamera ; } set { visualcamera = value ; } }
public bool IsScriptsWindowOpen { get { return ( scriptwindow ! = null ) & & ! scriptwindow . IsDisposed ; } }
Added, Visual mode, DECORATE: "Alpha" and "DefaultAlpha" properties are now supported.
Added, Visual mode, DECORATE: "RenderStyle" property is now partially supported.
Added, Visual mode, DECORATE: +BRIGHT flag is now supported.
Added, Visual mode, UDMF: "Alpha" thing property is now supported.
Added, Visual mode, UDMF: "RenderStyle" thing property is now partially supported.
Added, Visual mode, Hexen map format and UDMF: "Translucent" and "Invisible" thing flags are now supported.
Added, Game Configurations: added "alpha" and "renderstyle" Thing and Thing Category properties.
Fixed, Visual mode: blockmap was not updated when moving things using "Move Thing Left/Right/Forward/Backward" and "Move Thing to Cursor Location" actions.
DECORATE parser: added a warning when unable to find actor's parent class.
Internal: current map format can now be checked using "General.Map.UDMF", "General.Map.HEXEN" and "General.Map.DOOM" properties.
Updated documentation ("Game Configuration - Things Settings" page).
2015-09-28 14:57:48 +00:00
//mxd. Map format
public bool UDMF { get { return config . UDMF ; } }
public bool HEXEN { get { return config . HEXEN ; } }
public bool DOOM { get { return config . DOOM ; } }
//mxd. Scripts
2015-07-27 09:02:28 +00:00
internal Dictionary < string , ScriptItem > NamedScripts { get { return namedscripts ; } }
internal Dictionary < int , ScriptItem > NumberedScripts { get { return numberedscripts ; } }
2015-11-13 21:42:41 +00:00
internal HashSet < string > ScriptIncludes { get { return scriptincludes ; } }
Added, Visual mode, DECORATE: "Alpha" and "DefaultAlpha" properties are now supported.
Added, Visual mode, DECORATE: "RenderStyle" property is now partially supported.
Added, Visual mode, DECORATE: +BRIGHT flag is now supported.
Added, Visual mode, UDMF: "Alpha" thing property is now supported.
Added, Visual mode, UDMF: "RenderStyle" thing property is now partially supported.
Added, Visual mode, Hexen map format and UDMF: "Translucent" and "Invisible" thing flags are now supported.
Added, Game Configurations: added "alpha" and "renderstyle" Thing and Thing Category properties.
Fixed, Visual mode: blockmap was not updated when moving things using "Move Thing Left/Right/Forward/Backward" and "Move Thing to Cursor Location" actions.
DECORATE parser: added a warning when unable to find actor's parent class.
Internal: current map format can now be checked using "General.Map.UDMF", "General.Map.HEXEN" and "General.Map.DOOM" properties.
Updated documentation ("Game Configuration - Things Settings" page).
2015-09-28 14:57:48 +00:00
2013-03-18 13:52:27 +00:00
public ViewMode ViewMode { get { return renderer2d . ViewMode ; } }
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Constructor / Disposer
// Constructor
2014-11-11 11:47:10 +00:00
internal MapManager ( )
{
2013-09-11 09:47:53 +00:00
// We have no destructor
GC . SuppressFinalize ( this ) ;
// Create temporary path
temppath = General . MakeTempDirname ( ) ;
Directory . CreateDirectory ( temppath ) ;
General . WriteLogLine ( "Temporary directory: " + temppath ) ;
// Basic objects
grid = new GridSetup ( ) ;
undoredo = new UndoManager ( ) ;
copypaste = new CopyPasteManager ( ) ;
launcher = new Launcher ( this ) ;
thingsfilter = new NullThingsFilter ( ) ;
errors = new List < CompilerError > ( ) ;
//mxd
2015-07-27 09:02:28 +00:00
numberedscripts = new Dictionary < int , ScriptItem > ( ) ;
namedscripts = new Dictionary < string , ScriptItem > ( ) ;
2015-11-13 21:42:41 +00:00
scriptincludes = new HashSet < string > ( ) ;
2013-09-11 09:47:53 +00:00
}
// Disposer
2016-02-01 22:04:00 +00:00
public void Dispose ( )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Not already disposed?
2015-10-02 23:15:29 +00:00
if ( ! isdisposed )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Let the plugins know
General . Plugins . OnMapCloseBegin ( ) ;
// Stop processing
General . MainWindow . StopProcessing ( ) ;
// Close script editor
CloseScriptEditor ( false ) ;
// Change to no mode
General . Editing . ChangeMode ( ( EditMode ) null ) ;
// Unbind any methods
General . Actions . UnbindMethods ( this ) ;
// Dispose
2015-10-02 23:15:29 +00:00
maploading = true ; //mxd
if ( grid ! = null ) grid . Dispose ( ) ;
if ( launcher ! = null ) launcher . Dispose ( ) ;
if ( copypaste ! = null ) copypaste . Dispose ( ) ;
if ( undoredo ! = null ) undoredo . Dispose ( ) ;
2013-09-11 09:47:53 +00:00
General . WriteLogLine ( "Unloading data resources..." ) ;
2015-10-02 23:15:29 +00:00
if ( data ! = null ) data . Dispose ( ) ;
2013-09-11 09:47:53 +00:00
General . WriteLogLine ( "Closing temporary file..." ) ;
2015-10-02 23:15:29 +00:00
if ( tempwad ! = null ) tempwad . Dispose ( ) ;
2013-09-11 09:47:53 +00:00
General . WriteLogLine ( "Unloading map data..." ) ;
2015-10-02 23:15:29 +00:00
if ( map ! = null ) map . Dispose ( ) ;
2013-09-11 09:47:53 +00:00
General . WriteLogLine ( "Stopping graphics device..." ) ;
2015-10-02 23:15:29 +00:00
if ( renderer2d ! = null ) renderer2d . Dispose ( ) ;
if ( renderer3d ! = null ) renderer3d . Dispose ( ) ;
if ( graphics ! = null ) graphics . Dispose ( ) ;
2013-09-11 09:47:53 +00:00
visualcamera = null ;
grid = null ;
launcher = null ;
copypaste = null ;
undoredo = null ;
data = null ;
tempwad = null ;
map = null ;
renderer2d = null ;
renderer3d = null ;
graphics = null ;
// We may spend some time to clean things up here
GC . Collect ( ) ;
2015-05-27 12:38:03 +00:00
GC . WaitForPendingFinalizers ( ) ; //mxd
GC . Collect ( ) ; //mxd
2013-09-11 09:47:53 +00:00
// Remove temp file
General . WriteLogLine ( "Removing temporary directory..." ) ;
2014-11-11 11:47:10 +00:00
try
{
Directory . Delete ( temppath , true ) ;
}
2015-10-02 23:15:29 +00:00
catch ( Exception e )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
General . WriteLogLine ( e . GetType ( ) . Name + ": " + e . Message ) ;
General . WriteLogLine ( "Failed to remove temporary directory!" ) ;
}
// Let the plugins know
General . Plugins . OnMapCloseEnd ( ) ;
// Done
isdisposed = true ;
}
}
#endregion
#region = = = = = = = = = = = = = = = = = = New / Open
// Initializes for a new map
2014-11-11 11:47:10 +00:00
internal bool InitializeNewMap ( MapOptions options )
{
2015-01-09 13:56:54 +00:00
#if DEBUG
DebugConsole . Clear ( ) ;
#endif
2013-09-11 09:47:53 +00:00
// Apply settings
2015-07-30 23:48:16 +00:00
this . filetitle = options . CurrentName + ".wad" ;
2013-09-11 09:47:53 +00:00
this . filepathname = "" ;
2015-10-02 23:15:29 +00:00
this . maploading = true ; //mxd
2013-09-11 09:47:53 +00:00
this . changed = false ;
this . options = options ;
General . WriteLogLine ( "Creating new map '" + options . CurrentName + "' with configuration '" + options . ConfigFile + "'" ) ;
// Initiate graphics
General . WriteLogLine ( "Initializing graphics device..." ) ;
graphics = new D3DDevice ( General . MainWindow . Display ) ;
2015-10-02 23:15:29 +00:00
if ( ! graphics . Initialize ( ) ) return false ;
2013-09-11 09:47:53 +00:00
// Create renderers
renderer2d = new Renderer2D ( graphics ) ;
renderer3d = new Renderer3D ( graphics ) ;
// Load game configuration
General . WriteLogLine ( "Loading game configuration..." ) ;
configinfo = General . GetConfigurationInfo ( options . ConfigFile ) ;
2014-02-18 14:04:14 +00:00
config = new GameConfiguration ( configinfo . Configuration ) ; //mxd
2014-08-30 18:12:07 +00:00
origmapconfigname = configinfo . Filename ; //mxd
2013-09-11 09:47:53 +00:00
configinfo . ApplyDefaults ( config ) ;
General . Editing . UpdateCurrentEditModes ( ) ;
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Create map data
map = new MapSet ( ) ;
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Create temp wadfile
2014-11-11 11:47:10 +00:00
string tempfile = General . MakeTempFilename ( temppath ) ;
2013-09-11 09:47:53 +00:00
General . WriteLogLine ( "Creating temporary file: " + tempfile ) ;
2012-07-10 10:20:45 +00:00
#if DEBUG
2013-09-11 09:47:53 +00:00
tempwad = new WAD ( tempfile ) ;
2012-07-10 10:20:45 +00:00
#else
2014-11-11 11:47:10 +00:00
try { tempwad = new WAD ( tempfile ) ; }
catch ( Exception e )
{
General . ShowErrorMessage ( "Error while creating a temporary wad file:\n" + e . GetType ( ) . Name + ": " + e . Message , MessageBoxButtons . OK ) ;
return false ;
}
2012-07-10 10:20:45 +00:00
#endif
2013-09-11 09:47:53 +00:00
// Read the map from temp file
General . WriteLogLine ( "Initializing map format interface " + config . FormatInterface + "..." ) ;
io = MapSetIO . Create ( config . FormatInterface , tempwad , this ) ;
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Create required lumps
General . WriteLogLine ( "Creating map data structures..." ) ;
tempwad . Insert ( TEMP_MAP_HEADER , 0 , 0 ) ;
io . Write ( map , TEMP_MAP_HEADER , 1 ) ;
CreateRequiredLumps ( tempwad , TEMP_MAP_HEADER ) ;
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Load data manager
General . WriteLogLine ( "Loading data resources..." ) ;
data = new DataManager ( ) ;
data . Load ( configinfo . Resources , options . Resources ) ;
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Update structures
options . ApplyGridSettings ( ) ;
map . UpdateConfiguration ( ) ;
map . Update ( ) ;
thingsfilter . Update ( ) ;
2012-05-21 23:51:32 +00:00
2015-07-27 09:02:28 +00:00
namedscripts = new Dictionary < string , ScriptItem > ( ) ; //mxd
numberedscripts = new Dictionary < int , ScriptItem > ( ) ; //mxd
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Bind any methods
General . Actions . BindMethods ( this ) ;
// Set defaults
this . visualcamera = new VisualCamera ( ) ;
General . Editing . ChangeMode ( configinfo . StartMode ) ;
ClassicMode cmode = ( General . Editing . Mode as ClassicMode ) ;
2015-10-02 23:15:29 +00:00
if ( cmode ! = null ) cmode . SetZoom ( 0.5f ) ;
2013-09-11 09:47:53 +00:00
renderer2d . SetViewMode ( ( ViewMode ) General . Settings . DefaultViewMode ) ;
General . Settings . SetDefaultThingFlags ( config . DefaultThingFlags ) ;
// Success
this . changed = false ;
2015-10-02 23:15:29 +00:00
this . maploading = false ; //mxd
2013-09-11 09:47:53 +00:00
General . WriteLogLine ( "Map creation done" ) ;
2015-09-25 13:20:53 +00:00
General . MainWindow . UpdateMapChangedStatus ( ) ; //mxd
2013-09-11 09:47:53 +00:00
return true ;
}
// Initializes for an existing map
2014-11-11 11:47:10 +00:00
internal bool InitializeOpenMap ( string filepathname , MapOptions options )
{
2013-09-11 09:47:53 +00:00
WAD mapwad ;
2015-01-09 13:56:54 +00:00
#if DEBUG
DebugConsole . Clear ( ) ;
#endif
2013-09-11 09:47:53 +00:00
// Apply settings
this . filetitle = Path . GetFileName ( filepathname ) ;
this . filepathname = filepathname ;
this . changed = false ;
2015-10-02 23:15:29 +00:00
this . maploading = true ; //mxd
2013-09-11 09:47:53 +00:00
this . options = options ;
General . WriteLogLine ( "Opening map '" + options . CurrentName + "' with configuration '" + options . ConfigFile + "'" ) ;
// Initiate graphics
General . WriteLogLine ( "Initializing graphics device..." ) ;
graphics = new D3DDevice ( General . MainWindow . Display ) ;
2015-10-02 23:15:29 +00:00
if ( ! graphics . Initialize ( ) ) return false ;
2013-09-11 09:47:53 +00:00
// Create renderers
renderer2d = new Renderer2D ( graphics ) ;
renderer3d = new Renderer3D ( graphics ) ;
// Load game configuration
General . WriteLogLine ( "Loading game configuration..." ) ;
configinfo = General . GetConfigurationInfo ( options . ConfigFile ) ;
2014-02-18 14:04:14 +00:00
config = new GameConfiguration ( configinfo . Configuration ) ;
2014-08-30 18:12:07 +00:00
origmapconfigname = configinfo . Filename ; //mxd
2013-09-11 09:47:53 +00:00
configinfo . ApplyDefaults ( config ) ;
General . Editing . UpdateCurrentEditModes ( ) ;
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Create map data
map = new MapSet ( ) ;
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Create temp wadfile
2015-12-27 21:54:50 +00:00
string tempfile = General . MakeTempFilename ( temppath ) ;
2013-09-11 09:47:53 +00:00
General . WriteLogLine ( "Creating temporary file: " + tempfile ) ;
2012-07-10 10:20:45 +00:00
#if DEBUG
2013-09-11 09:47:53 +00:00
tempwad = new WAD ( tempfile ) ;
2012-07-10 10:20:45 +00:00
#else
2013-07-29 08:50:50 +00:00
try { tempwad = new WAD ( tempfile ) ; } catch ( Exception e )
{
General . ShowErrorMessage ( "Error while creating a temporary wad file:\n" + e . GetType ( ) . Name + ": " + e . Message , MessageBoxButtons . OK ) ;
return false ;
}
2012-07-10 10:20:45 +00:00
#endif
2013-09-11 09:47:53 +00:00
// Now open the map file
General . WriteLogLine ( "Opening source file: " + filepathname ) ;
2012-07-10 10:20:45 +00:00
#if DEBUG
2013-09-11 09:47:53 +00:00
mapwad = new WAD ( filepathname , true ) ;
2012-07-10 10:20:45 +00:00
#else
2013-07-29 08:50:50 +00:00
try { mapwad = new WAD ( filepathname , true ) ; } catch ( Exception e )
{
General . ShowErrorMessage ( "Error while opening source wad file:\n" + e . GetType ( ) . Name + ": " + e . Message , MessageBoxButtons . OK ) ;
return false ;
}
2012-07-10 10:20:45 +00:00
#endif
2013-09-11 09:47:53 +00:00
// Copy the map lumps to the temp file
General . WriteLogLine ( "Copying map lumps to temporary file..." ) ;
CopyLumpsByType ( mapwad , options . CurrentName , tempwad , TEMP_MAP_HEADER ,
true , true , true , true ) ;
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Close the map file
mapwad . Dispose ( ) ;
2012-07-10 10:20:45 +00:00
2015-09-25 13:20:53 +00:00
//mxd. Create MapSet
bool maprestored ;
if ( ! CreateMapSet ( map , filepathname , options , out maprestored ) ) return false ;
2010-08-15 19:43:00 +00:00
2013-09-11 09:47:53 +00:00
// Load data manager
General . WriteLogLine ( "Loading data resources..." ) ;
data = new DataManager ( ) ;
2014-11-11 11:47:10 +00:00
DataLocation maplocation = new DataLocation ( DataLocation . RESOURCE_WAD , filepathname , options . StrictPatches , false , false ) ;
2013-09-11 09:47:53 +00:00
data . Load ( configinfo . Resources , options . Resources , maplocation ) ;
2010-08-15 19:43:00 +00:00
2013-09-11 09:47:53 +00:00
// Remove unused sectors
map . RemoveUnusedSectors ( true ) ;
2009-04-19 18:07:22 +00:00
2014-11-25 11:52:01 +00:00
//mxd. Translate to long or short texture names.
2014-12-03 09:06:05 +00:00
bool nameschanged = map . TranslateTextureNames ( config . UseLongTextureNames , false ) ;
grid . TranslateBackgroundName ( config . UseLongTextureNames ) ;
2014-11-25 11:52:01 +00:00
//mxd. Sector textures may've been changed
2015-10-02 23:15:29 +00:00
if ( nameschanged ) data . UpdateUsedTextures ( ) ;
2014-11-25 11:52:01 +00:00
2013-09-11 09:47:53 +00:00
// Update structures
options . ApplyGridSettings ( ) ;
map . UpdateConfiguration ( ) ;
map . SnapAllToAccuracy ( ) ;
map . Update ( ) ;
thingsfilter . Update ( ) ;
2009-04-19 18:07:22 +00:00
2015-11-13 21:42:41 +00:00
//mxd. Update includes list and script names
UpdateScriptNames ( true ) ;
2012-07-10 10:20:45 +00:00
2014-07-16 09:45:04 +00:00
//mxd. Restore selection groups
options . ReadSelectionGroups ( ) ;
2013-09-11 09:47:53 +00:00
// Bind any methods
General . Actions . BindMethods ( this ) ;
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Set defaults
this . visualcamera = new VisualCamera ( ) ;
General . Editing . ChangeMode ( configinfo . StartMode ) ;
renderer2d . SetViewMode ( ( ViewMode ) General . Settings . DefaultViewMode ) ;
General . Settings . SetDefaultThingFlags ( config . DefaultThingFlags ) ;
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Center map in screen
2015-12-28 15:01:53 +00:00
//if(General.Editing.Mode is ClassicMode) (General.Editing.Mode as ClassicMode).CenterInScreen();
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Success
2015-09-25 13:20:53 +00:00
this . changed = maprestored ; //mxd
2015-10-02 23:15:29 +00:00
this . maploading = false ; //mxd
2013-09-11 09:47:53 +00:00
General . WriteLogLine ( "Map loading done" ) ;
2015-09-25 13:20:53 +00:00
General . MainWindow . UpdateMapChangedStatus ( ) ; //mxd
2013-09-11 09:47:53 +00:00
return true ;
}
2012-07-10 10:20:45 +00:00
2013-07-25 12:39:40 +00:00
//mxd. This switches to another map in the same wad
2014-11-25 11:52:01 +00:00
internal bool InitializeSwitchMap ( MapOptions options )
2014-11-11 11:47:10 +00:00
{
2015-01-09 13:56:54 +00:00
#if DEBUG
DebugConsole . Clear ( ) ;
#endif
2013-07-25 12:39:40 +00:00
this . changed = false ;
2016-01-15 18:20:47 +00:00
this . maploading = true ;
2013-07-25 12:39:40 +00:00
this . options = options ;
// Create map data
MapSet newmap = new MapSet ( ) ;
2013-07-26 09:36:32 +00:00
WAD mapwad ;
2013-07-25 12:39:40 +00:00
// Create temp wadfile
string tempfile = General . MakeTempFilename ( temppath ) ;
General . WriteLogLine ( "Creating temporary file: " + tempfile ) ;
if ( tempwad ! = null ) tempwad . Dispose ( ) ;
#if DEBUG
tempwad = new WAD ( tempfile ) ;
#else
2013-07-26 09:36:32 +00:00
try { tempwad = new WAD ( tempfile ) ; } catch ( Exception e )
{
General . ShowErrorMessage ( "Error while creating a temporary wad file:\n" + e . GetType ( ) . Name + ": " + e . Message , MessageBoxButtons . OK ) ;
return false ;
}
2013-07-25 12:39:40 +00:00
#endif
// Now open the map file
General . WriteLogLine ( "Opening source file: " + filepathname ) ;
2013-07-26 09:36:32 +00:00
2013-07-25 12:39:40 +00:00
#if DEBUG
2013-07-26 09:36:32 +00:00
mapwad = new WAD ( filepathname , true ) ;
2013-07-25 12:39:40 +00:00
#else
2013-07-26 09:36:32 +00:00
try { mapwad = new WAD ( filepathname , true ) ; } catch ( Exception e )
{
General . ShowErrorMessage ( "Error while opening source wad file:\n" + e . GetType ( ) . Name + ": " + e . Message , MessageBoxButtons . OK ) ;
return false ;
}
2013-07-25 12:39:40 +00:00
#endif
// Copy the map lumps to the temp file
General . WriteLogLine ( "Copying map lumps to temporary file..." ) ;
CopyLumpsByType ( mapwad , options . CurrentName , tempwad , TEMP_MAP_HEADER , true , true , true , true ) ;
// Close the map file
mapwad . Dispose ( ) ;
2016-01-15 18:20:47 +00:00
// Create MapSet
2015-09-25 13:20:53 +00:00
bool maprestored ;
if ( ! CreateMapSet ( newmap , filepathname , options , out maprestored ) ) return false ;
2013-07-25 12:39:40 +00:00
2016-01-15 18:20:47 +00:00
// And switch to it
2013-07-25 12:39:40 +00:00
ChangeMapSet ( newmap ) ;
2016-01-15 18:20:47 +00:00
// Translate texture names
2014-12-03 09:06:05 +00:00
map . TranslateTextureNames ( config . UseLongTextureNames , false ) ;
grid . TranslateBackgroundName ( config . UseLongTextureNames ) ;
2014-11-25 11:52:01 +00:00
2016-01-15 18:20:47 +00:00
// Sector textures may've been changed
2014-12-03 09:06:05 +00:00
data . UpdateUsedTextures ( ) ;
2013-07-25 12:39:40 +00:00
2016-01-18 11:39:59 +00:00
// This will update DataManager.mapinfo only
data . ReloadMapInfoPartial ( ) ;
2016-01-15 18:20:47 +00:00
// Skybox may've been changed
data . SetupSkybox ( ) ;
// Update includes list and script names
2015-11-13 21:42:41 +00:00
UpdateScriptNames ( true ) ;
2013-07-25 12:39:40 +00:00
2016-01-15 18:20:47 +00:00
// Restore selection groups
2014-07-16 09:45:04 +00:00
options . ReadSelectionGroups ( ) ;
2016-01-15 18:20:47 +00:00
// Center map in screen or on stored coordinates
2015-09-25 13:20:53 +00:00
if ( General . Editing . Mode is ClassicMode )
2014-11-11 11:47:10 +00:00
{
2013-09-12 15:02:08 +00:00
ClassicMode mode = General . Editing . Mode as ClassicMode ;
mode . OnRedoEnd ( ) ;
2015-07-09 22:32:12 +00:00
if ( options . ViewPosition . IsFinite ( ) & & ! float . IsNaN ( options . ViewScale ) )
mode . CenterOnCoordinates ( options . ViewPosition , options . ViewScale ) ;
else
mode . CenterInScreen ( ) ;
2013-09-12 15:02:08 +00:00
}
2013-07-25 12:39:40 +00:00
// Success
2015-09-25 13:20:53 +00:00
this . changed = maprestored ;
2016-01-15 18:20:47 +00:00
this . maploading = false ;
2013-07-25 12:39:40 +00:00
General . WriteLogLine ( "Map switching done" ) ;
2016-01-15 18:20:47 +00:00
General . MainWindow . UpdateMapChangedStatus ( ) ;
2015-09-25 13:20:53 +00:00
return true ;
}
//mxd
private bool CreateMapSet ( MapSet newmap , string filepathname , MapOptions options , out bool maprestored )
{
maprestored = false ;
string wadname = Path . GetFileNameWithoutExtension ( filepathname ) ;
if ( ! string . IsNullOrEmpty ( wadname ) )
{
string hash = MurmurHash2 . Hash ( wadname + options . LevelName + File . GetLastWriteTime ( filepathname ) ) . ToString ( ) ;
string backuppath = Path . Combine ( General . MapRestorePath , wadname + "." + hash + ".restore" ) ;
// Backup exists and it's newer than the map itself?
if ( File . Exists ( backuppath ) & & File . GetLastWriteTime ( backuppath ) > File . GetLastWriteTime ( filepathname ) )
{
if ( General . ShowWarningMessage ( "Looks like your previous editing session has gone terribly wrong." + Environment . NewLine
+ "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 ) ;
General . WriteLogLine ( "Restoring map from '" + backuppath + "'..." ) ;
#if DEBUG
// Restore map
newmap . Deserialize ( SharpCompressHelper . DecompressStream ( new MemoryStream ( File . ReadAllBytes ( backuppath ) ) ) ) ;
#else
try
{
// Restore map
newmap . Deserialize ( SharpCompressHelper . DecompressStream ( new MemoryStream ( File . ReadAllBytes ( backuppath ) ) ) ) ;
// Delete the backup
File . Delete ( backuppath ) ;
}
catch ( Exception e )
{
General . ErrorLogger . Add ( ErrorType . Error , "Unable to restore the map data structures from the backup. " + e . GetType ( ) . Name + ": " + e . Message ) ;
General . ShowErrorMessage ( "Unable to restore the map data structures from the backup." , MessageBoxButtons . OK ) ;
return false ;
}
#endif
maprestored = true ;
}
}
}
// Read the map from temp file
if ( ! maprestored )
{
newmap . BeginAddRemove ( ) ;
General . WriteLogLine ( "Initializing map format interface " + config . FormatInterface + "..." ) ;
io = MapSetIO . Create ( config . FormatInterface , tempwad , this ) ;
2015-10-01 21:35:52 +00:00
General . WriteLogLine ( "Reading map data from file..." ) ;
2015-09-25 13:20:53 +00:00
#if DEBUG
2015-09-27 21:09:14 +00:00
newmap = io . Read ( newmap , TEMP_MAP_HEADER ) ;
2015-09-25 13:20:53 +00:00
#else
2015-09-27 21:09:14 +00:00
try { newmap = io . Read ( newmap , TEMP_MAP_HEADER ) ; } catch ( Exception e )
2015-09-25 13:20:53 +00:00
{
2015-10-01 21:35:52 +00:00
General . ErrorLogger . Add ( ErrorType . Error , "Unable to read the map data with the specified configuration. " + e . GetType ( ) . Name + ": " + e . Message ) ;
General . ShowErrorMessage ( "Unable to read the map data with the specified configuration." + Environment . NewLine + Environment . NewLine + e . Message , MessageBoxButtons . OK ) ;
2015-09-25 13:20:53 +00:00
return false ;
}
#endif
newmap . EndAddRemove ( ) ;
}
2013-07-25 12:39:40 +00:00
return true ;
}
2013-09-11 09:47:53 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Save
/// <summary>
/// This exports the structures from memory into a WAD file with the current map format.
/// </summary>
2014-12-03 23:15:26 +00:00
public bool ExportToFile ( string filepathname )
{
2016-01-25 14:39:55 +00:00
General . Plugins . OnMapSaveBegin ( SavePurpose . Testing ) ;
bool result = SaveMap ( filepathname , SavePurpose . Testing ) ;
General . Plugins . OnMapSaveEnd ( SavePurpose . Testing ) ;
return result ;
}
/// <summary>
/// This writes the map structures to the temporary file.
/// </summary>
private bool WriteMapToTempFile ( )
{
StatusInfo oldstatus = General . MainWindow . Status ;
// Make a copy of the map data
MapSet outputset = map . Clone ( ) ;
// Remove all flags from all 3D Start things
foreach ( Thing t in outputset . Things )
{
if ( t . Type = = config . Start3DModeThingType )
{
// We're not using SetFlag here, this doesn't have to be undone.
// Please note that this is totally exceptional!
List < string > flagkeys = new List < string > ( t . Flags . Keys ) ;
foreach ( string k in flagkeys ) t . Flags [ k ] = false ;
}
}
// Do we need sidedefs compression?
if ( map . Sidedefs . Count > io . MaxSidedefs )
{
// Compress sidedefs
General . MainWindow . DisplayStatus ( StatusType . Busy , "Compressing sidedefs..." ) ;
outputset . CompressSidedefs ( ) ;
// Check if it still doesnt fit
if ( outputset . Sidedefs . Count > io . MaxSidedefs )
{
// Problem! Can't save the map like this!
General . ShowErrorMessage ( "Unable to save the map: There are too many unique sidedefs!" , MessageBoxButtons . OK ) ;
General . MainWindow . DisplayStatus ( oldstatus ) ;
return false ;
}
}
// Check things
if ( map . Things . Count > io . MaxThings )
{
General . ShowErrorMessage ( "Unable to save the map: There are too many things!" , MessageBoxButtons . OK ) ;
General . MainWindow . DisplayStatus ( oldstatus ) ;
return false ;
}
// Check sectors
if ( map . Sectors . Count > io . MaxSectors )
{
General . ShowErrorMessage ( "Unable to save the map: There are too many sectors!" , MessageBoxButtons . OK ) ;
General . MainWindow . DisplayStatus ( oldstatus ) ;
return false ;
}
// Check linedefs
if ( map . Linedefs . Count > io . MaxLinedefs )
{
General . ShowErrorMessage ( "Unable to save the map: There are too many linedefs!" , MessageBoxButtons . OK ) ;
General . MainWindow . DisplayStatus ( oldstatus ) ;
return false ;
}
// Check vertices
if ( map . Vertices . Count > io . MaxVertices )
{
General . ShowErrorMessage ( "Unable to save the map: There are too many vertices!" , MessageBoxButtons . OK ) ;
General . MainWindow . DisplayStatus ( oldstatus ) ;
return false ;
}
// TODO: Check for more limitations
// Write to temporary file
General . WriteLogLine ( "Writing map data structures to file..." ) ;
int index = Math . Max ( 0 , tempwad . FindLumpIndex ( TEMP_MAP_HEADER ) ) ;
io . Write ( outputset , TEMP_MAP_HEADER , index ) ;
outputset . Dispose ( ) ;
General . MainWindow . DisplayStatus ( oldstatus ) ;
return true ;
2013-09-11 09:47:53 +00:00
}
// Initializes for an existing map
2014-12-03 23:15:26 +00:00
internal bool SaveMap ( string newfilepathname , SavePurpose purpose )
{
2015-09-06 22:15:21 +00:00
string settingsfile ;
2013-09-11 09:47:53 +00:00
WAD targetwad ;
2014-01-09 13:09:43 +00:00
bool includenodes ;
2013-09-11 09:47:53 +00:00
General . WriteLogLine ( "Saving map to file: " + newfilepathname ) ;
// Scripts changed?
bool localscriptschanged = CheckScriptChanged ( ) ;
// If the scripts window is open, save the scripts first
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( IsScriptsWindowOpen ) scriptwindow . Editor . ImplicitSave ( ) ;
2013-09-11 09:47:53 +00:00
// Only recompile scripts when the scripts have changed
// (not when only the map changed)
2014-12-03 23:15:26 +00:00
if ( localscriptschanged & & ! CompileScriptLumps ( ) )
{
// Compiler failure
if ( errors . Count > 0 )
General . ShowErrorMessage ( "Error while compiling scripts: " + errors [ 0 ] . description , MessageBoxButtons . OK ) ;
else
General . ShowErrorMessage ( "Unknown compiler error while compiling scripts!" , MessageBoxButtons . OK ) ;
2013-09-11 09:47:53 +00:00
}
// Show script window if there are any errors and we are going to test the map
// and always update the errors on the scripts window.
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( ( errors . Count > 0 ) & & ( scriptwindow = = null ) & & ( purpose = = SavePurpose . Testing ) ) ShowScriptEditor ( ) ;
if ( scriptwindow ! = null ) scriptwindow . Editor . ShowErrors ( errors ) ;
2013-09-11 09:47:53 +00:00
// Only write the map and rebuild nodes when the actual map has changed
// (not when only scripts have changed)
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( changed )
2014-12-03 23:15:26 +00:00
{
2016-01-25 14:39:55 +00:00
// Write the current map structures to the temp file
if ( ! WriteMapToTempFile ( ) ) return false ;
2013-09-11 09:47:53 +00:00
// Get the corresponding nodebuilder
2015-09-06 22:15:21 +00:00
string nodebuildername = ( purpose = = SavePurpose . Testing ) ? configinfo . NodebuilderTest : configinfo . NodebuilderSave ;
2013-09-11 09:47:53 +00:00
// Build the nodes
2016-01-25 14:39:55 +00:00
StatusInfo oldstatus = General . MainWindow . Status ;
2013-09-11 09:47:53 +00:00
General . MainWindow . DisplayStatus ( StatusType . Busy , "Building map nodes..." ) ;
2015-09-06 22:15:21 +00:00
includenodes = ( ! string . IsNullOrEmpty ( nodebuildername ) & & BuildNodes ( nodebuildername , true ) ) ;
2013-09-11 09:47:53 +00:00
General . MainWindow . DisplayStatus ( oldstatus ) ;
}
2014-06-30 13:42:45 +00:00
else
{
2013-09-11 09:47:53 +00:00
// Check if we have nodebuilder lumps
includenodes = VerifyNodebuilderLumps ( tempwad , TEMP_MAP_HEADER ) ;
}
// Suspend data resources
data . Suspend ( ) ;
2015-09-12 21:05:01 +00:00
//mxd. Check if the target file is locked
FileLockChecker . FileLockCheckResult checkresult = FileLockChecker . CheckFile ( newfilepathname ) ;
if ( ! string . IsNullOrEmpty ( checkresult . Error ) )
{
if ( checkresult . Processes . Count > 0 )
{
string rest = "Press 'Retry' to close " + ( checkresult . Processes . Count > 1 ? "all processes" : "the process" )
+ " and retry." + Environment . NewLine + "Press 'Cancel' to cancel saving." ;
if ( General . ShowErrorMessage ( checkresult . Error + rest , MessageBoxButtons . RetryCancel ) = = DialogResult . Retry )
{
// Close all processes
foreach ( Process process in checkresult . Processes )
{
try
{
if ( ! process . HasExited ) process . Kill ( ) ;
}
catch ( Exception e )
{
General . ShowErrorMessage ( "Failed to close " + Path . GetFileName ( process . MainModule . FileName ) + ":" + Environment . NewLine + Environment . NewLine + e . Message , MessageBoxButtons . OK ) ;
data . Resume ( ) ;
General . WriteLogLine ( "Map saving failed: failed to close " + Path . GetFileName ( process . MainModule . FileName ) ) ;
return false ;
}
}
// Retry
data . Resume ( ) ;
General . WriteLogLine ( "Map saving restarted..." ) ;
return SaveMap ( newfilepathname , purpose ) ;
}
else
{
data . Resume ( ) ;
General . WriteLogLine ( "Map saving cancelled..." ) ;
return false ;
}
}
else
{
General . ShowErrorMessage ( checkresult . Error , MessageBoxButtons . OK ) ;
data . Resume ( ) ;
General . WriteLogLine ( "Map saving failed: " + checkresult . Error ) ;
return false ;
}
}
2013-09-11 09:47:53 +00:00
// Determine original map name
2016-02-01 22:04:00 +00:00
string origmapname = ( ! string . IsNullOrEmpty ( options . PreviousName ) & & purpose ! = SavePurpose . IntoFile ) ? options . PreviousName : options . CurrentName ;
2014-12-22 21:36:49 +00:00
string origwadfile = string . Empty ; //mxd
2013-09-11 09:47:53 +00:00
2014-12-03 23:15:26 +00:00
try
{
2015-12-28 15:01:53 +00:00
if ( File . Exists ( newfilepathname ) )
2014-12-03 23:15:26 +00:00
{
2014-06-30 13:42:45 +00:00
// mxd. Check if target wad already has a map with the same name
2015-12-28 15:01:53 +00:00
if ( purpose = = SavePurpose . IntoFile )
2014-12-03 23:15:26 +00:00
{
2014-06-30 13:42:45 +00:00
WAD wad = new WAD ( newfilepathname , true ) ;
int mapindex = wad . FindLumpIndex ( origmapname ) ;
wad . Dispose ( ) ;
2014-12-03 23:15:26 +00:00
if ( mapindex ! = - 1 & & MessageBox . Show ( General . MainWindow , "Target file already contains map '" + origmapname + "'\nDo you want to replace it?" , "Map already exists!" , MessageBoxButtons . YesNo , MessageBoxIcon . Warning ) = = DialogResult . No )
{
2014-06-30 13:42:45 +00:00
data . Resume ( ) ;
General . WriteLogLine ( "Map saving cancelled..." ) ;
return false ;
}
}
// Backup existing file, if any
2015-12-28 15:01:53 +00:00
if ( File . Exists ( newfilepathname + ".backup3" ) ) File . Delete ( newfilepathname + ".backup3" ) ;
if ( File . Exists ( newfilepathname + ".backup2" ) ) File . Move ( newfilepathname + ".backup2" , newfilepathname + ".backup3" ) ;
if ( File . Exists ( newfilepathname + ".backup1" ) ) File . Move ( newfilepathname + ".backup1" , newfilepathname + ".backup2" ) ;
2013-09-11 09:47:53 +00:00
File . Copy ( newfilepathname , newfilepathname + ".backup1" ) ;
}
// Except when saving INTO another file,
// kill the target file if it is different from source file
2015-12-28 15:01:53 +00:00
if ( ( purpose ! = SavePurpose . IntoFile ) & & ( newfilepathname ! = filepathname ) )
2014-12-03 23:15:26 +00:00
{
2013-09-11 09:47:53 +00:00
// Kill target file
2015-12-28 15:01:53 +00:00
if ( File . Exists ( newfilepathname ) ) File . Delete ( newfilepathname ) ;
2013-09-11 09:47:53 +00:00
// Kill .dbs settings file
settingsfile = newfilepathname . Substring ( 0 , newfilepathname . Length - 4 ) + ".dbs" ;
2015-12-28 15:01:53 +00:00
if ( File . Exists ( settingsfile ) ) File . Delete ( settingsfile ) ;
2013-09-11 09:47:53 +00:00
}
// On Save AS we have to copy the previous file to the new file
2015-12-28 15:01:53 +00:00
if ( ( purpose = = SavePurpose . AsNewFile ) & & ( filepathname ! = "" ) )
2014-12-03 23:15:26 +00:00
{
2013-09-11 09:47:53 +00:00
// Copy if original file still exists
2015-12-28 15:01:53 +00:00
if ( File . Exists ( filepathname ) ) File . Copy ( filepathname , newfilepathname , true ) ;
2013-09-11 09:47:53 +00:00
}
// If the target file exists, we need to rebuild it
2015-12-28 15:01:53 +00:00
if ( File . Exists ( newfilepathname ) )
2014-12-03 23:15:26 +00:00
{
2013-09-11 09:47:53 +00:00
// Move the target file aside
2014-12-22 21:36:49 +00:00
origwadfile = newfilepathname + ".temp" ;
2013-09-11 09:47:53 +00:00
File . Move ( newfilepathname , origwadfile ) ;
// Open original file
WAD origwad = new WAD ( origwadfile , true ) ;
// Create new target file
targetwad = new WAD ( newfilepathname ) ;
// Copy all lumps, except the original map
2014-02-18 14:04:14 +00:00
GameConfiguration origcfg ; //mxd
2015-12-28 15:01:53 +00:00
if ( origmapconfigname = = configinfo . Filename )
2014-12-03 23:15:26 +00:00
{
2014-02-18 14:04:14 +00:00
origcfg = config ;
2014-12-03 23:15:26 +00:00
}
else
{
2014-02-18 14:04:14 +00:00
ConfigurationInfo ci = General . GetConfigurationInfo ( origmapconfigname ) ;
origcfg = new GameConfiguration ( ci . Configuration ) ;
}
2013-09-11 09:47:53 +00:00
CopyAllLumpsExceptMap ( origwad , targetwad , origcfg , origmapname ) ;
// Close original file and delete it
origwad . Dispose ( ) ;
File . Delete ( origwadfile ) ;
}
2014-06-30 13:42:45 +00:00
else
{
2013-09-11 09:47:53 +00:00
// Create new target file
targetwad = new WAD ( newfilepathname ) ;
}
2014-12-03 23:15:26 +00:00
}
2016-01-25 14:39:55 +00:00
catch ( IOException )
2014-12-03 23:15:26 +00:00
{
2013-09-11 09:47:53 +00:00
General . ShowErrorMessage ( "IO Error while writing target file: " + newfilepathname + ". Please make sure the location is accessible and not in use by another program." , MessageBoxButtons . OK ) ;
2014-12-22 21:36:49 +00:00
if ( ! string . IsNullOrEmpty ( origwadfile ) & & File . Exists ( origwadfile ) ) File . Delete ( origwadfile ) ; //mxd. Clean-up
2013-09-11 09:47:53 +00:00
data . Resume ( ) ;
General . WriteLogLine ( "Map saving failed" ) ;
return false ;
2014-12-03 23:15:26 +00:00
}
2016-01-25 14:39:55 +00:00
catch ( UnauthorizedAccessException )
2014-12-03 23:15:26 +00:00
{
2013-09-11 09:47:53 +00:00
General . ShowErrorMessage ( "Error while accessing target file: " + newfilepathname + ". Please make sure the location is accessible and not in use by another program." , MessageBoxButtons . OK ) ;
2014-12-22 21:36:49 +00:00
if ( ! string . IsNullOrEmpty ( origwadfile ) & & File . Exists ( origwadfile ) ) File . Delete ( origwadfile ) ; //mxd. Clean-up
2013-09-11 09:47:53 +00:00
data . Resume ( ) ;
General . WriteLogLine ( "Map saving failed" ) ;
return false ;
}
// Copy map lumps to target file
CopyLumpsByType ( tempwad , TEMP_MAP_HEADER , targetwad , origmapname , true , true , includenodes , true ) ;
2014-06-30 13:42:45 +00:00
// mxd. Was the map renamed?
2014-09-24 11:47:52 +00:00
if ( options . LevelNameChanged )
2014-06-30 13:42:45 +00:00
{
2015-12-28 15:01:53 +00:00
if ( purpose ! = SavePurpose . IntoFile )
2014-06-30 13:42:45 +00:00
{
General . WriteLogLine ( "Changing map name from '" + options . PreviousName + "' to '" + options . CurrentName + "'" ) ;
// Find the map header in target
2016-01-25 14:39:55 +00:00
int index = targetwad . FindLumpIndex ( options . PreviousName ) ;
2015-12-28 15:01:53 +00:00
if ( index > - 1 )
2014-12-03 23:15:26 +00:00
{
2014-06-30 13:42:45 +00:00
// Rename the map lump name
targetwad . Lumps [ index ] . Rename ( options . CurrentName ) ;
2014-12-03 23:15:26 +00:00
}
else
{
2014-06-30 13:42:45 +00:00
// 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 ;
}
2013-09-11 09:47:53 +00:00
}
2014-06-30 13:42:45 +00:00
options . PreviousName = "" ;
2013-09-11 09:47:53 +00:00
}
// Done with the target file
targetwad . Dispose ( ) ;
// Resume data resources
data . Resume ( ) ;
// Not saved for testing purpose?
2015-12-28 15:01:53 +00:00
if ( purpose ! = SavePurpose . Testing )
2014-12-03 23:15:26 +00:00
{
2013-09-11 09:47:53 +00:00
// Saved in a different file?
2015-12-28 15:01:53 +00:00
if ( newfilepathname ! = filepathname )
2014-12-03 23:15:26 +00:00
{
2013-09-11 09:47:53 +00:00
// Keep new filename
filepathname = newfilepathname ;
filetitle = Path . GetFileName ( filepathname ) ;
// Reload resources
ReloadResources ( ) ;
}
2014-12-03 23:15:26 +00:00
try
{
2013-09-11 09:47:53 +00:00
// Open or create the map settings
settingsfile = newfilepathname . Substring ( 0 , newfilepathname . Length - 4 ) + ".dbs" ;
options . WriteConfiguration ( settingsfile ) ;
2014-12-03 23:15:26 +00:00
}
2016-01-25 14:39:55 +00:00
catch ( Exception e )
2014-12-03 23:15:26 +00:00
{
2013-09-11 09:47:53 +00:00
// Warning only
General . ErrorLogger . Add ( ErrorType . Warning , "Could not write the map settings configuration file. " + e . GetType ( ) . Name + ": " + e . Message ) ;
}
// Changes saved
changed = false ;
scriptschanged = false ;
}
// Success!
General . WriteLogLine ( "Map saving done" ) ;
2015-09-25 13:20:53 +00:00
General . MainWindow . UpdateMapChangedStatus ( ) ; //mxd
2014-01-09 13:09:43 +00:00
return true ;
2013-09-11 09:47:53 +00:00
}
2014-09-24 11:47:52 +00:00
//mxd. Don't save the map if it was not changed
internal bool MapSaveRequired ( string newfilepathname , SavePurpose purpose )
{
return ( changed | | scriptschanged | | CheckScriptChanged ( ) | | options . LevelNameChanged | | newfilepathname ! = filepathname | | purpose ! = SavePurpose . Normal ) ;
}
//mxd. Saves .dbs file
internal bool SaveSettingsFile ( string newfilepathname )
{
try
{
string settingsfile = newfilepathname . Substring ( 0 , newfilepathname . Length - 4 ) + ".dbs" ;
options . WriteConfiguration ( settingsfile ) ;
}
catch ( Exception e )
{
// Warning only
General . ErrorLogger . Add ( ErrorType . Warning , "Could not write the map settings configuration file. " + e . GetType ( ) . Name + ": " + e . Message ) ;
return false ;
}
return true ;
}
2015-09-25 13:20:53 +00:00
//mxd
internal void SaveMapBackup ( )
{
if ( isdisposed | | map = = null | | map . IsDisposed | | string . IsNullOrEmpty ( filepathname ) | | options = = null )
{
General . WriteLogLine ( "Map backup saving failed: required structures already disposed..." ) ;
return ;
}
#if ! DEBUG
try
{
#endif
string wadname = Path . GetFileNameWithoutExtension ( filepathname ) ;
if ( ! string . IsNullOrEmpty ( wadname ) )
{
// Make backup file path
if ( ! Directory . Exists ( General . MapRestorePath ) ) Directory . CreateDirectory ( General . MapRestorePath ) ;
string hash = MurmurHash2 . Hash ( wadname + options . LevelName + File . GetLastWriteTime ( filepathname ) ) . ToString ( ) ;
string backuppath = Path . Combine ( General . MapRestorePath , wadname + "." + hash + ".restore" ) ;
// Export map
MemoryStream ms = map . Serialize ( ) ;
ms . Seek ( 0 , SeekOrigin . Begin ) ;
File . WriteAllBytes ( backuppath , SharpCompressHelper . CompressStream ( ms ) . ToArray ( ) ) ;
// Log it
General . WriteLogLine ( "Map backup saved to '" + backuppath + "'" ) ;
}
else
{
// Log it
General . WriteLogLine ( "Map backup saving failed: invalid map WAD name" ) ;
}
#if ! DEBUG
}
catch ( Exception e )
{
// Log it
General . WriteLogLine ( "Map backup saving failed: " + e . Source + ": " + e . Message ) ;
}
#endif
}
2013-09-11 09:47:53 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Nodebuild
2016-01-25 14:39:55 +00:00
/// <summary>
/// This stores the current structures in memory to the temporary file and rebuilds the nodes.
/// The 'nodebuildername' must be a valid nodebuilder configuration profile.
/// Returns True on success, False when failed.
/// </summary>
public bool RebuildNodes ( string nodebuildername , bool failaswarning )
{
bool result ;
// Write the current map structures to the temp file
if ( ! WriteMapToTempFile ( ) ) return false ;
// Build the nodes
StatusInfo oldstatus = General . MainWindow . Status ;
General . MainWindow . DisplayStatus ( StatusType . Busy , "Building map nodes..." ) ;
if ( ! string . IsNullOrEmpty ( nodebuildername ) )
result = BuildNodes ( nodebuildername , failaswarning ) ;
else
result = false ;
General . MainWindow . DisplayStatus ( oldstatus ) ;
return result ;
}
2013-09-11 09:47:53 +00:00
// This builds the nodes in the temproary file with the given configuration name
2014-11-11 11:47:10 +00:00
private bool BuildNodes ( string nodebuildername , bool failaswarning )
{
2013-09-11 09:47:53 +00:00
bool lumpscomplete = false ;
WAD buildwad ;
// Find the nodebuilder
2014-11-11 11:47:10 +00:00
NodebuilderInfo nodebuilder = General . GetNodebuilderByName ( nodebuildername ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( nodebuilder = = null )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Problem! Can't find that nodebuilder!
General . ShowWarningMessage ( "Unable to build the nodes: The configured nodebuilder cannot be found.\nPlease check your game configuration settings!" , MessageBoxButtons . OK ) ;
return false ;
}
2014-06-30 13:42:45 +00:00
else
{
2013-09-11 09:47:53 +00:00
// Create the compiler interface that will run the nodebuilder
// This automatically creates a temporary directory for us
Compiler compiler = nodebuilder . CreateCompiler ( ) ;
// Make temporary filename
2014-11-11 11:47:10 +00:00
string tempfile1 = General . MakeTempFilename ( compiler . Location ) ;
2013-09-11 09:47:53 +00:00
// Make the temporary WAD file
General . WriteLogLine ( "Creating temporary build file: " + tempfile1 ) ;
2012-07-10 10:20:45 +00:00
#if DEBUG
2013-09-11 09:47:53 +00:00
buildwad = new WAD ( tempfile1 ) ;
2012-07-10 10:20:45 +00:00
#else
2014-11-11 11:47:10 +00:00
try { buildwad = new WAD ( tempfile1 ) ; }
catch ( Exception e )
{
General . ShowErrorMessage ( "Error while creating a temporary wad file:\n" + e . GetType ( ) . Name + ": " + e . Message , MessageBoxButtons . OK ) ;
return false ;
}
2012-07-10 10:20:45 +00:00
#endif
2013-09-11 09:47:53 +00:00
// Determine source file
2014-11-11 11:47:10 +00:00
string sourcefile = ( filepathname . Length > 0 ? filepathname : tempwad . Filename ) ;
2013-09-11 09:47:53 +00:00
2014-12-22 21:36:49 +00:00
//mxd.
RemoveUnneededLumps ( tempwad , TEMP_MAP_HEADER , true ) ;
2013-09-11 09:47:53 +00:00
// Copy lumps to buildwad
General . WriteLogLine ( "Copying map lumps to temporary build file..." ) ;
CopyLumpsByType ( tempwad , TEMP_MAP_HEADER , buildwad , BUILD_MAP_HEADER , true , false , false , true ) ;
// Close buildwad
buildwad . Dispose ( ) ;
// Does the nodebuilder require an output file?
2015-11-30 14:18:42 +00:00
string tempfile2 ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( nodebuilder . HasSpecialOutputFile )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Make a temporary output file for the nodebuilder
tempfile2 = General . MakeTempFilename ( compiler . Location ) ;
General . WriteLogLine ( "Temporary output file: " + tempfile2 ) ;
}
2014-11-11 11:47:10 +00:00
else
{
2013-09-11 09:47:53 +00:00
// Output file is same as input file
tempfile2 = tempfile1 ;
}
// Run the nodebuilder
compiler . Parameters = nodebuilder . Parameters ;
compiler . InputFile = Path . GetFileName ( tempfile1 ) ;
compiler . OutputFile = Path . GetFileName ( tempfile2 ) ;
compiler . SourceFile = sourcefile ;
compiler . WorkingDirectory = Path . GetDirectoryName ( tempfile1 ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( compiler . Run ( ) )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Open the output file
2014-11-11 11:47:10 +00:00
try { buildwad = new WAD ( tempfile2 ) ; }
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
catch ( Exception e )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
General . WriteLogLine ( e . GetType ( ) . Name + " while reading build wad file: " + e . Message ) ;
buildwad = null ;
}
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( buildwad ! = null )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Output lumps complete?
lumpscomplete = VerifyNodebuilderLumps ( buildwad , BUILD_MAP_HEADER ) ;
}
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( lumpscomplete )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Copy nodebuilder lumps to temp file
General . WriteLogLine ( "Copying nodebuilder lumps to temporary file..." ) ;
CopyLumpsByType ( buildwad , BUILD_MAP_HEADER , tempwad , TEMP_MAP_HEADER , false , false , true , false ) ;
}
2014-11-11 11:47:10 +00:00
else
{
2013-09-11 09:47:53 +00:00
//mxd. collect errors
2014-11-11 11:47:10 +00:00
string compilererrors = "" ;
2015-11-30 14:18:42 +00:00
foreach ( CompilerError e in compiler . Errors )
2014-12-22 21:36:49 +00:00
compilererrors + = Environment . NewLine + e . description ;
2013-09-11 09:47:53 +00:00
// Nodebuilder did not build the lumps!
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( failaswarning )
2014-11-11 11:47:10 +00:00
General . ShowWarningMessage ( "Unable to build the nodes: The nodebuilder failed to build the expected data structures.\nThe map will be saved without the nodes." + ( compiler . Errors . Length > 0 ? Environment . NewLine + compilererrors : "" ) , MessageBoxButtons . OK ) ;
2013-09-11 09:47:53 +00:00
else
2014-11-11 11:47:10 +00:00
General . ShowErrorMessage ( "Unable to build the nodes: The nodebuilder failed to build the expected data structures." + ( compiler . Errors . Length > 0 ? Environment . NewLine + compilererrors : "" ) , MessageBoxButtons . OK ) ;
2013-09-11 09:47:53 +00:00
}
// Done with the build wad
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( buildwad ! = null ) buildwad . Dispose ( ) ;
2013-09-11 09:47:53 +00:00
}
2014-11-11 11:47:10 +00:00
else //mxd
{
2013-09-11 09:47:53 +00:00
//collect errors
2014-11-11 11:47:10 +00:00
string compilererrors = "" ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
foreach ( CompilerError e in compiler . Errors )
2014-12-22 21:36:49 +00:00
compilererrors + = Environment . NewLine + e . description ;
2013-09-11 09:47:53 +00:00
// Nodebuilder did not build the lumps!
2014-11-11 11:47:10 +00:00
General . ShowErrorMessage ( "Unable to build the nodes: The nodebuilder failed to build the expected data structures" + ( compiler . Errors . Length > 0 ? ":" + Environment . NewLine + compilererrors : "." ) , MessageBoxButtons . OK ) ;
2013-09-11 09:47:53 +00:00
}
// Clean up
compiler . Dispose ( ) ;
2016-01-25 14:39:55 +00:00
// Let the plugins know
if ( lumpscomplete ) General . Plugins . OnMapNodesRebuilt ( ) ;
2013-09-11 09:47:53 +00:00
// Return result
return lumpscomplete ;
}
}
// This verifies if the nodebuilder lumps exist in a WAD file
2014-11-11 11:47:10 +00:00
private bool VerifyNodebuilderLumps ( WAD wad , string mapheader )
{
2013-09-11 09:47:53 +00:00
bool lumpscomplete = false ;
// Find the map header in source
int srcindex = wad . FindLumpIndex ( mapheader ) ;
2014-11-11 11:47:10 +00:00
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( srcindex > - 1 )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Go for all the map lump names
lumpscomplete = true ;
2014-11-11 11:47:10 +00:00
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
foreach ( KeyValuePair < string , MapLumpInfo > group in config . MapLumps )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Check if this lump should exist
2014-12-22 21:36:49 +00:00
if ( group . Value . NodeBuild & & ! group . Value . AllowEmpty & & group . Value . Required )
2014-11-11 11:47:10 +00:00
{
2014-12-22 21:36:49 +00:00
//mxd
string lumpname = group . Key ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( lumpname . Contains ( CONFIG_MAP_HEADER ) ) lumpname = lumpname . Replace ( CONFIG_MAP_HEADER , mapheader ) ;
2014-12-22 21:36:49 +00:00
2013-09-11 09:47:53 +00:00
// Find the lump in the source
2014-12-22 21:36:49 +00:00
if ( wad . FindLump ( lumpname , srcindex , srcindex + config . MapLumps . Count + 2 ) = = null )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Missing a lump!
lumpscomplete = false ;
break ;
}
}
}
}
return lumpscomplete ;
}
#endregion
#region = = = = = = = = = = = = = = = = = = Lumps
// This returns a copy of the requested lump stream data
// This is copied from the temp wad file and returns null when the lump is not found
2014-11-11 11:47:10 +00:00
public MemoryStream GetLumpData ( string lumpname )
{
2013-09-11 09:47:53 +00:00
Lump l = tempwad . FindLump ( lumpname ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( l ! = null )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
l . Stream . Seek ( 0 , SeekOrigin . Begin ) ;
return new MemoryStream ( l . Stream . ReadAllBytes ( ) ) ;
}
return null ;
}
// This writes a copy of the data to a lump in the temp file
2015-11-30 14:18:42 +00:00
public void SetLumpData ( string lumpname , MemoryStream lumpdata )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
int insertindex = tempwad . Lumps . Count ;
// Remove the lump if it already exists
int li = tempwad . FindLumpIndex ( lumpname ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( li > - 1 )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
insertindex = li ;
tempwad . RemoveAt ( li ) ;
}
// Insert new lump
2015-11-30 14:18:42 +00:00
Lump l = tempwad . Insert ( lumpname , insertindex , ( int ) lumpdata . Length ) ;
2013-09-11 09:47:53 +00:00
l . Stream . Seek ( 0 , SeekOrigin . Begin ) ;
2015-11-30 14:18:42 +00:00
lumpdata . WriteTo ( l . Stream ) ;
//mxd. Mark the map as changed (will also update the title)
IsChanged = true ;
2013-09-11 09:47:53 +00:00
}
// This checks if the specified lump exists in the temp file
2014-11-11 11:47:10 +00:00
public bool LumpExists ( string lumpname )
{
2013-09-11 09:47:53 +00:00
return ( tempwad . FindLumpIndex ( lumpname ) > - 1 ) ;
}
// This creates empty lumps for those required
2014-11-11 11:47:10 +00:00
private void CreateRequiredLumps ( WAD target , string mapname )
{
2013-09-11 09:47:53 +00:00
// Find the map header in target
2014-11-11 11:47:10 +00:00
int headerindex = target . FindLumpIndex ( mapname ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( headerindex = = - 1 )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// If this header doesnt exists in the target
// then insert at the end of the target
headerindex = target . Lumps . Count ;
}
// Begin inserting at target header index
2014-11-11 11:47:10 +00:00
int insertindex = headerindex ;
2013-09-11 09:47:53 +00:00
// Go for all the map lump names
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
foreach ( KeyValuePair < string , MapLumpInfo > group in config . MapLumps )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Check if this lump is required
2014-11-11 11:47:10 +00:00
if ( group . Value . Required )
{
2013-09-11 09:47:53 +00:00
// Get the lump name
2014-12-22 21:36:49 +00:00
string lumpname = ( group . Key . Contains ( CONFIG_MAP_HEADER ) ? group . Key . Replace ( CONFIG_MAP_HEADER , mapname ) : group . Key ) ; //mxd
2013-09-11 09:47:53 +00:00
// Check if the lump is missing at the target
2014-11-11 11:47:10 +00:00
int targetindex = FindSpecificLump ( target , lumpname , headerindex , mapname , config . MapLumps ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( targetindex = = - 1 )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Determine target index
insertindex + + ;
2015-12-28 15:01:53 +00:00
if ( insertindex > target . Lumps . Count ) insertindex = target . Lumps . Count ;
2013-09-11 09:47:53 +00:00
// Create new, emtpy lump
General . WriteLogLine ( lumpname + " is required! Created empty lump." ) ;
target . Insert ( lumpname , insertindex , 0 ) ;
}
2014-11-11 11:47:10 +00:00
else
{
2013-09-11 09:47:53 +00:00
// Move insert index
insertindex = targetindex ;
}
}
}
}
2012-07-10 10:20:45 +00:00
2013-07-23 14:25:03 +00:00
//mxd. This is called on tempwad, which should only have the current map inside it.
2014-12-22 21:36:49 +00:00
private void RemoveUnneededLumps ( WAD target , string mapname , bool glnodesonly )
2014-11-02 19:02:01 +00:00
{
2013-07-23 14:25:03 +00:00
//Get the list of lumps required by current map format
List < string > requiredLumps = new List < string > ( ) ;
2014-11-02 19:02:01 +00:00
foreach ( KeyValuePair < string , MapLumpInfo > group in config . MapLumps )
{
2014-12-22 21:36:49 +00:00
//this lump well be recreated by a nodebuilder when saving the map
//(or it won't be if the new map format or nodebuilder doesn't require / build this lump,
//so it will just stay there, possibly messing things up)
if ( group . Value . NodeBuild & & ( ! glnodesonly | | group . Key . ToUpperInvariant ( ) . StartsWith ( "GL_" ) ) ) continue ;
2014-11-02 19:02:01 +00:00
string lumpname = group . Key ;
2013-07-23 14:25:03 +00:00
if ( lumpname = = CONFIG_MAP_HEADER ) lumpname = mapname ;
requiredLumps . Add ( lumpname ) ;
}
//Remove lumps, which are not required
List < Lump > toRemove = new List < Lump > ( ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
foreach ( Lump lump in target . Lumps )
if ( ! requiredLumps . Contains ( lump . Name ) ) toRemove . Add ( lump ) ;
2013-07-23 14:25:03 +00:00
2015-12-28 15:01:53 +00:00
foreach ( Lump lump in toRemove ) target . Remove ( lump ) ;
2013-07-23 14:25:03 +00:00
}
2013-09-11 09:47:53 +00:00
// This copies all lumps, except those of a specific map
2014-11-11 11:47:10 +00:00
private static void CopyAllLumpsExceptMap ( WAD source , WAD target , GameConfiguration mapconfig , string sourcemapname )
{
2013-09-11 09:47:53 +00:00
// Go for all lumps
bool skipping = false ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
foreach ( Lump srclump in source . Lumps )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Check if we should stop skipping lumps here
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( skipping )
2014-11-11 11:47:10 +00:00
{
2014-12-22 21:36:49 +00:00
//mxd
string srclumpname = srclump . Name ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( srclumpname . Contains ( sourcemapname ) ) srclumpname = srclumpname . Replace ( sourcemapname , CONFIG_MAP_HEADER ) ;
2014-12-22 21:36:49 +00:00
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( ! mapconfig . MapLumps . ContainsKey ( srclumpname ) )
2014-12-22 21:36:49 +00:00
{
// Stop skipping
skipping = false ;
}
2013-09-11 09:47:53 +00:00
}
// Check if we should start skipping lumps here
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( ! skipping & & ( srclump . Name = = sourcemapname ) )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// We have encountered the map header, start skipping!
skipping = true ;
}
// Not skipping this lump?
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( ! skipping )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Copy lump over!
Lump tgtlump = target . Insert ( srclump . Name , target . Lumps . Count , srclump . Length ) ;
srclump . CopyTo ( tgtlump ) ;
}
}
}
// This copies specific map lumps from one WAD to another
private void CopyLumpsByType ( WAD source , string sourcemapname ,
WAD target , string targetmapname ,
bool copyrequired , bool copyblindcopy ,
2014-11-11 11:47:10 +00:00
bool copynodebuild , bool copyscript )
{
2013-09-11 09:47:53 +00:00
// Find the map header in target
2014-11-11 11:47:10 +00:00
int tgtheaderindex = target . FindLumpIndex ( targetmapname ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( tgtheaderindex = = - 1 )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// If this header doesnt exists in the target
// then insert at the end of the target
tgtheaderindex = target . Lumps . Count ;
}
// Begin inserting at target header index
2014-11-11 11:47:10 +00:00
int targetindex = tgtheaderindex ;
2013-09-11 09:47:53 +00:00
// Find the map header in source
2014-11-11 11:47:10 +00:00
int srcheaderindex = source . FindLumpIndex ( sourcemapname ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( srcheaderindex > - 1 )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Go for all the map lump names
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
foreach ( KeyValuePair < string , MapLumpInfo > group in config . MapLumps )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Check if this lump should be copied
2014-11-11 11:47:10 +00:00
if ( ( group . Value . Required & & copyrequired ) | | ( group . Value . BlindCopy & & copyblindcopy ) | |
( group . Value . NodeBuild & & copynodebuild ) | | ( ( group . Value . Script ! = null | | group . Value . ScriptBuild ) & & copyscript ) )
{
2013-09-11 09:47:53 +00:00
// Get the lump name
2014-12-22 21:36:49 +00:00
string srclumpname = ( group . Key . Contains ( CONFIG_MAP_HEADER ) ? group . Key . Replace ( CONFIG_MAP_HEADER , sourcemapname ) : group . Key ) ; //mxd
string tgtlumpname = ( group . Key . Contains ( CONFIG_MAP_HEADER ) ? group . Key . Replace ( CONFIG_MAP_HEADER , targetmapname ) : group . Key ) ; //mxd
2013-09-11 09:47:53 +00:00
// Find the lump in the source
2014-11-11 11:47:10 +00:00
int sourceindex = FindSpecificLump ( source , srclumpname , srcheaderindex , sourcemapname , config . MapLumps ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( sourceindex > - 1 )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Remove lump at target
2014-11-11 11:47:10 +00:00
int lumpindex = RemoveSpecificLump ( target , tgtlumpname , tgtheaderindex , targetmapname , config . MapLumps ) ;
2013-09-11 09:47:53 +00:00
// Determine target index
// When original lump was found and removed then insert at that position
// otherwise insert after last insertion position
2015-12-28 15:01:53 +00:00
if ( lumpindex > - 1 ) targetindex = lumpindex ; else targetindex + + ;
if ( targetindex > target . Lumps . Count ) targetindex = target . Lumps . Count ;
2013-09-11 09:47:53 +00:00
// Copy the lump to the target
//General.WriteLogLine(srclumpname + " copying as " + tgtlumpname);
2014-11-11 11:47:10 +00:00
Lump lump = source . Lumps [ sourceindex ] ;
Lump newlump = target . Insert ( tgtlumpname , targetindex , lump . Length ) ;
2013-09-11 09:47:53 +00:00
lump . CopyTo ( newlump ) ;
}
2014-11-11 11:47:10 +00:00
else
{
2013-09-11 09:47:53 +00:00
// We don't want to bother the user with this. There are a lot of lumps in
// the game configs that are trivial and don't need to be found.
2015-12-28 15:01:53 +00:00
if ( group . Value . Required )
2014-11-11 11:47:10 +00:00
{
General . ErrorLogger . Add ( ErrorType . Warning , group . Key + " (required lump) should be read but was not found in the WAD file." ) ;
2013-09-11 09:47:53 +00:00
}
}
}
}
}
}
// This finds a lump within the range of known lump names
// Returns -1 when the lump cannot be found
2014-12-22 21:36:49 +00:00
private static int FindSpecificLump ( WAD source , string lumpname , int mapheaderindex , string mapheadername , Dictionary < string , MapLumpInfo > maplumps )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// 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
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
for ( int i = 0 ; i < maplumps . Count + 1 ; i + + )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Still within bounds?
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( ( mapheaderindex + i ) < source . Lumps . Count )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Check if this is a known lump name
2014-12-22 21:36:49 +00:00
string srclumpname = source . Lumps [ mapheaderindex + i ] . Name ; //mxd
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( srclumpname . Contains ( mapheadername ) ) srclumpname = srclumpname . Replace ( mapheadername , CONFIG_MAP_HEADER ) ;
2014-12-22 21:36:49 +00:00
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( maplumps . ContainsKey ( srclumpname ) ) //mxd
2014-12-03 23:15:26 +00:00
{
2013-09-11 09:47:53 +00:00
// Is this the lump we are looking for?
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( source . Lumps [ mapheaderindex + i ] . Name = = lumpname )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Return this index
return mapheaderindex + i ;
}
}
2014-11-11 11:47:10 +00:00
else
{
2013-09-11 09:47:53 +00:00
// Unknown lump hit, abort search
break ;
}
}
}
// 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
2014-11-11 11:47:10 +00:00
internal static int RemoveSpecificLump ( WAD source , string lumpname , int mapheaderindex , string mapheadername , Dictionary < string , MapLumpInfo > maplumps )
{
2013-09-11 09:47:53 +00:00
// Find the specific lump index
2014-11-11 11:47:10 +00:00
int lumpindex = FindSpecificLump ( source , lumpname , mapheaderindex , mapheadername , maplumps ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( lumpindex > - 1 )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Remove this lump
//General.WriteLogLine(lumpname + " removed");
source . RemoveAt ( lumpindex ) ;
}
2014-11-11 11:47:10 +00:00
/ * else
{
2013-09-11 09:47:53 +00:00
// Lump not found
2014-11-11 11:47:10 +00:00
General . ErrorLogger . Add ( ErrorType . Warning , lumpname + " should be removed but was not found!" ) ;
} * /
2013-09-11 09:47:53 +00:00
// Return result
return lumpindex ;
}
#endregion
#region = = = = = = = = = = = = = = = = = = Selection Groups
// This adds selection to a group
2014-11-11 11:47:10 +00:00
private void AddSelectionToGroup ( int groupindex )
{
2013-09-11 09:47:53 +00:00
General . Interface . SetCursor ( Cursors . WaitCursor ) ;
// Make selection
2013-04-01 11:06:01 +00:00
map . AddSelectionToGroup ( groupindex ) ; //mxd. switched groupmask to groupindex
2012-07-10 10:20:45 +00:00
2013-04-01 11:06:01 +00:00
General . Interface . DisplayStatus ( StatusType . Action , "Assigned selection to group " + ( groupindex + 1 ) ) ;
2013-09-11 09:47:53 +00:00
General . Interface . SetCursor ( Cursors . Default ) ;
}
// This selects a group
2014-11-11 11:47:10 +00:00
private void SelectGroup ( int groupindex )
{
2013-09-11 09:47:53 +00:00
// Select
int groupmask = 0x01 < < groupindex ;
map . SelectVerticesByGroup ( groupmask ) ;
map . SelectLinedefsByGroup ( groupmask ) ;
map . SelectSectorsByGroup ( groupmask ) ;
map . SelectThingsByGroup ( groupmask ) ;
// Redraw to show selection
2013-04-01 11:06:01 +00:00
General . Interface . DisplayStatus ( StatusType . Action , "Selected group " + ( groupindex + 1 ) ) ;
2013-09-11 09:47:53 +00:00
General . Interface . RedrawDisplay ( ) ;
}
2012-07-10 10:20:45 +00:00
2013-04-01 11:06:01 +00:00
//mxd. This clears a group
2014-11-11 11:47:10 +00:00
private void ClearGroup ( int groupindex )
{
2013-04-01 11:06:01 +00:00
General . Interface . SetCursor ( Cursors . WaitCursor ) ;
// Clear group
2014-07-16 09:45:04 +00:00
map . ClearGroup ( 0x01 < < groupindex ) ;
2013-04-01 11:06:01 +00:00
General . Interface . DisplayStatus ( StatusType . Action , "Cleared group " + ( groupindex + 1 ) ) ;
General . Interface . SetCursor ( Cursors . Default ) ;
}
2013-09-11 09:47:53 +00:00
// Select actions
[BeginAction("selectgroup1")]
internal void SelectGroup1 ( ) { SelectGroup ( 0 ) ; }
[BeginAction("selectgroup2")]
internal void SelectGroup2 ( ) { SelectGroup ( 1 ) ; }
[BeginAction("selectgroup3")]
internal void SelectGroup3 ( ) { SelectGroup ( 2 ) ; }
[BeginAction("selectgroup4")]
internal void SelectGroup4 ( ) { SelectGroup ( 3 ) ; }
[BeginAction("selectgroup5")]
internal void SelectGroup5 ( ) { SelectGroup ( 4 ) ; }
[BeginAction("selectgroup6")]
internal void SelectGroup6 ( ) { SelectGroup ( 5 ) ; }
[BeginAction("selectgroup7")]
internal void SelectGroup7 ( ) { SelectGroup ( 6 ) ; }
[BeginAction("selectgroup8")]
internal void SelectGroup8 ( ) { SelectGroup ( 7 ) ; }
[BeginAction("selectgroup9")]
internal void SelectGroup9 ( ) { SelectGroup ( 8 ) ; }
[BeginAction("selectgroup10")]
internal void SelectGroup10 ( ) { SelectGroup ( 9 ) ; }
// Assign actions
[BeginAction("assigngroup1")]
internal void AssignGroup1 ( ) { AddSelectionToGroup ( 0 ) ; }
[BeginAction("assigngroup2")]
internal void AssignGroup2 ( ) { AddSelectionToGroup ( 1 ) ; }
[BeginAction("assigngroup3")]
internal void AssignGroup3 ( ) { AddSelectionToGroup ( 2 ) ; }
[BeginAction("assigngroup4")]
internal void AssignGroup4 ( ) { AddSelectionToGroup ( 3 ) ; }
[BeginAction("assigngroup5")]
internal void AssignGroup5 ( ) { AddSelectionToGroup ( 4 ) ; }
[BeginAction("assigngroup6")]
internal void AssignGroup6 ( ) { AddSelectionToGroup ( 5 ) ; }
[BeginAction("assigngroup7")]
internal void AssignGroup7 ( ) { AddSelectionToGroup ( 6 ) ; }
[BeginAction("assigngroup8")]
internal void AssignGroup8 ( ) { AddSelectionToGroup ( 7 ) ; }
[BeginAction("assigngroup9")]
internal void AssignGroup9 ( ) { AddSelectionToGroup ( 8 ) ; }
[BeginAction("assigngroup10")]
internal void AssignGroup10 ( ) { AddSelectionToGroup ( 9 ) ; }
2012-07-10 10:20:45 +00:00
2013-04-01 11:06:01 +00:00
//mxd. Clear actions
[BeginAction("cleargroup1")]
internal void ClearGroup1 ( ) { ClearGroup ( 0 ) ; }
[BeginAction("cleargroup2")]
internal void ClearGroup2 ( ) { ClearGroup ( 1 ) ; }
[BeginAction("cleargroup3")]
internal void ClearGroup3 ( ) { ClearGroup ( 2 ) ; }
[BeginAction("cleargroup4")]
internal void ClearGroup4 ( ) { ClearGroup ( 3 ) ; }
[BeginAction("cleargroup5")]
internal void ClearGroup5 ( ) { ClearGroup ( 4 ) ; }
[BeginAction("cleargroup6")]
internal void ClearGroup6 ( ) { ClearGroup ( 5 ) ; }
[BeginAction("cleargroup7")]
internal void ClearGroup7 ( ) { ClearGroup ( 6 ) ; }
[BeginAction("cleargroup8")]
internal void ClearGroup8 ( ) { ClearGroup ( 7 ) ; }
[BeginAction("cleargroup9")]
internal void ClearGroup9 ( ) { ClearGroup ( 8 ) ; }
[BeginAction("cleargroup10")]
internal void ClearGroup10 ( ) { ClearGroup ( 9 ) ; }
2013-09-11 09:47:53 +00:00
#endregion
2016-02-01 22:04:00 +00:00
#region = = = = = = = = = = = = = = = = = = [ mxd ] GZDB actions
[BeginAction("gztogglemodels")]
internal void ToggleModelsRenderingMode ( )
{
switch ( General . Settings . GZDrawModelsMode )
{
case ModelRenderMode . NONE :
General . Settings . GZDrawModelsMode = ModelRenderMode . SELECTION ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Models rendering mode: SELECTION ONLY" ) ;
break ;
case ModelRenderMode . SELECTION :
General . Settings . GZDrawModelsMode = ModelRenderMode . ACTIVE_THINGS_FILTER ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Models rendering mode: ACTIVE THINGS FILTER ONLY" ) ;
break ;
case ModelRenderMode . ACTIVE_THINGS_FILTER :
General . Settings . GZDrawModelsMode = ModelRenderMode . ALL ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Models rendering mode: ALL" ) ;
break ;
case ModelRenderMode . ALL :
General . Settings . GZDrawModelsMode = ModelRenderMode . NONE ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Models rendering mode: NONE" ) ;
break ;
}
General . MainWindow . RedrawDisplay ( ) ;
General . MainWindow . UpdateGZDoomPanel ( ) ;
}
[BeginAction("gztogglelights")]
internal void ToggleLightsRenderingMode ( )
{
if ( General . Editing . Mode is ClassicMode )
{
switch ( General . Settings . GZDrawLightsMode )
{
case LightRenderMode . NONE :
General . Settings . GZDrawLightsMode = LightRenderMode . ALL ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Dynamic lights rendering mode: ALL" ) ;
break ;
default :
General . Settings . GZDrawLightsMode = LightRenderMode . NONE ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Dynamic lights rendering mode: NONE" ) ;
break ;
}
}
else
{
switch ( General . Settings . GZDrawLightsMode )
{
case LightRenderMode . NONE :
General . Settings . GZDrawLightsMode = LightRenderMode . ALL ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Dynamic lights rendering mode: ALL" ) ;
break ;
case LightRenderMode . ALL :
General . Settings . GZDrawLightsMode = LightRenderMode . ALL_ANIMATED ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Dynamic lights rendering mode: ANIMATED" ) ;
break ;
case LightRenderMode . ALL_ANIMATED :
General . Settings . GZDrawLightsMode = LightRenderMode . NONE ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Dynamic lights rendering mode: NONE" ) ;
break ;
}
}
General . MainWindow . RedrawDisplay ( ) ;
General . MainWindow . UpdateGZDoomPanel ( ) ;
}
[BeginAction("gztogglefog")]
internal void ToggleFog ( )
{
General . Settings . GZDrawFog = ! General . Settings . GZDrawFog ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Fog rendering is " + ( General . Settings . GZDrawFog ? "ENABLED" : "DISABLED" ) ) ;
General . MainWindow . RedrawDisplay ( ) ;
General . MainWindow . UpdateGZDoomPanel ( ) ;
}
[BeginAction("gztogglesky")]
internal void ToggleSky ( )
{
General . Settings . GZDrawSky = ! General . Settings . GZDrawSky ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Sky rendering is " + ( General . Settings . GZDrawSky ? "ENABLED" : "DISABLED" ) ) ;
General . MainWindow . RedrawDisplay ( ) ;
General . MainWindow . UpdateGZDoomPanel ( ) ;
}
[BeginAction("gztogglefx")]
internal void ToggleFx ( )
{
int on = 0 ;
on + = General . Settings . GZDrawFog ? 1 : - 1 ;
on + = General . Settings . GZDrawSky ? 1 : - 1 ;
on + = General . Settings . GZDrawLightsMode ! = LightRenderMode . NONE ? 1 : - 1 ;
on + = General . Settings . GZDrawModelsMode ! = ModelRenderMode . NONE ? 1 : - 1 ;
bool enable = ( on < 0 ) ;
General . Settings . GZDrawFog = enable ;
General . Settings . GZDrawSky = enable ;
General . Settings . GZDrawLightsMode = ( enable ? LightRenderMode . ALL : LightRenderMode . NONE ) ;
General . Settings . GZDrawModelsMode = ( enable ? ModelRenderMode . ALL : ModelRenderMode . NONE ) ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Advanced effects are " + ( enable ? "ENABLED" : "DISABLED" ) ) ;
General . MainWindow . RedrawDisplay ( ) ;
General . MainWindow . UpdateGZDoomPanel ( ) ;
}
[BeginAction("gztoggleeventlines")]
internal void ToggleEventLines ( )
{
General . Settings . GZShowEventLines = ! General . Settings . GZShowEventLines ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Event lines are " + ( General . Settings . GZShowEventLines ? "ENABLED" : "DISABLED" ) ) ;
General . MainWindow . RedrawDisplay ( ) ;
General . MainWindow . UpdateGZDoomPanel ( ) ;
}
[BeginAction("gztogglevisualvertices")]
internal void ToggleVisualVertices ( )
{
General . Settings . GZShowVisualVertices = ! General . Settings . GZShowVisualVertices ;
General . MainWindow . DisplayStatus ( StatusType . Action , "Visual vertices are " + ( General . Settings . GZShowVisualVertices ? "ENABLED" : "DISABLED" ) ) ;
General . MainWindow . RedrawDisplay ( ) ;
General . MainWindow . UpdateGZDoomPanel ( ) ;
}
[BeginAction("gzreloadmodeldef")]
internal void ReloadModeldef ( )
{
data . ReloadModeldef ( ) ;
}
[BeginAction("gzreloadgldefs")]
internal void ReloadGldefs ( )
{
data . ReloadGldefs ( ) ;
}
#endregion
2013-09-11 09:47:53 +00:00
#region = = = = = = = = = = = = = = = = = = Script Editing
// Show the script editor
[BeginAction("openscripteditor")]
2014-11-11 11:47:10 +00:00
internal void ShowScriptEditor ( )
{
2013-09-11 09:47:53 +00:00
Cursor . Current = Cursors . WaitCursor ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( scriptwindow = = null )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Load the window
scriptwindow = new ScriptEditorForm ( ) ;
}
// Window not yet visible?
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( ! scriptwindow . Visible )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Show the window
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( General . Settings . ScriptOnTop )
2014-11-11 11:47:10 +00:00
{
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( scriptwindow . Visible & & ( scriptwindow . Owner = = null ) ) scriptwindow . Hide ( ) ;
2013-09-11 09:47:53 +00:00
scriptwindow . Show ( General . MainWindow ) ;
}
2014-11-11 11:47:10 +00:00
else
{
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( scriptwindow . Visible & & ( scriptwindow . Owner ! = null ) ) scriptwindow . Hide ( ) ;
2013-09-11 09:47:53 +00:00
scriptwindow . Show ( ) ;
}
}
2015-07-27 09:02:28 +00:00
if ( scriptwindow . WindowState = = FormWindowState . Minimized ) scriptwindow . WindowState = FormWindowState . Normal ; //mxd
2013-09-11 09:47:53 +00:00
scriptwindow . Activate ( ) ;
scriptwindow . Focus ( ) ;
Cursor . Current = Cursors . Default ;
}
// This asks the user to save changes in script files
// Returns false when cancelled by the user
2014-11-11 11:47:10 +00:00
internal bool AskSaveScriptChanges ( )
{
2013-09-11 09:47:53 +00:00
// Window open?
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( scriptwindow ! = null )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Ask to save changes
// This also saves implicitly
return scriptwindow . AskSaveAll ( ) ;
}
2013-07-23 14:25:03 +00:00
// No problems
return true ;
2013-09-11 09:47:53 +00:00
}
// This applies the changed status for internal scripts
2014-11-11 11:47:10 +00:00
internal void ApplyScriptChanged ( )
{
2013-09-11 09:47:53 +00:00
// Remember if lumps are changed
scriptschanged | = scriptwindow . Editor . CheckImplicitChanges ( ) ;
}
// Close the script editor
// Specify true for the closing parameter when
// the window is already in the closing process
2014-11-11 11:47:10 +00:00
internal void CloseScriptEditor ( bool closing )
{
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( scriptwindow ! = null )
2014-11-11 11:47:10 +00:00
{
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( ! scriptwindow . IsDisposed )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Remember what files were open
scriptwindow . Editor . WriteOpenFilesToConfiguration ( ) ;
// Close now
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( ! closing ) scriptwindow . Close ( ) ;
2013-09-11 09:47:53 +00:00
}
// Done
scriptwindow = null ;
}
}
// This checks if the scripts are changed
2015-11-30 14:18:42 +00:00
private bool CheckScriptChanged ( )
2014-11-11 11:47:10 +00:00
{
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( scriptwindow ! = null )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Check if scripts are changed
return scriptschanged | | scriptwindow . Editor . CheckImplicitChanges ( ) ;
}
2013-07-23 14:25:03 +00:00
2013-09-11 09:47:53 +00:00
return scriptschanged ;
}
// This compiles all lumps that require compiling and stores the results
// Returns true when our code worked properly (even when the compiler returned errors)
2014-11-11 11:47:10 +00:00
private bool CompileScriptLumps ( )
{
2013-09-11 09:47:53 +00:00
bool success = true ;
errors . Clear ( ) ;
// Go for all the map lumps
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
foreach ( MapLumpInfo lumpinfo in config . MapLumps . Values )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Is this a script lump?
2014-11-11 11:47:10 +00:00
if ( lumpinfo . Script ! = null | | lumpinfo . ScriptBuild )
{
2013-09-11 09:47:53 +00:00
// Compile it now
2014-11-11 11:47:10 +00:00
success & = CompileLump ( lumpinfo . Name , false ) ;
2013-09-11 09:47:53 +00:00
}
}
return success ;
}
// 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)
2014-11-11 11:47:10 +00:00
internal bool CompileLump ( string lumpname , bool clearerrors )
{
2015-01-28 23:33:56 +00:00
//mxd. Boilerplate
if ( ! config . MapLumps . ContainsKey ( lumpname ) )
{
General . ShowErrorMessage ( "Unable to compile lump '" + lumpname + "'. This lump is not defined in the current game configuration." , MessageBoxButtons . OK ) ;
return false ;
}
2014-11-11 11:47:10 +00:00
string inputfile ;
2013-09-11 09:47:53 +00:00
Compiler compiler ;
string reallumpname = lumpname ;
2012-07-10 10:20:45 +00:00
2013-07-23 14:25:03 +00:00
//mxd. Does lump require compiling?
2014-07-11 10:13:26 +00:00
ScriptConfiguration scriptconfig ;
2014-11-11 11:47:10 +00:00
if ( config . MapLumps [ lumpname ] . ScriptBuild )
{
2015-01-29 08:18:11 +00:00
//mxd. More boilderplate
if ( ! General . CompiledScriptConfigs . ContainsKey ( General . Map . Options . ScriptCompiler ) )
{
General . ShowErrorMessage ( "Unable to compile lump '" + lumpname + "'. Unable to find required script compiler configuration ('" + General . Map . Options . ScriptCompiler + "')." , MessageBoxButtons . OK ) ;
return false ;
}
2014-07-11 10:13:26 +00:00
scriptconfig = General . CompiledScriptConfigs [ General . Map . Options . ScriptCompiler ] ;
2014-11-11 11:47:10 +00:00
}
else
{
scriptconfig = config . MapLumps [ lumpname ] . Script ;
2014-07-11 10:13:26 +00:00
}
2015-11-13 21:42:41 +00:00
if ( scriptconfig . Compiler = = null ) return true ;
2013-07-23 14:25:03 +00:00
2013-09-11 09:47:53 +00:00
// Find the lump
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( lumpname = = CONFIG_MAP_HEADER ) reallumpname = TEMP_MAP_HEADER ;
2013-09-11 09:47:53 +00:00
Lump lump = tempwad . FindLump ( reallumpname ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( lump = = null ) throw new Exception ( "No such lump in temporary wad file '" + reallumpname + "'." ) ;
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Determine source file
2014-11-11 11:47:10 +00:00
string sourcefile = ( filepathname . Length > 0 ? filepathname : tempwad . Filename ) ;
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// New list of errors
2015-11-13 21:42:41 +00:00
if ( clearerrors ) errors . Clear ( ) ;
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Determine the script configuration to use
2014-11-11 11:47:10 +00:00
try
{
2013-07-23 14:25:03 +00:00
// Initialize compiler
compiler = scriptconfig . Compiler . Create ( ) ;
2014-11-11 11:47:10 +00:00
}
catch ( Exception e )
{
2013-07-23 14:25:03 +00:00
// Fail
errors . Add ( new CompilerError ( "Unable to initialize compiler. " + e . GetType ( ) . Name + ": " + e . Message ) ) ;
return false ;
}
2014-11-11 11:47:10 +00:00
try
{
2013-07-23 14:25:03 +00:00
// Write lump data to temp script file in compiler's temp directory
inputfile = General . MakeTempFilename ( compiler . Location , "tmp" ) ;
lump . Stream . Seek ( 0 , SeekOrigin . Begin ) ;
BinaryReader reader = new BinaryReader ( lump . Stream ) ;
File . WriteAllBytes ( inputfile , reader . ReadBytes ( ( int ) lump . Stream . Length ) ) ;
2014-11-11 11:47:10 +00:00
}
catch ( Exception e )
{
2013-07-23 14:25:03 +00:00
// Fail
compiler . Dispose ( ) ;
errors . Add ( new CompilerError ( "Unable to write script to working file. " + e . GetType ( ) . Name + ": " + e . Message ) ) ;
return false ;
}
// Make random output filename
2014-11-11 11:47:10 +00:00
string outputfile = General . MakeTempFilename ( compiler . Location , "tmp" ) ;
2013-07-23 14:25:03 +00:00
// Run compiler
compiler . Parameters = scriptconfig . Parameters ;
compiler . InputFile = Path . GetFileName ( inputfile ) ;
compiler . OutputFile = Path . GetFileName ( outputfile ) ;
compiler . SourceFile = sourcefile ;
compiler . WorkingDirectory = Path . GetDirectoryName ( inputfile ) ;
2015-11-30 14:18:42 +00:00
//mxd
if ( scriptconfig . ScriptType = = ScriptType . ACS )
{
compiler . Includes = General . Map . ScriptIncludes ;
compiler . CopyIncludesToWorkingDirectory = true ;
}
2014-11-11 11:47:10 +00:00
if ( compiler . Run ( ) )
{
2013-07-23 14:25:03 +00:00
// Process errors
2014-11-11 11:47:10 +00:00
foreach ( CompilerError e in compiler . Errors )
{
2013-07-23 14:25:03 +00:00
CompilerError newerror = e ;
// If the error's filename equals our temporary file,
// use the lump name instead and prefix it with ?
if ( string . Compare ( e . filename , inputfile , true ) = = 0 )
newerror . filename = "?" + reallumpname ;
errors . Add ( newerror ) ;
}
2012-07-10 10:20:45 +00:00
2013-07-23 14:25:03 +00:00
// No errors?
2014-11-11 11:47:10 +00:00
if ( compiler . Errors . Length = = 0 )
{
2013-07-23 14:25:03 +00:00
// Output file exists?
2014-11-11 11:47:10 +00:00
if ( File . Exists ( outputfile ) )
{
2013-07-23 14:25:03 +00:00
// Copy output file data into a lump?
2014-11-11 11:47:10 +00:00
if ( ! string . IsNullOrEmpty ( scriptconfig . ResultLump ) )
{
2013-07-23 14:25:03 +00:00
// Do that now then
2015-01-28 23:33:56 +00:00
byte [ ] filedata ;
2014-11-11 11:47:10 +00:00
try
{
2013-07-23 14:25:03 +00:00
filedata = File . ReadAllBytes ( outputfile ) ;
2014-11-11 11:47:10 +00:00
}
catch ( Exception e )
{
2013-07-23 14:25:03 +00:00
// Fail
compiler . Dispose ( ) ;
errors . Add ( new CompilerError ( "Unable to read compiler output file. " + e . GetType ( ) . Name + ": " + e . Message ) ) ;
return false ;
}
// Store data
MemoryStream stream = new MemoryStream ( filedata ) ;
SetLumpData ( scriptconfig . ResultLump , stream ) ;
}
}
}
2012-07-10 10:20:45 +00:00
2013-07-23 14:25:03 +00:00
// Clean up
compiler . Dispose ( ) ;
2012-07-10 10:20:45 +00:00
2013-07-23 14:25:03 +00:00
// Done
return true ;
}
2012-07-10 10:20:45 +00:00
2013-07-23 14:25:03 +00:00
// Fail
compiler . Dispose ( ) ;
2013-12-05 09:42:29 +00:00
errors . Clear ( ) ; //mxd
2013-07-23 14:25:03 +00:00
return false ;
2013-09-11 09:47:53 +00:00
}
// This clears all compiler errors
2015-01-29 08:00:41 +00:00
/ * internal void ClearCompilerErrors ( )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
errors . Clear ( ) ;
2015-01-29 08:00:41 +00:00
} * /
2013-09-11 09:47:53 +00:00
2015-11-13 21:42:41 +00:00
//mxd. Update includes list and script names
internal List < CompilerError > UpdateScriptNames ( bool logerrors )
{
List < CompilerError > compilererrors = UpdateScriptNames ( ) ;
if ( logerrors & & compilererrors . Count > 0 )
{
2015-12-17 10:07:28 +00:00
//INFO: CompileLump() prepends lumpname with "?" to distinguish between temporary files and files compiled in place
//INFO: also, error.linenumber is zero-based
2015-11-13 21:42:41 +00:00
foreach ( CompilerError error in compilererrors )
{
2015-12-17 10:07:28 +00:00
General . ErrorLogger . Add ( ErrorType . Error , "ACS error in '" + ( error . filename . StartsWith ( "?" ) ? error . filename . Replace ( "?" , "" ) : error . filename )
+ ( error . linenumber ! = CompilerError . NO_LINE_NUMBER ? "', line " + ( error . linenumber + 1 ) : "'" )
2015-11-30 14:18:42 +00:00
+ ". " + error . description + "." ) ;
2015-11-13 21:42:41 +00:00
}
}
return compilererrors ;
}
//mxd. Update includes list and script names
internal List < CompilerError > UpdateScriptNames ( )
2014-11-11 11:47:10 +00:00
{
2015-07-27 09:02:28 +00:00
List < ScriptItem > namedscriptslist = new List < ScriptItem > ( ) ;
List < ScriptItem > numberedscriptslist = new List < ScriptItem > ( ) ;
2015-11-13 21:42:41 +00:00
List < string > scripincludeslist = new List < string > ( ) ;
List < CompilerError > compilererrors = new List < CompilerError > ( ) ;
2013-09-11 09:47:53 +00:00
// Load the script lumps
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
foreach ( MapLumpInfo maplumpinfo in config . MapLumps . Values )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Is this a script lump?
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( ( maplumpinfo . ScriptBuild | | maplumpinfo . Script ! = null ) & & maplumpinfo . Name = = "SCRIPTS" )
2014-11-11 11:47:10 +00:00
{
2015-11-13 21:42:41 +00:00
ScriptConfiguration scriptconfig ;
if ( maplumpinfo . ScriptBuild )
{
//mxd. More boilderplate
if ( ! General . CompiledScriptConfigs . ContainsKey ( General . Map . Options . ScriptCompiler ) )
{
compilererrors . Add ( new CompilerError ( "Unable to compile lump '" + maplumpinfo . Name + "'. Unable to find required script compiler configuration ('" + General . Map . Options . ScriptCompiler + "')." ) ) ;
return compilererrors ;
}
scriptconfig = General . CompiledScriptConfigs [ General . Map . Options . ScriptCompiler ] ;
}
else
{
scriptconfig = maplumpinfo . Script ;
}
2013-09-11 09:47:53 +00:00
// Load the lump data
2014-11-11 11:47:10 +00:00
MemoryStream stream = GetLumpData ( maplumpinfo . Name ) ;
2015-11-28 20:59:32 +00:00
if ( stream ! = null & & stream . Length > 0 & & scriptconfig ! = null & & scriptconfig . Compiler ! = null )
2014-11-11 11:47:10 +00:00
{
2015-01-22 20:34:27 +00:00
// Get script names
2015-12-27 21:54:50 +00:00
AcsParserSE parser = new AcsParserSE { OnInclude = ( se , path , includetype ) = > se . Parse ( General . Map . Data . LoadFile ( path ) , path , true , includetype , false ) } ;
2015-12-17 10:07:28 +00:00
//INFO: CompileLump() prepends lumpname with "?" to distinguish between temporary files and files compiled in place
2015-12-27 21:54:50 +00:00
if ( parser . Parse ( stream , "?SCRIPTS" , scriptconfig . Compiler . Files , true , AcsParserSE . IncludeType . NONE , false ) )
2015-11-13 21:42:41 +00:00
{
// Add them to arrays
namedscriptslist . AddRange ( parser . NamedScripts ) ;
numberedscriptslist . AddRange ( parser . NumberedScripts ) ;
scripincludeslist . AddRange ( parser . Includes ) ;
}
2015-12-17 10:07:28 +00:00
2015-11-13 21:42:41 +00:00
// Check for errors
2015-12-17 10:07:28 +00:00
if ( parser . HasError )
2015-11-13 21:42:41 +00:00
{
compilererrors . Add ( new CompilerError ( parser . ErrorDescription , parser . ErrorSource , parser . ErrorLine ) ) ;
break ;
}
2016-02-01 22:04:00 +00:00
parser . Dispose ( ) ;
2013-09-11 09:47:53 +00:00
}
}
}
2015-07-27 09:02:28 +00:00
// Add to collections
2015-11-13 21:42:41 +00:00
scriptincludes . Clear ( ) ;
if ( compilererrors . Count = = 0 )
2015-07-27 09:02:28 +00:00
{
2015-11-13 21:42:41 +00:00
namedscripts = new Dictionary < string , ScriptItem > ( namedscriptslist . Count ) ;
numberedscripts = new Dictionary < int , ScriptItem > ( numberedscriptslist . Count ) ;
// Sort script names
namedscriptslist . Sort ( ScriptItem . SortByName ) ;
numberedscriptslist . Sort ( ScriptItem . SortByIndex ) ;
foreach ( ScriptItem item in namedscriptslist )
if ( ! namedscripts . ContainsKey ( item . Name . ToLowerInvariant ( ) ) ) namedscripts . Add ( item . Name . ToLowerInvariant ( ) , item ) ;
foreach ( ScriptItem item in numberedscriptslist )
if ( ! numberedscripts . ContainsKey ( item . Index ) ) numberedscripts . Add ( item . Index , item ) ;
foreach ( string include in scripincludeslist )
if ( ! scriptincludes . Contains ( include ) ) scriptincludes . Add ( include ) ;
2015-07-27 09:02:28 +00:00
}
2015-11-13 21:42:41 +00:00
else
2015-07-27 09:02:28 +00:00
{
2015-11-13 21:42:41 +00:00
// Clear collections
namedscripts . Clear ( ) ;
numberedscripts . Clear ( ) ;
2015-07-27 09:02:28 +00:00
}
2015-11-13 21:42:41 +00:00
return compilererrors ;
2013-09-11 09:47:53 +00:00
}
#endregion
#region = = = = = = = = = = = = = = = = = = Methods
// This updates everything after the configuration or settings have been changed
2014-11-11 11:47:10 +00:00
internal void UpdateConfiguration ( )
{
2013-09-11 09:47:53 +00:00
// Update map
map . UpdateConfiguration ( ) ;
// Update settings
renderer3d . CreateProjection ( ) ;
2014-09-20 22:05:23 +00:00
renderer3d . UpdateVertexHandle ( ) ; //mxd
2013-09-11 09:47:53 +00:00
// Things filters
General . MainWindow . UpdateThingsFilters ( ) ;
}
// This changes thing filter
2014-11-11 11:47:10 +00:00
public void ChangeThingFilter ( ThingsFilter newfilter )
{
2013-09-11 09:47:53 +00:00
// We have a special filter for null
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( newfilter = = null ) newfilter = new NullThingsFilter ( ) ;
2013-09-11 09:47:53 +00:00
// Deactivate old filter
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( thingsfilter ! = null ) thingsfilter . Deactivate ( ) ;
2013-09-11 09:47:53 +00:00
// Change
thingsfilter = newfilter ;
// Activate filter
thingsfilter . Activate ( ) ;
// Update interface
General . MainWindow . ReflectThingsFilter ( ) ;
// Redraw
General . MainWindow . RedrawDisplay ( ) ;
}
// This sets a new mapset for editing
2015-09-25 13:20:53 +00:00
private void ChangeMapSet ( MapSet newmap )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Let the plugin and editing mode know
General . Plugins . OnMapSetChangeBegin ( ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( General . Editing . Mode ! = null ) General . Editing . Mode . OnMapSetChangeBegin ( ) ;
2013-09-11 09:47:53 +00:00
this . visualcamera . Sector = null ;
// Can't have a selection in an old map set
map . ClearAllSelected ( ) ;
// Reset surfaces
renderer2d . Surfaces . Reset ( ) ;
// Apply
map . Dispose ( ) ;
map = newmap ;
map . UpdateConfiguration ( ) ;
map . SnapAllToAccuracy ( ) ;
map . Update ( ) ;
thingsfilter . Update ( ) ;
// Let the plugin and editing mode know
General . Plugins . OnMapSetChangeEnd ( ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( General . Editing . Mode ! = null ) General . Editing . Mode . OnMapSetChangeEnd ( ) ;
2013-09-11 09:47:53 +00:00
}
// This reloads resources
[BeginAction("reloadresources")]
2014-11-11 11:47:10 +00:00
internal void DoReloadResource ( )
{
2015-01-20 07:58:47 +00:00
//mxd. Get rid of old errors
General . ErrorLogger . Clear ( ) ;
2013-09-11 09:47:53 +00:00
// Set this to false so we can see if errors are added
General . ErrorLogger . IsErrorAdded = false ;
2014-12-11 12:55:35 +00:00
#if DEBUG
DebugConsole . Clear ( ) ;
#endif
2013-09-11 09:47:53 +00:00
ReloadResources ( ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( General . ErrorLogger . IsErrorAdded )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Show any errors if preferred
General . MainWindow . DisplayStatus ( StatusType . Warning , "There were errors during resources loading!" ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( General . Settings . ShowErrorsWindow ) General . MainWindow . ShowErrors ( ) ;
2013-09-11 09:47:53 +00:00
}
else
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
General . MainWindow . DisplayReady ( ) ;
2014-11-11 11:47:10 +00:00
}
2013-09-11 09:47:53 +00:00
}
2014-11-11 11:47:10 +00:00
internal void ReloadResources ( )
{
2013-09-11 09:47:53 +00:00
// Keep old display info
2014-03-04 09:04:43 +00:00
StatusInfo oldstatus = General . MainWindow . Status ;
Cursor oldcursor = Cursor . Current ;
2013-09-11 09:47:53 +00:00
// Show status
General . MainWindow . DisplayStatus ( StatusType . Busy , "Reloading data resources..." ) ;
Cursor . Current = Cursors . WaitCursor ;
// Clean up
data . Dispose ( ) ;
data = null ;
config = null ;
configinfo = null ;
GC . Collect ( ) ;
GC . WaitForPendingFinalizers ( ) ;
2015-05-27 12:38:03 +00:00
GC . Collect ( ) ; //mxd
2013-09-11 09:47:53 +00:00
2014-05-19 13:33:38 +00:00
// Clear errors
General . ErrorLogger . Clear ( ) ;
2013-09-11 09:47:53 +00:00
// Reload game configuration
General . WriteLogLine ( "Reloading game configuration..." ) ;
configinfo = General . GetConfigurationInfo ( options . ConfigFile ) ;
2014-02-18 14:04:14 +00:00
config = new GameConfiguration ( configinfo . Configuration ) ; //mxd
2013-09-11 09:47:53 +00:00
General . Editing . UpdateCurrentEditModes ( ) ;
// Reload data resources
General . WriteLogLine ( "Reloading data resources..." ) ;
data = new DataManager ( ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( ! string . IsNullOrEmpty ( filepathname ) )
2014-11-11 11:47:10 +00:00
{
2014-03-04 09:04:43 +00:00
DataLocation maplocation = new DataLocation ( DataLocation . RESOURCE_WAD , filepathname , false , false , false ) ;
2013-09-11 09:47:53 +00:00
data . Load ( configinfo . Resources , options . Resources , maplocation ) ;
}
2014-11-11 11:47:10 +00:00
else
{
2013-09-11 09:47:53 +00:00
data . Load ( configinfo . Resources , options . Resources ) ;
}
// Apply new settings to map elements
map . UpdateConfiguration ( ) ;
// Re-link the background image
grid . LinkBackground ( ) ;
// Inform all plugins that the resources are reloaded
General . Plugins . ReloadResources ( ) ;
// Inform editing mode that the resources are reloaded
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( General . Editing . Mode ! = null ) General . Editing . Mode . OnReloadResources ( ) ;
2013-09-11 09:47:53 +00:00
// Reset status
General . MainWindow . DisplayStatus ( oldstatus ) ;
Cursor . Current = oldcursor ;
2015-11-13 21:42:41 +00:00
//mxd. Update includes list and script names
UpdateScriptNames ( true ) ;
2013-09-11 09:47:53 +00:00
}
// Game Configuration action
[BeginAction("mapoptions")]
2014-11-11 11:47:10 +00:00
internal void ShowMapOptions ( )
{
2013-09-11 09:47:53 +00:00
// Cancel volatile mode, if any
General . Editing . DisengageVolatileMode ( ) ;
// Show map options dialog
MapOptionsForm optionsform = new MapOptionsForm ( options , false ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( optionsform . ShowDialog ( General . MainWindow ) = = DialogResult . OK )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Update interface
2015-03-05 23:19:10 +00:00
//General.MainWindow.UpdateInterface();
2013-09-11 09:47:53 +00:00
// Stop data manager
data . Dispose ( ) ;
// Apply new options
this . options = optionsform . Options ;
// Load new game configuration
2014-02-18 14:04:14 +00:00
General . WriteLogLine ( "Loading game configuration '" + options . ConfigFile + "'..." ) ;
2013-09-11 09:47:53 +00:00
configinfo = General . GetConfigurationInfo ( options . ConfigFile ) ;
2014-12-29 09:19:20 +00:00
Type oldiotype = io . GetType ( ) ; //mxd
2015-12-09 21:17:05 +00:00
2016-01-18 20:37:21 +00:00
//mxd. Step 1 of hackish way to translate SP/MP thing flags to Hexen / UDMF formats...
2015-12-09 21:17:05 +00:00
//TODO: add proper Doom -> Hexen thing flags translation to the configs?
2016-01-18 20:37:21 +00:00
if ( oldiotype = = typeof ( DoomMapSetIO ) & & configinfo . FormatInterface ! = "doommapsetio" )
2015-12-09 21:17:05 +00:00
{
// Translate to UDMF using Doom things flags translation table
foreach ( Thing t in General . Map . Map . Things ) t . TranslateToUDMF ( ) ;
}
2014-02-18 14:04:14 +00:00
config = new GameConfiguration ( configinfo . Configuration ) ; //mxd
2013-09-11 09:47:53 +00:00
configinfo . ApplyDefaults ( config ) ;
General . Editing . UpdateCurrentEditModes ( ) ;
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Setup new map format IO
General . WriteLogLine ( "Initializing map format interface " + config . FormatInterface + "..." ) ;
io = MapSetIO . Create ( config . FormatInterface , tempwad , this ) ;
2012-07-10 10:20:45 +00:00
2013-07-23 14:25:03 +00:00
//mxd. Some lumps may've become unneeded during map format conversion.
2014-12-29 09:19:20 +00:00
if ( oldiotype ! = io . GetType ( ) )
2014-12-22 21:36:49 +00:00
RemoveUnneededLumps ( tempwad , TEMP_MAP_HEADER , false ) ;
2013-07-23 14:25:03 +00:00
2013-09-11 09:47:53 +00:00
// Create required lumps if they don't exist yet
CreateRequiredLumps ( tempwad , TEMP_MAP_HEADER ) ;
2012-07-10 10:20:45 +00:00
2013-09-11 09:47:53 +00:00
// Let the plugins know
General . Plugins . MapReconfigure ( ) ;
2012-07-10 10:20:45 +00:00
2013-05-27 12:20:15 +00:00
//mxd. Update linedef color presets and flags if required
2014-12-29 09:19:20 +00:00
if ( oldiotype = = typeof ( UniversalMapSetIO ) & & ! ( io is UniversalMapSetIO ) )
2014-11-11 11:47:10 +00:00
{
2013-05-31 13:57:49 +00:00
foreach ( Linedef l in General . Map . Map . Linedefs ) l . TranslateFromUDMF ( ) ;
foreach ( Thing t in General . Map . Map . Things ) t . TranslateFromUDMF ( ) ;
2014-11-11 11:47:10 +00:00
}
2016-01-18 20:37:21 +00:00
else if ( oldiotype = = typeof ( DoomMapSetIO ) )
{
if ( io is UniversalMapSetIO )
{
//Thing flags were already translated in Setp 1...
//TODO: linedef actions will require the same handling...
foreach ( Linedef l in General . Map . Map . Linedefs ) l . TranslateToUDMF ( oldiotype ) ;
}
else if ( io is HexenMapSetIO )
{
// Step 2 of hackish way to translate SP/MP thing flags to Hexen map format...
foreach ( Thing t in General . Map . Map . Things ) t . TranslateFromUDMF ( ) ;
}
}
else if ( oldiotype ! = typeof ( UniversalMapSetIO ) & & io is UniversalMapSetIO )
2014-11-11 11:47:10 +00:00
{
2014-12-29 09:19:20 +00:00
foreach ( Linedef l in General . Map . Map . Linedefs ) l . TranslateToUDMF ( oldiotype ) ;
2013-05-31 13:57:49 +00:00
foreach ( Thing t in General . Map . Map . Things ) t . TranslateToUDMF ( ) ;
2013-05-27 12:20:15 +00:00
}
2016-01-18 20:37:21 +00:00
// Drop all arguments
if ( oldiotype ! = typeof ( DoomMapSetIO ) & & io is DoomMapSetIO )
2015-12-09 21:17:05 +00:00
{
2016-01-18 20:37:21 +00:00
foreach ( Linedef l in General . Map . Map . Linedefs )
for ( int i = 0 ; i < l . Args . Length ; i + + ) l . Args [ i ] = 0 ;
foreach ( Thing t in General . Map . Map . Things )
for ( int i = 0 ; i < t . Args . Length ; i + + ) t . Args [ i ] = 0 ;
2015-12-09 21:17:05 +00:00
}
2016-01-18 20:37:21 +00:00
2014-11-25 11:52:01 +00:00
map . UpdateCustomLinedefColors ( ) ;
2013-05-27 12:20:15 +00:00
2016-01-13 09:34:32 +00:00
// Reload resources
ReloadResources ( ) ;
2013-09-11 09:47:53 +00:00
// Update interface
General . MainWindow . SetupInterface ( ) ;
General . MainWindow . UpdateThingsFilters ( ) ;
2015-07-30 23:48:16 +00:00
General . MainWindow . UpdateLinedefColorPresets ( ) ; //mxd
2013-09-11 09:47:53 +00:00
General . MainWindow . UpdateInterface ( ) ;
2012-07-10 10:20:45 +00:00
2014-11-25 11:52:01 +00:00
//mxd. Translate texture names
2014-12-03 09:06:05 +00:00
bool nameschanged = map . TranslateTextureNames ( config . UseLongTextureNames , false ) ;
grid . TranslateBackgroundName ( config . UseLongTextureNames ) ;
2014-11-25 11:52:01 +00:00
//mxd. Sector textures may've been changed
2015-07-30 23:48:16 +00:00
if ( nameschanged ) data . UpdateUsedTextures ( ) ;
2014-11-25 11:52:01 +00:00
2013-09-11 09:47:53 +00:00
// Done
General . MainWindow . DisplayReady ( ) ;
2014-02-18 14:04:14 +00:00
General . MainWindow . RedrawDisplay ( ) ; //mxd
2013-09-11 09:47:53 +00:00
}
// Done
optionsform . Dispose ( ) ;
}
// This shows the things filters setup
[BeginAction("thingsfilterssetup")]
2014-11-11 11:47:10 +00:00
internal void ShowThingsFiltersSetup ( )
2015-07-30 23:48:16 +00:00
{
new ThingsFiltersForm ( ) . ShowDialog ( General . MainWindow ) ;
}
//mxd. This shows the linedef color presets window
[BeginAction("linedefcolorssetup")]
internal void ShowLinedefColorsSetup ( )
2014-11-11 11:47:10 +00:00
{
2013-09-11 09:47:53 +00:00
// Show things filter dialog
2015-07-30 23:48:16 +00:00
new LinedefColorPresetsForm ( ) . ShowDialog ( General . MainWindow ) ;
2013-09-11 09:47:53 +00:00
}
// This returns true is the given type matches
2014-11-11 11:47:10 +00:00
public bool IsType ( Type t )
{
return io . GetType ( ) = = t ;
2013-09-11 09:47:53 +00:00
}
2013-09-12 15:02:08 +00:00
//mxd
2014-11-11 11:47:10 +00:00
public SizeF GetTextSize ( string text , float scale )
{
2013-09-12 15:02:08 +00:00
return graphics . Font . GetTextSize ( text , scale ) ;
}
2014-02-26 14:11:06 +00:00
//mxd
[BeginAction("snapvertstogrid")]
2015-01-10 23:12:19 +00:00
private void SnapSelectedMapElementsToGrid ( )
2014-11-11 11:47:10 +00:00
{
2015-01-10 23:12:19 +00:00
// Get selected elements
2014-02-26 14:11:06 +00:00
ICollection < Vertex > verts = map . GetSelectedVertices ( true ) ;
2015-01-10 23:12:19 +00:00
ICollection < Linedef > lines = map . GetSelectedLinedefs ( true ) ; // Sector lines are auto-selected when a sector is selected
ICollection < Thing > things = map . GetSelectedThings ( true ) ;
2014-02-26 14:11:06 +00:00
2015-01-10 23:12:19 +00:00
// Get vertices from selection
Dictionary < int , Vertex > vertstosnap = new Dictionary < int , Vertex > ( verts . Count ) ;
foreach ( Vertex v in verts ) vertstosnap . Add ( v . Index , v ) ;
foreach ( Linedef l in lines )
2014-11-11 11:47:10 +00:00
{
2015-01-10 23:12:19 +00:00
if ( ! vertstosnap . ContainsKey ( l . Start . Index ) ) vertstosnap . Add ( l . Start . Index , l . Start ) ;
if ( ! vertstosnap . ContainsKey ( l . End . Index ) ) vertstosnap . Add ( l . End . Index , l . End ) ;
2014-02-26 14:11:06 +00:00
}
2015-01-10 23:12:19 +00:00
// Anything to snap?
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( vertstosnap . Count = = 0 & & things . Count = = 0 )
2014-11-11 11:47:10 +00:00
{
2014-02-26 14:11:06 +00:00
General . Interface . DisplayStatus ( StatusType . Warning , "Select any map element first!" ) ;
2015-01-10 23:12:19 +00:00
return ;
}
// Make undo
undoredo . CreateUndo ( "Snap map elements to grid" ) ;
// Do the snapping
Cursor . Current = Cursors . AppStarting ;
// Snap vertices?
int snappedverts = ( vertstosnap . Count > 0 ? SnapVertices ( vertstosnap . Values ) : 0 ) ;
// Snap things?..
int snappedthings = ( things . Count > 0 ? SnapThings ( things ) : 0 ) ;
// Assemble status message
List < string > message = new List < string > ( ) ;
if ( snappedverts > 0 ) message . Add ( snappedverts + " vertices" ) ;
if ( snappedthings > 0 ) message . Add ( snappedthings + " things" ) ;
// Map changed?
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( message . Count > 0 )
2015-01-10 23:12:19 +00:00
{
// Display status
General . Interface . DisplayStatus ( StatusType . Info , "Snapped " + string . Join ( " and " , message . ToArray ( ) ) ) ;
// Warn the user
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
/ * if ( snappedverts > 0 )
2015-01-10 23:12:19 +00:00
{
MessageBox . Show ( "Snapped " + snappedverts + " vertices to grid." + Environment . NewLine +
"It's a good idea to run Map Analysis Mode now." ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
} * /
2015-01-10 23:12:19 +00:00
// Invoke clear selection to update sector highlight overlay
General . Actions . InvokeAction ( "builder_clearselection" ) ;
// Update cached values
General . Map . Map . Update ( ) ;
// Map is changed
General . Map . IsChanged = true ;
}
2014-11-11 11:47:10 +00:00
else
{
2015-01-10 23:12:19 +00:00
// Display status
General . Interface . DisplayStatus ( StatusType . Info , "Selected map elements were already on the grid." ) ;
// Withdraw undo
undoredo . WithdrawUndo ( ) ;
2014-02-26 14:11:06 +00:00
}
2015-01-10 23:12:19 +00:00
// Done
General . Interface . RedrawDisplay ( ) ;
Cursor . Current = Cursors . Default ;
2014-02-26 14:11:06 +00:00
}
//mxd
2015-01-10 23:12:19 +00:00
private int SnapVertices ( IEnumerable < Vertex > verts )
2014-11-11 11:47:10 +00:00
{
2014-02-26 14:11:06 +00:00
int snappedCount = 0 ;
List < Vertex > movedVerts = new List < Vertex > ( ) ;
List < Linedef > movedLines = new List < Linedef > ( ) ;
//snap them all!
2014-11-11 11:47:10 +00:00
foreach ( Vertex v in verts )
{
2014-02-26 14:11:06 +00:00
Vector2D pos = v . Position ;
v . SnapToGrid ( ) ;
2014-11-11 11:47:10 +00:00
if ( v . Position . x ! = pos . x | | v . Position . y ! = pos . y )
{
2014-02-26 14:11:06 +00:00
snappedCount + + ;
movedVerts . Add ( v ) ;
2014-11-11 11:47:10 +00:00
foreach ( Linedef l in v . Linedefs )
{
2014-02-26 14:11:06 +00:00
if ( ! movedLines . Contains ( l ) ) movedLines . Add ( l ) ;
}
}
}
//Create blockmap
RectangleF area = MapSet . CreateArea ( General . Map . Map . Vertices ) ;
BlockMap < BlockEntry > blockmap = new BlockMap < BlockEntry > ( area ) ;
blockmap . AddVerticesSet ( General . Map . Map . Vertices ) ;
//merge overlapping vertices using teh power of BLOCKMAP!!!11
2014-11-11 11:47:10 +00:00
foreach ( Vertex v in movedVerts )
{
2015-12-28 15:01:53 +00:00
BlockEntry block = blockmap . GetBlockAt ( v . Position ) ;
2014-02-26 14:11:06 +00:00
if ( block = = null ) continue ;
2014-11-11 11:47:10 +00:00
foreach ( Vertex blockVert in block . Vertices )
{
2014-02-26 14:11:06 +00:00
if ( blockVert . IsDisposed | | blockVert . Index = = v . Index | | blockVert . Position ! = v . Position )
continue ;
2015-12-28 15:01:53 +00:00
foreach ( Linedef l in blockVert . Linedefs )
2014-11-11 11:47:10 +00:00
{
2015-12-28 15:01:53 +00:00
if ( ! movedLines . Contains ( l ) ) movedLines . Add ( l ) ;
2014-02-26 14:11:06 +00:00
}
v . Join ( blockVert ) ;
break ;
}
}
// Update cached values of lines because we may need their length/angle
General . Map . Map . Update ( true , false ) ;
General . Map . Map . BeginAddRemove ( ) ;
MapSet . RemoveLoopedLinedefs ( movedLines ) ;
MapSet . JoinOverlappingLines ( movedLines ) ;
General . Map . Map . EndAddRemove ( ) ;
//get changed sectors
List < Sector > changedSectors = new List < Sector > ( ) ;
2014-11-11 11:47:10 +00:00
foreach ( Linedef l in movedLines )
{
2014-02-26 14:11:06 +00:00
if ( l = = null | | l . IsDisposed ) continue ;
if ( l . Front ! = null & & l . Front . Sector ! = null & & ! changedSectors . Contains ( l . Front . Sector ) )
changedSectors . Add ( l . Front . Sector ) ;
if ( l . Back ! = null & & l . Back . Sector ! = null & & ! changedSectors . Contains ( l . Back . Sector ) )
changedSectors . Add ( l . Back . Sector ) ;
}
// Now update area of sectors
General . Map . Map . Update ( false , true ) ;
//fix invalid sectors
2014-11-11 11:47:10 +00:00
foreach ( Sector s in changedSectors )
{
if ( s . BBox . IsEmpty )
{
2014-02-26 14:11:06 +00:00
s . Dispose ( ) ;
2014-11-11 11:47:10 +00:00
}
else if ( s . Sidedefs . Count < 3 )
{
2014-02-26 14:11:06 +00:00
bool merged = false ;
2014-11-11 11:47:10 +00:00
foreach ( Sidedef side in s . Sidedefs )
{
if ( side . Other ! = null & & side . Other . Sector ! = null )
{
2014-02-26 14:11:06 +00:00
s . Join ( side . Other . Sector ) ;
merged = true ;
break ;
}
}
//oh well, I don't know what else I can do here...
if ( ! merged ) s . Dispose ( ) ;
}
}
2015-01-10 23:12:19 +00:00
return snappedCount ;
2014-02-26 14:11:06 +00:00
}
//mxd
2015-01-10 23:12:19 +00:00
private static int SnapThings ( IEnumerable < Thing > things )
2014-05-20 09:09:28 +00:00
{
2014-02-26 14:11:06 +00:00
int snappedCount = 0 ;
//snap them all!
2014-11-11 11:47:10 +00:00
foreach ( Thing t in things )
{
2014-02-26 14:11:06 +00:00
Vector2D pos = t . Position ;
t . SnapToGrid ( ) ;
if ( t . Position . x ! = pos . x | | t . Position . y ! = pos . y ) snappedCount + + ;
}
2015-01-10 23:12:19 +00:00
return snappedCount ;
2014-02-26 14:11:06 +00:00
}
2013-09-11 09:47:53 +00:00
#endregion
}
2012-07-10 10:20:45 +00:00
}