1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 15:12:57 +08:00

Update Remove/RemoveRange/RemoveAll calls in line with framework changes

This commit is contained in:
Dean Herbert 2022-08-26 15:19:05 +09:00
parent 2b7b77157a
commit a215d009fe
39 changed files with 52 additions and 56 deletions

View File

@ -271,8 +271,8 @@ namespace osu.Game.Rulesets.Catch.UI
SetHyperDashState(); SetHyperDashState();
} }
caughtObjectContainer.RemoveAll(d => d.HitObject == drawableObject.HitObject); caughtObjectContainer.RemoveAll(d => d.HitObject == drawableObject.HitObject, false);
droppedObjectTarget.RemoveAll(d => d.HitObject == drawableObject.HitObject); droppedObjectTarget.RemoveAll(d => d.HitObject == drawableObject.HitObject, false);
} }
/// <summary> /// <summary>
@ -430,7 +430,7 @@ namespace osu.Game.Rulesets.Catch.UI
{ {
var droppedObject = getDroppedObject(caughtObject); var droppedObject = getDroppedObject(caughtObject);
caughtObjectContainer.Remove(caughtObject); caughtObjectContainer.Remove(caughtObject, false);
droppedObjectTarget.Add(droppedObject); droppedObjectTarget.Add(droppedObject);

View File

@ -93,15 +93,15 @@ namespace osu.Game.Rulesets.Catch.UI
switch (entry.Animation) switch (entry.Animation)
{ {
case CatcherTrailAnimation.Dashing: case CatcherTrailAnimation.Dashing:
dashTrails.Remove(drawable); dashTrails.Remove(drawable, false);
break; break;
case CatcherTrailAnimation.HyperDashing: case CatcherTrailAnimation.HyperDashing:
hyperDashTrails.Remove(drawable); hyperDashTrails.Remove(drawable, false);
break; break;
case CatcherTrailAnimation.HyperDashAfterImage: case CatcherTrailAnimation.HyperDashAfterImage:
hyperDashAfterImages.Remove(drawable); hyperDashAfterImages.Remove(drawable, false);
break; break;
} }
} }

View File

@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Mania.Mods
HitObjectContainer hoc = column.HitObjectArea.HitObjectContainer; HitObjectContainer hoc = column.HitObjectArea.HitObjectContainer;
Container hocParent = (Container)hoc.Parent; Container hocParent = (Container)hoc.Parent;
hocParent.Remove(hoc); hocParent.Remove(hoc, false);
hocParent.Add(new PlayfieldCoveringWrapper(hoc).With(c => hocParent.Add(new PlayfieldCoveringWrapper(hoc).With(c =>
{ {
c.RelativeSizeAxes = Axes.Both; c.RelativeSizeAxes = Axes.Both;

View File

@ -155,7 +155,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
else else
{ {
lightContainer.FadeOut(120) lightContainer.FadeOut(120)
.OnComplete(d => Column.TopLevelContainer.Remove(d)); .OnComplete(d => Column.TopLevelContainer.Remove(d, false));
} }
} }

View File

@ -195,7 +195,7 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
var drawableObject = getFunc.Invoke(); var drawableObject = getFunc.Invoke();
hitObjectContainer.Remove(drawableObject); hitObjectContainer.Remove(drawableObject, false);
followPointRenderer.RemoveFollowPoints(drawableObject.HitObject); followPointRenderer.RemoveFollowPoints(drawableObject.HitObject);
}); });
} }
@ -212,7 +212,7 @@ namespace osu.Game.Rulesets.Osu.Tests
else else
targetTime = getObject(hitObjectContainer.Count - 1).HitObject.StartTime + 1; targetTime = getObject(hitObjectContainer.Count - 1).HitObject.StartTime + 1;
hitObjectContainer.Remove(toReorder); hitObjectContainer.Remove(toReorder, false);
toReorder.HitObject.StartTime = targetTime; toReorder.HitObject.StartTime = targetTime;
hitObjectContainer.Add(toReorder); hitObjectContainer.Add(toReorder);
}); });

View File

@ -77,7 +77,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
// This is a bit ugly but we don't have the concept of InternalContent so it'll have to do for now. (https://github.com/ppy/osu-framework/issues/1690) // This is a bit ugly but we don't have the concept of InternalContent so it'll have to do for now. (https://github.com/ppy/osu-framework/issues/1690)
protected override void AddInternal(Drawable drawable) => shakeContainer.Add(drawable); protected override void AddInternal(Drawable drawable) => shakeContainer.Add(drawable);
protected override void ClearInternal(bool disposeChildren = true) => shakeContainer.Clear(disposeChildren); protected override void ClearInternal(bool disposeChildren = true) => shakeContainer.Clear(disposeChildren);
protected override bool RemoveInternal(Drawable drawable) => shakeContainer.Remove(drawable); protected override bool RemoveInternal(Drawable drawable) => shakeContainer.Remove(drawable, true);
protected sealed override double InitialLifetimeOffset => HitObject.TimePreempt; protected sealed override double InitialLifetimeOffset => HitObject.TimePreempt;

View File

@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
isProxied = true; isProxied = true;
nonProxiedContent.Remove(Content); nonProxiedContent.Remove(Content, false);
proxiedContent.Add(Content); proxiedContent.Add(Content);
} }
@ -70,7 +70,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
isProxied = false; isProxied = false;
proxiedContent.Remove(Content); proxiedContent.Remove(Content, false);
nonProxiedContent.Add(Content); nonProxiedContent.Add(Content);
} }
@ -141,7 +141,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
Size = BaseSize = new Vector2(TaikoHitObject.DEFAULT_SIZE); Size = BaseSize = new Vector2(TaikoHitObject.DEFAULT_SIZE);
if (MainPiece != null) if (MainPiece != null)
Content.Remove(MainPiece); Content.Remove(MainPiece, true);
Content.Add(MainPiece = CreateMainPiece()); Content.Add(MainPiece = CreateMainPiece());
} }

View File

@ -171,7 +171,7 @@ namespace osu.Game.Tests.Visual.Background
=> AddStep("create loader", () => => AddStep("create loader", () =>
{ {
if (backgroundLoader != null) if (backgroundLoader != null)
Remove(backgroundLoader); Remove(backgroundLoader, true);
Add(backgroundLoader = new SeasonalBackgroundLoader()); Add(backgroundLoader = new SeasonalBackgroundLoader());
}); });

View File

@ -87,7 +87,7 @@ namespace osu.Game.Tests.Visual.Gameplay
Add(expectedComponentsAdjustmentContainer); Add(expectedComponentsAdjustmentContainer);
expectedComponentsAdjustmentContainer.UpdateSubTree(); expectedComponentsAdjustmentContainer.UpdateSubTree();
var expectedInfo = expectedComponentsContainer.CreateSkinnableInfo(); var expectedInfo = expectedComponentsContainer.CreateSkinnableInfo();
Remove(expectedComponentsAdjustmentContainer); Remove(expectedComponentsAdjustmentContainer, true);
return almostEqual(actualInfo, expectedInfo); return almostEqual(actualInfo, expectedInfo);
} }

View File

@ -63,7 +63,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
base.TearDownSteps(); base.TearDownSteps();
AddStep("stop watching user", () => spectatorClient.StopWatchingUser(dummy_user_id)); AddStep("stop watching user", () => spectatorClient.StopWatchingUser(dummy_user_id));
AddStep("remove test spectator client", () => Remove(spectatorClient)); AddStep("remove test spectator client", () => Remove(spectatorClient, false));
} }
} }
} }

View File

@ -91,7 +91,7 @@ namespace osu.Game.Tests.Visual.Gameplay
private void loadStoryboard(IWorkingBeatmap working) private void loadStoryboard(IWorkingBeatmap working)
{ {
if (storyboard != null) if (storyboard != null)
storyboardContainer.Remove(storyboard); storyboardContainer.Remove(storyboard, true);
var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true }; var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true };
storyboardContainer.Clock = decoupledClock; storyboardContainer.Clock = decoupledClock;
@ -106,7 +106,7 @@ namespace osu.Game.Tests.Visual.Gameplay
private void loadStoryboardNoVideo() private void loadStoryboardNoVideo()
{ {
if (storyboard != null) if (storyboard != null)
storyboardContainer.Remove(storyboard); storyboardContainer.Remove(storyboard, true);
var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true }; var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true };
storyboardContainer.Clock = decoupledClock; storyboardContainer.Clock = decoupledClock;

View File

