script editor roughly finished

This commit is contained in:
codeimp 2008-11-15 13:12:09 +00:00
parent 0fa7409d96
commit 746fe86aea
18 changed files with 535 additions and 77 deletions

Binary file not shown.

View file

@ -6,7 +6,7 @@ compilers
hacc
{
interface = "AccCompiler";
program = "hacc.exe";
program = "acc.exe";
common = "common.acs";
defs = "defs.acs";
special = "special.acs";

Binary file not shown.

View file

@ -4,7 +4,7 @@
// Compiler settings
compiler = "acc";
parameters = "-I %PT %FI %FO";
parameters = "-I \"%PT\" -I \"%PW\" %FI %FO";
resultlump = "BEHAVIOR";
// Editor settings

Binary file not shown.

After

Width:  |  Height:  |  Size: 780 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

View file

@ -126,13 +126,13 @@ namespace CodeImp.DoomBuilder.Compilers
General.WriteLogLine("Compile time: " + deltatime.TotalSeconds.ToString("########0.00") + " seconds");
// Now find the error file
string errfile = Path.Combine(this.tempdir.FullName, ACS_ERROR_FILE);
string errfile = Path.Combine(this.workingdir, ACS_ERROR_FILE);
if(File.Exists(errfile))
{
try
{
// Regex to find error lines
Regex errlinematcher = new Regex("\\:[0-9]+\\:\\b", RegexOptions.Compiled | RegexOptions.CultureInvariant);
Regex errlinematcher = new Regex(":[0-9]+: ", RegexOptions.Compiled | RegexOptions.CultureInvariant);
// Read all lines
string[] errlines = File.ReadAllLines(errfile);
@ -149,6 +149,8 @@ namespace CodeImp.DoomBuilder.Compilers
string linenr = match.Value.Replace(":", "").Trim();
if(!int.TryParse(linenr, out err.linenumber))
err.linenumber = CompilerError.NO_LINE_NUMBER;
else
err.linenumber--;
// Everything before the match is the filename
err.filename = linestr.Substring(0, match.Index);

View file

@ -29,6 +29,7 @@ using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Config;
using CodeImp.DoomBuilder.Types;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Compilers;
#endregion
@ -53,6 +54,9 @@ namespace CodeImp.DoomBuilder.Controls
// Derived classes must set this!
protected ScriptConfiguration config;
// The panel we're on
protected ScriptEditorPanel panel;
#endregion
#region ================== Properties
@ -62,6 +66,7 @@ namespace CodeImp.DoomBuilder.Controls
public virtual bool IsClosable { get { return true; } }
public virtual bool IsReconfigurable { get { return true; } }
public virtual string Filename { get { return null; } }
public ScriptEditorPanel Panel { get { return panel; } }
public bool IsChanged { get { return editor.IsChanged; } }
public ScriptConfiguration Config { get { return config; } }
@ -70,8 +75,11 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Constructor
// Constructor
public ScriptDocumentTab()
public ScriptDocumentTab(ScriptEditorPanel panel)
{
// Keep panel
this.panel = panel;
// Make the script control
editor = new ScriptEditorControl();
editor.Location = new Point(EDITOR_BORDER_LEFT, EDITOR_BORDER_TOP);
@ -94,6 +102,41 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Methods
// This moves the caret to the given line
public virtual void MoveToLine(int linenumber)
{
editor.MoveToLine(linenumber);
}
// This clears all marks
public virtual void ClearMarks()
{
editor.ClearMarks();
}
// This creates error marks for errors that apply to this file
public virtual void MarkScriptErrors(IEnumerable<CompilerError> errors)
{
// Clear all marks
ClearMarks();
// Go for all errors that apply to this script
foreach(CompilerError e in errors)
{
if(VerifyErrorForScript(e))
{
// Add a mark on the line where this error occurred
editor.AddMark(e.linenumber);
}
}
}
// This verifies if the specified error applies to this script
public virtual bool VerifyErrorForScript(CompilerError e)
{
return false;
}
// This compiles the script
public virtual void Compile()
{

View file

@ -145,6 +145,24 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Methods
// This moves the caret to a given line and ensures the line is visible
public void MoveToLine(int linenumber)
{
scriptedit.GotoLine(linenumber);
}
// This clears all marks
public void ClearMarks()
{
scriptedit.MarkerDeleteAll((int)ImageIndex.ScriptError);
}
// This adds a mark on the given line
public void AddMark(int linenumber)
{
scriptedit.MarkerAdd(linenumber, (int)ImageIndex.ScriptError);
}
// This sets up the script editor with a script configuration
public void SetupStyles(ScriptConfiguration config)
{

View file

@ -28,6 +28,8 @@ namespace CodeImp.DoomBuilder.Controls
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ScriptEditorPanel));
this.tabs = new System.Windows.Forms.TabControl();
this.toolbar = new System.Windows.Forms.ToolStrip();
this.buttonnew = new System.Windows.Forms.ToolStripDropDownButton();
@ -47,7 +49,17 @@ namespace CodeImp.DoomBuilder.Controls
this.buttonclose = new System.Windows.Forms.ToolStripButton();
this.openfile = new System.Windows.Forms.OpenFileDialog();
this.savefile = new System.Windows.Forms.SaveFileDialog();
this.splitter = new System.Windows.Forms.SplitContainer();
this.label1 = new System.Windows.Forms.Label();
this.errorlist = new System.Windows.Forms.ListView();
this.colIndex = new System.Windows.Forms.ColumnHeader();
this.colDescription = new System.Windows.Forms.ColumnHeader();
this.colFile = new System.Windows.Forms.ColumnHeader();
this.errorimages = new System.Windows.Forms.ImageList(this.components);
this.toolbar.SuspendLayout();
this.splitter.Panel1.SuspendLayout();
this.splitter.Panel2.SuspendLayout();
this.splitter.SuspendLayout();
this.SuspendLayout();
//
// tabs
@ -55,12 +67,12 @@ namespace CodeImp.DoomBuilder.Controls
this.tabs.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabs.Location = new System.Drawing.Point(3, 33);
this.tabs.Location = new System.Drawing.Point(3, 8);
this.tabs.Margin = new System.Windows.Forms.Padding(3, 8, 3, 3);
this.tabs.Name = "tabs";
this.tabs.Padding = new System.Drawing.Point(12, 3);
this.tabs.SelectedIndex = 0;
this.tabs.Size = new System.Drawing.Size(691, 435);
this.tabs.Size = new System.Drawing.Size(720, 386);
this.tabs.TabIndex = 0;
this.tabs.TabStop = false;
this.tabs.Selecting += new System.Windows.Forms.TabControlCancelEventHandler(this.tabs_Selecting);
@ -88,7 +100,7 @@ namespace CodeImp.DoomBuilder.Controls
this.buttonclose});
this.toolbar.Location = new System.Drawing.Point(0, 0);
this.toolbar.Name = "toolbar";
this.toolbar.Size = new System.Drawing.Size(697, 25);
this.toolbar.Size = new System.Drawing.Size(726, 25);
this.toolbar.TabIndex = 1;
//
// buttonnew
@ -245,16 +257,100 @@ namespace CodeImp.DoomBuilder.Controls
//
this.savefile.Title = "Save Script As";
//
// splitter
//
this.splitter.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitter.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
this.splitter.Location = new System.Drawing.Point(0, 25);
this.splitter.Name = "splitter";
this.splitter.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitter.Panel1
//
this.splitter.Panel1.Controls.Add(this.tabs);
//
// splitter.Panel2
//
this.splitter.Panel2.Controls.Add(this.label1);
this.splitter.Panel2.Controls.Add(this.errorlist);
this.splitter.Size = new System.Drawing.Size(726, 538);
this.splitter.SplitterDistance = 397;
this.splitter.TabIndex = 2;
this.splitter.TabStop = false;
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label1.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.label1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.label1.Location = new System.Drawing.Point(3, 0);
this.label1.Name = "label1";
this.label1.Padding = new System.Windows.Forms.Padding(1);
this.label1.Size = new System.Drawing.Size(720, 16);
this.label1.TabIndex = 1;
this.label1.Text = "Errors";
//
// errorlist
//
this.errorlist.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.errorlist.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.colIndex,
this.colDescription,
this.colFile});
this.errorlist.FullRowSelect = true;
this.errorlist.GridLines = true;
this.errorlist.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.errorlist.LabelWrap = false;
this.errorlist.Location = new System.Drawing.Point(3, 19);
this.errorlist.MultiSelect = false;
this.errorlist.Name = "errorlist";
this.errorlist.ShowGroups = false;
this.errorlist.Size = new System.Drawing.Size(720, 115);
this.errorlist.SmallImageList = this.errorimages;
this.errorlist.TabIndex = 0;
this.errorlist.TabStop = false;
this.errorlist.UseCompatibleStateImageBehavior = false;
this.errorlist.View = System.Windows.Forms.View.Details;
this.errorlist.ItemActivate += new System.EventHandler(this.errorlist_ItemActivate);
//
// colIndex
//
this.colIndex.Text = "";
this.colIndex.Width = 45;
//
// colDescription
//
this.colDescription.Text = "Description";
this.colDescription.Width = 500;
//
// colFile
//
this.colFile.Text = "File";
this.colFile.Width = 150;
//
// errorimages
//
this.errorimages.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("errorimages.ImageStream")));
this.errorimages.TransparentColor = System.Drawing.Color.Transparent;
this.errorimages.Images.SetKeyName(0, "ScriptError3.png");
//
// ScriptEditorPanel
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.SystemColors.Control;
this.Controls.Add(this.splitter);
this.Controls.Add(this.toolbar);
this.Controls.Add(this.tabs);
this.Name = "ScriptEditorPanel";
this.Size = new System.Drawing.Size(697, 471);
this.Size = new System.Drawing.Size(726, 563);
this.toolbar.ResumeLayout(false);
this.toolbar.PerformLayout();
this.splitter.Panel1.ResumeLayout(false);
this.splitter.Panel2.ResumeLayout(false);
this.splitter.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -281,5 +377,12 @@ namespace CodeImp.DoomBuilder.Controls
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.ToolStripDropDownButton buttonscriptconfig;
private System.Windows.Forms.ToolStripButton buttonclose;
private System.Windows.Forms.SplitContainer splitter;
private System.Windows.Forms.ListView errorlist;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ColumnHeader colIndex;
private System.Windows.Forms.ColumnHeader colDescription;
private System.Windows.Forms.ColumnHeader colFile;
private System.Windows.Forms.ImageList errorimages;
}
}

View file

@ -31,6 +31,7 @@ using CodeImp.DoomBuilder.Types;
using CodeImp.DoomBuilder.IO;
using System.Globalization;
using System.IO;
using CodeImp.DoomBuilder.Compilers;
#endregion
@ -45,6 +46,7 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Variables
private List<ScriptConfiguration> scriptconfigs;
private List<CompilerError> compilererrors;
#endregion
@ -111,7 +113,7 @@ namespace CodeImp.DoomBuilder.Controls
if(maplumpinfo.script != null)
{
// Load this!
ScriptLumpDocumentTab t = new ScriptLumpDocumentTab(maplumpinfo.name, maplumpinfo.script);
ScriptLumpDocumentTab t = new ScriptLumpDocumentTab(this, maplumpinfo.name, maplumpinfo.script);
tabs.TabPages.Add(t);
}
}
@ -130,6 +132,9 @@ namespace CodeImp.DoomBuilder.Controls
// Select the first tab
if(tabs.TabPages.Count > 0) tabs.SelectedIndex = 0;
// If the map has remembered any compile errors, then show them
ShowErrors(General.Map.Errors);
// Done
UpdateToolbar();
}
@ -138,6 +143,59 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Methods
// This clears all error marks and hides the errors list
public void ClearErrors()
{
// Hide list
splitter.Panel2Collapsed = true;
errorlist.Items.Clear();
// Clear marks
foreach(ScriptDocumentTab t in tabs.TabPages)
{
t.ClearMarks();
}
}
// This shows the errors panel with the given errors
// Also updates the scripts with markers for the given errors
public void ShowErrors(IEnumerable<CompilerError> errors)
{
// Copy list
if(errors != null)
compilererrors = new List<CompilerError>(errors);
else
compilererrors = new List<CompilerError>();
// Fill list
errorlist.BeginUpdate();
errorlist.Items.Clear();
int listindex = 1;
foreach(CompilerError e in compilererrors)
{
ListViewItem ei = new ListViewItem(listindex.ToString());
ei.ImageIndex = 0;
ei.SubItems.Add(e.description);
if(e.filename.StartsWith("?"))
ei.SubItems.Add(e.filename.Replace("?", "") + " (line " + e.linenumber.ToString() + ")");
else
ei.SubItems.Add(Path.GetFileName(e.filename) + " (line " + e.linenumber.ToString() + ")");
ei.Tag = e;
errorlist.Items.Add(ei);
listindex++;
}
errorlist.EndUpdate();
// Show marks on scripts
foreach(ScriptDocumentTab t in tabs.TabPages)
{
t.MarkScriptErrors(compilererrors);
}
// Show/hide panel
splitter.Panel2Collapsed = (errorlist.Items.Count == 0);
}
// This writes all explicitly opened files to the configuration
public void WriteOpenFilesToConfiguration()
{
@ -264,8 +322,8 @@ namespace CodeImp.DoomBuilder.Controls
}
}
// This opens the given file
public void OpenFile(string filename)
// This opens the given file, returns null when failed
public ScriptFileDocumentTab OpenFile(string filename)
{
ScriptConfiguration foundconfig = new ScriptConfiguration();
@ -284,15 +342,25 @@ namespace CodeImp.DoomBuilder.Controls
}
// Create new document
ScriptFileDocumentTab t = new ScriptFileDocumentTab(foundconfig);
ScriptFileDocumentTab t = new ScriptFileDocumentTab(this, foundconfig);
if(t.Open(filename))
{
// Mark any errors this script may have
if(compilererrors != null)
t.MarkScriptErrors(compilererrors);
// Add to tabs
tabs.TabPages.Add(t);
tabs.SelectedTab = t;
// Done
UpdateToolbar();
return t;
}
else
{
// Failed
return null;
}
}
@ -321,7 +389,7 @@ namespace CodeImp.DoomBuilder.Controls
ScriptConfiguration scriptconfig = ((sender as ToolStripMenuItem).Tag as ScriptConfiguration);
// Create new document
ScriptFileDocumentTab t = new ScriptFileDocumentTab(scriptconfig);
ScriptFileDocumentTab t = new ScriptFileDocumentTab(this, scriptconfig);
tabs.TabPages.Add(t);
tabs.SelectedTab = t;
@ -415,9 +483,24 @@ namespace CodeImp.DoomBuilder.Controls
// First save all implicit scripts to the temporary wad file
ImplicitSave();
// Compile script
// Get script
ScriptDocumentTab t = (tabs.SelectedTab as ScriptDocumentTab);
if(t.ExplicitSave && t.IsChanged)
{
// We can only compile when the script is saved
if(!SaveScript(t)) return;
}
// Compile now
General.MainWindow.DisplayStatus("Compiling script " + t.Text + "...");
t.Compile();
// Show warning
if((compilererrors != null) && (compilererrors.Count > 0))
General.MainWindow.DisplayWarning(compilererrors.Count.ToString() + " errors while compiling " + t.Text + "!");
else
General.MainWindow.DisplayReady();
UpdateToolbar();
}
@ -467,6 +550,39 @@ namespace CodeImp.DoomBuilder.Controls
ForceFocus();
}
// User double-clicks and error in the list
private void errorlist_ItemActivate(object sender, EventArgs e)
{
// Anything selection?
if(errorlist.SelectedItems.Count > 0)
{
// Get the compiler error
CompilerError err = (CompilerError)errorlist.SelectedItems[0].Tag;
// Show the tab with the script that matches
bool foundscript = false;
foreach(ScriptDocumentTab t in tabs.TabPages)
{
if(t.VerifyErrorForScript(err))
{
tabs.SelectedTab = t;
t.MoveToLine(err.linenumber);
foundscript = true;
break;
}
}
// If we don't have the script opened, see if we can find the file and open the script
if(!foundscript && File.Exists(err.filename))
{
ScriptDocumentTab t = OpenFile(err.filename);
if(t != null) t.MoveToLine(err.linenumber);
}
ForceFocus();
}
}
#endregion
}
}

