- Toolkit now saves and loads settings file

- Toolkit supports a default toolkit realm. Zone Builder now loads the default Realm each time it is opened. Allows developers to work on one Realm without having to re-select the Realm each time the Zone Builder is opened.
 - Toolkit settings properties are no longer static within Settings.cs.
 - Program.cs now contains a staticu property for Toolkit settings.
This commit is contained in:
Scionwest_cp 2009-12-08 17:27:55 -08:00
parent d96a175372
commit 37b2d42b4c
7 changed files with 267 additions and 58 deletions

View file

@ -1,3 +1,6 @@
<?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:ignore</Name><Value>bin
obj
</Value></Property><Property><Name>svn:ignore</Name><Value>bin
obj
Mud Designer.csproj.user
</Value></Property></Properties></ItemProperties>

View file

@ -34,27 +34,27 @@
this.button4 = new System.Windows.Forms.Button();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabRealm = new System.Windows.Forms.TabPage();
this.tabScript = new System.Windows.Forms.TabPage();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.lstRealms = new System.Windows.Forms.ListBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.btnLoadRealm = new System.Windows.Forms.Button();
this.btnSaveRealm = new System.Windows.Forms.Button();
this.btnDeleteRealm = new System.Windows.Forms.Button();
this.btnNewRealm = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.lstRealms = new System.Windows.Forms.ListBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.propertyRealm = new System.Windows.Forms.PropertyGrid();
this.tabScript = new System.Windows.Forms.TabPage();
this.txtScript = new System.Windows.Forms.RichTextBox();
this.tabControl1.SuspendLayout();
this.tabRealm.SuspendLayout();
this.tabScript.SuspendLayout();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.tabScript.SuspendLayout();
this.SuspendLayout();
//
// button1
@ -115,17 +115,6 @@
this.tabRealm.Text = "Realm Setup";
this.tabRealm.UseVisualStyleBackColor = true;
//
// tabScript
//
this.tabScript.Controls.Add(this.txtScript);
this.tabScript.Location = new System.Drawing.Point(4, 22);
this.tabScript.Name = "tabScript";
this.tabScript.Padding = new System.Windows.Forms.Padding(3);
this.tabScript.Size = new System.Drawing.Size(462, 438);
this.tabScript.TabIndex = 1;
this.tabScript.Text = "Realm Script";
this.tabScript.UseVisualStyleBackColor = true;
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
@ -144,16 +133,26 @@
this.splitContainer1.SplitterDistance = 196;
this.splitContainer1.TabIndex = 0;
//
// groupBox3
// groupBox1
//
this.groupBox3.Controls.Add(this.propertyRealm);
this.groupBox3.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox3.Location = new System.Drawing.Point(0, 0);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(256, 432);
this.groupBox3.TabIndex = 34;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Realm Properties";
this.groupBox1.Controls.Add(this.lstRealms);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox1.Location = new System.Drawing.Point(0, 76);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(196, 356);
this.groupBox1.TabIndex = 36;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Realms List";
//
// lstRealms
//
this.lstRealms.Dock = System.Windows.Forms.DockStyle.Fill;
this.lstRealms.FormattingEnabled = true;
this.lstRealms.Location = new System.Drawing.Point(3, 16);
this.lstRealms.Name = "lstRealms";
this.lstRealms.Size = new System.Drawing.Size(190, 329);
this.lstRealms.Sorted = true;
this.lstRealms.TabIndex = 17;
//
// groupBox2
//
@ -209,26 +208,16 @@
this.btnNewRealm.UseVisualStyleBackColor = true;
this.btnNewRealm.Click += new System.EventHandler(this.btnNewRealm_Click);
//
// groupBox1
// groupBox3
//
this.groupBox1.Controls.Add(this.lstRealms);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox1.Location = new System.Drawing.Point(0, 76);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(196, 356);
this.groupBox1.TabIndex = 36;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Realms List";
//
// lstRealms
//
this.lstRealms.Dock = System.Windows.Forms.DockStyle.Fill;
this.lstRealms.FormattingEnabled = true;
this.lstRealms.Location = new System.Drawing.Point(3, 16);
this.lstRealms.Name = "lstRealms";
this.lstRealms.Size = new System.Drawing.Size(190, 329);
this.lstRealms.Sorted = true;
this.lstRealms.TabIndex = 17;
this.groupBox3.Controls.Add(this.propertyRealm);
this.groupBox3.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox3.Location = new System.Drawing.Point(0, 0);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(256, 432);
this.groupBox3.TabIndex = 34;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Realm Properties";
//
// propertyRealm
//
@ -239,6 +228,17 @@
this.propertyRealm.TabIndex = 18;
this.propertyRealm.ToolbarVisible = false;
//
// tabScript
//
this.tabScript.Controls.Add(this.txtScript);
this.tabScript.Location = new System.Drawing.Point(4, 22);
this.tabScript.Name = "tabScript";
this.tabScript.Padding = new System.Windows.Forms.Padding(3);
this.tabScript.Size = new System.Drawing.Size(462, 438);
this.tabScript.TabIndex = 1;
this.tabScript.Text = "Realm Script";
this.tabScript.UseVisualStyleBackColor = true;
//
// txtScript
//
this.txtScript.Dock = System.Windows.Forms.DockStyle.Fill;
@ -263,13 +263,13 @@
this.Text = "Realm Explorer";
this.tabControl1.ResumeLayout(false);
this.tabRealm.ResumeLayout(false);
this.tabScript.ResumeLayout(false);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.tabScript.ResumeLayout(false);
this.ResumeLayout(false);
}

