mirror of
https://github.com/ppy/osu
synced 2025-01-08 23:29:43 +00:00
Update dependencies
This commit is contained in:
commit
27e3ffd293
39
osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs
Normal file
39
osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -13,9 +13,9 @@ namespace osu.Game.Online.API.Requests
|
||||
private readonly long id;
|
||||
private readonly int page;
|
||||
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.sort = sort;
|
||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Comments
|
||||
private readonly CommentableType type;
|
||||
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();
|
||||
|
||||
[Resolved]
|
||||
@ -74,7 +74,7 @@ namespace osu.Game.Overlays.Comments
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
private void onSortChanged(ValueChangedEvent<SortCommentsBy> sort) => getComments();
|
||||
private void onSortChanged(ValueChangedEvent<CommentsSortCriteria> sort) => getComments();
|
||||
|
||||
private void getComments()
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Comments
|
||||
private const int padding = 50;
|
||||
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();
|
||||
|
||||
private readonly Box background;
|
||||
@ -79,13 +79,11 @@ namespace osu.Game.Overlays.Comments
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
background.Colour = colours.Gray4;
|
||||
background.Colour = colours.Gray3;
|
||||
}
|
||||
|
||||
private class ShowDeletedButton : HeaderButton
|
||||
{
|
||||
private const int spacing = 5;
|
||||
|
||||
public readonly BindableBool Checked = new BindableBool();
|
||||
|
||||
private readonly SpriteIcon checkboxIcon;
|
||||
@ -96,7 +94,7 @@ namespace osu.Game.Overlays.Comments
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(spacing, 0),
|
||||
Spacing = new Vector2(5, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
checkboxIcon = new SpriteIcon
|
||||
|
@ -50,7 +50,7 @@ namespace osu.Game.Overlays.Comments
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
background.Colour = colours.Gray6;
|
||||
background.Colour = colours.Gray4;
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
@ -65,8 +65,8 @@ namespace osu.Game.Overlays.Comments
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -10,16 +10,18 @@ using osuTK;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Allocation;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Comments
|
||||
{
|
||||
public class SortSelector : OsuTabControl<SortCommentsBy>
|
||||
public class SortSelector : OsuTabControl<CommentsSortCriteria>
|
||||
{
|
||||
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
|
||||
{
|
||||
@ -33,21 +35,23 @@ namespace osu.Game.Overlays.Comments
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
private class SortTabItem : TabItem<SortCommentsBy>
|
||||
private class SortTabItem : TabItem<CommentsSortCriteria>
|
||||
{
|
||||
private readonly TabContent content;
|
||||
|
||||
public SortTabItem(SortCommentsBy value)
|
||||
public SortTabItem(CommentsSortCriteria value)
|
||||
: base(value)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
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
|
||||
{
|
||||
@ -55,15 +59,36 @@ namespace osu.Game.Overlays.Comments
|
||||
|
||||
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),
|
||||
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)
|
||||
{
|
||||
if (!Active.Value) base.OnHoverLost(e);
|
||||
@ -72,7 +97,7 @@ namespace osu.Game.Overlays.Comments
|
||||
}
|
||||
}
|
||||
|
||||
public enum SortCommentsBy
|
||||
public enum CommentsSortCriteria
|
||||
{
|
||||
New,
|
||||
Old,
|
||||
|
Loading…
Reference in New Issue
Block a user