@ -62,8 +62,8 @@ namespace osu.Game.Tests.Visual.Menus
[SetUp] [SetUp]
public void SetUp() => Schedule(() => public void SetUp() => Schedule(() =>
{ {
Remove(nowPlayingOverlay); Remove(nowPlayingOverlay, false);
Remove(volumeOverlay); Remove(volumeOverlay, false);
Children = new Drawable[] Children = new Drawable[]
{ {

View File

@ -34,7 +34,7 @@ namespace osu.Game.Tests.Visual.Navigation
AddStep("force save config", () => Game.LocalConfig.Save()); AddStep("force save config", () => Game.LocalConfig.Save());
AddStep("remove game", () => Remove(Game)); AddStep("remove game", () => Remove(Game, true));
AddStep("create game again", CreateGame); AddStep("create game again", CreateGame);

View File

@ -60,7 +60,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
if (selected.Text == mod.Acronym) if (selected.Text == mod.Acronym)
{ {
selectedMods.Remove(selected); selectedMods.Remove(selected, true);
break; break;
} }
} }

View File

@ -98,7 +98,7 @@ namespace osu.Game.Tests.Visual.SongSelect
OsuLogo logo = new OsuLogo { Scale = new Vector2(0.15f) }; OsuLogo logo = new OsuLogo { Scale = new Vector2(0.15f) };
Remove(testDifficultyCache); Remove(testDifficultyCache, false);
Children = new Drawable[] Children = new Drawable[]
{ {

View File

@ -259,7 +259,7 @@ namespace osu.Game.Tests.Visual.UserInterface
private void removeFacade() private void removeFacade()
{ {
trackingContainer.Remove(logoFacade); trackingContainer.Remove(logoFacade, false);
visualBox.Colour = Color4.White; visualBox.Colour = Color4.White;
moveLogoFacade(); moveLogoFacade();
} }

View File

@ -53,7 +53,7 @@ namespace osu.Game.Tournament.Tests.Screens
{ {
AddStep("setup screen", () => AddStep("setup screen", () =>
{ {
Remove(chat); Remove(chat, false);
Children = new Drawable[] Children = new Drawable[]
{ {

View File

@ -93,7 +93,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
{ {
allTeams.RemoveAll(gt => gt.Team == team); allTeams.RemoveAll(gt => gt.Team == team);
if (teams.RemoveAll(gt => gt.Team == team) > 0) if (teams.RemoveAll(gt => gt.Team == team, true) > 0)
{ {
TeamsCount--; TeamsCount--;
return true; return true;

View File

@ -170,7 +170,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
availableTeams.Add(team); availableTeams.Add(team);
RemoveAll(c => c is ScrollingTeam); RemoveAll(c => c is ScrollingTeam, false);
setScrollState(ScrollState.Idle); setScrollState(ScrollState.Idle);
} }
@ -186,7 +186,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
public void ClearTeams() public void ClearTeams()
{ {
availableTeams.Clear(); availableTeams.Clear();
RemoveAll(c => c is ScrollingTeam); RemoveAll(c => c is ScrollingTeam, true);
setScrollState(ScrollState.Idle); setScrollState(ScrollState.Idle);
} }

View File

@ -57,7 +57,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
if (allLines.Count == 0) if (allLines.Count == 0)
return; return;
Remove(allLines.First()); Remove(allLines.First(), true);
allLines.Remove(allLines.First()); allLines.Remove(allLines.First());
} }

View File

@ -106,7 +106,7 @@ namespace osu.Game.Tournament.Screens.Editors
break; break;
case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Remove:
args.OldItems.Cast<TModel>().ForEach(i => flow.RemoveAll(d => d.Model == i)); args.OldItems.Cast<TModel>().ForEach(i => flow.RemoveAll(d => d.Model == i, true));
break; break;
} }
}; };

View File

@ -70,7 +70,7 @@ namespace osu.Game.Graphics.Containers
if (value == footer) return; if (value == footer) return;
if (footer != null) if (footer != null)
scrollContainer.Remove(footer); scrollContainer.Remove(footer, true);
footer = value; footer = value;
if (value == null) return; if (value == null) return;

View File

@ -59,7 +59,7 @@ namespace osu.Game.Graphics.Containers
drawable.StateChanged += state => selectionChanged(drawable, state); drawable.StateChanged += state => selectionChanged(drawable, state);
} }
public override bool Remove(T drawable) public override bool Remove(T drawable, bool disposeImmediately)
=> throw new NotSupportedException($"Cannot remove drawables from {nameof(SelectionCycleFillFlowContainer<T>)}"); => throw new NotSupportedException($"Cannot remove drawables from {nameof(SelectionCycleFillFlowContainer<T>)}");
private void setSelected(int? value) private void setSelected(int? value)

View File

@ -74,7 +74,7 @@ namespace osu.Game.Graphics.UserInterface
} }
//I'm using ToList() here because Where() returns an Enumerable which can change it's elements afterwards //I'm using ToList() here because Where() returns an Enumerable which can change it's elements afterwards
RemoveRange(Children.Where((_, index) => index >= value.Count()).ToList()); RemoveRange(Children.Where((_, index) => index >= value.Count()).ToList(), true);
} }
} }
} }

