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 // Update news once per game launch
static bool fetchedNews; static bool fetchedNews;
bool newsOpen;
// Increment the version number when adding new stats // Increment the version number when adding new stats
const int SystemInformationVersion = 3; const int SystemInformationVersion = 3;
Dictionary<string, Pair<string, string>> GetSystemInformation() Dictionary<string, Pair<string, string>> GetSystemInformation()
@@ -242,6 +244,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (Game.Settings.Debug.CheckVersion) if (Game.Settings.Debug.CheckVersion)
webServices.CheckModVersion(); 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 // System information opt-out prompt
var sysInfoPrompt = widget.Get("SYSTEM_INFO_PROMPT"); var sysInfoPrompt = widget.Get("SYSTEM_INFO_PROMPT");
sysInfoPrompt.IsVisible = () => menuType == MenuType.SystemInfoPrompt; sysInfoPrompt.IsVisible = () => menuType == MenuType.SystemInfoPrompt;
@@ -306,14 +314,20 @@ namespace OpenRA.Mods.Common.Widgets.Logic
new Download(newsURL, cacheFile, e => { }, new Download(newsURL, cacheFile, e => { },
e => NewsDownloadComplete(e, cacheFile, currentNews, 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) void OnRemoteDirectConnect(string host, int port)
{ {
SwitchMenu(MenuType.None); SwitchMenu(MenuType.None);

View File

@@ -281,6 +281,24 @@ Container@MENU_BACKGROUND:
Height: 25 Height: 25
Text: Battlefield News Text: Battlefield News
Font: Bold Font: Bold
Container@UPDATE_NOTICE:
X: (WINDOW_RIGHT - WIDTH) / 2
Y: 75
Width: 128
Children:
Label@A:
Width: PARENT_RIGHT
Height: 25
Align: Center
Shadow: true
Text: You are running an outdated version of OpenRA.
Label@B:
Y: 20
Width: PARENT_RIGHT
Height: 25
Align: Center
Shadow: true
Text: Download the latest version from www.openra.net
Container@PERFORMANCE_INFO: Container@PERFORMANCE_INFO:
Logic: PerfDebugLogic Logic: PerfDebugLogic
Children: Children:

View File

@@ -27,7 +27,7 @@ Container@MAINMENU:
Height: 25 Height: 25
Align: Center Align: Center
Font: Regular Font: Regular
Contrast: True Shadow: true
Container@MENUS: Container@MENUS:
X: 13 + (WINDOW_RIGHT - 522) / 4 - WIDTH / 2 X: 13 + (WINDOW_RIGHT - 522) / 4 - WIDTH / 2
Y: WINDOW_BOTTOM / 2 - HEIGHT / 2 Y: WINDOW_BOTTOM / 2 - HEIGHT / 2
@@ -302,3 +302,21 @@ Container@MAINMENU:
Height: 25 Height: 25
Text: Battlefield News Text: Battlefield News
Font: Bold Font: Bold
Container@UPDATE_NOTICE:
X: (WINDOW_RIGHT - WIDTH) / 2
Y: 95
Width: 128
Children:
Label@A:
Width: PARENT_RIGHT
Height: 25
Align: Center
Shadow: true
Text: You are running an outdated version of OpenRA.
Label@B:
Y: 20
Width: PARENT_RIGHT
Height: 25
Align: Center
Shadow: true
Text: Download the latest version from www.openra.net

View File

@@ -266,6 +266,24 @@ Container@MAINMENU:
Height: 25 Height: 25
Text: Battlefield News Text: Battlefield News
Font: Bold Font: Bold
Container@UPDATE_NOTICE:
X: (WINDOW_RIGHT - WIDTH) / 2
Y: 95
Width: 128
Children:
Label@A:
Width: PARENT_RIGHT
Height: 25
Align: Center
Shadow: true
Text: You are running an outdated version of OpenRA.
Label@B:
Y: 20
Width: PARENT_RIGHT
Height: 25
Align: Center
Shadow: true
Text: Download the latest version from www.openra.net
Container@PERFORMANCE_INFO: Container@PERFORMANCE_INFO:
Logic: PerfDebugLogic Logic: PerfDebugLogic
Children: Children: