working on script editor

This commit is contained in:
codeimp 2008-11-11 16:19:50 +00:00
parent 72f4763c13
commit 3b871bbd09
5 changed files with 156 additions and 19 deletions

View file

@ -3,8 +3,11 @@ compilers
{
// This defines what files a compiler uses
// The setting named "program" defines what .exe to run
// The "interface" setting defines what interal interface to use for processing and error feedback
// All others are the required files (the setting names do not matter)
acc
{
interface = "AccCompiler";
program = "acc.exe";
zcommon = "zcommon.acs";
zdefs = "zdefs.acs";

View file

@ -137,6 +137,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="General\MapManager.cs" />
<Compile Include="Actions\SpecialKeys.cs" />
<Compile Include="Config\NodebuilderInfo.cs" />

View file

@ -33,59 +33,70 @@ namespace CodeImp.DoomBuilder.Config
internal class CompilerInfo
{
#region ================== Constants
#endregion
#region ================== Variables
private string name;
private string programfile;
private string programinterface;
private List<string> files;
#endregion
#region ================== Properties
public string Name { get { return name; } }
public string ProgramFile { get { return programfile; } }
public string ProgramInterface { get { return programinterface; } }
public List<string> Files { get { return files; } }
#endregion
#region ================== Constructor / Disposer
// Constructor
public CompilerInfo(string filename, string name, Configuration cfg)
{
IDictionary cfgfiles;
General.WriteLogLine("Registered compiler configuration '" + name + "' from '" + filename + "'");
// Initialize
this.name = name;
this.files = new List<string>();
// Read program file
// Read program file and interface
this.programfile = cfg.ReadSetting("compilers." + name + ".program", "");
this.programinterface = cfg.ReadSetting("compilers." + name + ".interface", "");
// Make list of files required
cfgfiles = cfg.ReadSetting("compilers." + name, new Hashtable());
foreach(DictionaryEntry de in cfgfiles)
files.Add(de.Value.ToString());
{
if(de.Key.ToString() != "interface")
files.Add(de.Value.ToString());
}
}
#endregion
#region ================== Methods
// This copies all compiler files to a given destination
public void CopyRequiredFiles(string targetpath)
{
// Copy files
foreach(string f in files)
File.Copy(Path.Combine(General.CompilersPath, f), Path.Combine(targetpath, f), true);
{
string sourcefile = Path.Combine(General.CompilersPath, f);
string targetfile = Path.Combine(targetpath, f);
if(!File.Exists(sourcefile)) General.WriteLogLine("WARNING: The file '" + f + "' required by the '" + name + "' compiler is missing!");
File.Copy(sourcefile, targetfile, true);
}
}
#endregion
}
}

View file

@ -0,0 +1,74 @@
#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;
#endregion
namespace CodeImp.DoomBuilder.General
{
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);
}
#endregion
}
}

View file

@ -0,0 +1,47 @@
#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;
#endregion
namespace CodeImp.DoomBuilder.General
{
public struct CompilerError
{
// Members
public string description;
public string filename;
public int linenumber;
// Constructor
public CompilerError(string description, string filename, int linenumber)
{
this.description = description;
this.filename = filename;
this.linenumber = linenumber;
}
}
}