1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-31 14:25:10 +08:00

Inherit GrayButton instead

Also fixes hover highlight.
This commit is contained in:
Joseph Madamba 2024-07-27 17:20:22 -07:00
parent 6a4872faa8
commit aed2b3c7c6
2 changed files with 12 additions and 50 deletions

View File

@ -3,9 +3,7 @@
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Beatmaps;
@ -15,41 +13,24 @@ using osuTK;
namespace osu.Game.Screens.Ranking
{
public partial class CollectionButton : OsuAnimatedButton, IHasPopover
public partial class CollectionButton : GrayButton, IHasPopover
{
private readonly Box background;
private readonly BeatmapInfo beatmapInfo;
public CollectionButton(BeatmapInfo beatmapInfo)
: base(FontAwesome.Solid.Book)
{
this.beatmapInfo = beatmapInfo;
Size = new Vector2(50, 30);
Children = new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both,
Depth = float.MaxValue
},
new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(13),
Icon = FontAwesome.Solid.Book,
},
};
TooltipText = "collections";
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
background.Colour = colours.Green;
Background.Colour = colours.Green;
Action = this.ShowPopover;
}

View File

@ -3,8 +3,6 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Logging;
using osu.Game.Beatmaps;
@ -19,17 +17,14 @@ using osuTK;
namespace osu.Game.Screens.Ranking
{
public partial class FavouriteButton : OsuAnimatedButton
public partial class FavouriteButton : GrayButton
{
private readonly Box background;
private readonly SpriteIcon icon;
public readonly BeatmapSetInfo BeatmapSetInfo;
private APIBeatmapSet? beatmapSet;
private readonly Bindable<BeatmapSetFavouriteState> current;
private PostBeatmapFavouriteRequest? favouriteRequest;
private readonly LoadingLayer loading;
private LoadingLayer loading = null!;
private readonly IBindable<APIUser> localUser = new Bindable<APIUser>();
@ -40,35 +35,21 @@ namespace osu.Game.Screens.Ranking
private OsuColour colours { get; set; } = null!;
public FavouriteButton(BeatmapSetInfo beatmapSetInfo)
: base(FontAwesome.Regular.Heart)
{
BeatmapSetInfo = beatmapSetInfo;
current = new BindableWithCurrent<BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(false, 0));
Size = new Vector2(50, 30);
Children = new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both,
Depth = float.MaxValue
},
icon = new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(13),
Icon = FontAwesome.Regular.Heart,
},
loading = new LoadingLayer(true, false),
};
Action = toggleFavouriteStatus;
}
[BackgroundDependencyLoader]
private void load()
{
Add(loading = new LoadingLayer(true, false));
current.BindValueChanged(_ => updateState(), true);
localUser.BindTo(api.LocalUser);
@ -147,14 +128,14 @@ namespace osu.Game.Screens.Ranking
{
if (current.Value.Favourited)
{
background.Colour = colours.Green;
icon.Icon = FontAwesome.Solid.Heart;
Background.Colour = colours.Green;
Icon.Icon = FontAwesome.Solid.Heart;
TooltipText = BeatmapsetsStrings.ShowDetailsUnfavourite;
}
else
{
background.Colour = colours.Gray4;
icon.Icon = FontAwesome.Regular.Heart;
Background.Colour = colours.Gray4;
Icon.Icon = FontAwesome.Regular.Heart;
TooltipText = BeatmapsetsStrings.ShowDetailsFavourite;
}
}