working on script editor

This commit is contained in:
codeimp 2008-11-13 16:21:11 +00:00
parent 3b871bbd09
commit d2553534cb
10 changed files with 175 additions and 21 deletions

View file

@ -5,6 +5,7 @@ compilers
// The setting named "program" defines what .exe to run
hacc
{
interface = "AccCompiler";
program = "hacc.exe";
common = "common.acs";
defs = "defs.acs";

View file

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

View file

@ -0,0 +1,29 @@
This describes the various compiler interfaces available. These can be used with
the "interface" setting in a compiler configuration. Plugins can create their
own interfaces by inheriting from the abstract Compiler class.
-------------------------------------------------------------------------------------
AccCompiler
This compiler interface is made for Acc compilers, but can be used for any compiler
which accepts a single script input file and writes a single output file.
If this interface detects a file named "acs.err" created by the compiler, it will
parse this file and treat the contents as compiler errors. In this case, the output
file contents are not copied into the wad file.
With this interface you can use the following command-line parameters:
%FI indicates the input path and filename.
%FO indicates the output path and filename.
%PI indicates the path of the input file (without filename).
%PO indicates the path of the output file (without filename).
%PT indicates the temporary directory path where the compiler is located.
-------------------------------------------------------------------------------------

View file

@ -1,3 +1,8 @@
This describes the placeholders that can be used in the command-line parameter for
testing settings (for launching the sourceport).
-------------------------------------------------------------------------------------
%F indicates the edited PWAD file to be tested.
@ -20,8 +25,22 @@ This is the first (highest) IWAD file that is found in the resources list.
-------------------------------------------------------------------------------------
%L1 indicates the first number in the map lump name and
%L2 indicates the second number in the map lump name.
These can be used for the -warp parameter.
-------------------------------------------------------------------------------------
%AP indicates the all resources files, except the first IWAD file (paths included).
The items are seperated by spaces. When used within quotes "%AP", the quotes are
also repeated for every item.
-------------------------------------------------------------------------------------
%S indicates the skill number at which to test.
-------------------------------------------------------------------------------------
%NM indicates the position where to put -nomonsters when the user chooses to test
without monsters.

View file

@ -45,6 +45,7 @@
</Target>
-->
<ItemGroup>
<Compile Include="Compilers\AccCompiler.cs" />
<Compile Include="Config\ArgumentInfo.cs" />
<Compile Include="Config\MapLumpInfo.cs" />
<Compile Include="Config\ScriptConfiguration.cs" />
@ -137,8 +138,8 @@
<Compile Include="Config\ConfigurationInfo.cs" />
<Compile Include="Editing\VisualMode.cs" />
<Compile Include="General\Clock.cs" />
<Compile Include="General\Compiler.cs" />
<Compile Include="General\CompilerError.cs" />
<Compile Include="Compilers\Compiler.cs" />
<Compile Include="Compilers\CompilerError.cs" />
<Compile Include="General\MapManager.cs" />
<Compile Include="Actions\SpecialKeys.cs" />
<Compile Include="Config\NodebuilderInfo.cs" />

View file

@ -26,30 +26,27 @@ using System.Diagnostics;
#endregion
namespace CodeImp.DoomBuilder.General
namespace CodeImp.DoomBuilder.Compilers
{
public abstract class Compiler
public sealed class AccCompiler : Compiler
{
#region ================== Variables
#region ================== Constants
// Errors
private List<CompilerError> errors;
#endregion
#region ================== Variables
#endregion
#region ================== Properties
public CompilerError[] Errors { get { return errors.ToArray(); } }
#endregion
#region ================== Constructor
// Constructor
public Compiler()
public AccCompiler()
{
// Initialize
this.errors = new List<CompilerError>();
}
#endregion
@ -60,12 +57,9 @@ namespace CodeImp.DoomBuilder.General
/// This runs the compiler.
/// </summary>
/// <returns>Returns false when failed to start.</returns>
public abstract bool Run();
// This reports an error
protected void ReportError(CompilerError err)
public override bool Run()
{
this.errors.Add(err);
return true;
}
#endregion

View file

@ -0,0 +1,100 @@
#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;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Reflection;
#endregion
namespace CodeImp.DoomBuilder.Compilers
{
public abstract class Compiler
{
#region ================== Variables
// Errors
private List<CompilerError> errors;
#endregion
#region ================== Properties
public CompilerError[] Errors { get { return errors.ToArray(); } }
#endregion
#region ================== Constructor
// Constructor
public Compiler()
{
// Initialize
this.errors = new List<CompilerError>();
}
#endregion
#region ================== Methods
/// <summary>
/// This runs the compiler.
/// </summary>
/// <returns>Returns false when failed to start.</returns>
public abstract bool Run();
// This reports an error
protected void ReportError(CompilerError err)
{
this.errors.Add(err);
}
// This creates a compiler by interface name
internal static Compiler Create(string name)
{
// Make list of assemblies to search in
List<Assembly> asms = General.Plugins.GetPluginAssemblies();
asms.Add(General.ThisAssembly);
try
{
// TODO
}
// Catch errors
catch(TargetInvocationException e)
{
// Throw the actual exception
Debug.WriteLine(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());
Debug.WriteLine(e.InnerException.Source + " throws " + e.InnerException.GetType().Name + ":");
Debug.WriteLine(e.InnerException.Message);
Debug.WriteLine(e.InnerException.StackTrace);
throw e.InnerException;
}
}
#endregion
}
}

View file

@ -26,7 +26,7 @@ using System.Diagnostics;
#endregion
namespace CodeImp.DoomBuilder.General
namespace CodeImp.DoomBuilder.Compilers
{
public struct CompilerError
{

View file

@ -88,7 +88,7 @@ namespace CodeImp.DoomBuilder.IO
// Create IO class
result = (MapSetIO)General.ThisAssembly.CreateInstance(fullname, false,
BindingFlags.Default, null, args, CultureInfo.CurrentCulture, new object[0]);
// Check result
if(result != null)
{

View file

@ -87,7 +87,17 @@ namespace CodeImp.DoomBuilder.Plugins
#endregion
#region ================== Methods
// This creates a list of assemblies
public List<Assembly> GetPluginAssemblies()
{
List<Assembly> asms = new List<Assembly>(plugins.Count);
foreach(Plugin p in plugins)
asms.Add(p.Assembly);
return asms;
}
// This loads all plugins
public void LoadAllPlugins()
{