mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 09:22:54 +08:00
Notify of existing imports
This commit is contained in:
parent
aaf3e650a5
commit
a88b69ec43
@ -102,7 +102,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
int fireCount = 0;
|
int fireCount = 0;
|
||||||
|
|
||||||
// ReSharper disable once AccessToModifiedClosure
|
// ReSharper disable once AccessToModifiedClosure
|
||||||
manager.ItemAdded += _ => fireCount++;
|
manager.ItemAdded += (_, __) => fireCount++;
|
||||||
manager.ItemRemoved += _ => fireCount++;
|
manager.ItemRemoved += _ => fireCount++;
|
||||||
|
|
||||||
var imported = loadOszIntoOsu(osu);
|
var imported = loadOszIntoOsu(osu);
|
||||||
|
@ -78,7 +78,7 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAdded(BeatmapSetInfo s) => Schedule(() =>
|
private void setAdded(BeatmapSetInfo s, bool existing) => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (s.OnlineBeatmapSetID == set.OnlineBeatmapSetID)
|
if (s.OnlineBeatmapSetID == set.OnlineBeatmapSetID)
|
||||||
DownloadState.Value = DownloadStatus.Downloaded;
|
DownloadState.Value = DownloadStatus.Downloaded;
|
||||||
|
@ -31,6 +31,8 @@ namespace osu.Game.Database
|
|||||||
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete
|
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete
|
||||||
where TFileModel : INamedFileInfo, new()
|
where TFileModel : INamedFileInfo, new()
|
||||||
{
|
{
|
||||||
|
public delegate void ItemAddedDelegate(TModel model, bool existing);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set an endpoint for notifications to be posted to.
|
/// Set an endpoint for notifications to be posted to.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -40,7 +42,7 @@ namespace osu.Game.Database
|
|||||||
/// Fired when a new <see cref="TModel"/> becomes available in the database.
|
/// Fired when a new <see cref="TModel"/> becomes available in the database.
|
||||||
/// This is not guaranteed to run on the update thread.
|
/// This is not guaranteed to run on the update thread.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action<TModel> ItemAdded;
|
public event ItemAddedDelegate ItemAdded;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fired when a <see cref="TModel"/> is removed from the database.
|
/// Fired when a <see cref="TModel"/> is removed from the database.
|
||||||
@ -107,7 +109,7 @@ namespace osu.Game.Database
|
|||||||
ContextFactory = contextFactory;
|
ContextFactory = contextFactory;
|
||||||
|
|
||||||
ModelStore = modelStore;
|
ModelStore = modelStore;
|
||||||
ModelStore.ItemAdded += s => handleEvent(() => ItemAdded?.Invoke(s));
|
ModelStore.ItemAdded += s => handleEvent(() => ItemAdded?.Invoke(s, false));
|
||||||
ModelStore.ItemRemoved += s => handleEvent(() => ItemRemoved?.Invoke(s));
|
ModelStore.ItemRemoved += s => handleEvent(() => ItemRemoved?.Invoke(s));
|
||||||
|
|
||||||
Files = new FileStore(contextFactory, storage);
|
Files = new FileStore(contextFactory, storage);
|
||||||
@ -236,6 +238,7 @@ namespace osu.Game.Database
|
|||||||
if (existing != null)
|
if (existing != null)
|
||||||
{
|
{
|
||||||
Logger.Log($"Found existing {typeof(TModel)} for {item} (ID {existing.ID}). Skipping import.", LoggingTarget.Database);
|
Logger.Log($"Found existing {typeof(TModel)} for {item} (ID {existing.ID}). Skipping import.", LoggingTarget.Database);
|
||||||
|
handleEvent(() => ItemAdded?.Invoke(existing, true));
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
this.frameworkConfig = frameworkConfig;
|
this.frameworkConfig = frameworkConfig;
|
||||||
|
|
||||||
ScoreManager.ItemAdded += score => Schedule(() => LoadScore(score));
|
ScoreManager.ItemAdded += (score, _) => Schedule(() => LoadScore(score));
|
||||||
|
|
||||||
if (!Host.IsPrimaryInstance)
|
if (!Host.IsPrimaryInstance)
|
||||||
{
|
{
|
||||||
|
@ -174,7 +174,7 @@ namespace osu.Game.Overlays.Direct
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAdded(BeatmapSetInfo s) => Schedule(() =>
|
private void setAdded(BeatmapSetInfo s, bool existing) => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (s.OnlineBeatmapSetID == SetInfo.OnlineBeatmapSetID)
|
if (s.OnlineBeatmapSetID == SetInfo.OnlineBeatmapSetID)
|
||||||
progressBar.FadeOut(500);
|
progressBar.FadeOut(500);
|
||||||
|
@ -75,7 +75,7 @@ namespace osu.Game.Overlays.Music
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(BeatmapManager beatmaps, IBindableBeatmap beatmap)
|
private void load(BeatmapManager beatmaps, IBindableBeatmap beatmap)
|
||||||
{
|
{
|
||||||
beatmaps.GetAllUsableBeatmapSets().ForEach(addBeatmapSet);
|
beatmaps.GetAllUsableBeatmapSets().ForEach(b => addBeatmapSet(b, false));
|
||||||
beatmaps.ItemAdded += addBeatmapSet;
|
beatmaps.ItemAdded += addBeatmapSet;
|
||||||
beatmaps.ItemRemoved += removeBeatmapSet;
|
beatmaps.ItemRemoved += removeBeatmapSet;
|
||||||
|
|
||||||
@ -83,8 +83,11 @@ namespace osu.Game.Overlays.Music
|
|||||||
beatmapBacking.ValueChanged += _ => updateSelectedSet();
|
beatmapBacking.ValueChanged += _ => updateSelectedSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addBeatmapSet(BeatmapSetInfo obj) => Schedule(() =>
|
private void addBeatmapSet(BeatmapSetInfo obj, bool existing) => Schedule(() =>
|
||||||
{
|
{
|
||||||
|
if (existing)
|
||||||
|
return;
|
||||||
|
|
||||||
var newItem = new PlaylistItem(obj) { OnSelect = set => Selected?.Invoke(set) };
|
var newItem = new PlaylistItem(obj) { OnSelect = set => Selected?.Invoke(set) };
|
||||||
|
|
||||||
items.Add(newItem);
|
items.Add(newItem);
|
||||||
|
@ -214,7 +214,14 @@ namespace osu.Game.Overlays
|
|||||||
beatmapSets.Insert(index, beatmapSetInfo);
|
beatmapSets.Insert(index, beatmapSetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleBeatmapAdded(BeatmapSetInfo obj) => Schedule(() => beatmapSets.Add(obj));
|
private void handleBeatmapAdded(BeatmapSetInfo obj, bool existing)
|
||||||
|
{
|
||||||
|
if (existing)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Schedule(() => beatmapSets.Add(obj));
|
||||||
|
}
|
||||||
|
|
||||||
private void handleBeatmapRemoved(BeatmapSetInfo obj) => Schedule(() => beatmapSets.RemoveAll(s => s.ID == obj.ID));
|
private void handleBeatmapRemoved(BeatmapSetInfo obj) => Schedule(() => beatmapSets.RemoveAll(s => s.ID == obj.ID));
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
@ -71,7 +71,14 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void itemRemoved(SkinInfo s) => Schedule(() => skinDropdown.Items = skinDropdown.Items.Where(i => i.ID != s.ID).ToArray());
|
private void itemRemoved(SkinInfo s) => Schedule(() => skinDropdown.Items = skinDropdown.Items.Where(i => i.ID != s.ID).ToArray());
|
||||||
private void itemAdded(SkinInfo s) => Schedule(() => skinDropdown.Items = skinDropdown.Items.Append(s).ToArray());
|
|
||||||
|
private void itemAdded(SkinInfo s, bool existing)
|
||||||
|
{
|
||||||
|
if (existing)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Schedule(() => skinDropdown.Items = skinDropdown.Items.Append(s).ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
|
@ -503,7 +503,7 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onBeatmapSetAdded(BeatmapSetInfo s) => Carousel.UpdateBeatmapSet(s);
|
private void onBeatmapSetAdded(BeatmapSetInfo s, bool existing) => Carousel.UpdateBeatmapSet(s);
|
||||||
private void onBeatmapSetRemoved(BeatmapSetInfo s) => Carousel.RemoveBeatmapSet(s);
|
private void onBeatmapSetRemoved(BeatmapSetInfo s) => Carousel.RemoveBeatmapSet(s);
|
||||||
private void onBeatmapRestored(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
private void onBeatmapRestored(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
||||||
private void onBeatmapHidden(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
private void onBeatmapHidden(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
||||||
|
Loading…
Reference in New Issue
Block a user