View file

@ -117,6 +117,12 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="tabs.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="toolbar.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="toolbar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
@ -126,4 +132,51 @@
<metadata name="savefile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>194, 17</value>
</metadata>
<metadata name="splitter.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label1.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="errorlist.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="errorimages.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>283, 17</value>
</metadata>
<data name="errorimages.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADI
BQAAAk1TRnQBSQFMAwEBAAEEAQABBAEAARABAAEQAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABQAMA
ARADAAEBAQABIAYAARD/ACMAAc8B2AHyAf8BWwFzAbkB/wEkAT8BkwH/ARwBMgF4Af8BFQErAW8B/wEV
AS8BgAH/AUoBYAGkAf8BzwHYAfIB/9wAAYABlAHUAf8BLwFOAawB/wEdAUIBuAH/AQ0BPQHQAf8BBAE6
AeIB/wEDATcB3AH/AQcBNAG9Af8BCgErAZYB/wELASYBfQH/AWgBegGyAf/UAAGJAZ0B3AH/ATwBWwG7
Af8BHQFNAd0B/wEKAUUB+gH/AQgBQgH5Af8BSAFzAfgB/wFIAXMB+AH/AQEBOgHqAf8BAQE3AeQB/wEG
ATABtgH/AQsBJgF9Af8BaAF6AbIB/8wAAc8B2AHyAf8BUQFsAcYB/wEvAVsB4wH/ARwBUwH9Af8BHAFT
Af0B/wFXAYAB/gH/A/4B/wP+Af8BWgGBAfoB/wEBATsB7gH/AQEBNwHkAf8BBgEwAbYB/wELASYBfQH/
Ac8B2AHyAf/IAAGnAbYB5QH/AU4BcQHZAf8BLQFgAv8BLgFiAv8BLQFgAv8BZgGLAv8D/gH/A/4B/wFR
AXoB+wH/AQMBPwH4Af8BAQE7Ae4B/wEBATcB5AH/AQoBKwGWAf8BSgFgAaQB/8gAAXEBiQHVAf8BTQF0
Ae4B/wE/AW4C/wFCAXAC/wE/AW4C/wE6AWsC/wFqAY4C/wFhAYYC/wEcAVMB/QH/AQ4BSQH7Af8BAwE/
AfgB/wEBAToB6gH/AQcBNAG9Af8BFQEvAYAB/8gAAYEBlAHRAf8BUQF6AfsB/wFTAX0C/wFXAYAB/gH/
AVMBfQL/AWEBhgL/A/4B/wP+Af8BPwFuAv8BGQFRAfsB/wEKAUUB+gH/AQEBPAHzAf8BAwE3AdwB/wEV
ASsBbwH/yAABigGbAdQB/wFhAYYB+wH/AWYBiwL/AWoBjgL/AWYBiwL/AZcBsQL/A/4B/wP+Af8BegGa
Av8BIgFYAf0B/wEOAUkB+wH/AQMBPwH4Af8BBAE6AeIB/wEcATIBeAH/yAABiQGdAdwB/wF6AZYB8gH/
AXoBmgL/AX0BnAL/AXoBmgL/AbEBxAL/A/4B/wP+Af8BogG4Af4B/wEpAV0B/gH/ARkBUQH7Af8BCAFC
AfkB/wENAT0B0AH/ASQBPwGTAf/IAAGnAbYB5QH/AY0BowHlAf8BhwGkAv8BjQGoAv8BhwGkAv8BxQHT
Af4B/wP+Af8D/gH/AbUBxwH+Af8BLQFgAv8BHAFTAf0B/wEKAUUB+gH/AR0BQgG4Af8BZQF7AboB/8gA
Ac8B2AHyAf8BlwGnAd0B/wGVAasB8QH/AZcBsQL/AY0BqAL/AakBvgL/A/4B/wP+Af8BgwGhAv8BLgFi
Av8BHAFTAf0B/wEdAU0B3QH/AS8BTgGsAf8BzwHYAfIB/8wAAbQBwgHsAf8BmwGqAd0B/wGVAasB8QH/
AYcBpAL/AXoBmgL/AWYBiwL/AVMBfQL/AT8BbgL/AS4BYgL/AS8BWwHjAf8BPAFbAbsB/wF2AYwB1AH/
1AABtAHCAewB/wGXAacB3QH/AY0BowHlAf8BegGWAfIB/wFhAYYB+wH/AVEBegH7Af8BTQF0Ae4B/wFO
AXEB2QH/AVEBbAHGAf8BfwGVAdwB/9wAAcwB2AH+Af8BnQGtAeAB/wGJAZ0B3AH/AYoBmwHUAf8BgQGU
AdEB/wFxAYkB1QH/AYEBlAHRAf8BzAHYAf4B//8A0QABQgFNAT4HAAE+AwABKAMAAUADAAEQAwABAQEA
AQEFAAGAFwAD/wEAAv8GAAHwAQ8GAAHgAQcGAAHAAQMGAAGAAQEGAAGAAQEGAAGAAQEGAAGAAQEGAAGA
AQEGAAGAAQEGAAGAAQEGAAGAAQEGAAHAAQMGAAHgAQcGAAHwAQ8GAAL/BgAL
</value>
</data>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View file

