mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 09:03:01 +08:00
Don't use bindables to avoid potential cross-usage contamination
This commit is contained in:
parent
62ffb4fe78
commit
811a562608
@ -44,6 +44,16 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public Action<(BeatmapSetInfo beatmapSet, bool isBatch)>? ProcessBeatmap { private get; set; }
|
public Action<(BeatmapSetInfo beatmapSet, bool isBatch)>? ProcessBeatmap { private get; set; }
|
||||||
|
|
||||||
|
public override bool PauseImports
|
||||||
|
{
|
||||||
|
get => base.PauseImports;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.PauseImports = value;
|
||||||
|
beatmapImporter.PauseImports = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public BeatmapManager(Storage storage, RealmAccess realm, IAPIProvider? api, AudioManager audioManager, IResourceStore<byte[]> gameResources, GameHost? host = null,
|
public BeatmapManager(Storage storage, RealmAccess realm, IAPIProvider? api, AudioManager audioManager, IResourceStore<byte[]> gameResources, GameHost? host = null,
|
||||||
WorkingBeatmap? defaultBeatmap = null, BeatmapDifficultyCache? difficultyCache = null, bool performOnlineLookups = false)
|
WorkingBeatmap? defaultBeatmap = null, BeatmapDifficultyCache? difficultyCache = null, bool performOnlineLookups = false)
|
||||||
: base(storage, realm)
|
: base(storage, realm)
|
||||||
@ -62,7 +72,6 @@ namespace osu.Game.Beatmaps
|
|||||||
BeatmapTrackStore = audioManager.GetTrackStore(userResources);
|
BeatmapTrackStore = audioManager.GetTrackStore(userResources);
|
||||||
|
|
||||||
beatmapImporter = CreateBeatmapImporter(storage, realm);
|
beatmapImporter = CreateBeatmapImporter(storage, realm);
|
||||||
beatmapImporter.PauseImports.BindTo(PauseImports);
|
|
||||||
beatmapImporter.ProcessBeatmap = args => ProcessBeatmap?.Invoke(args);
|
beatmapImporter.ProcessBeatmap = args => ProcessBeatmap?.Invoke(args);
|
||||||
beatmapImporter.PostNotification = obj => PostNotification?.Invoke(obj);
|
beatmapImporter.PostNotification = obj => PostNotification?.Invoke(obj);
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Extensions;
|
using osu.Game.Extensions;
|
||||||
@ -22,7 +21,7 @@ namespace osu.Game.Database
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Temporarily pause imports to avoid performance overheads affecting gameplay scenarios.
|
/// Temporarily pause imports to avoid performance overheads affecting gameplay scenarios.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly BindableBool PauseImports = new BindableBool();
|
public virtual bool PauseImports { get; set; }
|
||||||
|
|
||||||
protected RealmAccess Realm { get; }
|
protected RealmAccess Realm { get; }
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ using System.Linq;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
@ -60,7 +59,7 @@ namespace osu.Game.Database
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Temporarily pause imports to avoid performance overheads affecting gameplay scenarios.
|
/// Temporarily pause imports to avoid performance overheads affecting gameplay scenarios.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly BindableBool PauseImports = new BindableBool();
|
public bool PauseImports { get; set; }
|
||||||
|
|
||||||
public abstract IEnumerable<string> HandledExtensions { get; }
|
public abstract IEnumerable<string> HandledExtensions { get; }
|
||||||
|
|
||||||
@ -559,12 +558,12 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
private void pauseIfNecessary(CancellationToken cancellationToken)
|
private void pauseIfNecessary(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (!PauseImports.Value)
|
if (!PauseImports)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Logger.Log(@"Import is being paused.");
|
Logger.Log(@"Import is being paused.");
|
||||||
|
|
||||||
while (PauseImports.Value)
|
while (PauseImports)
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
|
@ -307,9 +307,12 @@ namespace osu.Game
|
|||||||
// Transfer any runtime changes back to configuration file.
|
// Transfer any runtime changes back to configuration file.
|
||||||
SkinManager.CurrentSkinInfo.ValueChanged += skin => configSkin.Value = skin.NewValue.ID.ToString();
|
SkinManager.CurrentSkinInfo.ValueChanged += skin => configSkin.Value = skin.NewValue.ID.ToString();
|
||||||
|
|
||||||
BeatmapManager.PauseImports.BindTo(LocalUserPlaying);
|
LocalUserPlaying.BindValueChanged(p =>
|
||||||
SkinManager.PauseImports.BindTo(LocalUserPlaying);
|
{
|
||||||
ScoreManager.PauseImports.BindTo(LocalUserPlaying);
|
BeatmapManager.PauseImports = p.NewValue;
|
||||||
|
SkinManager.PauseImports = p.NewValue;
|
||||||
|
ScoreManager.PauseImports = p.NewValue;
|
||||||
|
}, true);
|
||||||
|
|
||||||
IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true);
|
IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true);
|
||||||
|
|
||||||
|
@ -28,6 +28,16 @@ namespace osu.Game.Scoring
|
|||||||
private readonly OsuConfigManager configManager;
|
private readonly OsuConfigManager configManager;
|
||||||
private readonly ScoreImporter scoreImporter;
|
private readonly ScoreImporter scoreImporter;
|
||||||
|
|
||||||
|
public override bool PauseImports
|
||||||
|
{
|
||||||
|
get => base.PauseImports;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.PauseImports = value;
|
||||||
|
scoreImporter.PauseImports = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, RealmAccess realm, IAPIProvider api,
|
public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, RealmAccess realm, IAPIProvider api,
|
||||||
OsuConfigManager configManager = null)
|
OsuConfigManager configManager = null)
|
||||||
: base(storage, realm)
|
: base(storage, realm)
|
||||||
@ -38,8 +48,6 @@ namespace osu.Game.Scoring
|
|||||||
{
|
{
|
||||||
PostNotification = obj => PostNotification?.Invoke(obj)
|
PostNotification = obj => PostNotification?.Invoke(obj)
|
||||||
};
|
};
|
||||||
|
|
||||||
scoreImporter.PauseImports.BindTo(PauseImports);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Score GetScore(ScoreInfo score) => scoreImporter.GetScore(score);
|
public Score GetScore(ScoreInfo score) => scoreImporter.GetScore(score);
|
||||||
|
@ -64,6 +64,16 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
private Skin trianglesSkin { get; }
|
private Skin trianglesSkin { get; }
|
||||||
|
|
||||||
|
public override bool PauseImports
|
||||||
|
{
|
||||||
|
get => base.PauseImports;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.PauseImports = value;
|
||||||
|
skinImporter.PauseImports = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public SkinManager(Storage storage, RealmAccess realm, GameHost host, IResourceStore<byte[]> resources, AudioManager audio, Scheduler scheduler)
|
public SkinManager(Storage storage, RealmAccess realm, GameHost host, IResourceStore<byte[]> resources, AudioManager audio, Scheduler scheduler)
|
||||||
: base(storage, realm)
|
: base(storage, realm)
|
||||||
{
|
{
|
||||||
@ -79,8 +89,6 @@ namespace osu.Game.Skinning
|
|||||||
PostNotification = obj => PostNotification?.Invoke(obj),
|
PostNotification = obj => PostNotification?.Invoke(obj),
|
||||||
};
|
};
|
||||||
|
|
||||||
skinImporter.PauseImports.BindTo(PauseImports);
|
|
||||||
|
|
||||||
var defaultSkins = new[]
|
var defaultSkins = new[]
|
||||||
{
|
{
|
||||||
DefaultClassicSkin = new DefaultLegacySkin(this),
|
DefaultClassicSkin = new DefaultLegacySkin(this),
|
||||||
|
Loading…
Reference in New Issue
Block a user