-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move post-update notification logic to UpdateManager base class
- Loading branch information
Showing
5 changed files
with
78 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Framework.Allocation; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Graphics.Sprites; | ||
using osu.Game.Configuration; | ||
using osu.Game.Graphics; | ||
using osu.Game.Overlays; | ||
using osu.Game.Overlays.Notifications; | ||
|
||
namespace osu.Game.Updater | ||
{ | ||
public abstract class UpdateManager : CompositeDrawable | ||
{ | ||
[Resolved] | ||
private OsuConfigManager config { get; set; } | ||
|
||
[Resolved] | ||
private OsuGameBase game { get; set; } | ||
|
||
[Resolved] | ||
protected NotificationOverlay Notifications { get; private set; } | ||
|
||
protected override void LoadComplete() | ||
{ | ||
base.LoadComplete(); | ||
|
||
var version = game.Version; | ||
var lastVersion = config.Get<string>(OsuSetting.Version); | ||
|
||
if (game.IsDeployedBuild && version != lastVersion) | ||
{ | ||
config.Set(OsuSetting.Version, version); | ||
|
||
// only show a notification if we've previously saved a version to the config file (ie. not the first run). | ||
if (!string.IsNullOrEmpty(lastVersion)) | ||
Notifications.Post(new UpdateCompleteNotification(version)); | ||
} | ||
} | ||
|
||
private class UpdateCompleteNotification : SimpleNotification | ||
{ | ||
private readonly string version; | ||
|
||
public UpdateCompleteNotification(string version) | ||
{ | ||
this.version = version; | ||
Text = $"You are now running osu!lazer {version}.\nClick to see what's new!"; | ||
} | ||
|
||
[BackgroundDependencyLoader] | ||
private void load(OsuColour colours, ChangelogOverlay changelog, NotificationOverlay notificationOverlay) | ||
{ | ||
Icon = FontAwesome.Solid.CheckSquare; | ||
IconBackgound.Colour = colours.BlueDark; | ||
|
||
Activated = delegate | ||
{ | ||
notificationOverlay.Hide(); | ||
changelog.ShowBuild(OsuGameBase.CLIENT_STREAM_NAME, version); | ||
return true; | ||
}; | ||
} | ||
} | ||
} | ||
} |