@ -58,7 +58,7 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Constructor / Disposer
// Constructor
public ScriptFileDocumentTab(ScriptConfiguration config)
public ScriptFileDocumentTab(ScriptEditorPanel panel, ScriptConfiguration config) : base(panel)
{
string ext = "";
@ -84,9 +84,8 @@ namespace CodeImp.DoomBuilder.Controls
// This compiles the script file
public override void Compile()
{
DirectoryInfo tempdir;
Compiler compiler;
string inputfile, outputfile;
Compiler compiler;
// List of errors
List<CompilerError> errors = new List<CompilerError>();
@ -103,25 +102,45 @@ namespace CodeImp.DoomBuilder.Controls
return;
}
// Copy the source file into the temporary directory
inputfile = Path.Combine(compiler.Location, Path.GetFileName(filepathname));
File.Copy(filepathname, inputfile);
// Make random output filename
outputfile = General.MakeTempFilename(compiler.Location, "tmp");
// Run compiler
compiler.Parameters = config.Parameters;
compiler.InputFile = Path.GetFileName(filepathname);
compiler.InputFile = Path.GetFileName(inputfile);
compiler.OutputFile = Path.GetFileName(outputfile);
compiler.WorkingDirectory = Path.GetDirectoryName(filepathname);
compiler.WorkingDirectory = Path.GetDirectoryName(inputfile);
if(compiler.Run())
{
// Fetch errors
errors.AddRange(compiler.Errors);
foreach(CompilerError e in compiler.Errors)
{
CompilerError newerr = e;
// If the error's filename equals our temporary file,
// replace it with the original source filename
if(string.Compare(e.filename, inputfile, true) == 0)
newerr.filename = filepathname;
errors.Add(newerr);
}
}
// Dispose compiler
compiler.Dispose();
// TODO: Feed errors to panel
// Feed errors to panel
panel.ShowErrors(errors);
}
// This checks if a script error applies to this script
public override bool VerifyErrorForScript(CompilerError e)
{
return (string.Compare(e.filename, filepathname, true) == 0);
}
// This saves the document (used for both explicit and implicit)

