1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 16:03:01 +08:00

CI fixes.

This commit is contained in:
DrabWeb 2017-09-12 23:41:10 -03:00
parent 08b5d4e16c
commit 97e5a0d4a3
9 changed files with 1040 additions and 1033 deletions

View File

@ -1,386 +1,385 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Testing; using osu.Game.Beatmaps;
using osu.Game.Beatmaps; using osu.Game.Overlays;
using osu.Game.Overlays; using osu.Game.Rulesets;
using osu.Game.Rulesets; using osu.Game.Users;
using osu.Game.Users;
namespace osu.Desktop.Tests.Visual
namespace osu.Desktop.VisualTests.Tests {
{ internal class TestCaseOnlineBeatmapSetOverlay : OsuTestCase
internal class TestCaseOnlineBeatmapSetOverlay : TestCase {
{ public override string Description => @"view online beatmap sets";
public override string Description => @"view online beatmap sets";
private readonly OnlineBeatmapSetOverlay overlay;
private readonly OnlineBeatmapSetOverlay overlay;
public TestCaseOnlineBeatmapSetOverlay()
public TestCaseOnlineBeatmapSetOverlay() {
{ Add(overlay = new OnlineBeatmapSetOverlay());
Add(overlay = new OnlineBeatmapSetOverlay()); }
}
[BackgroundDependencyLoader]
[BackgroundDependencyLoader] private void load(RulesetStore rulesets)
private void load(RulesetStore rulesets) {
{ var mania = rulesets.GetRuleset(3);
var mania = rulesets.GetRuleset(3); var taiko = rulesets.GetRuleset(1);
var taiko = rulesets.GetRuleset(1);
AddStep(@"show first", () =>
AddStep(@"show first", () => {
{ overlay.ShowBeatmapSet(new BeatmapSetInfo
overlay.ShowBeatmapSet(new BeatmapSetInfo {
{ Metadata = new BeatmapMetadata
Metadata = new BeatmapMetadata {
{ Title = @"Lachryma <Re:QueenM>",
Title = @"Lachryma <Re:QueenM>", Artist = @"Kaneko Chiharu",
Artist = @"Kaneko Chiharu", Source = @"SOUND VOLTEX III GRAVITY WARS",
Source = @"SOUND VOLTEX III GRAVITY WARS", Tags = @"sdvx grace the 5th kac original song contest konami bemani",
Tags = @"sdvx grace the 5th kac original song contest konami bemani", },
}, OnlineInfo = new BeatmapSetOnlineInfo
OnlineInfo = new BeatmapSetOnlineInfo {
{ Preview = @"https://b.ppy.sh/preview/415886.mp3",
Preview = @"https://b.ppy.sh/preview/415886.mp3", PlayCount = 681380,
PlayCount = 681380, FavouriteCount = 356,
FavouriteCount = 356, Submitted = new DateTime(2016, 2, 10),
Submitted = new DateTime(2016, 2, 10), Ranked = new DateTime(2016, 6, 19),
Ranked = new DateTime(2016, 6, 19), BPM = 236,
BPM = 236, Author = new User
Author = new User {
{ Username = @"Fresh Chicken",
Username = @"Fresh Chicken", Id = 3984370,
Id = 3984370, },
}, Covers = new BeatmapSetOnlineCovers
Covers = new BeatmapSetOnlineCovers {
{ Cover = @"https://assets.ppy.sh/beatmaps/415886/covers/cover.jpg?1465651778",
Cover = @"https://assets.ppy.sh/beatmaps/415886/covers/cover.jpg?1465651778", },
}, },
}, Beatmaps = new List<BeatmapInfo>
Beatmaps = new List<BeatmapInfo> {
{ new BeatmapInfo
new BeatmapInfo {
{ StarDifficulty = 1.36,
StarDifficulty = 1.36, Version = @"BASIC",
Version = @"BASIC", Ruleset = mania,
Ruleset = mania, Difficulty = new BeatmapDifficulty
Difficulty = new BeatmapDifficulty {
{ CircleSize = 4,
CircleSize = 4, DrainRate = 6.5f,
DrainRate = 6.5f, OverallDifficulty = 6.5f,
OverallDifficulty = 6.5f, ApproachRate = 5,
ApproachRate = 5, },
}, OnlineInfo = new BeatmapOnlineInfo
OnlineInfo = new BeatmapOnlineInfo {
{ Length = 115000,
Length = 115000, HasVideo = false,
HasVideo = false, CircleCount = 265,
CircleCount = 265, SliderCount = 71,
SliderCount = 71, PlayCount = 47906,
PlayCount = 47906, PassCount = 19899,
PassCount = 19899, },
}, Metrics = new BeatmapMetrics
Metrics = new BeatmapMetrics {
{ Ratings = Enumerable.Range(0, 10),
Ratings = Enumerable.Range(0, 10), Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), },
}, },
}, new BeatmapInfo
new BeatmapInfo {
{ StarDifficulty = 2.22,
StarDifficulty = 2.22, Version = @"NOVICE",
Version = @"NOVICE", Ruleset = mania,
Ruleset = mania, Difficulty = new BeatmapDifficulty
Difficulty = new BeatmapDifficulty {
{ CircleSize = 4,
CircleSize = 4, DrainRate = 7,
DrainRate = 7, OverallDifficulty = 7,
OverallDifficulty = 7, ApproachRate = 5,
ApproachRate = 5, },
}, OnlineInfo = new BeatmapOnlineInfo
OnlineInfo = new BeatmapOnlineInfo {
{ Length = 118000,
Length = 118000, HasVideo = false,
HasVideo = false, CircleCount = 592,
CircleCount = 592, SliderCount = 62,
SliderCount = 62, PlayCount = 162021,
PlayCount = 162021, PassCount = 72116,
PassCount = 72116, },
}, Metrics = new BeatmapMetrics
Metrics = new BeatmapMetrics {
{ Ratings = Enumerable.Range(0, 10),
Ratings = Enumerable.Range(0, 10), Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), },
}, },
}, new BeatmapInfo
new BeatmapInfo {
{ StarDifficulty = 3.49,
StarDifficulty = 3.49, Version = @"ADVANCED",
Version = @"ADVANCED", Ruleset = mania,
Ruleset = mania, Difficulty = new BeatmapDifficulty
Difficulty = new BeatmapDifficulty {
{ CircleSize = 4,
CircleSize = 4, DrainRate = 7.5f,
DrainRate = 7.5f, OverallDifficulty = 7.5f,
OverallDifficulty = 7.5f, ApproachRate = 5,
ApproachRate = 5, },
}, OnlineInfo = new BeatmapOnlineInfo
OnlineInfo = new BeatmapOnlineInfo {
{ Length = 118000,
Length = 118000, HasVideo = false,
HasVideo = false, CircleCount = 1042,
CircleCount = 1042, SliderCount = 79,
SliderCount = 79, PlayCount = 225178,
PlayCount = 225178, PassCount = 73001,
PassCount = 73001, },
}, Metrics = new BeatmapMetrics
Metrics = new BeatmapMetrics {
{ Ratings = Enumerable.Range(0, 10),
Ratings = Enumerable.Range(0, 10), Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), },
}, },
}, new BeatmapInfo
new BeatmapInfo {
{ StarDifficulty = 4.24,
StarDifficulty = 4.24, Version = @"EXHAUST",
Version = @"EXHAUST", Ruleset = mania,
Ruleset = mania, Difficulty = new BeatmapDifficulty
Difficulty = new BeatmapDifficulty {
{ CircleSize = 4,
CircleSize = 4, DrainRate = 8,
DrainRate = 8, OverallDifficulty = 8,
OverallDifficulty = 8, ApproachRate = 5,
ApproachRate = 5, },
}, OnlineInfo = new BeatmapOnlineInfo
OnlineInfo = new BeatmapOnlineInfo {
{ Length = 118000,
Length = 118000, HasVideo = false,
HasVideo = false, CircleCount = 1352,
CircleCount = 1352, SliderCount = 69,
SliderCount = 69, PlayCount = 131545,
PlayCount = 131545, PassCount = 42703,
PassCount = 42703, },
}, Metrics = new BeatmapMetrics
Metrics = new BeatmapMetrics {
{ Ratings = Enumerable.Range(0, 10),
Ratings = Enumerable.Range(0, 10), Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), },
}, },
}, new BeatmapInfo
new BeatmapInfo {
{ StarDifficulty = 5.26,
StarDifficulty = 5.26, Version = @"GRAVITY",
Version = @"GRAVITY", Ruleset = mania,
Ruleset = mania, Difficulty = new BeatmapDifficulty
Difficulty = new BeatmapDifficulty {
{ CircleSize = 4,
CircleSize = 4, DrainRate = 8.5f,
DrainRate = 8.5f, OverallDifficulty = 8.5f,
OverallDifficulty = 8.5f, ApproachRate = 5,
ApproachRate = 5, },
}, OnlineInfo = new BeatmapOnlineInfo
OnlineInfo = new BeatmapOnlineInfo {
{ Length = 118000,
Length = 118000, HasVideo = false,
HasVideo = false, CircleCount = 1730,
CircleCount = 1730, SliderCount = 115,
SliderCount = 115, PlayCount = 117673,
PlayCount = 117673, PassCount = 24241,
PassCount = 24241, },
}, Metrics = new BeatmapMetrics
Metrics = new BeatmapMetrics {
{ Ratings = Enumerable.Range(0, 10),
Ratings = Enumerable.Range(0, 10), Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), },
}, },
}, },
}, });
}); });
});
AddStep(@"show second", () =>
AddStep(@"show second", () => {
{ overlay.ShowBeatmapSet(new BeatmapSetInfo
overlay.ShowBeatmapSet(new BeatmapSetInfo {
{ Metadata = new BeatmapMetadata
Metadata = new BeatmapMetadata {
{ Title = @"Soumatou Labyrinth",
Title = @"Soumatou Labyrinth", Artist = @"Yunomi with Momobako&miko",
Artist = @"Yunomi with Momobako&miko", Tags = @"mmbk.com yuzu__rinrin charlotte",
Tags = @"mmbk.com yuzu__rinrin charlotte", },
}, OnlineInfo = new BeatmapSetOnlineInfo
OnlineInfo = new BeatmapSetOnlineInfo {
{ Preview = @"https://b.ppy.sh/preview/625493.mp3",
Preview = @"https://b.ppy.sh/preview/625493.mp3", PlayCount = 22996,
PlayCount = 22996, FavouriteCount = 58,
FavouriteCount = 58, Submitted = new DateTime(2016, 6, 11),
Submitted = new DateTime(2016, 6, 11), Ranked = new DateTime(2016, 7, 12),
Ranked = new DateTime(2016, 7, 12), BPM = 160,
BPM = 160, Author = new User
Author = new User {
{ Username = @"komasy",
Username = @"komasy", Id = 1980256,
Id = 1980256, },
}, Covers = new BeatmapSetOnlineCovers
Covers = new BeatmapSetOnlineCovers {
{ Cover = @"https://assets.ppy.sh/beatmaps/625493/covers/cover.jpg?1499167472",
Cover = @"https://assets.ppy.sh/beatmaps/625493/covers/cover.jpg?1499167472", },
}, },
}, Beatmaps = new List<BeatmapInfo>
Beatmaps = new List<BeatmapInfo> {
{ new BeatmapInfo
new BeatmapInfo {
{ StarDifficulty = 1.40,
StarDifficulty = 1.40, Version = @"yzrin's Kantan",
Version = @"yzrin's Kantan", Ruleset = taiko,
Ruleset = taiko, Difficulty = new BeatmapDifficulty
Difficulty = new BeatmapDifficulty {
{ CircleSize = 2,
CircleSize = 2, DrainRate = 7,
DrainRate = 7, OverallDifficulty = 3,
OverallDifficulty = 3, ApproachRate = 10,
ApproachRate = 10, },
}, OnlineInfo = new BeatmapOnlineInfo
OnlineInfo = new BeatmapOnlineInfo {
{ Length = 193000,
Length = 193000, HasVideo = false,
HasVideo = false, CircleCount = 262,
CircleCount = 262, SliderCount = 0,
SliderCount = 0, PlayCount = 3952,
PlayCount = 3952, PassCount = 1373,
PassCount = 1373, },
}, Metrics = new BeatmapMetrics
Metrics = new BeatmapMetrics {
{ Ratings = Enumerable.Range(0, 10),
Ratings = Enumerable.Range(0, 10), Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), },
}, },
}, new BeatmapInfo
new BeatmapInfo {
{ StarDifficulty = 2.23,
StarDifficulty = 2.23, Version = @"Futsuu",
Version = @"Futsuu", Ruleset = taiko,
Ruleset = taiko, Difficulty = new BeatmapDifficulty
Difficulty = new BeatmapDifficulty {
{ CircleSize = 2,
CircleSize = 2, DrainRate = 6,
DrainRate = 6, OverallDifficulty = 4,
OverallDifficulty = 4, ApproachRate = 10,
ApproachRate = 10, },
}, OnlineInfo = new BeatmapOnlineInfo
OnlineInfo = new BeatmapOnlineInfo {
{ Length = 193000,
Length = 193000, HasVideo = false,
HasVideo = false, CircleCount = 464,
CircleCount = 464, SliderCount = 0,
SliderCount = 0, PlayCount = 4833,
PlayCount = 4833, PassCount = 920,
PassCount = 920, },
}, Metrics = new BeatmapMetrics
Metrics = new BeatmapMetrics {
{ Ratings = Enumerable.Range(0, 10),
Ratings = Enumerable.Range(0, 10), Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), },
}, },
}, new BeatmapInfo
new BeatmapInfo {
{ StarDifficulty = 3.19,
StarDifficulty = 3.19, Version = @"Muzukashii",
Version = @"Muzukashii", Ruleset = taiko,
Ruleset = taiko, Difficulty = new BeatmapDifficulty
Difficulty = new BeatmapDifficulty {
{ CircleSize = 2,
CircleSize = 2, DrainRate = 6,
DrainRate = 6, OverallDifficulty = 5,
OverallDifficulty = 5, ApproachRate = 10,
ApproachRate = 10, },
}, OnlineInfo = new BeatmapOnlineInfo
OnlineInfo = new BeatmapOnlineInfo {
{ Length = 193000,
Length = 193000, HasVideo = false,
HasVideo = false, CircleCount = 712,
CircleCount = 712, SliderCount = 0,
SliderCount = 0, PlayCount = 4405,
PlayCount = 4405, PassCount = 854,
PassCount = 854, },
}, Metrics = new BeatmapMetrics
Metrics = new BeatmapMetrics {
{ Ratings = Enumerable.Range(0, 10),
Ratings = Enumerable.Range(0, 10), Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), },
}, },
}, new BeatmapInfo
new BeatmapInfo {
{ StarDifficulty = 3.97,
StarDifficulty = 3.97, Version = @"Charlotte's Oni",
Version = @"Charlotte's Oni", Ruleset = taiko,
Ruleset = taiko, Difficulty = new BeatmapDifficulty
Difficulty = new BeatmapDifficulty {
{ CircleSize = 5,
CircleSize = 5, DrainRate = 6,
DrainRate = 6, OverallDifficulty = 5.5f,
OverallDifficulty = 5.5f, ApproachRate = 10,
ApproachRate = 10, },
}, OnlineInfo = new BeatmapOnlineInfo
OnlineInfo = new BeatmapOnlineInfo {
{ Length = 193000,
Length = 193000, HasVideo = false,
HasVideo = false, CircleCount = 943,
CircleCount = 943, SliderCount = 0,
SliderCount = 0, PlayCount = 3950,
PlayCount = 3950, PassCount = 693,
PassCount = 693, },
}, Metrics = new BeatmapMetrics
Metrics = new BeatmapMetrics {
{ Ratings = Enumerable.Range(0, 10),
Ratings = Enumerable.Range(0, 10), Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), },
}, },
}, new BeatmapInfo
new BeatmapInfo {
{ StarDifficulty = 5.08,
StarDifficulty = 5.08, Version = @"Labyrinth Oni",
Version = @"Labyrinth Oni", Ruleset = taiko,
Ruleset = taiko, Difficulty = new BeatmapDifficulty
Difficulty = new BeatmapDifficulty {
{ CircleSize = 5,
CircleSize = 5, DrainRate = 5,
DrainRate = 5, OverallDifficulty = 6,
OverallDifficulty = 6, ApproachRate = 10,
ApproachRate = 10, },
}, OnlineInfo = new BeatmapOnlineInfo
OnlineInfo = new BeatmapOnlineInfo {
{ Length = 193000,
Length = 193000, HasVideo = false,
HasVideo = false, CircleCount = 1068,
CircleCount = 1068, SliderCount = 0,
SliderCount = 0, PlayCount = 5856,
PlayCount = 5856, PassCount = 1207,
PassCount = 1207, },
}, Metrics = new BeatmapMetrics
Metrics = new BeatmapMetrics {
{ Ratings = Enumerable.Range(0, 10),
Ratings = Enumerable.Range(0, 10), Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), },
}, },
}, },
}, });
}); });
});
AddStep(@"hide", overlay.Hide);
AddStep(@"hide", overlay.Hide); AddStep(@"show without reload", overlay.Show);
AddStep(@"show without reload", overlay.Show); }
} }
} }
}

