From c671d97e6f3638b2ceae96986a509eafec0bff99 Mon Sep 17 00:00:00 2001 From: Joehu Date: Mon, 9 Nov 2020 18:39:35 -0800 Subject: [PATCH 1/3] Disable watch button on the local user --- osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs b/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs index c3ab9e86d4..35cb97adbb 100644 --- a/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs +++ b/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs @@ -102,6 +102,8 @@ namespace osu.Game.Overlays.Dashboard { public readonly User User; + private PurpleTriangleButton watchButton; + [Resolved(canBeNull: true)] private OsuGame game { get; set; } @@ -127,7 +129,7 @@ namespace osu.Game.Overlays.Dashboard Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, - new PurpleTriangleButton + watchButton = new PurpleTriangleButton { RelativeSizeAxes = Axes.X, Text = "Watch", @@ -139,6 +141,12 @@ namespace osu.Game.Overlays.Dashboard }, }; } + + [BackgroundDependencyLoader] + private void load(IAPIProvider api) + { + watchButton.Enabled.Value = User.Id != api.LocalUser.Value.Id; + } } } } From 670d6d87198e97b331095d9d6fb156d0f5ba3840 Mon Sep 17 00:00:00 2001 From: Joehu Date: Mon, 9 Nov 2020 18:59:54 -0800 Subject: [PATCH 2/3] Make button field readonly --- osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs b/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs index 35cb97adbb..36e2e9ae43 100644 --- a/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs +++ b/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs @@ -102,7 +102,7 @@ namespace osu.Game.Overlays.Dashboard { public readonly User User; - private PurpleTriangleButton watchButton; + private readonly PurpleTriangleButton watchButton; [Resolved(canBeNull: true)] private OsuGame game { get; set; } From 4af390a1681e4a616989d6483368ffe4d393ec50 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 10 Nov 2020 12:33:07 +0900 Subject: [PATCH 3/3] Move hierarchy init to load and remove unnecessary field storage --- .../Dashboard/CurrentlyPlayingDisplay.cs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs b/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs index 36e2e9ae43..d39a81f5e8 100644 --- a/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs +++ b/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs @@ -102,8 +102,6 @@ namespace osu.Game.Overlays.Dashboard { public readonly User User; - private readonly PurpleTriangleButton watchButton; - [Resolved(canBeNull: true)] private OsuGame game { get; set; } @@ -112,7 +110,11 @@ namespace osu.Game.Overlays.Dashboard User = user; AutoSizeAxes = Axes.Both; + } + [BackgroundDependencyLoader] + private void load(IAPIProvider api) + { InternalChildren = new Drawable[] { new FillFlowContainer @@ -123,30 +125,25 @@ namespace osu.Game.Overlays.Dashboard 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; - } } } }