Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added update notice in the about window. #962

Merged
merged 2 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Blish HUD/GameServices/Overlay/OverlayUpdateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<ContextMenuStripItem> GetContextMenuItems() {
if (this.LatestRelease.Version > Program.OverlayVersion) {
var updateToReleaseMenuItem = new ContextMenuStripItem(string.Format(this.LatestRelease.IsPrerelease
Expand Down
59 changes: 56 additions & 3 deletions Blish HUD/GameServices/Overlay/UI/Views/AboutView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
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
Expand Down Expand Up @@ -111,7 +111,7 @@
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
Expand Down Expand Up @@ -143,6 +143,60 @@

#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,

Check notice on line 169 in Blish HUD/GameServices/Overlay/UI/Views/AboutView.cs

View check run for this annotation

codefactor.io / CodeFactor

Blish HUD/GameServices/Overlay/UI/Views/AboutView.cs#L169

Arithmetic expressions should declare precedence (SA1407)

Check notice on line 169 in Blish HUD/GameServices/Overlay/UI/Views/AboutView.cs

View check run for this annotation

codefactor.io / CodeFactor

Blish HUD/GameServices/Overlay/UI/Views/AboutView.cs#L169

Arithmetic expressions should declare precedence (SA1407)
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),
Expand Down Expand Up @@ -220,6 +274,5 @@
? Strings.GameServices.OverlayService.ConnectionStatus_ArcDPSBridge_Connected
: Strings.GameServices.OverlayService.ConnectionStatus_ArcDPSBridge_Disconnected)));
}

}
}
Loading