mirror of
https://github.com/ppy/osu.git
synced 2025-03-24 06:47:18 +08:00
Implement ProfileItemBackground component
This commit is contained in:
parent
b30e268238
commit
59cb93321f
osu.Game/Overlays/Profile/Sections
@ -4,7 +4,6 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -13,32 +12,25 @@ using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
{
|
||||
public class DrawableMostPlayedBeatmap : OsuHoverContainer
|
||||
public class DrawableMostPlayedBeatmap : CompositeDrawable
|
||||
{
|
||||
private const int cover_width = 100;
|
||||
private const int corner_radius = 6;
|
||||
private const int height = 50;
|
||||
|
||||
private readonly BeatmapInfo beatmap;
|
||||
private readonly int playCount;
|
||||
|
||||
private Box background;
|
||||
|
||||
protected override IEnumerable<Drawable> EffectTargets => new[] { background };
|
||||
|
||||
public DrawableMostPlayedBeatmap(BeatmapInfo beatmap, int playCount)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
this.playCount = playCount;
|
||||
Enabled.Value = true; //manually enabled, because we have no action
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = height;
|
||||
Height = 50;
|
||||
|
||||
Masking = true;
|
||||
CornerRadius = corner_radius;
|
||||
@ -47,10 +39,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
IdleColour = colours.GreySeafoam;
|
||||
HoverColour = colours.GreySeafoamLight;
|
||||
|
||||
Children = new Drawable[]
|
||||
AddRangeInternal(new Drawable[]
|
||||
{
|
||||
new UpdateableBeatmapSetCover
|
||||
{
|
||||
@ -72,46 +61,48 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
CornerRadius = corner_radius,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Box { RelativeSizeAxes = Axes.Both },
|
||||
new Container
|
||||
new ProfileItemBackground
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(10),
|
||||
Children = new Drawable[]
|
||||
Child = new Container
|
||||
{
|
||||
new FillFlowContainer
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(10),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
new FillFlowContainer
|
||||
{
|
||||
new MostPlayedBeatmapMetadataContainer(beatmap),
|
||||
new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular))
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Colour = colours.GreySeafoamLighter
|
||||
}.With(d =>
|
||||
{
|
||||
d.AddText("mapped by ");
|
||||
d.AddUserLink(beatmap.Metadata.Author);
|
||||
}),
|
||||
}
|
||||
},
|
||||
new PlayCountText(playCount)
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight
|
||||
},
|
||||
}
|
||||
},
|
||||
new MostPlayedBeatmapMetadataContainer(beatmap),
|
||||
new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular))
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Colour = colours.GreySeafoamLighter
|
||||
}.With(d =>
|
||||
{
|
||||
d.AddText("mapped by ");
|
||||
d.AddUserLink(beatmap.Metadata.Author);
|
||||
}),
|
||||
}
|
||||
},
|
||||
new PlayCountText(playCount)
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private class MostPlayedBeatmapMetadataContainer : BeatmapMetadataContainer
|
||||
|
49
osu.Game/Overlays/Profile/Sections/ProfileItemBackground.cs
Normal file
49
osu.Game/Overlays/Profile/Sections/ProfileItemBackground.cs
Normal file
@ -0,0 +1,49 @@
|
||||
// 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;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
public class ProfileItemBackground : OsuHoverContainer
|
||||
{
|
||||
protected override IEnumerable<Drawable> EffectTargets => new[] { background };
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private readonly Box background;
|
||||
private readonly Container content;
|
||||
|
||||
public ProfileItemBackground()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Enabled.Value = true; //manually enabled, because we have no action
|
||||
Masking = true;
|
||||
CornerRadius = 6;
|
||||
|
||||
base.Content.AddRange(new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
IdleColour = colours.GreySeafoam;
|
||||
HoverColour = colours.GreySeafoamLight;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user