add ability to throw nonfatal errors in the map importer, and display them.
This commit is contained in:
89
OpenRA.Editor/ErrorListDialog.Designer.cs
generated
Normal file
89
OpenRA.Editor/ErrorListDialog.Designer.cs
generated
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
namespace OpenRA.Editor
|
||||||
|
{
|
||||||
|
partial class ErrorListDialog
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
25
OpenRA.Editor/ErrorListDialog.cs
Normal file
25
OpenRA.Editor/ErrorListDialog.cs
Normal file
@@ -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<string> errors )
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
foreach (var e in errors)
|
||||||
|
listBox1.Items.Add(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -368,9 +368,16 @@ namespace OpenRA.Editor
|
|||||||
* but something's not right internally in it, unless loaded via the real maploader */
|
* but something's not right internally in it, unless loaded via the real maploader */
|
||||||
|
|
||||||
var savePath = Path.Combine(Path.GetTempPath(), "OpenRA.Import");
|
var savePath = Path.Combine(Path.GetTempPath(), "OpenRA.Import");
|
||||||
Directory.CreateDirectory(savePath);
|
Directory.CreateDirectory(savePath);
|
||||||
|
|
||||||
|
var errors = new List<string>();
|
||||||
|
|
||||||
|
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",
|
map.Players.Add("Neutral", new PlayerReference("Neutral",
|
||||||
Rules.Info["world"].Traits.WithInterface<CountryInfo>().First().Race, true, true));
|
Rules.Info["world"].Traits.WithInterface<CountryInfo>().First().Race, true, true));
|
||||||
|
|
||||||
|
|||||||
@@ -100,16 +100,18 @@ namespace OpenRA.Editor
|
|||||||
int MapSize;
|
int MapSize;
|
||||||
int ActorCount = 0;
|
int ActorCount = 0;
|
||||||
Map Map = new Map();
|
Map Map = new Map();
|
||||||
List<string> Players = new List<string>();
|
List<string> Players = new List<string>();
|
||||||
|
Action<string> errorHandler;
|
||||||
|
|
||||||
LegacyMapImporter(string filename)
|
LegacyMapImporter(string filename, Action<string> errorHandler)
|
||||||
{
|
{
|
||||||
|
this.errorHandler = errorHandler;
|
||||||
ConvertIniMap(filename);
|
ConvertIniMap(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map Import(string filename)
|
public static Map Import(string filename, Action<string> errorHandler)
|
||||||
{
|
{
|
||||||
var converter = new LegacyMapImporter(filename);
|
var converter = new LegacyMapImporter(filename, errorHandler);
|
||||||
return converter.Map;
|
return converter.Map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,12 @@
|
|||||||
<Compile Include="ActorTemplate.cs" />
|
<Compile Include="ActorTemplate.cs" />
|
||||||
<Compile Include="ActorTool.cs" />
|
<Compile Include="ActorTool.cs" />
|
||||||
<Compile Include="BrushTool.cs" />
|
<Compile Include="BrushTool.cs" />
|
||||||
|
<Compile Include="ErrorListDialog.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="ErrorListDialog.Designer.cs">
|
||||||
|
<DependentUpon>ErrorListDialog.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Form1.cs">
|
<Compile Include="Form1.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
Reference in New Issue
Block a user