From 2faf15bad7d6095dd8fb8e5157e26f0b3ce651a4 Mon Sep 17 00:00:00 2001 From: Pavel Penev Date: Fri, 25 Sep 2015 19:41:30 +0300 Subject: [PATCH] Add an Install Mod dialog to the ModChooser --- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 1 + .../Logic/Installation/InstallModLogic.cs | 30 ++++++++++++ .../Widgets/Logic/ModBrowserLogic.cs | 16 +++++-- mods/modchooser/install.yaml | 47 +++++++++++++++++++ 4 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 OpenRA.Mods.Common/Widgets/Logic/Installation/InstallModLogic.cs diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index f73008306c..945a0003d1 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -596,6 +596,7 @@ + diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallModLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallModLogic.cs new file mode 100644 index 0000000000..e89ee00cad --- /dev/null +++ b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallModLogic.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("MOD_LIST").Text = text; + + panel.Get("BACK_BUTTON").OnClick = Ui.CloseWindow; + } + } +} diff --git a/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs index b43558d329..bab41933bc 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs @@ -158,13 +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] ? loadButton.Text : "Prerequisites missing!"; + 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 diff --git a/mods/modchooser/install.yaml b/mods/modchooser/install.yaml index 7f8d32093d..92921272d2 100644 --- a/mods/modchooser/install.yaml +++ b/mods/modchooser/install.yaml @@ -260,3 +260,50 @@ Container@INSTALL_MUSIC_PANEL: Text: Back Font: Bold Key: escape +Container@INSTALL_MOD_PANEL: + Logic: InstallModLogic + X: (WINDOW_RIGHT - WIDTH)/2 + Y: (WINDOW_BOTTOM - HEIGHT)/2 + Width: 500 + Height: 177 + Children: + Background: + Width: PARENT_RIGHT + Height: PARENT_BOTTOM + Background: panel-bg + Background@RULE: + X: 30 + Y: 50 + Width: 440 + Height: 150 + Background: panel-rule + Label@TITLE: + X: 0 + Y: 12 + Width: PARENT_RIGHT + Height: 25 + Text: Missing dependencies + Align: Center + Font: MediumBold + Label@DESC: + X: 0 + Y: 65 + Width: PARENT_RIGHT + Height: 25 + Align: Center + Text: Please fully install the following mods then try again: + Label@MOD_LIST: + X: 0 + Y: 85 + Width: PARENT_RIGHT + Height: 25 + Align: Center + Button@BACK_BUTTON: + X: PARENT_RIGHT - 130 + Y: PARENT_BOTTOM - 52 + Background: button-highlighted + Width: 110 + Height: 32 + Text: Back + Font: Bold + Key: escape