From a14b7eb59831c1a043c4659c2fdffb169d1f10fc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 12 Feb 2017 14:50:02 +0900 Subject: [PATCH 1/9] NotificationManager should become visible when receiving a notification (until we implement toasts). --- osu.Game/Overlays/NotificationManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Overlays/NotificationManager.cs b/osu.Game/Overlays/NotificationManager.cs index e4eb718639..ecfa3daa38 100644 --- a/osu.Game/Overlays/NotificationManager.cs +++ b/osu.Game/Overlays/NotificationManager.cs @@ -73,6 +73,8 @@ namespace osu.Game.Overlays public void Post(Notification notification) { + State = Visibility.Visible; + ++runningDepth; notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth; From ac548dc9ec1c37f4cdb9fdc83c9217bfe3f82f59 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 12 Feb 2017 14:50:42 +0900 Subject: [PATCH 2/9] Rework notifications to be more flexible. --- .../Tests/TestCaseNotificationManager.cs | 10 +- .../ProgressCompletionNotification.cs | 4 +- .../Notifications/ProgressNotification.cs | 121 +++++++++++------- .../Notifications/SimpleNotification.cs | 33 ++++- 4 files changed, 113 insertions(+), 55 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs index cc9201c1fd..77b313f4ad 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs @@ -88,13 +88,13 @@ namespace osu.Desktop.VisualTests.Tests if (n.Progress < 1) n.Progress += (float)(Time.Elapsed / 2000) * RNG.NextSingle(); else - n.Complete(); + n.State = ProgressNotificationState.Completed; } } private void sendProgress2() { - var n = new ProgressNotification(@"Downloading Haitai..."); + var n = new ProgressNotification { Text = @"Downloading Haitai..." }; manager.Post(n); progressingNotifications.Add(n); } @@ -103,19 +103,19 @@ namespace osu.Desktop.VisualTests.Tests private void sendProgress1() { - var n = new ProgressNotification(@"Uploading to BSS..."); + var n = new ProgressNotification { Text = @"Uploading to BSS..." }; manager.Post(n); progressingNotifications.Add(n); } private void sendNotification2() { - manager.Post(new SimpleNotification(@"You are amazing")); + manager.Post(new SimpleNotification { Text = @"You are amazing" }); } private void sendNotification1() { - manager.Post(new SimpleNotification(@"Welcome to osu!. Enjoy your stay!")); + manager.Post(new SimpleNotification { Text = @"Welcome to osu!. Enjoy your stay!" }); } } } diff --git a/osu.Game/Overlays/Notifications/ProgressCompletionNotification.cs b/osu.Game/Overlays/Notifications/ProgressCompletionNotification.cs index 1861e410d2..a5ec9a3545 100644 --- a/osu.Game/Overlays/Notifications/ProgressCompletionNotification.cs +++ b/osu.Game/Overlays/Notifications/ProgressCompletionNotification.cs @@ -1,6 +1,8 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Game.Graphics; + namespace osu.Game.Overlays.Notifications { public class ProgressCompletionNotification : SimpleNotification @@ -8,9 +10,9 @@ namespace osu.Game.Overlays.Notifications private ProgressNotification progressNotification; public ProgressCompletionNotification(ProgressNotification progressNotification) - : base(@"Task has completed!") { this.progressNotification = progressNotification; + Icon = FontAwesome.fa_check; } } } \ No newline at end of file diff --git a/osu.Game/Overlays/Notifications/ProgressNotification.cs b/osu.Game/Overlays/Notifications/ProgressNotification.cs index 4cb1557c32..b00204e166 100644 --- a/osu.Game/Overlays/Notifications/ProgressNotification.cs +++ b/osu.Game/Overlays/Notifications/ProgressNotification.cs @@ -17,6 +17,16 @@ namespace osu.Game.Overlays.Notifications public class ProgressNotification : Notification, IHasCompletionTarget { private string text; + public string Text + { + get { return text; } + set + { + text = value; + if (IsLoaded) + textDrawable.Text = text; + } + } private float progress; public float Progress @@ -24,42 +34,79 @@ namespace osu.Game.Overlays.Notifications get { return progress; } set { - Debug.Assert(state == ProgressNotificationState.Active); progress = value; - progressBar.Progress = progress; + if (IsLoaded) + progressBar.Progress = progress; } } - public ProgressNotificationState State + protected override void LoadComplete() + { + base.LoadComplete(); + + //we may have received changes before we were displayed. + State = state; + Progress = progress; + } + + public virtual ProgressNotificationState State { get { return state; } set { + bool stateChanged = state != value; state = value; - switch (state) + + if (IsLoaded) { - case ProgressNotificationState.Queued: - Light.Colour = colourQueued; - Light.Pulsate = false; - progressBar.Active = false; - break; - case ProgressNotificationState.Active: - Light.Colour = colourActive; - Light.Pulsate = true; - progressBar.Active = true; - break; - case ProgressNotificationState.Cancelled: - Light.Colour = colourCancelled; - Light.Pulsate = false; - progressBar.Active = false; - break; + switch (state) + { + case ProgressNotificationState.Queued: + Light.Colour = colourQueued; + Light.Pulsate = false; + progressBar.Active = false; + break; + case ProgressNotificationState.Active: + Light.Colour = colourActive; + Light.Pulsate = true; + progressBar.Active = true; + break; + case ProgressNotificationState.Cancelled: + Light.Colour = colourCancelled; + Light.Pulsate = false; + progressBar.Active = false; + break; + } + } + + if (stateChanged) + { + switch (state) + { + case ProgressNotificationState.Completed: + NotificationContent.MoveToY(-DrawSize.Y / 2, 200, EasingTypes.OutQuint); + FadeTo(0.01f, 200); //don't completely fade out or our scheduled task won't run. + + Delay(100); + Schedule(Completed); + break; + } } } } private ProgressNotificationState state; - public Action Completed; + protected virtual Notification CreateCompletionNotification() => new ProgressCompletionNotification(this) + { + Activated = CompletionClickAction, + Text = $"Task \"{Text}\" has completed!" + }; + + protected virtual void Completed() + { + CompletionTarget?.Invoke(CreateCompletionNotification()); + } public override bool DisplayOnTop => false; @@ -68,10 +115,7 @@ namespace osu.Game.Overlays.Notifications private Color4 colourActive; private Color4 colourCancelled; - public ProgressNotification(string text) - { - this.text = text; - } + private SpriteText textDrawable; [BackgroundDependencyLoader] private void load(OsuColour colours) @@ -85,7 +129,7 @@ namespace osu.Game.Overlays.Notifications RelativeSizeAxes = Axes.Both, }); - Content.Add(new SpriteText + Content.Add(textDrawable = new SpriteText { TextSize = 16, Colour = OsuColour.Gray(128), @@ -104,23 +148,6 @@ namespace osu.Game.Overlays.Notifications State = ProgressNotificationState.Queued; } - public void Complete() - { - Debug.Assert(state != ProgressNotificationState.Completed); - - state = ProgressNotificationState.Completed; - - NotificationContent.MoveToY(-DrawSize.Y / 2, 200, EasingTypes.OutQuint); - FadeTo(0.01f, 200); //don't completely fade out or our scheduled task won't run. - - Delay(100); - Schedule(() => - { - CompletionTarget?.Invoke(new ProgressCompletionNotification(this)); - base.Close(); - }); - } - public override void Close() { switch (State) @@ -135,8 +162,16 @@ namespace osu.Game.Overlays.Notifications } } + /// + /// The function to post completion notifications back to. + /// public Action CompletionTarget { get; set; } + /// + /// An action to complete when the completion notification is clicked. + /// + public Func CompletionClickAction; + class ProgressBar : Container { private Box box; @@ -175,7 +210,7 @@ namespace osu.Game.Overlays.Notifications { colourActive = colours.Blue; Colour = colourInactive = OsuColour.Gray(0.5f); - + Height = 5; Children = new[] diff --git a/osu.Game/Overlays/Notifications/SimpleNotification.cs b/osu.Game/Overlays/Notifications/SimpleNotification.cs index 7c6666082e..52bd271252 100644 --- a/osu.Game/Overlays/Notifications/SimpleNotification.cs +++ b/osu.Game/Overlays/Notifications/SimpleNotification.cs @@ -12,12 +12,33 @@ namespace osu.Game.Overlays.Notifications public class SimpleNotification : Notification { private string text; - - public SimpleNotification(string text) + public string Text { - this.text = text; + get { return text; } + set + { + text = value; + if (IsLoaded) + textDrawable.Text = text; + } } + private FontAwesome icon = FontAwesome.fa_info_circle; + public FontAwesome Icon + { + get { return icon; } + set + { + icon = value; + if (IsLoaded) + iconDrawable.Icon = icon; + } + } + + + private SpriteText textDrawable; + private TextAwesome iconDrawable; + [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -28,14 +49,14 @@ namespace osu.Game.Overlays.Notifications RelativeSizeAxes = Axes.Both, ColourInfo = ColourInfo.GradientVertical(OsuColour.Gray(0.2f), OsuColour.Gray(0.5f)) }, - new TextAwesome + iconDrawable = new TextAwesome { Anchor = Anchor.Centre, - Icon = FontAwesome.fa_info_circle, + Icon = icon , } }); - Content.Add(new SpriteText + Content.Add(textDrawable = new SpriteText { TextSize = 16, Colour = OsuColour.Gray(128), From 49ae976af665a695f3025379ff27efa3b6a22965 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 12 Feb 2017 14:52:10 +0900 Subject: [PATCH 3/9] Add squirrel dependencies. --- osu.Desktop/app.config | 11 ++++++++ osu.Desktop/osu.Desktop.csproj | 46 ++++++++++++++++++++++++++++++++++ osu.Desktop/packages.config | 7 ++++++ 3 files changed, 64 insertions(+) create mode 100644 osu.Desktop/app.config create mode 100644 osu.Desktop/packages.config diff --git a/osu.Desktop/app.config b/osu.Desktop/app.config new file mode 100644 index 0000000000..44ccc4b77a --- /dev/null +++ b/osu.Desktop/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 9df4148ac0..65bf80700f 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -80,8 +80,52 @@ osu!.res + + ..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.dll + True + + + ..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.MsDelta.dll + True + + + ..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.PatchApi.dll + True + + + ..\packages\squirrel.windows.1.5.2\lib\Net45\ICSharpCode.SharpZipLib.dll + True + + + ..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.dll + True + + + ..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Mdb.dll + True + + + ..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Pdb.dll + True + + + ..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Rocks.dll + True + + + ..\packages\squirrel.windows.1.5.2\lib\Net45\NuGet.Squirrel.dll + True + + + ..\packages\Splat.1.6.2\lib\Net45\Splat.dll + True + + + ..\packages\squirrel.windows.1.5.2\lib\Net45\Squirrel.dll + True + @@ -89,7 +133,9 @@ osu.licenseheader + + diff --git a/osu.Desktop/packages.config b/osu.Desktop/packages.config new file mode 100644 index 0000000000..8d1361bd0a --- /dev/null +++ b/osu.Desktop/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file From 870aa2750f83935939236c6c5acb44f48f1f6aa1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 12 Feb 2017 14:53:33 +0900 Subject: [PATCH 4/9] Don't attempt to import command line arguments as beatmaps. --- osu.Game/Database/BeatmapDatabase.cs | 106 ++++++++++++++------------- osu.Game/OsuGame.cs | 8 +- 2 files changed, 60 insertions(+), 54 deletions(-) diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index dff76479e8..d515c71ed4 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -83,64 +83,66 @@ namespace osu.Game.Database connection.DeleteAll(); } - public void Import(params string[] paths) + public void Import(IEnumerable paths) { foreach (string p in paths) + Import(p); + } + + public void Import(string path) + { + string hash = null; + + BeatmapMetadata metadata; + + using (var reader = ArchiveReader.GetReader(storage, path)) + metadata = reader.ReadMetadata(); + + if (metadata.OnlineBeatmapSetID.HasValue && + connection.Table().Count(b => b.OnlineBeatmapSetID == metadata.OnlineBeatmapSetID) != 0) + return; // TODO: Update this beatmap instead + + if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader { - var path = p; - string hash = null; - - BeatmapMetadata metadata; - - using (var reader = ArchiveReader.GetReader(storage, path)) - metadata = reader.ReadMetadata(); - - if (metadata.OnlineBeatmapSetID.HasValue && - connection.Table().Count(b => b.OnlineBeatmapSetID == metadata.OnlineBeatmapSetID) != 0) - return; // TODO: Update this beatmap instead - - if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader + using (var md5 = MD5.Create()) + using (var input = storage.GetStream(path)) { - using (var md5 = MD5.Create()) - using (var input = storage.GetStream(path)) - { - hash = BitConverter.ToString(md5.ComputeHash(input)).Replace("-", "").ToLowerInvariant(); - input.Seek(0, SeekOrigin.Begin); - path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash); - using (var output = storage.GetStream(path, FileAccess.Write)) - input.CopyTo(output); - } + hash = BitConverter.ToString(md5.ComputeHash(input)).Replace("-", "").ToLowerInvariant(); + input.Seek(0, SeekOrigin.Begin); + path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash); + using (var output = storage.GetStream(path, FileAccess.Write)) + input.CopyTo(output); } - var beatmapSet = new BeatmapSetInfo - { - OnlineBeatmapSetID = metadata.OnlineBeatmapSetID, - Beatmaps = new List(), - Path = path, - Hash = hash, - Metadata = metadata - }; - - using (var reader = ArchiveReader.GetReader(storage, path)) - { - string[] mapNames = reader.ReadBeatmaps(); - foreach (var name in mapNames) - { - using (var stream = new StreamReader(reader.GetStream(name))) - { - var decoder = BeatmapDecoder.GetDecoder(stream); - Beatmap beatmap = decoder.Decode(stream); - beatmap.BeatmapInfo.Path = name; - - // TODO: Diff beatmap metadata with set metadata and leave it here if necessary - beatmap.BeatmapInfo.Metadata = null; - - beatmapSet.Beatmaps.Add(beatmap.BeatmapInfo); - } - } - } - - Import(new[] { beatmapSet }); } + var beatmapSet = new BeatmapSetInfo + { + OnlineBeatmapSetID = metadata.OnlineBeatmapSetID, + Beatmaps = new List(), + Path = path, + Hash = hash, + Metadata = metadata + }; + + using (var reader = ArchiveReader.GetReader(storage, path)) + { + string[] mapNames = reader.ReadBeatmaps(); + foreach (var name in mapNames) + { + using (var stream = new StreamReader(reader.GetStream(name))) + { + var decoder = BeatmapDecoder.GetDecoder(stream); + Beatmap beatmap = decoder.Decode(stream); + beatmap.BeatmapInfo.Path = name; + + // TODO: Diff beatmap metadata with set metadata and leave it here if necessary + beatmap.BeatmapInfo.Metadata = null; + + beatmapSet.Beatmaps.Add(beatmap.BeatmapInfo); + } + } + } + + Import(new[] { beatmapSet }); } public void Import(IEnumerable beatmapSets) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index e8233366d9..9188fab355 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -24,6 +24,7 @@ using osu.Game.Screens.Menu; using OpenTK; using System.Linq; using osu.Framework.Graphics.Primitives; +using System.Collections.Generic; namespace osu.Game { @@ -67,14 +68,17 @@ namespace osu.Game } if (args?.Length > 0) - ImportBeatmaps(args); + { + var paths = args.Where(a => !a.StartsWith(@"-")); + ImportBeatmaps(paths); + } Dependencies.Cache(this); PlayMode = LocalConfig.GetBindable(OsuConfig.PlayMode); } - public void ImportBeatmaps(params string[] paths) + public void ImportBeatmaps(IEnumerable paths) { Schedule(delegate { Dependencies.Get().Import(paths); }); } From 0cd149eda46cf180f70ee3fa938dd9f5036c0165 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 12 Feb 2017 14:54:07 +0900 Subject: [PATCH 5/9] Stop using embedded manifest, add AssemblyInfo. --- osu.Desktop/Properties/AssemblyInfo.cs | 26 ++++++++++++++++++++++++++ osu.Desktop/osu.Desktop.csproj | 15 +++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 osu.Desktop/Properties/AssemblyInfo.cs diff --git a/osu.Desktop/Properties/AssemblyInfo.cs b/osu.Desktop/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..d7391080a6 --- /dev/null +++ b/osu.Desktop/Properties/AssemblyInfo.cs @@ -0,0 +1,26 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("osu!lazer")] +[assembly: AssemblyDescription("click the circles. to the beat.")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("ppy Pty Ltd")] +[assembly: AssemblyProduct("osu!lazer")] +[assembly: AssemblyCopyright("ppy Pty Ltd 2007-2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("55e28cb2-7b6c-4595-8dcc-9871d8aad7e9")] + +[assembly: AssemblyVersion("0.0.3")] +[assembly: AssemblyFileVersion("0.0.3")] diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 65bf80700f..0eda38bbd7 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -77,7 +77,14 @@ false - osu!.res + + + + + lazer.ico + + + Properties\app.manifest @@ -201,10 +208,14 @@ + + + + + -