diff --git a/OpenRA.Editor/ErrorListDialog.Designer.cs b/OpenRA.Editor/ErrorListDialog.Designer.cs new file mode 100644 index 0000000000..5b9c5c297c --- /dev/null +++ b/OpenRA.Editor/ErrorListDialog.Designer.cs @@ -0,0 +1,89 @@ +namespace OpenRA.Editor +{ + partial class ErrorListDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.listBox1 = new System.Windows.Forms.ListBox(); + this.button1 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label1 + // + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label1.Location = new System.Drawing.Point(10, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(610, 23); + this.label1.TabIndex = 0; + this.label1.Text = "Your map import completed, but with errors:"; + // + // listBox1 + // + this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listBox1.FormattingEnabled = true; + this.listBox1.Location = new System.Drawing.Point(13, 30); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(607, 316); + this.listBox1.TabIndex = 1; + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.button1.Location = new System.Drawing.Point(545, 359); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 2; + this.button1.Text = "Close"; + this.button1.UseVisualStyleBackColor = true; + // + // ErrorListDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(632, 394); + this.Controls.Add(this.button1); + this.Controls.Add(this.listBox1); + this.Controls.Add(this.label1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Name = "ErrorListDialog"; + this.Text = "Map Import Errors"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.Button button1; + } +} \ No newline at end of file diff --git a/OpenRA.Editor/ErrorListDialog.cs b/OpenRA.Editor/ErrorListDialog.cs new file mode 100644 index 0000000000..def8d6f31b --- /dev/null +++ b/OpenRA.Editor/ErrorListDialog.cs @@ -0,0 +1,25 @@ +#region Copyright & License Information +/* + * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using System.Collections.Generic; +using System.Windows.Forms; + +namespace OpenRA.Editor +{ + public partial class ErrorListDialog : Form + { + public ErrorListDialog( IEnumerable errors ) + { + InitializeComponent(); + foreach (var e in errors) + listBox1.Items.Add(e); + } + } +} diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index 67843b2cd9..0d791a61e2 100755 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -368,9 +368,16 @@ namespace OpenRA.Editor * but something's not right internally in it, unless loaded via the real maploader */ var savePath = Path.Combine(Path.GetTempPath(), "OpenRA.Import"); - Directory.CreateDirectory(savePath); + Directory.CreateDirectory(savePath); + + var errors = new List(); + + var map = LegacyMapImporter.Import(ofd.FileName, a => errors.Add(a)); + + if (errors.Count > 0) + using (var eld = new ErrorListDialog(errors)) + eld.ShowDialog(); - var map = LegacyMapImporter.Import(ofd.FileName); map.Players.Add("Neutral", new PlayerReference("Neutral", Rules.Info["world"].Traits.WithInterface().First().Race, true, true)); diff --git a/OpenRA.Editor/LegacyMapImporter.cs b/OpenRA.Editor/LegacyMapImporter.cs index 856b82ca0b..12ee438d07 100644 --- a/OpenRA.Editor/LegacyMapImporter.cs +++ b/OpenRA.Editor/LegacyMapImporter.cs @@ -100,16 +100,18 @@ namespace OpenRA.Editor int MapSize; int ActorCount = 0; Map Map = new Map(); - List Players = new List(); + List Players = new List(); + Action errorHandler; - LegacyMapImporter(string filename) - { + LegacyMapImporter(string filename, Action errorHandler) + { + this.errorHandler = errorHandler; ConvertIniMap(filename); } - public static Map Import(string filename) - { - var converter = new LegacyMapImporter(filename); + public static Map Import(string filename, Action errorHandler) + { + var converter = new LegacyMapImporter(filename, errorHandler); return converter.Map; } diff --git a/OpenRA.Editor/OpenRA.Editor.csproj b/OpenRA.Editor/OpenRA.Editor.csproj index 294815d6af..1ba2ea80c5 100644 --- a/OpenRA.Editor/OpenRA.Editor.csproj +++ b/OpenRA.Editor/OpenRA.Editor.csproj @@ -56,6 +56,12 @@ + + Form + + + ErrorListDialog.cs + Form