- Removed the ManagedScripting Engine from the project. Scripting will be implemented at a later time using a custom build engine.
 - Room.Load was re-wrote to allow for loading a supplied room name (not a full filename). The Room will load the supplied Roomname by checking within it's current Zone. Rooms within different Zones can be loaded by supplying a Zone name as one of the optional parameters. Same goes for loading Rooms within a different Realm
 - All classes using the original Room.Load code have been tweaked to use the new code. Cuts the needed code used by each individual class by 80%.
 - Room.InstallPath Property added for returning the full filename and location of the Room where it's currently installed.

Designer:
 - Room Designer now supports deleting Rooms.
 - Doorway Editor no longer fails when attempting to change doorway Traveling Directions.

Runtime:
 - No longer prints blank lines if the object does not contain any text to print.
 - Added a 2nd Print method with a boolean argument for printing blank lines by force if needed.

Note: Room Deleting and Room.Load code was only tested using Rooms within Root Zones. Rooms contained within a Zone owned by a Realm was not tested.
This commit is contained in:
Scionwest_cp 2010-02-06 20:56:15 -08:00
parent 59502408ce
commit f79a5d482b
15 changed files with 147 additions and 92 deletions

View file

@ -1 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Properties><Property><Name>svn:mime-type</Name><Value>application/octet-stream</Value></Property></Properties></ItemProperties>

Binary file not shown.

View file

@ -46,10 +46,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ManagedScriptingWIN, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\ManagedScriptingWIN.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>

View file

@ -22,20 +22,8 @@ namespace MudDesigner.MudEngine.Characters
{
if (CurrentRoom.DoorwayExist(travelDirection.ToString()))
{
string fileName = "";
if (CurrentRoom.Realm == "No Realm Associated.")
{
fileName = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Zones), CurrentRoom.Zone);
fileName = Path.Combine(fileName, "Rooms");
}
else
{
fileName = Path.Combine(FileManager.GetDataPath(CurrentRoom.Realm, CurrentRoom.Zone), "Rooms");
}
string connectedRoom = CurrentRoom.GetDoor(travelDirection).ConnectedRoom;
fileName = Path.Combine(fileName, connectedRoom);
fileName += ".room";
CurrentRoom = (Room)CurrentRoom.Load(fileName);
CurrentRoom = (Room)CurrentRoom.Load(connectedRoom);
}
}
}

View file

@ -33,23 +33,8 @@ namespace MudDesigner.MudEngine.GameCommands
if (door.TravelDirection == direction)
{
string zonePath = "";
string roomPath = "";
string roomFilename = "";
room = (Room)room.Load(door.ConnectedRoom);
if (room.Realm == "No Realm Associated.")
{
zonePath = FileManager.GetDataPath(SaveDataTypes.Zones);
zonePath = Path.Combine(zonePath, room.Zone);
}
else
{
zonePath = FileManager.GetDataPath(room.Realm, room.Zone);
}
roomPath = Path.Combine(zonePath, "Rooms");
roomFilename = Path.Combine(roomPath, door.ConnectedRoom + ".room");
room = (Room)room.Load(roomFilename);
CommandResults cmd = CommandEngine.ExecuteCommand("Look", player, project, room, "Look");
string lookValue = "";
@ -57,7 +42,6 @@ namespace MudDesigner.MudEngine.GameCommands
lookValue = cmd.Result[0].ToString();
return new CommandResults(new object[] { lookValue, room });
}
}
}

View file

