Major Changes:
- Widget Development Resumed. - Corrected instances where the Project Information was not being saved. - Corrected instances where deleting a Realm was not happening correctly. Minor Changes: - Realm Widget UI Tweaks - Realm Widget Improvements - Code Optimizations
This commit is contained in:
parent
d5ebbe186f
commit
6c8678a624
5 changed files with 107 additions and 17 deletions
|
@ -11,26 +11,47 @@ using System.IO;
|
|||
using MudDesigner.MudEngine.FileSystem;
|
||||
using MudDesigner.MudEngine.GameObjects;
|
||||
using MudDesigner.MudEngine.GameObjects.Environment;
|
||||
|
||||
namespace MudDesigner.UIWidgets
|
||||
{
|
||||
public partial class RealmExplorer : UserControl
|
||||
public partial class RealmWidget : UserControl, IWidget
|
||||
{
|
||||
public RealmExplorer()
|
||||
public RealmWidget()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Dock = DockStyle.Fill;
|
||||
}
|
||||
|
||||
public Control InstallControl(string projectPath)
|
||||
public Control Initialize()
|
||||
{
|
||||
string[] files = Directory.GetFiles(Path.Combine(projectPath, "Realms"), "*.realm", SearchOption.AllDirectories);
|
||||
string[] files = new string[]{};
|
||||
|
||||
if (Directory.Exists(FileManager.GetDataPath(SaveDataTypes.Realms)))
|
||||
files = Directory.GetFiles(FileManager.GetDataPath(SaveDataTypes.Realms), "*.realm", SearchOption.AllDirectories);
|
||||
|
||||
//TODO: Add if (files.length==0) statement and set a 'No Realms' label in container
|
||||
|
||||
if (files.Length == 0)
|
||||
{
|
||||
Button button = new Button();
|
||||
button.FlatStyle = FlatStyle.Flat;
|
||||
button.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(48, 48, 48);
|
||||
button.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(48, 48, 48);
|
||||
button.Font = new Font(new FontFamily(System.Drawing.Text.GenericFontFamilies.Serif), 12f, FontStyle.Bold);
|
||||
button.BackColor = System.Drawing.Color.FromArgb(48, 48, 48);
|
||||
button.ForeColor = System.Drawing.Color.LightGray;
|
||||
button.Size = new System.Drawing.Size(160, 128);
|
||||
button.Name = "btnNoRealms";
|
||||
button.Text = "No Existing Realms.";
|
||||
button.Dock = DockStyle.Fill;
|
||||
this.Controls.Clear();
|
||||
this.Controls.Add(button);
|
||||
}
|
||||
|
||||
foreach (string realmFile in files)
|
||||
{
|
||||
Realm realm = new Realm();
|
||||
realm = (Realm)FileManager.Load(realmFile, realm);
|
||||
realm = (Realm)realm.Load(realmFile);
|
||||
|
||||
Button button = new Button();
|
||||
button.FlatStyle = FlatStyle.Flat;
|
||||
|
@ -51,5 +72,61 @@ namespace MudDesigner.UIWidgets
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
this.Controls.Clear();
|
||||
|
||||
FlowLayoutPanel flowContainer = new FlowLayoutPanel();
|
||||
flowContainer.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
flowContainer.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
flowContainer.Location = new System.Drawing.Point(0, 0);
|
||||
flowContainer.Name = "flowContainer";
|
||||
flowContainer.Padding = new System.Windows.Forms.Padding(10);
|
||||
flowContainer.Size = new System.Drawing.Size(537, 502);
|
||||
flowContainer.TabIndex = 0;
|
||||
|
||||
string[] files = new string[] { };
|
||||
|
||||
if (Directory.Exists(FileManager.GetDataPath(SaveDataTypes.Realms)))
|
||||
files = Directory.GetFiles(FileManager.GetDataPath(SaveDataTypes.Realms), "*.realm", SearchOption.AllDirectories);
|
||||
|
||||
//TODO: Add if (files.length==0) statement and set a 'No Realms' label in container
|
||||
|
||||
if (files.Length == 0)
|
||||
{
|
||||
Button button = new Button();
|
||||
button.FlatStyle = FlatStyle.Flat;
|
||||
button.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(48, 48, 48);
|
||||
button.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(48, 48, 48);
|
||||
button.Font = new Font(new FontFamily(System.Drawing.Text.GenericFontFamilies.Serif), 12f, FontStyle.Bold);
|
||||
button.BackColor = System.Drawing.Color.FromArgb(48, 48, 48);
|
||||
button.ForeColor = System.Drawing.Color.LightGray;
|
||||
button.Size = new System.Drawing.Size(160, 128);
|
||||
button.Name = "btnNoRealms";
|
||||
button.Text = "No Existing Realms.";
|
||||
button.Dock = DockStyle.Fill;
|
||||
this.Controls.Clear();
|
||||
this.Controls.Add(button);
|
||||
}
|
||||
|
||||
foreach (string realmFile in files)
|
||||
{
|
||||
Realm realm = new Realm();
|
||||
realm = (Realm)realm.Load(realmFile);
|
||||
|
||||
Button button = new Button();
|
||||
button.FlatStyle = FlatStyle.Flat;
|
||||
button.Font = new Font(new FontFamily(System.Drawing.Text.GenericFontFamilies.Serif), 12f, FontStyle.Bold);
|
||||
button.BackColor = System.Drawing.Color.FromArgb(48, 48, 48);
|
||||
button.ForeColor = System.Drawing.Color.LightGray;
|
||||
button.Size = new System.Drawing.Size(160, 128);
|
||||
button.Name = "btn" + realm.Name;
|
||||
button.Text = realm.Name;
|
||||
button.Click += new EventHandler(button_Click);
|
||||
flowContainer.Controls.Add(button);
|
||||
}
|
||||
base.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue