Move hierarchy init to load and remove unnecessary field storage

This commit is contained in:
Dean Herbert 2020-11-10 12:33:07 +09:00
parent 670d6d8719
commit 4af390a168
1 changed files with 8 additions and 11 deletions

View File

@ -102,8 +102,6 @@ private class PlayingUserPanel : CompositeDrawable
{
public readonly User User;
private readonly PurpleTriangleButton watchButton;
[Resolved(canBeNull: true)]
private OsuGame game { get; set; }
@ -112,7 +110,11 @@ public PlayingUserPanel(User user)
User = user;
AutoSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load(IAPIProvider api)
{
InternalChildren = new Drawable[]
{
new FillFlowContainer
@ -123,30 +125,25 @@ public PlayingUserPanel(User user)
Width = 290,
Children = new Drawable[]
{
new UserGridPanel(user)
new UserGridPanel(User)
{
RelativeSizeAxes = Axes.X,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
},
watchButton = new PurpleTriangleButton
new PurpleTriangleButton
{
RelativeSizeAxes = Axes.X,
Text = "Watch",
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Action = () => game?.PerformFromScreen(s => s.Push(new Spectator(user)))
Action = () => game?.PerformFromScreen(s => s.Push(new Spectator(User))),
Enabled = { Value = User.Id != api.LocalUser.Value.Id }
}
}
},
};
}
[BackgroundDependencyLoader]
private void load(IAPIProvider api)
{
watchButton.Enabled.Value = User.Id != api.LocalUser.Value.Id;
}
}
}
}