@ -7,9 +7,6 @@ using System.Text;
using MudDesigner.MudEngine.FileSystem;
using MudDesigner.MudEngine.GameManagement;
using MudDesigner.MudEngine.GameObjects;
//ManagedScripting
using ManagedScripting;
using ManagedScripting.CodeBuilding;
namespace MudDesigner.MudEngine.GameManagement
{

View file

@ -100,7 +100,6 @@ namespace MudDesigner.MudEngine.GameObjects
private string _Name = "";
#endregion
#region Constructor & Private Methods
/// <summary>
/// Initializes the base object
/// </summary>
@ -114,7 +113,6 @@ namespace MudDesigner.MudEngine.GameObjects
this.Listen = "You hear nothing of interest.";
this.Smell = "You don't smell anything unsual.";
this.Name = DefaultName();
SetupScript();
}
private bool ShouldSerializeName()
@ -132,39 +130,13 @@ namespace MudDesigner.MudEngine.GameObjects
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;
}
}
#endregion
#region Public Methods
/// <summary>
/// Loads the supplied filename and returns it.
/// </summary>
/// <param name="filename"></param>
/// <returns></returns>
public object Load(string filename)
public virtual object Load(string filename)
{
if (!File.Exists(filename))
{

View file

@ -6,7 +6,9 @@ using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Drawing.Design;
using System.IO;
using MudDesigner.MudEngine.FileSystem;
using MudDesigner.MudEngine.UITypeEditors;
namespace MudDesigner.MudEngine.GameObjects.Environment
@ -76,6 +78,26 @@ namespace MudDesigner.MudEngine.GameObjects.Environment
set;
}
[Browsable(false)]
public string InstallPath
{
get
{
string zonePath = "";
if (this.Realm == null || this.Realm == "No Realm Associated.")
{
zonePath = FileManager.GetDataPath(SaveDataTypes.Zones);
zonePath = Path.Combine(zonePath, this.Zone);
}
else
zonePath = FileManager.GetDataPath(this.Realm, this.Zone);
string roomPath = Path.Combine(zonePath, "Rooms");
string filename = Path.Combine(roomPath, this.Filename);
return filename;
}
}
public Room()
{
Doorways = new List<Door>();
@ -103,5 +125,63 @@ namespace MudDesigner.MudEngine.GameObjects.Environment
}
return null;
}
/// <summary>
/// Load a Room that exists within the same Zone as the current Room
/// </summary>
/// <param name="roomName"></param>
/// <returns></returns>
public override object Load(string roomName)
{
//Correct the roomname incase it doesnt contain a file extension
if (!roomName.ToLower().EndsWith(".room"))
roomName += ".room";
//If the current room does not belong within a Realm, then load it from the
//Zones root directory
if (this.Realm != null || this.Realm != "No Realm Associated.")
{
return this.Load(roomName, this.Zone);
}
//This Zone is contained within a Realm so we have to load it from within the
//Realm and not from within the Zones root directory
else
return this.Load(roomName, this.Zone, this.Realm);
}
public object Load(string roomName, string zoneName)
{
string filename = "";
if (!roomName.ToLower().EndsWith(".room"))
roomName += ".room";
if (this.Realm != null && this.Realm != "No Realm Associated.")
{
return this.Load(roomName, zoneName, this.Realm);
}
else
filename = FileManager.GetDataPath(SaveDataTypes.Zones);
filename = Path.Combine(filename, zoneName);
filename = Path.Combine(filename, "Rooms");
filename = Path.Combine(filename, roomName);
return base.Load(filename);
}
public object Load(string roomName, string zoneName, string realmName)
{
if (!roomName.ToLower().EndsWith(".room"))
roomName += ".room";
string filename = FileManager.GetDataPath(realmName, zoneName);
filename = Path.Combine(filename, "Rooms");
filename = Path.Combine(filename, roomName);
if (realmName == null || realmName == "No Realm Associated.")
return this.Load(roomName, zoneName);
return base.Load(filename);
}
}
}

View file

@ -128,7 +128,8 @@ namespace MudDesigner.MudEngine.GameObjects.Environment
foreach (string file in rooms)
{
Room r = new Room();
r = (Room)FileManager.Load(file, r);
r = (Room)r.Load(Path.GetFileNameWithoutExtension(file));
//r = (Room)FileManager.Load(file, r);
this.Rooms.Add(r);
}

View file

@ -80,7 +80,7 @@ namespace MudDesigner.MudEngine.UITypeEditors
propertyDoorway.Refresh();
return;
}
else if (_Room.DoorwayExist(e.ChangedItem.Value.ToString()))
else if (lstInstalledDoors.Items.Contains(e.ChangedItem.Value.ToString()))
{
MessageBox.Show("This direction has already been installed into the room. Please select another direction.", "Mud Designer");
_Door = (Door)propertyDoorway.SelectedObject;
@ -88,6 +88,11 @@ namespace MudDesigner.MudEngine.UITypeEditors
propertyDoorway.Refresh();
return;
}
else
{
lstInstalledDoors.Items.Remove(e.OldValue.ToString());
lstInstalledDoors.Items.Add(e.ChangedItem.Value.ToString());
}
}
else if (e.ChangedItem.Label == "ConnectedRoom")
{

View file

@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UIRoomControl));
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.lstRooms = new System.Windows.Forms.ListBox();
@ -37,9 +38,12 @@
this.txtFindRoom = new System.Windows.Forms.ToolStripTextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.propertyRoom = new System.Windows.Forms.PropertyGrid();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.mnuDeleteRoom = new System.Windows.Forms.ToolStripMenuItem();
this.groupBox1.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
@ -57,6 +61,7 @@
//
// lstRooms
//
this.lstRooms.ContextMenuStrip = this.contextMenuStrip1;
this.lstRooms.Dock = System.Windows.Forms.DockStyle.Fill;
this.lstRooms.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lstRooms.FormattingEnabled = true;
@ -124,6 +129,20 @@
this.propertyRoom.ToolbarVisible = false;
this.propertyRoom.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyRoom_PropertyValueChanged);
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mnuDeleteRoom});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(143, 26);
//
// mnuDeleteRoom
//
this.mnuDeleteRoom.Name = "mnuDeleteRoom";
this.mnuDeleteRoom.Size = new System.Drawing.Size(152, 22);
this.mnuDeleteRoom.Text = "Delete Room";
this.mnuDeleteRoom.Click += new System.EventHandler(this.mnuDeleteRoom_Click);
//
// UIRoomControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -147,6 +166,7 @@
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -161,5 +181,7 @@
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.PropertyGrid propertyRoom;
public System.Windows.Forms.ListBox lstRooms;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem mnuDeleteRoom;
}
}