View file

@ -30,6 +30,7 @@ using CodeImp.DoomBuilder.Config;
using CodeImp.DoomBuilder.Types;
using CodeImp.DoomBuilder.IO;
using System.IO;
using CodeImp.DoomBuilder.Compilers;
#endregion
@ -59,7 +60,7 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Constructor / Disposer
// Constructor
public ScriptLumpDocumentTab(string lumpname, ScriptConfiguration config)
public ScriptLumpDocumentTab(ScriptEditorPanel panel, string lumpname, ScriptConfiguration config) : base(panel)
{
// Initialize
this.lumpname = lumpname;
@ -93,8 +94,11 @@ namespace CodeImp.DoomBuilder.Controls
// Compile script
public override void Compile()
{
// Do it!
General.Map.CompileLump(lumpname);
// Compile
General.Map.CompileLump(lumpname, true);
// Feed errors to panel
panel.ShowErrors(General.Map.Errors);
}
// Implicit save
@ -106,6 +110,12 @@ namespace CodeImp.DoomBuilder.Controls
General.Map.SetLumpData(lumpname, stream);
return true;
}
// This checks if a script error applies to this script
public override bool VerifyErrorForScript(CompilerError e)
{
return (string.Compare(e.filename, "?" + lumpname, true) == 0);
}
#endregion

