From e3d52d8d7171076a28ddb67feaf130cf62a7ea3a Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sat, 10 Aug 2019 12:22:45 +0200 Subject: [PATCH 01/10] Add NewsOverlay class --- osu.Game/Overlays/NewsOverlay.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 osu.Game/Overlays/NewsOverlay.cs diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs new file mode 100644 index 0000000000..76040a6086 --- /dev/null +++ b/osu.Game/Overlays/NewsOverlay.cs @@ -0,0 +1,23 @@ +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; + +namespace osu.Game.Overlays +{ + public class NewsOverlay : FullscreenOverlay + { + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colours.PurpleLightAlternative + } + }; + } + } +} From 4b0ac381b7372a0ba2f6238e2890509c158debb2 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sat, 10 Aug 2019 12:26:54 +0200 Subject: [PATCH 02/10] Add visual tests. --- .../Visual/Online/TestSceneNewsOverlay.cs | 17 +++++++++++++++++ osu.Game/Overlays/NewsOverlay.cs | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs new file mode 100644 index 0000000000..3362d4700f --- /dev/null +++ b/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs @@ -0,0 +1,17 @@ +using osu.Game.Overlays; + +namespace osu.Game.Tests.Visual.Online +{ + public class TestSceneNewsOverlay : OsuTestScene + { + private NewsOverlay news; + + protected override void LoadComplete() + { + base.LoadComplete(); + Add(news = new NewsOverlay()); + AddStep(@"Show", news.Show); + AddStep(@"Hide", news.Hide); + } + } +} diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs index 76040a6086..76b917b65d 100644 --- a/osu.Game/Overlays/NewsOverlay.cs +++ b/osu.Game/Overlays/NewsOverlay.cs @@ -15,7 +15,7 @@ namespace osu.Game.Overlays new Box { RelativeSizeAxes = Axes.Both, - Colour = colours.PurpleLightAlternative + Colour = colours.PurpleDarkAlternative } }; } From b19c378fc8a7e5b571ed0e288b79c6e2ac628941 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sat, 10 Aug 2019 12:53:34 +0200 Subject: [PATCH 03/10] Add NewsHeader class --- osu.Game/Overlays/News/NewsHeader.cs | 71 ++++++++++++++++++++++++++++ osu.Game/Overlays/NewsOverlay.cs | 21 +++++++- 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 osu.Game/Overlays/News/NewsHeader.cs diff --git a/osu.Game/Overlays/News/NewsHeader.cs b/osu.Game/Overlays/News/NewsHeader.cs new file mode 100644 index 0000000000..43a514cdc6 --- /dev/null +++ b/osu.Game/Overlays/News/NewsHeader.cs @@ -0,0 +1,71 @@ +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; +using osu.Game.Graphics; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Overlays.News +{ + public class NewsHeader : OverlayHeader + { + private const string front_page_string = "Front Page"; + + private NewsHeaderTitle title; + + public NewsHeader() + { + TabControl.AddItem(front_page_string); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colour) + { + TabControl.AccentColour = colour.Violet; + } + + protected override Drawable CreateBackground() => new NewsHeaderBackground(); + + protected override Drawable CreateContent() => new Container(); + + protected override ScreenTitle CreateTitle() => title = new NewsHeaderTitle(); + + private class NewsHeaderBackground : Sprite + { + public NewsHeaderBackground() + { + RelativeSizeAxes = Axes.Both; + FillMode = FillMode.Fill; + } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + Texture = textures.Get(@"Headers/changelog"); //using changelog bg until corresponding osu-resources pr is merged. + } + } + + private class NewsHeaderTitle : ScreenTitle + { + private const string article_string = "Article"; + + public bool IsReadingArticle + { + set => Section = value ? article_string : front_page_string; + } + + public NewsHeaderTitle() + { + Title = "News"; + IsReadingArticle = false; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + AccentColour = colours.Violet; + } + } + } +} diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs index 76b917b65d..80088a25bc 100644 --- a/osu.Game/Overlays/NewsOverlay.cs +++ b/osu.Game/Overlays/NewsOverlay.cs @@ -1,12 +1,17 @@ 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 osu.Game.Overlays.News; namespace osu.Game.Overlays { public class NewsOverlay : FullscreenOverlay { + private NewsHeader header; + [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -16,7 +21,21 @@ namespace osu.Game.Overlays { RelativeSizeAxes = Axes.Both, Colour = colours.PurpleDarkAlternative - } + }, + new OsuScrollContainer + { + RelativeSizeAxes = Axes.Both, + Child = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + header = new NewsHeader() + }, + }, + }, }; } } From 0e5561c783344856d751338f32e876cb373cb4a0 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sat, 10 Aug 2019 16:12:42 +0200 Subject: [PATCH 04/10] Use News overlay resources --- osu.Game/Overlays/News/NewsHeader.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/News/NewsHeader.cs b/osu.Game/Overlays/News/NewsHeader.cs index 43a514cdc6..fb02f7f105 100644 --- a/osu.Game/Overlays/News/NewsHeader.cs +++ b/osu.Game/Overlays/News/NewsHeader.cs @@ -42,7 +42,7 @@ namespace osu.Game.Overlays.News [BackgroundDependencyLoader] private void load(TextureStore textures) { - Texture = textures.Get(@"Headers/changelog"); //using changelog bg until corresponding osu-resources pr is merged. + Texture = textures.Get(@"Headers/news"); } } @@ -61,6 +61,8 @@ namespace osu.Game.Overlays.News IsReadingArticle = false; } + protected override Drawable CreateIcon() => new ScreenTitleIcon(@"Icons/news"); + [BackgroundDependencyLoader] private void load(OsuColour colours) { From b92e331730f2971c5fbe7b5afe0031e781c2c494 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sat, 10 Aug 2019 17:06:52 +0200 Subject: [PATCH 05/10] Add tabcontrol logic to news overlay --- .../Visual/Online/TestSceneNewsOverlay.cs | 3 ++ osu.Game/Overlays/News/NewsHeader.cs | 35 ++++++++++++++++++- osu.Game/Overlays/NewsOverlay.cs | 13 +++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs index 3362d4700f..d5273801d8 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs @@ -12,6 +12,9 @@ namespace osu.Game.Tests.Visual.Online Add(news = new NewsOverlay()); AddStep(@"Show", news.Show); AddStep(@"Hide", news.Hide); + + AddStep(@"Show front page", () => news.ShowFrontPage()); + AddStep(@"Custom article", () => news.Current.Value = "Test Article 101"); } } } diff --git a/osu.Game/Overlays/News/NewsHeader.cs b/osu.Game/Overlays/News/NewsHeader.cs index fb02f7f105..e887d48456 100644 --- a/osu.Game/Overlays/News/NewsHeader.cs +++ b/osu.Game/Overlays/News/NewsHeader.cs @@ -1,10 +1,12 @@ using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; +using System; namespace osu.Game.Overlays.News { @@ -14,9 +16,21 @@ namespace osu.Game.Overlays.News private NewsHeaderTitle title; + public readonly Bindable Current = new Bindable(null); + + public Action ShowFrontPage; + public NewsHeader() { TabControl.AddItem(front_page_string); + + TabControl.Current.ValueChanged += e => + { + if (e.NewValue == front_page_string) + ShowFrontPage?.Invoke(); + }; + + Current.ValueChanged += showArticle; } [BackgroundDependencyLoader] @@ -25,6 +39,25 @@ namespace osu.Game.Overlays.News TabControl.AccentColour = colour.Violet; } + private void showArticle(ValueChangedEvent e) + { + if (e.OldValue != null) + TabControl.RemoveItem(e.OldValue); + + if (e.NewValue != null) + { + TabControl.AddItem(e.NewValue); + TabControl.Current.Value = e.NewValue; + + title.IsReadingArticle = true; + } + else + { + TabControl.Current.Value = front_page_string; + title.IsReadingArticle = false; + } + } + protected override Drawable CreateBackground() => new NewsHeaderBackground(); protected override Drawable CreateContent() => new Container(); @@ -52,7 +85,7 @@ namespace osu.Game.Overlays.News public bool IsReadingArticle { - set => Section = value ? article_string : front_page_string; + set => Section = value ? article_string : front_page_string; } public NewsHeaderTitle() diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs index 80088a25bc..1506cbb288 100644 --- a/osu.Game/Overlays/NewsOverlay.cs +++ b/osu.Game/Overlays/NewsOverlay.cs @@ -1,4 +1,5 @@ using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -12,6 +13,8 @@ namespace osu.Game.Overlays { private NewsHeader header; + public readonly Bindable Current = new Bindable(null); + [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -37,6 +40,16 @@ namespace osu.Game.Overlays }, }, }; + + header.Current.BindTo(Current); + header.ShowFrontPage = ShowFrontPage; + Current.TriggerChange(); + } + + public void ShowFrontPage() + { + Current.Value = null; + Show(); } } } From 87811afade5abfdbf6dc3a2503242f2be4be076b Mon Sep 17 00:00:00 2001 From: Lucas A Date: Mon, 12 Aug 2019 20:16:41 +0200 Subject: [PATCH 06/10] Add missing licence headers to added files. --- osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs | 5 ++++- osu.Game/Overlays/News/NewsHeader.cs | 5 ++++- osu.Game/Overlays/NewsOverlay.cs | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs index d5273801d8..546f6ac182 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs @@ -1,4 +1,7 @@ -using osu.Game.Overlays; +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Overlays; namespace osu.Game.Tests.Visual.Online { diff --git a/osu.Game/Overlays/News/NewsHeader.cs b/osu.Game/Overlays/News/NewsHeader.cs index e887d48456..6a14828473 100644 --- a/osu.Game/Overlays/News/NewsHeader.cs +++ b/osu.Game/Overlays/News/NewsHeader.cs @@ -1,4 +1,7 @@ -using osu.Framework.Allocation; +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs index 1506cbb288..b509204c58 100644 --- a/osu.Game/Overlays/NewsOverlay.cs +++ b/osu.Game/Overlays/NewsOverlay.cs @@ -1,4 +1,7 @@ -using osu.Framework.Allocation; +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; From 840d4741daf285b0c2541997f39b6fda309a492b Mon Sep 17 00:00:00 2001 From: Lucas A Date: Wed, 14 Aug 2019 20:24:36 +0200 Subject: [PATCH 07/10] Add NewsContent class and fix broken reference. --- osu.Game/Overlays/News/NewsContent.cs | 16 ++++++++++++++++ osu.Game/Overlays/News/NewsHeader.cs | 2 +- osu.Game/Overlays/NewsOverlay.cs | 10 +++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 osu.Game/Overlays/News/NewsContent.cs diff --git a/osu.Game/Overlays/News/NewsContent.cs b/osu.Game/Overlays/News/NewsContent.cs new file mode 100644 index 0000000000..f0763285eb --- /dev/null +++ b/osu.Game/Overlays/News/NewsContent.cs @@ -0,0 +1,16 @@ +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; + +namespace osu.Game.Overlays.News +{ + public abstract class NewsContent : FillFlowContainer + { + public NewsContent() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Direction = FillDirection.Vertical; + Padding = new MarginPadding { Bottom = 100 }; + } + } +} diff --git a/osu.Game/Overlays/News/NewsHeader.cs b/osu.Game/Overlays/News/NewsHeader.cs index 6a14828473..27620ab523 100644 --- a/osu.Game/Overlays/News/NewsHeader.cs +++ b/osu.Game/Overlays/News/NewsHeader.cs @@ -97,7 +97,7 @@ namespace osu.Game.Overlays.News IsReadingArticle = false; } - protected override Drawable CreateIcon() => new ScreenTitleIcon(@"Icons/news"); + protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/news"); [BackgroundDependencyLoader] private void load(OsuColour colours) diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs index b509204c58..b341321a46 100644 --- a/osu.Game/Overlays/NewsOverlay.cs +++ b/osu.Game/Overlays/NewsOverlay.cs @@ -15,6 +15,7 @@ namespace osu.Game.Overlays public class NewsOverlay : FullscreenOverlay { private NewsHeader header; + private Container content; public readonly Bindable Current = new Bindable(null); @@ -39,13 +40,20 @@ namespace osu.Game.Overlays Children = new Drawable[] { header = new NewsHeader() + { + ShowFrontPage = ShowFrontPage + }, + content = new Container() + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + } }, }, }, }; header.Current.BindTo(Current); - header.ShowFrontPage = ShowFrontPage; Current.TriggerChange(); } From 46e71e9ead75227f63080ed4751e3f61228d1f40 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Wed, 14 Aug 2019 21:34:29 +0200 Subject: [PATCH 08/10] Add missing licence header --- osu.Game/Overlays/News/NewsContent.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/News/NewsContent.cs b/osu.Game/Overlays/News/NewsContent.cs index f0763285eb..26f92b3825 100644 --- a/osu.Game/Overlays/News/NewsContent.cs +++ b/osu.Game/Overlays/News/NewsContent.cs @@ -1,4 +1,7 @@ -using osu.Framework.Graphics; +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; namespace osu.Game.Overlays.News From 4d1b1a4022d530d5c7fff5ceec3d04ffca641543 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Wed, 14 Aug 2019 21:52:36 +0200 Subject: [PATCH 09/10] Fix CI inspections --- osu.Game/Overlays/News/NewsContent.cs | 2 +- osu.Game/Overlays/NewsOverlay.cs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/News/NewsContent.cs b/osu.Game/Overlays/News/NewsContent.cs index 26f92b3825..16a8ed84b8 100644 --- a/osu.Game/Overlays/News/NewsContent.cs +++ b/osu.Game/Overlays/News/NewsContent.cs @@ -8,7 +8,7 @@ namespace osu.Game.Overlays.News { public abstract class NewsContent : FillFlowContainer { - public NewsContent() + protected NewsContent() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs index b341321a46..aadca8883e 100644 --- a/osu.Game/Overlays/NewsOverlay.cs +++ b/osu.Game/Overlays/NewsOverlay.cs @@ -15,6 +15,8 @@ namespace osu.Game.Overlays public class NewsOverlay : FullscreenOverlay { private NewsHeader header; + + //ReSharper disable NotAccessedField.Local private Container content; public readonly Bindable Current = new Bindable(null); @@ -39,11 +41,11 @@ namespace osu.Game.Overlays Direction = FillDirection.Vertical, Children = new Drawable[] { - header = new NewsHeader() + header = new NewsHeader { ShowFrontPage = ShowFrontPage }, - content = new Container() + content = new Container { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, From af2ffac03a5fe99a4d62e0508e3e0f1e215d2be3 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 18 Aug 2019 14:52:26 +0200 Subject: [PATCH 10/10] Add global Top and Horizontal padding to NewsContent --- osu.Game/Overlays/News/NewsContent.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/News/NewsContent.cs b/osu.Game/Overlays/News/NewsContent.cs index 16a8ed84b8..5ff210f9f5 100644 --- a/osu.Game/Overlays/News/NewsContent.cs +++ b/osu.Game/Overlays/News/NewsContent.cs @@ -13,7 +13,7 @@ namespace osu.Game.Overlays.News RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Direction = FillDirection.Vertical; - Padding = new MarginPadding { Bottom = 100 }; + Padding = new MarginPadding { Bottom = 100, Top = 20, Horizontal = 50 }; } } }