View file

@ -1,4 +1,5 @@
using System;
using System.IO;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -6,22 +7,28 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MudDesigner.MudEngine.GameObjects.Environment;
using MudDesigner.MudEngine.FileSystem;
namespace MudDesigner.Editors
{
public partial class ToolkitLauncher : Form
{
public const int VersionMajor = 1;
public const int VersionMinor = 0;
public const int VersionRevision = 0;
public string version = VersionMajor.ToString() + "." + VersionMinor.ToString() + "." + VersionRevision.ToString();
bool IsStartup = true;
public ToolkitLauncher()
{
InitializeComponent();
this.Text = "Mud Designer Toolkit " + Settings.GetVersion();
this.Text = "Mud Designer Toolkit " + Program.Settings.GetVersion();
Settings settings = new Settings();
if (Program.Settings.DefaultRealm != null)
{
lblCurrentRealm.Text = "Current Realm: " + Program.Settings.DefaultRealm.Name;
chkDefaultRealm.Checked = true;
}
//done starting up. This prevents checkbox change events from firing during startup
IsStartup = false;
}
private void btnProjectSettings_Click(object sender, EventArgs e)
@ -83,5 +90,70 @@ namespace MudDesigner.Editors
this.Show();
}
private void chkDefaultRealm_CheckedChanged(object sender, EventArgs e)
{
if (IsStartup)
return;
if (!chkDefaultRealm.Checked)
{
Program.Settings.DefaultRealm = null;
lblCurrentRealm.Text = "Current Realm: None";
SaveSettings();
}
else
{
Realm realm = GetRealm();
if (realm != null)
{
Program.Settings.DefaultRealm = realm;
SaveSettings();
}
}
}
private void btnChangeRealm_Click(object sender, EventArgs e)
{
Realm realm = GetRealm();
if (realm != null)
{
Program.Settings.DefaultRealm = realm;
SaveSettings();
}
}
public Realm GetRealm()
{
ExistingRealms form = new ExistingRealms();
form.Show();
this.Hide();
while (form.Created)
Application.DoEvents();
this.Show();
Realm realm = new Realm();
string[] files = Directory.GetFiles(FileManager.GetDataPath(SaveDataTypes.Realms), "*.realm", SearchOption.AllDirectories);
foreach (string file in files)
{
realm = (Realm)FileManager.Load(file, realm);
if (realm.Name == form.lstRealms.SelectedItem.ToString())
{
Program.Settings.DefaultRealm = realm;
lblCurrentRealm.Text = "Current Realm: " + realm.Name;
return realm;
}
}
return null;
}
public void SaveSettings()
{
string savePath = Path.Combine(Application.StartupPath, "Toolkit.xml");
FileManager.Save(savePath, Program.Settings);
}
}
}

View file

