Add an update warning to the main menu.

This commit is contained in:
Paul Chote
2017-12-28 18:23:57 +00:00
committed by abcdefg30
parent 3effa5cec4
commit 5c53172ab0
4 changed files with 71 additions and 3 deletions

View File

@@ -37,6 +37,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
// Update news once per game launch
static bool fetchedNews;
bool newsOpen;
// Increment the version number when adding new stats
const int SystemInformationVersion = 3;
Dictionary<string, Pair<string, string>> GetSystemInformation()
@@ -242,6 +244,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (Game.Settings.Debug.CheckVersion)
webServices.CheckModVersion();
var updateLabel = rootMenu.GetOrNull("UPDATE_NOTICE");
if (updateLabel != null)
updateLabel.IsVisible = () => !newsOpen && menuType != MenuType.None &&
menuType != MenuType.SystemInfoPrompt &&
webServices.ModVersionStatus == ModVersionStatus.Outdated;
// System information opt-out prompt
var sysInfoPrompt = widget.Get("SYSTEM_INFO_PROMPT");
sysInfoPrompt.IsVisible = () => menuType == MenuType.SystemInfoPrompt;
@@ -306,14 +314,20 @@ namespace OpenRA.Mods.Common.Widgets.Logic
new Download(newsURL, cacheFile, e => { },
e => NewsDownloadComplete(e, cacheFile, currentNews,
() => newsButton.AttachPanel(newsPanel)));
() => OpenNewsPanel(newsButton)));
}
newsButton.OnClick = () => newsButton.AttachPanel(newsPanel);
newsButton.OnClick = () => OpenNewsPanel(newsButton);
}
}
}
void OpenNewsPanel(DropDownButtonWidget button)
{
newsOpen = true;
button.AttachPanel(newsPanel, () => newsOpen = false);
}
void OnRemoteDirectConnect(string host, int port)
{
SwitchMenu(MenuType.None);