diff --git a/osu-framework b/osu-framework index 21fd81a848..e776f6f272 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 21fd81a84860cf6854026458ac82905b6248f41d +Subproject commit e776f6f2729bbe93206c4e8c089eeca57522fcf7 diff --git a/osu.Desktop.Tests/BenchmarkTest.cs b/osu.Desktop.Tests/BenchmarkTest.cs new file mode 100644 index 0000000000..c55b98aa57 --- /dev/null +++ b/osu.Desktop.Tests/BenchmarkTest.cs @@ -0,0 +1,33 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using NUnit.Framework; +using osu.Desktop.VisualTests; +using osu.Framework.Desktop.Platform; +using osu.Game.Modes; +using osu.Game.Modes.Catch; +using osu.Game.Modes.Mania; +using osu.Game.Modes.Osu; +using osu.Game.Modes.Taiko; + +namespace osu.Desktop.Tests +{ + [TestFixture] + public class BenchmarkTest + { + [Test] + public void TestBenchmark() + { + using (var host = new HeadlessGameHost()) + { + Ruleset.Register(new OsuRuleset()); + Ruleset.Register(new TaikoRuleset()); + Ruleset.Register(new ManiaRuleset()); + Ruleset.Register(new CatchRuleset()); + + host.Add(new Benchmark()); + host.Run(); + } + } + } +} diff --git a/osu.Desktop.Tests/app.config b/osu.Desktop.Tests/app.config new file mode 100644 index 0000000000..44ccc4b77a --- /dev/null +++ b/osu.Desktop.Tests/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/osu.Desktop.Tests/osu.Desktop.Tests.csproj b/osu.Desktop.Tests/osu.Desktop.Tests.csproj new file mode 100644 index 0000000000..2c88548c3e --- /dev/null +++ b/osu.Desktop.Tests/osu.Desktop.Tests.csproj @@ -0,0 +1,117 @@ + + + + + Debug + AnyCPU + {230AC4F3-7783-49FB-9AEC-B83CDA3B9F3D} + Library + Properties + osu.Desktop.Tests + osu.Desktop.Tests + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + ..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll + True + + + False + $(SolutionDir)\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll + + + + $(SolutionDir)\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll + + + $(SolutionDir)\packages\SQLiteNetExtensions.1.3.0\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1\SQLiteNetExtensions.dll + + + $(SolutionDir)\packages\SQLite.Net-PCL.3.1.1\lib\net4\SQLite.Net.Platform.Win32.dll + + + $(SolutionDir)\packages\SQLite.Net-PCL.3.1.1\lib\net40\SQLite.Net.Platform.Generic.dll + + + $(SolutionDir)\packages\ppy.OpenTK.2.0.50727.1339\lib\net45\OpenTK.dll + + + + + + + + {65DC628F-A640-4111-AB35-3A5652BC1E17} + osu.Framework.Desktop + + + {C76BF5B3-985E-4D39-95FE-97C9C879B83A} + osu.Framework + + + {d9a367c9-4c1a-489f-9b05-a0cea2b53b58} + osu.Game.Resources + + + {69051C69-12AE-4E7D-A3E6-460D2E282312} + osu.Desktop.VisualTests + + + {58F6C80C-1253-4A0E-A465-B8C85EBEADF3} + osu.Game.Modes.Catch + + + {48F4582B-7687-4621-9CBE-5C24197CB536} + osu.Game.Modes.Mania + + + {C92A607B-1FDD-4954-9F92-03FF547D9080} + osu.Game.Modes.Osu + + + {F167E17A-7DE6-4AF5-B920-A5112296C695} + osu.Game.Modes.Taiko + + + {0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D} + osu.Game + + + + + + + + + + + + \ No newline at end of file diff --git a/osu.Desktop.Tests/packages.config b/osu.Desktop.Tests/packages.config new file mode 100644 index 0000000000..05b53c019c --- /dev/null +++ b/osu.Desktop.Tests/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/osu.Desktop.VisualTests/Benchmark.cs b/osu.Desktop.VisualTests/Benchmark.cs new file mode 100644 index 0000000000..506788e93c --- /dev/null +++ b/osu.Desktop.VisualTests/Benchmark.cs @@ -0,0 +1,56 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Framework; +using osu.Framework.Allocation; +using osu.Framework.Desktop.Platform; +using osu.Framework.GameModes.Testing; +using osu.Game; +using osu.Game.Modes; +using osu.Game.Modes.Catch; +using osu.Game.Modes.Mania; +using osu.Game.Modes.Osu; +using osu.Game.Modes.Taiko; + +namespace osu.Desktop.VisualTests +{ + public class Benchmark : OsuGameBase + { + private double timePerTest = 200; + + [BackgroundDependencyLoader] + private void load(BaseGame game) + { + Host.MaximumDrawHz = int.MaxValue; + Host.MaximumUpdateHz = int.MaxValue; + Host.MaximumInactiveHz = int.MaxValue; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + TestBrowser f = new TestBrowser(); + Add(f); + + Console.WriteLine($@"{Time}: Running {f.TestCount} tests for {timePerTest}ms each..."); + + for (int i = 1; i < f.TestCount; i++) + { + int loadableCase = i; + Scheduler.AddDelayed(delegate + { + f.LoadTest(loadableCase); + Console.WriteLine($@"{Time}: Switching to test #{loadableCase}"); + }, loadableCase * timePerTest); + } + + Scheduler.AddDelayed(Host.Exit, f.TestCount * timePerTest); + } + } +} diff --git a/osu.Desktop.VisualTests/Program.cs b/osu.Desktop.VisualTests/Program.cs index df54297812..b89c6bcf4d 100644 --- a/osu.Desktop.VisualTests/Program.cs +++ b/osu.Desktop.VisualTests/Program.cs @@ -18,6 +18,8 @@ namespace osu.Desktop.VisualTests [STAThread] public static void Main(string[] args) { + bool benchmark = args.Length > 0 && args[0] == @"-benchmark"; + using (BasicGameHost host = Host.GetSuitableHost(@"osu")) { Ruleset.Register(new OsuRuleset()); @@ -25,7 +27,10 @@ namespace osu.Desktop.VisualTests Ruleset.Register(new ManiaRuleset()); Ruleset.Register(new CatchRuleset()); - host.Add(new VisualTestGame()); + if (benchmark) + host.Add(new Benchmark()); + else + host.Add(new VisualTestGame()); host.Run(); } } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs new file mode 100644 index 0000000000..77b313f4ad --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs @@ -0,0 +1,121 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using osu.Framework.Graphics; +using osu.Framework.GameModes.Testing; +using osu.Framework.MathUtils; +using osu.Framework.Timing; +using osu.Game.Overlays; +using System.Linq; +using osu.Game.Overlays.Notifications; +using osu.Game.Screens.Backgrounds; + +namespace osu.Desktop.VisualTests.Tests +{ + class TestCaseNotificationManager : TestCase + { + public override string Name => @"Notification Manager"; + public override string Description => @"I handle notifications"; + + NotificationManager manager; + + public override void Reset() + { + base.Reset(); + + progressingNotifications.Clear(); + + AddInternal(new BackgroundModeDefault() { Depth = 10 }); + + Content.Add(manager = new NotificationManager + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + }); + + AddToggle(@"show", manager.ToggleVisibility); + + AddButton(@"simple #1", sendNotification1); + AddButton(@"simple #2", sendNotification2); + AddButton(@"progress #1", sendProgress1); + AddButton(@"progress #2", sendProgress2); + AddButton(@"barrage", () => sendBarrage()); + } + + private void sendBarrage(int remaining = 100) + { + switch (RNG.Next(0, 4)) + { + case 0: + sendNotification1(); + break; + case 1: + sendNotification2(); + break; + case 2: + sendProgress1(); + break; + case 3: + sendProgress2(); + break; + } + + if (remaining > 0) + { + Delay(80); + Schedule(() => sendBarrage(remaining - 1)); + } + } + + protected override void Update() + { + base.Update(); + + progressingNotifications.RemoveAll(n => n.State == ProgressNotificationState.Completed); + + while (progressingNotifications.Count(n => n.State == ProgressNotificationState.Active) < 3) + { + var p = progressingNotifications.FirstOrDefault(n => n.IsLoaded && n.State == ProgressNotificationState.Queued); + if (p == null) + break; + + p.State = ProgressNotificationState.Active; + } + + foreach (var n in progressingNotifications.FindAll(n => n.State == ProgressNotificationState.Active)) + { + if (n.Progress < 1) + n.Progress += (float)(Time.Elapsed / 2000) * RNG.NextSingle(); + else + n.State = ProgressNotificationState.Completed; + } + } + + private void sendProgress2() + { + var n = new ProgressNotification { Text = @"Downloading Haitai..." }; + manager.Post(n); + progressingNotifications.Add(n); + } + + List progressingNotifications = new List(); + + private void sendProgress1() + { + var n = new ProgressNotification { Text = @"Uploading to BSS..." }; + manager.Post(n); + progressingNotifications.Add(n); + } + + private void sendNotification2() + { + manager.Post(new SimpleNotification { Text = @"You are amazing" }); + } + + private void sendNotification1() + { + manager.Post(new SimpleNotification { Text = @"Welcome to osu!. Enjoy your stay!" }); + } + } +} diff --git a/osu.Desktop.VisualTests/VisualTestGame.cs b/osu.Desktop.VisualTests/VisualTestGame.cs index 7489559c98..952de4ab26 100644 --- a/osu.Desktop.VisualTests/VisualTestGame.cs +++ b/osu.Desktop.VisualTests/VisualTestGame.cs @@ -10,7 +10,6 @@ using osu.Framework.Desktop.Platform; using System.Reflection; using System.IO; using System.Collections.Generic; -using SQLiteNetExtensions.Extensions; using osu.Framework.Allocation; namespace osu.Desktop.VisualTests diff --git a/osu.Desktop.VisualTests/app.config b/osu.Desktop.VisualTests/app.config new file mode 100644 index 0000000000..9bad888bf3 --- /dev/null +++ b/osu.Desktop.VisualTests/app.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 69df007013..cd899d4dd2 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -59,6 +59,7 @@ AllRules.ruleset false false + false none @@ -73,6 +74,7 @@ true AllRules.ruleset false + false @@ -100,13 +102,12 @@ $(SolutionDir)\packages\ppy.OpenTK.2.0.50727.1339\lib\net45\OpenTK.dll - - osu.licenseheader + @@ -172,10 +173,12 @@ + + diff --git a/osu.Desktop.VisualTests/packages.config b/osu.Desktop.VisualTests/packages.config index f39a585e49..75affafd35 100644 --- a/osu.Desktop.VisualTests/packages.config +++ b/osu.Desktop.VisualTests/packages.config @@ -1,13 +1,12 @@ - - - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 5edeffd448..167d4644b7 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -11,6 +11,9 @@ using System.Windows.Forms; using osu.Framework.Platform; using osu.Framework.Desktop.Platform; using osu.Game.Database; +using osu.Desktop.Overlays; +using System.Reflection; +using System.Drawing; namespace osu.Desktop { @@ -22,12 +25,22 @@ namespace osu.Desktop } + protected override void LoadComplete() + { + base.LoadComplete(); + + (new VersionManager()).Preload(this, Add); + } + public override void SetHost(BasicGameHost host) { base.SetHost(host); var desktopWindow = host.Window as DesktopGameWindow; if (desktopWindow != null) { + desktopWindow.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); + desktopWindow.Title = @"osu!lazer"; + desktopWindow.DragEnter += dragEnter; desktopWindow.DragDrop += dragDrop; } diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs new file mode 100644 index 0000000000..a3648e1f12 --- /dev/null +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -0,0 +1,93 @@ +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osu.Game.Overlays; +using osu.Game.Overlays.Notifications; +using Squirrel; +using System.Reflection; + +namespace osu.Desktop.Overlays +{ + public class VersionManager : OverlayContainer + { + private UpdateManager updateManager; + private NotificationManager notification; + + [BackgroundDependencyLoader] + private void load(NotificationManager notification) + { + this.notification = notification; + + AutoSizeAxes = Axes.Both; + Anchor = Anchor.BottomCentre; + Origin = Anchor.BottomCentre; + + var asm = Assembly.GetEntryAssembly().GetName(); + Add(new OsuSpriteText + { + Text = $@"osu!lazer v{asm.Version}" + }); + + updateChecker(); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + State = Visibility.Visible; + } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + updateManager?.Dispose(); + } + + private async void updateChecker() + { + updateManager = await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true); + var info = await updateManager.CheckForUpdate(); + if (info.ReleasesToApply.Count > 0) + { + ProgressNotification n = new UpdateProgressNotification + { + Text = @"Downloading update..." + }; + Schedule(() => notification.Post(n)); + Schedule(() => n.State = ProgressNotificationState.Active); + await updateManager.DownloadReleases(info.ReleasesToApply, (int p) => Schedule(() => n.Progress = p / 100f)); + Schedule(() => n.Text = @"Installing update..."); + await updateManager.ApplyReleases(info, (int p) => Schedule(() => n.Progress = p / 100f)); + Schedule(() => n.State = ProgressNotificationState.Completed); + + } + else + { + //check again every 30 minutes. + Scheduler.AddDelayed(updateChecker, 60000 * 30); + } + } + + protected override void PopIn() + { + } + + protected override void PopOut() + { + } + + class UpdateProgressNotification : ProgressNotification + { + protected override Notification CreateCompletionNotification() => new ProgressCompletionNotification(this) + { + Text = @"Update ready to install. Click to restart!", + Activated = () => + { + UpdateManager.RestartApp(); + return true; + } + }; + } + } +} 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/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..2ab913d706 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -59,6 +59,7 @@ AllRules.ruleset false false + false @@ -75,21 +76,76 @@ true AllRules.ruleset false + false - osu!.res + + + + + lazer.ico + + + Properties\app.manifest + + ..\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 + + osu.licenseheader + + @@ -155,10 +211,14 @@ + + + + + -