View File

@ -25,12 +25,12 @@ namespace osu.Game.Beatmaps
/// <summary> /// <summary>
/// The date this beatmap set was ranked. /// The date this beatmap set was ranked.
/// </summary> /// </summary>
public DateTimeOffset Ranked { get; set; } public DateTimeOffset? Ranked { get; set; }
/// <summary> /// <summary>
/// The date this beatmap set was last updated. /// The date this beatmap set was last updated.
/// </summary> /// </summary>
public DateTimeOffset LastUpdated { get; set; } public DateTimeOffset? LastUpdated { get; set; }
/// <summary> /// <summary>
/// The different sizes of cover art for this beatmap set. /// The different sizes of cover art for this beatmap set.

View File

@ -1,82 +1,91 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Users; using osu.Game.Users;
namespace osu.Game.Overlays.OnlineBeatmapSet namespace osu.Game.Overlays.OnlineBeatmapSet
{ {
public class AuthorInfo : Container public class AuthorInfo : Container
{ {
private const float height = 50; private const float height = 50;
public AuthorInfo(BeatmapSetOnlineInfo info) public AuthorInfo(BeatmapSetOnlineInfo info)
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
Height = height; Height = height;
Children = new Drawable[] FillFlowContainer fields;
{ Children = new Drawable[]
new UpdateableAvatar {
{ new UpdateableAvatar
Size = new Vector2(height), {
CornerRadius = 3, Size = new Vector2(height),
Masking = true, CornerRadius = 3,
User = info.Author, Masking = true,
EdgeEffect = new EdgeEffectParameters User = info.Author,
{ EdgeEffect = new EdgeEffectParameters
Colour = Color4.Black.Opacity(0.25f), {
Type = EdgeEffectType.Shadow, Colour = Color4.Black.Opacity(0.25f),
Radius = 3, Type = EdgeEffectType.Shadow,
Offset = new Vector2(0f, 1f), Radius = 3,
}, Offset = new Vector2(0f, 1f),
}, },
new FillFlowContainer },
{ fields = new FillFlowContainer
RelativeSizeAxes = Axes.Both, {
Direction = FillDirection.Vertical, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = height + 5 }, Direction = FillDirection.Vertical,
Children = new Drawable[] Padding = new MarginPadding { Left = height + 5 },
{ Children = new Drawable[]
new Field("made by", info.Author.Username, @"Exo2.0-RegularItalic"), {
new Field("submitted on", info.Submitted.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold") new Field("made by", info.Author.Username, @"Exo2.0-RegularItalic"),
{ new Field("submitted on", info.Submitted.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold")
Margin = new MarginPadding { Top = 5 }, {
}, Margin = new MarginPadding { Top = 5 },
new Field(info.Ranked == null ? "last updated on " : "ranked on ", (info.Ranked == null ? info.Submitted : info.Ranked).ToString(@"MMM d, yyyy"), @"Exo2.0-Bold"), },
}, },
}, },
}; };
}
if (info.Ranked.HasValue)
private class Field : FillFlowContainer {
{ fields.Add(new Field("ranked on ", info.Ranked.Value.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold"));
public Field(string first, string second, string secondFont) }
{ else if (info.LastUpdated.HasValue)
AutoSizeAxes = Axes.Both; {
Direction = FillDirection.Horizontal; fields.Add(new Field("last updated on ", info.LastUpdated.Value.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold"));
}
Children = new[] }
{
new OsuSpriteText private class Field : FillFlowContainer
{ {
Text = $"{first} ", public Field(string first, string second, string secondFont)
TextSize = 13, {
}, AutoSizeAxes = Axes.Both;
new OsuSpriteText Direction = FillDirection.Horizontal;
{
Text = second, Children = new[]
TextSize = 13, {
Font = secondFont, new OsuSpriteText
}, {
}; Text = $"{first} ",
} TextSize = 13,
} },
} new OsuSpriteText
} {
Text = second,
TextSize = 13,
Font = secondFont,
},
};
}
}
}
}

View File

@ -27,14 +27,13 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
beatmap = value; beatmap = value;
length.Value = TimeSpan.FromMilliseconds(beatmap.OnlineInfo.Length).ToString(@"m\:ss"); length.Value = TimeSpan.FromMilliseconds(beatmap.OnlineInfo.Length).ToString(@"m\:ss");
circleCount.Value = string.Format(@"{0:n0}", beatmap.OnlineInfo.CircleCount); circleCount.Value = beatmap.OnlineInfo.CircleCount.ToString("N0");
sliderCount.Value = string.Format(@"{0:n0}", beatmap.OnlineInfo.SliderCount); sliderCount.Value = beatmap.OnlineInfo.SliderCount.ToString("N0");
} }
} }
public BasicStats(BeatmapSetInfo set) public BasicStats(BeatmapSetInfo set)
{ {
var statWidth = 0.25f;
Child = new FillFlowContainer Child = new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -42,14 +41,14 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Children = new[] Children = new[]
{ {
length = new Statistic(FontAwesome.fa_clock_o, "Length") { Width = statWidth }, length = new Statistic(FontAwesome.fa_clock_o, "Length") { Width = 0.25f },
new Statistic(FontAwesome.fa_circle, "BPM") new Statistic(FontAwesome.fa_circle, "BPM")
{ {
Width = statWidth, Width = 0.25f,
Value = set.OnlineInfo.BPM.ToString(@"0.##"), Value = set.OnlineInfo.BPM.ToString(@"0.##"),
}, },
circleCount = new Statistic(FontAwesome.fa_circle_o, "Circle Count") { Width = statWidth }, circleCount = new Statistic(FontAwesome.fa_circle_o, "Circle Count") { Width = 0.25f },
sliderCount = new Statistic(FontAwesome.fa_circle, "Slider Count") { Width = statWidth }, sliderCount = new Statistic(FontAwesome.fa_circle, "Slider Count") { Width = 0.25f },
}, },
}; };
} }

