From 65a83aa41b13b5443345a3eb7eae11ec31326153 Mon Sep 17 00:00:00 2001 From: Dade Lamkins Date: Mon, 22 Apr 2024 23:03:39 -0400 Subject: [PATCH] Added update notice in the about window. --- .../Overlay/OverlayUpdateHandler.cs | 10 +++- .../Overlay/UI/Views/AboutView.cs | 59 ++++++++++++++++++- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/Blish HUD/GameServices/Overlay/OverlayUpdateHandler.cs b/Blish HUD/GameServices/Overlay/OverlayUpdateHandler.cs index 5f444db3f..7d160b03c 100644 --- a/Blish HUD/GameServices/Overlay/OverlayUpdateHandler.cs +++ b/Blish HUD/GameServices/Overlay/OverlayUpdateHandler.cs @@ -93,7 +93,7 @@ private void NotifyOfNewRelease(CoreVersionManifest coreVersionManifest) { } } - private void ShowReleaseSplash(CoreVersionManifest coreVersionManifest, bool subtle) { + internal void ShowReleaseSplash(CoreVersionManifest coreVersionManifest, bool subtle) { if (_activeUpdateWindow?.Parent == null) { // Release old window. _activeUpdateWindow = null; @@ -108,6 +108,14 @@ private void ShowReleaseSplash(CoreVersionManifest coreVersionManifest, bool sub } } + public (bool Available, CoreVersionManifest NewManifest) GetUpdateAvailable() { + if (this.LatestRelease.Version > Program.OverlayVersion) { + return (true, this.LatestRelease); + } + + return (false, default); + } + public IEnumerable GetContextMenuItems() { if (this.LatestRelease.Version > Program.OverlayVersion) { var updateToReleaseMenuItem = new ContextMenuStripItem(string.Format(this.LatestRelease.IsPrerelease diff --git a/Blish HUD/GameServices/Overlay/UI/Views/AboutView.cs b/Blish HUD/GameServices/Overlay/UI/Views/AboutView.cs index 72d5c2da1..ed8bbe66b 100644 --- a/Blish HUD/GameServices/Overlay/UI/Views/AboutView.cs +++ b/Blish HUD/GameServices/Overlay/UI/Views/AboutView.cs @@ -65,7 +65,7 @@ protected override void Build(Container buildPanel) { var discordSection = new Image(GameService.Content.GetTexture("views/about/section-splitter")) { Parent = aboutPanel, Width = aboutPanel.Width - 64, - Left = 32 - 24, + Left = 8, Height = 16, Top = lovePanel.Bottom, Opacity = 0.5f @@ -111,7 +111,7 @@ protected override void Build(Container buildPanel) { var bottomDiscordSection = new Image(GameService.Content.GetTexture("views/about/section-splitter")) { Parent = aboutPanel, Width = aboutPanel.Width - 64, - Left = 32, + Left = 8, Height = 16, Top = discordNote.Bottom + 8, Opacity = 0.5f @@ -143,6 +143,60 @@ protected override void Build(Container buildPanel) { #endregion + #region "Available Updates" + + var update = GameService.Overlay.OverlayUpdateHandler.GetUpdateAvailable(); + + if (update.Available) { + _ = new Label() { + Parent = aboutPanel, + Top = bottomDiscordSection.Bottom, + Text = $"An update to Blish HUD v{update.NewManifest.Version} is available!", + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Middle, + Left = 0, + TextColor = Color.Orange, + Width = aboutPanel.Width, + Height = 50 + }; + + var updateButton = new StandardButton() { + Text = $"Update Blish HUD", + Width = 164, + Parent = aboutPanel + }; + updateButton.Location = new Point( + aboutPanel.Width / 2 - updateButton.Width / 2, + bottomDiscordSection.Bottom + 45 + ); + + updateButton.Click += (s, e) => { + GameService.Overlay.OverlayUpdateHandler.ShowReleaseSplash(update.NewManifest, false); + }; + } else { + _ = new Label() { + Parent = aboutPanel, + Top = bottomDiscordSection.Bottom, + Text = "You are running the latest version of Blish HUD.", + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Middle, + Left = 0, + Width = aboutPanel.Width, + Height = 90 + }; + } + + _ = new Image(GameService.Content.GetTexture("views/about/section-splitter")) { + Parent = aboutPanel, + Width = aboutPanel.Width - 64, + Left = 8, + Height = 16, + Top = fadeBottom + 90, + Opacity = 0.25f + }; + + #endregion + var gw2CopyrightStatement = new Label() { Font = GameService.Content.DefaultFont16, Text = string.Format(Strings.GameServices.OverlayService.AboutAnetNotice, DateTime.Now.Year), @@ -220,6 +274,5 @@ protected override void Build(Container buildPanel) { ? Strings.GameServices.OverlayService.ConnectionStatus_ArcDPSBridge_Connected : Strings.GameServices.OverlayService.ConnectionStatus_ArcDPSBridge_Disconnected))); } - } }