From d89f9590ea5d86bde2a07ebedacb107671c860e0 Mon Sep 17 00:00:00 2001 From: Naeferith Date: Sat, 4 Mar 2017 23:48:28 +0100 Subject: [PATCH 01/37] Visual test for lobby room panels --- .../Tests/TestCaseMultiRoomPanel.cs | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseMultiRoomPanel.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMultiRoomPanel.cs b/osu.Desktop.VisualTests/Tests/TestCaseMultiRoomPanel.cs new file mode 100644 index 0000000000..0ef0e39b1b --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseMultiRoomPanel.cs @@ -0,0 +1,71 @@ +// 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.Screens.Testing; +using osu.Game.Graphics.UserInterface; +using osu.Game.Screens.Select; +using osu.Game.Screens.Multiplayer; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; +using osu.Game.Graphics.Sprites; + +namespace osu.Desktop.VisualTests.Tests +{ + class TestCaseMultiRoomPanel : TestCase + { + private MultiRoomPanel test; + private FlowContainer panelContainer; + public override string Name => @"MultiRoomPanel"; + public override string Description => @"Select your favourite room"; + + private void action(int action) + { + switch (action) + { + case 0: + if (test.Status == 0) test.Status = 1; + else test.Status = 0; + break; + } + } + + public override void Reset() + { + base.Reset(); + + AddButton(@"ChangeState", () => action(0)); + + Add(panelContainer = new FlowContainer //Positionning container + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Direction = FlowDirections.Vertical, + Size = new Vector2(0.4f, 0.5f), + Children = new Drawable[] + { + test = new MultiRoomPanel("Great Room Right Here", "Naeferith", 0), + new MultiRoomPanel("Relax it's the weekend", "Someone", 1), + } + }); + } + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) + { + foreach (MultiRoomPanel panel in panelContainer.Children) + { + panel.BorderThickness = 0; + if (panel.Clicked == true) + { + panel.BorderThickness = 3; + panel.Clicked = false; + } + } + return base.OnMouseUp(state, args); + } + } +} From 89a443fb9261ccc63e788f5646127e910e627a7a Mon Sep 17 00:00:00 2001 From: Naeferith Date: Sat, 4 Mar 2017 23:49:47 +0100 Subject: [PATCH 02/37] Lobby's Room Panel --- .../Screens/Multiplayer/MultiRoomPanel.cs | 261 ++++++++++++++++++ 1 file changed, 261 insertions(+) create mode 100644 osu.Game/Screens/Multiplayer/MultiRoomPanel.cs diff --git a/osu.Game/Screens/Multiplayer/MultiRoomPanel.cs b/osu.Game/Screens/Multiplayer/MultiRoomPanel.cs new file mode 100644 index 0000000000..386b9217e3 --- /dev/null +++ b/osu.Game/Screens/Multiplayer/MultiRoomPanel.cs @@ -0,0 +1,261 @@ +// 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.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; +using osu.Game.Graphics; +using osu.Game.Graphics.Backgrounds; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Screens.Multiplayer +{ + public class MultiRoomPanel : ClickableContainer + { + private bool didClick; + private string roomName; + private string hostName; + + private int roomStatus; + private Color4 statusColour; + private string statusString; + + private Box sideSprite; + private OsuSpriteText hostSprite; + private OsuSpriteText statusSprite; + private OsuSpriteText roomSprite; + + public const int BORDER_SIZE = 3; + public const int PANEL_HEIGHT = 90; + + + public Color4 ColourFree = new Color4(166, 204, 0, 255); + public Color4 ColourBusy = new Color4(135, 102, 237, 255); + + public int CONTENT_PADDING = 5; + + public bool Clicked + { + get { return didClick; } + set + { + didClick = value; + } + } + + public int Status + { + get { return roomStatus; } + set + { + roomStatus = value; + if (roomStatus == 0) + { + statusColour = ColourFree; + statusString = "Welcoming Players"; + + UpdatePanel(this); + } + else + { + statusColour = ColourBusy; + statusString = "Now Playing"; + + UpdatePanel(this); + } + } + } + + public void UpdatePanel(MultiRoomPanel panel) + { + panel.BorderColour = statusColour; + panel.sideSprite.Colour = statusColour; + + statusSprite.Colour = statusColour; + statusSprite.Text = statusString; + } + + public MultiRoomPanel(string matchName = "Room Name", string host = "Undefined", int status = 0) + { + roomName = matchName; + hostName = host; + roomStatus = status; + + if (status == 0) + { + statusColour = ColourFree; + statusString = "Welcoming Players"; + } + else + { + statusColour = ColourBusy; + statusString = "Now Playing"; + } + + RelativeSizeAxes = Axes.X; + Height = PANEL_HEIGHT; + Masking = true; + CornerRadius = 5; + BorderThickness = 0; + BorderColour = statusColour; + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(40), + Radius = 5, + }; + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = new Color4(34,34,34, 255), + }, + sideSprite = new Box + { + RelativeSizeAxes = Axes.Y, + Width = 5, + Colour = statusColour, + }, + /*new Box //Beatmap img + { + + },*/ + new Background(@"Backgrounds/bg4") + { + RelativeSizeAxes = Axes.Both, + } + , + new FlowContainer + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Direction = FlowDirections.Vertical, + Size = new Vector2(0.75f,1), + + Children = new Drawable[] + { + roomSprite = new OsuSpriteText + { + Text = roomName, + TextSize = 18, + Margin = new MarginPadding { Top = CONTENT_PADDING }, + }, + new FlowContainer + { + RelativeSizeAxes = Axes.X, + Height = 20, + Direction = FlowDirections.Horizontal, + Spacing = new Vector2(5,0), + Children = new Drawable[] + { + + + new Container + { + Masking = true, + CornerRadius = 5, + Width = 30, + Height = 20, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Gray, + } + } + + }, + new Container + { + Masking = true, + CornerRadius = 5, + Width = 40, + Height = 20, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = new Color4(173,56,126,255), + } + } + }, + new OsuSpriteText + { + Text = "hosted by", + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + TextSize = 14, + }, + hostSprite = new OsuSpriteText + { + Text = hostName, + Font = @"Exo2.0-Bold", + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Shear = new Vector2(0.1f,0), + Colour = new Color4(69,179,222,255), + TextSize = 14, + }, + new OsuSpriteText + { + Text = "#6895 - #50024", + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + TextSize = 14, + Margin = new MarginPadding { Left = 80 }, + Colour = new Color4(153,153,153,255), + } + } + }, + statusSprite = new OsuSpriteText + { + Text = statusString, + TextSize = 14, + Font = @"Exo2.0-Bold", + Colour = statusColour, + Margin = new MarginPadding { Top = 10 } + }, + new FlowContainer + { + RelativeSizeAxes = Axes.X, + Direction = FlowDirections.Horizontal, + Children = new Drawable[] + { + new OsuSpriteText + { + Text = "Platina", + Font = @"Exo2.0-Bold", + TextSize = 14, + Shear = new Vector2(0.1f,0), + Colour = new Color4(153,153,153,255), + }, + new OsuSpriteText + { + Text = " - " + "Maaya Sakamoto", + TextSize = 14, + Shear = new Vector2(0.1f,0), + Colour = new Color4(153,153,153,255), + } + } + }, + } + }, + }; + } + + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) + { + BorderThickness = 3; + didClick = true; + return base.OnMouseUp(state, args); + } + } +} \ No newline at end of file From 2a269dbc5afa9a630eedaed10c573901526ef56b Mon Sep 17 00:00:00 2001 From: Naeferith Date: Fri, 28 Apr 2017 10:57:59 +0200 Subject: [PATCH 03/37] Remove unsused variable + IStateful Implementation --- .../Screens/Multiplayer/MultiRoomPanel.cs | 68 +++++++++++-------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/osu.Game/Screens/Multiplayer/MultiRoomPanel.cs b/osu.Game/Screens/Multiplayer/MultiRoomPanel.cs index 386b9217e3..174ec19f75 100644 --- a/osu.Game/Screens/Multiplayer/MultiRoomPanel.cs +++ b/osu.Game/Screens/Multiplayer/MultiRoomPanel.cs @@ -1,8 +1,9 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . +// 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; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; @@ -14,8 +15,35 @@ using osu.Game.Graphics.Sprites; namespace osu.Game.Screens.Multiplayer { - public class MultiRoomPanel : ClickableContainer + public class MultiRoomPanel : ClickableContainer, IStateful { + private PanelState state; + public PanelState State + { + get { return state; } + set + { + if (state == value) + return; + + state = value; + switch (state) + { + case PanelState.Free: + statusColour = ColourFree; + statusString = "Welcoming Players"; + UpdatePanel(this); + break; + + case PanelState.Busy: + statusColour = ColourBusy; + statusString = "Now Playing"; + UpdatePanel(this); + break; + } + } + } + private bool didClick; private string roomName; private string hostName; @@ -29,15 +57,12 @@ namespace osu.Game.Screens.Multiplayer private OsuSpriteText statusSprite; private OsuSpriteText roomSprite; - public const int BORDER_SIZE = 3; public const int PANEL_HEIGHT = 90; - + public const int CONTENT_PADDING = 5; public Color4 ColourFree = new Color4(166, 204, 0, 255); public Color4 ColourBusy = new Color4(135, 102, 237, 255); - public int CONTENT_PADDING = 5; - public bool Clicked { get { return didClick; } @@ -47,29 +72,6 @@ namespace osu.Game.Screens.Multiplayer } } - public int Status - { - get { return roomStatus; } - set - { - roomStatus = value; - if (roomStatus == 0) - { - statusColour = ColourFree; - statusString = "Welcoming Players"; - - UpdatePanel(this); - } - else - { - statusColour = ColourBusy; - statusString = "Now Playing"; - - UpdatePanel(this); - } - } - } - public void UpdatePanel(MultiRoomPanel panel) { panel.BorderColour = statusColour; @@ -257,5 +259,11 @@ namespace osu.Game.Screens.Multiplayer didClick = true; return base.OnMouseUp(state, args); } + + public enum PanelState + { + Free, + Busy + } } -} \ No newline at end of file +} From bf6c1705411178b545effba584820eecaa0666bd Mon Sep 17 00:00:00 2001 From: Naeferith Date: Fri, 28 Apr 2017 10:59:34 +0200 Subject: [PATCH 04/37] IStateful implementation --- osu.Desktop.VisualTests/Tests/TestCaseMultiRoomPanel.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMultiRoomPanel.cs b/osu.Desktop.VisualTests/Tests/TestCaseMultiRoomPanel.cs index 0ef0e39b1b..29cc4481a9 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMultiRoomPanel.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMultiRoomPanel.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . +// Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; @@ -28,8 +28,7 @@ namespace osu.Desktop.VisualTests.Tests switch (action) { case 0: - if (test.Status == 0) test.Status = 1; - else test.Status = 0; + test.State = test.State == MultiRoomPanel.PanelState.Free ? MultiRoomPanel.PanelState.Busy : MultiRoomPanel.PanelState.Free; break; } } From bc980b60ac1d762b593f0e14daaf352b58ec1b0b Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sun, 21 May 2017 22:36:46 -0300 Subject: [PATCH 05/37] Add files to project, update with framework changes --- .../Tests/TestCaseMultiRoomPanel.cs | 12 ++++++------ .../osu.Desktop.VisualTests.csproj | 1 + osu.Game/Screens/Multiplayer/MultiRoomPanel.cs | 14 +++++++------- osu.Game/osu.Game.csproj | 1 + 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMultiRoomPanel.cs b/osu.Desktop.VisualTests/Tests/TestCaseMultiRoomPanel.cs index 29cc4481a9..a6dbcda8f9 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMultiRoomPanel.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMultiRoomPanel.cs @@ -3,7 +3,6 @@ using OpenTK; using OpenTK.Graphics; -using osu.Framework.Screens.Testing; using osu.Game.Graphics.UserInterface; using osu.Game.Screens.Select; using osu.Game.Screens.Multiplayer; @@ -13,14 +12,15 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; using osu.Game.Graphics.Sprites; +using osu.Framework.Testing; namespace osu.Desktop.VisualTests.Tests { class TestCaseMultiRoomPanel : TestCase { private MultiRoomPanel test; - private FlowContainer panelContainer; - public override string Name => @"MultiRoomPanel"; + private FillFlowContainer panelContainer; + public override string Description => @"Select your favourite room"; private void action(int action) @@ -37,14 +37,14 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - AddButton(@"ChangeState", () => action(0)); + AddStep(@"ChangeState", () => action(0)); - Add(panelContainer = new FlowContainer //Positionning container + Add(panelContainer = new FillFlowContainer //Positionning container { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, - Direction = FlowDirections.Vertical, + Direction = FillDirection.Vertical, Size = new Vector2(0.4f, 0.5f), Children = new Drawable[] { diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 135e4596c7..a2228ca9aa 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -217,6 +217,7 @@ + diff --git a/osu.Game/Screens/Multiplayer/MultiRoomPanel.cs b/osu.Game/Screens/Multiplayer/MultiRoomPanel.cs index 174ec19f75..cbc4cc1182 100644 --- a/osu.Game/Screens/Multiplayer/MultiRoomPanel.cs +++ b/osu.Game/Screens/Multiplayer/MultiRoomPanel.cs @@ -4,12 +4,12 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; -using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Sprites; @@ -132,12 +132,12 @@ namespace osu.Game.Screens.Multiplayer RelativeSizeAxes = Axes.Both, } , - new FlowContainer + new FillFlowContainer { RelativeSizeAxes = Axes.Both, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - Direction = FlowDirections.Vertical, + Direction = FillDirection.Vertical, Size = new Vector2(0.75f,1), Children = new Drawable[] @@ -148,11 +148,11 @@ namespace osu.Game.Screens.Multiplayer TextSize = 18, Margin = new MarginPadding { Top = CONTENT_PADDING }, }, - new FlowContainer + new FillFlowContainer { RelativeSizeAxes = Axes.X, Height = 20, - Direction = FlowDirections.Horizontal, + Direction = FillDirection.Horizontal, Spacing = new Vector2(5,0), Children = new Drawable[] { @@ -225,10 +225,10 @@ namespace osu.Game.Screens.Multiplayer Colour = statusColour, Margin = new MarginPadding { Top = 10 } }, - new FlowContainer + new FillFlowContainer { RelativeSizeAxes = Axes.X, - Direction = FlowDirections.Horizontal, + Direction = FillDirection.Horizontal, Children = new Drawable[] { new OsuSpriteText diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 2a1195135a..6cc05bf327 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -427,6 +427,7 @@ + From e5ee7096f8a37e7b1dd205eeee7184ae34e0dcca Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 00:07:15 -0300 Subject: [PATCH 06/37] Initial cleanup --- .../Tests/TestCaseDrawableMultiplayerRoom.cs | 60 ++++ .../Tests/TestCaseMultiRoomPanel.cs | 70 ----- .../osu.Desktop.VisualTests.csproj | 2 +- .../Online/Multiplayer/MultiplayerRoom.cs | 26 ++ .../Multiplayer/DrawableMultiplayerRoom.cs | 215 ++++++++++++++ .../Screens/Multiplayer/MultiRoomPanel.cs | 269 ------------------ osu.Game/osu.Game.csproj | 6 +- 7 files changed, 307 insertions(+), 341 deletions(-) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseDrawableMultiplayerRoom.cs delete mode 100644 osu.Desktop.VisualTests/Tests/TestCaseMultiRoomPanel.cs create mode 100644 osu.Game/Online/Multiplayer/MultiplayerRoom.cs create mode 100644 osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs delete mode 100644 osu.Game/Screens/Multiplayer/MultiRoomPanel.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawableMultiplayerRoom.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawableMultiplayerRoom.cs new file mode 100644 index 0000000000..c9a0dfa280 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawableMultiplayerRoom.cs @@ -0,0 +1,60 @@ +// 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.Game.Graphics.UserInterface; +using osu.Game.Screens.Select; +using osu.Game.Screens.Multiplayer; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; +using osu.Game.Graphics.Sprites; +using osu.Framework.Testing; +using osu.Game.Online.Multiplayer; +using osu.Game.Users; +using osu.Game.Database; + +namespace osu.Desktop.VisualTests.Tests +{ + class TestCaseDrawableMultiplayerRoom : TestCase + { + public override string Description => @"Select your favourite room"; + + public override void Reset() + { + base.Reset(); + + DrawableMultiplayerRoom p; + Add(new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Y, + Width = 500f, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + p = new DrawableMultiplayerRoom(new MultiplayerRoom + { + Name = @"Great Room Right Here", + Host = new User { Username = @"Naeferith", Country = new Country { FlagName = @"FR" }}, + Status = MultiplayerRoomStatus.Open, + CurrentBeatmap = new BeatmapMetadata { Title = @"Seiryu", Artist = @"Critical Crystal" }, + }), + new DrawableMultiplayerRoom(new MultiplayerRoom + { + Name = @"Relax It's The Weekend", + Host = new User{ Username = @"Someone", Country = new Country { FlagName = @"CA" }}, + Status = MultiplayerRoomStatus.Playing, + CurrentBeatmap = new BeatmapMetadata { Title = @"ZAQ", Artist = @"Serendipity" }, + }), + } + }); + + AddStep(@"change state", () => { p.Room.Status = MultiplayerRoomStatus.Playing; }); + } + } +} diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMultiRoomPanel.cs b/osu.Desktop.VisualTests/Tests/TestCaseMultiRoomPanel.cs deleted file mode 100644 index a6dbcda8f9..0000000000 --- a/osu.Desktop.VisualTests/Tests/TestCaseMultiRoomPanel.cs +++ /dev/null @@ -1,70 +0,0 @@ -// 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.Game.Graphics.UserInterface; -using osu.Game.Screens.Select; -using osu.Game.Screens.Multiplayer; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Input; -using osu.Game.Graphics.Sprites; -using osu.Framework.Testing; - -namespace osu.Desktop.VisualTests.Tests -{ - class TestCaseMultiRoomPanel : TestCase - { - private MultiRoomPanel test; - private FillFlowContainer panelContainer; - - public override string Description => @"Select your favourite room"; - - private void action(int action) - { - switch (action) - { - case 0: - test.State = test.State == MultiRoomPanel.PanelState.Free ? MultiRoomPanel.PanelState.Busy : MultiRoomPanel.PanelState.Free; - break; - } - } - - public override void Reset() - { - base.Reset(); - - AddStep(@"ChangeState", () => action(0)); - - Add(panelContainer = new FillFlowContainer //Positionning container - { - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Direction = FillDirection.Vertical, - Size = new Vector2(0.4f, 0.5f), - Children = new Drawable[] - { - test = new MultiRoomPanel("Great Room Right Here", "Naeferith", 0), - new MultiRoomPanel("Relax it's the weekend", "Someone", 1), - } - }); - } - protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) - { - foreach (MultiRoomPanel panel in panelContainer.Children) - { - panel.BorderThickness = 0; - if (panel.Clicked == true) - { - panel.BorderThickness = 3; - panel.Clicked = false; - } - } - return base.OnMouseUp(state, args); - } - } -} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 2374b07bf3..fa507527aa 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -220,7 +220,7 @@ - + diff --git a/osu.Game/Online/Multiplayer/MultiplayerRoom.cs b/osu.Game/Online/Multiplayer/MultiplayerRoom.cs new file mode 100644 index 0000000000..5c9e72bcf2 --- /dev/null +++ b/osu.Game/Online/Multiplayer/MultiplayerRoom.cs @@ -0,0 +1,26 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.ComponentModel; +using osu.Game.Database; +using osu.Game.Users; + +namespace osu.Game.Online.Multiplayer +{ + public class MultiplayerRoom + { + public string Name { get; set; } + public User Host { get; set; } + public MultiplayerRoomStatus Status { get; set; } + public BeatmapMetadata CurrentBeatmap { get; set; } + } + + public enum MultiplayerRoomStatus + { + [Description(@"Welcoming Players")] + Open, + + [Description(@"Now Playing")] + Playing, + } +} diff --git a/osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs b/osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs new file mode 100644 index 0000000000..2c0e7db1db --- /dev/null +++ b/osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs @@ -0,0 +1,215 @@ +// 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; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Localisation; +using osu.Game.Graphics; +using osu.Game.Graphics.Backgrounds; +using osu.Game.Graphics.Sprites; +using osu.Game.Online.Multiplayer; +using osu.Game.Users; + +namespace osu.Game.Screens.Multiplayer +{ + public class DrawableMultiplayerRoom : ClickableContainer + { + private const float content_padding = 5; + private const float height = 90; + + private readonly Box sideStrip; + private readonly OsuSpriteText status; + private readonly OsuSpriteText host; + private readonly OsuSpriteText rankBounds; + private readonly FillFlowContainer beatmapInfoFlow; + private readonly OsuSpriteText beatmapTitle; + private readonly OsuSpriteText beatmapArtist; + + private Color4 openColour; + private Color4 playingColour; + + public readonly MultiplayerRoom Room; + + public DrawableMultiplayerRoom(MultiplayerRoom room) + { + Room = room; + + RelativeSizeAxes = Axes.X; + Height = height; + CornerRadius = 5; + Masking = true; + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(40), + Radius = 5, + }; + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.Gray(34), + }, + new Background(@"Backgrounds/bg4") + { + RelativeSizeAxes = Axes.Both, + }, + sideStrip = new Box + { + RelativeSizeAxes = Axes.Y, + Width = 5, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = content_padding, Bottom = content_padding * 2, Left = Height + content_padding * 2, Right = content_padding }, + Children = new Drawable[] + { + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(5f), + Children = new Drawable[] + { + new OsuSpriteText + { + Text = Room.Name, + TextSize = 18, + }, + new Container + { + RelativeSizeAxes = Axes.X, + Height = 20f, + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Y, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5f, 0f), + Children = new Drawable[] + { + new DrawableFlag(Room.Host?.Country?.FlagName ?? "__") + { + Width = 30f, + RelativeSizeAxes = Axes.Y, + }, + new Container + { + Width = 40f, + RelativeSizeAxes = Axes.Y, + }, + new OsuSpriteText + { + Text = "hosted by", + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + TextSize = 14, + }, + host = new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Text = Room.Host?.Username ?? @"", + TextSize = 14, + Font = @"Exo2.0-BoldItalic", + }, + }, + }, + rankBounds = new OsuSpriteText + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Text = "#6895 - #50024", + TextSize = 14, + Margin = new MarginPadding { Right = 10 }, + }, + }, + }, + }, + }, + new FillFlowContainer + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + status = new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-Bold", + }, + beatmapInfoFlow = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Horizontal, + Children = new[] + { + beatmapTitle = new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-BoldItalic", + }, + new OsuSpriteText + { + Text = @" - ", + TextSize = 14, + Font = @"Exo2.0-RegularItalic", + }, + beatmapArtist = new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-RegularItalic", + }, + }, + }, + }, + }, + }, + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours, LocalisationEngine localisation) + { + openColour = colours.GreenLight; + playingColour = colours.Purple; + beatmapInfoFlow.Colour = rankBounds.Colour = colours.Gray9; + host.Colour = colours.Blue; + + if (Room.CurrentBeatmap != null) + { + beatmapTitle.Current = localisation.GetUnicodePreference(Room.CurrentBeatmap.TitleUnicode, Room.CurrentBeatmap.Title); + beatmapArtist.Current = localisation.GetUnicodePreference(Room.CurrentBeatmap.ArtistUnicode, Room.CurrentBeatmap.Artist); + } + + updateStatus(); + } + + private void updateStatus() + { + if (Room == null) return; + + status.Text = Room.Status.GetDescription(); + + foreach (Drawable d in new Drawable[] { sideStrip, status }) + d.FadeColour(Room.Status == MultiplayerRoomStatus.Playing? playingColour : openColour); + } + } +} diff --git a/osu.Game/Screens/Multiplayer/MultiRoomPanel.cs b/osu.Game/Screens/Multiplayer/MultiRoomPanel.cs deleted file mode 100644 index cbc4cc1182..0000000000 --- a/osu.Game/Screens/Multiplayer/MultiRoomPanel.cs +++ /dev/null @@ -1,269 +0,0 @@ -// 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; -using osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Input; -using osu.Game.Graphics.Backgrounds; -using osu.Game.Graphics.Sprites; - -namespace osu.Game.Screens.Multiplayer -{ - public class MultiRoomPanel : ClickableContainer, IStateful - { - private PanelState state; - public PanelState State - { - get { return state; } - set - { - if (state == value) - return; - - state = value; - switch (state) - { - case PanelState.Free: - statusColour = ColourFree; - statusString = "Welcoming Players"; - UpdatePanel(this); - break; - - case PanelState.Busy: - statusColour = ColourBusy; - statusString = "Now Playing"; - UpdatePanel(this); - break; - } - } - } - - private bool didClick; - private string roomName; - private string hostName; - - private int roomStatus; - private Color4 statusColour; - private string statusString; - - private Box sideSprite; - private OsuSpriteText hostSprite; - private OsuSpriteText statusSprite; - private OsuSpriteText roomSprite; - - public const int PANEL_HEIGHT = 90; - public const int CONTENT_PADDING = 5; - - public Color4 ColourFree = new Color4(166, 204, 0, 255); - public Color4 ColourBusy = new Color4(135, 102, 237, 255); - - public bool Clicked - { - get { return didClick; } - set - { - didClick = value; - } - } - - public void UpdatePanel(MultiRoomPanel panel) - { - panel.BorderColour = statusColour; - panel.sideSprite.Colour = statusColour; - - statusSprite.Colour = statusColour; - statusSprite.Text = statusString; - } - - public MultiRoomPanel(string matchName = "Room Name", string host = "Undefined", int status = 0) - { - roomName = matchName; - hostName = host; - roomStatus = status; - - if (status == 0) - { - statusColour = ColourFree; - statusString = "Welcoming Players"; - } - else - { - statusColour = ColourBusy; - statusString = "Now Playing"; - } - - RelativeSizeAxes = Axes.X; - Height = PANEL_HEIGHT; - Masking = true; - CornerRadius = 5; - BorderThickness = 0; - BorderColour = statusColour; - EdgeEffect = new EdgeEffect - { - Type = EdgeEffectType.Shadow, - Colour = Color4.Black.Opacity(40), - Radius = 5, - }; - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = new Color4(34,34,34, 255), - }, - sideSprite = new Box - { - RelativeSizeAxes = Axes.Y, - Width = 5, - Colour = statusColour, - }, - /*new Box //Beatmap img - { - - },*/ - new Background(@"Backgrounds/bg4") - { - RelativeSizeAxes = Axes.Both, - } - , - new FillFlowContainer - { - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - Direction = FillDirection.Vertical, - Size = new Vector2(0.75f,1), - - Children = new Drawable[] - { - roomSprite = new OsuSpriteText - { - Text = roomName, - TextSize = 18, - Margin = new MarginPadding { Top = CONTENT_PADDING }, - }, - new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - Height = 20, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(5,0), - Children = new Drawable[] - { - - - new Container - { - Masking = true, - CornerRadius = 5, - Width = 30, - Height = 20, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Gray, - } - } - - }, - new Container - { - Masking = true, - CornerRadius = 5, - Width = 40, - Height = 20, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = new Color4(173,56,126,255), - } - } - }, - new OsuSpriteText - { - Text = "hosted by", - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - TextSize = 14, - }, - hostSprite = new OsuSpriteText - { - Text = hostName, - Font = @"Exo2.0-Bold", - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Shear = new Vector2(0.1f,0), - Colour = new Color4(69,179,222,255), - TextSize = 14, - }, - new OsuSpriteText - { - Text = "#6895 - #50024", - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - TextSize = 14, - Margin = new MarginPadding { Left = 80 }, - Colour = new Color4(153,153,153,255), - } - } - }, - statusSprite = new OsuSpriteText - { - Text = statusString, - TextSize = 14, - Font = @"Exo2.0-Bold", - Colour = statusColour, - Margin = new MarginPadding { Top = 10 } - }, - new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - Direction = FillDirection.Horizontal, - Children = new Drawable[] - { - new OsuSpriteText - { - Text = "Platina", - Font = @"Exo2.0-Bold", - TextSize = 14, - Shear = new Vector2(0.1f,0), - Colour = new Color4(153,153,153,255), - }, - new OsuSpriteText - { - Text = " - " + "Maaya Sakamoto", - TextSize = 14, - Shear = new Vector2(0.1f,0), - Colour = new Color4(153,153,153,255), - } - } - }, - } - }, - }; - } - - protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) - { - BorderThickness = 3; - didClick = true; - return base.OnMouseUp(state, args); - } - - public enum PanelState - { - Free, - Busy - } - } -} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index f96bbaa08a..d773e0c093 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -428,7 +428,8 @@ - + + @@ -451,6 +452,9 @@ + + + - \ No newline at end of file + From 800a31947014ee6bb9c77a95eb782f6ac4f057d6 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 01:08:35 -0300 Subject: [PATCH 09/37] Remove newline --- osu.Game/osu.Game.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 2b0a6435bc..27bcb8fa39 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -457,4 +457,4 @@ --> - + \ No newline at end of file From 26bf9dd64bfdceb7df4bf162ee21ee519a0947ec Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 01:13:51 -0300 Subject: [PATCH 10/37] Remove unused Background --- osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs b/osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs index 4a746226d8..97efef2968 100644 --- a/osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs @@ -64,10 +64,6 @@ namespace osu.Game.Screens.Multiplayer RelativeSizeAxes = Axes.Both, Colour = OsuColour.Gray(34), }, - new Background(@"Backgrounds/bg4") - { - RelativeSizeAxes = Axes.Both, - }, sideStrip = new Box { RelativeSizeAxes = Axes.Y, From d1df89584437c5d3cb4af3c3424d62485506fe00 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 01:16:59 -0300 Subject: [PATCH 11/37] Unused using --- osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs b/osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs index 97efef2968..37182cb692 100644 --- a/osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs @@ -12,7 +12,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Localisation; using osu.Game.Graphics; -using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Sprites; using osu.Game.Online.Multiplayer; using osu.Game.Users; From 87cdf5aac61fcf3a609823b556344218be1798cb Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 01:29:39 -0300 Subject: [PATCH 12/37] CI fixes --- .../Tests/TestCaseDrawableMultiplayerRoom.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawableMultiplayerRoom.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawableMultiplayerRoom.cs index a358fd6701..1c6c0d6420 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDrawableMultiplayerRoom.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawableMultiplayerRoom.cs @@ -1,25 +1,17 @@ // 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.Game.Graphics.UserInterface; -using osu.Game.Screens.Select; -using osu.Game.Screens.Multiplayer; -using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Input; -using osu.Game.Graphics.Sprites; +using osu.Framework.Graphics; using osu.Framework.Testing; +using osu.Game.Screens.Multiplayer; using osu.Game.Online.Multiplayer; using osu.Game.Users; using osu.Game.Database; namespace osu.Desktop.VisualTests.Tests { - class TestCaseDrawableMultiplayerRoom : TestCase + internal class TestCaseDrawableMultiplayerRoom : TestCase { public override string Description => @"Select your favourite room"; From 03f6cded8463a75cf762d8661c13e840ee349ccc Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 12:44:58 -0300 Subject: [PATCH 13/37] MultiplayerRoom -> Room --- ...wableMultiplayerRoom.cs => TestCaseDrawableRoom.cs} | 8 ++++---- osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj | 2 +- .../Online/Multiplayer/{MultiplayerRoom.cs => Room.cs} | 2 +- .../{DrawableMultiplayerRoom.cs => DrawableRoom.cs} | 10 +++++----- osu.Game/osu.Game.csproj | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) rename osu.Desktop.VisualTests/Tests/{TestCaseDrawableMultiplayerRoom.cs => TestCaseDrawableRoom.cs} (89%) rename osu.Game/Online/Multiplayer/{MultiplayerRoom.cs => Room.cs} (91%) rename osu.Game/Screens/Multiplayer/{DrawableMultiplayerRoom.cs => DrawableRoom.cs} (95%) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawableMultiplayerRoom.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs similarity index 89% rename from osu.Desktop.VisualTests/Tests/TestCaseDrawableMultiplayerRoom.cs rename to osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs index 1c6c0d6420..8150de9fb8 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDrawableMultiplayerRoom.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs @@ -11,7 +11,7 @@ using osu.Game.Database; namespace osu.Desktop.VisualTests.Tests { - internal class TestCaseDrawableMultiplayerRoom : TestCase + internal class TestCaseDrawableRoom : TestCase { public override string Description => @"Select your favourite room"; @@ -19,7 +19,7 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - DrawableMultiplayerRoom p; + DrawableRoom p; Add(new FillFlowContainer { Anchor = Anchor.Centre, @@ -29,14 +29,14 @@ namespace osu.Desktop.VisualTests.Tests Direction = FillDirection.Vertical, Children = new Drawable[] { - p = new DrawableMultiplayerRoom(new MultiplayerRoom + p = new DrawableRoom(new Room { Name = @"Great Room Right Here", Host = new User { Username = @"Naeferith", Id = 9492835, Country = new Country { FlagName = @"FR" }}, Status = MultiplayerRoomStatus.Open, CurrentBeatmap = new BeatmapMetadata { Title = @"Seiryu", Artist = @"Critical Crystal" }, }), - new DrawableMultiplayerRoom(new MultiplayerRoom + new DrawableRoom(new Room { Name = @"Relax It's The Weekend", Host = new User{ Username = @"peppy", Id = 2, Country = new Country { FlagName = @"AU" }}, diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index fa507527aa..6e6f0a691d 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -220,7 +220,7 @@ - + diff --git a/osu.Game/Online/Multiplayer/MultiplayerRoom.cs b/osu.Game/Online/Multiplayer/Room.cs similarity index 91% rename from osu.Game/Online/Multiplayer/MultiplayerRoom.cs rename to osu.Game/Online/Multiplayer/Room.cs index 5c9e72bcf2..9def99386d 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerRoom.cs +++ b/osu.Game/Online/Multiplayer/Room.cs @@ -7,7 +7,7 @@ using osu.Game.Users; namespace osu.Game.Online.Multiplayer { - public class MultiplayerRoom + public class Room { public string Name { get; set; } public User Host { get; set; } diff --git a/osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs b/osu.Game/Screens/Multiplayer/DrawableRoom.cs similarity index 95% rename from osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs rename to osu.Game/Screens/Multiplayer/DrawableRoom.cs index 37182cb692..4a7622b888 100644 --- a/osu.Game/Screens/Multiplayer/DrawableMultiplayerRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableRoom.cs @@ -18,7 +18,7 @@ using osu.Game.Users; namespace osu.Game.Screens.Multiplayer { - public class DrawableMultiplayerRoom : ClickableContainer + public class DrawableRoom : ClickableContainer { private const float content_padding = 5; private const float height = 90; @@ -39,11 +39,11 @@ namespace osu.Game.Screens.Multiplayer private Color4 playingColour; private LocalisationEngine localisation; - public readonly Bindable Room; + public readonly Bindable Room; - public DrawableMultiplayerRoom(MultiplayerRoom room) + public DrawableRoom(Room room) { - Room = new Bindable(room); + Room = new Bindable(room); RelativeSizeAxes = Axes.X; Height = height; @@ -206,7 +206,7 @@ namespace osu.Game.Screens.Multiplayer Room.TriggerChange(); } - private void displayRoom(MultiplayerRoom room) + private void displayRoom(Room room) { name.Text = room.Name; status.Text = room.Status.GetDescription(); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 27bcb8fa39..7af7bdf1e6 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -425,8 +425,8 @@ - - + + From 2c16d9c3a7531d7397117719a0cd6e8e5b04befd Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 12:45:40 -0300 Subject: [PATCH 14/37] CurrentBeatmap -> Beatmap --- osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs | 6 +++--- osu.Game/Online/Multiplayer/Room.cs | 2 +- osu.Game/Screens/Multiplayer/DrawableRoom.cs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs index 8150de9fb8..2a10be8906 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs @@ -34,14 +34,14 @@ namespace osu.Desktop.VisualTests.Tests Name = @"Great Room Right Here", Host = new User { Username = @"Naeferith", Id = 9492835, Country = new Country { FlagName = @"FR" }}, Status = MultiplayerRoomStatus.Open, - CurrentBeatmap = new BeatmapMetadata { Title = @"Seiryu", Artist = @"Critical Crystal" }, + Beatmap = new BeatmapMetadata { Title = @"Seiryu", Artist = @"Critical Crystal" }, }), new DrawableRoom(new Room { Name = @"Relax It's The Weekend", Host = new User{ Username = @"peppy", Id = 2, Country = new Country { FlagName = @"AU" }}, Status = MultiplayerRoomStatus.Playing, - CurrentBeatmap = new BeatmapMetadata { Title = @"ZAQ", Artist = @"Serendipity" }, + Beatmap = new BeatmapMetadata { Title = @"ZAQ", Artist = @"Serendipity" }, }), } }); @@ -66,7 +66,7 @@ namespace osu.Desktop.VisualTests.Tests AddStep(@"change beatmap", () => { - p.Room.Value.CurrentBeatmap = null; + p.Room.Value.Beatmap = null; p.Room.TriggerChange(); }); diff --git a/osu.Game/Online/Multiplayer/Room.cs b/osu.Game/Online/Multiplayer/Room.cs index 9def99386d..56ac71f6f9 100644 --- a/osu.Game/Online/Multiplayer/Room.cs +++ b/osu.Game/Online/Multiplayer/Room.cs @@ -12,7 +12,7 @@ namespace osu.Game.Online.Multiplayer public string Name { get; set; } public User Host { get; set; } public MultiplayerRoomStatus Status { get; set; } - public BeatmapMetadata CurrentBeatmap { get; set; } + public BeatmapMetadata Beatmap { get; set; } } public enum MultiplayerRoomStatus diff --git a/osu.Game/Screens/Multiplayer/DrawableRoom.cs b/osu.Game/Screens/Multiplayer/DrawableRoom.cs index 4a7622b888..b33100c900 100644 --- a/osu.Game/Screens/Multiplayer/DrawableRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableRoom.cs @@ -214,11 +214,11 @@ namespace osu.Game.Screens.Multiplayer flagContainer.Children = new[] { new DrawableFlag(room.Host.Country?.FlagName ?? @"__") { RelativeSizeAxes = Axes.Both } }; avatar.User = room.Host; - if (room.CurrentBeatmap != null) + if (room.Beatmap != null) { - beatmapTitle.Current = localisation.GetUnicodePreference(room.CurrentBeatmap.TitleUnicode, room.CurrentBeatmap.Title); + beatmapTitle.Current = localisation.GetUnicodePreference(room.Beatmap.TitleUnicode, room.Beatmap.Title); beatmapDash.Text = @" - "; - beatmapArtist.Current = localisation.GetUnicodePreference(room.CurrentBeatmap.ArtistUnicode, room.CurrentBeatmap.Artist); + beatmapArtist.Current = localisation.GetUnicodePreference(room.Beatmap.ArtistUnicode, room.Beatmap.Artist); } else { From 65df2d2b70d262691a01cf424c74ebe95b1c4841 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 12:46:41 -0300 Subject: [PATCH 15/37] MultiplayerRoomStatus -> RoomStatus --- osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs | 8 ++++---- osu.Game/Online/Multiplayer/Room.cs | 4 ++-- osu.Game/Screens/Multiplayer/DrawableRoom.cs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs index 2a10be8906..08034ee4ae 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs @@ -33,14 +33,14 @@ namespace osu.Desktop.VisualTests.Tests { Name = @"Great Room Right Here", Host = new User { Username = @"Naeferith", Id = 9492835, Country = new Country { FlagName = @"FR" }}, - Status = MultiplayerRoomStatus.Open, + Status = RoomStatus.Open, Beatmap = new BeatmapMetadata { Title = @"Seiryu", Artist = @"Critical Crystal" }, }), new DrawableRoom(new Room { Name = @"Relax It's The Weekend", Host = new User{ Username = @"peppy", Id = 2, Country = new Country { FlagName = @"AU" }}, - Status = MultiplayerRoomStatus.Playing, + Status = RoomStatus.Playing, Beatmap = new BeatmapMetadata { Title = @"ZAQ", Artist = @"Serendipity" }, }), } @@ -48,7 +48,7 @@ namespace osu.Desktop.VisualTests.Tests AddStep(@"change state", () => { - p.Room.Value.Status = MultiplayerRoomStatus.Playing; + p.Room.Value.Status = RoomStatus.Playing; p.Room.TriggerChange(); }); @@ -72,7 +72,7 @@ namespace osu.Desktop.VisualTests.Tests AddStep(@"change state", () => { - p.Room.Value.Status = MultiplayerRoomStatus.Open; + p.Room.Value.Status = RoomStatus.Open; p.Room.TriggerChange(); }); } diff --git a/osu.Game/Online/Multiplayer/Room.cs b/osu.Game/Online/Multiplayer/Room.cs index 56ac71f6f9..12df7dc61c 100644 --- a/osu.Game/Online/Multiplayer/Room.cs +++ b/osu.Game/Online/Multiplayer/Room.cs @@ -11,11 +11,11 @@ namespace osu.Game.Online.Multiplayer { public string Name { get; set; } public User Host { get; set; } - public MultiplayerRoomStatus Status { get; set; } + public RoomStatus Status { get; set; } public BeatmapMetadata Beatmap { get; set; } } - public enum MultiplayerRoomStatus + public enum RoomStatus { [Description(@"Welcoming Players")] Open, diff --git a/osu.Game/Screens/Multiplayer/DrawableRoom.cs b/osu.Game/Screens/Multiplayer/DrawableRoom.cs index b33100c900..db7dcb1a60 100644 --- a/osu.Game/Screens/Multiplayer/DrawableRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableRoom.cs @@ -231,7 +231,7 @@ namespace osu.Game.Screens.Multiplayer } foreach (Drawable d in new Drawable[] { sideStrip, status }) - d.FadeColour(room.Status == MultiplayerRoomStatus.Playing? playingColour : openColour, 100); + d.FadeColour(room.Status == RoomStatus.Playing? playingColour : openColour, 100); } } } From 25b457e994947b6549fca71bf0b76ae3585714fe Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 13:05:18 -0300 Subject: [PATCH 16/37] Proper Bindable usage --- .../Tests/TestCaseDrawableRoom.cs | 44 ++++++++--------- osu.Game/Online/Multiplayer/Room.cs | 9 ++-- osu.Game/Screens/Multiplayer/DrawableRoom.cs | 47 ++++++++++++------- 3 files changed, 55 insertions(+), 45 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs index 08034ee4ae..4164e27195 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs @@ -19,7 +19,8 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - DrawableRoom p; + DrawableRoom first; + DrawableRoom second; Add(new FillFlowContainer { Anchor = Anchor.Centre, @@ -29,51 +30,44 @@ namespace osu.Desktop.VisualTests.Tests Direction = FillDirection.Vertical, Children = new Drawable[] { - p = new DrawableRoom(new Room - { - Name = @"Great Room Right Here", - Host = new User { Username = @"Naeferith", Id = 9492835, Country = new Country { FlagName = @"FR" }}, - Status = RoomStatus.Open, - Beatmap = new BeatmapMetadata { Title = @"Seiryu", Artist = @"Critical Crystal" }, - }), - new DrawableRoom(new Room - { - Name = @"Relax It's The Weekend", - Host = new User{ Username = @"peppy", Id = 2, Country = new Country { FlagName = @"AU" }}, - Status = RoomStatus.Playing, - Beatmap = new BeatmapMetadata { Title = @"ZAQ", Artist = @"Serendipity" }, - }), + first = new DrawableRoom(new Room()), + second = new DrawableRoom(new Room()), } }); + first.Room.Name.Value = @"Great Room Right Here"; + first.Room.Host.Value = new User { Username = @"Naeferith", Id = 9492835, Country = new Country { FlagName = @"FR" }}; + first.Room.Status.Value = RoomStatus.Open; + first.Room.Beatmap.Value = new BeatmapMetadata { Title = @"Seiryu", Artist = @"Critical Crystal" }; + + second.Room.Name.Value = @"Relax It's The Weekend"; + second.Room.Host.Value = new User { Username = @"peppy", Id = 2, Country = new Country { FlagName = @"AU" }}; + second.Room.Status.Value = RoomStatus.Playing; + second.Room.Beatmap.Value = new BeatmapMetadata { Title = @"ZAQ", Artist = @"Serendipity" }; + AddStep(@"change state", () => { - p.Room.Value.Status = RoomStatus.Playing; - p.Room.TriggerChange(); + first.Room.Status.Value = RoomStatus.Playing; }); AddStep(@"change name", () => { - p.Room.Value.Name = @"I Changed Name"; - p.Room.TriggerChange(); + first.Room.Name.Value = @"I Changed Name"; }); AddStep(@"change host", () => { - p.Room.Value.Host = new User { Username = @"DrabWeb", Id = 6946022, Country = new Country { FlagName = @"CA" } }; - p.Room.TriggerChange(); + first.Room.Host.Value = new User { Username = @"DrabWeb", Id = 6946022, Country = new Country { FlagName = @"CA" } }; }); AddStep(@"change beatmap", () => { - p.Room.Value.Beatmap = null; - p.Room.TriggerChange(); + first.Room.Beatmap.Value = null; }); AddStep(@"change state", () => { - p.Room.Value.Status = RoomStatus.Open; - p.Room.TriggerChange(); + first.Room.Status.Value = RoomStatus.Open; }); } } diff --git a/osu.Game/Online/Multiplayer/Room.cs b/osu.Game/Online/Multiplayer/Room.cs index 12df7dc61c..3dacf0862e 100644 --- a/osu.Game/Online/Multiplayer/Room.cs +++ b/osu.Game/Online/Multiplayer/Room.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.ComponentModel; +using osu.Framework.Configuration; using osu.Game.Database; using osu.Game.Users; @@ -9,10 +10,10 @@ namespace osu.Game.Online.Multiplayer { public class Room { - public string Name { get; set; } - public User Host { get; set; } - public RoomStatus Status { get; set; } - public BeatmapMetadata Beatmap { get; set; } + public Bindable Name = new Bindable(); + public Bindable Host = new Bindable(); + public Bindable Status = new Bindable(); + public Bindable Beatmap = new Bindable(); } public enum RoomStatus diff --git a/osu.Game/Screens/Multiplayer/DrawableRoom.cs b/osu.Game/Screens/Multiplayer/DrawableRoom.cs index db7dcb1a60..5e81c46282 100644 --- a/osu.Game/Screens/Multiplayer/DrawableRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableRoom.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Localisation; +using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Online.Multiplayer; @@ -39,11 +40,11 @@ namespace osu.Game.Screens.Multiplayer private Color4 playingColour; private LocalisationEngine localisation; - public readonly Bindable Room; + public readonly Room Room; public DrawableRoom(Room room) { - Room = new Bindable(room); + Room = room; RelativeSizeAxes = Axes.X; Height = height; @@ -190,7 +191,10 @@ namespace osu.Game.Screens.Multiplayer }, }; - Room.ValueChanged += displayRoom; + Room.Name.ValueChanged += displayName; + Room.Host.ValueChanged += displayUser; + Room.Status.ValueChanged += displayStatus; + Room.Beatmap.ValueChanged += displayBeatmap; } [BackgroundDependencyLoader] @@ -203,22 +207,36 @@ namespace osu.Game.Screens.Multiplayer beatmapInfoFlow.Colour = rankBounds.Colour = colours.Gray9; host.Colour = colours.Blue; - Room.TriggerChange(); + displayStatus(Room.Status.Value); } - private void displayRoom(Room room) + private void displayName(string value) { - name.Text = room.Name; - status.Text = room.Status.GetDescription(); - host.Text = room.Host.Username; - flagContainer.Children = new[] { new DrawableFlag(room.Host.Country?.FlagName ?? @"__") { RelativeSizeAxes = Axes.Both } }; - avatar.User = room.Host; + name.Text = value; + } - if (room.Beatmap != null) + private void displayUser(User value) + { + avatar.User = value; + host.Text = value.Username; + flagContainer.Children = new[] { new DrawableFlag(value.Country?.FlagName ?? @"__") { RelativeSizeAxes = Axes.Both } }; + } + + private void displayStatus(RoomStatus value) + { + status.Text = value.GetDescription() ?? value.ToString(); + + foreach (Drawable d in new Drawable[] { sideStrip, status }) + d.FadeColour(value == RoomStatus.Playing ? playingColour : openColour, 100); + } + + private void displayBeatmap(BeatmapMetadata value) + { + if (value != null) { - beatmapTitle.Current = localisation.GetUnicodePreference(room.Beatmap.TitleUnicode, room.Beatmap.Title); + beatmapTitle.Current = localisation.GetUnicodePreference(value.TitleUnicode, value.Title); beatmapDash.Text = @" - "; - beatmapArtist.Current = localisation.GetUnicodePreference(room.Beatmap.ArtistUnicode, room.Beatmap.Artist); + beatmapArtist.Current = localisation.GetUnicodePreference(value.ArtistUnicode, value.Artist); } else { @@ -229,9 +247,6 @@ namespace osu.Game.Screens.Multiplayer beatmapDash.Text = string.Empty; beatmapArtist.Text = string.Empty; } - - foreach (Drawable d in new Drawable[] { sideStrip, status }) - d.FadeColour(room.Status == RoomStatus.Playing? playingColour : openColour, 100); } } } From cf0e7887b57618ca01700b36054929a5b2ebd70f Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 13:14:56 -0300 Subject: [PATCH 17/37] Unused using --- osu.Game/Screens/Multiplayer/DrawableRoom.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Multiplayer/DrawableRoom.cs b/osu.Game/Screens/Multiplayer/DrawableRoom.cs index 5e81c46282..f3ff88b086 100644 --- a/osu.Game/Screens/Multiplayer/DrawableRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableRoom.cs @@ -4,7 +4,6 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Configuration; using osu.Framework.Extensions; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; From 9798117d53462e9aefea28c67be643ceaa3dbdb0 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 21:13:57 -0300 Subject: [PATCH 18/37] Move RoomStatus to a class instead of enum --- .../Tests/TestCaseDrawableRoom.cs | 8 +++--- osu.Game/Online/Multiplayer/Room.cs | 12 +-------- osu.Game/Online/Multiplayer/RoomStatus.cs | 26 +++++++++++++++++++ osu.Game/Screens/Multiplayer/DrawableRoom.cs | 12 ++++----- osu.Game/osu.Game.csproj | 1 + 5 files changed, 37 insertions(+), 22 deletions(-) create mode 100644 osu.Game/Online/Multiplayer/RoomStatus.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs index 4164e27195..de58323abe 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs @@ -37,17 +37,17 @@ namespace osu.Desktop.VisualTests.Tests first.Room.Name.Value = @"Great Room Right Here"; first.Room.Host.Value = new User { Username = @"Naeferith", Id = 9492835, Country = new Country { FlagName = @"FR" }}; - first.Room.Status.Value = RoomStatus.Open; + first.Room.Status.Value = new RoomStatusOpen(); first.Room.Beatmap.Value = new BeatmapMetadata { Title = @"Seiryu", Artist = @"Critical Crystal" }; second.Room.Name.Value = @"Relax It's The Weekend"; second.Room.Host.Value = new User { Username = @"peppy", Id = 2, Country = new Country { FlagName = @"AU" }}; - second.Room.Status.Value = RoomStatus.Playing; + second.Room.Status.Value = new RoomStatusPlaying(); second.Room.Beatmap.Value = new BeatmapMetadata { Title = @"ZAQ", Artist = @"Serendipity" }; AddStep(@"change state", () => { - first.Room.Status.Value = RoomStatus.Playing; + first.Room.Status.Value = new RoomStatusPlaying(); }); AddStep(@"change name", () => @@ -67,7 +67,7 @@ namespace osu.Desktop.VisualTests.Tests AddStep(@"change state", () => { - first.Room.Status.Value = RoomStatus.Open; + first.Room.Status.Value = new RoomStatusOpen(); }); } } diff --git a/osu.Game/Online/Multiplayer/Room.cs b/osu.Game/Online/Multiplayer/Room.cs index 3dacf0862e..c82025f902 100644 --- a/osu.Game/Online/Multiplayer/Room.cs +++ b/osu.Game/Online/Multiplayer/Room.cs @@ -1,7 +1,6 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . +// Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.ComponentModel; using osu.Framework.Configuration; using osu.Game.Database; using osu.Game.Users; @@ -15,13 +14,4 @@ namespace osu.Game.Online.Multiplayer public Bindable Status = new Bindable(); public Bindable Beatmap = new Bindable(); } - - public enum RoomStatus - { - [Description(@"Welcoming Players")] - Open, - - [Description(@"Now Playing")] - Playing, - } } diff --git a/osu.Game/Online/Multiplayer/RoomStatus.cs b/osu.Game/Online/Multiplayer/RoomStatus.cs new file mode 100644 index 0000000000..4f943596a7 --- /dev/null +++ b/osu.Game/Online/Multiplayer/RoomStatus.cs @@ -0,0 +1,26 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Game.Graphics; + +namespace osu.Game.Online.Multiplayer +{ + public abstract class RoomStatus + { + public abstract string Message { get; } + public abstract Color4 GetAppropriateColour(OsuColour colours); + } + + public class RoomStatusOpen : RoomStatus + { + public override string Message => @"Welcoming Players"; + public override Color4 GetAppropriateColour(OsuColour colours) => colours.GreenLight; + } + + public class RoomStatusPlaying : RoomStatus + { + public override string Message => @"Now Playing"; + public override Color4 GetAppropriateColour(OsuColour colours) => colours.Purple; + } +} diff --git a/osu.Game/Screens/Multiplayer/DrawableRoom.cs b/osu.Game/Screens/Multiplayer/DrawableRoom.cs index f3ff88b086..e4e781b839 100644 --- a/osu.Game/Screens/Multiplayer/DrawableRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableRoom.cs @@ -4,7 +4,6 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Extensions; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -35,8 +34,7 @@ namespace osu.Game.Screens.Multiplayer private readonly OsuSpriteText beatmapDash; private readonly OsuSpriteText beatmapArtist; - private Color4 openColour; - private Color4 playingColour; + private OsuColour colours; private LocalisationEngine localisation; public readonly Room Room; @@ -200,9 +198,8 @@ namespace osu.Game.Screens.Multiplayer private void load(OsuColour colours, LocalisationEngine localisation) { this.localisation = localisation; + this.colours = colours; - openColour = colours.GreenLight; - playingColour = colours.Purple; beatmapInfoFlow.Colour = rankBounds.Colour = colours.Gray9; host.Colour = colours.Blue; @@ -223,10 +220,11 @@ namespace osu.Game.Screens.Multiplayer private void displayStatus(RoomStatus value) { - status.Text = value.GetDescription() ?? value.ToString(); + if (value == null) return; + status.Text = value.Message; foreach (Drawable d in new Drawable[] { sideStrip, status }) - d.FadeColour(value == RoomStatus.Playing ? playingColour : openColour, 100); + d.FadeColour(value.GetAppropriateColour(colours), 100); } private void displayBeatmap(BeatmapMetadata value) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 7af7bdf1e6..2d2894cdca 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -427,6 +427,7 @@ + From 0dbb2220e090f5c59723f25c275c23939a047ba6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 24 May 2017 21:07:12 +0900 Subject: [PATCH 19/37] Add missing early activation to menu flashes --- osu.Game/Screens/Menu/MenuSideFlashes.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Menu/MenuSideFlashes.cs b/osu.Game/Screens/Menu/MenuSideFlashes.cs index 0cf1fa54fa..77239726e8 100644 --- a/osu.Game/Screens/Menu/MenuSideFlashes.cs +++ b/osu.Game/Screens/Menu/MenuSideFlashes.cs @@ -36,6 +36,8 @@ namespace osu.Game.Screens.Menu public MenuSideFlashes() { + EarlyActivationMilliseconds = box_fade_in_time; + RelativeSizeAxes = Axes.Both; Anchor = Anchor.Centre; Origin = Anchor.Centre; From 5cb6963940662f61982dbc43457303b70471b45e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 24 May 2017 22:08:14 +0900 Subject: [PATCH 20/37] Make spinners easier for now The underlying spin counting doesn't match stabnle, so they have been near impossible to complete until now. --- osu.Game.Rulesets.Osu/Objects/Spinner.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game.Rulesets.Osu/Objects/Spinner.cs b/osu.Game.Rulesets.Osu/Objects/Spinner.cs index eff60ba935..6ba499739a 100644 --- a/osu.Game.Rulesets.Osu/Objects/Spinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Spinner.cs @@ -24,6 +24,9 @@ namespace osu.Game.Rulesets.Osu.Objects base.ApplyDefaults(controlPointInfo, difficulty); SpinsRequired = (int)(Duration / 1000 * BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 3, 5, 7.5)); + + // spinning doesn't match 1:1 with stable, so let's fudge them easier for the time being. + SpinsRequired = (int)(SpinsRequired * 0.6); } } } From b803e40a7d68d3e996f9d7d2950d6c49fe6eb6df Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 24 May 2017 17:02:28 -0300 Subject: [PATCH 21/37] Unbind from room values when disposing --- osu.Game/Screens/Multiplayer/DrawableRoom.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/osu.Game/Screens/Multiplayer/DrawableRoom.cs b/osu.Game/Screens/Multiplayer/DrawableRoom.cs index e4e781b839..7365963085 100644 --- a/osu.Game/Screens/Multiplayer/DrawableRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableRoom.cs @@ -245,5 +245,15 @@ namespace osu.Game.Screens.Multiplayer beatmapArtist.Text = string.Empty; } } + + protected override void Dispose(bool isDisposing) + { + Room.Name.ValueChanged -= displayName; + Room.Host.ValueChanged -= displayUser; + Room.Status.ValueChanged -= displayStatus; + Room.Beatmap.ValueChanged -= displayBeatmap; + + base.Dispose(isDisposing); + } } } From b57a3f20562530877fe4520db08f6a1dee3dd4cd Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 24 May 2017 19:44:48 -0300 Subject: [PATCH 22/37] Initial layout of user panel and user dropdown --- .../Graphics/UserInterface/OsuDropdown.cs | 10 +- .../Sections/General/LoginSettings.cs | 163 ++++++++++++++++-- 2 files changed, 158 insertions(+), 15 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index 9c1799c04c..9d11b8074d 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -42,7 +42,7 @@ namespace osu.Game.Graphics.UserInterface protected override DropdownMenuItem CreateMenuItem(string text, T value) => new OsuDropdownMenuItem(text, value) { AccentColour = AccentColour }; - private class OsuDropdownMenuItem : DropdownMenuItem + public class OsuDropdownMenuItem : DropdownMenuItem { public OsuDropdownMenuItem(string text, T current) : base(text, current) { @@ -115,11 +115,11 @@ namespace osu.Game.Graphics.UserInterface public class OsuDropdownHeader : DropdownHeader { - private readonly SpriteText label; + protected readonly SpriteText Text; protected override string Label { - get { return label.Text; } - set { label.Text = value; } + get { return Text.Text; } + set { Text.Text = value; } } protected readonly TextAwesome Icon; @@ -146,7 +146,7 @@ namespace osu.Game.Graphics.UserInterface Foreground.Children = new Drawable[] { - label = new OsuSpriteText + Text = new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index d94388ed87..da07f55be0 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -13,16 +13,20 @@ using osu.Game.Online.API; using OpenTK; using osu.Framework.Input; using osu.Game.Users; +using System.ComponentModel; +using osu.Game.Graphics; +using OpenTK.Graphics; +using osu.Framework.Extensions.Color4Extensions; + +using Container = osu.Framework.Graphics.Containers.Container; namespace osu.Game.Overlays.Settings.Sections.General { - public class LoginSettings : SettingsSubsection, IOnlineComponent + public class LoginSettings : FillFlowContainer, IOnlineComponent { private bool bounding = true; private LoginForm form; - protected override string Header => "Account"; - public override RectangleF BoundingBox => bounding ? base.BoundingBox : RectangleF.Empty; public bool Bounding @@ -35,6 +39,14 @@ namespace osu.Game.Overlays.Settings.Sections.General } } + public LoginSettings() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Direction = FillDirection.Vertical; + Spacing = new Vector2(0f, 5f); + } + [BackgroundDependencyLoader(permitNulls: true)] private void load(APIAccess api) { @@ -50,6 +62,12 @@ namespace osu.Game.Overlays.Settings.Sections.General case APIState.Offline: Children = new Drawable[] { + new OsuSpriteText + { + Text = "LOG IN", + Margin = new MarginPadding { Bottom = 10 }, + Font = @"Exo2.0-Black", + }, form = new LoginForm() }; break; @@ -67,23 +85,52 @@ namespace osu.Game.Overlays.Settings.Sections.General { new OsuSpriteText { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, Text = "Connecting...", + Margin = new MarginPadding { Top = 10, Bottom = 10 }, }, }; break; case APIState.Online: Children = new Drawable[] { - new UserPanel(api.LocalUser.Value) + new FillFlowContainer { RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { Left = 20, Right = 20 }, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0f, 10f), + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new[] + { + new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Text = "Signed in", + TextSize = 18, + Font = @"Exo2.0-Bold", + Margin = new MarginPadding { Top = 5, Bottom = 5 }, + }, + }, + }, + new UserPanel(api.LocalUser.Value) + { + RelativeSizeAxes = Axes.X, + }, + new UserDropdown + { + RelativeSizeAxes = Axes.X, + }, + }, }, - new OsuButton - { - RelativeSizeAxes = Axes.X, - Text = "Sign out", - Action = api.Logout - } }; break; } @@ -171,5 +218,101 @@ namespace osu.Game.Overlays.Settings.Sections.General return base.OnFocus(state); } } + + private class UserDropdown : OsuEnumDropdown + { + protected override DropdownHeader CreateHeader() => new UserDropdownHeader { AccentColour = AccentColour }; + protected override Menu CreateMenu() => new UserDropdownMenu(); + protected override DropdownMenuItem CreateMenuItem(string text, UserAction value) => new UserDropdownMenuItem(text, value) { AccentColour = AccentColour }; + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + AccentColour = colours.Gray5; + } + + private class UserDropdownHeader : OsuDropdownHeader + { + protected readonly TextAwesome statusIcon; + + public UserDropdownHeader() + { + Foreground.Padding = new MarginPadding { Left = 10, Right = 10 }; + Margin = new MarginPadding { Bottom = 5 }; + Masking = true; + CornerRadius = 5; + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.25f), + Radius = 4, + }; + + Icon.TextSize = 14; + Icon.Margin = new MarginPadding(0); + + Foreground.Add(statusIcon = new TextAwesome + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Icon = FontAwesome.fa_circle_o, + TextSize = 14, + }); + + //todo: Magic number + Text.Margin = new MarginPadding { Left = 20 }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + BackgroundColour = colours.Gray3; + } + + public void SetStatusColour(Color4 colour) => statusIcon.FadeColour(colour, 500, EasingTypes.OutQuint); + } + + private class UserDropdownMenu : OsuMenu + { + public UserDropdownMenu() + { + CornerRadius = 5; + ItemsContainer.Padding = new MarginPadding(0); + Masking = true; + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.25f), + Radius = 4, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Background.Colour = colours.Gray3; + } + } + + private class UserDropdownMenuItem : OsuDropdownMenuItem + { + public UserDropdownMenuItem(string text, UserAction current) : base(text, current) + { + Foreground.Padding = new MarginPadding(5); + CornerRadius = 5; + } + } + } + + private enum UserAction + { + Online, + [Description(@"Do not disturb")] + DoNotDisturb, + [Description(@"Appear offline")] + AppearOffline, + [Description(@"Sign out")] + SignOut, + } } } From efd4c574312824258a973622ec6f2105e937f952 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 24 May 2017 21:09:18 -0300 Subject: [PATCH 23/37] Dropdown actions, +User.Status, +UserStatusDoNotDisturb, properly align UserDropdownMenuItem --- .../Sections/General/LoginSettings.cs | 54 ++++++++++++++++--- osu.Game/Users/User.cs | 3 ++ osu.Game/Users/UserStatus.cs | 6 +++ 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index da07f55be0..b740aa282a 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -26,6 +26,7 @@ namespace osu.Game.Overlays.Settings.Sections.General { private bool bounding = true; private LoginForm form; + private OsuColour colours; public override RectangleF BoundingBox => bounding ? base.BoundingBox : RectangleF.Empty; @@ -48,8 +49,9 @@ namespace osu.Game.Overlays.Settings.Sections.General } [BackgroundDependencyLoader(permitNulls: true)] - private void load(APIAccess api) + private void load(OsuColour colours, APIAccess api) { + this.colours = colours; api?.Register(this); } @@ -93,6 +95,8 @@ namespace osu.Game.Overlays.Settings.Sections.General }; break; case APIState.Online: + UserDropdown dropdown; + UserPanel panel; Children = new Drawable[] { new FillFlowContainer @@ -121,17 +125,40 @@ namespace osu.Game.Overlays.Settings.Sections.General }, }, }, - new UserPanel(api.LocalUser.Value) + panel = new UserPanel(api.LocalUser.Value) { RelativeSizeAxes = Axes.X, }, - new UserDropdown + dropdown = new UserDropdown { RelativeSizeAxes = Axes.X, }, }, }, }; + panel.Status.BindTo(api.LocalUser.Value.Status); + dropdown.Current.ValueChanged += newValue => + { + switch (newValue) + { + case UserAction.Online: + api.LocalUser.Value.Status.Value = new UserStatusOnline(); + dropdown.StatusColour = colours.Green; + break; + case UserAction.DoNotDisturb: + api.LocalUser.Value.Status.Value = new UserStatusDoNotDisturb(); + dropdown.StatusColour = colours.Red; + break; + case UserAction.AppearOffline: + api.LocalUser.Value.Status.Value = new UserStatusOffline(); + dropdown.StatusColour = colours.Gray7; + break; + case UserAction.SignOut: + api.Logout(); + break; + } + }; + dropdown.Current.TriggerChange(); break; } @@ -225,6 +252,14 @@ namespace osu.Game.Overlays.Settings.Sections.General protected override Menu CreateMenu() => new UserDropdownMenu(); protected override DropdownMenuItem CreateMenuItem(string text, UserAction value) => new UserDropdownMenuItem(text, value) { AccentColour = AccentColour }; + public Color4 StatusColour + { + set + { + (Header as UserDropdownHeader).StatusColour = value; + } + } + [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -235,6 +270,14 @@ namespace osu.Game.Overlays.Settings.Sections.General { protected readonly TextAwesome statusIcon; + public Color4 StatusColour + { + set + { + statusIcon.FadeColour(value, 500, EasingTypes.OutQuint); + } + } + public UserDropdownHeader() { Foreground.Padding = new MarginPadding { Left = 10, Right = 10 }; @@ -268,8 +311,6 @@ namespace osu.Game.Overlays.Settings.Sections.General { BackgroundColour = colours.Gray3; } - - public void SetStatusColour(Color4 colour) => statusIcon.FadeColour(colour, 500, EasingTypes.OutQuint); } private class UserDropdownMenu : OsuMenu @@ -298,7 +339,8 @@ namespace osu.Game.Overlays.Settings.Sections.General { public UserDropdownMenuItem(string text, UserAction current) : base(text, current) { - Foreground.Padding = new MarginPadding(5); + //todo: Another magic number + Foreground.Padding = new MarginPadding { Top = 5, Bottom = 5, Left = 19, Right = 5 }; CornerRadius = 5; } } diff --git a/osu.Game/Users/User.cs b/osu.Game/Users/User.cs index 1361eefcff..93933c8fe9 100644 --- a/osu.Game/Users/User.cs +++ b/osu.Game/Users/User.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using Newtonsoft.Json; +using osu.Framework.Configuration; namespace osu.Game.Users { @@ -19,6 +20,8 @@ namespace osu.Game.Users [JsonProperty(@"country")] public Country Country; + public Bindable Status = new Bindable(); + //public Team Team; [JsonProperty(@"profile_colour")] diff --git a/osu.Game/Users/UserStatus.cs b/osu.Game/Users/UserStatus.cs index dcb5ccbd8f..15e6c4fb60 100644 --- a/osu.Game/Users/UserStatus.cs +++ b/osu.Game/Users/UserStatus.cs @@ -58,4 +58,10 @@ namespace osu.Game.Users public override string Message => @"Modding a map"; public override Color4 GetAppropriateColour(OsuColour colours) => colours.PurpleDark; } + + public class UserStatusDoNotDisturb : UserStatus + { + public override string Message => @"Do not disturb"; + public override Color4 GetAppropriateColour(OsuColour colours) => colours.RedDark; + } } From 9b863f60ab5e91dd366d64f4272eaeac7b29ec81 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 24 May 2017 21:32:46 -0300 Subject: [PATCH 24/37] Adjust dropdown layout --- osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index b740aa282a..435c6cf9bb 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -317,6 +317,7 @@ namespace osu.Game.Overlays.Settings.Sections.General { public UserDropdownMenu() { + Margin = new MarginPadding { Bottom = 5 }; CornerRadius = 5; ItemsContainer.Padding = new MarginPadding(0); Masking = true; From 8e09b738b0177e98a56bcdfdd373601a7c742682 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 24 May 2017 21:51:00 -0300 Subject: [PATCH 25/37] Remove magic numbers --- osu.Game/Graphics/UserInterface/OsuDropdown.cs | 6 +++--- .../Settings/Sections/General/LoginSettings.cs | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index 9d11b8074d..14483f3bfb 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -60,7 +60,7 @@ namespace osu.Game.Graphics.UserInterface AutoSizeAxes = Axes.Y, Children = new Drawable[] { - chevron = new TextAwesome + Chevron = new TextAwesome { AlwaysPresent = true, Icon = FontAwesome.fa_chevron_right, @@ -84,12 +84,12 @@ namespace osu.Game.Graphics.UserInterface private Color4? accentColour; - private readonly TextAwesome chevron; + protected readonly TextAwesome Chevron; protected override void FormatForeground(bool hover = false) { base.FormatForeground(hover); - chevron.Alpha = hover ? 1 : 0; + Chevron.Alpha = hover ? 1 : 0; } public Color4 AccentColour diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 435c6cf9bb..a4b54a52a2 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -268,6 +268,8 @@ namespace osu.Game.Overlays.Settings.Sections.General private class UserDropdownHeader : OsuDropdownHeader { + public static readonly float LABEL_LEFT_MARGIN = 20; + protected readonly TextAwesome statusIcon; public Color4 StatusColour @@ -301,9 +303,8 @@ namespace osu.Game.Overlays.Settings.Sections.General Icon = FontAwesome.fa_circle_o, TextSize = 14, }); - - //todo: Magic number - Text.Margin = new MarginPadding { Left = 20 }; + + Text.Margin = new MarginPadding { Left = LABEL_LEFT_MARGIN }; } [BackgroundDependencyLoader] @@ -340,8 +341,8 @@ namespace osu.Game.Overlays.Settings.Sections.General { public UserDropdownMenuItem(string text, UserAction current) : base(text, current) { - //todo: Another magic number - Foreground.Padding = new MarginPadding { Top = 5, Bottom = 5, Left = 19, Right = 5 }; + Foreground.Padding = new MarginPadding { Top = 5, Bottom = 5, Left = UserDropdownHeader.LABEL_LEFT_MARGIN, Right = 5 }; + Chevron.Margin = new MarginPadding { Left = 2, Right = 3 }; CornerRadius = 5; } } From 9cad34440183384270888a2767289d5d9c820a90 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 24 May 2017 22:02:32 -0300 Subject: [PATCH 26/37] Revert back header for login form, fix incorrect spacing on header --- osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index a4b54a52a2..51b95a4d8e 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -66,8 +66,8 @@ namespace osu.Game.Overlays.Settings.Sections.General { new OsuSpriteText { - Text = "LOG IN", - Margin = new MarginPadding { Bottom = 10 }, + Text = "ACCOUNT", + Margin = new MarginPadding { Bottom = 5 }, Font = @"Exo2.0-Black", }, form = new LoginForm() From ec3c92fc3c31bfd4c9764cbf05621e0fbdb1a702 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 24 May 2017 22:26:48 -0300 Subject: [PATCH 27/37] Trim whitespace --- osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs | 2 +- osu.Game/Users/UserStatus.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 51b95a4d8e..c2a4e4c833 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -303,7 +303,7 @@ namespace osu.Game.Overlays.Settings.Sections.General Icon = FontAwesome.fa_circle_o, TextSize = 14, }); - + Text.Margin = new MarginPadding { Left = LABEL_LEFT_MARGIN }; } diff --git a/osu.Game/Users/UserStatus.cs b/osu.Game/Users/UserStatus.cs index 15e6c4fb60..461008db0f 100644 --- a/osu.Game/Users/UserStatus.cs +++ b/osu.Game/Users/UserStatus.cs @@ -58,7 +58,7 @@ namespace osu.Game.Users public override string Message => @"Modding a map"; public override Color4 GetAppropriateColour(OsuColour colours) => colours.PurpleDark; } - + public class UserStatusDoNotDisturb : UserStatus { public override string Message => @"Do not disturb"; From e22eb1f20578ababb88cd4e834ab434167248fd2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 24 May 2017 22:39:07 -0300 Subject: [PATCH 28/37] CI fixes --- .../Overlays/Settings/Sections/General/LoginSettings.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index c2a4e4c833..501618be7f 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -256,7 +256,9 @@ namespace osu.Game.Overlays.Settings.Sections.General { set { - (Header as UserDropdownHeader).StatusColour = value; + var h = Header as UserDropdownHeader; + if (h == null) return; + h.StatusColour = value; } } @@ -268,10 +270,9 @@ namespace osu.Game.Overlays.Settings.Sections.General private class UserDropdownHeader : OsuDropdownHeader { - public static readonly float LABEL_LEFT_MARGIN = 20; - - protected readonly TextAwesome statusIcon; + public const float LABEL_LEFT_MARGIN = 20; + private readonly TextAwesome statusIcon; public Color4 StatusColour { set From be81346573dc4e3f6b94258c4442a42d16129458 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 25 May 2017 14:47:25 +0900 Subject: [PATCH 29/37] Attempt to fix inner scope warning --- .../Sections/General/LoginSettings.cs | 62 +++++++++---------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 501618be7f..2c92e8653e 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -95,8 +95,33 @@ namespace osu.Game.Overlays.Settings.Sections.General }; break; case APIState.Online: - UserDropdown dropdown; - UserPanel panel; + UserDropdown dropdown = new UserDropdown { RelativeSizeAxes = Axes.X }; + dropdown.Current.ValueChanged += newValue => + { + switch (newValue) + { + case UserAction.Online: + api.LocalUser.Value.Status.Value = new UserStatusOnline(); + dropdown.StatusColour = colours.Green; + break; + case UserAction.DoNotDisturb: + api.LocalUser.Value.Status.Value = new UserStatusDoNotDisturb(); + dropdown.StatusColour = colours.Red; + break; + case UserAction.AppearOffline: + api.LocalUser.Value.Status.Value = new UserStatusOffline(); + dropdown.StatusColour = colours.Gray7; + break; + case UserAction.SignOut: + api.Logout(); + break; + } + }; + dropdown.Current.TriggerChange(); + + UserPanel panel = new UserPanel(api.LocalUser.Value) { RelativeSizeAxes = Axes.X }; + panel.Status.BindTo(api.LocalUser.Value.Status); + Children = new Drawable[] { new FillFlowContainer @@ -125,40 +150,11 @@ namespace osu.Game.Overlays.Settings.Sections.General }, }, }, - panel = new UserPanel(api.LocalUser.Value) - { - RelativeSizeAxes = Axes.X, - }, - dropdown = new UserDropdown - { - RelativeSizeAxes = Axes.X, - }, + panel, + dropdown, }, }, }; - panel.Status.BindTo(api.LocalUser.Value.Status); - dropdown.Current.ValueChanged += newValue => - { - switch (newValue) - { - case UserAction.Online: - api.LocalUser.Value.Status.Value = new UserStatusOnline(); - dropdown.StatusColour = colours.Green; - break; - case UserAction.DoNotDisturb: - api.LocalUser.Value.Status.Value = new UserStatusDoNotDisturb(); - dropdown.StatusColour = colours.Red; - break; - case UserAction.AppearOffline: - api.LocalUser.Value.Status.Value = new UserStatusOffline(); - dropdown.StatusColour = colours.Gray7; - break; - case UserAction.SignOut: - api.Logout(); - break; - } - }; - dropdown.Current.TriggerChange(); break; } From d7fa6933be18d192bbaf097dfb032606ec8f719c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 25 May 2017 16:31:56 +0900 Subject: [PATCH 30/37] Fix potential nullref --- osu.Game/Users/UserPanel.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index c78a69dac8..bdfe6d1c8e 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -158,14 +158,19 @@ namespace osu.Game.Users }, }, }; - - Status.ValueChanged += displayStatus; } [BackgroundDependencyLoader] private void load(OsuColour colours) { this.colours = colours; + Status.ValueChanged += displayStatus; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + Status.TriggerChange(); } private void displayStatus(UserStatus status) From 1a255fdf4818358f2478e674601a7fe6399ddce6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 25 May 2017 19:47:18 +0900 Subject: [PATCH 31/37] Fix display order regression --- .../Sections/General/LoginSettings.cs | 59 ++++++++++--------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 2c92e8653e..d8db44607a 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -28,6 +28,9 @@ namespace osu.Game.Overlays.Settings.Sections.General private LoginForm form; private OsuColour colours; + private UserPanel panel; + private UserDropdown dropdown; + public override RectangleF BoundingBox => bounding ? base.BoundingBox : RectangleF.Empty; public bool Bounding @@ -95,33 +98,6 @@ namespace osu.Game.Overlays.Settings.Sections.General }; break; case APIState.Online: - UserDropdown dropdown = new UserDropdown { RelativeSizeAxes = Axes.X }; - dropdown.Current.ValueChanged += newValue => - { - switch (newValue) - { - case UserAction.Online: - api.LocalUser.Value.Status.Value = new UserStatusOnline(); - dropdown.StatusColour = colours.Green; - break; - case UserAction.DoNotDisturb: - api.LocalUser.Value.Status.Value = new UserStatusDoNotDisturb(); - dropdown.StatusColour = colours.Red; - break; - case UserAction.AppearOffline: - api.LocalUser.Value.Status.Value = new UserStatusOffline(); - dropdown.StatusColour = colours.Gray7; - break; - case UserAction.SignOut: - api.Logout(); - break; - } - }; - dropdown.Current.TriggerChange(); - - UserPanel panel = new UserPanel(api.LocalUser.Value) { RelativeSizeAxes = Axes.X }; - panel.Status.BindTo(api.LocalUser.Value.Status); - Children = new Drawable[] { new FillFlowContainer @@ -150,11 +126,36 @@ namespace osu.Game.Overlays.Settings.Sections.General }, }, }, - panel, - dropdown, + panel = new UserPanel(api.LocalUser.Value) { RelativeSizeAxes = Axes.X }, + dropdown = new UserDropdown { RelativeSizeAxes = Axes.X }, }, }, }; + + panel.Status.BindTo(api.LocalUser.Value.Status); + + dropdown.Current.TriggerChange(); + dropdown.Current.ValueChanged += newValue => + { + switch (newValue) + { + case UserAction.Online: + api.LocalUser.Value.Status.Value = new UserStatusOnline(); + dropdown.StatusColour = colours.Green; + break; + case UserAction.DoNotDisturb: + api.LocalUser.Value.Status.Value = new UserStatusDoNotDisturb(); + dropdown.StatusColour = colours.Red; + break; + case UserAction.AppearOffline: + api.LocalUser.Value.Status.Value = new UserStatusOffline(); + dropdown.StatusColour = colours.Gray7; + break; + case UserAction.SignOut: + api.Logout(); + break; + } + }; break; } From 97e57178a77af3fee0c8cd448df623f042115846 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 25 May 2017 21:33:04 +0900 Subject: [PATCH 32/37] Make triangles use raw vertices instead of sprites. --- osu-framework | 2 +- osu.Game/Graphics/Backgrounds/Triangles.cs | 211 ++++++++++++++++----- 2 files changed, 166 insertions(+), 47 deletions(-) diff --git a/osu-framework b/osu-framework index 777996fb97..3e989ae630 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 777996fb9731ba1895a5ab1323cbbc97259ff741 +Subproject commit 3e989ae63031a75e622225d6f4d14c6e26170b97 diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index 5cca57be8a..28e57eb470 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -5,16 +5,28 @@ using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Framework.MathUtils; using OpenTK; using OpenTK.Graphics; using System; +using System.Runtime.InteropServices; +using osu.Framework.Graphics.OpenGL; +using osu.Framework.Graphics.Shaders; +using osu.Framework.Graphics.Textures; +using osu.Framework.Graphics.OpenGL.Buffers; +using OpenTK.Graphics.ES30; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Allocation; +using System.Collections.Generic; +using osu.Framework.Graphics.Batches; namespace osu.Game.Graphics.Backgrounds { - public class Triangles : Container + public class Triangles : Drawable { + private const float triangle_size = 100; + public override bool HandleInput => false; public Color4 ColourLight = Color4.White; @@ -49,6 +61,28 @@ namespace osu.Game.Graphics.Backgrounds /// public float Velocity = 1; + private readonly List parts = new List(); + + private Shader shader; + private readonly Texture texture; + + public Triangles() + { + texture = Texture.WhitePixel; + } + + [BackgroundDependencyLoader] + private void load(ShaderManager shaders) + { + shader = shaders?.Load("Triangles", FragmentShaderDescriptor.TEXTURE_ROUNDED); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + addTriangles(true); + } + public float TriangleScale { get { return triangleScale; } @@ -57,42 +91,69 @@ namespace osu.Game.Graphics.Backgrounds float change = value / triangleScale; triangleScale = value; - if (change != 1) - Children.ForEach(t => t.Scale *= change); + for (int i = 0; i < parts.Count; i++) + { + TriangleParticle newParticle = parts[i]; + newParticle.Scale *= change; + parts[i] = newParticle; + } } } - protected override void LoadComplete() - { - base.LoadComplete(); - - addTriangles(true); - } - - private int aimTriangleCount => (int)(DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale) * SpawnRatio); - protected override void Update() { base.Update(); - float adjustedAlpha = HideAlphaDiscrepancies ? - // Cubically scale alpha to make it drop off more sharply. - (float)Math.Pow(DrawInfo.Colour.AverageColour.Linear.A, 3) : - 1; + Invalidate(Invalidation.DrawNode, shallPropagate: false); - foreach (var t in Children) + for (int i = 0; i < parts.Count; i++) { - t.Alpha = adjustedAlpha; - t.Position -= new Vector2(0, (float)(t.Scale.X * (50 / DrawHeight) * (Time.Elapsed / 950)) / triangleScale * Velocity); - if (ExpireOffScreenTriangles && t.DrawPosition.Y + t.DrawSize.Y * t.Scale.Y < 0) - t.Expire(); - } + TriangleParticle newParticle = parts[i]; - if (CreateNewTriangles) - addTriangles(false); + newParticle.Position += new Vector2(0, -(float)(parts[i].Scale * (50 / DrawHeight)) / triangleScale * Velocity) * ((float)Time.Elapsed / 950); + + float adjustedAlpha = HideAlphaDiscrepancies ? + // Cubically scale alpha to make it drop off more sharply. + (float)Math.Pow(DrawInfo.Colour.AverageColour.Linear.A, 3) : + 1; + + newParticle.Colour.A = adjustedAlpha; + + parts[i] = newParticle; + + if (!CreateNewTriangles) + continue; + + float bottomPos = parts[i].Position.Y + triangle_size * parts[i].Scale * 0.866f / DrawHeight; + + if (bottomPos < 0) + parts[i] = createTriangle(false); + } } - protected virtual Triangle CreateTriangle() + private void addTriangles(bool randomY) + { + int aimTriangleCount = (int)(DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale) * SpawnRatio); + + for (int i = 0; i < aimTriangleCount; i++) + parts.Add(createTriangle(randomY)); + } + + private TriangleParticle createTriangle(bool randomY) + { + var particle = CreateTriangle(); + + particle.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() : 1); + particle.Colour = CreateTriangleShade(); + + return particle; + } + + /// + /// Creates a triangle particle with a random scale. + /// + /// The triangle particle. + protected virtual TriangleParticle CreateTriangle() { const float std_dev = 0.16f; const float mean = 0.5f; @@ -102,32 +163,90 @@ namespace osu.Game.Graphics.Backgrounds float randStdNormal = (float)(Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2)); //random normal(0,1) var scale = Math.Max(triangleScale * (mean + std_dev * randStdNormal), 0.1f); //random normal(mean,stdDev^2) - const float size = 100; - - return new EquilateralTriangle - { - Origin = Anchor.TopCentre, - RelativePositionAxes = Axes.Both, - Size = new Vector2(size), - Scale = new Vector2(scale), - EdgeSmoothness = new Vector2(1), - Colour = GetTriangleShade(), - Depth = scale, - }; + return new TriangleParticle { Scale = scale }; } - protected virtual Color4 GetTriangleShade() => Interpolation.ValueAt(RNG.NextSingle(), ColourDark, ColourLight, 0, 1); + /// + /// Creates a shade of colour for the triangles. + /// + /// The colour. + protected virtual Color4 CreateTriangleShade() => Interpolation.ValueAt(RNG.NextSingle(), ColourDark, ColourLight, 0, 1); - private void addTriangles(bool randomY) + protected override DrawNode CreateDrawNode() => new TrianglesDrawNode(); + + private TrianglesDrawNodeSharedData sharedData = new TrianglesDrawNodeSharedData(); + protected override void ApplyDrawNode(DrawNode node) { - int addCount = aimTriangleCount - Children.Count(); - for (int i = 0; i < addCount; i++) + base.ApplyDrawNode(node); + + var trianglesNode = node as TrianglesDrawNode; + + trianglesNode.Shader = shader; + trianglesNode.Texture = texture; + trianglesNode.Size = DrawSize; + trianglesNode.Shared = sharedData; + + trianglesNode.Parts.Clear(); + trianglesNode.Parts.AddRange(parts); + } + + public class TrianglesDrawNodeSharedData + { + public LinearBatch VertexBatch = new LinearBatch(100 * 3, 10, PrimitiveType.Triangles); + } + + public class TrianglesDrawNode : DrawNode + { + public Shader Shader; + public Texture Texture; + + public float Time; + public TrianglesDrawNodeSharedData Shared; + + public readonly List Parts = new List(); + public Vector2 Size; + + public override void Draw(Action vertexAction) { - var sprite = CreateTriangle(); - float triangleHeight = sprite.DrawHeight / DrawHeight; - sprite.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() * (1 + triangleHeight) - triangleHeight : 1); - Add(sprite); + base.Draw(vertexAction); + + Shader.Bind(); + Texture.TextureGL.Bind(); + + int updateStart = -1, updateEnd = 0; + for (int i = 0; i < Parts.Count; ++i) + { + if (updateStart == -1) + updateStart = i; + updateEnd = i + 1; + + TriangleParticle particle = Parts[i]; + + Vector2 offset = new Vector2(particle.Scale * 0.5f, particle.Scale * 0.866f); + + var triangle = new Triangle( + (particle.Position * Size) * DrawInfo.Matrix, + (particle.Position * Size + offset * triangle_size) * DrawInfo.Matrix, + (particle.Position * Size + new Vector2(-offset.X, offset.Y) * triangle_size) * DrawInfo.Matrix + ); + + int index = i * 6; + + ColourInfo colourInfo = DrawInfo.Colour; + colourInfo.ApplyChild(particle.Colour); + + Texture.DrawTriangle(triangle, colourInfo, null, Shared.VertexBatch.Add); + } + + Shader.Unbind(); } } + + public struct TriangleParticle + { + public Vector2 Position; + public Color4 Colour; + public float Scale; + } } } From 86f6db2d31da91beb0734e72b46426875ae6dfc0 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 25 May 2017 21:33:49 +0900 Subject: [PATCH 33/37] Cleanup. --- osu-framework | 2 +- osu.Game/Graphics/Backgrounds/Triangles.cs | 27 ++++++---------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/osu-framework b/osu-framework index 3e989ae630..4c84c0ef14 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 3e989ae63031a75e622225d6f4d14c6e26170b97 +Subproject commit 4c84c0ef14ca1fab6098d900c036dff4c85987a5 diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index 28e57eb470..702dd7585b 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -1,19 +1,15 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Linq; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.MathUtils; using OpenTK; using OpenTK.Graphics; using System; -using System.Runtime.InteropServices; using osu.Framework.Graphics.OpenGL; using osu.Framework.Graphics.Shaders; using osu.Framework.Graphics.Textures; -using osu.Framework.Graphics.OpenGL.Buffers; using OpenTK.Graphics.ES30; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Primitives; @@ -74,7 +70,7 @@ namespace osu.Game.Graphics.Backgrounds [BackgroundDependencyLoader] private void load(ShaderManager shaders) { - shader = shaders?.Load("Triangles", FragmentShaderDescriptor.TEXTURE_ROUNDED); + shader = shaders?.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED); } protected override void LoadComplete() @@ -110,7 +106,7 @@ namespace osu.Game.Graphics.Backgrounds { TriangleParticle newParticle = parts[i]; - newParticle.Position += new Vector2(0, -(float)(parts[i].Scale * (50 / DrawHeight)) / triangleScale * Velocity) * ((float)Time.Elapsed / 950); + newParticle.Position += new Vector2(0, -(parts[i].Scale * (50 / DrawHeight)) / triangleScale * Velocity) * ((float)Time.Elapsed / 950); float adjustedAlpha = HideAlphaDiscrepancies ? // Cubically scale alpha to make it drop off more sharply. @@ -174,12 +170,12 @@ namespace osu.Game.Graphics.Backgrounds protected override DrawNode CreateDrawNode() => new TrianglesDrawNode(); - private TrianglesDrawNodeSharedData sharedData = new TrianglesDrawNodeSharedData(); + private readonly TrianglesDrawNodeSharedData sharedData = new TrianglesDrawNodeSharedData(); protected override void ApplyDrawNode(DrawNode node) { base.ApplyDrawNode(node); - var trianglesNode = node as TrianglesDrawNode; + var trianglesNode = (TrianglesDrawNode)node; trianglesNode.Shader = shader; trianglesNode.Texture = texture; @@ -213,25 +209,16 @@ namespace osu.Game.Graphics.Backgrounds Shader.Bind(); Texture.TextureGL.Bind(); - int updateStart = -1, updateEnd = 0; - for (int i = 0; i < Parts.Count; ++i) + foreach (TriangleParticle particle in Parts) { - if (updateStart == -1) - updateStart = i; - updateEnd = i + 1; - - TriangleParticle particle = Parts[i]; - - Vector2 offset = new Vector2(particle.Scale * 0.5f, particle.Scale * 0.866f); + var offset = new Vector2(particle.Scale * 0.5f, particle.Scale * 0.866f); var triangle = new Triangle( - (particle.Position * Size) * DrawInfo.Matrix, + particle.Position * Size * DrawInfo.Matrix, (particle.Position * Size + offset * triangle_size) * DrawInfo.Matrix, (particle.Position * Size + new Vector2(-offset.X, offset.Y) * triangle_size) * DrawInfo.Matrix ); - int index = i * 6; - ColourInfo colourInfo = DrawInfo.Colour; colourInfo.ApplyChild(particle.Colour); From 91dba765c2f572dcb1b5979ef8e506209441aeed Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 25 May 2017 22:03:36 +0900 Subject: [PATCH 34/37] Add back the concept of triangle ordering by size. --- osu.Game/Graphics/Backgrounds/Triangles.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index 702dd7585b..6cc7857fa9 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -16,6 +16,7 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Allocation; using System.Collections.Generic; using osu.Framework.Graphics.Batches; +using osu.Framework.Lists; namespace osu.Game.Graphics.Backgrounds { @@ -57,7 +58,7 @@ namespace osu.Game.Graphics.Backgrounds /// public float Velocity = 1; - private readonly List parts = new List(); + private readonly SortedList parts = new SortedList(Comparer.Default); private Shader shader; private readonly Texture texture; @@ -123,15 +124,17 @@ namespace osu.Game.Graphics.Backgrounds float bottomPos = parts[i].Position.Y + triangle_size * parts[i].Scale * 0.866f / DrawHeight; if (bottomPos < 0) - parts[i] = createTriangle(false); + parts.RemoveAt(i); } + + addTriangles(false); } private void addTriangles(bool randomY) { int aimTriangleCount = (int)(DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale) * SpawnRatio); - for (int i = 0; i < aimTriangleCount; i++) + for (int i = 0; i < aimTriangleCount - parts.Count; i++) parts.Add(createTriangle(randomY)); } @@ -229,11 +232,20 @@ namespace osu.Game.Graphics.Backgrounds } } - public struct TriangleParticle + public struct TriangleParticle : IComparable { public Vector2 Position; public Color4 Colour; public float Scale; + + /// + /// Compares two s. This is a reverse comparer because when the + /// triangles are added to the particles list, they should be drawn from largest to smallest + /// such that the smaller triangles appear on top. + /// + /// + /// + public int CompareTo(TriangleParticle other) => other.Scale.CompareTo(Scale); } } } From c8cf387f5ff1d6fc41d02d166ad37759bc5fffca Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 25 May 2017 22:09:02 +0900 Subject: [PATCH 35/37] A bit more cleanup. --- osu.Game/Graphics/Backgrounds/Triangles.cs | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index 6cc7857fa9..9a19819af8 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -107,13 +107,13 @@ namespace osu.Game.Graphics.Backgrounds { TriangleParticle newParticle = parts[i]; - newParticle.Position += new Vector2(0, -(parts[i].Scale * (50 / DrawHeight)) / triangleScale * Velocity) * ((float)Time.Elapsed / 950); - float adjustedAlpha = HideAlphaDiscrepancies ? // Cubically scale alpha to make it drop off more sharply. (float)Math.Pow(DrawInfo.Colour.AverageColour.Linear.A, 3) : 1; + + newParticle.Position += new Vector2(0, -(parts[i].Scale * (50 / DrawHeight)) / triangleScale * Velocity) * ((float)Time.Elapsed / 950); newParticle.Colour.A = adjustedAlpha; parts[i] = newParticle; @@ -140,7 +140,7 @@ namespace osu.Game.Graphics.Backgrounds private TriangleParticle createTriangle(bool randomY) { - var particle = CreateTriangle(); + TriangleParticle particle = CreateTriangle(); particle.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() : 1); particle.Colour = CreateTriangleShade(); @@ -189,17 +189,16 @@ namespace osu.Game.Graphics.Backgrounds trianglesNode.Parts.AddRange(parts); } - public class TrianglesDrawNodeSharedData + private class TrianglesDrawNodeSharedData { - public LinearBatch VertexBatch = new LinearBatch(100 * 3, 10, PrimitiveType.Triangles); + public readonly LinearBatch VertexBatch = new LinearBatch(100 * 3, 10, PrimitiveType.Triangles); } - public class TrianglesDrawNode : DrawNode + private class TrianglesDrawNode : DrawNode { public Shader Shader; public Texture Texture; - public float Time; public TrianglesDrawNodeSharedData Shared; public readonly List Parts = new List(); @@ -232,10 +231,21 @@ namespace osu.Game.Graphics.Backgrounds } } - public struct TriangleParticle : IComparable + protected struct TriangleParticle : IComparable { + /// + /// The position of the top vertex of the triangle. + /// public Vector2 Position; + + /// + /// The colour of the triangle. + /// public Color4 Colour; + + /// + /// The scale of the triangle. + /// public float Scale; /// From 9eec2edd30a56ed2281687a63980bf0a311b36b5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 25 May 2017 22:43:33 +0900 Subject: [PATCH 36/37] Fix initial login state not being reflected in user panel --- osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index d8db44607a..561f81d6c3 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -134,7 +134,6 @@ namespace osu.Game.Overlays.Settings.Sections.General panel.Status.BindTo(api.LocalUser.Value.Status); - dropdown.Current.TriggerChange(); dropdown.Current.ValueChanged += newValue => { switch (newValue) @@ -156,6 +155,8 @@ namespace osu.Game.Overlays.Settings.Sections.General break; } }; + dropdown.Current.TriggerChange(); + break; } From ec8f49df0fce0b4bdca9c31915a523ffb0f8dc6d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 25 May 2017 22:46:50 +0900 Subject: [PATCH 37/37] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 4c84c0ef14..8baad1b948 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 4c84c0ef14ca1fab6098d900c036dff4c85987a5 +Subproject commit 8baad1b9484b9f35724e2f965c18cfe710907d80