View File

@ -1,264 +1,264 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using System.Linq; using System.Linq;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.OnlineBeatmapSet namespace osu.Game.Overlays.OnlineBeatmapSet
{ {
public class BeatmapPicker : Container public class BeatmapPicker : Container
{ {
private const float tile_icon_padding = 7; private const float tile_icon_padding = 7;
private const float tile_spacing = 2; private const float tile_spacing = 2;
private readonly OsuSpriteText version, starRating; private readonly OsuSpriteText version, starRating;
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>(); public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
public BeatmapPicker(BeatmapSetInfo set) public BeatmapPicker(BeatmapSetInfo set)
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
TilesFillFlowContainer tileContainer; TilesFillFlowContainer tileContainer;
Children = new Drawable[] Children = new Drawable[]
{ {
new FillFlowContainer new FillFlowContainer
{ {
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
tileContainer = new TilesFillFlowContainer tileContainer = new TilesFillFlowContainer
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Left = -(tile_icon_padding + tile_spacing / 2) }, Margin = new MarginPadding { Left = -(tile_icon_padding + tile_spacing / 2) },
OnLostHover = () => OnLostHover = () =>
{ {
showBeatmap(Beatmap.Value); showBeatmap(Beatmap.Value);
starRating.FadeOut(100); starRating.FadeOut(100);
}, },
}, },
new FillFlowContainer new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Top = 10 }, Margin = new MarginPadding { Top = 10 },
Spacing = new Vector2(5f), Spacing = new Vector2(5f),
Children = new[] Children = new[]
{ {
version = new OsuSpriteText version = new OsuSpriteText
{ {
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
TextSize = 20, TextSize = 20,
Font = @"Exo2.0-Bold", Font = @"Exo2.0-Bold",
}, },
starRating = new OsuSpriteText starRating = new OsuSpriteText
{ {
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
TextSize = 13, TextSize = 13,
Font = @"Exo2.0-Bold", Font = @"Exo2.0-Bold",
Text = "Star Difficulty", Text = "Star Difficulty",
Alpha = 0, Alpha = 0,
Margin = new MarginPadding { Bottom = 1 }, Margin = new MarginPadding { Bottom = 1 },
}, },
}, },
}, },
new FillFlowContainer new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Spacing = new Vector2(10f), Spacing = new Vector2(10f),
Margin = new MarginPadding { Top = 5 }, Margin = new MarginPadding { Top = 5 },
Children = new[] Children = new[]
{ {
new Statistic(FontAwesome.fa_play_circle, set.OnlineInfo.PlayCount), new Statistic(FontAwesome.fa_play_circle, set.OnlineInfo.PlayCount),
new Statistic(FontAwesome.fa_heart, set.OnlineInfo.FavouriteCount), new Statistic(FontAwesome.fa_heart, set.OnlineInfo.FavouriteCount),
}, },
}, },
}, },
}, },
}; };
Beatmap.Value = set.Beatmaps.First(); Beatmap.Value = set.Beatmaps.First();
Beatmap.ValueChanged += showBeatmap; Beatmap.ValueChanged += showBeatmap;
tileContainer.ChildrenEnumerable = set.Beatmaps.Select(b => new BeatmapTile(b, Beatmap) tileContainer.ChildrenEnumerable = set.Beatmaps.Select(b => new BeatmapTile(b, Beatmap)
{ {
OnHovered = beatmap => OnHovered = beatmap =>
{ {
showBeatmap(beatmap); showBeatmap(beatmap);
starRating.Text = string.Format("Star Difficulty {0:N2}", beatmap.StarDifficulty); starRating.Text = beatmap.StarDifficulty.ToString("Star Difficulty 0.##");
starRating.FadeIn(100); starRating.FadeIn(100);
}, },
}); });
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
starRating.Colour = colours.Yellow; starRating.Colour = colours.Yellow;
} }
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
// done here so everything can bind in intialization and get the first trigger // done here so everything can bind in intialization and get the first trigger
Beatmap.TriggerChange(); Beatmap.TriggerChange();
} }
private void showBeatmap(BeatmapInfo beatmap) => version.Text = beatmap.Version; private void showBeatmap(BeatmapInfo beatmap) => version.Text = beatmap.Version;
private class TilesFillFlowContainer : FillFlowContainer private class TilesFillFlowContainer : FillFlowContainer
{ {
public Action OnLostHover; public Action OnLostHover;
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(InputState state)
{ {
base.OnHoverLost(state); base.OnHoverLost(state);
OnLostHover?.Invoke(); OnLostHover?.Invoke();
} }
} }
private class BeatmapTile : OsuClickableContainer private class BeatmapTile : OsuClickableContainer
{ {
private const float transition_duration = 100; private const float transition_duration = 100;
private const float size = 52; private const float size = 52;
private readonly BeatmapInfo beatmap; private readonly BeatmapInfo beatmap;
private readonly Bindable<BeatmapInfo> bindable = new Bindable<BeatmapInfo>(); private readonly Bindable<BeatmapInfo> bindable = new Bindable<BeatmapInfo>();
private readonly Container bg; private readonly Container bg;
private readonly DifficultyIcon icon; private readonly DifficultyIcon icon;
public Action<BeatmapInfo> OnHovered; public Action<BeatmapInfo> OnHovered;
public BeatmapTile(BeatmapInfo beatmap, Bindable<BeatmapInfo> bindable) public BeatmapTile(BeatmapInfo beatmap, Bindable<BeatmapInfo> bindable)
{ {
this.beatmap = beatmap; this.beatmap = beatmap;
Size = new Vector2(size); Size = new Vector2(size);
Margin = new MarginPadding { Horizontal = tile_spacing / 2 }; Margin = new MarginPadding { Horizontal = tile_spacing / 2 };
Children = new Drawable[] Children = new Drawable[]
{ {
bg = new Container bg = new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Masking = true, Masking = true,
CornerRadius = 4, CornerRadius = 4,
Child = new Box Child = new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(0.5f), Colour = Color4.Black.Opacity(0.5f),
}, },
}, },
icon = new DifficultyIcon(beatmap) icon = new DifficultyIcon(beatmap)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Size = new Vector2(size - tile_icon_padding * 2), Size = new Vector2(size - tile_icon_padding * 2),
Margin = new MarginPadding { Bottom = 1 }, Margin = new MarginPadding { Bottom = 1 },
}, },
}; };
Action = () => this.bindable.Value = beatmap; Action = () => this.bindable.Value = beatmap;
this.bindable.ValueChanged += beatmapChanged; this.bindable.ValueChanged += beatmapChanged;
this.bindable.BindTo(bindable); this.bindable.BindTo(bindable);
} }
protected override bool OnHover(InputState state) protected override bool OnHover(InputState state)
{ {
fadeIn(); fadeIn();
OnHovered?.Invoke(beatmap); OnHovered?.Invoke(beatmap);
return base.OnHover(state); return base.OnHover(state);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(InputState state)
{ {
if (bindable.Value != beatmap) if (bindable.Value != beatmap)
fadeOut(); fadeOut();
base.OnHoverLost(state); base.OnHoverLost(state);
} }
private void beatmapChanged(BeatmapInfo value) private void beatmapChanged(BeatmapInfo value)
{ {
if (value == beatmap) if (value == beatmap)
fadeIn(); fadeIn();
else else
fadeOut(); fadeOut();
} }
private void fadeIn() private void fadeIn()
{ {
bg.FadeIn(transition_duration); bg.FadeIn(transition_duration);
icon.FadeIn(transition_duration); icon.FadeIn(transition_duration);
} }
private void fadeOut() private void fadeOut()
{ {
bg.FadeOut(); bg.FadeOut();
icon.FadeTo(0.7f, transition_duration); icon.FadeTo(0.7f, transition_duration);
} }
} }
private class Statistic : FillFlowContainer private class Statistic : FillFlowContainer
{ {
private readonly OsuSpriteText text; private readonly OsuSpriteText text;
private int value; private int value;
public int Value public int Value
{ {
get { return value; } get { return value; }
set set
{ {
this.value = value; this.value = value;
text.Text = Value.ToString(@"N0"); text.Text = Value.ToString(@"N0");
} }
} }
public Statistic(FontAwesome icon, int value = 0) public Statistic(FontAwesome icon, int value = 0)
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Direction = FillDirection.Horizontal; Direction = FillDirection.Horizontal;
Spacing = new Vector2(2f); Spacing = new Vector2(2f);
Children = new Drawable[] Children = new Drawable[]
{ {
new SpriteIcon new SpriteIcon
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Icon = icon, Icon = icon,
Shadow = true, Shadow = true,
Size = new Vector2(13), Size = new Vector2(13),
}, },
text = new OsuSpriteText text = new OsuSpriteText
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Font = @"Exo2.0-SemiBoldItalic", Font = @"Exo2.0-SemiBoldItalic",
TextSize = 14, TextSize = 14,
}, },
}; };
Value = value; Value = value;
} }
} }
} }
} }

