1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 02:17:46 +08:00

Centralise calls to mutable hitobjects list

This commit is contained in:
Dean Herbert 2020-01-01 21:24:00 +09:00
parent ca90f708f1
commit 4f2fa2626a
2 changed files with 11 additions and 5 deletions

View File

@ -7,6 +7,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using ManagedBass;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -125,6 +126,9 @@ namespace osu.Game
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
Bass.Configure(ManagedBass.Configuration.DeviceBufferLength, 2);
Bass.Configure(ManagedBass.Configuration.DevicePeriod, -512);
Resources.AddStore(new DllResourceStore(@"osu.Game.Resources.dll")); Resources.AddStore(new DllResourceStore(@"osu.Game.Resources.dll"));
dependencies.Cache(contextFactory = new DatabaseContextFactory(Storage)); dependencies.Cache(contextFactory = new DatabaseContextFactory(Storage));

View File

@ -62,6 +62,8 @@ namespace osu.Game.Screens.Edit
public IBeatmap Clone() => (EditorBeatmap)MemberwiseClone(); public IBeatmap Clone() => (EditorBeatmap)MemberwiseClone();
private IList mutableHitObjects => (IList)beatmap.HitObjects;
/// <summary> /// <summary>
/// Adds a <see cref="HitObject"/> to this <see cref="EditorBeatmap"/>. /// Adds a <see cref="HitObject"/> to this <see cref="EditorBeatmap"/>.
/// </summary> /// </summary>
@ -72,7 +74,7 @@ namespace osu.Game.Screens.Edit
// Preserve existing sorting order in the beatmap // Preserve existing sorting order in the beatmap
var insertionIndex = findInsertionIndex(beatmap.HitObjects, hitObject.StartTime); var insertionIndex = findInsertionIndex(beatmap.HitObjects, hitObject.StartTime);
((IList)beatmap.HitObjects).Insert(insertionIndex + 1, hitObject); mutableHitObjects.Insert(insertionIndex + 1, hitObject);
HitObjectAdded?.Invoke(hitObject); HitObjectAdded?.Invoke(hitObject);
} }
@ -83,10 +85,10 @@ namespace osu.Game.Screens.Edit
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param> /// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
public void Remove(HitObject hitObject) public void Remove(HitObject hitObject)
{ {
if (!((IList)beatmap.HitObjects).Contains(hitObject)) if (!mutableHitObjects.Contains(hitObject))
return; return;
((IList)beatmap.HitObjects).Remove(hitObject); mutableHitObjects.Remove(hitObject);
var bindable = startTimeBindables[hitObject]; var bindable = startTimeBindables[hitObject];
bindable.UnbindAll(); bindable.UnbindAll();
@ -101,10 +103,10 @@ namespace osu.Game.Screens.Edit
startTimeBindables[hitObject].ValueChanged += _ => startTimeBindables[hitObject].ValueChanged += _ =>
{ {
// For now we'll remove and re-add the hitobject. This is not optimal and can be improved if required. // For now we'll remove and re-add the hitobject. This is not optimal and can be improved if required.
((IList)beatmap.HitObjects).Remove(hitObject); mutableHitObjects.Remove(hitObject);
var insertionIndex = findInsertionIndex(beatmap.HitObjects, hitObject.StartTime); var insertionIndex = findInsertionIndex(beatmap.HitObjects, hitObject.StartTime);
((IList)beatmap.HitObjects).Insert(insertionIndex + 1, hitObject); mutableHitObjects.Insert(insertionIndex + 1, hitObject);
StartTimeChanged?.Invoke(hitObject); StartTimeChanged?.Invoke(hitObject);
}; };