2020-02-24 12:28:33 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2020-02-24 12:28:33 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2021-06-26 01:10:04 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2021-07-01 03:28:07 +08:00
|
|
|
|
using osu.Game.Resources.Localisation.Web;
|
|
|
|
|
using osu.Framework.Extensions;
|
2020-02-24 12:28:33 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class OverlayPanelDisplayStyleControl : OsuTabControl<OverlayPanelDisplayStyle>
|
2020-02-24 12:28:33 +08:00
|
|
|
|
{
|
|
|
|
|
protected override Dropdown<OverlayPanelDisplayStyle> CreateDropdown() => null;
|
|
|
|
|
|
|
|
|
|
protected override TabItem<OverlayPanelDisplayStyle> CreateTabItem(OverlayPanelDisplayStyle value) => new PanelDisplayTabItem(value);
|
|
|
|
|
|
|
|
|
|
protected override bool AddEnumEntriesAutomatically => false;
|
|
|
|
|
|
|
|
|
|
public OverlayPanelDisplayStyleControl()
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
AddTabItem(new PanelDisplayTabItem(OverlayPanelDisplayStyle.Card)
|
|
|
|
|
{
|
|
|
|
|
Icon = FontAwesome.Solid.Square
|
|
|
|
|
});
|
|
|
|
|
AddTabItem(new PanelDisplayTabItem(OverlayPanelDisplayStyle.List)
|
|
|
|
|
{
|
|
|
|
|
Icon = FontAwesome.Solid.Bars
|
|
|
|
|
});
|
2020-07-19 01:24:38 +08:00
|
|
|
|
AddTabItem(new PanelDisplayTabItem(OverlayPanelDisplayStyle.Brick)
|
|
|
|
|
{
|
|
|
|
|
Icon = FontAwesome.Solid.Th
|
|
|
|
|
});
|
2020-02-24 12:28:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal
|
|
|
|
|
};
|
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
|
private partial class PanelDisplayTabItem : TabItem<OverlayPanelDisplayStyle>, IHasTooltip
|
2020-02-24 12:28:33 +08:00
|
|
|
|
{
|
|
|
|
|
public IconUsage Icon
|
|
|
|
|
{
|
|
|
|
|
set => icon.Icon = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
|
private OverlayColourProvider colourProvider { get; set; }
|
|
|
|
|
|
2021-07-01 03:28:07 +08:00
|
|
|
|
public LocalisableString TooltipText => Value.GetLocalisableDescription();
|
2020-02-24 12:28:33 +08:00
|
|
|
|
|
|
|
|
|
private readonly SpriteIcon icon;
|
|
|
|
|
|
|
|
|
|
public PanelDisplayTabItem(OverlayPanelDisplayStyle value)
|
|
|
|
|
: base(value)
|
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(11);
|
2020-02-25 04:37:46 +08:00
|
|
|
|
AddRange(new Drawable[]
|
2020-02-24 12:28:33 +08:00
|
|
|
|
{
|
2020-02-25 04:37:46 +08:00
|
|
|
|
icon = new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
FillMode = FillMode.Fit
|
|
|
|
|
},
|
|
|
|
|
new HoverClickSounds()
|
2020-02-24 12:28:33 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnActivated() => updateState();
|
|
|
|
|
|
|
|
|
|
protected override void OnDeactivated() => updateState();
|
|
|
|
|
|
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
|
|
|
|
{
|
|
|
|
|
updateState();
|
|
|
|
|
return base.OnHover(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
|
|
|
|
{
|
|
|
|
|
updateState();
|
|
|
|
|
base.OnHoverLost(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateState() => icon.Colour = Active.Value || IsHovered ? colourProvider.Light1 : Color4.White;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum OverlayPanelDisplayStyle
|
|
|
|
|
{
|
2021-07-31 06:38:54 +08:00
|
|
|
|
[LocalisableDescription(typeof(UsersStrings), nameof(UsersStrings.ViewModeCard))]
|
2020-02-24 12:28:33 +08:00
|
|
|
|
Card,
|
2021-07-01 03:28:07 +08:00
|
|
|
|
|
2021-07-31 06:38:54 +08:00
|
|
|
|
[LocalisableDescription(typeof(UsersStrings), nameof(UsersStrings.ViewModeList))]
|
|
|
|
|
List,
|
2021-07-01 03:28:07 +08:00
|
|
|
|
|
2021-07-31 06:38:54 +08:00
|
|
|
|
[LocalisableDescription(typeof(UsersStrings), nameof(UsersStrings.ViewModeBrick))]
|
|
|
|
|
Brick
|
2021-07-01 03:28:07 +08:00
|
|
|
|
}
|
2020-02-24 12:28:33 +08:00
|
|
|
|
}
|