View File

@ -1,108 +1,108 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Screens.Select.Details; using osu.Game.Screens.Select.Details;
namespace osu.Game.Overlays.OnlineBeatmapSet namespace osu.Game.Overlays.OnlineBeatmapSet
{ {
public class Details : FillFlowContainer public class Details : FillFlowContainer
{ {
private readonly BasicStats basic; private readonly BasicStats basic;
private readonly AdvancedStats advanced; private readonly AdvancedStats advanced;
private readonly UserRatings ratings; private readonly UserRatings ratings;
private BeatmapInfo beatmap; private BeatmapInfo beatmap;
public BeatmapInfo Beatmap public BeatmapInfo Beatmap
{ {
get { return beatmap; } get { return beatmap; }
set set
{ {
if (value == beatmap) return; if (value == beatmap) return;
beatmap = value; beatmap = value;
basic.Beatmap = advanced.Beatmap = Beatmap; basic.Beatmap = advanced.Beatmap = Beatmap;
ratings.Metrics = Beatmap.Metrics; ratings.Metrics = Beatmap.Metrics;
} }
} }
public Details(BeatmapSetInfo set) public Details(BeatmapSetInfo set)
{ {
Width = OnlineBeatmapSetOverlay.RIGHT_WIDTH; Width = OnlineBeatmapSetOverlay.RIGHT_WIDTH;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
Spacing = new Vector2(1f); Spacing = new Vector2(1f);
Children = new Drawable[] Children = new Drawable[]
{ {
new AsyncLoadWrapper(new PreviewButton(set) new AsyncLoadWrapper(new PreviewButton(set)
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
}) })
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
}, },
new DetailBox new DetailBox
{ {
Child = basic = new BasicStats(set) Child = basic = new BasicStats(set)
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Vertical = 10 }, Margin = new MarginPadding { Vertical = 10 },
}, },
}, },
new DetailBox new DetailBox
{ {
Child = advanced = new AdvancedStats Child = advanced = new AdvancedStats
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Vertical = 7.5f }, Margin = new MarginPadding { Vertical = 7.5f },
}, },
}, },
new DetailBox new DetailBox
{ {
Child = ratings = new UserRatings Child = ratings = new UserRatings
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Height = 95, Height = 95,
Margin = new MarginPadding { Top = 10 }, Margin = new MarginPadding { Top = 10 },
}, },
}, },
}; };
} }
private class DetailBox : Container private class DetailBox : Container
{ {
private Container content; private readonly Container content;
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;
public DetailBox() public DetailBox()
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new Box new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(0.5f), Colour = Color4.Black.Opacity(0.5f),
}, },
content = new Container content = new Container
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Horizontal = 15 }, Padding = new MarginPadding { Horizontal = 15 },
}, },
}; };
} }
} }
} }
} }

