MUD Engine:
- BaseObject now sets the default value for Name programmatically for the editors propertygrids. - Room, Realm and Zone no longer set their Name Properties to their default value, BaseObject handles it. Room Designer: - Scripts where'nt being saved, this has been corrected. - Rooms wheren't being loaded when supplied via the command line argument (Method is used by the Zone Builder) - Displaying scripts within the Designer is now fixed. Zone Builder: - Now displays the Zone Object Properties in the property grid.
This commit is contained in:
parent
24b5c3f687
commit
82e43cb4f2
7 changed files with 72 additions and 84 deletions
|
@ -11,22 +11,6 @@ namespace MUDEngine.Objects
|
||||||
{
|
{
|
||||||
public class BaseObject
|
public class BaseObject
|
||||||
{
|
{
|
||||||
public virtual void OnEnter()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnExit()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnCreate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnDestroy()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[Category("Object Setup")]
|
[Category("Object Setup")]
|
||||||
[RefreshProperties(RefreshProperties.All)] //Required to refresh Filename property in the editors propertygrid
|
[RefreshProperties(RefreshProperties.All)] //Required to refresh Filename property in the editors propertygrid
|
||||||
public string Name
|
public string Name
|
||||||
|
@ -59,29 +43,70 @@ namespace MUDEngine.Objects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Browsable(false)]
|
|
||||||
[XmlIgnore()]
|
|
||||||
public Controls.VisualContainer Control
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return this._Control;
|
|
||||||
}
|
|
||||||
internal set
|
|
||||||
{
|
|
||||||
this._Control = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private Controls.VisualContainer _Control;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the base object
|
/// Initializes the base object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BaseObject()
|
public BaseObject()
|
||||||
{
|
{
|
||||||
Control = new Controls.VisualContainer(this);
|
|
||||||
Script = "";
|
Script = "";
|
||||||
this.Name = "New " + this.GetType().Name;
|
this.Name = DefaultName();
|
||||||
|
SetupScript();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ShouldSerializeName()
|
||||||
|
{
|
||||||
|
return this.Name != DefaultName();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetName()
|
||||||
|
{
|
||||||
|
this.Name = DefaultName();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string DefaultName()
|
||||||
|
{
|
||||||
|
return "New " + this.GetType().Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetupScript()
|
||||||
|
{
|
||||||
|
//Check if the realm script is empty. If so then generate a standard script for it.
|
||||||
|
if (Script == "")
|
||||||
|
{
|
||||||
|
//Instance a new method helper class
|
||||||
|
ManagedScripting.CodeBuilding.MethodSetup method = new ManagedScripting.CodeBuilding.MethodSetup();
|
||||||
|
string script = "";
|
||||||
|
//Setup our method. All objects inheriting from BaseObject will have the standard
|
||||||
|
//methods created for them.
|
||||||
|
string[] names = new string[] { "OnCreate", "OnDestroy", "OnEnter", "OnExit" };
|
||||||
|
foreach (string name in names)
|
||||||
|
{
|
||||||
|
method = new ManagedScripting.CodeBuilding.MethodSetup();
|
||||||
|
method.Name = name;
|
||||||
|
method.ReturnType = "void";
|
||||||
|
method.IsOverride = true;
|
||||||
|
method.Modifier = ManagedScripting.CodeBuilding.ClassGenerator.Modifiers.Public;
|
||||||
|
method.Code = new string[] { "base." + method.Name + "();" };
|
||||||
|
script = script.Insert(Script.Length, method.Create() + "\n");
|
||||||
|
}
|
||||||
|
Script = script;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnEnter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnExit()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnCreate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnDestroy()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,20 +60,6 @@ namespace MUDEngine.Objects.Environment
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
public List<Door> InstalledDoors;
|
public List<Door> InstalledDoors;
|
||||||
|
|
||||||
[XmlIgnore()]
|
|
||||||
[Browsable(false)]
|
|
||||||
public new Controls.RoomControl Control
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return this._Control;
|
|
||||||
}
|
|
||||||
internal set
|
|
||||||
{
|
|
||||||
this._Control = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Room()
|
public Room()
|
||||||
{
|
{
|
||||||
InstalledDoors = new List<Door>();
|
InstalledDoors = new List<Door>();
|
||||||
|
|
|
@ -11,8 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RoomDesigner", "RoomDesigne
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MudDesigner", "MudDesigner\MudDesigner.csproj", "{F782C36B-5A00-4BC9-BE4E-B631729DA40E}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MudDesigner", "MudDesigner\MudDesigner.csproj", "{F782C36B-5A00-4BC9-BE4E-B631729DA40E}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualDesigner", "VisualDesigner\VisualDesigner.csproj", "{2E20971A-E968-4AE9-B7B2-58236D499618}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZoneBuilder", "ZoneBuilder\ZoneBuilder.csproj", "{C81C3F3F-1D36-451E-A17A-33E953C30307}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZoneBuilder", "ZoneBuilder\ZoneBuilder.csproj", "{C81C3F3F-1D36-451E-A17A-33E953C30307}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RealmExplorer", "RealmExplorer\RealmExplorer.csproj", "{7CF280B2-883D-4218-AE39-6B511E2704A3}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RealmExplorer", "RealmExplorer\RealmExplorer.csproj", "{7CF280B2-883D-4218-AE39-6B511E2704A3}"
|
||||||
|
@ -43,10 +41,6 @@ Global
|
||||||
{F782C36B-5A00-4BC9-BE4E-B631729DA40E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{F782C36B-5A00-4BC9-BE4E-B631729DA40E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{F782C36B-5A00-4BC9-BE4E-B631729DA40E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{F782C36B-5A00-4BC9-BE4E-B631729DA40E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{F782C36B-5A00-4BC9-BE4E-B631729DA40E}.Release|Any CPU.Build.0 = Release|Any CPU
|
{F782C36B-5A00-4BC9-BE4E-B631729DA40E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{2E20971A-E968-4AE9-B7B2-58236D499618}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{2E20971A-E968-4AE9-B7B2-58236D499618}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{2E20971A-E968-4AE9-B7B2-58236D499618}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{2E20971A-E968-4AE9-B7B2-58236D499618}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{C81C3F3F-1D36-451E-A17A-33E953C30307}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{C81C3F3F-1D36-451E-A17A-33E953C30307}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{C81C3F3F-1D36-451E-A17A-33E953C30307}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{C81C3F3F-1D36-451E-A17A-33E953C30307}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{C81C3F3F-1D36-451E-A17A-33E953C30307}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{C81C3F3F-1D36-451E-A17A-33E953C30307}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace RoomDesigner
|
||||||
|
|
||||||
if (File.Exists(file))
|
if (File.Exists(file))
|
||||||
{
|
{
|
||||||
Application.Run(new frmMain(room));
|
Application.Run(new frmMain(argument));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
1
RoomDesigner/frmMain.Designer.cs
generated
1
RoomDesigner/frmMain.Designer.cs
generated
|
@ -229,6 +229,7 @@
|
||||||
this.txtScript.Size = new System.Drawing.Size(555, 267);
|
this.txtScript.Size = new System.Drawing.Size(555, 267);
|
||||||
this.txtScript.TabIndex = 0;
|
this.txtScript.TabIndex = 0;
|
||||||
this.txtScript.Text = "";
|
this.txtScript.Text = "";
|
||||||
|
this.txtScript.TextChanged += new System.EventHandler(this.txtScript_TextChanged);
|
||||||
//
|
//
|
||||||
// groupBox5
|
// groupBox5
|
||||||
//
|
//
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace RoomDesigner
|
||||||
|
|
||||||
//Get the current rooms scripts.
|
//Get the current rooms scripts.
|
||||||
//TODO: Add Doorway script support
|
//TODO: Add Doorway script support
|
||||||
SetupRoomScript();
|
//SetupRoomScript();
|
||||||
|
|
||||||
if (parameters.Length != 0)
|
if (parameters.Length != 0)
|
||||||
{
|
{
|
||||||
|
@ -69,13 +69,14 @@ namespace RoomDesigner
|
||||||
{
|
{
|
||||||
if (argument.ToString().ToLower().StartsWith("room="))
|
if (argument.ToString().ToLower().StartsWith("room="))
|
||||||
{
|
{
|
||||||
string rooms = Engine.GetDataPath(Engine.SaveDataTypes.Rooms);
|
string roomPath = Engine.GetDataPath(Engine.SaveDataTypes.Rooms);
|
||||||
string filename = System.IO.Path.Combine(rooms, argument.ToString());
|
string room = argument.ToString().Substring("room=".Length);
|
||||||
|
string filename = System.IO.Path.Combine(roomPath, room.ToString());
|
||||||
|
|
||||||
//Room to load should always be the first arg.
|
//Room to load should always be the first arg.
|
||||||
if (System.IO.File.Exists(filename))
|
if (System.IO.File.Exists(filename))
|
||||||
{
|
{
|
||||||
_CurrentRoom = (Room)ManagedScripting.XmlSerialization.Load(filename, _CurrentRoom);
|
_CurrentRoom = (Room)MUDEngine.FileSystem.FileSystem.Load(filename, _CurrentRoom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,6 +85,7 @@ namespace RoomDesigner
|
||||||
|
|
||||||
//Show the user(s) the rooms properties
|
//Show the user(s) the rooms properties
|
||||||
propertyRoom.SelectedObject = _CurrentRoom;
|
propertyRoom.SelectedObject = _CurrentRoom;
|
||||||
|
txtScript.Text = _CurrentRoom.Script;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupRoomScript()
|
private void SetupRoomScript()
|
||||||
|
@ -359,5 +361,10 @@ namespace RoomDesigner
|
||||||
+ "}\n";
|
+ "}\n";
|
||||||
MessageBox.Show(_ScriptEngine.Compile(code), "Script Compiling", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show(_ScriptEngine.Compile(code), "Script Compiling", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void txtScript_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_CurrentRoom.Script = txtScript.Text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,32 +26,7 @@ namespace ZoneBuilder
|
||||||
_CurrentRoom = new Room();
|
_CurrentRoom = new Room();
|
||||||
_CurrentZone = new Zone();
|
_CurrentZone = new Zone();
|
||||||
|
|
||||||
SetupScript();
|
propertyZone.SelectedObject = _CurrentZone;
|
||||||
}
|
|
||||||
|
|
||||||
private void SetupScript()
|
|
||||||
{
|
|
||||||
//Check if the realm script is empty. If so then generate a standard script for it.
|
|
||||||
if (String.IsNullOrEmpty(_CurrentZone.Script))
|
|
||||||
{
|
|
||||||
//Instance a new method helper class
|
|
||||||
ManagedScripting.CodeBuilding.MethodSetup method = new ManagedScripting.CodeBuilding.MethodSetup();
|
|
||||||
string script = "";
|
|
||||||
//Setup our method. All objects inheriting from BaseObject will have the standard
|
|
||||||
//methods created for them.
|
|
||||||
string[] names = new string[] { "OnCreate", "OnDestroy", "OnEnter", "OnExit" };
|
|
||||||
foreach (string name in names)
|
|
||||||
{
|
|
||||||
method = new ManagedScripting.CodeBuilding.MethodSetup();
|
|
||||||
method.Name = name;
|
|
||||||
method.ReturnType = "void";
|
|
||||||
method.IsOverride = true;
|
|
||||||
method.Modifier = ManagedScripting.CodeBuilding.ClassGenerator.Modifiers.Public;
|
|
||||||
method.Code = new string[] { "base." + method.Name + "();" };
|
|
||||||
script = script.Insert(_CurrentZone.Script.Length, method.Create() + "\n");
|
|
||||||
}
|
|
||||||
_CurrentZone.Script = script;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnRoomEditor_Click(object sender, EventArgs e)
|
private void btnRoomEditor_Click(object sender, EventArgs e)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue