mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Add silent import parameter
This commit is contained in:
@ -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, bool existing) => Schedule(() =>
|
private void setAdded(BeatmapSetInfo s, bool existing, bool silent) => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (s.OnlineBeatmapSetID == set.OnlineBeatmapSetID)
|
if (s.OnlineBeatmapSetID == set.OnlineBeatmapSetID)
|
||||||
DownloadState.Value = DownloadStatus.Downloaded;
|
DownloadState.Value = DownloadStatus.Downloaded;
|
||||||
|
@ -32,7 +32,7 @@ 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);
|
public delegate void ItemAddedDelegate(TModel model, bool existing, bool silent);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set an endpoint for notifications to be posted to.
|
/// Set an endpoint for notifications to be posted to.
|
||||||
@ -110,7 +110,7 @@ namespace osu.Game.Database
|
|||||||
ContextFactory = contextFactory;
|
ContextFactory = contextFactory;
|
||||||
|
|
||||||
ModelStore = modelStore;
|
ModelStore = modelStore;
|
||||||
ModelStore.ItemAdded += s => handleEvent(() => ItemAdded?.Invoke(s, false));
|
ModelStore.ItemAdded += (item, silent) => handleEvent(() => ItemAdded?.Invoke(item, false, silent));
|
||||||
ModelStore.ItemRemoved += s => handleEvent(() => ItemRemoved?.Invoke(s));
|
ModelStore.ItemRemoved += s => handleEvent(() => ItemRemoved?.Invoke(s));
|
||||||
|
|
||||||
Files = new FileStore(contextFactory, storage);
|
Files = new FileStore(contextFactory, storage);
|
||||||
@ -211,7 +211,7 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
model.Hash = computeHash(archive);
|
model.Hash = computeHash(archive);
|
||||||
|
|
||||||
return Import(model, archive);
|
return Import(model, false, archive);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -245,8 +245,9 @@ namespace osu.Game.Database
|
|||||||
/// Import an item from a <see cref="TModel"/>.
|
/// Import an item from a <see cref="TModel"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The model to be imported.</param>
|
/// <param name="item">The model to be imported.</param>
|
||||||
|
/// <param name="silent">Whether the user should be notified fo the import.</param>
|
||||||
/// <param name="archive">An optional archive to use for model population.</param>
|
/// <param name="archive">An optional archive to use for model population.</param>
|
||||||
public TModel Import(TModel item, ArchiveReader archive = null)
|
public TModel Import(TModel item, bool silent = false, ArchiveReader archive = null)
|
||||||
{
|
{
|
||||||
delayEvents();
|
delayEvents();
|
||||||
|
|
||||||
@ -266,7 +267,7 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
Undelete(existing);
|
Undelete(existing);
|
||||||
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));
|
handleEvent(() => ItemAdded?.Invoke(existing, true, silent));
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +277,7 @@ namespace osu.Game.Database
|
|||||||
Populate(item, archive);
|
Populate(item, archive);
|
||||||
|
|
||||||
// import to store
|
// import to store
|
||||||
ModelStore.Add(item);
|
ModelStore.Add(item, silent);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,9 @@ namespace osu.Game.Database
|
|||||||
public abstract class MutableDatabaseBackedStore<T> : DatabaseBackedStore
|
public abstract class MutableDatabaseBackedStore<T> : DatabaseBackedStore
|
||||||
where T : class, IHasPrimaryKey, ISoftDelete
|
where T : class, IHasPrimaryKey, ISoftDelete
|
||||||
{
|
{
|
||||||
public event Action<T> ItemAdded;
|
public delegate void ItemAddedDelegate(T model, bool silent);
|
||||||
|
|
||||||
|
public event ItemAddedDelegate ItemAdded;
|
||||||
public event Action<T> ItemRemoved;
|
public event Action<T> ItemRemoved;
|
||||||
|
|
||||||
protected MutableDatabaseBackedStore(IDatabaseContextFactory contextFactory, Storage storage = null)
|
protected MutableDatabaseBackedStore(IDatabaseContextFactory contextFactory, Storage storage = null)
|
||||||
@ -33,7 +35,8 @@ namespace osu.Game.Database
|
|||||||
/// Add a <see cref="T"/> to the database.
|
/// Add a <see cref="T"/> to the database.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The item to add.</param>
|
/// <param name="item">The item to add.</param>
|
||||||
public void Add(T item)
|
/// <param name="silent">Whether the user should be notified of the addition.</param>
|
||||||
|
public void Add(T item, bool silent)
|
||||||
{
|
{
|
||||||
using (var usage = ContextFactory.GetForWrite())
|
using (var usage = ContextFactory.GetForWrite())
|
||||||
{
|
{
|
||||||
@ -41,7 +44,7 @@ namespace osu.Game.Database
|
|||||||
context.Attach(item);
|
context.Attach(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemAdded?.Invoke(item);
|
ItemAdded?.Invoke(item, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -54,7 +57,7 @@ namespace osu.Game.Database
|
|||||||
usage.Context.Update(item);
|
usage.Context.Update(item);
|
||||||
|
|
||||||
ItemRemoved?.Invoke(item);
|
ItemRemoved?.Invoke(item);
|
||||||
ItemAdded?.Invoke(item);
|
ItemAdded?.Invoke(item, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -89,7 +92,7 @@ namespace osu.Game.Database
|
|||||||
item.DeletePending = false;
|
item.DeletePending = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemAdded?.Invoke(item);
|
ItemAdded?.Invoke(item, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
this.frameworkConfig = frameworkConfig;
|
this.frameworkConfig = frameworkConfig;
|
||||||
|
|
||||||
ScoreManager.ItemAdded += (score, _) => Schedule(() => LoadScore(score));
|
ScoreManager.ItemAdded += (score, _, silent) => Schedule(() => LoadScore(score, silent));
|
||||||
|
|
||||||
if (!Host.IsPrimaryInstance)
|
if (!Host.IsPrimaryInstance)
|
||||||
{
|
{
|
||||||
@ -248,15 +248,18 @@ namespace osu.Game
|
|||||||
/// <param name="beatmapId">The beatmap to show.</param>
|
/// <param name="beatmapId">The beatmap to show.</param>
|
||||||
public void ShowBeatmap(int beatmapId) => beatmapSetOverlay.FetchAndShowBeatmap(beatmapId);
|
public void ShowBeatmap(int beatmapId) => beatmapSetOverlay.FetchAndShowBeatmap(beatmapId);
|
||||||
|
|
||||||
protected void LoadScore(ScoreInfo score)
|
protected void LoadScore(ScoreInfo score, bool silent)
|
||||||
{
|
{
|
||||||
|
if (silent)
|
||||||
|
return;
|
||||||
|
|
||||||
scoreLoad?.Cancel();
|
scoreLoad?.Cancel();
|
||||||
|
|
||||||
var menu = intro.ChildScreen;
|
var menu = intro.ChildScreen;
|
||||||
|
|
||||||
if (menu == null)
|
if (menu == null)
|
||||||
{
|
{
|
||||||
scoreLoad = Schedule(() => LoadScore(score));
|
scoreLoad = Schedule(() => LoadScore(score, false));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ namespace osu.Game.Overlays.Direct
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAdded(BeatmapSetInfo s, bool existing) => Schedule(() =>
|
private void setAdded(BeatmapSetInfo s, bool existing, bool silent) => 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(b => addBeatmapSet(b, false));
|
beatmaps.GetAllUsableBeatmapSets().ForEach(b => addBeatmapSet(b, false, false));
|
||||||
beatmaps.ItemAdded += addBeatmapSet;
|
beatmaps.ItemAdded += addBeatmapSet;
|
||||||
beatmaps.ItemRemoved += removeBeatmapSet;
|
beatmaps.ItemRemoved += removeBeatmapSet;
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ namespace osu.Game.Overlays.Music
|
|||||||
beatmapBacking.ValueChanged += _ => updateSelectedSet();
|
beatmapBacking.ValueChanged += _ => updateSelectedSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addBeatmapSet(BeatmapSetInfo obj, bool existing) => Schedule(() =>
|
private void addBeatmapSet(BeatmapSetInfo obj, bool existing, bool silent) => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (existing)
|
if (existing)
|
||||||
return;
|
return;
|
||||||
|
@ -214,7 +214,7 @@ namespace osu.Game.Overlays
|
|||||||
beatmapSets.Insert(index, beatmapSetInfo);
|
beatmapSets.Insert(index, beatmapSetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleBeatmapAdded(BeatmapSetInfo obj, bool existing)
|
private void handleBeatmapAdded(BeatmapSetInfo obj, bool existing, bool silent)
|
||||||
{
|
{
|
||||||
if (existing)
|
if (existing)
|
||||||
return;
|
return;
|
||||||
|
@ -72,7 +72,7 @@ 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, bool existing)
|
private void itemAdded(SkinInfo s, bool existing, bool silent)
|
||||||
{
|
{
|
||||||
if (existing)
|
if (existing)
|
||||||
return;
|
return;
|
||||||
|
@ -278,7 +278,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
var score = CreateScoreInfo();
|
var score = CreateScoreInfo();
|
||||||
if (RulesetContainer.Replay == null)
|
if (RulesetContainer.Replay == null)
|
||||||
scoreManager.Import(score);
|
scoreManager.Import(score, true);
|
||||||
|
|
||||||
Push(new Results(score));
|
Push(new Results(score));
|
||||||
|
|
||||||
|
@ -505,7 +505,7 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onBeatmapSetAdded(BeatmapSetInfo s, bool existing) => Carousel.UpdateBeatmapSet(s);
|
private void onBeatmapSetAdded(BeatmapSetInfo s, bool existing, bool silent) => 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));
|
||||||
|
Reference in New Issue
Block a user