View File

@ -64,8 +64,8 @@ namespace osu.Game.Graphics.UserInterface
X = value.HasFlagFast(Anchor.x2) ? SIZE_RETRACTED.X * shear.X * 0.5f : 0; X = value.HasFlagFast(Anchor.x2) ? SIZE_RETRACTED.X * shear.X * 0.5f : 0;
Remove(c1); Remove(c1, false);
Remove(c2); Remove(c2, false);
c1.Depth = value.HasFlagFast(Anchor.x2) ? 0 : 1; c1.Depth = value.HasFlagFast(Anchor.x2) ? 0 : 1;
c2.Depth = value.HasFlagFast(Anchor.x2) ? 1 : 0; c2.Depth = value.HasFlagFast(Anchor.x2) ? 1 : 0;
Add(c1); Add(c1);

View File

@ -99,7 +99,7 @@ namespace osu.Game.Overlays.Chat.ChannelList
FillFlowContainer<ChannelListItem> flow = getFlowForChannel(channel); FillFlowContainer<ChannelListItem> flow = getFlowForChannel(channel);
channelMap.Remove(channel); channelMap.Remove(channel);
flow.Remove(item); flow.Remove(item, true);
updateVisibility(); updateVisibility();
} }

View File

@ -181,7 +181,7 @@ namespace osu.Game.Overlays.Chat
{ {
Trace.Assert(updated.Id.HasValue, "An updated message was returned with no ID."); Trace.Assert(updated.Id.HasValue, "An updated message was returned with no ID.");
ChatLineFlow.Remove(found); ChatLineFlow.Remove(found, false);
found.Message = updated; found.Message = updated;
ChatLineFlow.Add(found); ChatLineFlow.Add(found);
} }

View File

@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.UI
// remove any existing judgements for the judged object. // remove any existing judgements for the judged object.
// this can be the case when rewinding. // this can be the case when rewinding.
RemoveAll(c => c.JudgedObject == judgement.JudgedObject); RemoveAll(c => c.JudgedObject == judgement.JudgedObject, false);
base.Add(judgement); base.Add(judgement);
} }

View File

@ -292,7 +292,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
blueprint.Selected -= OnBlueprintSelected; blueprint.Selected -= OnBlueprintSelected;
blueprint.Deselected -= OnBlueprintDeselected; blueprint.Deselected -= OnBlueprintDeselected;
SelectionBlueprints.Remove(blueprint); SelectionBlueprints.Remove(blueprint, true);
if (movementBlueprints?.Contains(blueprint) == true) if (movementBlueprints?.Contains(blueprint) == true)
finishSelectionMovement(); finishSelectionMovement();

View File

@ -35,10 +35,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
base.Add(drawable); base.Add(drawable);
} }
public override bool Remove(SelectionBlueprint<HitObject> drawable) public override bool Remove(SelectionBlueprint<HitObject> drawable, bool disposeImmediately)
{ {
SortInternal(); SortInternal();
return base.Remove(drawable); return base.Remove(drawable, disposeImmediately);
} }
protected override int Compare(Drawable x, Drawable y) protected override int Compare(Drawable x, Drawable y)

View File

@ -77,7 +77,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
{ {
if (placementBlueprint != null) if (placementBlueprint != null)
{ {
SelectionBlueprints.Remove(placementBlueprint); SelectionBlueprints.Remove(placementBlueprint, true);
placementBlueprint = null; placementBlueprint = null;
} }
} }

View File

