mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:33:30 +08:00
Update with framework-side bindable list changes
This commit is contained in:
parent
6fd5667ff4
commit
958c891d15
@ -116,8 +116,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
|
||||
public Slider()
|
||||
{
|
||||
SamplesBindable.ItemsAdded += _ => updateNestedSamples();
|
||||
SamplesBindable.ItemsRemoved += _ => updateNestedSamples();
|
||||
SamplesBindable.CollectionChanged += (_, __) => updateNestedSamples();
|
||||
Path.Version.ValueChanged += _ => updateNestedPositions();
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
using osu.Game.Overlays.BeatmapSet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
@ -15,6 +17,7 @@ using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
@ -44,17 +47,19 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Ruleset = { BindTarget = ruleset }
|
||||
});
|
||||
|
||||
modSelector.SelectedMods.ItemsAdded += mods =>
|
||||
modSelector.SelectedMods.CollectionChanged += (_, args) =>
|
||||
{
|
||||
mods.ForEach(mod => selectedMods.Add(new OsuSpriteText
|
||||
switch (args.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
args.NewItems.Cast<Mod>().ForEach(mod => selectedMods.Add(new OsuSpriteText
|
||||
{
|
||||
Text = mod.Acronym,
|
||||
}));
|
||||
};
|
||||
break;
|
||||
|
||||
modSelector.SelectedMods.ItemsRemoved += mods =>
|
||||
{
|
||||
mods.ForEach(mod =>
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
args.OldItems.Cast<Mod>().ForEach(mod =>
|
||||
{
|
||||
foreach (var selected in selectedMods)
|
||||
{
|
||||
@ -65,6 +70,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
AddStep("osu ruleset", () => ruleset.Value = new OsuRuleset().RulesetInfo);
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
@ -71,8 +73,19 @@ namespace osu.Game.Tournament.Screens.Editors
|
||||
}
|
||||
});
|
||||
|
||||
Storage.ItemsAdded += items => items.ForEach(i => flow.Add(CreateDrawable(i)));
|
||||
Storage.ItemsRemoved += items => items.ForEach(i => flow.RemoveAll(d => d.Model == i));
|
||||
Storage.CollectionChanged += (_, args) =>
|
||||
{
|
||||
switch (args.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
args.NewItems.Cast<TModel>().ForEach(i => flow.Add(CreateDrawable(i)));
|
||||
break;
|
||||
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
args.OldItems.Cast<TModel>().ForEach(i => flow.RemoveAll(d => d.Model == i));
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
foreach (var model in Storage)
|
||||
flow.Add(CreateDrawable(model));
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -90,8 +91,19 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
foreach (var r in rounds.Prepend(new TournamentRound()))
|
||||
add(r);
|
||||
|
||||
rounds.ItemsRemoved += items => items.ForEach(i => Control.RemoveDropdownItem(i));
|
||||
rounds.ItemsAdded += items => items.ForEach(add);
|
||||
rounds.CollectionChanged += (_, args) =>
|
||||
{
|
||||
switch (args.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
args.NewItems.Cast<TournamentRound>().ForEach(add);
|
||||
break;
|
||||
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
args.OldItems.Cast<TournamentRound>().ForEach(i => Control.RemoveDropdownItem(i));
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private readonly List<IUnbindable> refBindables = new List<IUnbindable>();
|
||||
@ -122,8 +134,19 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
foreach (var t in teams.Prepend(new TournamentTeam()))
|
||||
add(t);
|
||||
|
||||
teams.ItemsRemoved += items => items.ForEach(i => Control.RemoveDropdownItem(i));
|
||||
teams.ItemsAdded += items => items.ForEach(add);
|
||||
teams.CollectionChanged += (_, args) =>
|
||||
{
|
||||
switch (args.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
args.NewItems.Cast<TournamentTeam>().ForEach(add);
|
||||
break;
|
||||
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
args.OldItems.Cast<TournamentTeam>().ForEach(i => Control.RemoveDropdownItem(i));
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private readonly List<IUnbindable> refBindables = new List<IUnbindable>();
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Caching;
|
||||
@ -68,24 +69,26 @@ namespace osu.Game.Tournament.Screens.Ladder
|
||||
foreach (var match in LadderInfo.Matches)
|
||||
addMatch(match);
|
||||
|
||||
LadderInfo.Rounds.ItemsAdded += _ => layout.Invalidate();
|
||||
LadderInfo.Rounds.ItemsRemoved += _ => layout.Invalidate();
|
||||
|
||||
LadderInfo.Matches.ItemsAdded += matches =>
|
||||
LadderInfo.Rounds.CollectionChanged += (_, __) => layout.Invalidate();
|
||||
LadderInfo.Matches.CollectionChanged += (_, args) =>
|
||||
{
|
||||
foreach (var p in matches)
|
||||
switch (args.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
foreach (var p in args.NewItems.Cast<TournamentMatch>())
|
||||
addMatch(p);
|
||||
layout.Invalidate();
|
||||
};
|
||||
break;
|
||||
|
||||
LadderInfo.Matches.ItemsRemoved += matches =>
|
||||
{
|
||||
foreach (var p in matches)
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
foreach (var p in args.NewItems.Cast<TournamentMatch>())
|
||||
{
|
||||
foreach (var d in MatchesContainer.Where(d => d.Match == p))
|
||||
d.Expire();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
layout.Invalidate();
|
||||
};
|
||||
}
|
||||
|
@ -191,8 +191,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
scope.BindValueChanged(_ => getScores());
|
||||
ruleset.BindValueChanged(_ => getScores());
|
||||
|
||||
modSelector.SelectedMods.ItemsAdded += _ => getScores();
|
||||
modSelector.SelectedMods.ItemsRemoved += _ => getScores();
|
||||
modSelector.SelectedMods.CollectionChanged += (_, __) => getScores();
|
||||
|
||||
Beatmap.BindValueChanged(onBeatmapChanged);
|
||||
user.BindValueChanged(onUserChanged, true);
|
||||
|
@ -125,8 +125,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
}
|
||||
|
||||
samplesBindable = HitObject.SamplesBindable.GetBoundCopy();
|
||||
samplesBindable.ItemsAdded += _ => loadSamples();
|
||||
samplesBindable.ItemsRemoved += _ => loadSamples();
|
||||
samplesBindable.CollectionChanged += (_, __) => loadSamples();
|
||||
|
||||
updateState(ArmedState.Idle, true);
|
||||
onDefaultsApplied();
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Bindables;
|
||||
@ -47,18 +48,20 @@ namespace osu.Game.Rulesets.Objects
|
||||
{
|
||||
ExpectedDistance.ValueChanged += _ => invalidate();
|
||||
|
||||
ControlPoints.ItemsAdded += items =>
|
||||
ControlPoints.CollectionChanged += (_, args) =>
|
||||
{
|
||||
foreach (var c in items)
|
||||
switch (args.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
foreach (var c in args.NewItems.Cast<PathControlPoint>())
|
||||
c.Changed += invalidate;
|
||||
break;
|
||||
|
||||
invalidate();
|
||||
};
|
||||
|
||||
ControlPoints.ItemsRemoved += items =>
|
||||
{
|
||||
foreach (var c in items)
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
foreach (var c in args.NewItems.Cast<PathControlPoint>())
|
||||
c.Changed -= invalidate;
|
||||
break;
|
||||
}
|
||||
|
||||
invalidate();
|
||||
};
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
@ -70,18 +71,20 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
AddBlueprintFor(obj);
|
||||
|
||||
selectedHitObjects.BindTo(beatmap.SelectedHitObjects);
|
||||
selectedHitObjects.ItemsAdded += objects =>
|
||||
selectedHitObjects.CollectionChanged += (selectedObjects, args) =>
|
||||
{
|
||||
foreach (var o in objects)
|
||||
switch (args.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
foreach (var o in args.NewItems)
|
||||
SelectionBlueprints.FirstOrDefault(b => b.HitObject == o)?.Select();
|
||||
break;
|
||||
|
||||
SelectionChanged?.Invoke(selectedHitObjects);
|
||||
};
|
||||
|
||||
selectedHitObjects.ItemsRemoved += objects =>
|
||||
{
|
||||
foreach (var o in objects)
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
foreach (var o in args.OldItems)
|
||||
SelectionBlueprints.FirstOrDefault(b => b.HitObject == o)?.Deselect();
|
||||
break;
|
||||
}
|
||||
|
||||
SelectionChanged?.Invoke(selectedHitObjects);
|
||||
};
|
||||
|
@ -26,8 +26,7 @@ namespace osu.Game.Screens.Multi.Components
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Playlist.ItemsAdded += _ => updateText();
|
||||
Playlist.ItemsRemoved += _ => updateText();
|
||||
Playlist.CollectionChanged += (_, __) => updateText();
|
||||
|
||||
updateText();
|
||||
}
|
||||
|
@ -51,8 +51,7 @@ namespace osu.Game.Screens.Multi.Components
|
||||
}
|
||||
};
|
||||
|
||||
Playlist.ItemsAdded += _ => updateInfo();
|
||||
Playlist.ItemsRemoved += _ => updateInfo();
|
||||
Playlist.CollectionChanged += (_, __) => updateInfo();
|
||||
|
||||
updateInfo();
|
||||
}
|
||||
|
@ -48,8 +48,7 @@ namespace osu.Game.Screens.Multi.Components
|
||||
|
||||
Type.BindValueChanged(type => gameTypeContainer.Child = new DrawableGameType(type.NewValue) { Size = new Vector2(height) }, true);
|
||||
|
||||
Playlist.ItemsAdded += _ => updateBeatmap();
|
||||
Playlist.ItemsRemoved += _ => updateBeatmap();
|
||||
Playlist.CollectionChanged += (_, __) => updateBeatmap();
|
||||
|
||||
updateBeatmap();
|
||||
}
|
||||
|
@ -23,8 +23,7 @@ namespace osu.Game.Screens.Multi.Components
|
||||
{
|
||||
InternalChild = sprite = CreateBackgroundSprite();
|
||||
|
||||
Playlist.ItemsAdded += _ => updateBeatmap();
|
||||
Playlist.ItemsRemoved += _ => updateBeatmap();
|
||||
Playlist.CollectionChanged += (_, __) => updateBeatmap();
|
||||
|
||||
updateBeatmap();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Specialized;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -29,10 +30,15 @@ namespace osu.Game.Screens.Multi
|
||||
base.LoadComplete();
|
||||
|
||||
// Scheduled since items are removed and re-added upon rearrangement
|
||||
Items.ItemsRemoved += items => Schedule(() =>
|
||||
Items.CollectionChanged += (_, args) => Schedule(() =>
|
||||
{
|
||||
if (!Items.Contains(SelectedItem.Value))
|
||||
switch (args.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
if (args.OldItems.Contains(SelectedItem))
|
||||
SelectedItem.Value = null;
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -84,8 +84,7 @@ namespace osu.Game.Screens.Multi
|
||||
beatmap.BindValueChanged(_ => scheduleRefresh());
|
||||
ruleset.BindValueChanged(_ => scheduleRefresh());
|
||||
|
||||
requiredMods.ItemsAdded += _ => scheduleRefresh();
|
||||
requiredMods.ItemsRemoved += _ => scheduleRefresh();
|
||||
requiredMods.CollectionChanged += (_, __) => scheduleRefresh();
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user