Merge pull request #9463 from penev92/modDependencies
Add support for inter-mod dependencies
This commit is contained in:
@@ -596,6 +596,7 @@
|
||||
<Compile Include="Widgets\Logic\Ingame\WorldTooltipLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Installation\InstallFromCDLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Installation\DownloadPackagesLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Installation\InstallModLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Installation\InstallLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Installation\InstallMusicLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Lobby\ClientTooltipLogic.cs" />
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 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.Linq;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class InstallModLogic : ChromeLogic
|
||||
{
|
||||
[ObjectCreator.UseCtor]
|
||||
public InstallModLogic(Widget widget, string modId)
|
||||
{
|
||||
var panel = widget.Get("INSTALL_MOD_PANEL");
|
||||
|
||||
var mods = Manifest.AllMods[modId].RequiresMods.Select(x => "{0} ({1})".F(x.Key, x.Value));
|
||||
var text = string.Join(", ", mods);
|
||||
panel.Get<LabelWidget>("MOD_LIST").Text = text;
|
||||
|
||||
panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = Ui.CloseWindow;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
readonly Dictionary<string, Sprite> previews = new Dictionary<string, Sprite>();
|
||||
readonly Dictionary<string, Sprite> logos = new Dictionary<string, Sprite>();
|
||||
readonly Cache<ModMetadata, bool> modInstallStatus;
|
||||
readonly Cache<string, bool> modPrerequisitesFulfilled;
|
||||
readonly Widget modChooserPanel;
|
||||
readonly ButtonWidget loadButton;
|
||||
readonly SheetBuilder sheetBuilder;
|
||||
@@ -38,6 +39,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
[ObjectCreator.UseCtor]
|
||||
public ModBrowserLogic(Widget widget)
|
||||
{
|
||||
modInstallStatus = new Cache<ModMetadata, bool>(IsModInstalled);
|
||||
modPrerequisitesFulfilled = new Cache<string, bool>(Game.IsModInstalled);
|
||||
|
||||
modChooserPanel = widget;
|
||||
loadButton = modChooserPanel.Get<ButtonWidget>("LOAD_BUTTON");
|
||||
loadButton.OnClick = () => LoadMod(selectedMod);
|
||||
@@ -93,8 +97,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
modInstallStatus = new Cache<ModMetadata, bool>(IsModInstalled);
|
||||
|
||||
ModMetadata initialMod;
|
||||
ModMetadata.AllMods.TryGetValue(Game.Settings.Game.PreviousMod, out initialMod);
|
||||
SelectMod(initialMod != null && initialMod.Id != "modchooser" ? initialMod : ModMetadata.AllMods["ra"]);
|
||||
@@ -156,11 +158,23 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (selectedIndex - modOffset > 4)
|
||||
modOffset = selectedIndex - 4;
|
||||
|
||||
loadButton.Text = modInstallStatus[mod] ? "Load Mod" : "Install Assets";
|
||||
loadButton.Text = !modPrerequisitesFulfilled[mod.Id] ? "Install mod" :
|
||||
modInstallStatus[mod] ? "Load Mod" : "Install Assets";
|
||||
}
|
||||
|
||||
void LoadMod(ModMetadata mod)
|
||||
{
|
||||
if (!modPrerequisitesFulfilled[mod.Id])
|
||||
{
|
||||
var widgetArgs = new WidgetArgs
|
||||
{
|
||||
{ "modId", mod.Id }
|
||||
};
|
||||
|
||||
Ui.OpenWindow("INSTALL_MOD_PANEL", widgetArgs);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!modInstallStatus[mod])
|
||||
{
|
||||
var widgetArgs = new WidgetArgs
|
||||
|
||||
Reference in New Issue
Block a user