@ -38,6 +38,12 @@
this.btnCurrencyEditor = new System.Windows.Forms.Button();
this.btnRealmExplorer = new System.Windows.Forms.Button();
this.btnZoneBuilder = new System.Windows.Forms.Button();
this.tabToolkitSettings = new System.Windows.Forms.TabPage();
this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnChangeRealm = new System.Windows.Forms.Button();
this.lblCurrentRealm = new System.Windows.Forms.Label();
this.chkDefaultRealm = new System.Windows.Forms.CheckBox();
this.tabFunctions = new System.Windows.Forms.TabPage();
this.groupBox9 = new System.Windows.Forms.GroupBox();
this.groupBox14 = new System.Windows.Forms.GroupBox();
@ -57,6 +63,9 @@
this.tabEditors.SuspendLayout();
this.tabPage1.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
this.tabToolkitSettings.SuspendLayout();
this.flowLayoutPanel2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.tabFunctions.SuspendLayout();
this.groupBox9.SuspendLayout();
this.groupBox12.SuspendLayout();
@ -105,6 +114,7 @@
// tabEditors
//
this.tabEditors.Controls.Add(this.tabPage1);
this.tabEditors.Controls.Add(this.tabToolkitSettings);
this.tabEditors.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabEditors.Location = new System.Drawing.Point(0, 0);
this.tabEditors.Name = "tabEditors";
@ -192,6 +202,69 @@
this.btnZoneBuilder.UseVisualStyleBackColor = true;
this.btnZoneBuilder.Click += new System.EventHandler(this.btnZoneBuilder_Click);
//
// tabToolkitSettings
//
this.tabToolkitSettings.Controls.Add(this.flowLayoutPanel2);
this.tabToolkitSettings.Location = new System.Drawing.Point(4, 22);
this.tabToolkitSettings.Name = "tabToolkitSettings";
this.tabToolkitSettings.Padding = new System.Windows.Forms.Padding(3);
this.tabToolkitSettings.Size = new System.Drawing.Size(619, 199);
this.tabToolkitSettings.TabIndex = 1;
this.tabToolkitSettings.Text = "Toolkit Settings";
this.tabToolkitSettings.UseVisualStyleBackColor = true;
//
// flowLayoutPanel2
//
this.flowLayoutPanel2.Controls.Add(this.groupBox1);
this.flowLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel2.Location = new System.Drawing.Point(3, 3);
this.flowLayoutPanel2.Name = "flowLayoutPanel2";
this.flowLayoutPanel2.Size = new System.Drawing.Size(613, 193);
this.flowLayoutPanel2.TabIndex = 0;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.btnChangeRealm);
this.groupBox1.Controls.Add(this.lblCurrentRealm);
this.groupBox1.Controls.Add(this.chkDefaultRealm);
this.groupBox1.Location = new System.Drawing.Point(3, 3);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(215, 61);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Toolkit Default Realm Settings";
//
// btnChangeRealm
//
this.btnChangeRealm.Location = new System.Drawing.Point(154, 13);
this.btnChangeRealm.Name = "btnChangeRealm";
this.btnChangeRealm.Size = new System.Drawing.Size(55, 23);
this.btnChangeRealm.TabIndex = 5;
this.btnChangeRealm.Text = "Change";
this.btnChangeRealm.UseVisualStyleBackColor = true;
this.btnChangeRealm.Click += new System.EventHandler(this.btnChangeRealm_Click);
//
// lblCurrentRealm
//
this.lblCurrentRealm.AutoSize = true;
this.lblCurrentRealm.Location = new System.Drawing.Point(3, 39);
this.lblCurrentRealm.Name = "lblCurrentRealm";
this.lblCurrentRealm.Size = new System.Drawing.Size(106, 13);
this.lblCurrentRealm.TabIndex = 4;
this.lblCurrentRealm.Text = "Current Realm: None";
//
// chkDefaultRealm
//
this.chkDefaultRealm.AutoSize = true;
this.chkDefaultRealm.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.chkDefaultRealm.Location = new System.Drawing.Point(6, 19);
this.chkDefaultRealm.Name = "chkDefaultRealm";
this.chkDefaultRealm.Size = new System.Drawing.Size(126, 17);
this.chkDefaultRealm.TabIndex = 3;
this.chkDefaultRealm.Text = "Enable Default Realm";
this.chkDefaultRealm.UseVisualStyleBackColor = true;
this.chkDefaultRealm.CheckedChanged += new System.EventHandler(this.chkDefaultRealm_CheckedChanged);
//
// tabFunctions
//
this.tabFunctions.Controls.Add(this.groupBox9);
@ -352,6 +425,10 @@
this.tabEditors.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.flowLayoutPanel1.ResumeLayout(false);
this.tabToolkitSettings.ResumeLayout(false);
this.flowLayoutPanel2.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.tabFunctions.ResumeLayout(false);
this.groupBox9.ResumeLayout(false);
this.groupBox12.ResumeLayout(false);
@ -387,6 +464,12 @@
private System.Windows.Forms.Button btnRealmExplorer;
private System.Windows.Forms.Button btnZoneBuilder;
private System.Windows.Forms.ToolTip Help;
private System.Windows.Forms.TabPage tabToolkitSettings;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.CheckBox chkDefaultRealm;
private System.Windows.Forms.Label lblCurrentRealm;
private System.Windows.Forms.Button btnChangeRealm;
}
}