@ -255,8 +255,7 @@ namespace osu.Game.Screens.Menu
{ {
lazerLogo.FadeOut().OnComplete(_ => lazerLogo.FadeOut().OnComplete(_ =>
{ {
logoContainerSecondary.Remove(lazerLogo); logoContainerSecondary.Remove(lazerLogo, true);
lazerLogo.Dispose(); // explicit disposal as we are pushing a new screen and the expire may not get run.
logo.FadeIn(); logo.FadeIn();

View File

@ -232,7 +232,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
private void removeUser(APIUser user) private void removeUser(APIUser user)
{ {
avatarFlow.RemoveAll(a => a.User == user); avatarFlow.RemoveAll(a => a.User == user, true);
} }
private void clearUsers() private void clearUsers()
@ -250,7 +250,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
hiddenUsers.Count = hiddenCount; hiddenUsers.Count = hiddenCount;
if (displayedCircles > NumberOfCircles) if (displayedCircles > NumberOfCircles)
avatarFlow.Remove(avatarFlow.Last()); avatarFlow.Remove(avatarFlow.Last(), true);
else if (displayedCircles < NumberOfCircles) else if (displayedCircles < NumberOfCircles)
{ {
var nextUser = RecentParticipants.FirstOrDefault(u => avatarFlow.All(a => a.User != u)); var nextUser = RecentParticipants.FirstOrDefault(u => avatarFlow.All(a => a.User != u));

View File

@ -138,7 +138,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{ {
foreach (var r in rooms) foreach (var r in rooms)
{ {
roomFlow.RemoveAll(d => d.Room == r); roomFlow.RemoveAll(d => d.Room == r, true);
// selection may have a lease due to being in a sub screen. // selection may have a lease due to being in a sub screen.
if (!SelectedRoom.Disabled) if (!SelectedRoom.Disabled)

View File

@ -317,7 +317,7 @@ namespace osu.Game.Screens.Ranking
var screenSpacePos = detachedPanel.ScreenSpaceDrawQuad.TopLeft; var screenSpacePos = detachedPanel.ScreenSpaceDrawQuad.TopLeft;
// Remove from the local container and re-attach. // Remove from the local container and re-attach.
detachedPanelContainer.Remove(detachedPanel); detachedPanelContainer.Remove(detachedPanel, false);
ScorePanelList.Attach(detachedPanel); ScorePanelList.Attach(detachedPanel);
// Move into its original location in the attached container first, then to the final location. // Move into its original location in the attached container first, then to the final location.

View File

@ -151,7 +151,7 @@ namespace osu.Game.Skinning
bool wasPlaying = IsPlaying; bool wasPlaying = IsPlaying;
// Remove all pooled samples (return them to the pool), and dispose the rest. // Remove all pooled samples (return them to the pool), and dispose the rest.
samplesContainer.RemoveAll(s => s.IsInPool); samplesContainer.RemoveAll(s => s.IsInPool, false);
samplesContainer.Clear(); samplesContainer.Clear();
foreach (var s in samples) foreach (var s in samples)

View File

@ -85,7 +85,7 @@ namespace osu.Game.Skinning
if (!(component is Drawable drawable)) if (!(component is Drawable drawable))
throw new ArgumentException($"Provided argument must be of type {nameof(Drawable)}.", nameof(component)); throw new ArgumentException($"Provided argument must be of type {nameof(Drawable)}.", nameof(component));
content.Remove(drawable); content.Remove(drawable, true);
components.Remove(component); components.Remove(component);
} }

View File

@ -58,10 +58,7 @@ namespace osu.Game.Tests.Visual
AddStep("Create new game instance", () => AddStep("Create new game instance", () =>
{ {
if (Game?.Parent != null) if (Game?.Parent != null)
{ Remove(Game, true);
Remove(Game);
Game.Dispose();
}
RecycleLocalStorage(false); RecycleLocalStorage(false);

View File

@ -67,7 +67,7 @@ namespace osu.Game.Tests.Visual
protected void ResetPlacement() protected void ResetPlacement()
{ {
if (CurrentBlueprint != null) if (CurrentBlueprint != null)
Remove(CurrentBlueprint); Remove(CurrentBlueprint, true);
Add(CurrentBlueprint = CreateBlueprint()); Add(CurrentBlueprint = CreateBlueprint());
} }