From 3819ecb2be476b74bbb2773c588e687a108f7aa5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 19 Jun 2018 20:19:52 +0900 Subject: [PATCH] Update framework --- osu.Desktop/Overlays/VersionManager.cs | 13 ++++++++----- .../Objects/Drawables/Pieces/SliderBody.cs | 6 +++--- osu.Game/Beatmaps/WorkingBeatmap.cs | 6 +++--- osu.Game/Graphics/Containers/LinkFlowContainer.cs | 8 +++++--- .../Graphics/UserInterface/ExternalLinkButton.cs | 12 +++++------- osu.Game/Screens/Edit/Editor.cs | 8 ++++++-- osu.Game/osu.Game.csproj | 2 +- 7 files changed, 31 insertions(+), 24 deletions(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index 26e80b3f48..bc1faec822 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -1,12 +1,13 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Diagnostics; +using System; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; +using osu.Framework.Platform; using osu.Game; using osu.Game.Configuration; using osu.Game.Graphics; @@ -24,16 +25,18 @@ public class VersionManager : OverlayContainer private OsuConfigManager config; private OsuGameBase game; private NotificationOverlay notificationOverlay; + private GameHost host; public override bool HandleKeyboardInput => false; public override bool HandleMouseInput => false; [BackgroundDependencyLoader] - private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config) + private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config, GameHost host) { notificationOverlay = notification; this.config = config; this.game = game; + this.host = host; AutoSizeAxes = Axes.Both; Anchor = Anchor.BottomCentre; @@ -106,19 +109,19 @@ protected override void LoadComplete() // 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)); + notificationOverlay.Post(new UpdateCompleteNotification(version, host.OpenUrlExternally)); } } private class UpdateCompleteNotification : SimpleNotification { - public UpdateCompleteNotification(string version) + public UpdateCompleteNotification(string version, Action openUrl = null) { Text = $"You are now running osu!lazer {version}.\nClick to see what's new!"; Icon = FontAwesome.fa_check_square; Activated = delegate { - Process.Start($"https://osu.ppy.sh/home/changelog/{version}"); + openUrl?.Invoke($"https://osu.ppy.sh/home/changelog/lazer/{version}"); return true; }; } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs index 0a6b1b459a..94a61e7904 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs @@ -139,8 +139,8 @@ private void reloadTexture() var texture = new Texture(textureWidth, 1); //initialise background - var upload = new TextureUpload(textureWidth * 4); - var bytes = upload.Data; + var raw = new RawTexture(textureWidth, 1); + var bytes = raw.Data; const float aa_portion = 0.02f; const float border_portion = 0.128f; @@ -171,7 +171,7 @@ private void reloadTexture() } } - texture.SetData(upload); + texture.SetData(new TextureUpload(raw)); path.Texture = texture; container.ForceRedraw(); diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 66a6206c16..4310d9b7df 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -13,7 +13,6 @@ using osu.Framework.IO.File; using System.IO; using osu.Game.IO.Serialization; -using System.Diagnostics; using osu.Game.Rulesets; using osu.Game.Rulesets.UI; using osu.Game.Skinning; @@ -49,12 +48,13 @@ protected WorkingBeatmap(BeatmapInfo beatmapInfo) /// /// Saves the . /// - public void Save() + /// The absolute path of the output file. + public string Save() { var path = FileSafety.GetTempPath(Guid.NewGuid().ToString().Replace("-", string.Empty) + ".json"); using (var sw = new StreamWriter(path)) sw.WriteLine(Beatmap.Serialize()); - Process.Start(path); + return path; } protected abstract IBeatmap GetBeatmap(); diff --git a/osu.Game/Graphics/Containers/LinkFlowContainer.cs b/osu.Game/Graphics/Containers/LinkFlowContainer.cs index 157c814f55..9c5da71aff 100644 --- a/osu.Game/Graphics/Containers/LinkFlowContainer.cs +++ b/osu.Game/Graphics/Containers/LinkFlowContainer.cs @@ -3,11 +3,11 @@ using osu.Game.Online.Chat; using System; -using System.Diagnostics; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Graphics.Sprites; using System.Collections.Generic; +using osu.Framework.Platform; using osu.Game.Overlays; using osu.Game.Overlays.Notifications; @@ -25,12 +25,14 @@ public LinkFlowContainer(Action defaultCreationParameters = null) private OsuGame game; private Action showNotImplementedError; + private GameHost host; [BackgroundDependencyLoader(true)] - private void load(OsuGame game, NotificationOverlay notifications) + private void load(OsuGame game, NotificationOverlay notifications, GameHost host) { // will be null in tests this.game = game; + this.host = host; showNotImplementedError = () => notifications?.Post(new SimpleNotification { @@ -88,7 +90,7 @@ public void AddLink(string text, string url, LinkAction linkType = LinkAction.Ex showNotImplementedError?.Invoke(); break; case LinkAction.External: - Process.Start(url); + host.OpenUrlExternally(url); break; case LinkAction.OpenUserProfile: if (long.TryParse(linkArgument, out long userId)) diff --git a/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs b/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs index 77079894cc..be2412ccad 100644 --- a/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs +++ b/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs @@ -1,12 +1,12 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Diagnostics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Input; +using osu.Framework.Platform; using OpenTK; using OpenTK.Graphics; @@ -17,6 +17,7 @@ public class ExternalLinkButton : CompositeDrawable, IHasTooltip public string Link { get; set; } private Color4 hoverColour; + private GameHost host; public ExternalLinkButton(string link = null) { @@ -30,9 +31,10 @@ public ExternalLinkButton(string link = null) } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OsuColour colours, GameHost host) { hoverColour = colours.Yellow; + this.host = host; } protected override bool OnHover(InputState state) @@ -50,11 +52,7 @@ protected override void OnHoverLost(InputState state) protected override bool OnClick(InputState state) { if(Link != null) - Process.Start(new ProcessStartInfo - { - FileName = Link, - UseShellExecute = true //see https://github.com/dotnet/corefx/issues/10361 - }); + host.OpenUrlExternally(Link); return true; } diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index d4f66c2f09..2a2111c8d6 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -13,6 +13,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; +using osu.Framework.Platform; using osu.Framework.Timing; using osu.Game.Graphics.UserInterface; using osu.Game.Screens.Edit.Screens; @@ -39,13 +40,16 @@ public class Editor : OsuScreen private EditorClock clock; private DependencyContainer dependencies; + private GameHost host; protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OsuColour colours, GameHost host) { + this.host = host; + // TODO: should probably be done at a RulesetContainer level to share logic with Player. var sourceClock = (IAdjustableClock)Beatmap.Value.Track ?? new StopwatchClock(); clock = new EditorClock(Beatmap.Value, beatDivisor) { IsCoupled = false }; @@ -155,7 +159,7 @@ private void load(OsuColour colours) private void exportBeatmap() { - Beatmap.Value.Save(); + host.OpenFileExternally(Beatmap.Value.Save()); } private void onModeChanged(EditorScreenMode mode) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index d87e190352..f0bc330994 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -18,7 +18,7 @@ - +