MudCompiler:
- Removed External Script compilation support for now. I'll add it back once I provide SourceFile and SourceCode compiling support to the MudScriptCompiler. At the moment only Whole Directory compiling is supported. MudDesigner: - Removed all of the source code, with the exception of the designer generated source, from frmProjectManager. It will need to be re-wrote due to the removal of the MudScriptEngine. MudEngine: - Deleted Scripting.GameObject - Deleted Scripting.GameObjectCollection - Deleted Scripting.ScriptEngine - Deleted classes were replaced by the rScript engine. Only class needed now is the MudScriptCompiler, which handles all of the custom MudEngine script compiling, using the rScript Engine. - Removed old Scripting.ScriptEngine references from within GameManagement.Game - GameManagement.Game no longer checks to see if MudEngine.dll exists. If it didn't exist, the engine wouldn't be running to perform that check in the first place. - GameManagement.Game no longer adds MudEngine.dll as a referenced assembly. The MudScriptCompiler handles that during compilation. - MudScriptCompiler.Compile() always returns false when SourceFile or SourceCode is passed as an argument. Only Script Directories can be compiled at this time. MudGame: - Removed references to Scripting.ScriptEngine from MudGame.Program - Re-wrote how scripted Type's that inherit and replace MudEngine.GameManagement.Game. Scripts are compiled prior to Game.Start() being invoked, allowing GameManagement.Game to be replaced with an inherited class from a compiled script. TODO: Look at a way to prevent Game.Start() from compiling the scripts again, as they have already been compiled once. It's not a big hit on startup time, but it needs to be wrote the proper way.
This commit is contained in:
parent
7a0d1c5a74
commit
3f73247d0e
10 changed files with 38 additions and 689 deletions
|
@ -17,144 +17,23 @@ namespace MudDesigner
|
|||
{
|
||||
public partial class frmProjectManager : Form
|
||||
{
|
||||
String[] _ProjectFiles;
|
||||
String _ProjectPath;
|
||||
String _ScriptPath;
|
||||
const String SettingsFile = "Settings.ini";
|
||||
|
||||
dynamic _Game;
|
||||
ScriptEngine _ScriptEngine;
|
||||
Client client;
|
||||
Thread r;
|
||||
|
||||
public frmProjectManager()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_ProjectPath = Path.Combine(Environment.CurrentDirectory, "Projects");
|
||||
_ScriptPath = Path.Combine(Environment.CurrentDirectory, "Scripts");
|
||||
|
||||
if (!Directory.Exists(_ProjectPath))
|
||||
Directory.CreateDirectory(_ProjectPath);
|
||||
|
||||
if (!Directory.Exists(_ScriptPath))
|
||||
Directory.CreateDirectory(_ScriptPath);
|
||||
|
||||
if (!File.Exists(SettingsFile))
|
||||
{
|
||||
Log.Write("Settings.ini missing!", false);
|
||||
FileManager.WriteLine(SettingsFile, "Scripts", "ScriptPath");
|
||||
FileManager.WriteLine(SettingsFile, ".cs", "ScriptExtension");
|
||||
FileManager.WriteLine(SettingsFile, "True", "ServerEnabled");
|
||||
}
|
||||
|
||||
_ScriptEngine = new ScriptEngine(new Game(), ScriptEngine.ScriptTypes.Both);
|
||||
_ScriptEngine.Initialize();
|
||||
|
||||
GameObject go = _ScriptEngine.GetObject("Game");
|
||||
|
||||
if (go == null)
|
||||
{
|
||||
_Game = new Game();
|
||||
go = new GameObject(_Game, "Game");
|
||||
_ScriptEngine = new ScriptEngine(_Game, ScriptEngine.ScriptTypes.Both);
|
||||
}
|
||||
else
|
||||
{
|
||||
_Game = (Game)go.Instance;
|
||||
_ScriptEngine = new ScriptEngine(_Game, ScriptEngine.ScriptTypes.Both);
|
||||
}
|
||||
|
||||
//TODO: Do I need to Re-initialize _ScriptEngine?
|
||||
|
||||
RefreshProjects();
|
||||
|
||||
client = new Client();
|
||||
client.Initialize("localhost", 555);
|
||||
|
||||
comServerType.Items.Add("Local Server");
|
||||
comServerType.Items.Add("Test Server");
|
||||
comServerType.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void RefreshProjects()
|
||||
{
|
||||
_ProjectFiles = Directory.GetFiles(Environment.CurrentDirectory, "*.ini");
|
||||
|
||||
foreach (String filename in _ProjectFiles)
|
||||
{
|
||||
if (Path.GetFileNameWithoutExtension(filename).ToLower() == "settings")
|
||||
continue;
|
||||
|
||||
_Game.Load(filename);
|
||||
|
||||
lstProjects.Items.Add(_Game.GameTitle);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnNewProject_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmInputBox input = new frmInputBox("Enter the name of your project.");
|
||||
input.ShowDialog();
|
||||
|
||||
if (input.IsCancel)
|
||||
return;
|
||||
else if (String.IsNullOrEmpty(input.Input))
|
||||
return;
|
||||
|
||||
lstProjects.Items.Add(input.Input);
|
||||
|
||||
_Game.GameTitle = input.Input;
|
||||
//Setup save data paths.
|
||||
_Game.DataPaths = new SaveDataPaths(Path.Combine("Projects", _Game.GameTitle, _Game.DataPaths.Environment), Path.Combine("Projects", _Game.GameTitle, _Game.DataPaths.Players), Path.Combine("Projects", _Game.GameTitle, _Game.DataPath.Scripts));
|
||||
|
||||
_Game.Save();
|
||||
|
||||
input = null;
|
||||
|
||||
ShowDesigner();
|
||||
}
|
||||
|
||||
private void ShowDesigner()
|
||||
{
|
||||
frmDesigner form = new frmDesigner(_Game, client);
|
||||
|
||||
form.Show();
|
||||
this.Hide();
|
||||
|
||||
if (comServerType.SelectedItem.ToString() == "Test Server")
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
frmInputBox input = new frmInputBox("Enter the Port that your local server is currently running on.");
|
||||
|
||||
input.ShowDialog();
|
||||
|
||||
if (input.IsCancel)
|
||||
return;
|
||||
|
||||
client.Initialize("localhost", Convert.ToInt32(input.Input));
|
||||
|
||||
if (!client.Connect() || !client.Send("hello", false)) // test send + client data
|
||||
{
|
||||
MessageBox.Show("Failed to connect to a local server. Is the server running?", "Mud Designer");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
while (form.Visible)
|
||||
{
|
||||
Application.DoEvents();
|
||||
}
|
||||
|
||||
//Refresh the project list incase the project was renamed.
|
||||
lstProjects.Items.Clear();
|
||||
|
||||
RefreshProjects();
|
||||
|
||||
this.Show();
|
||||
form = null;
|
||||
}
|
||||
|
||||
private void btnClose_Click(object sender, EventArgs e)
|
||||
|
@ -163,11 +42,7 @@ namespace MudDesigner
|
|||
}
|
||||
|
||||
private void editProjectToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (File.Exists(lstProjects.SelectedItem.ToString() + ".ini"))
|
||||
_Game.Load(lstProjects.SelectedItem.ToString() + ".ini");
|
||||
|
||||
ShowDesigner();
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue