mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:52:54 +08:00
Use AddRangeInternal for simplicity, but disallow ClearInternal for safety
This commit is contained in:
parent
fc37d8b7df
commit
de8724b1f6
@ -7,8 +7,6 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -45,25 +43,16 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
[Cached]
|
[Cached]
|
||||||
protected OnlinePlayBeatmapAvailablilityTracker BeatmapAvailablilityTracker { get; }
|
protected OnlinePlayBeatmapAvailablilityTracker BeatmapAvailablilityTracker { get; }
|
||||||
|
|
||||||
private readonly Container content;
|
|
||||||
|
|
||||||
protected RoomSubScreen()
|
protected RoomSubScreen()
|
||||||
{
|
{
|
||||||
InternalChildren = new Drawable[]
|
AddInternal(BeatmapAvailablilityTracker = new OnlinePlayBeatmapAvailablilityTracker
|
||||||
{
|
|
||||||
BeatmapAvailablilityTracker = new OnlinePlayBeatmapAvailablilityTracker
|
|
||||||
{
|
{
|
||||||
SelectedItem = { BindTarget = SelectedItem }
|
SelectedItem = { BindTarget = SelectedItem }
|
||||||
},
|
});
|
||||||
content = new Container { RelativeSizeAxes = Axes.Both },
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Forward all internal management to content to ensure locally added components are not removed unintentionally.
|
protected override void ClearInternal(bool disposeChildren = true) =>
|
||||||
// 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)
|
throw new InvalidOperationException($"{nameof(RoomSubScreen)}'s children should not be cleared as it will remove required components");
|
||||||
protected override void AddInternal(Drawable drawable) => content.Add(drawable);
|
|
||||||
protected override bool RemoveInternal(Drawable drawable) => content.Remove(drawable);
|
|
||||||
protected override void ClearInternal(bool disposeChildren = true) => content.Clear(disposeChildren);
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio)
|
private void load(AudioManager audio)
|
||||||
|
@ -54,7 +54,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
InternalChildren = new Drawable[]
|
AddRangeInternal(new Drawable[]
|
||||||
{
|
{
|
||||||
mainContent = new GridContainer
|
mainContent = new GridContainer
|
||||||
{
|
{
|
||||||
@ -177,7 +177,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
State = { Value = client.Room == null ? Visibility.Visible : Visibility.Hidden }
|
State = { Value = client.Room == null ? Visibility.Visible : Visibility.Hidden }
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
if (client.Room == null)
|
if (client.Room == null)
|
||||||
{
|
{
|
||||||
|
@ -44,7 +44,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
InternalChildren = new Drawable[]
|
AddRangeInternal(new Drawable[]
|
||||||
{
|
{
|
||||||
mainContent = new GridContainer
|
mainContent = new GridContainer
|
||||||
{
|
{
|
||||||
@ -190,7 +190,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
|||||||
EditPlaylist = () => this.Push(new MatchSongSelect()),
|
EditPlaylist = () => this.Push(new MatchSongSelect()),
|
||||||
State = { Value = roomId.Value == null ? Visibility.Visible : Visibility.Hidden }
|
State = { Value = roomId.Value == null ? Visibility.Visible : Visibility.Hidden }
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
if (roomId.Value == null)
|
if (roomId.Value == null)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user