diff --git a/osu.Desktop.VisualTests/Program.cs b/osu.Desktop.VisualTests/Program.cs index 52aceb1ee8..4732930b0b 100644 --- a/osu.Desktop.VisualTests/Program.cs +++ b/osu.Desktop.VisualTests/Program.cs @@ -3,6 +3,7 @@ using System; using osu.Framework.Desktop; +using osu.Framework.Desktop.Platform; using osu.Framework.Platform; namespace osu.Framework.VisualTests diff --git a/osu.Desktop.VisualTests/VisualTestGame.cs b/osu.Desktop.VisualTests/VisualTestGame.cs index 5a51f28d82..38ac3b45f9 100644 --- a/osu.Desktop.VisualTests/VisualTestGame.cs +++ b/osu.Desktop.VisualTests/VisualTestGame.cs @@ -5,15 +5,77 @@ using osu.Framework.GameModes.Testing; using osu.Framework.Graphics.Cursor; using osu.Game.Database; using osu.Game; +using osu.Framework.Desktop.Platform; +using System.Reflection; +using System.IO; +using System.Collections.Generic; +using osu.Game.GameModes.Play; +using SQLiteNetExtensions.Extensions; namespace osu.Framework.VisualTests { class VisualTestGame : OsuGameBase { + private void InsertTestMap(int i) + { + var beatmapSet = new BeatmapSetInfo + { + BeatmapSetID = 1234 + i, + Hash = "d8e8fca2dc0f896fd7cb4cb0031ba249", + Path = "/foo/bar/baz", + Metadata = new BeatmapMetadata + { + BeatmapSetID = 1234 + i, + Artist = "MONACA", + Title = "Black Song", + Author = "Some Guy", + }, + Beatmaps = new List(new[] + { + new BeatmapInfo + { + BeatmapID = 1234 + i, + Mode = PlayMode.Osu, + Path = "normal.osu", + Version = "Normal", + BaseDifficulty = new BaseDifficulty + { + OverallDifficulty = 3.5f, + } + }, + new BeatmapInfo + { + BeatmapID = 1235 + i, + Mode = PlayMode.Osu, + Path = "hard.osu", + Version = "Hard", + BaseDifficulty = new BaseDifficulty + { + OverallDifficulty = 5, + } + }, + new BeatmapInfo + { + BeatmapID = 1236 + i, + Mode = PlayMode.Osu, + Path = "insane.osu", + Version = "Insane", + BaseDifficulty = new BaseDifficulty + { + OverallDifficulty = 7, + } + }, + }), + }; + BeatmapDatabase.Connection.InsertWithChildren(beatmapSet, true); + } + public override void Load(BaseGame game) { + (Host.Storage as DesktopStorage).InMemorySQL = true; base.Load(game); - + for (int i = 0; i < 100; i += 10) + InsertTestMap(i); Add(new TestBrowser()); } } diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 3dfe829651..2f97d991a6 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -81,15 +81,22 @@ - ..\packages\ppy.OpenTK.2.0.50727.1337\lib\net20\OpenTK.dll + $(SolutionDir)\packages\ppy.OpenTK.2.0.50727.1337\lib\net20\OpenTK.dll True + + $(SolutionDir)\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll + + + $(SolutionDir)\packages\SQLiteNetExtensions.1.3.0\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1\SQLiteNetExtensions.dll + osu.licenseheader + @@ -170,4 +177,4 @@ - \ No newline at end of file + diff --git a/osu.Desktop.VisualTests/packages.config b/osu.Desktop.VisualTests/packages.config new file mode 100644 index 0000000000..62a2a41a2a --- /dev/null +++ b/osu.Desktop.VisualTests/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs index 36837044a1..8586e3a2a9 100644 --- a/osu.Desktop/Program.cs +++ b/osu.Desktop/Program.cs @@ -25,7 +25,7 @@ namespace osu.Desktop var importer = new BeatmapImporter(host); foreach (var file in args) - if (importer.Import(file).Wait(1000)) + if (!importer.Import(file).Wait(1000)) throw new TimeoutException(@"IPC took too long to send"); Console.WriteLine(@"Sent import requests to running instance"); } diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index a39caac2fe..512ca32a75 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -17,7 +17,7 @@ namespace osu.Game.Database { public class BeatmapDatabase { - private static SQLiteConnection connection { get; set; } + public static SQLiteConnection Connection { get; set; } private BasicStorage storage; public event Action BeatmapSetAdded; @@ -29,13 +29,13 @@ namespace osu.Game.Database ipc = new BeatmapImporter(host, this); - if (connection == null) + if (Connection == null) { - connection = storage.GetDatabase(@"beatmaps"); - connection.CreateTable(); - connection.CreateTable(); - connection.CreateTable(); - connection.CreateTable(); + Connection = storage.GetDatabase(@"beatmaps"); + Connection.CreateTable(); + Connection.CreateTable(); + Connection.CreateTable(); + Connection.CreateTable(); } } @@ -44,10 +44,10 @@ namespace osu.Game.Database foreach (var setInfo in Query()) storage.Delete(setInfo.Path); - connection.DeleteAll(); - connection.DeleteAll(); - connection.DeleteAll(); - connection.DeleteAll(); + Connection.DeleteAll(); + Connection.DeleteAll(); + Connection.DeleteAll(); + Connection.DeleteAll(); } public void Import(params string[] paths) @@ -62,7 +62,7 @@ namespace osu.Game.Database using (var reader = ArchiveReader.GetReader(storage, path)) metadata = reader.ReadMetadata(); - if (connection.Table().Count(b => b.BeatmapSetID == metadata.BeatmapSetID) != 0) + if (Connection.Table().Count(b => b.BeatmapSetID == metadata.BeatmapSetID) != 0) return; // TODO: Update this beatmap instead if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader @@ -104,7 +104,7 @@ namespace osu.Game.Database } } } - connection.InsertWithChildren(beatmapSet, true); + Connection.InsertWithChildren(beatmapSet, true); BeatmapSetAdded?.Invoke(beatmapSet); } } @@ -136,25 +136,25 @@ namespace osu.Game.Database public TableQuery Query() where T : class { - return connection.Table(); + return Connection.Table(); } public T GetWithChildren(object id) where T : class { - return connection.GetWithChildren(id); + return Connection.GetWithChildren(id); } public List GetAllWithChildren(Expression> filter = null, bool recursive = true) where T : class { - return connection.GetAllWithChildren(filter, recursive); + return Connection.GetAllWithChildren(filter, recursive); } public T GetChildren(T item, bool recursive = true) { if (item == null) return default(T); - connection.GetChildren(item, recursive); + Connection.GetChildren(item, recursive); return item; } @@ -171,9 +171,9 @@ namespace osu.Game.Database if (!validTypes.Any(t => t == typeof(T))) throw new ArgumentException(nameof(T), "Must be a type managed by BeatmapDatabase"); if (cascade) - connection.UpdateWithChildren(record); + Connection.UpdateWithChildren(record); else - connection.Update(record); + Connection.Update(record); } } }