- made some processed command line settings available to plugins

- General.Exit() method for plugins to close Doom Builder
- command-line parameter -delaywindow to keep the main window hidden until nothing more to process. This gives plugins the ability to perform an operation without showing the main window at all if the plugin calls General.Exit() before the window is shown. Usefull for batch processes in which no interface window is desired.
- some new plugin events that occur before and after making a new map and opening a map.
This commit is contained in:
codeimp 2008-10-13 17:47:08 +00:00
parent 2ae441436e
commit e029efcbe6
5 changed files with 127 additions and 10 deletions

View file

@ -3,7 +3,7 @@ Doom Builder 2 command-line arguments
Usage:
builder.exe [wadfile] [-map mapname] [-cfg configname]
builder.exe [wadfile] [-map mapname] [-cfg configname] [-delaywindow]
==========================================================================================
@ -24,6 +24,13 @@ Do NOT include the path, all game configurations must be in the Configurations s
When used in combination with -map this will provide the required information to load a
map directly and skip the map-options dialog.
- delaywindow
This delays showing the main interface window until the automatic map loading from
command line parameters is completed, and the program is not terminating yet. This is
usefull for plugins that can be used to perform batch processes where the showing of the
main interface window is not desired. If a plugin completes it's actions on map load and
terminates the application immediately, the main window will not be shown at all.
==========================================================================================
Examples:

View file

@ -117,6 +117,7 @@ namespace CodeImp.DoomBuilder
private static string autoloadfile = null;
private static string autoloadmap = null;
private static string autoloadconfig = null;
private static bool delaymainwindow;
#endregion
@ -142,9 +143,10 @@ namespace CodeImp.DoomBuilder
public static Clock Clock { get { return clock; } }
public static bool DebugBuild { get { return debugbuild; } }
internal static TypesManager Types { get { return types; } }
internal static string AutoLoadFile { get { return autoloadfile; } }
internal static string AutoLoadMap { get { return autoloadmap; } }
internal static string AutoLoadConfig { get { return autoloadconfig; } }
public static string AutoLoadFile { get { return autoloadfile; } }
public static string AutoLoadMap { get { return autoloadmap; } }
public static string AutoLoadConfig { get { return autoloadconfig; } }
public static bool DelayMainWindow { get { return delaymainwindow; } }
#endregion
@ -497,11 +499,14 @@ namespace CodeImp.DoomBuilder
mainwindow = new MainForm();
mainwindow.UpdateInterface();
// Show main window
General.WriteLogLine("Showing main interface window...");
mainwindow.Show();
mainwindow.Update();
if(!delaymainwindow)
{
// Show main window
General.WriteLogLine("Showing main interface window...");
mainwindow.Show();
mainwindow.Update();
}
// Start Direct3D
General.WriteLogLine("Starting Direct3D graphics driver...");
try { D3DDevice.Startup(); }
@ -541,6 +546,10 @@ namespace CodeImp.DoomBuilder
General.WriteLogLine("Creating types manager...");
types = new TypesManager();
// Do auto map loading when window is delayed
if(delaymainwindow)
mainwindow.PerformAutoMapLoading();
// Run application from the main window
General.WriteLogLine("Startup done");
mainwindow.DisplayReady();
@ -600,8 +609,14 @@ namespace CodeImp.DoomBuilder
// Get next arg
string curarg = argslist.Dequeue();
// Delay window?
if(string.Compare(curarg, "-DELAYWINDOW", true) == 0)
{
// Delay showing the main window
delaymainwindow = true;
}
// Map name info?
if(string.Compare(curarg, "-MAP", true) == 0)
else if(string.Compare(curarg, "-MAP", true) == 0)
{
// Store next arg as map name information
autoloadmap = argslist.Dequeue();
@ -638,6 +653,26 @@ namespace CodeImp.DoomBuilder
#endregion
#region ================== Terminate
// This is for plugins to use
public static void Exit(bool properexit)
{
// Plugin wants to exit nicely?
if(properexit)
{
// Close dialog forms first
while((Form.ActiveForm != mainwindow) && (Form.ActiveForm != null))
Form.ActiveForm.Close();
// Close main window
mainwindow.Close();
}
else
{
// Terminate, no questions asked
Terminate(true);
}
}
// This terminates the program
internal static void Terminate(bool properexit)
@ -682,6 +717,9 @@ namespace CodeImp.DoomBuilder
General.WriteLogLine("Immediate program termination");
Application.Exit();
}
// Die.
Process.GetCurrentProcess().Kill();
}
#endregion
@ -743,6 +781,9 @@ namespace CodeImp.DoomBuilder
mainwindow.DisplayStatus("Creating new map...");
Cursor.Current = Cursors.WaitCursor;
// Let the plugins know
plugins.OnMapNewBegin();
// Clear the display
mainwindow.ClearDisplay();
@ -765,6 +806,9 @@ namespace CodeImp.DoomBuilder
mainwindow.ShowSplashDisplay();
}
// Let the plugins know
plugins.OnMapNewEnd();
// All done
mainwindow.RedrawDisplay();
mainwindow.UpdateInterface();
@ -866,6 +910,9 @@ namespace CodeImp.DoomBuilder
mainwindow.DisplayStatus("Opening map file...");
Cursor.Current = Cursors.WaitCursor;
// Let the plugins know
plugins.OnMapOpenBegin();
// Clear the display
mainwindow.ClearDisplay();
@ -889,6 +936,9 @@ namespace CodeImp.DoomBuilder
mainwindow.ShowSplashDisplay();
}
// Let the plugins know
plugins.OnMapOpenEnd();
// All done
mainwindow.RedrawDisplay();
mainwindow.UpdateInterface();

View file

@ -99,6 +99,34 @@ namespace CodeImp.DoomBuilder.Plugins
#region ================== Events
/// <summary>
/// Occurs before a map is opened.
/// </summary>
public virtual void OnMapOpenBegin()
{
}
/// <summary>
/// Occurs after a map is opened.
/// </summary>
public virtual void OnMapOpenEnd()
{
}
/// <summary>
/// Occurs before a new map is created.
/// </summary>
public virtual void OnMapNewBegin()
{
}
/// <summary>
/// Occurs after a new map is created.
/// </summary>
public virtual void OnMapNewEnd()
{
}
/// <summary>
/// This is called after the constructor to allow a plugin to initialize.
/// </summary>

View file

@ -283,6 +283,30 @@ namespace CodeImp.DoomBuilder.Plugins
foreach(Plugin p in plugins) p.Plug.OnRedoEnd();
}
public void OnMapOpenBegin()
{
foreach(Plugin p in plugins) p.Plug.OnMapOpenBegin();
}
public void OnMapOpenEnd()
{
foreach(Plugin p in plugins) p.Plug.OnMapOpenEnd();
}
public void OnMapNewBegin()
{
foreach(Plugin p in plugins) p.Plug.OnMapNewBegin();
}
public void OnMapNewEnd()
{
foreach(Plugin p in plugins) p.Plug.OnMapNewEnd();
}
#endregion
}

View file

@ -204,6 +204,14 @@ namespace CodeImp.DoomBuilder.Windows
// Window is first shown
private void MainForm_Shown(object sender, EventArgs e)
{
// Perform auto mapo loading action when the window is not delayed
if(!General.DelayMainWindow) PerformAutoMapLoading();
}
// Auto map loading that must be done when the window is first shown after loading
// but also before the window is shown when the -delaywindow parameter is given
internal void PerformAutoMapLoading()
{
// Check if the command line arguments tell us to load something
if(General.AutoLoadFile != null)