Allow mod to be launched after installing required content.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using OpenRA.FileSystem;
|
||||
using OpenRA.Widgets;
|
||||
@@ -19,11 +20,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class ModContentPromptLogic : ChromeLogic
|
||||
{
|
||||
readonly ModContent content;
|
||||
bool requiredContentInstalled;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ModContentPromptLogic(Widget widget, ModData modData, Manifest mod, ModContent content, Action continueLoading)
|
||||
{
|
||||
var panel = widget.Get("CONTENT_PROMPT_PANEL");
|
||||
this.content = content;
|
||||
CheckRequiredContentInstalled();
|
||||
|
||||
var panel = widget.Get("CONTENT_PROMPT_PANEL");
|
||||
var headerTemplate = panel.Get<LabelWidget>("HEADER_TEMPLATE");
|
||||
var headerLines = !string.IsNullOrEmpty(content.InstallPromptMessage) ? content.InstallPromptMessage.Replace("\\n", "\n").Split('\n') : new string[0];
|
||||
var headerHeight = 0;
|
||||
@@ -48,7 +54,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
{ "mod", mod },
|
||||
{ "content", content },
|
||||
{ "onCancel", () => { } }
|
||||
{ "onCancel", CheckRequiredContentInstalled }
|
||||
});
|
||||
};
|
||||
|
||||
@@ -77,9 +83,24 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
};
|
||||
|
||||
var quitButton = panel.Get<ButtonWidget>("QUIT_BUTTON");
|
||||
quitButton.GetText = () => requiredContentInstalled ? "Continue" : "Quit";
|
||||
quitButton.Bounds.Y += headerHeight;
|
||||
quitButton.OnClick = Game.Exit;
|
||||
quitButton.OnClick = () =>
|
||||
{
|
||||
if (requiredContentInstalled)
|
||||
continueLoading();
|
||||
else
|
||||
Game.Exit();
|
||||
};
|
||||
|
||||
Game.RunAfterTick(Ui.ResetTooltips);
|
||||
}
|
||||
|
||||
void CheckRequiredContentInstalled()
|
||||
{
|
||||
requiredContentInstalled = content.Packages
|
||||
.Where(p => p.Value.Required)
|
||||
.All(p => p.Value.TestFiles.All(f => File.Exists(Platform.ResolvePath(f))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user