Add an Install Mod dialog to the ModChooser

This commit is contained in:
Pavel Penev
2015-09-25 19:41:30 +03:00
parent 9748b556dc
commit 2faf15bad7
4 changed files with 91 additions and 3 deletions

View File

@@ -596,6 +596,7 @@
<Compile Include="Widgets\Logic\Ingame\WorldTooltipLogic.cs" /> <Compile Include="Widgets\Logic\Ingame\WorldTooltipLogic.cs" />
<Compile Include="Widgets\Logic\Installation\InstallFromCDLogic.cs" /> <Compile Include="Widgets\Logic\Installation\InstallFromCDLogic.cs" />
<Compile Include="Widgets\Logic\Installation\DownloadPackagesLogic.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\InstallLogic.cs" />
<Compile Include="Widgets\Logic\Installation\InstallMusicLogic.cs" /> <Compile Include="Widgets\Logic\Installation\InstallMusicLogic.cs" />
<Compile Include="Widgets\Logic\Lobby\ClientTooltipLogic.cs" /> <Compile Include="Widgets\Logic\Lobby\ClientTooltipLogic.cs" />

View File

@@ -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;
}
}
}

View File

@@ -158,13 +158,23 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (selectedIndex - modOffset > 4) if (selectedIndex - modOffset > 4)
modOffset = selectedIndex - 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";
loadButton.Text = modPrerequisitesFulfilled[mod.Id] ? loadButton.Text : "Prerequisites missing!";
} }
void LoadMod(ModMetadata mod) 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]) if (!modInstallStatus[mod])
{ {
var widgetArgs = new WidgetArgs var widgetArgs = new WidgetArgs

View File

@@ -260,3 +260,50 @@ Container@INSTALL_MUSIC_PANEL:
Text: Back Text: Back
Font: Bold Font: Bold
Key: escape 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