Re-wrote the MudCompiler project. It now supports compiling whole directories or single files using the new scripting engine.
This commit is contained in:
parent
cd68f3d042
commit
7bc89b294b
5 changed files with 357 additions and 37 deletions
|
@ -6,7 +6,7 @@
|
|||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{98E974DA-C650-4B88-B2F8-57AC7AE6C34F}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>MUDCompiler</RootNamespace>
|
||||
<AssemblyName>MUDCompiler</AssemblyName>
|
||||
|
@ -37,9 +37,14 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
|
@ -47,6 +52,12 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="frmCompiler.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="frmCompiler.Designer.cs">
|
||||
<DependentUpon>frmCompiler.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
@ -55,6 +66,15 @@
|
|||
<Project>{498943A8-DF5A-4DB0-B506-0BFF44788657}</Project>
|
||||
<Name>MudEngine</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\rScripting\rScripting.csproj">
|
||||
<Project>{BC1B32DA-7209-4B32-8171-A190EF21F5D6}</Project>
|
||||
<Name>rScripting</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="frmCompiler.resx">
|
||||
<DependentUpon>frmCompiler.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using MudEngine.Scripting;
|
||||
|
||||
|
@ -9,44 +10,10 @@ namespace MUDCompiler
|
|||
{
|
||||
class Program
|
||||
{
|
||||
[STAThread()]
|
||||
static void Main(String[] args)
|
||||
{
|
||||
Console.WriteLine("===========================");
|
||||
Console.WriteLine("MUD Engine Content Compiler");
|
||||
Console.WriteLine("Version 0.1");
|
||||
Console.WriteLine("===========================");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("1): Compile Scripts");
|
||||
Console.WriteLine("2): Exit Compiler");
|
||||
//Console.Write("Enter Selection: ");
|
||||
Console.WriteLine("Out of engine compiling is currently not supported. Please review the documentation regarding in-engine compiling.");
|
||||
|
||||
String command = Console.ReadLine();
|
||||
|
||||
//command error checking.
|
||||
if (String.IsNullOrEmpty(command))
|
||||
{
|
||||
Console.WriteLine("Invalid Command!");
|
||||
System.Threading.Thread.Sleep(1000); //wait before shutting down so user sees invalid command
|
||||
}
|
||||
else if (Convert.ToInt16(command) >= 3)
|
||||
{
|
||||
Console.WriteLine("Invalid Command!");
|
||||
System.Threading.Thread.Sleep(1000); //wait before shutting down so user sees invalid command
|
||||
}
|
||||
|
||||
switch (Convert.ToInt16(command))
|
||||
{
|
||||
case 1:
|
||||
CompileScripts();
|
||||
break;
|
||||
case 2:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void CompileScripts()
|
||||
{
|
||||
Application.Run(new frmCompiler());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
140
MUDCompiler/frmCompiler.Designer.cs
generated
Normal file
140
MUDCompiler/frmCompiler.Designer.cs
generated
Normal file
|
@ -0,0 +1,140 @@
|
|||
namespace MUDCompiler
|
||||
{
|
||||
partial class frmCompiler
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openDirectoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openScriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.txtConsole = new System.Windows.Forms.RichTextBox();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(784, 24);
|
||||
this.menuStrip1.TabIndex = 0;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.openDirectoryToolStripMenuItem,
|
||||
this.openScriptToolStripMenuItem,
|
||||
this.toolStripMenuItem1,
|
||||
this.exitToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
this.fileToolStripMenuItem.Text = "File";
|
||||
//
|
||||
// openDirectoryToolStripMenuItem
|
||||
//
|
||||
this.openDirectoryToolStripMenuItem.Name = "openDirectoryToolStripMenuItem";
|
||||
this.openDirectoryToolStripMenuItem.Size = new System.Drawing.Size(170, 22);
|
||||
this.openDirectoryToolStripMenuItem.Text = "Compile Directory";
|
||||
this.openDirectoryToolStripMenuItem.Click += new System.EventHandler(this.openDirectoryToolStripMenuItem_Click);
|
||||
//
|
||||
// openScriptToolStripMenuItem
|
||||
//
|
||||
this.openScriptToolStripMenuItem.Name = "openScriptToolStripMenuItem";
|
||||
this.openScriptToolStripMenuItem.Size = new System.Drawing.Size(170, 22);
|
||||
this.openScriptToolStripMenuItem.Text = "Compile File";
|
||||
this.openScriptToolStripMenuItem.Click += new System.EventHandler(this.openScriptToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripMenuItem1
|
||||
//
|
||||
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||
this.toolStripMenuItem1.Size = new System.Drawing.Size(167, 6);
|
||||
//
|
||||
// exitToolStripMenuItem
|
||||
//
|
||||
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
|
||||
this.exitToolStripMenuItem.Size = new System.Drawing.Size(170, 22);
|
||||
this.exitToolStripMenuItem.Text = "Exit";
|
||||
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.txtConsole);
|
||||
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.groupBox1.Location = new System.Drawing.Point(0, 24);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(784, 538);
|
||||
this.groupBox1.TabIndex = 1;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Compile Results";
|
||||
//
|
||||
// txtConsole
|
||||
//
|
||||
this.txtConsole.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.txtConsole.Location = new System.Drawing.Point(3, 16);
|
||||
this.txtConsole.Name = "txtConsole";
|
||||
this.txtConsole.Size = new System.Drawing.Size(778, 519);
|
||||
this.txtConsole.TabIndex = 0;
|
||||
this.txtConsole.Text = "";
|
||||
//
|
||||
// frmCompiler
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(784, 562);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Name = "frmCompiler";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Mud Script Compiler";
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem openDirectoryToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem openScriptToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.RichTextBox txtConsole;
|
||||
}
|
||||
}
|
67
MUDCompiler/frmCompiler.cs
Normal file
67
MUDCompiler/frmCompiler.cs
Normal file
|
@ -0,0 +1,67 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MUDCompiler
|
||||
{
|
||||
public partial class frmCompiler : Form
|
||||
{
|
||||
public frmCompiler()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void openDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
rScripting.CompileEngine engine = new rScripting.CompileEngine();
|
||||
|
||||
FolderBrowserDialog browse = new FolderBrowserDialog();
|
||||
browse.ShowDialog();
|
||||
|
||||
if (String.IsNullOrEmpty(browse.SelectedPath))
|
||||
{
|
||||
txtConsole.Text = "Compilation canceled.";
|
||||
return;
|
||||
}
|
||||
|
||||
bool isOK = engine.Compile(browse.SelectedPath);
|
||||
|
||||
if (isOK)
|
||||
txtConsole.Text = "Compiled without error.";
|
||||
else
|
||||
txtConsole.Text = engine.Errors;
|
||||
}
|
||||
|
||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
private void openScriptToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
rScripting.CompileEngine engine = new rScripting.CompileEngine();
|
||||
|
||||
OpenFileDialog browse = new OpenFileDialog();
|
||||
browse.ShowDialog();
|
||||
|
||||
System.IO.FileInfo file = new System.IO.FileInfo(browse.FileName);
|
||||
|
||||
if (String.IsNullOrEmpty(browse.FileName))
|
||||
{
|
||||
txtConsole.Text = "Compilation canceled.";
|
||||
return;
|
||||
}
|
||||
|
||||
bool isOK = engine.Compile(file);
|
||||
if (isOK)
|
||||
txtConsole.Text = "Compiled without error.";
|
||||
else
|
||||
txtConsole.Text = engine.Errors;
|
||||
}
|
||||
}
|
||||
}
|
126
MUDCompiler/frmCompiler.resx
Normal file
126
MUDCompiler/frmCompiler.resx
Normal file
|
@ -0,0 +1,126 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>27</value>
|
||||
</metadata>
|
||||
</root>
|
Loading…
Add table
Add a link
Reference in a new issue