View file

@ -145,8 +145,7 @@ namespace MudDesigner.MudEngine.UITypeEditors
{
//Load the connected room
Room r = new Room();
fullFilename = Path.Combine(savePath, d.ConnectedRoom + ".room");
r = (Room)r.Load(fullFilename);
r = (Room)r.Load(d.ConnectedRoom);
//Loop though each of its doorways to see if any of them are attached
//to are old room name
foreach (Door renamedDoor in r.Doorways)
@ -211,7 +210,7 @@ namespace MudDesigner.MudEngine.UITypeEditors
zoneRoomPath = Path.Combine(zonePath, "Rooms");
roomFile = Path.Combine(zoneRoomPath, roomName);
_Room = new Room();
_Room = (Room)_Room.Load(roomFile);
_Room = (Room)_Room.Load(roomName, _Zone.Name, _Zone.Realm);
propertyRoom.SelectedObject = _Room;
}
@ -220,5 +219,20 @@ namespace MudDesigner.MudEngine.UITypeEditors
if (!CheckSavedState())
e.Cancel = true;
}
private void mnuDeleteRoom_Click(object sender, EventArgs e)
{
if (lstRooms.SelectedIndex == -1)
{
MessageBox.Show("Select a Room to delete first!", "Mud Designer");
return;
}
Room r = new Room();
r = (Room)r.Load(lstRooms.SelectedItem.ToString(), _Zone.Name);
File.Delete(r.InstallPath);
lstRooms.Items.Remove(lstRooms.SelectedItem);
_Zone.Rooms.Remove(r);
}
}
}

View file

@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>122, 17</value>
</metadata>
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>

View file

@ -10,9 +10,6 @@ using MudDesigner.MudEngine.FileSystem;
using MudDesigner.MudEngine.GameManagement;
using MudDesigner.MudEngine.GameObjects;
using MudDesigner.MudEngine.GameObjects.Environment;
//Script Engine
using ManagedScripting;
using ManagedScripting.CodeBuilding;
namespace MudDesigner
{

View file

@ -66,8 +66,17 @@ namespace MudDesigner
}
public void Print(string message)
{
if (string.IsNullOrEmpty(message))
return;
txtConsole.Text += message + "\n";
txtConsole.Select(txtConsole.Text.Length, 0);
txtConsole.Select(txtConsole.Text.Length - 1, 0);
}
public void Print(bool newLine)
{
txtCommand.Text += "\n";
txtConsole.Select(txtConsole.Text.Length - 1, 0);
}
private void Runtime_Load(object sender, EventArgs e)
@ -79,36 +88,24 @@ namespace MudDesigner
return;
}
_Project = (ProjectInformation)_Project.Load(FileManager.GetDataPath(SaveDataTypes.Root));
if ((_Project.InitialLocation.Zone == null) || (_Project.InitialLocation.Zone == ""))
if (_Project.InitialLocation.Zone == null && _Project.InitialLocation.Zone == "")
{
Print("No Initial Zone was defined within the Project Information. Please associated a Zone to the Projects Initial Zone setting in order to launch the game.");
return;
}
Print("Loading environment...");
string filename = FileManager.GetDataPath(SaveDataTypes.Root);
if (!String.IsNullOrEmpty(_Project.InitialLocation.Realm) && (_Project.InitialLocation.Realm != "No Realm Associated."))
{
filename = Path.Combine(filename, "Realms");
filename = Path.Combine(filename, _Project.InitialLocation.Realm);
}
filename = Path.Combine(filename, "Zones");
filename = Path.Combine(filename, _Project.InitialLocation.Zone);
filename = Path.Combine(filename, "Rooms");
filename = Path.Combine(filename, _Project.InitialLocation.Room);
filename += ".room";
_Room = (Room)_Room.Load(filename);
_Room = (Room)_Room.Load(_Project.InitialLocation.Room, _Project.InitialLocation.Zone);
Print("Prepping test player...");
_Player.CurrentRoom = _Room;
_Player.OnTravel(AvailableTravelDirections.North);
Print("Loading Game Commands...");
CommandEngine.LoadAllCommands();
Print("Startup Complete.");
Print(""); //blank line
Print(true); //blank line
txtCommand.Select();
if (string.IsNullOrEmpty(_Project.CompanyName))
@ -136,7 +133,7 @@ namespace MudDesigner
else
Print(_Project.Story);
Print("");//blank line
Print(true);//blank line
ExecuteCommand("Look");
}