Update dependencies

This commit is contained in:
Andrei Zavatski
2019-10-13 11:23:49 +03:00
6 changed files with 85 additions and 23 deletions

View File

@ -0,0 +1,39 @@
// 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 System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Game.Overlays.Comments;
namespace osu.Game.Tests.Visual.Online
{
[TestFixture]
public class TestSceneCommentsHeader : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(CommentsHeader),
typeof(HeaderButton),
typeof(SortSelector),
};
private readonly Bindable<CommentsSortCriteria> sort = new Bindable<CommentsSortCriteria>();
private readonly BindableBool showDeleted = new BindableBool();
public TestSceneCommentsHeader()
{
Add(new CommentsHeader
{
Sort = { BindTarget = sort },
ShowDeleted = { BindTarget = showDeleted }
});
AddStep("Trigger ShowDeleted", () => showDeleted.Value = !showDeleted.Value);
AddStep("Select old", () => sort.Value = CommentsSortCriteria.Old);
AddStep("Select new", () => sort.Value = CommentsSortCriteria.New);
AddStep("Select top", () => sort.Value = CommentsSortCriteria.Top);
}
}
}

View File

@ -13,9 +13,9 @@ namespace osu.Game.Online.API.Requests
private readonly long id; private readonly long id;
private readonly int page; private readonly int page;
private readonly CommentableType type; private readonly CommentableType type;
private readonly SortCommentsBy sort; private readonly CommentsSortCriteria sort;
public GetCommentsRequest(CommentableType type, long id, SortCommentsBy sort = SortCommentsBy.New, int page = 1) public GetCommentsRequest(CommentableType type, long id, CommentsSortCriteria sort = CommentsSortCriteria.New, int page = 1)
{ {
this.type = type; this.type = type;
this.sort = sort; this.sort = sort;

View File

@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Comments
private readonly CommentableType type; private readonly CommentableType type;
private readonly long id; private readonly long id;
public readonly Bindable<SortCommentsBy> Sort = new Bindable<SortCommentsBy>(); public readonly Bindable<CommentsSortCriteria> Sort = new Bindable<CommentsSortCriteria>();
public readonly BindableBool ShowDeleted = new BindableBool(); public readonly BindableBool ShowDeleted = new BindableBool();
[Resolved] [Resolved]
@ -74,7 +74,7 @@ namespace osu.Game.Overlays.Comments
base.LoadComplete(); base.LoadComplete();
} }
private void onSortChanged(ValueChangedEvent<SortCommentsBy> sort) => getComments(); private void onSortChanged(ValueChangedEvent<CommentsSortCriteria> sort) => getComments();
private void getComments() private void getComments()
{ {

View File

@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Comments
private const int padding = 50; private const int padding = 50;
private const int text_size = 14; private const int text_size = 14;
public readonly Bindable<SortCommentsBy> Sort = new Bindable<SortCommentsBy>(); public readonly Bindable<CommentsSortCriteria> Sort = new Bindable<CommentsSortCriteria>();
public readonly BindableBool ShowDeleted = new BindableBool(); public readonly BindableBool ShowDeleted = new BindableBool();
private readonly Box background; private readonly Box background;
@ -79,13 +79,11 @@ namespace osu.Game.Overlays.Comments
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
background.Colour = colours.Gray4; background.Colour = colours.Gray3;
} }
private class ShowDeletedButton : HeaderButton private class ShowDeletedButton : HeaderButton
{ {
private const int spacing = 5;
public readonly BindableBool Checked = new BindableBool(); public readonly BindableBool Checked = new BindableBool();
private readonly SpriteIcon checkboxIcon; private readonly SpriteIcon checkboxIcon;
@ -96,7 +94,7 @@ namespace osu.Game.Overlays.Comments
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Spacing = new Vector2(spacing, 0), Spacing = new Vector2(5, 0),
Children = new Drawable[] Children = new Drawable[]
{ {
checkboxIcon = new SpriteIcon checkboxIcon = new SpriteIcon

View File

@ -50,7 +50,7 @@ namespace osu.Game.Overlays.Comments
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
background.Colour = colours.Gray6; background.Colour = colours.Gray4;
} }
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
@ -65,8 +65,8 @@ namespace osu.Game.Overlays.Comments
FadeOutBackground(); FadeOutBackground();
} }
public void FadeInBackground() => background.FadeIn(duration, Easing.OutQuint); protected void FadeInBackground() => background.FadeIn(duration, Easing.OutQuint);
public void FadeOutBackground() => background.FadeOut(duration, Easing.OutQuint); protected void FadeOutBackground() => background.FadeOut(duration, Easing.OutQuint);
} }
} }

View File

@ -10,16 +10,18 @@ using osuTK;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Allocation;
using osuTK.Graphics;
namespace osu.Game.Overlays.Comments namespace osu.Game.Overlays.Comments
{ {
public class SortSelector : OsuTabControl<SortCommentsBy> public class SortSelector : OsuTabControl<CommentsSortCriteria>
{ {
private const int spacing = 5; private const int spacing = 5;
protected override Dropdown<SortCommentsBy> CreateDropdown() => null; protected override Dropdown<CommentsSortCriteria> CreateDropdown() => null;
protected override TabItem<SortCommentsBy> CreateTabItem(SortCommentsBy value) => new SortTabItem(value); protected override TabItem<CommentsSortCriteria> CreateTabItem(CommentsSortCriteria value) => new SortTabItem(value);
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
{ {
@ -33,21 +35,23 @@ namespace osu.Game.Overlays.Comments
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
} }
private class SortTabItem : TabItem<SortCommentsBy> private class SortTabItem : TabItem<CommentsSortCriteria>
{ {
private readonly TabContent content; private readonly TabContent content;
public SortTabItem(SortCommentsBy value) public SortTabItem(CommentsSortCriteria value)
: base(value) : base(value)
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Child = content = new TabContent(value) Child = content = new TabContent(value)
{ Active = { BindTarget = Active } }; {
Active = { BindTarget = Active }
};
} }
protected override void OnActivated() => content.FadeInBackground(); protected override void OnActivated() => content.Activate();
protected override void OnDeactivated() => content.FadeOutBackground(); protected override void OnDeactivated() => content.Deactivate();
private class TabContent : HeaderButton private class TabContent : HeaderButton
{ {
@ -55,15 +59,36 @@ namespace osu.Game.Overlays.Comments
public readonly BindableBool Active = new BindableBool(); public readonly BindableBool Active = new BindableBool();
public TabContent(SortCommentsBy value) [Resolved]
private OsuColour colours { get; set; }
private readonly SpriteText text;
public TabContent(CommentsSortCriteria value)
{ {
Add(new SpriteText Add(text = new SpriteText
{ {
Font = OsuFont.GetFont(size: text_size), Font = OsuFont.GetFont(size: text_size),
Text = value.ToString() Text = value.ToString()
}); });
} }
public void Activate()
{
FadeInBackground();
text.Font = text.Font.With(weight: FontWeight.Bold);
text.Colour = colours.BlueLighter;
}
public void Deactivate()
{
if (!IsHovered)
FadeOutBackground();
text.Font = text.Font.With(weight: FontWeight.Medium);
text.Colour = Color4.White;
}
protected override void OnHoverLost(HoverLostEvent e) protected override void OnHoverLost(HoverLostEvent e)
{ {
if (!Active.Value) base.OnHoverLost(e); if (!Active.Value) base.OnHoverLost(e);
@ -72,7 +97,7 @@ namespace osu.Game.Overlays.Comments
} }
} }
public enum SortCommentsBy public enum CommentsSortCriteria
{ {
New, New,
Old, Old,