View file

@ -261,8 +261,6 @@ namespace CodeImp.DoomBuilder
// Disable interface
General.MainWindow.DisplayStatus("Waiting for game application to finish...");
General.MainWindow.Enabled = false;
General.MainWindow.Activate();
try
{
@ -292,8 +290,6 @@ namespace CodeImp.DoomBuilder
catch(Exception) { }
// Done
General.MainWindow.Activate();
General.MainWindow.Enabled = true;
General.MainWindow.DisplayReady();
Cursor.Current = oldcursor;
}

View file

@ -373,7 +373,7 @@ namespace CodeImp.DoomBuilder
Configuration mapsettings;
WAD targetwad;
int index;
bool includenodes;
bool includenodes = false;
string origmapname;
General.WriteLogLine("Saving map to file: " + newfilepathname);
@ -407,18 +407,45 @@ namespace CodeImp.DoomBuilder
if(index == -1) index = 0;
io.Write(outputset, TEMP_MAP_HEADER, index);
// Get the corresponding nodebuilder
if(savemode == SAVE_TEST) nodebuildername = configinfo.NodebuilderTest;
else nodebuildername = configinfo.NodebuilderSave;
// Only recompile scripts when the scripts have changed
// (not when only the map changed)
if(CheckScriptChanged())
{
if(!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);
}
else
{
if(errors != null)
{
if(scriptwindow != null) scriptwindow.Editor.ShowErrors(errors);
if(errors.Count > 0) General.ShowWarningMessage("The compiler was unable to compile all scripts in your map, due to script errors.", MessageBoxButtons.OK);
}
}
}
// Build the nodes
oldstatus = General.MainWindow.GetCurrentSatus();
General.MainWindow.DisplayStatus("Building map nodes...");
if((nodebuildername != null) && (nodebuildername != ""))
includenodes = BuildNodes(nodebuildername, true);
else
includenodes = false;
General.MainWindow.DisplayStatus(oldstatus);
// Only rebuild nodes when the actual map has changed
// (not when only scripts have changed)
if(changed)
{
// Get the corresponding nodebuilder
if(savemode == SAVE_TEST) nodebuildername = configinfo.NodebuilderTest;
else nodebuildername = configinfo.NodebuilderSave;
// Build the nodes
oldstatus = General.MainWindow.GetCurrentSatus();
General.MainWindow.DisplayStatus("Building map nodes...");
if((nodebuildername != null) && (nodebuildername != ""))
includenodes = BuildNodes(nodebuildername, true);
else
includenodes = false;
General.MainWindow.DisplayStatus(oldstatus);
}
// Suspend data resources
data.Suspend();
@ -497,37 +524,47 @@ namespace CodeImp.DoomBuilder
// Resume data resources
data.Resume();
try
{
// Open or create the map settings
settingsfile = newfilepathname.Substring(0, newfilepathname.Length - 4) + ".dbs";
options.WriteConfiguration(settingsfile);
}
catch(Exception e)
{
// Warning only
General.WriteLogLine("WARNING: " + e.GetType().Name + ": " + e.Message);
General.WriteLogLine("WARNING: Could not write the map settings configuration file!");
}
// Was the map saved in a different file? And not for testing purpose?
if((savemode != SAVE_TEST) && (newfilepathname != filepathname))
// Not saved for testing purpose?
if(savemode != SAVE_TEST)
{
// Keep new filename
filepathname = newfilepathname;
filetitle = Path.GetFileName(filepathname);
// Saved in a different file?
if(newfilepathname != filepathname)
{
// Keep new filename
filepathname = newfilepathname;
filetitle = Path.GetFileName(filepathname);
// Reload resources
ReloadResources();
}
try
{
// Open or create the map settings
settingsfile = newfilepathname.Substring(0, newfilepathname.Length - 4) + ".dbs";
options.WriteConfiguration(settingsfile);
}
catch(Exception e)
{
// Warning only
General.WriteLogLine("WARNING: " + e.GetType().Name + ": " + e.Message);
General.WriteLogLine("WARNING: Could not write the map settings configuration file!");
}
// Check for compile errors, if the scripts were compiled above
if(CheckScriptChanged() && (errors != null) && (errors.Count > 0))
{
// Show the errors in the script editor
ShowScriptEditor();
scriptwindow.Editor.ShowErrors(errors);
}
// Changes saved
changed = false;
// Reload resources
ReloadResources();
scriptschanged = false;
}
// Reset changed status
if(savemode != SAVE_TEST) changed = false;
// Success!
General.WriteLogLine("Map saving done");
return true;
@ -1119,21 +1156,42 @@ namespace CodeImp.DoomBuilder
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)
private bool CompileScriptLumps()
{
bool success = true;
errors = new List<CompilerError>();
// Go for all the map lumps
foreach(MapLumpInfo lumpinfo in config.MapLumps.Values)
{
// Is this a script lump?
if(lumpinfo.script != null)
{
// Compile it now
success &= CompileLump(lumpinfo.name, false);
}
}
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)
internal bool CompileLump(string lumpname)
internal bool CompileLump(string lumpname, bool clearerrors)
{
DirectoryInfo tempdir;
Compiler compiler;
string inputfile, outputfile;
Compiler compiler;
byte[] filedata;
// Find the lump
Lump lump = tempwad.FindLump(lumpname);
if(lump == null) throw new Exception("No such lump in temporary wad file '" + lumpname + "'.");
// New list of errors
errors = new List<CompilerError>();
if(clearerrors || (errors == null))
errors = new List<CompilerError>();
// Determine the script configuration to use
ScriptConfiguration scriptconfig = config.MapLumps[lump.Name].script;
@ -1176,8 +1234,47 @@ namespace CodeImp.DoomBuilder
compiler.WorkingDirectory = Path.GetDirectoryName(inputfile);
if(compiler.Run())
{
// Fetch errors
errors.AddRange(compiler.Errors);
// Process errors
foreach(CompilerError e in compiler.Errors)
{
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 = "?" + lumpname;
errors.Add(newerror);
}
// No errors?
if(compiler.Errors.Length == 0)
{
// Output file exists?
if(File.Exists(outputfile))
{
// Copy output file data into a lump?
if((scriptconfig.ResultLump != null) && (scriptconfig.ResultLump.Length > 0))
{
// Do that now then
try
{
filedata = File.ReadAllBytes(outputfile);
}
catch(Exception e)
{
// 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);
}
}
}
// Clean up
compiler.Dispose();

View file

@ -169,7 +169,8 @@ namespace CodeImp.DoomBuilder.Map
// Write configuration type information
wadcfg.WriteSetting("type", "Doom Builder Map Settings Configuration");
wadcfg.WriteSetting("gameconfig", configfile);
// Update the settings file with this map configuration
wadcfg.WriteSetting("maps." + currentname, mapconfig.Root);

View file

@ -38,13 +38,13 @@ namespace CodeImp.DoomBuilder.Windows
this.editor.Dock = System.Windows.Forms.DockStyle.Fill;
this.editor.Location = new System.Drawing.Point(0, 0);
this.editor.Name = "editor";
this.editor.Size = new System.Drawing.Size(729, 495);
this.editor.Size = new System.Drawing.Size(729, 578);
this.editor.TabIndex = 0;
//
// ScriptEditorForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(729, 495);
this.ClientSize = new System.Drawing.Size(729, 578);
this.Controls.Add(this.editor);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "ScriptEditorForm";