View file

@ -31,6 +31,40 @@ namespace MudDesigner.Editors
InitializeComponent();
//Reinstance all of our environments
Program.Realm = new Realm();
//If we have a default Realm selected, lets load it
if (Program.Settings.DefaultRealm != null)
{
//Load it
string realmPath = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Realms), Program.Settings.DefaultRealm.Name);
string realmFile = Path.Combine(realmPath, Program.Settings.DefaultRealm.Filename);
Program.Realm = (Realm)FileManager.Load(realmFile, Program.Realm);
this.Text = "Zone Builder: (" + Program.Realm.Name + ")";
IsRealmLoaded = true;
//realm is loaded, now clear out the list of zones & rooms and show the zones contained
//within the new realm
lstZones.Items.Clear();
lstRooms.Items.Clear();
_Zones.Clear();
string[] files = Directory.GetFiles(realmPath, "*.zone", SearchOption.AllDirectories);
foreach (string file in files)
{
string filename = Path.GetFileName(file);
if (Program.Realm.Zones.Contains(filename))
{
Zone zone = new Zone();
zone = (Zone)FileManager.Load(file, zone);
zone.RefreshRoomList();
_Zones.Add(zone);
lstZones.Items.Add(zone.Name);
}
else
continue;
}
}
}
private void btnNewZone_Click(object sender, EventArgs e)

View file

@ -23,6 +23,7 @@ namespace MudDesigner
public static Room Room { get; set; }
public static ScriptingEngine ScriptEngine { get; set; }
public static Form CurrentEditor { get; set; }
public static Settings Settings { get; set; }
/// <summary>
/// The main entry point for the application.
@ -30,17 +31,30 @@ namespace MudDesigner
[STAThread]
static void Main()
{
//Creates a new instance of the project and settings
Project = new ProjectInformation();
Settings = new Settings();
//Make sure our directory structure is created
FileManager.ValidateDataPaths();
//Setup what fileformat we are going to use.
FileManager.FileType = FileManager.OutputFormats.XML;
//Load the MUD project if the file exists
string filename = System.IO.Path.Combine(FileManager.GetDataPath(SaveDataTypes.Root), "Project.Xml");
if (System.IO.File.Exists(filename))
Project = (ProjectInformation)FileManager.Load(filename, Project);
//Load the toolkit settings if it exists.
filename = System.IO.Path.Combine(Application.StartupPath, "Toolkit.xml");
if (System.IO.File.Exists(filename))
Settings = (Settings)FileManager.Load(filename, Settings);
//Setup default application properties
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//Run the toolkit
Application.Run(new MudDesigner.Editors.ToolkitLauncher());
}
}

View file

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MudDesigner.MudEngine.GameObjects.Environment;
namespace MudDesigner
{
@ -25,9 +26,11 @@ namespace MudDesigner
}
#warning Reminder: Change Settings.VersionStage to KitStages.Preview upon release.
public static KitStages VersionStage = KitStages.Development_Source_Only;
public KitStages VersionStage = KitStages.Development_Source_Only;
public static string GetVersion()
public Realm DefaultRealm;
public string GetVersion()
{
string stage = VersionStage.ToString().Replace("_", " ");
Version version = new Version(Application.ProductVersion);