// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; using osu.Game.Rulesets; using osu.Game.Screens; using osu.Game.Screens.Menu; using osu.Game.Tournament.Components; using OpenTK; namespace osu.Game.Tournament.Screens.Showcase { public class ShowcaseScreen : OsuScreen { private readonly Container panelContainer; [Resolved] private APIAccess api { get; set; } = null; [Resolved] private RulesetStore rulesets { get; set; } = null; [BackgroundDependencyLoader] private void load() { var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = 1091460 }); req.Success += success; api.Queue(req); } private void success(APIBeatmap apiBeatmap) { var beatmap = apiBeatmap.ToBeatmap(rulesets); panelContainer.Children = new Drawable[] { new OsuSpriteText { Text = $"Length {beatmap.OnlineInfo.Length}s", Margin = new MarginPadding { Horizontal = 15, Vertical = 5 }, Colour = OsuColour.Gray(0.33f), Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, }, new OsuSpriteText { Text = $"BPM {beatmap.BeatmapSet.OnlineInfo.BPM:0.#}", Margin = new MarginPadding { Horizontal = 15, Vertical = 5 }, Colour = OsuColour.Gray(0.33f), Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft }, new OsuSpriteText { Text = $"AR {beatmap.BaseDifficulty.ApproachRate:0.#}", Margin = new MarginPadding { Horizontal = 15, Vertical = 5 }, Colour = OsuColour.Gray(0.33f), Anchor = Anchor.TopRight, Origin = Anchor.TopRight }, new OsuSpriteText { Text = $"Star Rating {beatmap.StarDifficulty:0.#}", Margin = new MarginPadding { Horizontal = 15, Vertical = 5 }, Colour = OsuColour.Gray(0.33f), Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight }, new TournamentBeatmapPanel(beatmap) { Anchor = Anchor.Centre, Origin = Anchor.Centre } }; } public ShowcaseScreen() { RelativeSizeAxes = Axes.Both; Children = new Drawable[] { new Container { Masking = true, RelativeSizeAxes = Axes.X, Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, Y = -10, Width = 0.9f, Height = TournamentBeatmapPanel.HEIGHT, CornerRadius = TournamentBeatmapPanel.HEIGHT / 2, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = OsuColour.Gray(0.93f), }, new Container { Masking = true, CornerRadius = TournamentBeatmapPanel.HEIGHT / 2, Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, Width = 0.7f, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = OsuColour.Gray(0.86f), }, panelContainer = new Container { RelativeSizeAxes = Axes.Both, } } }, new OsuLogo { Triangles = false, Colour = OsuColour.Gray(0.33f), Scale = new Vector2(0.08f), Margin = new MarginPadding(50), Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, } } } }; } } }