mirror of
https://github.com/osukey/osukey.git
synced 2025-05-22 05:57:35 +09:00
Merge branch 'master' into pause-input-fixes
This commit is contained in:
commit
7cc999027d
@ -16,7 +16,6 @@ using osu.Game.Rulesets;
|
|||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
using osu.Game.Screens.Select.Carousel;
|
using osu.Game.Screens.Select.Carousel;
|
||||||
using osu.Game.Screens.Select.Filter;
|
using osu.Game.Screens.Select.Filter;
|
||||||
using osu.Game.Tests.Platform;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
@ -28,6 +27,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
private RulesetStore rulesets;
|
private RulesetStore rulesets;
|
||||||
|
|
||||||
private WorkingBeatmap defaultBeatmap;
|
private WorkingBeatmap defaultBeatmap;
|
||||||
|
private DatabaseContextFactory factory;
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
@ -59,13 +59,14 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
TestSongSelect songSelect = null;
|
TestSongSelect songSelect = null;
|
||||||
|
|
||||||
var storage = new TestStorage(@"TestCasePlaySongSelect");
|
factory = new DatabaseContextFactory(LocalStorage);
|
||||||
|
factory.ResetDatabase();
|
||||||
|
|
||||||
// this is by no means clean. should be replacing inside of OsuGameBase somehow.
|
using (var usage = factory.Get())
|
||||||
IDatabaseContextFactory factory = new SingletonContextFactory(new OsuDbContext());
|
usage.Migrate();
|
||||||
|
|
||||||
Dependencies.Cache(rulesets = new RulesetStore(factory));
|
Dependencies.Cache(rulesets = new RulesetStore(factory));
|
||||||
Dependencies.Cache(manager = new BeatmapManager(storage, factory, rulesets, null, null)
|
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, null)
|
||||||
{
|
{
|
||||||
DefaultBeatmap = defaultBeatmap = Beatmap.Default
|
DefaultBeatmap = defaultBeatmap = Beatmap.Default
|
||||||
});
|
});
|
||||||
|
@ -11,7 +11,7 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
public class DatabaseContextFactory : IDatabaseContextFactory
|
public class DatabaseContextFactory : IDatabaseContextFactory
|
||||||
{
|
{
|
||||||
private readonly GameHost host;
|
private readonly Storage storage;
|
||||||
|
|
||||||
private const string database_name = @"client";
|
private const string database_name = @"client";
|
||||||
|
|
||||||
@ -26,9 +26,9 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
private IDbContextTransaction currentWriteTransaction;
|
private IDbContextTransaction currentWriteTransaction;
|
||||||
|
|
||||||
public DatabaseContextFactory(GameHost host)
|
public DatabaseContextFactory(Storage storage)
|
||||||
{
|
{
|
||||||
this.host = host;
|
this.storage = storage;
|
||||||
recycleThreadContexts();
|
recycleThreadContexts();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
private void recycleThreadContexts() => threadContexts = new ThreadLocal<OsuDbContext>(CreateContext);
|
private void recycleThreadContexts() => threadContexts = new ThreadLocal<OsuDbContext>(CreateContext);
|
||||||
|
|
||||||
protected virtual OsuDbContext CreateContext() => new OsuDbContext(host.Storage.GetDatabaseConnectionString(database_name))
|
protected virtual OsuDbContext CreateContext() => new OsuDbContext(storage.GetDatabaseConnectionString(database_name))
|
||||||
{
|
{
|
||||||
Database = { AutoTransactionsEnabled = false }
|
Database = { AutoTransactionsEnabled = false }
|
||||||
};
|
};
|
||||||
@ -129,7 +129,7 @@ namespace osu.Game.Database
|
|||||||
recycleThreadContexts();
|
recycleThreadContexts();
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
GC.WaitForPendingFinalizers();
|
GC.WaitForPendingFinalizers();
|
||||||
host.Storage.DeleteDatabase(database_name);
|
storage.DeleteDatabase(database_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
||||||
|
|
||||||
namespace osu.Game.Database
|
|
||||||
{
|
|
||||||
public class SingletonContextFactory : IDatabaseContextFactory
|
|
||||||
{
|
|
||||||
private readonly OsuDbContext context;
|
|
||||||
|
|
||||||
public SingletonContextFactory(OsuDbContext context)
|
|
||||||
{
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OsuDbContext Get() => context;
|
|
||||||
|
|
||||||
public DatabaseWriteUsage GetForWrite(bool withTransaction = true) => new DatabaseWriteUsage(context, null);
|
|
||||||
}
|
|
||||||
}
|
|
@ -107,7 +107,7 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
Resources.AddStore(new DllResourceStore(@"osu.Game.Resources.dll"));
|
Resources.AddStore(new DllResourceStore(@"osu.Game.Resources.dll"));
|
||||||
|
|
||||||
dependencies.Cache(contextFactory = new DatabaseContextFactory(Host));
|
dependencies.Cache(contextFactory = new DatabaseContextFactory(Host.Storage));
|
||||||
|
|
||||||
dependencies.Cache(new LargeTextureStore(new RawTextureLoaderStore(new NamespacedResourceStore<byte[]>(Resources, @"Textures"))));
|
dependencies.Cache(new LargeTextureStore(new RawTextureLoaderStore(new NamespacedResourceStore<byte[]>(Resources, @"Textures"))));
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
{
|
{
|
||||||
string[] split = text.Split(',');
|
string[] split = text.Split(',');
|
||||||
|
|
||||||
|
Vector2 pos = new Vector2((int)Convert.ToSingle(split[0], CultureInfo.InvariantCulture), (int)Convert.ToSingle(split[1], CultureInfo.InvariantCulture));
|
||||||
|
|
||||||
ConvertHitObjectType type = (ConvertHitObjectType)int.Parse(split[3]) & ~ConvertHitObjectType.ColourHax;
|
ConvertHitObjectType type = (ConvertHitObjectType)int.Parse(split[3]) & ~ConvertHitObjectType.ColourHax;
|
||||||
bool combo = type.HasFlag(ConvertHitObjectType.NewCombo);
|
bool combo = type.HasFlag(ConvertHitObjectType.NewCombo);
|
||||||
type &= ~ConvertHitObjectType.NewCombo;
|
type &= ~ConvertHitObjectType.NewCombo;
|
||||||
@ -41,15 +43,13 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
|
|
||||||
if (type.HasFlag(ConvertHitObjectType.Circle))
|
if (type.HasFlag(ConvertHitObjectType.Circle))
|
||||||
{
|
{
|
||||||
result = CreateHit(new Vector2(int.Parse(split[0]), int.Parse(split[1])), combo);
|
result = CreateHit(pos, combo);
|
||||||
|
|
||||||
if (split.Length > 5)
|
if (split.Length > 5)
|
||||||
readCustomSampleBanks(split[5], bankInfo);
|
readCustomSampleBanks(split[5], bankInfo);
|
||||||
}
|
}
|
||||||
else if (type.HasFlag(ConvertHitObjectType.Slider))
|
else if (type.HasFlag(ConvertHitObjectType.Slider))
|
||||||
{
|
{
|
||||||
var pos = new Vector2(int.Parse(split[0]), int.Parse(split[1]));
|
|
||||||
|
|
||||||
CurveType curveType = CurveType.Catmull;
|
CurveType curveType = CurveType.Catmull;
|
||||||
double length = 0;
|
double length = 0;
|
||||||
var points = new List<Vector2> { Vector2.Zero };
|
var points = new List<Vector2> { Vector2.Zero };
|
||||||
@ -170,7 +170,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
readCustomSampleBanks(string.Join(":", ss.Skip(1)), bankInfo);
|
readCustomSampleBanks(string.Join(":", ss.Skip(1)), bankInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = CreateHold(new Vector2(int.Parse(split[0]), int.Parse(split[1])), combo, endTime + offset);
|
result = CreateHold(pos, combo, endTime + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == null)
|
if (result == null)
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
||||||
|
|
||||||
using osu.Framework.Platform;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Platform
|
|
||||||
{
|
|
||||||
public class TestStorage : DesktopStorage
|
|
||||||
{
|
|
||||||
public TestStorage(string baseName) : base(baseName, null)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string GetDatabaseConnectionString(string name)
|
|
||||||
{
|
|
||||||
return "DataSource=:memory:";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +1,12 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -20,6 +22,9 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
protected DependencyContainer Dependencies { get; private set; }
|
protected DependencyContainer Dependencies { get; private set; }
|
||||||
|
|
||||||
|
private readonly Lazy<Storage> localStorage;
|
||||||
|
protected Storage LocalStorage => localStorage.Value;
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
{
|
{
|
||||||
Dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
Dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
@ -33,6 +38,11 @@ namespace osu.Game.Tests.Visual
|
|||||||
return Dependencies;
|
return Dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected OsuTestCase()
|
||||||
|
{
|
||||||
|
localStorage = new Lazy<Storage>(() => new DesktopStorage($"{GetType().Name}-{Guid.NewGuid()}", null));
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audioManager, RulesetStore rulesets)
|
private void load(AudioManager audioManager, RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
@ -50,6 +60,9 @@ namespace osu.Game.Tests.Visual
|
|||||||
beatmap.Disabled = true;
|
beatmap.Disabled = true;
|
||||||
beatmap.Value.Track.Stop();
|
beatmap.Value.Track.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (localStorage.IsValueCreated)
|
||||||
|
localStorage.Value.DeleteDirectory(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ITestCaseTestRunner CreateRunner() => new OsuTestCaseTestRunner();
|
protected override ITestCaseTestRunner CreateRunner() => new OsuTestCaseTestRunner();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user