diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs new file mode 100644 index 0000000000..95405544a8 --- /dev/null +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -0,0 +1,180 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Overlays.Direct +{ + public class DirectGridPanel : DirectPanel + { + private readonly float horizontal_padding = 10; + private readonly float vertical_padding = 5; + + private readonly Sprite background; + private readonly OsuSpriteText title, artist, mapperPrefix, mapper, source; + private readonly Statistic playCount, favouriteCount; + private readonly FillFlowContainer difficultyIcons; + + protected override Sprite Background => background; + protected override OsuSpriteText Title => title; + protected override OsuSpriteText Artist => artist; + protected override OsuSpriteText Mapper => mapper; + protected override OsuSpriteText Source => source; + protected override Statistic PlayCount => playCount; + protected override Statistic FavouriteCount => favouriteCount; + protected override FillFlowContainer DifficultyIcons => difficultyIcons; + + public DirectGridPanel() + { + Height = 140 + vertical_padding; //full height of all the elements plus vertical padding (autosize uses the image) + CornerRadius = 4; + Masking = true; + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Offset = new Vector2(0f, 1f), + Radius = 3f, + Colour = Color4.Black.Opacity(0.25f), + }; + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + }, + background = new Sprite + { + FillMode = FillMode.Fill, + }, + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(0.5f), + }, + new FillFlowContainer + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Direction = FillDirection.Vertical, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Spacing = new Vector2(0f, vertical_padding), + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = horizontal_padding, Right = horizontal_padding }, + Direction = FillDirection.Vertical, + Children = new[] + { + title = new OsuSpriteText + { + TextSize = 18, + Font = @"Exo2.0-BoldItalic", + }, + artist = new OsuSpriteText + { + Font = @"Exo2.0-BoldItalic", + }, + }, + }, + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Padding = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding, Left = horizontal_padding, Right = horizontal_padding }, + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new[] + { + mapperPrefix = new OsuSpriteText + { + Text = @"mapped by ", + TextSize = 14, + Shadow = false, + }, + mapper = new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-SemiBoldItalic", + Shadow = false, + }, + }, + }, + source = new OsuSpriteText + { + TextSize = 14, + Shadow = false, + }, + difficultyIcons = new FillFlowContainer + { + Margin = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding }, + AutoSizeAxes = Axes.Both, + Children = new[] + { + new Box //todo: placeholder + { + Size = new Vector2(16f), + }, + }, + }, + }, + }, + }, + }, + }, + }, + new FillFlowContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Margin = new MarginPadding { Top = vertical_padding, Right = vertical_padding }, + Children = new[] + { + playCount = new Statistic(FontAwesome.fa_play_circle) + { + Margin = new MarginPadding { Right = 1 }, + }, + favouriteCount = new Statistic(FontAwesome.fa_heart), + }, + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + mapperPrefix.Colour = colours.Gray5; + Mapper.Colour = colours.BlueDark; + Source.Colour = colours.Gray5; + } + } +} diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs new file mode 100644 index 0000000000..00ef4c3206 --- /dev/null +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -0,0 +1,167 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Colour; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Overlays.Direct +{ + public class DirectListPanel : DirectPanel + { + private readonly float horizontal_padding = 10; + private readonly float vertical_padding = 5; + private readonly float height = 70; + + private readonly Sprite background; + private readonly OsuSpriteText title, artist, mapper, source; + private readonly Statistic playCount, favouriteCount; + private readonly FillFlowContainer difficultyIcons; + + protected override Sprite Background => background; + protected override OsuSpriteText Title => title; + protected override OsuSpriteText Artist => artist; + protected override OsuSpriteText Mapper => mapper; + protected override OsuSpriteText Source => source; + protected override Statistic PlayCount => playCount; + protected override Statistic FavouriteCount => favouriteCount; + protected override FillFlowContainer DifficultyIcons => difficultyIcons; + + public DirectListPanel() + { + RelativeSizeAxes = Axes.X; + Height = height; + CornerRadius = 5; + Masking = true; + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Offset = new Vector2(0f, 1f), + Radius = 3f, + Colour = Color4.Black.Opacity(0.25f), + }; + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + }, + background = new Sprite + { + FillMode = FillMode.Fill, + }, + new Box + { + RelativeSizeAxes = Axes.Both, + ColourInfo = ColourInfo.GradientHorizontal(Color4.Black.Opacity(0.25f), Color4.Black.Opacity(0.75f)), + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding, Left = horizontal_padding, Right = vertical_padding }, + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + title = new OsuSpriteText + { + TextSize = 18, + Font = @"Exo2.0-BoldItalic", + }, + artist = new OsuSpriteText + { + Font = @"Exo2.0-BoldItalic", + }, + difficultyIcons = new FillFlowContainer + { + Margin = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding }, + AutoSizeAxes = Axes.Both, + }, + }, + }, + new FillFlowContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Margin = new MarginPadding { Right = (height - vertical_padding * 2) + vertical_padding }, + Children = new Drawable[] + { + playCount = new Statistic(FontAwesome.fa_play_circle, 4579492) + { + Margin = new MarginPadding { Right = 1 }, + }, + favouriteCount = new Statistic(FontAwesome.fa_heart, 2659), + new FillFlowContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new[] + { + new OsuSpriteText + { + Text = @"mapped by ", + TextSize = 14, + }, + mapper = new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-SemiBoldItalic", + }, + }, + }, + source = new OsuSpriteText + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + TextSize = 14, + }, + }, + }, + new DownloadButton + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Size = new Vector2(height - (vertical_padding * 2)), + }, + }, + }, + }; + } + + private class DownloadButton : ClickableContainer + { + //todo: proper download button animations + public DownloadButton() + { + Children = new Drawable[] + { + new TextAwesome + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + UseFullGlyphHeight = false, + TextSize = 30, + Icon = FontAwesome.fa_osu_chevron_down_o, + }, + }; + } + } + } +} diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 5b5d054d5c..a5aa7b92fa 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -2,9 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; -using OpenTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -14,182 +12,31 @@ using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.Direct { - public class DirectPanel : Container + public abstract class DirectPanel : Container { - private readonly float horizontal_padding = 10; - private readonly float vertical_padding = 5; - - private readonly Sprite background; - private readonly OsuSpriteText title, artist, mapperPrefix, mapper, source; - private readonly Statistic playCount, favouriteCount; - private readonly FillFlowContainer difficultyIcons; - - private DirectPanelStyle style; - public DirectPanelStyle Style - { - get { return style; } - set - { - if (value == style) return; - style = value; - } - } - - public DirectPanel() - { - Height = 135 + vertical_padding; //full height of all the elements plus vertical padding (autosize uses the image) - CornerRadius = 4; - Masking = true; - EdgeEffect = new EdgeEffect - { - Type = EdgeEffectType.Shadow, - Offset = new Vector2(0f, 1f), - Radius = 3f, - Colour = Color4.Black.Opacity(0.25f), - }; - - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - }, - background = new Sprite - { - FillMode = FillMode.Fill, - }, - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black.Opacity(0.5f), - }, - new FillFlowContainer - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Direction = FillDirection.Vertical, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Spacing = new Vector2(0f, vertical_padding), - Children = new Drawable[] - { - new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Padding = new MarginPadding { Left = horizontal_padding, Right = horizontal_padding }, - Direction = FillDirection.Vertical, - Children = new[] - { - title = new OsuSpriteText - { - TextSize = 18, - Font = @"Exo2.0-BoldItalic", - }, - artist = new OsuSpriteText - { - Font = @"Exo2.0-BoldItalic", - }, - }, - }, - new Container - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - }, - new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Padding = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding, Left = horizontal_padding, Right = horizontal_padding }, - Children = new Drawable[] - { - new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Children = new[] - { - mapperPrefix = new OsuSpriteText - { - Text = @"mapped by ", - TextSize = 14, - Shadow = false, - }, - mapper = new OsuSpriteText - { - TextSize = 14, - Font = @"Exo2.0-SemiBoldItalic", - Shadow = false, - }, - }, - }, - source = new OsuSpriteText - { - TextSize = 14, - Shadow = false, - }, - difficultyIcons = new FillFlowContainer - { - Margin = new MarginPadding { Top = vertical_padding }, - AutoSizeAxes = Axes.Both, - Children = new[] - { - new Box //todo: placeholder - { - Size = new Vector2(16f), - }, - }, - }, - }, - }, - }, - }, - }, - }, - new FillFlowContainer - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Vertical, - Margin = new MarginPadding { Top = vertical_padding, Right = vertical_padding }, - Children = new[] - { - playCount = new Statistic(FontAwesome.fa_play_circle) - { - Margin = new MarginPadding { Right = 1 }, - }, - favouriteCount = new Statistic(FontAwesome.fa_heart), - }, - }, - }; - - title.Text = @"Platina"; - artist.Text = @"Maaya Sakamoto"; - mapper.Text = @"TicClick"; - source.Text = @"from Cardcaptor Sakura"; - playCount.Value = 4579492; - favouriteCount.Value = 2659; - } + protected virtual Sprite Background { get; } + protected virtual OsuSpriteText Title { get; } + protected virtual OsuSpriteText Artist { get; } + protected virtual OsuSpriteText Mapper { get; } + protected virtual OsuSpriteText Source { get; } + protected virtual Statistic PlayCount { get; } + protected virtual Statistic FavouriteCount { get; } + protected virtual FillFlowContainer DifficultyIcons { get; } [BackgroundDependencyLoader] - private void load(TextureStore textures, OsuColour colours) + private void load(TextureStore textures) { - background.Texture = textures.Get(@"Backgrounds/bg4"); + Background.Texture = textures.Get(@"Backgrounds/bg4"); - mapperPrefix.Colour = colours.Gray5; - mapper.Colour = colours.BlueDark; - source.Colour = colours.Gray5; + Title.Text = @"Platina"; + Artist.Text = @"Maaya Sakamoto"; + Mapper.Text = @"TicClick"; + Source.Text = @"from Cardcaptor Sakura"; + PlayCount.Value = 4579492; + FavouriteCount.Value = 2659; } - private class Statistic : FillFlowContainer + public class Statistic : FillFlowContainer { private readonly SpriteText text; @@ -231,10 +78,4 @@ namespace osu.Game.Overlays.Direct } } } - - public enum DirectPanelStyle - { - Grid, - List, - } } diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index e1a6d236b8..b7d27cf9e0 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -67,13 +67,18 @@ namespace osu.Game.Overlays }, }, }, - new DirectPanel + new DirectGridPanel { Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Style = DirectPanelStyle.Grid, + Origin = Anchor.BottomCentre, Width = 300, - } + }, + new DirectListPanel + { + Anchor = Anchor.Centre, + Origin = Anchor.TopCentre, + Width = 0.8f, + }, }; filter.Search.Exit = Hide; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index df5a5e4034..e69a836829 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -434,6 +434,8 @@ + +