1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 13:37:25 +08:00
osu-lazer/osu.Desktop/Overlays/VersionManager.cs

141 lines
4.9 KiB
C#
Raw Normal View History

// 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.
2018-04-13 17:19:50 +08:00
using osu.Framework.Allocation;
2019-06-20 11:48:45 +08:00
using osu.Framework.Development;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
2018-11-20 15:51:59 +08:00
using osuTK;
using osuTK.Graphics;
2018-04-13 17:19:50 +08:00
namespace osu.Desktop.Overlays
{
public class VersionManager : OverlayContainer
{
private OsuConfigManager config;
private OsuGameBase game;
private NotificationOverlay notificationOverlay;
[BackgroundDependencyLoader]
private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config)
2018-04-13 17:19:50 +08:00
{
notificationOverlay = notification;
this.config = config;
this.game = game;
AutoSizeAxes = Axes.Both;
Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre;
Alpha = 0;
Children = new Drawable[]
{
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5),
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Children = new Drawable[]
{
new OsuSpriteText
{
Font = OsuFont.GetFont(weight: FontWeight.Bold),
2018-04-13 17:19:50 +08:00
Text = game.Name
},
new OsuSpriteText
{
2019-06-20 11:48:45 +08:00
Colour = DebugUtils.IsDebugBuild ? colours.Red : Color4.White,
2018-04-13 17:19:50 +08:00
Text = game.Version
},
}
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Font = OsuFont.Numeric.With(size: 12),
2018-04-13 17:19:50 +08:00
Colour = colours.Yellow,
Text = @"Development Build"
},
new Sprite
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
2018-08-31 06:04:40 +08:00
Texture = textures.Get(@"Menu/dev-build-footer"),
2018-04-13 17:19:50 +08:00
},
}
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
var version = game.Version;
var lastVersion = config.Get<string>(OsuSetting.Version);
2019-04-01 11:16:05 +08:00
if (game.IsDeployedBuild && version != lastVersion)
2018-04-13 17:19:50 +08:00
{
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))
notificationOverlay.Post(new UpdateCompleteNotification(version));
2018-04-13 17:19:50 +08:00
}
}
private class UpdateCompleteNotification : SimpleNotification
{
private readonly string version;
public UpdateCompleteNotification(string version)
2018-04-13 17:19:50 +08:00
{
this.version = version;
2018-04-13 17:19:50 +08:00
Text = $"You are now running osu!lazer {version}.\nClick to see what's new!";
}
[BackgroundDependencyLoader]
2019-08-13 16:29:48 +08:00
private void load(OsuColour colours, ChangelogOverlay changelog, NotificationOverlay notificationOverlay)
2018-04-13 17:19:50 +08:00
{
Icon = FontAwesome.Solid.CheckSquare;
2018-04-13 17:19:50 +08:00
IconBackgound.Colour = colours.BlueDark;
Activated = delegate
{
2019-08-13 16:29:48 +08:00
notificationOverlay.Hide();
2019-06-03 12:16:05 +08:00
changelog.ShowBuild(OsuGameBase.CLIENT_STREAM_NAME, version);
return true;
};
2018-04-13 17:19:50 +08:00
}
}
protected override void PopIn()
{
2018-12-27 18:22:24 +08:00
this.FadeIn(1400, Easing.OutQuint);
2018-04-13 17:19:50 +08:00
}
protected override void PopOut()
{
2018-12-27 18:22:24 +08:00
this.FadeOut(500, Easing.OutQuint);
2018-04-13 17:19:50 +08:00
}
}
}