diff --git a/..svnbridge/.svnbridge b/..svnbridge/.svnbridge index 17def6e..cef2a27 100644 --- a/..svnbridge/.svnbridge +++ b/..svnbridge/.svnbridge @@ -3,4 +3,8 @@ MudDesigner.suo svn:ignoreMud Designer ToolKit.jpeg MudDesigner.suo Design Document.gdp +svn:ignoreMud Designer ToolKit.jpeg +MudDesigner.suo +Design Document.gdp +Documentation \ No newline at end of file diff --git a/Mud Designer/Designer.cs b/Mud Designer/Designer.cs index a630b80..026c4be 100644 --- a/Mud Designer/Designer.cs +++ b/Mud Designer/Designer.cs @@ -615,6 +615,11 @@ namespace MudDesigner path = Path.Combine(path, filename); zone = (Zone)zone.Load(path); + if (zone.EntranceRoom == null) + { + MessageBox.Show("You must set the Entrance Room value for this Zones to become the Initial Location", "Mud Designer"); + return; + } location.Realm = "No Realm Associated."; location.Zone = zone.Name; location.Room = zone.EntranceRoom; @@ -635,7 +640,8 @@ namespace MudDesigner while (form.Created) Application.DoEvents(); - this.Show(); + if (this.Created) + this.Show(); } } } diff --git a/Mud Designer/Mud Designer.csproj b/Mud Designer/Mud Designer.csproj index 830d47e..cfce8c9 100644 --- a/Mud Designer/Mud Designer.csproj +++ b/Mud Designer/Mud Designer.csproj @@ -84,6 +84,7 @@ + diff --git a/Mud Designer/MudEngine/GameCommands/CommandExit.cs b/Mud Designer/MudEngine/GameCommands/CommandExit.cs new file mode 100644 index 0000000..72b4fcf --- /dev/null +++ b/Mud Designer/MudEngine/GameCommands/CommandExit.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +using MudDesigner.MudEngine.Interfaces; +using MudDesigner.MudEngine.Characters; +using MudDesigner.MudEngine.GameManagement; +using MudDesigner.MudEngine.GameObjects.Environment; + +namespace MudDesigner.MudEngine.GameCommands +{ + public class CommandExit : IGameCommand + { + public bool Override { get; set; } + public string Name { get; set; } + + public CommandResults Execute(BaseCharacter player, ProjectInformation project, Room room, string command) + { + Application.Exit(); + + return new CommandResults(); + } + } +} diff --git a/Mud Designer/Runtime.Designer.cs b/Mud Designer/Runtime.Designer.cs index 60b6004..76ec2ba 100644 --- a/Mud Designer/Runtime.Designer.cs +++ b/Mud Designer/Runtime.Designer.cs @@ -29,11 +29,26 @@ private void InitializeComponent() { this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.splitContainer2 = new System.Windows.Forms.SplitContainer(); this.txtConsole = new System.Windows.Forms.RichTextBox(); this.txtCommand = new System.Windows.Forms.TextBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.btnLook = new System.Windows.Forms.Button(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.btnWest = new System.Windows.Forms.Button(); + this.btnEast = new System.Windows.Forms.Button(); + this.btnSouth = new System.Windows.Forms.Button(); + this.btnNorth = new System.Windows.Forms.Button(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); + this.splitContainer2.Panel1.SuspendLayout(); + this.splitContainer2.Panel2.SuspendLayout(); + this.splitContainer2.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.flowLayoutPanel1.SuspendLayout(); + this.groupBox1.SuspendLayout(); this.SuspendLayout(); // // splitContainer1 @@ -42,25 +57,44 @@ this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; this.splitContainer1.Location = new System.Drawing.Point(0, 0); this.splitContainer1.Name = "splitContainer1"; - this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; // // splitContainer1.Panel1 // - this.splitContainer1.Panel1.Controls.Add(this.txtConsole); + this.splitContainer1.Panel1.Controls.Add(this.splitContainer2); // // splitContainer1.Panel2 // - this.splitContainer1.Panel2.Controls.Add(this.txtCommand); - this.splitContainer1.Size = new System.Drawing.Size(693, 422); - this.splitContainer1.SplitterDistance = 393; + this.splitContainer1.Panel2.Controls.Add(this.groupBox2); + this.splitContainer1.Panel2.Controls.Add(this.groupBox1); + this.splitContainer1.Size = new System.Drawing.Size(808, 564); + this.splitContainer1.SplitterDistance = 564; this.splitContainer1.TabIndex = 0; // + // splitContainer2 + // + this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; + this.splitContainer2.Location = new System.Drawing.Point(0, 0); + this.splitContainer2.Name = "splitContainer2"; + this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer2.Panel1 + // + this.splitContainer2.Panel1.Controls.Add(this.txtConsole); + // + // splitContainer2.Panel2 + // + this.splitContainer2.Panel2.Controls.Add(this.txtCommand); + this.splitContainer2.Size = new System.Drawing.Size(564, 564); + this.splitContainer2.SplitterDistance = 535; + this.splitContainer2.TabIndex = 1; + // // txtConsole // this.txtConsole.Dock = System.Windows.Forms.DockStyle.Fill; this.txtConsole.Location = new System.Drawing.Point(0, 0); this.txtConsole.Name = "txtConsole"; - this.txtConsole.Size = new System.Drawing.Size(693, 393); + this.txtConsole.Size = new System.Drawing.Size(564, 535); this.txtConsole.TabIndex = 0; this.txtConsole.Text = ""; // @@ -69,23 +103,114 @@ this.txtCommand.Dock = System.Windows.Forms.DockStyle.Fill; this.txtCommand.Location = new System.Drawing.Point(0, 0); this.txtCommand.Name = "txtCommand"; - this.txtCommand.Size = new System.Drawing.Size(693, 20); + this.txtCommand.Size = new System.Drawing.Size(564, 20); this.txtCommand.TabIndex = 1; this.txtCommand.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtCommand_KeyDown); // + // groupBox2 + // + this.groupBox2.Controls.Add(this.flowLayoutPanel1); + this.groupBox2.Dock = System.Windows.Forms.DockStyle.Top; + this.groupBox2.Location = new System.Drawing.Point(0, 144); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(240, 71); + this.groupBox2.TabIndex = 1; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Environment Commands"; + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.Controls.Add(this.btnLook); + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 16); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(234, 52); + this.flowLayoutPanel1.TabIndex = 0; + // + // btnLook + // + this.btnLook.Location = new System.Drawing.Point(3, 3); + this.btnLook.Name = "btnLook"; + this.btnLook.Size = new System.Drawing.Size(75, 45); + this.btnLook.TabIndex = 1; + this.btnLook.Text = "Look"; + this.btnLook.UseVisualStyleBackColor = true; + this.btnLook.Click += new System.EventHandler(this.btnLook_Click); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.btnWest); + this.groupBox1.Controls.Add(this.btnEast); + this.groupBox1.Controls.Add(this.btnSouth); + this.groupBox1.Controls.Add(this.btnNorth); + this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top; + this.groupBox1.Location = new System.Drawing.Point(0, 0); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(240, 144); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Travel Directions"; + // + // btnWest + // + this.btnWest.Location = new System.Drawing.Point(3, 49); + this.btnWest.Name = "btnWest"; + this.btnWest.Size = new System.Drawing.Size(75, 45); + this.btnWest.TabIndex = 3; + this.btnWest.Text = "West"; + this.btnWest.UseVisualStyleBackColor = true; + this.btnWest.Click += new System.EventHandler(this.btnWest_Click); + // + // btnEast + // + this.btnEast.Location = new System.Drawing.Point(159, 49); + this.btnEast.Name = "btnEast"; + this.btnEast.Size = new System.Drawing.Size(75, 45); + this.btnEast.TabIndex = 2; + this.btnEast.Text = "East"; + this.btnEast.UseVisualStyleBackColor = true; + this.btnEast.Click += new System.EventHandler(this.btnEast_Click); + // + // btnSouth + // + this.btnSouth.Location = new System.Drawing.Point(81, 89); + this.btnSouth.Name = "btnSouth"; + this.btnSouth.Size = new System.Drawing.Size(75, 45); + this.btnSouth.TabIndex = 1; + this.btnSouth.Text = "South"; + this.btnSouth.UseVisualStyleBackColor = true; + this.btnSouth.Click += new System.EventHandler(this.btnSouth_Click); + // + // btnNorth + // + this.btnNorth.Location = new System.Drawing.Point(81, 12); + this.btnNorth.Name = "btnNorth"; + this.btnNorth.Size = new System.Drawing.Size(75, 45); + this.btnNorth.TabIndex = 0; + this.btnNorth.Text = "North"; + this.btnNorth.UseVisualStyleBackColor = true; + this.btnNorth.Click += new System.EventHandler(this.btnNorth_Click); + // // Runtime // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(693, 422); + this.ClientSize = new System.Drawing.Size(808, 564); this.Controls.Add(this.splitContainer1); this.Name = "Runtime"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Runtime"; this.Load += new System.EventHandler(this.Runtime_Load); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); - this.splitContainer1.Panel2.PerformLayout(); this.splitContainer1.ResumeLayout(false); + this.splitContainer2.Panel1.ResumeLayout(false); + this.splitContainer2.Panel2.ResumeLayout(false); + this.splitContainer2.Panel2.PerformLayout(); + this.splitContainer2.ResumeLayout(false); + this.groupBox2.ResumeLayout(false); + this.flowLayoutPanel1.ResumeLayout(false); + this.groupBox1.ResumeLayout(false); this.ResumeLayout(false); } @@ -93,7 +218,17 @@ #endregion private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.SplitContainer splitContainer2; private System.Windows.Forms.RichTextBox txtConsole; private System.Windows.Forms.TextBox txtCommand; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Button btnNorth; + private System.Windows.Forms.Button btnWest; + private System.Windows.Forms.Button btnEast; + private System.Windows.Forms.Button btnSouth; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private System.Windows.Forms.Button btnLook; + } } \ No newline at end of file diff --git a/Mud Designer/Runtime.cs b/Mud Designer/Runtime.cs index ecfee7f..92a6235 100644 --- a/Mud Designer/Runtime.cs +++ b/Mud Designer/Runtime.cs @@ -36,6 +36,34 @@ namespace MudDesigner _Room = new Room(); } + public void ExecuteCommand(string command) + { + CommandResults result = CommandEngine.ExecuteCommand(command, _Player, _Project, _Room, command); + + if (result.Result == null) + return; + + foreach (object obj in result.Result) + { + switch (obj.GetType().Name.ToLower()) + { + case "string": + Print(obj.ToString()); + break; + case "room": + _Room = (Room)obj; + break; + case "projectinformation": + _Project = (ProjectInformation)obj; + break; + case "playerbasic": + _Player = (PlayerBasic)obj; + break; + } + } + + txtCommand.Clear(); + } public void Print(string message) { txtConsole.Text += message + "\n"; @@ -45,16 +73,21 @@ namespace MudDesigner private void Runtime_Load(object sender, EventArgs e) { Print("Loading project information..."); + if (!File.Exists(FileManager.GetDataPath(SaveDataTypes.Root) + "\\Game.xml")) + { + Print("Failed Loading Project Information... Runtime failed to initialize."); + return; + } _Project = (ProjectInformation)_Project.Load(FileManager.GetDataPath(SaveDataTypes.Root)); - if (_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."); - Application.Exit(); + return; } Print("Loading environment..."); string filename = FileManager.GetDataPath(SaveDataTypes.Root); - if (_Project.InitialLocation.Realm != "No Realm Associated.") + if (!String.IsNullOrEmpty(_Project.InitialLocation.Realm) && (_Project.InitialLocation.Realm != "No Realm Associated.")) { filename = Path.Combine(filename, "Realms"); filename = Path.Combine(filename, _Project.InitialLocation.Realm); @@ -104,56 +137,40 @@ namespace MudDesigner Print(_Project.Story); Print("");//blank line - CommandResults result = CommandEngine.ExecuteCommand("Look", _Player, _Project, _Room, "Look"); - if (result.Result.Length != 0) - Print(result.Result[0].ToString()); + ExecuteCommand("Look"); } private void txtCommand_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { - string[] words = txtCommand.Text.Split(' '); - string firstWord = ""; - if (words.Length == 0) - return; - firstWord = words[0]; - List arguments = new List(); - foreach (string word in words) - { - if (word == firstWord) - continue; - arguments.Add(word); - } - arguments.Add(_Room); - arguments.Add(_Player); - arguments.Add(_Project); - CommandResults result = CommandEngine.ExecuteCommand(txtCommand.Text, _Player, _Project, _Room, txtCommand.Text); - - if (result.Result == null) - return; - - foreach (object obj in result.Result) - { - switch (obj.GetType().Name.ToLower()) - { - case "string": - Print(obj.ToString()); - break; - case "room": - _Room = (Room)obj; - break; - case "projectinformation": - _Project = (ProjectInformation)obj; - break; - case "playerbasic": - _Player = (PlayerBasic)obj; - break; - } - } - - txtCommand.Clear(); + ExecuteCommand(txtCommand.Text); } } + + private void btnNorth_Click(object sender, EventArgs e) + { + ExecuteCommand("Walk North"); + } + + private void btnSouth_Click(object sender, EventArgs e) + { + ExecuteCommand("Walk South"); + } + + private void btnWest_Click(object sender, EventArgs e) + { + ExecuteCommand("Walk West"); + } + + private void btnEast_Click(object sender, EventArgs e) + { + ExecuteCommand("Walk East"); + } + + private void btnLook_Click(object sender, EventArgs e) + { + ExecuteCommand("Look"); + } } }