1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 06:23:21 +08:00

Basic implementation of BeatmapSetCommentsContainer

This commit is contained in:
Andrei Zavatski 2020-02-22 03:24:50 +03:00
parent e21db7dbbe
commit 894b50f955
2 changed files with 65 additions and 22 deletions

View File

@ -3,17 +3,14 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Overlays.BeatmapSet
{
@ -43,14 +40,6 @@ namespace osu.Game.Overlays.BeatmapSet
RelativeSizeAxes = Axes.X;
Height = base_height;
Masking = true;
EdgeEffect = new EdgeEffectParameters
{
Colour = Color4.Black.Opacity(0.25f),
Type = EdgeEffectType.Shadow,
Radius = 3,
Offset = new Vector2(0f, 1f),
};
Children = new Drawable[]
{

View File

@ -4,8 +4,10 @@
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
@ -13,8 +15,10 @@ using osu.Game.Graphics.Containers;
using osu.Game.Online.API.Requests;
using osu.Game.Overlays.BeatmapSet;
using osu.Game.Overlays.BeatmapSet.Scores;
using osu.Game.Overlays.Comments;
using osu.Game.Rulesets;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Overlays
{
@ -40,6 +44,7 @@ namespace osu.Game.Overlays
{
OsuScrollContainer scroll;
Info info;
BeatmapSetCommentsContainer comments;
Children = new Drawable[]
{
@ -51,15 +56,17 @@ namespace osu.Game.Overlays
{
RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false,
Child = new ReverseChildIDFillFlowContainer<Drawable>
Child = new ReverseChildIDFillFlowContainer<Section>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 20),
Children = new Drawable[]
Children = new[]
{
new ReverseChildIDFillFlowContainer<Drawable>
new Section
{
Child = new ReverseChildIDFillFlowContainer<Drawable>
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
@ -70,17 +77,26 @@ namespace osu.Game.Overlays
info = new Info()
}
},
new ScoresContainer
},
new Section
{
Child = new ScoresContainer
{
Beatmap = { BindTarget = Header.Picker.Beatmap }
}
},
new Section
{
Child = comments = new BeatmapSetCommentsContainer()
}
},
},
},
};
Header.BeatmapSet.BindTo(beatmapSet);
info.BeatmapSet.BindTo(beatmapSet);
comments.BeatmapSet.BindTo(beatmapSet);
Header.Picker.Beatmap.ValueChanged += b =>
{
@ -143,5 +159,43 @@ namespace osu.Game.Overlays
beatmapSet.Value = set;
Show();
}
private class Section : Container
{
public Section()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Masking = true;
EdgeEffect = new EdgeEffectParameters
{
Colour = Color4.Black.Opacity(0.25f),
Type = EdgeEffectType.Shadow,
Radius = 3,
Offset = new Vector2(0f, 1f),
};
}
}
private class BeatmapSetCommentsContainer : CommentsContainer
{
public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>();
public BeatmapSetCommentsContainer()
{
BeatmapSet.BindValueChanged(beatmapSet =>
{
if (beatmapSet.NewValue?.OnlineBeatmapSetID.HasValue != true)
{
Hide();
}
else
{
Show();
ShowComments(CommentableType.Beatmapset, beatmapSet.NewValue.OnlineBeatmapSetID.Value);
}
}, true);
}
}
}
}