From 70338e087a356d3dde16bcc2c548286fa28695c7 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 31 Jul 2018 14:41:31 +0900 Subject: [PATCH] Disable beatmap download button if not supporter --- .../BeatmapSet/Buttons/DownloadButton.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs index 223ca1c904..7cfacc9475 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs @@ -1,18 +1,25 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Online.API; +using osu.Game.Users; using OpenTK; +using OpenTK.Graphics; namespace osu.Game.Overlays.BeatmapSet.Buttons { public class DownloadButton : HeaderButton { + private readonly IBindable localUser = new Bindable(); + public DownloadButton(BeatmapSetInfo set, bool noVideo = false) { Width = 120; @@ -86,5 +93,17 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons } }; } + + [BackgroundDependencyLoader] + private void load(APIAccess api) + { + localUser.BindTo(api.LocalUser); + localUser.BindValueChanged(userChanged, true); + Enabled.BindValueChanged(enabledChanged, true); + } + + private void userChanged(User user) => Enabled.Value = user.IsSupporter; + + private void enabledChanged(bool enabled) => this.FadeColour(enabled ? Color4.White : Color4.Gray, 200, Easing.OutQuint); } }