View File

@ -1,59 +1,59 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK; using OpenTK;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.OnlineBeatmapSet namespace osu.Game.Overlays.OnlineBeatmapSet
{ {
public class DownloadButton : HeaderButton public class DownloadButton : HeaderButton
{ {
public DownloadButton(string title, string subtitle) public DownloadButton(string title, string subtitle)
{ {
Width = 120; Width = 120;
RelativeSizeAxes = Axes.Y; RelativeSizeAxes = Axes.Y;
Child = new Container Child = new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Horizontal = 10 }, Padding = new MarginPadding { Horizontal = 10 },
Children = new Drawable[] Children = new Drawable[]
{ {
new FillFlowContainer new FillFlowContainer
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Children = new[] Children = new[]
{ {
new OsuSpriteText new OsuSpriteText
{ {
Text = title, Text = title,
TextSize = 13, TextSize = 13,
Font = @"Exo2.0-Bold", Font = @"Exo2.0-Bold",
}, },
new OsuSpriteText new OsuSpriteText
{ {
Text = subtitle, Text = subtitle,
TextSize = 11, TextSize = 11,
Font = @"Exo2.0-Bold", Font = @"Exo2.0-Bold",
}, },
}, },
}, },
new SpriteIcon new SpriteIcon
{ {
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
Icon = FontAwesome.fa_download, Icon = FontAwesome.fa_download,
Size = new Vector2(16), Size = new Vector2(16),
Margin = new MarginPadding { Right = 5 }, Margin = new MarginPadding { Right = 5 },
}, },
}, },
}; };
} }
} }
} }

