Skip to content
Snippets Groups Projects
Commit d2553534 authored by codeimp's avatar codeimp
Browse files

working on script editor

parent 3b871bbd
No related branches found
No related tags found
No related merge requests found
......@@ -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";
......
......@@ -4,7 +4,7 @@
// Compiler settings
compiler = "acc";
parameters = "%FI %FO";
parameters = "-I %PT %FI %FO";
resultlump = "BEHAVIOR";
// Editor settings
......
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.
-------------------------------------------------------------------------------------
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.
......@@ -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" />
......
......@@ -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
#endregion
// Errors
private List<CompilerError> errors;
#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
......
#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
}
}
......@@ -26,7 +26,7 @@ using System.Diagnostics;
#endregion
namespace CodeImp.DoomBuilder.General
namespace CodeImp.DoomBuilder.Compilers
{
public struct CompilerError
{
......
......@@ -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)
{
......
......@@ -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()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment