MUDEngine:

* Realm.cs - Description Property added.
 * Room.cs - Inherits from Zone.cs
 * Zone.cs - Inherits from Realm.cs
 * Zone.cs - Removed Name Property.
 * Deleted old MUDEngine/XmlSerialization.cs as it has been replaced with MUDEngine/FileSystem/XmlSerialization.cs

Project Manager:
 * frmMain.cs - collection of Zones and Rooms are created during selectedIndexChanges from comRealms, lstRooms and lstZones.
 * frmMain.cs - PropertyGrid is now populated within the frmMain_Load instead of within the forms constructor.
 * frmMain.cs - lstZones now populates the lstRooms list box with rooms when its selected index is changed.
This commit is contained in:
Scionwest_cp 2009-11-06 18:10:52 -08:00
parent 97274cb4aa
commit f62fb84e13
6 changed files with 87 additions and 77 deletions

View file

@ -18,5 +18,14 @@ namespace MUDEngine.Environment
get;
set;
}
/// <summary>
/// Description of the Realm.
/// </summary>
public string Description
{
get;
set;
}
}
}

View file

@ -9,7 +9,7 @@ namespace MUDEngine.Environment
/// Rooms are traversable by players during gameplay. They are connected via Door objects, that allow players
/// to move from one room to another.
/// </summary>
public class Room
public class Room : Zone
{
}
}

View file

@ -8,11 +8,7 @@ namespace MUDEngine.Environment
/// <summary>
/// Zones contain an unlimited number of Rooms.
/// </summary>
public class Zone
public class Zone : Realm
{
/// <summary>
/// The name of the Zone.
/// </summary>
public string Name { get; set; }
}
}

View file

@ -1,42 +0,0 @@
#region ====== Using Statements ======
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
#endregion
namespace MUDEngine
{
public class XmlSerialization
{
public static void Save(string Filename, object o)
{
Stream stream = File.Create(Filename);
XmlSerializer serializer = new XmlSerializer(o.GetType());
serializer.Serialize(stream, o);
stream.Close();
}
/// <summary>
/// Loads an item via Xml Deserialization
/// </summary>
/// <param name="Filename">The Xml document to deserialize.</param>
/// <returns></returns>
public static object Load(string Filename, object o)
{
Stream stream = File.OpenRead(Filename);
object obj = new object();
XmlSerializer serializer = new XmlSerializer(o.GetType());
obj = (object)serializer.Deserialize(stream);
stream.Close();
return obj;
}
}
}

View file

@ -32,11 +32,11 @@
this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.lstRooms = new System.Windows.Forms.CheckedListBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.lstZones = new System.Windows.Forms.CheckedListBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.comRealms = new System.Windows.Forms.ComboBox();
this.lstZones = new System.Windows.Forms.CheckedListBox();
this.lstRooms = new System.Windows.Forms.CheckedListBox();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
@ -93,6 +93,16 @@
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Available Rooms";
//
// lstRooms
//
this.lstRooms.Dock = System.Windows.Forms.DockStyle.Fill;
this.lstRooms.FormattingEnabled = true;
this.lstRooms.Location = new System.Drawing.Point(3, 16);
this.lstRooms.Name = "lstRooms";
this.lstRooms.Size = new System.Drawing.Size(143, 154);
this.lstRooms.TabIndex = 1;
this.lstRooms.ThreeDCheckBoxes = true;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.lstZones);
@ -103,6 +113,17 @@
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Available Zones";
//
// lstZones
//
this.lstZones.Dock = System.Windows.Forms.DockStyle.Fill;
this.lstZones.FormattingEnabled = true;
this.lstZones.Location = new System.Drawing.Point(3, 16);
this.lstZones.Name = "lstZones";
this.lstZones.Size = new System.Drawing.Size(143, 109);
this.lstZones.TabIndex = 0;
this.lstZones.ThreeDCheckBoxes = true;
this.lstZones.SelectedIndexChanged += new System.EventHandler(this.lstZones_SelectedIndexChanged);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.comRealms);
@ -125,26 +146,6 @@
this.comRealms.TabIndex = 0;
this.comRealms.SelectedIndexChanged += new System.EventHandler(this.comRealms_SelectedIndexChanged);
//
// lstZones
//
this.lstZones.Dock = System.Windows.Forms.DockStyle.Fill;
this.lstZones.FormattingEnabled = true;
this.lstZones.Location = new System.Drawing.Point(3, 16);
this.lstZones.Name = "lstZones";
this.lstZones.Size = new System.Drawing.Size(143, 109);
this.lstZones.TabIndex = 0;
this.lstZones.ThreeDCheckBoxes = true;
//
// lstRooms
//
this.lstRooms.Dock = System.Windows.Forms.DockStyle.Fill;
this.lstRooms.FormattingEnabled = true;
this.lstRooms.Location = new System.Drawing.Point(3, 16);
this.lstRooms.Name = "lstRooms";
this.lstRooms.Size = new System.Drawing.Size(143, 154);
this.lstRooms.TabIndex = 1;
this.lstRooms.ThreeDCheckBoxes = true;
//
// frmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

View file

@ -11,20 +11,24 @@ namespace Project_Manager
{
public partial class frmMain : Form
{
List<MUDEngine.Environment.Zone> zones;
List<MUDEngine.Environment.Room> rooms;
public frmMain()
{
InitializeComponent();
propertyGrid1.SelectedObject = Program.project;
}
private void frmMain_Load(object sender, EventArgs e)
{
//Get all of the realms currently created.
string[] realms = System.IO.Directory.GetFiles(Application.StartupPath + @"\Data\Realms");
string[] files = System.IO.Directory.GetFiles(Application.StartupPath + @"\Data\Realms");
//Aquire the project settings and show them.
propertyGrid1.SelectedObject = Program.project;
//Add each realm found into the combo box of available realms.
foreach (string realm in realms)
foreach (string realm in files)
{
//Instance a new realm
MUDEngine.Environment.Realm newRealm = new MUDEngine.Environment.Realm();
@ -44,7 +48,7 @@ namespace Project_Manager
{
comRealms.SelectedIndex = 0;
}
}
}//End frmMain_Load
private void comRealms_SelectedIndexChanged(object sender, EventArgs e)
{
@ -54,16 +58,17 @@ namespace Project_Manager
if (comRealms.Items.Count == 0)
return;
string[] zones = System.IO.Directory.GetFiles(Application.StartupPath + @"\Data\Zones");
string[] files = System.IO.Directory.GetFiles(Application.StartupPath + @"\Data\Zones");
//Add each zone found into the list box.
foreach (string zone in zones)
foreach (string zone in files)
{
MUDEngine.Environment.Zone newZone = new MUDEngine.Environment.Zone();
//De-serialize the current zone.
newZone = (MUDEngine.Environment.Zone)MUDEngine.FileSystem.FileSystem.Load(zone, newZone);
//Add it to the available zones list box
lstZones.Items.Add(newZone.Name);
zones.Add(newZone);
}
//Check if we have an existing realm that's set as our startup.
@ -82,6 +87,47 @@ namespace Project_Manager
}
}
}
}//End comRealms
private void lstZones_SelectedIndexChanged(object sender, EventArgs e)
{
string realm = comRealms.SelectedItem.ToString();
string zone = lstZones.SelectedItem.ToString();
lstRooms.Items.Clear();
//Check if we have any realms first.
if (comRealms.Items.Count == 0)
return;
string[] files = System.IO.Directory.GetFiles(Application.StartupPath + @"\Data\Rooms");
//Add each room found into the list box.
foreach (string room in files)
{
MUDEngine.Environment.Room newRoom = new MUDEngine.Environment.Room();
//De-serialize the current Room.
newRoom = (MUDEngine.Environment.Room)MUDEngine.FileSystem.FileSystem.Load(room, newRoom);
//Add it to the available rooms list box
lstRooms.Items.Add(newRoom.Name);
rooms.Add(newRoom);
}
//Now select the initial room if its listed.
string selectedRealm = comRealms.SelectedItem.ToString();
string selectedZone = lstZones.SelectedItem.ToString();
string initialRealm = Program.project.InitialLocation.Realm.Name;
string initialZone = Program.project.InitialLocation.Zone.Name;
//The realm and zone that matches the initial are selected, so lets select the initial room next.
if ((initialRealm == selectedRealm) && (initialZone == selectedZone))
{
foreach (MUDEngine.Environment.Room room in rooms)
{
if (lstRooms.Items.Contains(room.Name))
lstRooms.SelectedIndex = lstRooms.Items.IndexOf(room.Name);
}
}
}
}
}