View File

@ -1,80 +1,80 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE] // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK; using OpenTK;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Backgrounds;
namespace osu.Game.Overlays.OnlineBeatmapSet namespace osu.Game.Overlays.OnlineBeatmapSet
{ {
public class FavouriteButton : HeaderButton public class FavouriteButton : HeaderButton
{ {
public readonly Bindable<bool> Favourited = new Bindable<bool>(); public readonly Bindable<bool> Favourited = new Bindable<bool>();
public FavouriteButton() public FavouriteButton()
{ {
RelativeSizeAxes = Axes.Y; RelativeSizeAxes = Axes.Y;
Container pink; Container pink;
SpriteIcon icon; SpriteIcon icon;
Children = new Drawable[] Children = new Drawable[]
{ {
pink = new Container pink = new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Alpha = 0f, Alpha = 0f,
Children = new Drawable[] Children = new Drawable[]
{ {
new Box new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex(@"9f015f"), Colour = OsuColour.FromHex(@"9f015f"),
}, },
new Triangles new Triangles
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
ColourLight = OsuColour.FromHex(@"cb2187"), ColourLight = OsuColour.FromHex(@"cb2187"),
ColourDark = OsuColour.FromHex(@"9f015f"), ColourDark = OsuColour.FromHex(@"9f015f"),
TriangleScale = 1.5f, TriangleScale = 1.5f,
}, },
}, },
}, },
icon = new SpriteIcon icon = new SpriteIcon
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Icon = FontAwesome.fa_heart_o, Icon = FontAwesome.fa_heart_o,
Size = new Vector2(18), Size = new Vector2(18),
Shadow = false, Shadow = false,
}, },
}; };
Favourited.ValueChanged += value => Favourited.ValueChanged += value =>
{ {
if (value) if (value)
{ {
pink.FadeIn(200); pink.FadeIn(200);
icon.Icon = FontAwesome.fa_heart; icon.Icon = FontAwesome.fa_heart;
} }
else else
{ {
pink.FadeOut(200); pink.FadeOut(200);
icon.Icon = FontAwesome.fa_heart_o; icon.Icon = FontAwesome.fa_heart_o;
} }
}; };
Action = () => Favourited.Value = !Favourited.Value; Action = () => Favourited.Value = !Favourited.Value;
} }
protected override void UpdateAfterChildren() protected override void UpdateAfterChildren()
{ {
base.UpdateAfterChildren(); base.UpdateAfterChildren();
Width = DrawHeight; Width = DrawHeight;
} }
} }
} }

View File

@ -1,45 +1,45 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
namespace osu.Game.Overlays.OnlineBeatmapSet namespace osu.Game.Overlays.OnlineBeatmapSet
{ {
public class HeaderButton : OsuClickableContainer public class HeaderButton : OsuClickableContainer
{ {
private readonly Container content; private readonly Container content;
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;
public HeaderButton() public HeaderButton()
{ {
CornerRadius = 3; CornerRadius = 3;
Masking = true; Masking = true;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new Box new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex(@"094c5f"), Colour = OsuColour.FromHex(@"094c5f"),
}, },
new Triangles new Triangles
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
ColourLight = OsuColour.FromHex(@"0f7c9b"), ColourLight = OsuColour.FromHex(@"0f7c9b"),
ColourDark = OsuColour.FromHex(@"094c5f"), ColourDark = OsuColour.FromHex(@"094c5f"),
TriangleScale = 1.5f, TriangleScale = 1.5f,
}, },
content = new Container content = new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
}; };
} }
} }
} }