void ImportLegacyMapClicked(object sender, EventArgs e) { using (var ofd = new OpenFileDialog { RestoreDirectory = true, Filter = "Legacy maps (*.ini;*.mpr)|*.ini;*.mpr" }) if (DialogResult.OK == ofd.ShowDialog()) { /* massive hack: we should be able to call NewMap() with the imported Map object, * 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); 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(); } map.MakeDefaultPlayers(); map.Save(savePath); LoadMap(savePath); loadedMapName = null; /* editor needs to think this hasnt been saved */ Directory.Delete(savePath, true); MakeDirty(); } }
void ImportLegacyMapClicked(object sender, EventArgs e) { using (var ofd = new OpenFileDialog { RestoreDirectory = true, Filter = "Legacy maps (*.ini;*.mpr)|*.ini;*.mpr" }) if (DialogResult.OK == ofd.ShowDialog()) { /* massive hack: we should be able to call NewMap() with the imported Map object, * 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); 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(); map.MakeDefaultPlayers(); map.Save(savePath); LoadMap(savePath); loadedMapName = null; /* editor needs to think this hasnt been saved */ Directory.Delete(savePath, true); MakeDirty(); } }
void ImportLegacyMapClicked(object sender, EventArgs e) { using (var ofd = new OpenFileDialog { RestoreDirectory = true, Filter = "Legacy maps (*.ini;*.mpr)|*.ini;*.mpr" }) if (DialogResult.OK == ofd.ShowDialog()) { /* massive hack: we should be able to call NewMap() with the imported Map object, * 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); 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(); if (!map.Players.ContainsKey("Neutral")) map.Players.Add("Neutral", new PlayerReference { Name = "Neutral", Race = Rules.Info["world"].Traits.WithInterface<CountryInfo>().First().Race, OwnsWorld = true, NonCombatant = true }); map.Players.Add("Creeps", new PlayerReference { Name = "Creeps", Race = Rules.Info["world"].Traits.WithInterface<CountryInfo>().First().Race, NonCombatant = true }); map.Save(savePath); LoadMap(savePath); loadedMapName = null; /* editor needs to think this hasnt been saved */ Directory.Delete(savePath, true); MakeDirty(); } }