1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-26 04:32:55 +08:00
osu-lazer/osu.Desktop/Overlays/VersionManager.cs

143 lines
5.0 KiB
C#
Raw Normal View History

2018-01-05 19:21:19 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
2017-02-14 15:13:25 +08:00
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Diagnostics;
2017-02-14 15:13:25 +08:00
using osu.Framework.Allocation;
2017-09-19 12:29:50 +08:00
using osu.Framework.Development;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2017-02-13 19:06:51 +08:00
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game;
2017-09-18 21:32:49 +08:00
using osu.Game.Configuration;
2017-02-13 19:06:51 +08:00
using osu.Game.Graphics;
2017-09-18 21:32:49 +08:00
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
2017-09-18 21:32:49 +08:00
using osu.Game.Overlays.Notifications;
2017-02-13 19:06:51 +08:00
using OpenTK;
using OpenTK.Graphics;
namespace osu.Desktop.Overlays
{
public class VersionManager : OverlayContainer
{
private OsuConfigManager config;
private OsuGameBase game;
2018-03-27 17:57:20 +08:00
private NotificationOverlay notificationOverlay;
public override bool HandleKeyboardInput => false;
public override bool HandleMouseInput => false;
2017-02-13 19:06:51 +08:00
[BackgroundDependencyLoader]
private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config)
{
notificationOverlay = notification;
this.config = config;
this.game = game;
AutoSizeAxes = Axes.Both;
Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre;
2017-02-13 19:06:51 +08:00
Alpha = 0;
2017-02-13 19:06:51 +08:00
Children = new Drawable[]
{
2017-03-02 02:33:01 +08:00
new FillFlowContainer
2017-02-13 19:06:51 +08:00
{
AutoSizeAxes = Axes.Both,
2017-03-04 18:00:17 +08:00
Direction = FillDirection.Vertical,
2017-02-13 19:06:51 +08:00
Children = new Drawable[]
{
2017-03-02 02:33:01 +08:00
new FillFlowContainer
2017-02-13 19:06:51 +08:00
{
AutoSizeAxes = Axes.Both,
2017-03-04 18:00:17 +08:00
Direction = FillDirection.Horizontal,
2017-03-02 02:33:01 +08:00
Spacing = new Vector2(5),
2017-02-13 19:06:51 +08:00
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Children = new Drawable[]
{
new OsuSpriteText
{
Font = @"Exo2.0-Bold",
Text = game.Name
2017-02-13 19:06:51 +08:00
},
new OsuSpriteText
{
2017-09-19 12:29:50 +08:00
Colour = DebugUtils.IsDebug ? colours.Red : Color4.White,
Text = game.Version
2017-02-13 19:06:51 +08:00
},
}
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
TextSize = 12,
Colour = colours.Yellow,
Font = @"Venera",
2017-03-07 09:59:19 +08:00
Text = @"Development Build"
2017-02-13 19:06:51 +08:00
},
new Sprite
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
2017-02-13 19:06:51 +08:00
Texture = textures.Get(@"Menu/dev-build-footer"),
},
}
}
};
2017-11-20 18:44:06 +08:00
#if NET_FRAMEWORK
2018-03-27 17:57:20 +08:00
Add(new SquirrelUpdateManager());
#endif
}
protected override void LoadComplete()
{
base.LoadComplete();
var version = game.Version;
var lastVersion = config.Get<string>(OsuSetting.Version);
2017-08-22 21:48:50 +08:00
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))
2018-01-04 23:42:48 +08:00
notificationOverlay.Post(new UpdateCompleteNotification(version));
}
}
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 PopIn()
{
this.FadeIn(1000);
}
protected override void PopOut()
{
}
}
}