mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Show a notification after a successful update
Allows access to the github changelog
This commit is contained in:
@ -2,6 +2,7 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
@ -19,6 +20,7 @@ using OpenTK.Graphics;
|
|||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game;
|
using osu.Game;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
|
||||||
namespace osu.Desktop.Overlays
|
namespace osu.Desktop.Overlays
|
||||||
{
|
{
|
||||||
@ -26,18 +28,24 @@ namespace osu.Desktop.Overlays
|
|||||||
{
|
{
|
||||||
private UpdateManager updateManager;
|
private UpdateManager updateManager;
|
||||||
private NotificationOverlay notificationOverlay;
|
private NotificationOverlay notificationOverlay;
|
||||||
|
private OsuConfigManager config;
|
||||||
|
private OsuGameBase game;
|
||||||
|
|
||||||
public override bool HandleInput => false;
|
public override bool HandleInput => false;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game)
|
private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config)
|
||||||
{
|
{
|
||||||
notificationOverlay = notification;
|
notificationOverlay = notification;
|
||||||
|
this.config = config;
|
||||||
|
this.game = game;
|
||||||
|
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
Anchor = Anchor.BottomCentre;
|
Anchor = Anchor.BottomCentre;
|
||||||
Origin = Anchor.BottomCentre;
|
Origin = Anchor.BottomCentre;
|
||||||
|
|
||||||
Alpha = 0;
|
Alpha = 0;
|
||||||
|
State = Visibility.Hidden;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -91,6 +99,44 @@ namespace osu.Desktop.Overlays
|
|||||||
checkForUpdateAsync();
|
checkForUpdateAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
State = Visibility.Visible;
|
||||||
|
|
||||||
|
var version = game.Version;
|
||||||
|
var lastVersion = config.Get<string>(OsuSetting.Version);
|
||||||
|
if (char.IsNumber(version[0]) && 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))
|
||||||
|
Scheduler.AddDelayed(() => notificationOverlay.Post(new UpdateCompleteNotification(version)), 5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UpdateCompleteNotification : SimpleNotification
|
||||||
|
{
|
||||||
|
public UpdateCompleteNotification(string version)
|
||||||
|
{
|
||||||
|
Text = $"You are now running osu!lazer {version}.\nClick to see what's new!";
|
||||||
|
Icon = FontAwesome.fa_check_square;
|
||||||
|
Activated = delegate
|
||||||
|
{
|
||||||
|
Process.Start($"https://github.com/ppy/osu/releases/tag/v{version}");
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
IconBackgound.Colour = colours.BlueDark;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
@ -70,6 +70,8 @@ namespace osu.Game.Configuration
|
|||||||
|
|
||||||
// Update
|
// Update
|
||||||
Set(OsuSetting.ReleaseStream, ReleaseStream.Lazer);
|
Set(OsuSetting.ReleaseStream, ReleaseStream.Lazer);
|
||||||
|
|
||||||
|
Set(OsuSetting.Version, string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsuConfigManager(Storage storage) : base(storage)
|
public OsuConfigManager(Storage storage) : base(storage)
|
||||||
@ -106,6 +108,7 @@ namespace osu.Game.Configuration
|
|||||||
SnakingInSliders,
|
SnakingInSliders,
|
||||||
SnakingOutSliders,
|
SnakingOutSliders,
|
||||||
ShowFpsDisplay,
|
ShowFpsDisplay,
|
||||||
ChatDisplayHeight
|
ChatDisplayHeight,
|
||||||
|
Version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user