mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 07:43:00 +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 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,
|
||||
WorkingBeatmap? defaultBeatmap = null, BeatmapDifficultyCache? difficultyCache = null, bool performOnlineLookups = false)
|
||||
: base(storage, realm)
|
||||
@ -62,7 +72,6 @@ namespace osu.Game.Beatmaps
|
||||
BeatmapTrackStore = audioManager.GetTrackStore(userResources);
|
||||
|
||||
beatmapImporter = CreateBeatmapImporter(storage, realm);
|
||||
beatmapImporter.PauseImports.BindTo(PauseImports);
|
||||
beatmapImporter.ProcessBeatmap = args => ProcessBeatmap?.Invoke(args);
|
||||
beatmapImporter.PostNotification = obj => PostNotification?.Invoke(obj);
|
||||
|
||||
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Extensions;
|
||||
@ -22,7 +21,7 @@ namespace osu.Game.Database
|
||||
/// <summary>
|
||||
/// Temporarily pause imports to avoid performance overheads affecting gameplay scenarios.
|
||||
/// </summary>
|
||||
public readonly BindableBool PauseImports = new BindableBool();
|
||||
public virtual bool PauseImports { get; set; }
|
||||
|
||||
protected RealmAccess Realm { get; }
|
||||
|
||||
|
@ -8,7 +8,6 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Humanizer;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Logging;
|
||||
@ -60,7 +59,7 @@ namespace osu.Game.Database
|
||||
/// <summary>
|
||||
/// Temporarily pause imports to avoid performance overheads affecting gameplay scenarios.
|
||||
/// </summary>
|
||||
public readonly BindableBool PauseImports = new BindableBool();
|
||||
public bool PauseImports { get; set; }
|
||||
|
||||
public abstract IEnumerable<string> HandledExtensions { get; }
|
||||
|
||||
@ -559,12 +558,12 @@ namespace osu.Game.Database
|
||||
|
||||
private void pauseIfNecessary(CancellationToken cancellationToken)
|
||||
{
|
||||
if (!PauseImports.Value)
|
||||
if (!PauseImports)
|
||||
return;
|
||||
|
||||
Logger.Log(@"Import is being paused.");
|
||||
|
||||
while (PauseImports.Value)
|
||||
while (PauseImports)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
Thread.Sleep(500);
|
||||
|
@ -307,9 +307,12 @@ namespace osu.Game
|
||||
// Transfer any runtime changes back to configuration file.
|
||||
SkinManager.CurrentSkinInfo.ValueChanged += skin => configSkin.Value = skin.NewValue.ID.ToString();
|
||||
|
||||
BeatmapManager.PauseImports.BindTo(LocalUserPlaying);
|
||||
SkinManager.PauseImports.BindTo(LocalUserPlaying);
|
||||
ScoreManager.PauseImports.BindTo(LocalUserPlaying);
|
||||
LocalUserPlaying.BindValueChanged(p =>
|
||||
{
|
||||
BeatmapManager.PauseImports = p.NewValue;
|
||||
SkinManager.PauseImports = p.NewValue;
|
||||
ScoreManager.PauseImports = p.NewValue;
|
||||
}, true);
|
||||
|
||||
IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true);
|
||||
|
||||
|
@ -28,6 +28,16 @@ namespace osu.Game.Scoring
|
||||
private readonly OsuConfigManager configManager;
|
||||
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,
|
||||
OsuConfigManager configManager = null)
|
||||
: base(storage, realm)
|
||||
@ -38,8 +48,6 @@ namespace osu.Game.Scoring
|
||||
{
|
||||
PostNotification = obj => PostNotification?.Invoke(obj)
|
||||
};
|
||||
|
||||
scoreImporter.PauseImports.BindTo(PauseImports);
|
||||
}
|
||||
|
||||
public Score GetScore(ScoreInfo score) => scoreImporter.GetScore(score);
|
||||
|
@ -64,6 +64,16 @@ namespace osu.Game.Skinning
|
||||
|
||||
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)
|
||||
: base(storage, realm)
|
||||
{
|
||||
@ -79,8 +89,6 @@ namespace osu.Game.Skinning
|
||||
PostNotification = obj => PostNotification?.Invoke(obj),
|
||||
};
|
||||
|
||||
skinImporter.PauseImports.BindTo(PauseImports);
|
||||
|
||||
var defaultSkins = new[]
|
||||
{
|
||||
DefaultClassicSkin = new DefaultLegacySkin(this),
|
||||
|
Loading…
Reference in New Issue
Block a user