mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
Use isolated storage/api
This commit is contained in:
parent
654b815b36
commit
c83db94eb7
@ -28,7 +28,7 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
{
|
{
|
||||||
private const float click_padding = 25;
|
private const float click_padding = 25;
|
||||||
|
|
||||||
private GameHost gameHost;
|
private GameHost host;
|
||||||
private TestOsuGame osuGame;
|
private TestOsuGame osuGame;
|
||||||
|
|
||||||
private Vector2 backButtonPosition => osuGame.ToScreenSpace(new Vector2(click_padding, osuGame.LayoutRectangle.Bottom - click_padding));
|
private Vector2 backButtonPosition => osuGame.ToScreenSpace(new Vector2(click_padding, osuGame.LayoutRectangle.Bottom - click_padding));
|
||||||
@ -36,9 +36,9 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
private Vector2 optionsButtonPosition => osuGame.ToScreenSpace(new Vector2(click_padding, click_padding));
|
private Vector2 optionsButtonPosition => osuGame.ToScreenSpace(new Vector2(click_padding, click_padding));
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(GameHost gameHost)
|
private void load(GameHost host)
|
||||||
{
|
{
|
||||||
this.gameHost = gameHost;
|
this.host = host;
|
||||||
|
|
||||||
Child = new Box
|
Child = new Box
|
||||||
{
|
{
|
||||||
@ -58,8 +58,8 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
osuGame.Dispose();
|
osuGame.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
osuGame = new TestOsuGame();
|
osuGame = new TestOsuGame(LocalStorage, API);
|
||||||
osuGame.SetHost(gameHost);
|
osuGame.SetHost(host);
|
||||||
|
|
||||||
Add(osuGame);
|
Add(osuGame);
|
||||||
});
|
});
|
||||||
@ -163,19 +163,16 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
|
|
||||||
protected override Loader CreateLoader() => new TestLoader();
|
protected override Loader CreateLoader() => new TestLoader();
|
||||||
|
|
||||||
private DependencyContainer dependencies;
|
public TestOsuGame(Storage storage, IAPIProvider api)
|
||||||
|
{
|
||||||
private DummyAPIAccess dummyAPI;
|
Storage = storage;
|
||||||
|
API = api;
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
|
}
|
||||||
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
dependencies.CacheAs<IAPIProvider>(dummyAPI = new DummyAPIAccess());
|
API.Login("Rhythm Champion", "osu!");
|
||||||
|
|
||||||
dummyAPI.Login("Rhythm Champion", "osu!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,10 @@ namespace osu.Game.Online.API
|
|||||||
public void Perform(IAPIProvider api)
|
public void Perform(IAPIProvider api)
|
||||||
{
|
{
|
||||||
if (!(api is APIAccess apiAccess))
|
if (!(api is APIAccess apiAccess))
|
||||||
throw new NotSupportedException($"A {nameof(APIAccess)} is required to perform requests.");
|
{
|
||||||
|
Fail(new NotSupportedException($"A {nameof(APIAccess)} is required to perform requests."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
API = apiAccess;
|
API = apiAccess;
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
protected RulesetConfigCache RulesetConfigCache;
|
protected RulesetConfigCache RulesetConfigCache;
|
||||||
|
|
||||||
protected APIAccess API;
|
protected IAPIProvider API;
|
||||||
|
|
||||||
protected MenuCursorContainer MenuCursorContainer;
|
protected MenuCursorContainer MenuCursorContainer;
|
||||||
|
|
||||||
@ -73,6 +73,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
|
protected Storage Storage { get; set; }
|
||||||
|
|
||||||
private Bindable<WorkingBeatmap> beatmap; // cached via load() method
|
private Bindable<WorkingBeatmap> beatmap; // cached via load() method
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
@ -123,7 +125,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.Storage));
|
dependencies.Cache(contextFactory = new DatabaseContextFactory(Storage));
|
||||||
|
|
||||||
var largeStore = new LargeTextureStore(Host.CreateTextureLoaderStore(new NamespacedResourceStore<byte[]>(Resources, @"Textures")));
|
var largeStore = new LargeTextureStore(Host.CreateTextureLoaderStore(new NamespacedResourceStore<byte[]>(Resources, @"Textures")));
|
||||||
largeStore.AddStore(Host.CreateTextureLoaderStore(new OnlineStore()));
|
largeStore.AddStore(Host.CreateTextureLoaderStore(new OnlineStore()));
|
||||||
@ -158,21 +160,21 @@ namespace osu.Game
|
|||||||
|
|
||||||
runMigrations();
|
runMigrations();
|
||||||
|
|
||||||
dependencies.Cache(SkinManager = new SkinManager(Host.Storage, contextFactory, Host, Audio, new NamespacedResourceStore<byte[]>(Resources, "Skins/Legacy")));
|
dependencies.Cache(SkinManager = new SkinManager(Storage, contextFactory, Host, Audio, new NamespacedResourceStore<byte[]>(Resources, "Skins/Legacy")));
|
||||||
dependencies.CacheAs<ISkinSource>(SkinManager);
|
dependencies.CacheAs<ISkinSource>(SkinManager);
|
||||||
|
|
||||||
API = new APIAccess(LocalConfig);
|
if (API == null) API = new APIAccess(LocalConfig);
|
||||||
|
|
||||||
dependencies.CacheAs<IAPIProvider>(API);
|
dependencies.CacheAs(API);
|
||||||
|
|
||||||
var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures);
|
var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures);
|
||||||
|
|
||||||
dependencies.Cache(RulesetStore = new RulesetStore(contextFactory));
|
dependencies.Cache(RulesetStore = new RulesetStore(contextFactory));
|
||||||
dependencies.Cache(FileStore = new FileStore(contextFactory, Host.Storage));
|
dependencies.Cache(FileStore = new FileStore(contextFactory, Storage));
|
||||||
|
|
||||||
// ordering is important here to ensure foreign keys rules are not broken in ModelStore.Cleanup()
|
// ordering is important here to ensure foreign keys rules are not broken in ModelStore.Cleanup()
|
||||||
dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Host.Storage, API, contextFactory, Host));
|
dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, API, contextFactory, Host));
|
||||||
dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, contextFactory, RulesetStore, API, Audio, Host, defaultBeatmap));
|
dependencies.Cache(BeatmapManager = new BeatmapManager(Storage, contextFactory, RulesetStore, API, Audio, Host, defaultBeatmap));
|
||||||
|
|
||||||
// this should likely be moved to ArchiveModelManager when another case appers where it is necessary
|
// this should likely be moved to ArchiveModelManager when another case appers where it is necessary
|
||||||
// to have inter-dependent model managers. this could be obtained with an IHasForeign<T> interface to
|
// to have inter-dependent model managers. this could be obtained with an IHasForeign<T> interface to
|
||||||
@ -206,7 +208,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
FileStore.Cleanup();
|
FileStore.Cleanup();
|
||||||
|
|
||||||
AddInternal(API);
|
if (API is APIAccess apiAcces)
|
||||||
|
AddInternal(apiAcces);
|
||||||
AddInternal(RulesetConfigCache);
|
AddInternal(RulesetConfigCache);
|
||||||
|
|
||||||
GlobalActionContainer globalBinding;
|
GlobalActionContainer globalBinding;
|
||||||
@ -266,9 +269,13 @@ namespace osu.Game
|
|||||||
|
|
||||||
public override void SetHost(GameHost host)
|
public override void SetHost(GameHost host)
|
||||||
{
|
{
|
||||||
if (LocalConfig == null)
|
|
||||||
LocalConfig = new OsuConfigManager(host.Storage);
|
|
||||||
base.SetHost(host);
|
base.SetHost(host);
|
||||||
|
|
||||||
|
if (Storage == null)
|
||||||
|
Storage = host.Storage;
|
||||||
|
|
||||||
|
if (LocalConfig == null)
|
||||||
|
LocalConfig = new OsuConfigManager(Storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly List<ICanAcceptFiles> fileImporters = new List<ICanAcceptFiles>();
|
private readonly List<ICanAcceptFiles> fileImporters = new List<ICanAcceptFiles>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user