automatically switch mods when possible
This commit is contained in:
@@ -77,12 +77,19 @@ namespace OpenRA.Mods.Common.LoadScreens
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load a replay directly
|
// Load a replay directly
|
||||||
var replay = args != null ? args.GetValue("Launch.Replay", null) : null;
|
var replayFilename = args != null ? args.GetValue("Launch.Replay", null) : null;
|
||||||
if (!string.IsNullOrEmpty(replay))
|
if (!string.IsNullOrEmpty(replayFilename))
|
||||||
{
|
{
|
||||||
var replayMeta = ReplayMetadata.Read(replay);
|
var replayMeta = ReplayMetadata.Read(replayFilename);
|
||||||
if (ReplayUtils.CheckReplayCompatibility(replayMeta, Game.LoadShellMap))
|
if (ReplayUtils.PromptConfirmReplayCompatibility(replayMeta, Game.LoadShellMap))
|
||||||
Game.JoinReplay(replay);
|
Game.JoinReplay(replayFilename);
|
||||||
|
|
||||||
|
if (replayMeta != null)
|
||||||
|
{
|
||||||
|
var mod = replayMeta.GameInfo.Mod;
|
||||||
|
if (mod != null && mod != Game.ModData.Manifest.Mod.Id && ModMetadata.AllMods.ContainsKey(mod))
|
||||||
|
Game.InitializeMod(mod, args);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -635,7 +635,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
onStart();
|
onStart();
|
||||||
};
|
};
|
||||||
|
|
||||||
if (selectedReplay != null && ReplayUtils.CheckReplayCompatibility(selectedReplay))
|
if (selectedReplay != null && ReplayUtils.PromptConfirmReplayCompatibility(selectedReplay))
|
||||||
startReplay();
|
startReplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,34 +17,37 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{
|
{
|
||||||
static readonly Action DoNothing = () => { };
|
static readonly Action DoNothing = () => { };
|
||||||
|
|
||||||
public static bool CheckReplayCompatibility(ReplayMetadata replayMeta, Action onCancel = null)
|
public static bool PromptConfirmReplayCompatibility(ReplayMetadata replayMeta, Action onCancel = null)
|
||||||
{
|
{
|
||||||
if (onCancel == null)
|
if (onCancel == null)
|
||||||
onCancel = DoNothing;
|
onCancel = DoNothing;
|
||||||
|
|
||||||
var mod = replayMeta.GameInfo.Mod;
|
if (replayMeta == null)
|
||||||
if (mod == null)
|
return IncompatibleReplayDialog("outdated engine", null, onCancel);
|
||||||
return IncompatibleReplayDialog("an unknown mod", mod, onCancel);
|
|
||||||
|
|
||||||
var version = replayMeta.GameInfo.Version;
|
var version = replayMeta.GameInfo.Version;
|
||||||
if (version == null)
|
if (version == null)
|
||||||
return IncompatibleReplayDialog("an unknown version", version, onCancel);
|
return IncompatibleReplayDialog("unknown version", version, onCancel);
|
||||||
|
|
||||||
|
var mod = replayMeta.GameInfo.Mod;
|
||||||
|
if (mod == null)
|
||||||
|
return IncompatibleReplayDialog("unknown mod", mod, onCancel);
|
||||||
|
|
||||||
var allMods = ModMetadata.AllMods;
|
var allMods = ModMetadata.AllMods;
|
||||||
if (!allMods.ContainsKey(mod))
|
if (!allMods.ContainsKey(mod))
|
||||||
return IncompatibleReplayDialog("an unavailable mod", mod, onCancel);
|
return IncompatibleReplayDialog("unavailable mod", mod, onCancel);
|
||||||
else if (allMods[mod].Version != version)
|
else if (allMods[mod].Version != version)
|
||||||
return IncompatibleReplayDialog("an incompatible version", version, onCancel);
|
return IncompatibleReplayDialog("incompatible version", version, onCancel);
|
||||||
|
|
||||||
if (replayMeta.GameInfo.MapPreview.Status != MapStatus.Available)
|
if (replayMeta.GameInfo.MapPreview.Status != MapStatus.Available)
|
||||||
return IncompatibleReplayDialog("an unavailable map", replayMeta.GameInfo.MapUid, onCancel);
|
return IncompatibleReplayDialog("unavailable map", replayMeta.GameInfo.MapUid, onCancel);
|
||||||
else
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IncompatibleReplayDialog(string type, string name, Action onCancel)
|
static bool IncompatibleReplayDialog(string type, string name, Action onCancel)
|
||||||
{
|
{
|
||||||
var error = "It was recorded with " + type;
|
var error = "It was recorded with an " + type;
|
||||||
error += string.IsNullOrEmpty(name) ? "." : ":\n{0}".F(name);
|
error += string.IsNullOrEmpty(name) ? "." : ":\n{0}".F(name);
|
||||||
|
|
||||||
ConfirmationDialogs.CancelPrompt("Incompatible Replay", error, onCancel);
|
ConfirmationDialogs.CancelPrompt("Incompatible Replay", error, onCancel);
|
||||||
|
|||||||
Reference in New Issue
Block a user