Remove save dialog when creating a new map.
This commit is contained in:
committed by
Gustas Kažukauskas
parent
1707dbd92b
commit
9913ecb42f
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenRA.FileSystem;
|
||||
using OpenRA.Mods.Common.Terrain;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
@@ -69,24 +70,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (map.Rules.TerrainInfo is ITerrainInfoNotifyMapCreated notifyMapCreated)
|
||||
notifyMapCreated.MapCreated(map);
|
||||
|
||||
Action<string> afterSave = uid =>
|
||||
{
|
||||
map.Dispose();
|
||||
Game.LoadEditor(uid);
|
||||
|
||||
Ui.CloseWindow();
|
||||
onSelect(uid);
|
||||
};
|
||||
|
||||
Ui.OpenWindow("SAVE_MAP_PANEL", new WidgetArgs()
|
||||
{
|
||||
{ "onSave", afterSave },
|
||||
{ "onExit", () => { Ui.CloseWindow(); onExit(); } },
|
||||
{ "map", map },
|
||||
{ "world", world },
|
||||
{ "playerDefinitions", map.PlayerDefinitions },
|
||||
{ "actorDefinitions", map.ActorDefinitions }
|
||||
});
|
||||
var package = new ZipFileLoader.ReadWriteZipFile();
|
||||
map.Save(package);
|
||||
map = new Map(modData, package);
|
||||
Game.LoadEditor(map);
|
||||
Ui.CloseWindow();
|
||||
onSelect(map.Uid);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
}
|
||||
|
||||
if (map.Package != null)
|
||||
if (!string.IsNullOrEmpty(map.Package?.Name))
|
||||
{
|
||||
selectedDirectory = writableDirectories.FirstOrDefault(k => k.Folder.Contains(map.Package.Name));
|
||||
selectedDirectory ??= writableDirectories.FirstOrDefault(k => Directory.GetDirectories(k.Folder.Name).Any(f => f.Contains(map.Package.Name)));
|
||||
|
||||
@@ -519,8 +519,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
return;
|
||||
|
||||
var actionManager = world.WorldActor.Trait<EditorActionManager>();
|
||||
AddButton("PLAY_MAP", "Play Map")
|
||||
.OnClick = () =>
|
||||
var button = AddButton("PLAY_MAP", "Play Map");
|
||||
button.IsDisabled = () => leaving || string.IsNullOrEmpty(world.Map.Package.Name);
|
||||
button.OnClick = () =>
|
||||
{
|
||||
hideMenu = true;
|
||||
var uid = modData.MapCache.GetUpdatedMap(world.Map.Uid);
|
||||
@@ -618,8 +619,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
void ExitEditor(EditorActionManager actionManager, Action onSuccess)
|
||||
{
|
||||
var map = modData.MapCache.GetUpdatedMap(world.Map.Uid);
|
||||
var deletedOrUnavailable = map == null || modData.MapCache[map].Status != MapStatus.Available;
|
||||
var deletedOrUnavailable = false;
|
||||
if (!string.IsNullOrEmpty(world.Map.Package.Name))
|
||||
{
|
||||
var map = modData.MapCache.GetUpdatedMap(world.Map.Uid);
|
||||
deletedOrUnavailable = map == null || modData.MapCache[map].Status != MapStatus.Available;
|
||||
}
|
||||
|
||||
if (actionManager.HasUnsavedItems() || deletedOrUnavailable)
|
||||
{
|
||||
hideMenu = true;
|
||||
|
||||
Reference in New Issue
Block a user