2019-10-10 09:06:25 +00: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.
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2021-06-18 12:00:08 +00:00
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
|
using osu.Framework.Audio.Sample;
|
2019-10-10 09:06:25 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osu.Framework.Input.Events;
|
2019-11-25 02:30:55 +00:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2019-10-10 09:06:25 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Comments
|
|
|
|
|
{
|
|
|
|
|
public class CommentsHeader : CompositeDrawable
|
|
|
|
|
{
|
2019-10-10 12:56:08 +00:00
|
|
|
|
public readonly Bindable<CommentsSortCriteria> Sort = new Bindable<CommentsSortCriteria>();
|
2019-10-10 09:06:25 +00:00
|
|
|
|
public readonly BindableBool ShowDeleted = new BindableBool();
|
|
|
|
|
|
|
|
|
|
private readonly Box background;
|
|
|
|
|
|
|
|
|
|
public CommentsHeader()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2019-10-14 12:32:16 +00:00
|
|
|
|
Height = 40;
|
|
|
|
|
|
2019-10-10 09:06:25 +00:00
|
|
|
|
AddRangeInternal(new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
background = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-10-14 12:32:16 +00:00
|
|
|
|
Padding = new MarginPadding { Horizontal = 50 },
|
2019-10-10 09:06:25 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-02-16 23:20:53 +00:00
|
|
|
|
new OverlaySortTabControl<CommentsSortCriteria>
|
2019-10-10 09:06:25 +00:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2020-02-16 23:20:53 +00:00
|
|
|
|
Current = Sort
|
2019-10-10 09:06:25 +00:00
|
|
|
|
},
|
|
|
|
|
new ShowDeletedButton
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
Checked = { BindTarget = ShowDeleted }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2020-01-27 11:58:27 +00:00
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
2019-10-10 09:06:25 +00:00
|
|
|
|
{
|
2020-01-27 11:58:27 +00:00
|
|
|
|
background.Colour = colourProvider.Background4;
|
2019-10-10 09:06:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class ShowDeletedButton : HeaderButton
|
|
|
|
|
{
|
|
|
|
|
public readonly BindableBool Checked = new BindableBool();
|
|
|
|
|
|
|
|
|
|
private readonly SpriteIcon checkboxIcon;
|
2021-06-18 12:00:08 +00:00
|
|
|
|
private Sample sampleChecked;
|
|
|
|
|
private Sample sampleUnchecked;
|
2019-10-10 09:06:25 +00:00
|
|
|
|
|
|
|
|
|
public ShowDeletedButton()
|
|
|
|
|
{
|
|
|
|
|
Add(new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
2019-10-10 10:24:22 +00:00
|
|
|
|
Spacing = new Vector2(5, 0),
|
2019-10-10 09:06:25 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
checkboxIcon = new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Size = new Vector2(10),
|
|
|
|
|
},
|
2019-11-25 02:30:55 +00:00
|
|
|
|
new OsuSpriteText
|
2019-10-10 09:06:25 +00:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2020-07-12 22:22:05 +00:00
|
|
|
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold),
|
2019-10-10 09:06:25 +00:00
|
|
|
|
Text = @"Show deleted"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-18 12:00:08 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(AudioManager audio)
|
|
|
|
|
{
|
|
|
|
|
sampleChecked = audio.Samples.Get(@"UI/check-on");
|
|
|
|
|
sampleUnchecked = audio.Samples.Get(@"UI/check-off");
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-10 09:06:25 +00:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
2019-10-14 12:49:02 +00:00
|
|
|
|
Checked.BindValueChanged(isChecked => checkboxIcon.Icon = isChecked.NewValue ? FontAwesome.Solid.CheckSquare : FontAwesome.Regular.Square, true);
|
2019-10-10 09:06:25 +00:00
|
|
|
|
base.LoadComplete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnClick(ClickEvent e)
|
|
|
|
|
{
|
|
|
|
|
Checked.Value = !Checked.Value;
|
2021-06-18 12:00:08 +00:00
|
|
|
|
|
|
|
|
|
if (Checked.Value)
|
|
|
|
|
sampleChecked?.Play();
|
|
|
|
|
else
|
|
|
|
|
sampleUnchecked?.Play();
|
|
|
|
|
|
2019-10-14 12:48:12 +00:00
|
|
|
|
return true;
|
2019-10-10 09:06:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-02-16 23:20:53 +00:00
|
|
|
|
|
|
|
|
|
public enum CommentsSortCriteria
|
|
|
|
|
{
|
2020-02-24 20:41:34 +00:00
|
|
|
|
[System.ComponentModel.Description(@"Recent")]
|
2020-02-16 23:20:53 +00:00
|
|
|
|
New,
|
|
|
|
|
Old,
|
|
|
|
|
Top
|
|
|
|
|
}
|
2019-10-10 09:06:25 +00:00
|
|
|
|
}
|