From d89f9590ea5d86bde2a07ebedacb107671c860e0 Mon Sep 17 00:00:00 2001 From: Naeferith Date: Sat, 4 Mar 2017 23:48:28 +0100 Subject: [PATCH 001/129] 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 002/129] 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 003/129] 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 004/129] 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 67806c4247ab83893bb14577a782a20d7f376f68 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Wed, 17 May 2017 21:16:53 +0200 Subject: [PATCH 005/129] add tab item --- osu.Game/Overlays/Chat/ChatTabControl.cs | 32 ++++++++++++++++++++++-- osu.Game/Overlays/ChatOverlay.cs | 12 +++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index 57447f1913..9f38b81e68 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Chat { public class ChatTabControl : OsuTabControl { - protected override TabItem CreateTabItem(Channel value) => new ChannelTabItem(value); + protected override TabItem CreateTabItem(Channel value) => value.Id == -1 ? new ChannelTabItem.ChannelSelectorTabItem(value) : new ChannelTabItem(value); private const float shear_width = 10; @@ -37,6 +37,11 @@ namespace osu.Game.Overlays.Chat TextSize = 20, Padding = new MarginPadding(10), }); + + AddItem(new Channel + { + Id = ChatOverlay.CHANNEL_SELECTOR_ID, + }); } private class ChannelTabItem : TabItem @@ -49,6 +54,7 @@ namespace osu.Game.Overlays.Chat private readonly SpriteText textBold; private readonly Box box; private readonly Box highlightBox; + private readonly TextAwesome icon; public override bool Active { @@ -159,7 +165,7 @@ namespace osu.Game.Overlays.Chat RelativeSizeAxes = Axes.Both, Children = new Drawable[] { - new TextAwesome + icon = new TextAwesome { Icon = FontAwesome.fa_hashtag, Anchor = Anchor.CentreLeft, @@ -191,6 +197,28 @@ namespace osu.Game.Overlays.Chat } }; } + + public class ChannelSelectorTabItem : ChannelTabItem + { + public ChannelSelectorTabItem(Channel value) : base(value) + { + Depth = float.MaxValue; + Width = 60; + + icon.Icon = FontAwesome.fa_plus; + icon.X = 0; + } + + [BackgroundDependencyLoader] + private new void load(OsuColour colour) + { + backgroundActive = colour.Green; + backgroundInactive = colour.GreenDark; + backgroundHover = colour.Green; + + updateState(); + } + } } } } diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index a85af251c5..5e998bff51 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -44,6 +44,8 @@ namespace osu.Game.Overlays public const float TAB_AREA_HEIGHT = 50; + public const int CHANNEL_SELECTOR_ID = -1; + private GetMessagesRequest fetchReq; private readonly ChatTabControl channelTabs; @@ -262,6 +264,16 @@ namespace osu.Game.Overlays { if (currentChannel == value) return; + if(value.Id == CHANNEL_SELECTOR_ID) + { + //channel selector popout + currentChannel = value; + return; + }else if(currentChannel?.Id == CHANNEL_SELECTOR_ID) + { + //channel selector popin + } + if (currentChannel != null) currentChannelContainer.Clear(false); From 0e3fb55d5e84f149489449a36f94380482d79aec Mon Sep 17 00:00:00 2001 From: Jorolf Date: Thu, 18 May 2017 17:02:11 +0200 Subject: [PATCH 006/129] usage of constant and formatting --- osu.Game/Overlays/Chat/ChatTabControl.cs | 2 +- osu.Game/Overlays/ChatOverlay.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index 9f38b81e68..62d24289b1 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Chat { public class ChatTabControl : OsuTabControl { - protected override TabItem CreateTabItem(Channel value) => value.Id == -1 ? new ChannelTabItem.ChannelSelectorTabItem(value) : new ChannelTabItem(value); + protected override TabItem CreateTabItem(Channel value) => value.Id == ChatOverlay.CHANNEL_SELECTOR_ID ? new ChannelTabItem.ChannelSelectorTabItem(value) : new ChannelTabItem(value); private const float shear_width = 10; diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 5e998bff51..57c7c2cd69 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -264,12 +264,13 @@ namespace osu.Game.Overlays { if (currentChannel == value) return; - if(value.Id == CHANNEL_SELECTOR_ID) + if (value.Id == CHANNEL_SELECTOR_ID) { //channel selector popout currentChannel = value; return; - }else if(currentChannel?.Id == CHANNEL_SELECTOR_ID) + } + else if (currentChannel?.Id == CHANNEL_SELECTOR_ID) { //channel selector popin } From 94484974f9e94066e1b6d18326cc246d7bbed58a Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 19 May 2017 11:59:23 +0200 Subject: [PATCH 007/129] use AddTabItem instead + Bindable for ChannelSelectorTabItem --- osu.Game/Overlays/Chat/ChatTabControl.cs | 27 ++++++++++++++++++------ osu.Game/Overlays/ChatOverlay.cs | 13 +----------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index 62d24289b1..800ed96025 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -14,15 +14,20 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Online.Chat; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Configuration; namespace osu.Game.Overlays.Chat { public class ChatTabControl : OsuTabControl { - protected override TabItem CreateTabItem(Channel value) => value.Id == ChatOverlay.CHANNEL_SELECTOR_ID ? new ChannelTabItem.ChannelSelectorTabItem(value) : new ChannelTabItem(value); + protected override TabItem CreateTabItem(Channel value) => new ChannelTabItem(value); private const float shear_width = 10; + private Bindable channelSelectorActive = new Bindable(); + + public Bindable ChannelSelectorActive => channelSelectorActive; + public ChatTabControl() { TabContainer.Margin = new MarginPadding { Left = 50 }; @@ -38,10 +43,7 @@ namespace osu.Game.Overlays.Chat Padding = new MarginPadding(10), }); - AddItem(new Channel - { - Id = ChatOverlay.CHANNEL_SELECTOR_ID, - }); + AddTabItem(new ChannelTabItem.ChannelSelectorTabItem(new Channel(), channelSelectorActive)); } private class ChannelTabItem : TabItem @@ -200,8 +202,21 @@ namespace osu.Game.Overlays.Chat public class ChannelSelectorTabItem : ChannelTabItem { - public ChannelSelectorTabItem(Channel value) : base(value) + public override bool Active { + get { return base.Active; } + set + { + activeBindable.Value = value; + base.Active = value; + } + } + + private Bindable activeBindable; + + public ChannelSelectorTabItem(Channel value, Bindable active) : base(value) + { + activeBindable = active; Depth = float.MaxValue; Width = 60; diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 57c7c2cd69..6c8c176861 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -44,8 +44,6 @@ namespace osu.Game.Overlays public const float TAB_AREA_HEIGHT = 50; - public const int CHANNEL_SELECTOR_ID = -1; - private GetMessagesRequest fetchReq; private readonly ChatTabControl channelTabs; @@ -264,16 +262,7 @@ namespace osu.Game.Overlays { if (currentChannel == value) return; - if (value.Id == CHANNEL_SELECTOR_ID) - { - //channel selector popout - currentChannel = value; - return; - } - else if (currentChannel?.Id == CHANNEL_SELECTOR_ID) - { - //channel selector popin - } + if (channelTabs.ChannelSelectorActive) return; if (currentChannel != null) currentChannelContainer.Clear(false); From bc980b60ac1d762b593f0e14daaf352b58ec1b0b Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sun, 21 May 2017 22:36:46 -0300 Subject: [PATCH 008/129] 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 009/129] 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 012/129] 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 013/129] 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 014/129] 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 015/129] 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 016/129] 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 017/129] 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 018/129] 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 019/129] 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 020/129] 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 021/129] 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 7d28290a4a26b3fe2521c801374a797cc7176717 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 23 May 2017 17:35:40 +0200 Subject: [PATCH 022/129] update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 42e26d49b9..79b335e9d4 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 42e26d49b9046fcb96c123b0dfb48e06d741e162 +Subproject commit 79b335e9d4d6f8ff89524f06dbe324db3cf29513 From 320e7b358ee9e1dc95a66ed34e9531b6b8c94af9 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 23 May 2017 17:50:28 +0200 Subject: [PATCH 023/129] revert framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 79b335e9d4..89f8468e02 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 79b335e9d4d6f8ff89524f06dbe324db3cf29513 +Subproject commit 89f8468e02187aab5ad0625503252b488a1d571c From af9b02746ad86d15f5e2a2f14a267358a9a4683c Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 23 May 2017 18:19:01 +0200 Subject: [PATCH 024/129] make fields readonly --- osu.Game/Overlays/Chat/ChatTabControl.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index 800ed96025..875c7c411d 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -24,7 +24,7 @@ namespace osu.Game.Overlays.Chat private const float shear_width = 10; - private Bindable channelSelectorActive = new Bindable(); + private readonly Bindable channelSelectorActive = new Bindable(); public Bindable ChannelSelectorActive => channelSelectorActive; @@ -212,7 +212,7 @@ namespace osu.Game.Overlays.Chat } } - private Bindable activeBindable; + private readonly Bindable activeBindable; public ChannelSelectorTabItem(Channel value, Bindable active) : base(value) { From dcf879687d30fba36c5e7a1f19213ed63e84de27 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 24 May 2017 20:45:01 +0900 Subject: [PATCH 025/129] Implement basic hold note + tick input. --- .../Tests/TestCaseManiaPlayfield.cs | 47 +++++ .../Legacy/DistanceObjectPatternGenerator.cs | 9 +- .../Legacy/EndTimeObjectPatternGenerator.cs | 9 +- .../Judgements/HoldNoteTailJudgement.cs | 13 ++ .../Judgements/HoldNoteTickJudgement.cs | 9 + .../Objects/Drawables/DrawableHoldNote.cs | 198 ++++++++++++++++-- .../Objects/Drawables/DrawableHoldNoteTick.cs | 75 +++++++ osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 42 ++-- .../Objects/HoldNoteTail.cs | 24 +++ .../Objects/HoldNoteTick.cs | 9 + .../osu.Game.Rulesets.Mania.csproj | 5 + 11 files changed, 406 insertions(+), 34 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/Judgements/HoldNoteTailJudgement.cs create mode 100644 osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/HoldNoteTail.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 9dcba02849..27ad39fb1e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -11,6 +11,9 @@ using OpenTK; using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Timing; +using osu.Framework.Configuration; +using OpenTK.Input; +using osu.Framework.Timing; namespace osu.Desktop.VisualTests.Tests { @@ -59,6 +62,48 @@ namespace osu.Desktop.VisualTests.Tests } }; + Action createPlayfieldWithNotesAcceptingInput = () => + { + Clear(); + + var rateAdjustClock = new StopwatchClock(true) { Rate = 0.2 }; + + ManiaPlayfield playField; + Add(playField = new ManiaPlayfield(4, new List { new TimingChange { BeatLength = 200 } }) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Scale = new Vector2(1, -1), + Clock = new FramedClock(rateAdjustClock) + }); + + playField.Add(new DrawableNote(new Note + { + StartTime = 1000, + Column = 0 + }, new Bindable(Key.D))); + + playField.Add(new DrawableHoldNote(new HoldNote + { + StartTime = 1000, + Duration = 2000, + Column = 1 + }, new Bindable(Key.F))); + + playField.Add(new DrawableHoldNote(new HoldNote + { + StartTime = 1000, + Duration = 2000, + Column = 2 + }, new Bindable(Key.J))); + + playField.Add(new DrawableNote(new Note + { + StartTime = 1000, + Column = 3 + }, new Bindable(Key.K))); + }; + AddStep("1 column", () => createPlayfield(1, SpecialColumnPosition.Normal)); AddStep("4 columns", () => createPlayfield(4, SpecialColumnPosition.Normal)); AddStep("Left special style", () => createPlayfield(4, SpecialColumnPosition.Left)); @@ -76,6 +121,8 @@ namespace osu.Desktop.VisualTests.Tests AddWaitStep(10); AddStep("Right special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Right)); AddWaitStep(10); + + AddStep("Test", () => createPlayfieldWithNotesAcceptingInput()); } private void triggerKeyDown(Column column) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 718e0967da..279ac868f1 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -471,14 +471,17 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy } else { - newObject = new HoldNote + var holdNote = new HoldNote { StartTime = startTime, - Samples = sampleInfoListAt(startTime), - EndSamples = sampleInfoListAt(endTime), Column = column, Duration = endTime - startTime }; + + holdNote.HeadNote.Samples = sampleInfoListAt(startTime); + holdNote.TailNote.Samples = sampleInfoListAt(endTime); + + newObject = holdNote; } pattern.Add(newObject); diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs index 8f438f9ff4..ddc7d77c0c 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs @@ -69,18 +69,21 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy if (holdNote) { - newObject = new HoldNote + var hold = new HoldNote { StartTime = HitObject.StartTime, - EndSamples = HitObject.Samples, Column = column, Duration = endTime - HitObject.StartTime }; - newObject.Samples.Add(new SampleInfo + hold.HeadNote.Samples.Add(new SampleInfo { Name = SampleInfo.HIT_NORMAL }); + + hold.TailNote.Samples = HitObject.Samples; + + newObject = hold; } else { diff --git a/osu.Game.Rulesets.Mania/Judgements/HoldNoteTailJudgement.cs b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTailJudgement.cs new file mode 100644 index 0000000000..df2f7e9e63 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTailJudgement.cs @@ -0,0 +1,13 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Rulesets.Mania.Judgements +{ + public class HoldNoteTailJudgement : ManiaJudgement + { + /// + /// Whether the hold note has been released too early and shouldn't give full score for the release. + /// + public bool HasBroken; + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs new file mode 100644 index 0000000000..bead455c13 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs @@ -0,0 +1,9 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Rulesets.Mania.Judgements +{ + public class HoldNoteTickJudgement : ManiaJudgement + { + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index f9d027e7ce..a8efe5d2f8 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -7,14 +7,47 @@ using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using OpenTK.Graphics; using osu.Framework.Configuration; using OpenTK.Input; +using osu.Framework.Input; +using OpenTK; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Mania.Judgements; namespace osu.Game.Rulesets.Mania.Objects.Drawables { public class DrawableHoldNote : DrawableManiaHitObject { - private readonly NotePiece headPiece; + private readonly DrawableNote headNote; + private readonly DrawableNote tailNote; private readonly BodyPiece bodyPiece; - private readonly NotePiece tailPiece; + private readonly Container tickContainer; + + /// + /// Relative time at which the user started holding this note. + /// + private double holdStartTime; + + /// + /// Whether the hold note has been released too early and shouldn't give full score for the release. + /// + private bool hasBroken; + + private bool _holding; + /// + /// Whether the user is holding the hold note. + /// + private bool holding + { + get { return _holding; } + set + { + if (_holding == value) + return; + _holding = value; + + if (holding) + holdStartTime = Time.Current; + } + } public DrawableHoldNote(HoldNote hitObject, Bindable key = null) : base(hitObject, key) @@ -32,17 +65,39 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, - headPiece = new NotePiece + tickContainer = new Container + { + RelativeSizeAxes = Axes.Both, + RelativeCoordinateSpace = new Vector2(1, (float)HitObject.Duration) + }, + headNote = new DrawableHoldNoteHead(this, key) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre }, - tailPiece = new NotePiece + tailNote = new DrawableHoldNoteTail(this, key) { Anchor = Anchor.BottomCentre, Origin = Anchor.TopCentre } }); + + foreach (var tick in HitObject.Ticks) + { + var drawableTick = new DrawableHoldNoteTick(tick) + { + IsHolding = () => holding, + HoldStartTime = () => holdStartTime + }; + + drawableTick.Y -= (float)HitObject.StartTime; + + tickContainer.Add(drawableTick); + AddNested(drawableTick); + } + + AddNested(headNote); + AddNested(tailNote); } public override Color4 AccentColour @@ -54,9 +109,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables return; base.AccentColour = value; - headPiece.AccentColour = value; bodyPiece.AccentColour = value; - tailPiece.AccentColour = value; + headNote.AccentColour = value; + tailNote.AccentColour = value; } } @@ -64,14 +119,133 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { } - protected override void Update() + /// + /// Handles key down events on the body of the hold note. + /// + /// The input state. + /// The key down args. + /// Whether the key press was handled. + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { - if (Time.Current > HitObject.StartTime) - headPiece.Colour = Color4.Green; - if (Time.Current > HitObject.EndTime) + // Make sure the keypress happened within reasonable bounds of the hold note + if (Time.Current < HitObject.StartTime || Time.Current > HitObject.EndTime) + return false; + + if (args.Key != Key) + return false; + + if (args.Repeat) + return false; + + holding = true; + + return true; + } + + /// + /// Handles key up events on the body of the hold note. + /// + /// The input state. + /// The key down args. + /// Whether the key press was handled. + protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) + { + // Make sure that the user started holding the key during the hold note + if (!holding) + return false; + + if (args.Key != Key) + return false; + + holding = false; + + // If the key has been released too early, they should not receive full score for the release + if (!tailNote.Judged) + hasBroken = true; + + return true; + } + + private class DrawableHoldNoteHead : DrawableNote + { + private readonly DrawableHoldNote holdNote; + + public DrawableHoldNoteHead(DrawableHoldNote holdNote, Bindable key = null) + : base(holdNote.HitObject.HeadNote, key) { - bodyPiece.Colour = Color4.Green; - tailPiece.Colour = Color4.Green; + this.holdNote = holdNote; + + RelativePositionAxes = Axes.None; + Y = 0; + } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (!base.OnKeyDown(state, args)) + return false; + + // We only want to trigger a holding state from the head if the head has received a judgement + if (Judgement.Result == HitResult.None) + return false; + + // If the head has been missed, make sure the user also can't receive a full score for the release + if (Judgement.Result == HitResult.Miss) + holdNote.hasBroken = true; + + holdNote.holding = true; + + return true; + } + } + + private class DrawableHoldNoteTail : DrawableNote + { + private readonly DrawableHoldNote holdNote; + + public DrawableHoldNoteTail(DrawableHoldNote holdNote, Bindable key = null) + : base(holdNote.HitObject.TailNote, key) + { + this.holdNote = holdNote; + + RelativePositionAxes = Axes.None; + Y = 0; + } + + protected override ManiaJudgement CreateJudgement() => new HoldNoteTailJudgement(); + + protected override void CheckJudgement(bool userTriggered) + { + base.CheckJudgement(userTriggered); + + var tailJudgement = Judgement as HoldNoteTailJudgement; + if (tailJudgement == null) + return; + + tailJudgement.HasBroken = holdNote.hasBroken; + } + + protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) + { + // Make sure that the user started holding the key during the hold note + if (!holdNote.holding) + return false; + + if (Judgement.Result != HitResult.None) + return false; + + if (args.Key != Key) + return false; + + UpdateJudgement(true); + + // Handled by the hold note, which will set holding = false + return false; + } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + // Tail doesn't handle key down + return false; } } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs new file mode 100644 index 0000000000..13fde29bc2 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs @@ -0,0 +1,75 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using OpenTK.Graphics; +using OpenTK.Input; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; +using osu.Game.Rulesets.Mania.Judgements; +using osu.Game.Rulesets.Objects.Drawables; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + public class DrawableHoldNoteTick : DrawableManiaHitObject + { + public Func HoldStartTime; + public Func IsHolding; + + public DrawableHoldNoteTick(HoldNoteTick hitObject) + : base(hitObject, null) + { + RelativeSizeAxes = Axes.X; + + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.X, + Height = 1 + } + }; + } + + protected override ManiaJudgement CreateJudgement() => new HoldNoteTickJudgement(); + + protected override void CheckJudgement(bool userTriggered) + { + if (!userTriggered) + return; + + if (Time.Current < HitObject.StartTime) + return; + + + if (HoldStartTime?.Invoke() > HitObject.StartTime) + return; + + Judgement.ManiaResult = ManiaHitResult.Perfect; + Judgement.Result = HitResult.Hit; + } + + protected override void UpdateState(ArmedState state) + { + switch (State) + { + case ArmedState.Hit: + Colour = Color4.Green; + break; + } + } + + protected override void Update() + { + if (Judgement.Result != HitResult.None) + return; + + if (IsHolding?.Invoke() != true) + return; + + UpdateJudgement(true); + } + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index 30e71aeb5d..926f434015 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Collections.Generic; using osu.Game.Audio; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Database; @@ -12,32 +13,41 @@ namespace osu.Game.Rulesets.Mania.Objects /// /// Represents a hit object which requires pressing, holding, and releasing a key. /// - public class HoldNote : Note, IHasEndTime + public class HoldNote : ManiaHitObject, IHasEndTime { - /// - /// Lenience of release hit windows. This is to make cases where the hold note release - /// is timed alongside presses of other hit objects less awkward. - /// - private const double release_window_lenience = 1.5; - public double Duration { get; set; } public double EndTime => StartTime + Duration; - /// - /// The samples to be played when this hold note is released. - /// - public SampleInfoList EndSamples = new SampleInfoList(); + private Note headNote; + public Note HeadNote => headNote ?? (headNote = new Note { StartTime = StartTime }); + + private Note tailNote; + public Note TailNote => tailNote ?? (tailNote = new HoldNoteTail { StartTime = EndTime }); /// - /// The key-release hit windows for this hold note. + /// The length (in milliseconds) between ticks of this hold. /// - public HitWindows ReleaseHitWindows { get; protected set; } = new HitWindows(); + private double tickSpacing = 50; - public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) + public IEnumerable Ticks => ticks ?? (ticks = createTicks()); + private List ticks; + + private List createTicks() { - base.ApplyDefaults(controlPointInfo, difficulty); + var ret = new List(); - ReleaseHitWindows = HitWindows * release_window_lenience; + if (tickSpacing == 0) + return ret; + + for (double t = StartTime + HeadNote.HitWindows.Great / 2; t <= EndTime - TailNote.HitWindows.Great / 2; t+= tickSpacing) + { + ret.Add(new HoldNoteTick + { + StartTime = t + }); + } + + return ret; } } } diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNoteTail.cs b/osu.Game.Rulesets.Mania/Objects/HoldNoteTail.cs new file mode 100644 index 0000000000..6399277a2b --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/HoldNoteTail.cs @@ -0,0 +1,24 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Database; + +namespace osu.Game.Rulesets.Mania.Objects +{ + public class HoldNoteTail : Note + { + /// + /// Lenience of release hit windows. This is to make cases where the hold note release + /// is timed alongside presses of other hit objects less awkward. + /// + private const double release_window_lenience = 1.5; + + public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) + { + base.ApplyDefaults(controlPointInfo, difficulty); + + HitWindows *= release_window_lenience; + } + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs new file mode 100644 index 0000000000..805b2a0938 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs @@ -0,0 +1,9 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Rulesets.Mania.Objects +{ + public class HoldNoteTick : ManiaHitObject + { + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 9442d7cf8f..91cb551414 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -57,10 +57,13 @@ + + + @@ -68,6 +71,8 @@ + + From 78067e085c858f8e6d8ab70ac9bf2699a3d0e3ca Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 24 May 2017 20:53:47 +0900 Subject: [PATCH 026/129] Fix note input ordering. --- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index ff763f87c4..495959b061 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -189,7 +189,12 @@ namespace osu.Game.Rulesets.Mania.UI } } - public override void Add(DrawableHitObject h) => Columns.ElementAt(h.HitObject.Column).Add(h); + public override void Add(DrawableHitObject h) + { + h.Depth = (float)h.HitObject.StartTime; + + Columns.ElementAt(h.HitObject.Column).Add(h); + } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { From 4ef18ff135fd91e3e40274f507a545f438bfa590 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 24 May 2017 20:54:01 +0900 Subject: [PATCH 027/129] Test case improvements. --- .../Tests/TestCaseManiaPlayfield.cs | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 27ad39fb1e..8d0a87ae9d 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -77,31 +77,34 @@ namespace osu.Desktop.VisualTests.Tests Clock = new FramedClock(rateAdjustClock) }); - playField.Add(new DrawableNote(new Note + for (int t = 1000; t <= 2000; t += 100) { - StartTime = 1000, - Column = 0 - }, new Bindable(Key.D))); + playField.Add(new DrawableNote(new Note + { + StartTime = t, + Column = 0 + }, new Bindable(Key.J))); + + playField.Add(new DrawableNote(new Note + { + StartTime = t, + Column = 3 + }, new Bindable(Key.K))); + } playField.Add(new DrawableHoldNote(new HoldNote { StartTime = 1000, - Duration = 2000, + Duration = 1000, Column = 1 }, new Bindable(Key.F))); playField.Add(new DrawableHoldNote(new HoldNote { StartTime = 1000, - Duration = 2000, + Duration = 1000, Column = 2 }, new Bindable(Key.J))); - - playField.Add(new DrawableNote(new Note - { - StartTime = 1000, - Column = 3 - }, new Bindable(Key.K))); }; AddStep("1 column", () => createPlayfield(1, SpecialColumnPosition.Normal)); From 0dbb2220e090f5c59723f25c275c23939a047ba6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 24 May 2017 21:07:12 +0900 Subject: [PATCH 028/129] 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 d6b104d794d2fdebcd46949115c581f1b8d7565e Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 24 May 2017 21:24:18 +0900 Subject: [PATCH 029/129] Minor visual change for DrawableHoldNoteTick. --- .../Objects/Drawables/DrawableHoldNote.cs | 3 ++ .../Objects/Drawables/DrawableHoldNoteTick.cs | 50 ++++++++++++++++--- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index a8efe5d2f8..ee371b61ca 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -11,6 +11,7 @@ using osu.Framework.Input; using OpenTK; using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Mania.Judgements; +using osu.Framework.Extensions.IEnumerableExtensions; namespace osu.Game.Rulesets.Mania.Objects.Drawables { @@ -109,6 +110,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables return; base.AccentColour = value; + tickContainer.Children.ForEach(t => t.AccentColour = value); + bodyPiece.AccentColour = value; headNote.AccentColour = value; tailNote.AccentColour = value; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs index 13fde29bc2..7a8f25e098 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs @@ -2,12 +2,12 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using OpenTK; using OpenTK.Graphics; -using OpenTK.Input; -using osu.Framework.Configuration; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Input; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Objects.Drawables; @@ -18,19 +18,55 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public Func HoldStartTime; public Func IsHolding; + private readonly Container glowContainer; + public DrawableHoldNoteTick(HoldNoteTick hitObject) : base(hitObject, null) { + Anchor = Anchor.TopCentre; + Origin = Anchor.TopCentre; + RelativeSizeAxes = Axes.X; + Size = new Vector2(1); Children = new[] { - new Box + glowContainer = new CircularContainer { - RelativeSizeAxes = Axes.X, - Height = 1 + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.Both, + Masking = true, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0, + AlwaysPresent = true + } + } } }; + + AccentColour = Color4.White; + } + + public override Color4 AccentColour + { + get { return base.AccentColour; } + set + { + base.AccentColour = value; + + glowContainer.EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Radius = 2f, + Roundness = 15f, + Colour = value.Opacity(0.3f) + }; + } } protected override ManiaJudgement CreateJudgement() => new HoldNoteTickJudgement(); @@ -56,7 +92,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables switch (State) { case ArmedState.Hit: - Colour = Color4.Green; + AccentColour = Color4.Green; break; } } From 21cdee02f3cfce00771a10bc3ee89ef7421fbbd2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 24 May 2017 21:24:33 +0900 Subject: [PATCH 030/129] Get tickSpacing from beatmap. --- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index 926f434015..b3e2482908 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -2,10 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; -using osu.Game.Audio; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Database; -using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Objects.Types; namespace osu.Game.Rulesets.Mania.Objects @@ -29,6 +27,14 @@ namespace osu.Game.Rulesets.Mania.Objects /// private double tickSpacing = 50; + public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) + { + base.ApplyDefaults(controlPointInfo, difficulty); + + TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); + tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate; + } + public IEnumerable Ticks => ticks ?? (ticks = createTicks()); private List ticks; From ed65b3559a72b27dc904268f36643d68a589983c Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 24 May 2017 21:25:01 +0900 Subject: [PATCH 031/129] CI fix. --- .../Objects/Drawables/DrawableHoldNoteTick.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs index 7a8f25e098..7c84157c26 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private readonly Container glowContainer; public DrawableHoldNoteTick(HoldNoteTick hitObject) - : base(hitObject, null) + : base(hitObject) { Anchor = Anchor.TopCentre; Origin = Anchor.TopCentre; From a5b79b2192b5d34fb8f1d69363fe03495dcd77a9 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 24 May 2017 21:56:49 +0900 Subject: [PATCH 032/129] Fix notes not getting accent colours. --- osu.Game.Rulesets.Mania/UI/Column.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index c8cb5f6387..6dfd5000d4 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -1,7 +1,6 @@ // 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 OpenTK.Input; @@ -188,7 +187,11 @@ namespace osu.Game.Rulesets.Mania.UI } } - public void Add(DrawableHitObject hitObject) => ControlPointContainer.Add(hitObject); + public void Add(DrawableHitObject hitObject) + { + hitObject.AccentColour = AccentColour; + ControlPointContainer.Add(hitObject); + } private bool onKeyDown(InputState state, KeyDownEventArgs args) { From 946cd4bfa380ca4a3684f1375f11ee94d708ef1c Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 24 May 2017 21:57:38 +0900 Subject: [PATCH 033/129] General cleanup + more xmldocs. --- .../Tests/TestCaseManiaPlayfield.cs | 6 +-- .../Legacy/DistanceObjectPatternGenerator.cs | 4 +- .../Legacy/EndTimeObjectPatternGenerator.cs | 4 +- .../Objects/Drawables/DrawableHoldNote.cs | 45 ++++++++++++------- .../Objects/Drawables/DrawableHoldNoteTick.cs | 11 +++++ .../Objects/Drawables/DrawableNote.cs | 3 ++ osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 40 ++++++++++++++--- .../Objects/HoldNoteTail.cs | 24 ---------- .../Objects/HoldNoteTick.cs | 3 ++ .../osu.Game.Rulesets.Mania.csproj | 1 - 10 files changed, 86 insertions(+), 55 deletions(-) delete mode 100644 osu.Game.Rulesets.Mania/Objects/HoldNoteTail.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 8d0a87ae9d..857c2c0ca7 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -66,7 +66,7 @@ namespace osu.Desktop.VisualTests.Tests { Clear(); - var rateAdjustClock = new StopwatchClock(true) { Rate = 0.2 }; + var rateAdjustClock = new StopwatchClock(true) { Rate = 0.5 }; ManiaPlayfield playField; Add(playField = new ManiaPlayfield(4, new List { new TimingChange { BeatLength = 200 } }) @@ -83,7 +83,7 @@ namespace osu.Desktop.VisualTests.Tests { StartTime = t, Column = 0 - }, new Bindable(Key.J))); + }, new Bindable(Key.D))); playField.Add(new DrawableNote(new Note { @@ -125,7 +125,7 @@ namespace osu.Desktop.VisualTests.Tests AddStep("Right special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Right)); AddWaitStep(10); - AddStep("Test", () => createPlayfieldWithNotesAcceptingInput()); + AddStep("Notes with input", () => createPlayfieldWithNotesAcceptingInput()); } private void triggerKeyDown(Column column) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 279ac868f1..076bcdfaab 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -478,8 +478,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy Duration = endTime - startTime }; - holdNote.HeadNote.Samples = sampleInfoListAt(startTime); - holdNote.TailNote.Samples = sampleInfoListAt(endTime); + holdNote.Head.Samples = sampleInfoListAt(startTime); + holdNote.Tail.Samples = sampleInfoListAt(endTime); newObject = holdNote; } diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs index ddc7d77c0c..6ad7489e0f 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs @@ -76,12 +76,12 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy Duration = endTime - HitObject.StartTime }; - hold.HeadNote.Samples.Add(new SampleInfo + hold.Head.Samples.Add(new SampleInfo { Name = SampleInfo.HIT_NORMAL }); - hold.TailNote.Samples = HitObject.Samples; + hold.Tail.Samples = HitObject.Samples; newObject = hold; } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index ee371b61ca..cef4eecd38 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -15,15 +15,19 @@ using osu.Framework.Extensions.IEnumerableExtensions; namespace osu.Game.Rulesets.Mania.Objects.Drawables { + /// + /// Visualises a hit object. + /// public class DrawableHoldNote : DrawableManiaHitObject { - private readonly DrawableNote headNote; - private readonly DrawableNote tailNote; + private readonly DrawableNote head; + private readonly DrawableNote tail; + private readonly BodyPiece bodyPiece; private readonly Container tickContainer; /// - /// Relative time at which the user started holding this note. + /// Time at which the user started holding this hold note. /// private double holdStartTime; @@ -34,7 +38,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private bool _holding; /// - /// Whether the user is holding the hold note. + /// Whether the user is currently holding the hold note. /// private bool holding { @@ -71,12 +75,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables RelativeSizeAxes = Axes.Both, RelativeCoordinateSpace = new Vector2(1, (float)HitObject.Duration) }, - headNote = new DrawableHoldNoteHead(this, key) + head = new HeadNote(this, key) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre }, - tailNote = new DrawableHoldNoteTail(this, key) + tail = new TailNote(this, key) { Anchor = Anchor.BottomCentre, Origin = Anchor.TopCentre @@ -91,14 +95,15 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables HoldStartTime = () => holdStartTime }; + // To make the ticks relative to ourselves we need to offset them backwards drawableTick.Y -= (float)HitObject.StartTime; tickContainer.Add(drawableTick); AddNested(drawableTick); } - AddNested(headNote); - AddNested(tailNote); + AddNested(head); + AddNested(tail); } public override Color4 AccentColour @@ -113,8 +118,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables tickContainer.Children.ForEach(t => t.AccentColour = value); bodyPiece.AccentColour = value; - headNote.AccentColour = value; - tailNote.AccentColour = value; + head.AccentColour = value; + tail.AccentColour = value; } } @@ -163,18 +168,21 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables holding = false; // If the key has been released too early, they should not receive full score for the release - if (!tailNote.Judged) + if (!tail.Judged) hasBroken = true; return true; } - private class DrawableHoldNoteHead : DrawableNote + /// + /// The head note of a hold. + /// + private class HeadNote : DrawableNote { private readonly DrawableHoldNote holdNote; - public DrawableHoldNoteHead(DrawableHoldNote holdNote, Bindable key = null) - : base(holdNote.HitObject.HeadNote, key) + public HeadNote(DrawableHoldNote holdNote, Bindable key = null) + : base(holdNote.HitObject.Head, key) { this.holdNote = holdNote; @@ -201,12 +209,15 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables } } - private class DrawableHoldNoteTail : DrawableNote + /// + /// The tail note of a hold. + /// + private class TailNote : DrawableNote { private readonly DrawableHoldNote holdNote; - public DrawableHoldNoteTail(DrawableHoldNote holdNote, Bindable key = null) - : base(holdNote.HitObject.TailNote, key) + public TailNote(DrawableHoldNote holdNote, Bindable key = null) + : base(holdNote.HitObject.Tail, key) { this.holdNote = holdNote; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs index 7c84157c26..8cd60e9901 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs @@ -13,9 +13,19 @@ using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Mania.Objects.Drawables { + /// + /// Visualises a hit object. + /// public class DrawableHoldNoteTick : DrawableManiaHitObject { + /// + /// References the time at which the user started holding the hold note. + /// public Func HoldStartTime; + + /// + /// References whether the user is currently holding the hold note. + /// public Func IsHolding; private readonly Container glowContainer; @@ -49,6 +59,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables } }; + // Set the default glow AccentColour = Color4.White; } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 42bb371975..658d409bb8 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -13,6 +13,9 @@ using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Mania.Objects.Drawables { + /// + /// Visualises a hit object. + /// public class DrawableNote : DrawableManiaHitObject { private readonly NotePiece headPiece; diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index b3e2482908..db317ddf7b 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -16,14 +16,20 @@ namespace osu.Game.Rulesets.Mania.Objects public double Duration { get; set; } public double EndTime => StartTime + Duration; - private Note headNote; - public Note HeadNote => headNote ?? (headNote = new Note { StartTime = StartTime }); + private Note head; + /// + /// The head note of the hold. + /// + public Note Head => head ?? (head = new Note { StartTime = StartTime }); - private Note tailNote; - public Note TailNote => tailNote ?? (tailNote = new HoldNoteTail { StartTime = EndTime }); + private Note tail; + /// + /// The tail note of the hold. + /// + public Note Tail => tail ?? (tail = new TailNote { StartTime = EndTime }); /// - /// The length (in milliseconds) between ticks of this hold. + /// The time between ticks of this hold. /// private double tickSpacing = 50; @@ -35,6 +41,9 @@ namespace osu.Game.Rulesets.Mania.Objects tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate; } + /// + /// The scoring scoring ticks of the hold note. + /// public IEnumerable Ticks => ticks ?? (ticks = createTicks()); private List ticks; @@ -45,7 +54,7 @@ namespace osu.Game.Rulesets.Mania.Objects if (tickSpacing == 0) return ret; - for (double t = StartTime + HeadNote.HitWindows.Great / 2; t <= EndTime - TailNote.HitWindows.Great / 2; t+= tickSpacing) + for (double t = StartTime + Head.HitWindows.Great / 2; t <= EndTime - Tail.HitWindows.Great / 2; t+= tickSpacing) { ret.Add(new HoldNoteTick { @@ -55,5 +64,24 @@ namespace osu.Game.Rulesets.Mania.Objects return ret; } + + /// + /// The tail of the hold note. + /// + private class TailNote : Note + { + /// + /// Lenience of release hit windows. This is to make cases where the hold note release + /// is timed alongside presses of other hit objects less awkward. + /// + private const double release_window_lenience = 1.5; + + public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) + { + base.ApplyDefaults(controlPointInfo, difficulty); + + HitWindows *= release_window_lenience; + } + } } } diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNoteTail.cs b/osu.Game.Rulesets.Mania/Objects/HoldNoteTail.cs deleted file mode 100644 index 6399277a2b..0000000000 --- a/osu.Game.Rulesets.Mania/Objects/HoldNoteTail.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Game.Beatmaps.ControlPoints; -using osu.Game.Database; - -namespace osu.Game.Rulesets.Mania.Objects -{ - public class HoldNoteTail : Note - { - /// - /// Lenience of release hit windows. This is to make cases where the hold note release - /// is timed alongside presses of other hit objects less awkward. - /// - private const double release_window_lenience = 1.5; - - public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) - { - base.ApplyDefaults(controlPointInfo, difficulty); - - HitWindows *= release_window_lenience; - } - } -} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs index 805b2a0938..6c4cf127f3 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs @@ -3,6 +3,9 @@ namespace osu.Game.Rulesets.Mania.Objects { + /// + /// A scoring tick of a hold note. + /// public class HoldNoteTick : ManiaHitObject { } diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 91cb551414..7a8ec25fe4 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -71,7 +71,6 @@ - From 181648515b433c56006d1a8d9b2685e20c08fa63 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 24 May 2017 16:05:24 +0300 Subject: [PATCH 034/129] Moving icon to the beat on the TwoLayerButton --- .../Graphics/UserInterface/TwoLayerButton.cs | 118 +++++++++++------- 1 file changed, 71 insertions(+), 47 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index 237aaa44a6..4aeaf6965d 100644 --- a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs +++ b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs @@ -5,18 +5,21 @@ using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Transforms; using osu.Framework.Input; using OpenTK; using OpenTK.Graphics; using osu.Game.Graphics.Sprites; using osu.Framework.Extensions.Color4Extensions; +using osu.Game.Graphics.Containers; +using osu.Game.Beatmaps.ControlPoints; +using osu.Framework.Audio.Track; +using System; namespace osu.Game.Graphics.UserInterface { public class TwoLayerButton : ClickableContainer { - private readonly TextAwesome icon; + private readonly IconBeatSyncedContainer iconBeatSyncedContainer; public Box IconLayer; public Box TextLayer; @@ -95,11 +98,10 @@ namespace osu.Game.Graphics.UserInterface }, } }, - icon = new TextAwesome + iconBeatSyncedContainer = new IconBeatSyncedContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, - TextSize = 25, }, } }, @@ -146,7 +148,7 @@ namespace osu.Game.Graphics.UserInterface { set { - icon.Icon = value; + iconBeatSyncedContainer.Icon = value; } } @@ -162,58 +164,16 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnHover(InputState state) { - icon.ClearTransforms(); - ResizeTo(SIZE_EXTENDED, transform_time, EasingTypes.OutElastic); - - int duration = 0; //(int)(Game.Audio.BeatLength / 2); - if (duration == 0) duration = pulse_length; - IconLayer.FadeColour(HoverColour, transform_time, EasingTypes.OutElastic); - const double offset = 0; //(1 - Game.Audio.SyncBeatProgress) * duration; - double startTime = Time.Current + offset; - - // basic pulse - icon.Transforms.Add(new TransformScale - { - StartValue = new Vector2(1.1f), - EndValue = Vector2.One, - StartTime = startTime, - EndTime = startTime + duration, - Easing = EasingTypes.Out, - LoopCount = -1, - LoopDelay = duration - }); - return true; } protected override void OnHoverLost(InputState state) { - icon.ClearTransforms(); - ResizeTo(SIZE_RETRACTED, transform_time, EasingTypes.OutElastic); - IconLayer.FadeColour(TextLayer.Colour, transform_time, EasingTypes.OutElastic); - - int duration = 0; //(int)(Game.Audio.BeatLength); - if (duration == 0) duration = pulse_length * 2; - - const double offset = 0; //(1 - Game.Audio.SyncBeatProgress) * duration; - double startTime = Time.Current + offset; - - // slow pulse - icon.Transforms.Add(new TransformScale - { - StartValue = new Vector2(1.1f), - EndValue = Vector2.One, - StartTime = startTime, - EndTime = startTime + duration, - Easing = EasingTypes.Out, - LoopCount = -1, - LoopDelay = duration - }); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) @@ -239,5 +199,69 @@ namespace osu.Game.Graphics.UserInterface return base.OnClick(state); } + + private class IconBeatSyncedContainer : BeatSyncedContainer + { + private const double beat_in_time = 60; + + private readonly TextAwesome icon; + private readonly Container amplitudeContainer; + + public FontAwesome Icon { set { icon.Icon = value; } } + + public IconBeatSyncedContainer() + { + EarlyActivationMilliseconds = beat_in_time; + AutoSizeAxes = Axes.Both; + + Children = new Drawable[] + { + amplitudeContainer = new Container + { + AutoSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Children = new Drawable[] + { + icon = new TextAwesome + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + TextSize = 25 + } + } + }, + }; + } + + private int lastBeatIndex; + + protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) + { + base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes); + + lastBeatIndex = beatIndex; + + var beatLength = timingPoint.BeatLength; + + float amplitudeAdjust = Math.Min(1, 0.4f + amplitudes.Maximum); + + if (beatIndex < 0) return; + + icon.ScaleTo(1 - 0.1f * amplitudeAdjust, beat_in_time, EasingTypes.Out); + using (icon.BeginDelayedSequence(beat_in_time)) + icon.ScaleTo(1, beatLength * 2, EasingTypes.OutQuint); + } + + protected override void Update() + { + base.Update(); + + const float scale_adjust_cutoff = 0.4f; + + var maxAmplitude = lastBeatIndex >= 0 ? Beatmap.Value?.Track?.CurrentAmplitudes.Maximum ?? 0 : 0; + amplitudeContainer.ScaleTo(1 - Math.Max(0, maxAmplitude - scale_adjust_cutoff) * 0.1f, 75, EasingTypes.OutQuint); + } + } } } \ No newline at end of file From 5cb6963940662f61982dbc43457303b70471b45e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 24 May 2017 22:08:14 +0900 Subject: [PATCH 035/129] 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 036/129] 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 037/129] 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 038/129] 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 039/129] 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 040/129] 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 041/129] 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 042/129] 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 043/129] 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 044/129] 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 045/129] 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 046/129] 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 9ea70b849b3ab88ffb8afade1d271487799ac934 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Thu, 25 May 2017 14:16:51 +0200 Subject: [PATCH 047/129] Fix initialize beatmap change animation of the music controller --- osu.Game/Overlays/MusicController.cs | 46 +++++++++++++++------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 4faa339bed..ff6b581480 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -264,32 +264,36 @@ namespace osu.Game.Overlays private void beatmapChanged(WorkingBeatmap beatmap) { - progressBar.IsEnabled = beatmap != null; - - bool audioEquals = beatmapBacking.Value?.BeatmapInfo?.AudioEquals(current?.BeatmapInfo) ?? false; - - TransformDirection direction; - - if (audioEquals) - direction = TransformDirection.None; - else if (queuedDirection.HasValue) + if (current != null) { - direction = queuedDirection.Value; + progressBar.IsEnabled = beatmap != null; + + bool audioEquals = beatmapBacking.Value?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false; + + TransformDirection direction; + + if (audioEquals) + direction = TransformDirection.None; + else if (queuedDirection.HasValue) + { + direction = queuedDirection.Value; + queuedDirection = null; + } + else + { + //figure out the best direction based on order in playlist. + var last = playlist.BeatmapSets.TakeWhile(b => b.ID != current.BeatmapSetInfo.ID).Count(); + var next = beatmapBacking.Value == null ? -1 : playlist.BeatmapSets.TakeWhile(b => b.ID != beatmapBacking.Value.BeatmapSetInfo.ID).Count(); + + direction = last > next ? TransformDirection.Prev : TransformDirection.Next; + } + + + updateDisplay(beatmapBacking, direction); queuedDirection = null; } - else - { - //figure out the best direction based on order in playlist. - var last = current == null ? -1 : playlist.BeatmapSets.TakeWhile(b => b.ID != current.BeatmapSetInfo.ID).Count(); - var next = beatmapBacking.Value == null ? -1 : playlist.BeatmapSets.TakeWhile(b => b.ID != beatmapBacking.Value.BeatmapSetInfo.ID).Count(); - - direction = last > next ? TransformDirection.Prev : TransformDirection.Next; - } current = beatmapBacking.Value; - - updateDisplay(beatmapBacking, direction); - queuedDirection = null; } private ScheduledDelegate pendingBeatmapSwitch; From c32d816f9cb26c531cdd4b81dca360acdf464a6f Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Thu, 25 May 2017 14:19:04 +0200 Subject: [PATCH 048/129] Removed new line --- osu-framework | 2 +- osu.Game/Overlays/MusicController.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/osu-framework b/osu-framework index 777996fb97..4de8400d5b 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 777996fb9731ba1895a5ab1323cbbc97259ff741 +Subproject commit 4de8400d5b3169bddb9fea7b25ed2498a166c14d diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index ff6b581480..1ac189d8e2 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -288,7 +288,6 @@ namespace osu.Game.Overlays direction = last > next ? TransformDirection.Prev : TransformDirection.Next; } - updateDisplay(beatmapBacking, direction); queuedDirection = null; } From 97e57178a77af3fee0c8cd448df623f042115846 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 25 May 2017 21:33:04 +0900 Subject: [PATCH 049/129] 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 050/129] 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 051/129] 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 052/129] 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 053/129] 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 054/129] 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 From 9de7e7bc40617f7538e1b738e2e8c20f97a84129 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Thu, 25 May 2017 17:49:47 +0200 Subject: [PATCH 055/129] Fixes --- osu.Game/Overlays/MusicController.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 1ac189d8e2..f1be55801f 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -264,14 +264,14 @@ namespace osu.Game.Overlays private void beatmapChanged(WorkingBeatmap beatmap) { + progressBar.IsEnabled = beatmap != null; + + TransformDirection direction = TransformDirection.None; + if (current != null) { - progressBar.IsEnabled = beatmap != null; - bool audioEquals = beatmapBacking.Value?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false; - TransformDirection direction; - if (audioEquals) direction = TransformDirection.None; else if (queuedDirection.HasValue) @@ -287,12 +287,12 @@ namespace osu.Game.Overlays direction = last > next ? TransformDirection.Prev : TransformDirection.Next; } - - updateDisplay(beatmapBacking, direction); - queuedDirection = null; } current = beatmapBacking.Value; + + updateDisplay(beatmapBacking, direction); + queuedDirection = null; } private ScheduledDelegate pendingBeatmapSwitch; From 79e731ec2a182cc5cb3032ad9c90aec0b9c2c6db Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Thu, 25 May 2017 20:20:30 +0200 Subject: [PATCH 056/129] Updated framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 4de8400d5b..8baad1b948 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 4de8400d5b3169bddb9fea7b25ed2498a166c14d +Subproject commit 8baad1b9484b9f35724e2f965c18cfe710907d80 From a9658ec66fbcc62e1b79214ffdda0a84ec3e44c0 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Thu, 25 May 2017 20:25:59 +0200 Subject: [PATCH 057/129] update colour, width, icon and text --- osu.Game/Overlays/Chat/ChatTabControl.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index 875c7c411d..fdfda92214 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -43,7 +43,7 @@ namespace osu.Game.Overlays.Chat Padding = new MarginPadding(10), }); - AddTabItem(new ChannelTabItem.ChannelSelectorTabItem(new Channel(), channelSelectorActive)); + AddTabItem(new ChannelTabItem.ChannelSelectorTabItem(new Channel { Name = "+" }, channelSelectorActive)); } private class ChannelTabItem : TabItem @@ -218,18 +218,20 @@ namespace osu.Game.Overlays.Chat { activeBindable = active; Depth = float.MaxValue; - Width = 60; + Width = 45; - icon.Icon = FontAwesome.fa_plus; + icon.Icon = 0; icon.X = 0; + + text.TextSize = 45; + textBold.TextSize = 45; } [BackgroundDependencyLoader] private new void load(OsuColour colour) { - backgroundActive = colour.Green; - backgroundInactive = colour.GreenDark; - backgroundHover = colour.Green; + backgroundInactive = colour.Gray2; + backgroundActive = colour.Gray3; updateState(); } From c2d3b6c05ad5c8dfacb6d47fdceed144409ef16e Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 15:53:49 +0900 Subject: [PATCH 058/129] Remove late initialization of head + tail, keep them updated with start time and end time. --- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 29 +++++++++++++++++---- osu.Game/Rulesets/Objects/HitObject.cs | 2 +- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index db317ddf7b..5069b4f623 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -13,20 +13,39 @@ namespace osu.Game.Rulesets.Mania.Objects /// public class HoldNote : ManiaHitObject, IHasEndTime { - public double Duration { get; set; } public double EndTime => StartTime + Duration; - private Note head; + private double duration; + public double Duration + { + get { return duration; } + set + { + duration = value; + Tail.StartTime = EndTime; + } + } + + public override double StartTime + { + get { return base.StartTime; } + set + { + base.StartTime = value; + Head.StartTime = value; + Tail.StartTime = EndTime; + } + } + /// /// The head note of the hold. /// - public Note Head => head ?? (head = new Note { StartTime = StartTime }); + public Note Head = new Note(); - private Note tail; /// /// The tail note of the hold. /// - public Note Tail => tail ?? (tail = new TailNote { StartTime = EndTime }); + public Note Tail = new TailNote(); /// /// The time between ticks of this hold. diff --git a/osu.Game/Rulesets/Objects/HitObject.cs b/osu.Game/Rulesets/Objects/HitObject.cs index 5592681cab..b282965db8 100644 --- a/osu.Game/Rulesets/Objects/HitObject.cs +++ b/osu.Game/Rulesets/Objects/HitObject.cs @@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Objects /// /// The time at which the HitObject starts. /// - public double StartTime; + public virtual double StartTime { get; set; } /// /// The samples to be played when this hit object is hit. From d3206396e7b5474db47117541ce22487cfcbb38c Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 16:10:04 +0900 Subject: [PATCH 059/129] Rewrite comments. --- .../Objects/Drawables/DrawableHoldNote.cs | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index cef4eecd38..cee2e103b9 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -127,15 +127,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { } - /// - /// Handles key down events on the body of the hold note. - /// - /// The input state. - /// The key down args. - /// Whether the key press was handled. protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { - // Make sure the keypress happened within reasonable bounds of the hold note + // Make sure the keypress happened within the body of the hold note if (Time.Current < HitObject.StartTime || Time.Current > HitObject.EndTime) return false; @@ -145,17 +139,14 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables if (args.Repeat) return false; + // The user has pressed during the body of the hold note, after the head note and its hit windows have passed + // and within the limited range of the above if-statement. This state will be managed by the head note if the + // user has pressed during the hit windows of the head note. holding = true; return true; } - /// - /// Handles key up events on the body of the hold note. - /// - /// The input state. - /// The key down args. - /// Whether the key press was handled. protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) { // Make sure that the user started holding the key during the hold note @@ -167,7 +158,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables holding = false; - // If the key has been released too early, they should not receive full score for the release + // If the key has been released too early, the user should not receive full score for the release if (!tail.Judged) hasBroken = true; @@ -196,13 +187,15 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables return false; // We only want to trigger a holding state from the head if the head has received a judgement - if (Judgement.Result == HitResult.None) + if (!Judged) return false; - // If the head has been missed, make sure the user also can't receive a full score for the release + // If the key has been released too early, the user should not receive full score for the release if (Judgement.Result == HitResult.Miss) holdNote.hasBroken = true; + // The head note also handles early hits before the body, but we want accurate early hits to count as the body being held + // The body doesn't handle these early early hits, so we have to explicitly set the holding state here holdNote.holding = true; return true; From 47e1b7b389e9347b22c6a1d1e28139ad4e000e80 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 16:28:39 +0900 Subject: [PATCH 060/129] Fix tick construction loop. --- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index 5069b4f623..c241c4cf41 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -40,12 +40,12 @@ namespace osu.Game.Rulesets.Mania.Objects /// /// The head note of the hold. /// - public Note Head = new Note(); + public readonly Note Head = new Note(); /// /// The tail note of the hold. /// - public Note Tail = new TailNote(); + public readonly Note Tail = new TailNote(); /// /// The time between ticks of this hold. @@ -73,7 +73,7 @@ namespace osu.Game.Rulesets.Mania.Objects if (tickSpacing == 0) return ret; - for (double t = StartTime + Head.HitWindows.Great / 2; t <= EndTime - Tail.HitWindows.Great / 2; t+= tickSpacing) + for (double t = StartTime + tickSpacing; t <= EndTime - tickSpacing; t += tickSpacing) { ret.Add(new HoldNoteTick { From 3f4cbd02cdaf2def643a4df6a4be4b79c63edd39 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 16:29:20 +0900 Subject: [PATCH 061/129] Fix warnings. --- .../Patterns/Legacy/DistanceObjectPatternGenerator.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 076bcdfaab..2d1f75e196 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -475,11 +475,11 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { StartTime = startTime, Column = column, - Duration = endTime - startTime + Duration = endTime - startTime, + Head = { Samples = sampleInfoListAt(startTime) }, + Tail = { Samples = sampleInfoListAt(endTime) } }; - holdNote.Head.Samples = sampleInfoListAt(startTime); - holdNote.Tail.Samples = sampleInfoListAt(endTime); newObject = holdNote; } From 871d44d6281cd6a795ce824645ee43f40aed1f6d Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 16:39:43 +0900 Subject: [PATCH 062/129] Renamings. --- .../Objects/Drawables/DrawableHoldNote.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index cee2e103b9..b9b94e7f45 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -75,12 +75,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables RelativeSizeAxes = Axes.Both, RelativeCoordinateSpace = new Vector2(1, (float)HitObject.Duration) }, - head = new HeadNote(this, key) + head = new DrawableHeadNote(this, key) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre }, - tail = new TailNote(this, key) + tail = new DrawableTailNote(this, key) { Anchor = Anchor.BottomCentre, Origin = Anchor.TopCentre @@ -168,11 +168,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables /// /// The head note of a hold. /// - private class HeadNote : DrawableNote + private class DrawableHeadNote : DrawableNote { private readonly DrawableHoldNote holdNote; - public HeadNote(DrawableHoldNote holdNote, Bindable key = null) + public DrawableHeadNote(DrawableHoldNote holdNote, Bindable key = null) : base(holdNote.HitObject.Head, key) { this.holdNote = holdNote; @@ -205,11 +205,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables /// /// The tail note of a hold. /// - private class TailNote : DrawableNote + private class DrawableTailNote : DrawableNote { private readonly DrawableHoldNote holdNote; - public TailNote(DrawableHoldNote holdNote, Bindable key = null) + public DrawableTailNote(DrawableHoldNote holdNote, Bindable key = null) : base(holdNote.HitObject.Tail, key) { this.holdNote = holdNote; From 5eab6112552ca9e972ac8d06567fd4de02d54cc5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 26 May 2017 17:33:50 +0900 Subject: [PATCH 063/129] Fix some possible nullrefs on beatmap load failure --- osu.Game/Screens/Play/Player.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index a39e7dbab2..707d026e2b 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -293,7 +293,7 @@ namespace osu.Game.Screens.Play protected override bool OnExiting(Screen next) { - if (HasFailed || !ValidForResume || pauseContainer.AllowExit || HitRenderer.HasReplayLoaded) + if (HasFailed || !ValidForResume || pauseContainer?.AllowExit != false || HitRenderer?.HasReplayLoaded != false) { fadeOut(); return base.OnExiting(next); @@ -310,7 +310,7 @@ namespace osu.Game.Screens.Play HitRenderer?.FadeOut(fade_out_duration); Content.FadeOut(fade_out_duration); - hudOverlay.ScaleTo(0.7f, fade_out_duration * 3, EasingTypes.In); + hudOverlay?.ScaleTo(0.7f, fade_out_duration * 3, EasingTypes.In); Background?.FadeTo(1f, fade_out_duration); } From 3ec41a313b548d59a89fbdbd1e1b89a03b05c74c Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 18:48:18 +0900 Subject: [PATCH 064/129] Add base DrawableHitObject + HitObjectStartTimeComparer. --- .../Objects/Drawables/DrawableHitObject.cs | 49 ++++++++++++----- .../Objects/HitObjectStartTimeComparer.cs | 55 +++++++++++++++++++ 2 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index c5dbc27fd3..fcdcf672d5 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -15,28 +15,51 @@ using System.Linq; namespace osu.Game.Rulesets.Objects.Drawables { - public abstract class DrawableHitObject : Container - where TObject : HitObject - where TJudgement : Judgement + public abstract class DrawableHitObject : Container { - public event Action> OnJudgement; - - public TObject HitObject; + public readonly HitObject HitObject; /// /// The colour used for various elements of this DrawableHitObject. /// public virtual Color4 AccentColour { get; set; } + protected DrawableHitObject(HitObject hitObject) + { + HitObject = hitObject; + } + } + + public abstract class DrawableHitObject : DrawableHitObject + where TObject : HitObject + { + public new readonly TObject HitObject; + + protected DrawableHitObject(TObject hitObject) + : base(hitObject) + { + HitObject = hitObject; + } + } + + public abstract class DrawableHitObject : DrawableHitObject + where TObject : HitObject + where TJudgement : Judgement + { + public event Action> OnJudgement; + public override bool HandleInput => Interactive; public bool Interactive = true; public TJudgement Judgement; - protected abstract TJudgement CreateJudgement(); + protected List Samples = new List(); - protected abstract void UpdateState(ArmedState state); + protected DrawableHitObject(TObject hitObject) + : base(hitObject) + { + } private ArmedState state; public ArmedState State @@ -59,8 +82,6 @@ namespace osu.Game.Rulesets.Objects.Drawables } } - protected List Samples = new List(); - protected void PlaySamples() { Samples.ForEach(s => s?.Play()); @@ -79,11 +100,6 @@ namespace osu.Game.Rulesets.Objects.Drawables /// public bool Judged => (Judgement?.Result ?? HitResult.None) != HitResult.None && (NestedHitObjects?.All(h => h.Judged) ?? true); - protected DrawableHitObject(TObject hitObject) - { - HitObject = hitObject; - } - /// /// Process a hit of this hitobject. Carries out judgement. /// @@ -176,5 +192,8 @@ namespace osu.Game.Rulesets.Objects.Drawables h.OnJudgement += d => OnJudgement?.Invoke(d); nestedHitObjects.Add(h); } + + protected abstract TJudgement CreateJudgement(); + protected abstract void UpdateState(ArmedState state); } } diff --git a/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs b/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs new file mode 100644 index 0000000000..e65bc4a99f --- /dev/null +++ b/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs @@ -0,0 +1,55 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Game.Rulesets.Objects.Drawables; + +namespace osu.Game.Rulesets.Objects +{ + /// + /// Compares two hit objects by their start time, falling back to creation order if their start time is equal. + /// + public class HitObjectStartTimeComparer : Drawable.CreationOrderDepthComparer + { + public override int Compare(Drawable x, Drawable y) + { + var hitObjectX = x as DrawableHitObject; + var hitObjectY = y as DrawableHitObject; + + // If either of the two drawables are not hit objects, fall back to the base comparer + if ((hitObjectX ?? hitObjectY) == null) + return base.Compare(x, y); + + // Compare by start time + int i = hitObjectX.HitObject.StartTime.CompareTo(hitObjectY.HitObject.StartTime); + if (i != 0) + return i; + + return base.Compare(x, y); + } + } + + /// + /// Compares two hit objects by their start time, falling back to creation order if their start time is equal. + /// This will compare the two hit objects in reverse order. + /// + public class HitObjectReverseStartTimeComparer : Drawable.ReverseCreationOrderDepthComparer + { + public override int Compare(Drawable x, Drawable y) + { + var hitObjectX = x as DrawableHitObject; + var hitObjectY = y as DrawableHitObject; + + // If either of the two drawables are not hit objects, fall back to the base comparer + if ((hitObjectX ?? hitObjectY) == null) + return base.Compare(x, y); + + // Compare by start time + int i = hitObjectY.HitObject.StartTime.CompareTo(hitObjectX.HitObject.StartTime); + if (i != 0) + return i; + + return base.Compare(x, y); + } + } +} \ No newline at end of file From e4b59314ea0735dc2607d3e56df6e2ec6a580d78 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 18:52:43 +0900 Subject: [PATCH 065/129] Use new HitObjectStartTimeComparer. --- osu-framework | 2 +- osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs | 3 +++ osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 7 +------ 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/osu-framework b/osu-framework index 777996fb97..ea5a2a7e1a 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 777996fb9731ba1895a5ab1323cbbc97259ff741 +Subproject commit ea5a2a7e1abffb1515c020fd017b583b71780316 diff --git a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs index cc8897840e..636c84d9dc 100644 --- a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using OpenTK; using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Timing { @@ -28,6 +29,8 @@ namespace osu.Game.Rulesets.Mania.Timing private readonly List drawableControlPoints; + protected override IComparer DepthComparer => new HitObjectStartTimeComparer(); + public ControlPointContainer(IEnumerable timingChanges) { drawableControlPoints = timingChanges.Select(t => new DrawableControlPoint(t)).ToList(); diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 495959b061..ff763f87c4 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -189,12 +189,7 @@ namespace osu.Game.Rulesets.Mania.UI } } - public override void Add(DrawableHitObject h) - { - h.Depth = (float)h.HitObject.StartTime; - - Columns.ElementAt(h.HitObject.Column).Add(h); - } + public override void Add(DrawableHitObject h) => Columns.ElementAt(h.HitObject.Column).Add(h); protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { From f294fef29bcaf1264639c7ffc952e12c2056b25d Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 18:56:21 +0900 Subject: [PATCH 066/129] Remove holding property in favor of a nullable hold start time. --- .../Objects/Drawables/DrawableHoldNote.cs | 33 ++++--------------- .../Objects/Drawables/DrawableHoldNoteTick.cs | 3 +- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index b9b94e7f45..5d7f3314cd 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -27,33 +27,15 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private readonly Container tickContainer; /// - /// Time at which the user started holding this hold note. + /// Time at which the user started holding this hold note. Null if the user is not holding this hold note. /// - private double holdStartTime; + private double? holdStartTime; /// /// Whether the hold note has been released too early and shouldn't give full score for the release. /// private bool hasBroken; - private bool _holding; - /// - /// Whether the user is currently holding the hold note. - /// - private bool holding - { - get { return _holding; } - set - { - if (_holding == value) - return; - _holding = value; - - if (holding) - holdStartTime = Time.Current; - } - } - public DrawableHoldNote(HoldNote hitObject, Bindable key = null) : base(hitObject, key) { @@ -91,7 +73,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { var drawableTick = new DrawableHoldNoteTick(tick) { - IsHolding = () => holding, HoldStartTime = () => holdStartTime }; @@ -142,7 +123,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables // The user has pressed during the body of the hold note, after the head note and its hit windows have passed // and within the limited range of the above if-statement. This state will be managed by the head note if the // user has pressed during the hit windows of the head note. - holding = true; + holdStartTime = Time.Current; return true; } @@ -150,13 +131,13 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) { // Make sure that the user started holding the key during the hold note - if (!holding) + if (!holdStartTime.HasValue) return false; if (args.Key != Key) return false; - holding = false; + holdStartTime = null; // If the key has been released too early, the user should not receive full score for the release if (!tail.Judged) @@ -196,7 +177,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables // The head note also handles early hits before the body, but we want accurate early hits to count as the body being held // The body doesn't handle these early early hits, so we have to explicitly set the holding state here - holdNote.holding = true; + holdNote.holdStartTime = Time.Current; return true; } @@ -234,7 +215,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) { // Make sure that the user started holding the key during the hold note - if (!holdNote.holding) + if (!holdNote.holdStartTime.HasValue) return false; if (Judgement.Result != HitResult.None) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs index 8cd60e9901..9ecc77d3fc 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables /// /// References the time at which the user started holding the hold note. /// - public Func HoldStartTime; + public Func HoldStartTime; /// /// References whether the user is currently holding the hold note. @@ -90,7 +90,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables if (Time.Current < HitObject.StartTime) return; - if (HoldStartTime?.Invoke() > HitObject.StartTime) return; From 1e4bca90f08e10a89c09729027e65db672f9b3a1 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 26 May 2017 12:10:16 +0200 Subject: [PATCH 067/129] remove duplicate code --- osu.Game/Overlays/Chat/ChatTabControl.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index fdfda92214..9c26632a8b 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -24,9 +24,7 @@ namespace osu.Game.Overlays.Chat private const float shear_width = 10; - private readonly Bindable channelSelectorActive = new Bindable(); - - public Bindable ChannelSelectorActive => channelSelectorActive; + public readonly Bindable ChannelSelectorActive = new Bindable(); public ChatTabControl() { @@ -43,7 +41,7 @@ namespace osu.Game.Overlays.Chat Padding = new MarginPadding(10), }); - AddTabItem(new ChannelTabItem.ChannelSelectorTabItem(new Channel { Name = "+" }, channelSelectorActive)); + AddTabItem(new ChannelTabItem.ChannelSelectorTabItem(new Channel { Name = "+" }, ChannelSelectorActive)); } private class ChannelTabItem : TabItem @@ -122,6 +120,11 @@ namespace osu.Game.Overlays.Chat backgroundHover = colours.Gray7; highlightBox.Colour = colours.Yellow; + } + + protected override void LoadComplete() + { + base.LoadComplete(); updateState(); } @@ -232,8 +235,6 @@ namespace osu.Game.Overlays.Chat { backgroundInactive = colour.Gray2; backgroundActive = colour.Gray3; - - updateState(); } } } From 43a7923199fa4a4ff8b49b5a191ab90f131f7b01 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 19:22:17 +0900 Subject: [PATCH 068/129] Implement base mania judgement score. --- .../Judgements/ManiaJudgement.cs | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Judgements/ManiaJudgement.cs b/osu.Game.Rulesets.Mania/Judgements/ManiaJudgement.cs index 6e69da3da7..33083ca0f5 100644 --- a/osu.Game.Rulesets.Mania/Judgements/ManiaJudgement.cs +++ b/osu.Game.Rulesets.Mania/Judgements/ManiaJudgement.cs @@ -2,11 +2,37 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Mania.Judgements { public class ManiaJudgement : Judgement { + /// + /// The maximum possible hit result. + /// + public const ManiaHitResult MAX_HIT_RESULT = ManiaHitResult.Perfect; + + /// + /// The result value for the combo portion of the score. + /// + public int ResultValueForScore => Result == HitResult.Miss ? 0 : NumericResultForScore(ManiaResult); + + /// + /// The result value for the accuracy portion of the score. + /// + public int ResultValueForAccuracy => Result == HitResult.Miss ? 0 : NumericResultForAccuracy(ManiaResult); + + /// + /// The maximum result value for the combo portion of the score. + /// + public int MaxResultValueForScore => NumericResultForScore(MAX_HIT_RESULT); + + /// + /// The maximum result value for the accuracy portion of the score. + /// + public int MaxResultValueForAccuracy => NumericResultForAccuracy(MAX_HIT_RESULT); + public override string ResultString => string.Empty; public override string MaxResultString => string.Empty; @@ -15,5 +41,42 @@ namespace osu.Game.Rulesets.Mania.Judgements /// The hit result. /// public ManiaHitResult ManiaResult; + + public virtual int NumericResultForScore(ManiaHitResult result) + { + switch (result) + { + default: + return 0; + case ManiaHitResult.Bad: + return 50; + case ManiaHitResult.Ok: + return 100; + case ManiaHitResult.Good: + return 200; + case ManiaHitResult.Great: + case ManiaHitResult.Perfect: + return 300; + } + } + + public virtual int NumericResultForAccuracy(ManiaHitResult result) + { + switch (result) + { + default: + return 0; + case ManiaHitResult.Bad: + return 50; + case ManiaHitResult.Ok: + return 100; + case ManiaHitResult.Good: + return 200; + case ManiaHitResult.Great: + return 300; + case ManiaHitResult.Perfect: + return 305; + } + } } } From 4c67c13410f0b7567944672ac1ba29f66d91b84a Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 19:28:14 +0900 Subject: [PATCH 069/129] Add hold note tail judgement. --- .../Judgements/HoldNoteTailJudgement.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Judgements/HoldNoteTailJudgement.cs b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTailJudgement.cs index df2f7e9e63..d5cf57a5da 100644 --- a/osu.Game.Rulesets.Mania/Judgements/HoldNoteTailJudgement.cs +++ b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTailJudgement.cs @@ -9,5 +9,29 @@ namespace osu.Game.Rulesets.Mania.Judgements /// Whether the hold note has been released too early and shouldn't give full score for the release. /// public bool HasBroken; + + public override int NumericResultForScore(ManiaHitResult result) + { + switch (result) + { + default: + return base.NumericResultForScore(result); + case ManiaHitResult.Great: + case ManiaHitResult.Perfect: + return base.NumericResultForScore(HasBroken ? ManiaHitResult.Good : result); + } + } + + public override int NumericResultForAccuracy(ManiaHitResult result) + { + switch (result) + { + default: + return base.NumericResultForAccuracy(result); + case ManiaHitResult.Great: + case ManiaHitResult.Perfect: + return base.NumericResultForAccuracy(HasBroken ? ManiaHitResult.Good : result); + } + } } } \ No newline at end of file From 02f582a3f80993177dc06dbbc322679e23f99bd3 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 19:29:47 +0900 Subject: [PATCH 070/129] Add hold note tick judgement. --- osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs index bead455c13..d6a72c825a 100644 --- a/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs +++ b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs @@ -5,5 +5,7 @@ namespace osu.Game.Rulesets.Mania.Judgements { public class HoldNoteTickJudgement : ManiaJudgement { + public override int NumericResultForScore(ManiaHitResult result) => 20; + public override int NumericResultForAccuracy(ManiaHitResult result) => 0; // Don't count ticks into accuracy } } \ No newline at end of file From 9517bfc2f18d948226d2a37649d73aea1771f48b Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 19:33:23 +0900 Subject: [PATCH 071/129] Add file to csproj. --- osu.Game/osu.Game.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 25b692151f..c669ac1981 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -176,6 +176,7 @@ + From 2c23703ca6f85f7c792c9dca1392d3cf015212d1 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 26 May 2017 13:46:44 +0300 Subject: [PATCH 072/129] Removed amplitude container --- .../Graphics/UserInterface/TwoLayerButton.cs | 40 ++++--------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index 4aeaf6965d..209d9fb468 100644 --- a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs +++ b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs @@ -19,7 +19,7 @@ namespace osu.Game.Graphics.UserInterface { public class TwoLayerButton : ClickableContainer { - private readonly IconBeatSyncedContainer iconBeatSyncedContainer; + private readonly BouncingIcon bouncingIcon; public Box IconLayer; public Box TextLayer; @@ -98,7 +98,7 @@ namespace osu.Game.Graphics.UserInterface }, } }, - iconBeatSyncedContainer = new IconBeatSyncedContainer + bouncingIcon = new BouncingIcon { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -148,7 +148,7 @@ namespace osu.Game.Graphics.UserInterface { set { - iconBeatSyncedContainer.Icon = value; + bouncingIcon.Icon = value; } } @@ -200,48 +200,34 @@ namespace osu.Game.Graphics.UserInterface return base.OnClick(state); } - private class IconBeatSyncedContainer : BeatSyncedContainer + private class BouncingIcon : BeatSyncedContainer { private const double beat_in_time = 60; private readonly TextAwesome icon; - private readonly Container amplitudeContainer; public FontAwesome Icon { set { icon.Icon = value; } } - public IconBeatSyncedContainer() + public BouncingIcon() { EarlyActivationMilliseconds = beat_in_time; AutoSizeAxes = Axes.Both; Children = new Drawable[] { - amplitudeContainer = new Container + icon = new TextAwesome { - AutoSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, - Children = new Drawable[] - { - icon = new TextAwesome - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - TextSize = 25 - } - } - }, + TextSize = 25 + } }; } - private int lastBeatIndex; - protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) { base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes); - lastBeatIndex = beatIndex; - var beatLength = timingPoint.BeatLength; float amplitudeAdjust = Math.Min(1, 0.4f + amplitudes.Maximum); @@ -252,16 +238,6 @@ namespace osu.Game.Graphics.UserInterface using (icon.BeginDelayedSequence(beat_in_time)) icon.ScaleTo(1, beatLength * 2, EasingTypes.OutQuint); } - - protected override void Update() - { - base.Update(); - - const float scale_adjust_cutoff = 0.4f; - - var maxAmplitude = lastBeatIndex >= 0 ? Beatmap.Value?.Track?.CurrentAmplitudes.Maximum ?? 0 : 0; - amplitudeContainer.ScaleTo(1 - Math.Max(0, maxAmplitude - scale_adjust_cutoff) * 0.1f, 75, EasingTypes.OutQuint); - } } } } \ No newline at end of file From cbe36259c3eea9bd422aeaea816e22d400893ba6 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 07:49:45 -0300 Subject: [PATCH 073/129] Add BreadcrumbControl --- .../Tests/TestCaseBreadcrumbs.cs | 39 ++++++++++++ .../osu.Desktop.VisualTests.csproj | 1 + .../UserInterface/BreadcrumbControl.cs | 63 +++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 4 files changed, 104 insertions(+) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs create mode 100644 osu.Game/Graphics/UserInterface/BreadcrumbControl.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs b/osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs new file mode 100644 index 0000000000..658d2f92b1 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs @@ -0,0 +1,39 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Testing; +using osu.Game.Graphics.UserInterface; +using osu.Framework.Graphics; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseBreadcrumbs : TestCase + { + public override string Description => @"breadcrumb > control"; + + public override void Reset() + { + base.Reset(); + + BreadcrumbControl c; + Add(c = new BreadcrumbControl + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + Width = 0.5f, + }); + + AddStep(@"first", () => c.Current.Value = BreadcrumbTab.Click); + AddStep(@"second", () => c.Current.Value = BreadcrumbTab.The); + AddStep(@"third", () => c.Current.Value = BreadcrumbTab.Circles); + } + + private enum BreadcrumbTab + { + Click, + The, + Circles, + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 7b7997063b..5a532d7234 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -223,6 +223,7 @@ + diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs new file mode 100644 index 0000000000..be3933f362 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -0,0 +1,63 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Linq; +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.UserInterface; + +namespace osu.Game.Graphics.UserInterface +{ + public class BreadcrumbControl : OsuTabControl + { + public static readonly float padding = 10; + + protected override TabItem CreateTabItem(T value) => new BreadcrumbTabItem(value); + + public BreadcrumbControl() + { + Height = 28; + TabContainer.Spacing = new Vector2(padding, 0f); + Current.ValueChanged += tab => + { + foreach (TabItem t in TabContainer.Children) + { + if (!(t is BreadcrumbTabItem)) return; + + var tIndex = TabContainer.IndexOf(t); + var tabIndex = TabContainer.IndexOf(TabMap[tab]); + var hide = tIndex < tabIndex; + var hideChevron = tIndex <= tabIndex; + + t.FadeTo(hide ? 0f : 1f, 500, EasingTypes.OutQuint); + t.ScaleTo(new Vector2(hide ? 0.8f : 1f, 1f), 500, EasingTypes.OutQuint); + (t as BreadcrumbTabItem).Chevron.FadeTo(hideChevron ? 0f : 1f, 500, EasingTypes.OutQuint); + } + }; + } + + private class BreadcrumbTabItem : OsuTabItem + { + public readonly TextAwesome Chevron; + + //don't allow clicking between transitions and don't make the chevron clickable + protected override bool InternalContains(Vector2 screenSpacePos) => Alpha < 1f ? false : Text.Contains(screenSpacePos); + + public BreadcrumbTabItem(T value) : base(value) + { + Text.TextSize = 18; + Padding = new MarginPadding { Right = padding + 9 }; + Add(Chevron = new TextAwesome + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreLeft, + TextSize = 12, + Icon = FontAwesome.fa_chevron_right, + Margin = new MarginPadding { Left = 10 }, + Alpha = 0f, + }); + } + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 25b692151f..4d1b1a1b11 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -450,6 +450,7 @@ + From 9ec6e0b692cf14b31e07079264aeceb736025d49 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 19:56:27 +0900 Subject: [PATCH 074/129] Fix hold note ticks changing combo. --- osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs index d6a72c825a..852f97b3f2 100644 --- a/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs +++ b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs @@ -5,6 +5,8 @@ namespace osu.Game.Rulesets.Mania.Judgements { public class HoldNoteTickJudgement : ManiaJudgement { + public override bool AffectsCombo => false; + public override int NumericResultForScore(ManiaHitResult result) => 20; public override int NumericResultForAccuracy(ManiaHitResult result) => 0; // Don't count ticks into accuracy } From ab5e1bfc891e01f7a05c851591dae1cf4f9978e0 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 19:56:50 +0900 Subject: [PATCH 075/129] Add basic score calculations. --- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 6 + .../Scoring/ManiaScoreProcessor.cs | 148 ++++++++++++++++++ 2 files changed, 154 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index c241c4cf41..3550d561c1 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using System.Linq; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Database; using osu.Game.Rulesets.Objects.Types; @@ -60,6 +61,11 @@ namespace osu.Game.Rulesets.Mania.Objects tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate; } + /// + /// Total number of hold note ticks. + /// + public int TotalTicks => Ticks.Count(); + /// /// The scoring scoring ticks of the hold note. /// diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index 7a9572a0c7..2f4ce075c3 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -1,8 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; +using osu.Game.Beatmaps; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; @@ -10,6 +13,52 @@ namespace osu.Game.Rulesets.Mania.Scoring { internal class ManiaScoreProcessor : ScoreProcessor { + /// + /// The maximum score achievable. + /// Does _not_ include bonus score - for bonus score see . + /// + private const int max_score = 1000000; + + /// + /// The amount of the score attributed to combo. + /// + private const double combo_portion_max = max_score * 0.2; + + /// + /// The amount of the score attributed to accuracy. + /// + private const double accuracy_portion_max = max_score * 0.8; + + /// + /// The cumulative combo portion of the score. + /// + private double comboScore => combo_portion_max * comboPortion / maxComboPortion; + + /// + /// The cumulative accuracy portion of the score. + /// + private double accuracyScore => accuracy_portion_max * Math.Pow(Accuracy, 4) * totalHits / maxTotalHits; + + /// + /// The cumulative bonus score. + /// This is added on top of , thus the total score can exceed . + /// + private double bonusScore; + + private double maxComboPortion; + private double comboPortion; + private int maxTotalHits; + private int totalHits; + + private double hpIncreaseBad; + private double hpIncreaseOk; + private double hpIncreaseGood; + private double hpIncreaseGreat; + private double hpIncreasePerfect; + private double hpIncreaseTick; + private double hpIncreaseTickMiss; + private double hpIncreaseMiss; + public ManiaScoreProcessor() { } @@ -19,8 +68,107 @@ namespace osu.Game.Rulesets.Mania.Scoring { } + protected override void ComputeTargets(Beatmap beatmap) + { + foreach (var obj in beatmap.HitObjects) + { + if (obj is Note) + { + AddJudgement(new ManiaJudgement + { + Result = HitResult.Hit, + ManiaResult = ManiaHitResult.Perfect + }); + } + else if (obj is HoldNote) + { + // Head + AddJudgement(new ManiaJudgement + { + Result = HitResult.Hit, + ManiaResult = ManiaJudgement.MAX_HIT_RESULT + }); + + // Ticks + for (int i = 0; i < ((HoldNote)obj).TotalTicks; i++) + { + AddJudgement(new HoldNoteTickJudgement + { + Result = HitResult.Hit, + ManiaResult = ManiaJudgement.MAX_HIT_RESULT, + }); + } + + AddJudgement(new HoldNoteTailJudgement + { + Result = HitResult.Hit, + ManiaResult = ManiaJudgement.MAX_HIT_RESULT + }); + } + } + + maxTotalHits = totalHits; + maxComboPortion = comboPortion; + } + protected override void OnNewJudgement(ManiaJudgement judgement) { + bool isTick = judgement is HoldNoteTickJudgement; + + if (!isTick) + totalHits++; + + switch (judgement.Result) + { + case HitResult.Miss: + if (isTick) + Health.Value += hpIncreaseTickMiss; + else + Health.Value += hpIncreaseMiss; + break; + case HitResult.Hit: + if (isTick) + { + Health.Value += hpIncreaseTick; + bonusScore += judgement.ResultValueForScore; + } + else + { + switch (judgement.ManiaResult) + { + case ManiaHitResult.Bad: + Health.Value += hpIncreaseBad; + break; + case ManiaHitResult.Ok: + Health.Value += hpIncreaseOk; + break; + case ManiaHitResult.Good: + Health.Value += hpIncreaseGood; + break; + case ManiaHitResult.Great: + Health.Value += hpIncreaseGreat; + break; + case ManiaHitResult.Perfect: + Health.Value += hpIncreasePerfect; + break; + } + + comboPortion += judgement.ResultValueForScore; + } + break; + } + + int scoreForAccuracy = 0; + int maxScoreForAccuracy = 0; + + foreach (var j in Judgements) + { + scoreForAccuracy += j.ResultValueForAccuracy; + maxScoreForAccuracy += j.MaxResultValueForAccuracy; + } + + Accuracy.Value = (double)scoreForAccuracy / maxScoreForAccuracy; + TotalScore.Value = comboScore + accuracyScore + bonusScore; } protected override void Reset() From 10f62eb8da15bd22268fca9b84a71755d932af55 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 20:25:24 +0900 Subject: [PATCH 076/129] Fix incorrect combo score. --- .../Scoring/ManiaScoreProcessor.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index 2f4ce075c3..4a5ab639b9 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -29,6 +29,16 @@ namespace osu.Game.Rulesets.Mania.Scoring /// private const double accuracy_portion_max = max_score * 0.8; + /// + /// The factor used to determine relevance of combos. + /// + private const double combo_base = 4; + + /// + /// The combo value at which hit objects result in the max score possible. + /// + private const int combo_relevance_cap = 400; + /// /// The cumulative combo portion of the score. /// @@ -153,7 +163,9 @@ namespace osu.Game.Rulesets.Mania.Scoring break; } - comboPortion += judgement.ResultValueForScore; + // A factor that is applied to make higher combos more relevant + double comboRelevance = Math.Min(Math.Max(0.5, Math.Log(Combo.Value, combo_base)), Math.Log(combo_relevance_cap, combo_base)); + comboPortion += judgement.ResultValueForScore * comboRelevance; } break; } From 95908af677aec6bf59bf1545233e3b4f8e35fa4d Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 20:26:06 +0900 Subject: [PATCH 077/129] Fix resetting scoreprocessor. --- osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index 4a5ab639b9..18df7888b6 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -188,6 +188,10 @@ namespace osu.Game.Rulesets.Mania.Scoring base.Reset(); Health.Value = 1; + + bonusScore = 0; + comboPortion = 0; + totalHits = 0; } } } From ca080117349bc78789a0f1e79c27818666f46e22 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 20:26:26 +0900 Subject: [PATCH 078/129] Add basic (new) hp calculations. --- .../Scoring/ManiaScoreProcessor.cs | 98 +++++++++++-------- 1 file changed, 56 insertions(+), 42 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index 18df7888b6..fc2e8bec10 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -60,14 +60,17 @@ namespace osu.Game.Rulesets.Mania.Scoring private int maxTotalHits; private int totalHits; - private double hpIncreaseBad; - private double hpIncreaseOk; - private double hpIncreaseGood; - private double hpIncreaseGreat; - private double hpIncreasePerfect; - private double hpIncreaseTick; - private double hpIncreaseTickMiss; - private double hpIncreaseMiss; + private double hpMultiplier = 1; + private const double hp_increase_bad = 0.005; + private const double hp_increase_ok = 0.010; + private const double hp_increase_good = 0.035; + private const double hp_increase_tick = 0.040; + private const double hp_increase_great = 0.055; + private const double hp_increase_perfect = 0.065; + + private double hpMissMultiplier = 1; + private const double hp_increase_tick_miss = -0.025; + private const double hp_increase_miss = -0.125; public ManiaScoreProcessor() { @@ -80,41 +83,52 @@ namespace osu.Game.Rulesets.Mania.Scoring protected override void ComputeTargets(Beatmap beatmap) { - foreach (var obj in beatmap.HitObjects) + while (true) { - if (obj is Note) + foreach (var obj in beatmap.HitObjects) { - AddJudgement(new ManiaJudgement + if (obj is Note) { - Result = HitResult.Hit, - ManiaResult = ManiaHitResult.Perfect - }); - } - else if (obj is HoldNote) - { - // Head - AddJudgement(new ManiaJudgement - { - Result = HitResult.Hit, - ManiaResult = ManiaJudgement.MAX_HIT_RESULT - }); - - // Ticks - for (int i = 0; i < ((HoldNote)obj).TotalTicks; i++) - { - AddJudgement(new HoldNoteTickJudgement + AddJudgement(new ManiaJudgement { Result = HitResult.Hit, - ManiaResult = ManiaJudgement.MAX_HIT_RESULT, + ManiaResult = ManiaHitResult.Perfect }); } - - AddJudgement(new HoldNoteTailJudgement + else if (obj is HoldNote) { - Result = HitResult.Hit, - ManiaResult = ManiaJudgement.MAX_HIT_RESULT - }); + // Head + AddJudgement(new ManiaJudgement + { + Result = HitResult.Hit, + ManiaResult = ManiaJudgement.MAX_HIT_RESULT + }); + + // Ticks + for (int i = 0; i < ((HoldNote)obj).TotalTicks; i++) + { + AddJudgement(new HoldNoteTickJudgement + { + Result = HitResult.Hit, + ManiaResult = ManiaJudgement.MAX_HIT_RESULT, + }); + } + + AddJudgement(new HoldNoteTailJudgement + { + Result = HitResult.Hit, + ManiaResult = ManiaJudgement.MAX_HIT_RESULT + }); + } } + + if (!HasFailed) + break; + + hpMultiplier *= 1.01; + hpMissMultiplier *= 0.98; + + Reset(); } maxTotalHits = totalHits; @@ -132,14 +146,14 @@ namespace osu.Game.Rulesets.Mania.Scoring { case HitResult.Miss: if (isTick) - Health.Value += hpIncreaseTickMiss; + Health.Value += hpMissMultiplier * hp_increase_tick_miss; else - Health.Value += hpIncreaseMiss; + Health.Value += hpMissMultiplier * hp_increase_miss; break; case HitResult.Hit: if (isTick) { - Health.Value += hpIncreaseTick; + Health.Value += hpMultiplier * hp_increase_tick; bonusScore += judgement.ResultValueForScore; } else @@ -147,19 +161,19 @@ namespace osu.Game.Rulesets.Mania.Scoring switch (judgement.ManiaResult) { case ManiaHitResult.Bad: - Health.Value += hpIncreaseBad; + Health.Value += hpMultiplier * hp_increase_bad; break; case ManiaHitResult.Ok: - Health.Value += hpIncreaseOk; + Health.Value += hpMultiplier * hp_increase_ok; break; case ManiaHitResult.Good: - Health.Value += hpIncreaseGood; + Health.Value += hpMultiplier * hp_increase_good; break; case ManiaHitResult.Great: - Health.Value += hpIncreaseGreat; + Health.Value += hpMultiplier * hp_increase_great; break; case ManiaHitResult.Perfect: - Health.Value += hpIncreasePerfect; + Health.Value += hpMultiplier * hp_increase_perfect; break; } From d052f093d5984e45ef7fbd45165f939231375c29 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 26 May 2017 14:29:45 +0300 Subject: [PATCH 079/129] Scaling on hover --- osu.Game/Graphics/UserInterface/TwoLayerButton.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index 209d9fb468..ebaef661c4 100644 --- a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs +++ b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs @@ -167,6 +167,8 @@ namespace osu.Game.Graphics.UserInterface ResizeTo(SIZE_EXTENDED, transform_time, EasingTypes.OutElastic); IconLayer.FadeColour(HoverColour, transform_time, EasingTypes.OutElastic); + bouncingIcon.ScaleTo(1.1f, transform_time, EasingTypes.OutElastic); + return true; } @@ -174,6 +176,8 @@ namespace osu.Game.Graphics.UserInterface { ResizeTo(SIZE_RETRACTED, transform_time, EasingTypes.OutElastic); IconLayer.FadeColour(TextLayer.Colour, transform_time, EasingTypes.OutElastic); + + bouncingIcon.ScaleTo(1, transform_time, EasingTypes.OutElastic); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) From 3715171948983a9f95fe246143f56ef14e245d65 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 20:32:21 +0900 Subject: [PATCH 080/129] Ticks can't be missed. --- osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index fc2e8bec10..1be92f6dc4 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -69,7 +69,6 @@ namespace osu.Game.Rulesets.Mania.Scoring private const double hp_increase_perfect = 0.065; private double hpMissMultiplier = 1; - private const double hp_increase_tick_miss = -0.025; private const double hp_increase_miss = -0.125; public ManiaScoreProcessor() @@ -145,9 +144,6 @@ namespace osu.Game.Rulesets.Mania.Scoring switch (judgement.Result) { case HitResult.Miss: - if (isTick) - Health.Value += hpMissMultiplier * hp_increase_tick_miss; - else Health.Value += hpMissMultiplier * hp_increase_miss; break; case HitResult.Hit: From b28b7af887261f8b67d8daba0aff7ff5876ec2a2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 20:42:03 +0900 Subject: [PATCH 081/129] Scale HP with drain rate a bit. --- .../Scoring/ManiaScoreProcessor.cs | 102 ++++++++++++++++-- 1 file changed, 93 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index 1be92f6dc4..12c8386ae7 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -3,6 +3,7 @@ using System; using osu.Game.Beatmaps; +using osu.Game.Database; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Objects.Drawables; @@ -39,6 +40,71 @@ namespace osu.Game.Rulesets.Mania.Scoring /// private const int combo_relevance_cap = 400; + /// + /// The hit HP multiplier at OD = 0. + /// + private const double hp_multiplier_min = 0.75; + + /// + /// The hit HP multiplier at OD = 0. + /// + private const double hp_multiplier_mid = 0.85; + + /// + /// The hit HP multiplier at OD = 0. + /// + private const double hp_multiplier_max = 1; + + /// + /// The default BAD hit HP increase. + /// + private const double hp_increase_bad = 0.005; + + /// + /// The default OK hit HP increase. + /// + private const double hp_increase_ok = 0.010; + + /// + /// The default GOOD hit HP increase. + /// + private const double hp_increase_good = 0.035; + + /// + /// The default tick hit HP increase. + /// + private const double hp_increase_tick = 0.040; + + /// + /// The default GREAT hit HP increase. + /// + private const double hp_increase_great = 0.055; + + /// + /// The default PERFECT hit HP increase. + /// + private const double hp_increase_perfect = 0.065; + + /// + /// The MISS HP multiplier at OD = 0. + /// + private const double hp_multiplier_miss_min = 0.5; + + /// + /// The MISS HP multiplier at OD = 5. + /// + private const double hp_multiplier_miss_mid = 0.75; + + /// + /// The MISS HP multiplier at OD = 10. + /// + private const double hp_multiplier_miss_max = 1; + + /// + /// The default MISS HP increase. + /// + private const double hp_increase_miss = -0.125; + /// /// The cumulative combo portion of the score. /// @@ -55,21 +121,35 @@ namespace osu.Game.Rulesets.Mania.Scoring /// private double bonusScore; + /// + /// The achieved by a perfect playthrough. + /// private double maxComboPortion; + + /// + /// The portion of the score dedicated to combo. + /// private double comboPortion; + + /// + /// The achieved by a perfect playthrough. + /// private int maxTotalHits; + + /// + /// The total hits. + /// private int totalHits; - private double hpMultiplier = 1; - private const double hp_increase_bad = 0.005; - private const double hp_increase_ok = 0.010; - private const double hp_increase_good = 0.035; - private const double hp_increase_tick = 0.040; - private const double hp_increase_great = 0.055; - private const double hp_increase_perfect = 0.065; - + /// + /// The MISS HP multiplier. + /// private double hpMissMultiplier = 1; - private const double hp_increase_miss = -0.125; + + /// + /// The HIT HP multiplier. + /// + private double hpMultiplier = 1; public ManiaScoreProcessor() { @@ -82,6 +162,10 @@ namespace osu.Game.Rulesets.Mania.Scoring protected override void ComputeTargets(Beatmap beatmap) { + BeatmapDifficulty difficulty = beatmap.BeatmapInfo.Difficulty; + hpMultiplier = BeatmapDifficulty.DifficultyRange(difficulty.DrainRate, hp_multiplier_min, hp_multiplier_mid, hp_multiplier_max); + hpMissMultiplier = BeatmapDifficulty.DifficultyRange(difficulty.DrainRate, hp_multiplier_miss_min, hp_multiplier_miss_mid, hp_multiplier_miss_max); + while (true) { foreach (var obj in beatmap.HitObjects) From 64612ef34b99250921cf96b5c0dfc85ad40f2ea9 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 26 May 2017 16:10:28 +0200 Subject: [PATCH 082/129] add multimod animation --- osu.Game/Overlays/Mods/ModButton.cs | 44 +++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 831b9082bd..68c1fb8592 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -27,6 +27,7 @@ namespace osu.Game.Overlays.Mods public class ModButton : ModButtonEmpty, IHasTooltip { private ModIcon foregroundIcon; + private ModIcon backgroundIcon; private readonly SpriteText text; private readonly Container iconsContainer; private SampleChannel sampleOn, sampleOff; @@ -35,6 +36,9 @@ namespace osu.Game.Overlays.Mods public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty; + private const EasingTypes modSwitchEasing = EasingTypes.InOutQuint; + private const double modSwitchDuration = 100; + private int _selectedIndex = -1; private int selectedIndex { @@ -45,6 +49,9 @@ namespace osu.Game.Overlays.Mods set { if (value == _selectedIndex) return; + + bool beforeSelected = Selected; + _selectedIndex = value; if (value >= Mods.Length) @@ -55,13 +62,30 @@ namespace osu.Game.Overlays.Mods { _selectedIndex = Mods.Length - 1; } - - iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic); - iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic); + if (beforeSelected ^ Selected) + { + iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic); + iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic); + } + else + { + foregroundIcon.RotateTo(15f, modSwitchDuration, modSwitchEasing); + backgroundIcon.RotateTo(-15f, modSwitchDuration, modSwitchEasing); + using (foregroundIcon.BeginDelayedSequence(modSwitchDuration)) + { + foregroundIcon.RotateTo(-15f); + foregroundIcon.RotateTo(0f, modSwitchDuration, modSwitchEasing); + } + using (backgroundIcon.BeginDelayedSequence(modSwitchDuration)) + { + backgroundIcon.RotateTo(15f); + backgroundIcon.RotateTo(0f, modSwitchDuration, modSwitchEasing); + } + } foregroundIcon.Highlighted = Selected; if (mod != null) - displayMod(SelectedMod ?? Mods[0]); + Scheduler.AddDelayed(() => displayMod(SelectedMod ?? Mods[0]), beforeSelected ^ Selected ? 0 : modSwitchDuration); } } @@ -159,6 +183,8 @@ namespace osu.Game.Overlays.Mods private void displayMod(Mod mod) { + if(backgroundIcon != null) + backgroundIcon.Icon = foregroundIcon.Icon; foregroundIcon.Icon = mod.Icon; text.Text = mod.Name; } @@ -170,17 +196,17 @@ namespace osu.Game.Overlays.Mods { iconsContainer.Add(new[] { - new ModIcon(Mods[0]) + backgroundIcon = new ModIcon(Mods[1]) { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, + Origin = Anchor.BottomRight, + Anchor = Anchor.BottomRight, AutoSizeAxes = Axes.Both, Position = new Vector2(1.5f), }, foregroundIcon = new ModIcon(Mods[0]) { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, + Origin = Anchor.BottomRight, + Anchor = Anchor.BottomRight, AutoSizeAxes = Axes.Both, Position = new Vector2(-1.5f), }, From db1dde72de27b276a023932e7ae999986b7882dc Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 26 May 2017 16:29:15 +0200 Subject: [PATCH 083/129] change constant names --- osu.Game/Overlays/Mods/ModButton.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 68c1fb8592..e1545ab1b8 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -36,8 +36,8 @@ namespace osu.Game.Overlays.Mods public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty; - private const EasingTypes modSwitchEasing = EasingTypes.InOutQuint; - private const double modSwitchDuration = 100; + private const EasingTypes mod_switch_easing = EasingTypes.InOutQuint; + private const double mod_switch_duration = 100; private int _selectedIndex = -1; private int selectedIndex @@ -69,23 +69,23 @@ namespace osu.Game.Overlays.Mods } else { - foregroundIcon.RotateTo(15f, modSwitchDuration, modSwitchEasing); - backgroundIcon.RotateTo(-15f, modSwitchDuration, modSwitchEasing); - using (foregroundIcon.BeginDelayedSequence(modSwitchDuration)) + foregroundIcon.RotateTo(15f, mod_switch_duration, mod_switch_easing); + backgroundIcon.RotateTo(-15f, mod_switch_duration, mod_switch_easing); + using (foregroundIcon.BeginDelayedSequence(mod_switch_duration)) { foregroundIcon.RotateTo(-15f); - foregroundIcon.RotateTo(0f, modSwitchDuration, modSwitchEasing); + foregroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); } - using (backgroundIcon.BeginDelayedSequence(modSwitchDuration)) + using (backgroundIcon.BeginDelayedSequence(mod_switch_duration)) { backgroundIcon.RotateTo(15f); - backgroundIcon.RotateTo(0f, modSwitchDuration, modSwitchEasing); + backgroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); } } foregroundIcon.Highlighted = Selected; if (mod != null) - Scheduler.AddDelayed(() => displayMod(SelectedMod ?? Mods[0]), beforeSelected ^ Selected ? 0 : modSwitchDuration); + Scheduler.AddDelayed(() => displayMod(SelectedMod ?? Mods[0]), beforeSelected ^ Selected ? 0 : mod_switch_duration); } } From fb6ed159ca0042dc11ec2e33e22a030c97e00dba Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:03:51 -0300 Subject: [PATCH 084/129] Use padding for chevron margin --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index be3933f362..a54823e042 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -47,14 +47,14 @@ namespace osu.Game.Graphics.UserInterface public BreadcrumbTabItem(T value) : base(value) { Text.TextSize = 18; - Padding = new MarginPadding { Right = padding + 9 }; + Padding = new MarginPadding { Right = padding + 9 }; //padding + chevron width Add(Chevron = new TextAwesome { Anchor = Anchor.CentreRight, Origin = Anchor.CentreLeft, TextSize = 12, Icon = FontAwesome.fa_chevron_right, - Margin = new MarginPadding { Left = 10 }, + Margin = new MarginPadding { Left = padding }, Alpha = 0f, }); } From 352d3d247bec1cd5be22715f3894d9aa37b74f94 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:21:37 -0300 Subject: [PATCH 085/129] Fix incorrect sizes --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index a54823e042..4ee0ba9e5e 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -17,7 +17,7 @@ namespace osu.Game.Graphics.UserInterface public BreadcrumbControl() { - Height = 28; + Height = 26; TabContainer.Spacing = new Vector2(padding, 0f); Current.ValueChanged += tab => { @@ -46,8 +46,8 @@ namespace osu.Game.Graphics.UserInterface public BreadcrumbTabItem(T value) : base(value) { - Text.TextSize = 18; - Padding = new MarginPadding { Right = padding + 9 }; //padding + chevron width + Text.TextSize = 16; + Padding = new MarginPadding { Right = padding + 8 }; //padding + chevron width Add(Chevron = new TextAwesome { Anchor = Anchor.CentreRight, From 4c127a6130368c87f85b98af2e10ca6218f2c0b2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:29:20 -0300 Subject: [PATCH 086/129] CI fixes --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 4ee0ba9e5e..3bc94da07b 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -1,17 +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 OpenTK; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; namespace osu.Game.Graphics.UserInterface { public class BreadcrumbControl : OsuTabControl { - public static readonly float padding = 10; + public const float padding = 10; protected override TabItem CreateTabItem(T value) => new BreadcrumbTabItem(value); @@ -23,8 +21,6 @@ namespace osu.Game.Graphics.UserInterface { foreach (TabItem t in TabContainer.Children) { - if (!(t is BreadcrumbTabItem)) return; - var tIndex = TabContainer.IndexOf(t); var tabIndex = TabContainer.IndexOf(TabMap[tab]); var hide = tIndex < tabIndex; @@ -32,7 +28,7 @@ namespace osu.Game.Graphics.UserInterface t.FadeTo(hide ? 0f : 1f, 500, EasingTypes.OutQuint); t.ScaleTo(new Vector2(hide ? 0.8f : 1f, 1f), 500, EasingTypes.OutQuint); - (t as BreadcrumbTabItem).Chevron.FadeTo(hideChevron ? 0f : 1f, 500, EasingTypes.OutQuint); + ((BreadcrumbTabItem)t).Chevron.FadeTo(hideChevron ? 0f : 1f, 500, EasingTypes.OutQuint); } }; } @@ -42,7 +38,7 @@ namespace osu.Game.Graphics.UserInterface public readonly TextAwesome Chevron; //don't allow clicking between transitions and don't make the chevron clickable - protected override bool InternalContains(Vector2 screenSpacePos) => Alpha < 1f ? false : Text.Contains(screenSpacePos); + protected override bool InternalContains(Vector2 screenSpacePos) => Alpha == 1f && Text.Contains(screenSpacePos); public BreadcrumbTabItem(T value) : base(value) { From c9971bb490a60714279b3b965b4ee4734a8f02c5 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:32:46 -0300 Subject: [PATCH 087/129] Don't store hideChevron --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 3bc94da07b..b19b1c805e 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -24,11 +24,10 @@ namespace osu.Game.Graphics.UserInterface var tIndex = TabContainer.IndexOf(t); var tabIndex = TabContainer.IndexOf(TabMap[tab]); var hide = tIndex < tabIndex; - var hideChevron = tIndex <= tabIndex; t.FadeTo(hide ? 0f : 1f, 500, EasingTypes.OutQuint); t.ScaleTo(new Vector2(hide ? 0.8f : 1f, 1f), 500, EasingTypes.OutQuint); - ((BreadcrumbTabItem)t).Chevron.FadeTo(hideChevron ? 0f : 1f, 500, EasingTypes.OutQuint); + ((BreadcrumbTabItem)t).Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, EasingTypes.OutQuint); } }; } From 33d6b718be955c16a41d9e15b364eb9fae20aceb Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:36:00 -0300 Subject: [PATCH 088/129] padding -> PADDING --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index b19b1c805e..53e8275b56 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -9,14 +9,14 @@ namespace osu.Game.Graphics.UserInterface { public class BreadcrumbControl : OsuTabControl { - public const float padding = 10; + public const float PADDING = 10; protected override TabItem CreateTabItem(T value) => new BreadcrumbTabItem(value); public BreadcrumbControl() { Height = 26; - TabContainer.Spacing = new Vector2(padding, 0f); + TabContainer.Spacing = new Vector2(PADDING, 0f); Current.ValueChanged += tab => { foreach (TabItem t in TabContainer.Children) @@ -42,14 +42,14 @@ namespace osu.Game.Graphics.UserInterface public BreadcrumbTabItem(T value) : base(value) { Text.TextSize = 16; - Padding = new MarginPadding { Right = padding + 8 }; //padding + chevron width + Padding = new MarginPadding { Right = PADDING + 8 }; //padding + chevron width Add(Chevron = new TextAwesome { Anchor = Anchor.CentreRight, Origin = Anchor.CentreLeft, TextSize = 12, Icon = FontAwesome.fa_chevron_right, - Margin = new MarginPadding { Left = padding }, + Margin = new MarginPadding { Left = PADDING }, Alpha = 0f, }); } From 3699c399679a6273d710c33c436d55da5d0b7898 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:46:09 -0300 Subject: [PATCH 089/129] PADDING -> padding, make private --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 53e8275b56..8fb0affe8d 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -9,14 +9,14 @@ namespace osu.Game.Graphics.UserInterface { public class BreadcrumbControl : OsuTabControl { - public const float PADDING = 10; + private const float padding = 10; protected override TabItem CreateTabItem(T value) => new BreadcrumbTabItem(value); public BreadcrumbControl() { Height = 26; - TabContainer.Spacing = new Vector2(PADDING, 0f); + TabContainer.Spacing = new Vector2(padding, 0f); Current.ValueChanged += tab => { foreach (TabItem t in TabContainer.Children) @@ -42,14 +42,14 @@ namespace osu.Game.Graphics.UserInterface public BreadcrumbTabItem(T value) : base(value) { Text.TextSize = 16; - Padding = new MarginPadding { Right = PADDING + 8 }; //padding + chevron width + Padding = new MarginPadding { Right = padding + 8 }; //padding + chevron width Add(Chevron = new TextAwesome { Anchor = Anchor.CentreRight, Origin = Anchor.CentreLeft, TextSize = 12, Icon = FontAwesome.fa_chevron_right, - Margin = new MarginPadding { Left = PADDING }, + Margin = new MarginPadding { Left = padding }, Alpha = 0f, }); } From 731c15f91afa2cccfce8355b9f872c020202d639 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 27 May 2017 13:24:02 +0900 Subject: [PATCH 090/129] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index ea5a2a7e1a..16da101e76 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit ea5a2a7e1abffb1515c020fd017b583b71780316 +Subproject commit 16da101e76389f6b227fde511ddda8c8783f55ec From e86ccf61b3f70dfd8a22d4838d6789d2d8f94b4c Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 27 May 2017 09:52:02 +0200 Subject: [PATCH 091/129] use recursion --- osu.Game/Overlays/Mods/ModButton.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index e1545ab1b8..70197ba444 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -71,13 +71,11 @@ namespace osu.Game.Overlays.Mods { foregroundIcon.RotateTo(15f, mod_switch_duration, mod_switch_easing); backgroundIcon.RotateTo(-15f, mod_switch_duration, mod_switch_easing); - using (foregroundIcon.BeginDelayedSequence(mod_switch_duration)) + using (iconsContainer.BeginDelayedSequence(mod_switch_duration, true)) { foregroundIcon.RotateTo(-15f); foregroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); - } - using (backgroundIcon.BeginDelayedSequence(mod_switch_duration)) - { + backgroundIcon.RotateTo(15f); backgroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); } From 330bd4e11dc48205c11aff8f2839c6efe791a1b4 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Sat, 27 May 2017 20:22:19 +0900 Subject: [PATCH 092/129] Fix osu!direct hotkey overriding drawings hotkey (for now). --- osu.Game/OsuGame.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 886ff4f8d1..2c952ee514 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -255,6 +255,9 @@ namespace osu.Game settings.ToggleVisibility(); return true; case Key.D: + if (state.Keyboard.ShiftPressed || state.Keyboard.AltPressed) + return false; + direct.ToggleVisibility(); return true; } From e7087f22ea73394382f154ae6d24572feaf443a3 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 27 May 2017 17:27:11 -0300 Subject: [PATCH 093/129] Change UserPanel test case data to use always available covers --- osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs index 513bf24e0d..92d58c10c9 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs @@ -32,14 +32,14 @@ namespace osu.Desktop.VisualTests.Tests Username = @"flyte", Id = 3103765, Country = new Country { FlagName = @"JP" }, - CoverUrl = @"https://assets.ppy.sh/user-profile-covers/3103765/5b012e13611d5761caa7e24fecb3d3a16e1cf48fc2a3032cfd43dd444af83d82.jpeg" + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg" }) { Width = 300 }, peppy = new UserPanel(new User { Username = @"peppy", Id = 2, Country = new Country { FlagName = @"AU" }, - CoverUrl = @"https://assets.ppy.sh/user-profile-covers/2/08cad88747c235a64fca5f1b770e100f120827ded1ffe3b66bfcd19c940afa65.jpeg" + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg" }) { Width = 300 }, }, }); From d4a9813af9cbd12b04df6d5b4f5e81ef16b41028 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 27 May 2017 18:19:09 -0300 Subject: [PATCH 094/129] Cleanup BreadcrumbTabItem visibility code --- .../UserInterface/BreadcrumbControl.cs | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 8fb0affe8d..1c303ee175 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -2,7 +2,9 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; +using osu.Framework; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; namespace osu.Game.Graphics.UserInterface @@ -23,21 +25,44 @@ namespace osu.Game.Graphics.UserInterface { var tIndex = TabContainer.IndexOf(t); var tabIndex = TabContainer.IndexOf(TabMap[tab]); - var hide = tIndex < tabIndex; - t.FadeTo(hide ? 0f : 1f, 500, EasingTypes.OutQuint); - t.ScaleTo(new Vector2(hide ? 0.8f : 1f, 1f), 500, EasingTypes.OutQuint); + ((BreadcrumbTabItem)t).State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible; ((BreadcrumbTabItem)t).Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, EasingTypes.OutQuint); } }; } - private class BreadcrumbTabItem : OsuTabItem + private class BreadcrumbTabItem : OsuTabItem, IStateful { public readonly TextAwesome Chevron; //don't allow clicking between transitions and don't make the chevron clickable protected override bool InternalContains(Vector2 screenSpacePos) => Alpha == 1f && Text.Contains(screenSpacePos); + public override bool HandleInput => State == Visibility.Visible; + + private Visibility state; + public Visibility State + { + get { return state; } + set + { + if (value == state) return; + state = value; + + const float transition_duration = 500; + + if (State == Visibility.Visible) + { + FadeIn(transition_duration, EasingTypes.OutQuint); + ScaleTo(new Vector2(1f), transition_duration, EasingTypes.OutQuint); + } + else + { + FadeOut(transition_duration, EasingTypes.OutQuint); + ScaleTo(new Vector2(0.8f, 1f), transition_duration, EasingTypes.OutQuint); + } + } + } public BreadcrumbTabItem(T value) : base(value) { From bdeaf2dbb4a6a3a285f089c957b50746954bb906 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 28 May 2017 18:34:12 +0900 Subject: [PATCH 095/129] Update method names in line with framework changes --- osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs | 4 ++-- osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs | 2 +- osu.Game/Overlays/Dialog/PopupDialog.cs | 4 ++-- osu.Game/Screens/Menu/ButtonSystem.cs | 8 ++++---- osu.Game/Screens/Play/FailOverlay.cs | 2 +- osu.Game/Screens/Play/KeyCounterCollection.cs | 8 ++++---- osu.Game/Screens/Play/PauseContainer.cs | 2 +- osu.Game/Screens/Play/SkipButton.cs | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 9dcba02849..18857b137b 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -80,7 +80,7 @@ namespace osu.Desktop.VisualTests.Tests private void triggerKeyDown(Column column) { - column.TriggerKeyDown(new InputState(), new KeyDownEventArgs + column.TriggerOnKeyDown(new InputState(), new KeyDownEventArgs { Key = column.Key, Repeat = false @@ -89,7 +89,7 @@ namespace osu.Desktop.VisualTests.Tests private void triggerKeyUp(Column column) { - column.TriggerKeyUp(new InputState(), new KeyUpEventArgs + column.TriggerOnKeyUp(new InputState(), new KeyUpEventArgs { Key = column.Key }); diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs index f2ae47354e..a758d5fdef 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs @@ -74,7 +74,7 @@ namespace osu.Game.Graphics.UserInterface.Volume return; } - volumeMeterMaster.TriggerWheel(state); + volumeMeterMaster.TriggerOnWheel(state); } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/Dialog/PopupDialog.cs b/osu.Game/Overlays/Dialog/PopupDialog.cs index 47674de817..42819f7f87 100644 --- a/osu.Game/Overlays/Dialog/PopupDialog.cs +++ b/osu.Game/Overlays/Dialog/PopupDialog.cs @@ -71,7 +71,7 @@ namespace osu.Game.Overlays.Dialog private void pressButtonAtIndex(int index) { if (index < Buttons.Count()) - Buttons.Skip(index).First().TriggerClick(); + Buttons.Skip(index).First().TriggerOnClick(); } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) @@ -80,7 +80,7 @@ namespace osu.Game.Overlays.Dialog if (args.Key == Key.Enter) { - Buttons.OfType().FirstOrDefault()?.TriggerClick(); + Buttons.OfType().FirstOrDefault()?.TriggerOnClick(); return true; } diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 72db445052..52039a8417 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -135,7 +135,7 @@ namespace osu.Game.Screens.Menu switch (args.Key) { case Key.Space: - osuLogo.TriggerClick(state); + osuLogo.TriggerOnClick(state); return true; case Key.Escape: switch (State) @@ -144,7 +144,7 @@ namespace osu.Game.Screens.Menu State = MenuState.Initial; return true; case MenuState.Play: - backButton.TriggerClick(); + backButton.TriggerOnClick(); return true; } @@ -178,10 +178,10 @@ namespace osu.Game.Screens.Menu State = MenuState.TopLevel; return; case MenuState.TopLevel: - buttonsTopLevel.First().TriggerClick(); + buttonsTopLevel.First().TriggerOnClick(); return; case MenuState.Play: - buttonsPlay.First().TriggerClick(); + buttonsPlay.First().TriggerOnClick(); return; } } diff --git a/osu.Game/Screens/Play/FailOverlay.cs b/osu.Game/Screens/Play/FailOverlay.cs index faff687ddb..3e31da2348 100644 --- a/osu.Game/Screens/Play/FailOverlay.cs +++ b/osu.Game/Screens/Play/FailOverlay.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Play { if (!args.Repeat && args.Key == Key.Escape) { - Buttons.Children.Last().TriggerClick(); + Buttons.Children.Last().TriggerOnClick(); return true; } diff --git a/osu.Game/Screens/Play/KeyCounterCollection.cs b/osu.Game/Screens/Play/KeyCounterCollection.cs index 6e1c8a34e5..25cbfc14b7 100644 --- a/osu.Game/Screens/Play/KeyCounterCollection.cs +++ b/osu.Game/Screens/Play/KeyCounterCollection.cs @@ -131,13 +131,13 @@ namespace osu.Game.Screens.Play public override bool HandleInput => true; - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) => target.Children.Any(c => c.TriggerKeyDown(state, args)); + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) => target.Children.Any(c => c.TriggerOnKeyDown(state, args)); - protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) => target.Children.Any(c => c.TriggerKeyUp(state, args)); + protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) => target.Children.Any(c => c.TriggerOnKeyUp(state, args)); - protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => target.Children.Any(c => c.TriggerMouseDown(state, args)); + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => target.Children.Any(c => c.TriggerOnMouseDown(state, args)); - protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) => target.Children.Any(c => c.TriggerMouseUp(state, args)); + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) => target.Children.Any(c => c.TriggerOnMouseUp(state, args)); } } } diff --git a/osu.Game/Screens/Play/PauseContainer.cs b/osu.Game/Screens/Play/PauseContainer.cs index 1de62048b7..f052bafd63 100644 --- a/osu.Game/Screens/Play/PauseContainer.cs +++ b/osu.Game/Screens/Play/PauseContainer.cs @@ -136,7 +136,7 @@ namespace osu.Game.Screens.Play { if (!args.Repeat && args.Key == Key.Escape) { - Buttons.Children.First().TriggerClick(); + Buttons.Children.First().TriggerOnClick(); return true; } diff --git a/osu.Game/Screens/Play/SkipButton.cs b/osu.Game/Screens/Play/SkipButton.cs index 86bbb26412..ee11fc0ca6 100644 --- a/osu.Game/Screens/Play/SkipButton.cs +++ b/osu.Game/Screens/Play/SkipButton.cs @@ -127,7 +127,7 @@ namespace osu.Game.Screens.Play switch (args.Key) { case Key.Space: - button.TriggerClick(); + button.TriggerOnClick(); return true; } From d749fc516dbafb9d3406f57c91a2e152ed930d8c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 28 May 2017 20:08:46 +0900 Subject: [PATCH 096/129] Update focus handling in line with framework changes --- .../Graphics/UserInterface/FocusedTextBox.cs | 13 +++++++++++-- osu.Game/Overlays/ChatOverlay.cs | 2 +- osu.Game/Overlays/DirectOverlay.cs | 2 +- osu.Game/Overlays/LoginOverlay.cs | 3 ++- osu.Game/Overlays/Music/PlaylistOverlay.cs | 7 +++++-- .../Settings/Sections/General/LoginSettings.cs | 17 +++++++++++------ osu.Game/Overlays/SettingsOverlay.cs | 5 +++-- osu.Game/Screens/Select/FilterControl.cs | 11 ++++++++--- 8 files changed, 42 insertions(+), 18 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/FocusedTextBox.cs b/osu.Game/Graphics/UserInterface/FocusedTextBox.cs index 2f53d00c7e..fe1d255bba 100644 --- a/osu.Game/Graphics/UserInterface/FocusedTextBox.cs +++ b/osu.Game/Graphics/UserInterface/FocusedTextBox.cs @@ -3,6 +3,7 @@ using OpenTK.Graphics; using OpenTK.Input; +using osu.Framework.Allocation; using osu.Framework.Input; using System; using System.Linq; @@ -23,11 +24,19 @@ namespace osu.Game.Graphics.UserInterface set { focus = value; - if (!focus) - TriggerFocusLost(); + if (!focus && HasFocus) + inputManager.ChangeFocus(null); } } + private InputManager inputManager; + + [BackgroundDependencyLoader] + private void load(UserInputManager inputManager) + { + this.inputManager = inputManager; + } + protected override bool OnFocus(InputState state) { var result = base.OnFocus(state); diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 686a1d513a..90068eb170 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -165,7 +165,7 @@ namespace osu.Game.Overlays protected override bool OnFocus(InputState state) { //this is necessary as inputTextBox is masked away and therefore can't get focus :( - inputTextBox.TriggerFocus(); + InputManager.ChangeFocus(inputTextBox); return false; } diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 0930c825b6..b1bc7e0c04 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -189,7 +189,7 @@ namespace osu.Game.Overlays protected override bool OnFocus(InputState state) { - filter.Search.TriggerFocus(); + InputManager.ChangeFocus(filter.Search); return false; } diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index e555600028..e2c2148201 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Overlays.Settings.Sections.General; using OpenTK.Graphics; +using osu.Framework.Input; namespace osu.Game.Overlays { @@ -66,7 +67,7 @@ namespace osu.Game.Overlays settingsSection.Bounding = true; FadeIn(transition_time, EasingTypes.OutQuint); - settingsSection.TriggerFocus(); + InputManager.ChangeFocus(settingsSection); } protected override void PopOut() diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 5e433aa414..82596252b3 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -17,6 +17,7 @@ using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; using osu.Framework.Extensions; +using osu.Framework.Input; namespace osu.Game.Overlays.Music { @@ -35,10 +36,12 @@ namespace osu.Game.Overlays.Music private readonly Bindable beatmapBacking = new Bindable(); public IEnumerable BeatmapSets; + private InputManager inputManager; [BackgroundDependencyLoader] - private void load(OsuGameBase game, BeatmapDatabase beatmaps, OsuColour colours) + private void load(OsuGameBase game, BeatmapDatabase beatmaps, OsuColour colours, UserInputManager inputManager) { + this.inputManager = inputManager; this.beatmaps = beatmaps; trackManager = game.Audio.Track; @@ -100,7 +103,7 @@ namespace osu.Game.Overlays.Music protected override void PopIn() { filter.Search.HoldFocus = true; - Schedule(() => filter.Search.TriggerFocus()); + Schedule(() => inputManager.ChangeFocus(filter.Search)); ResizeTo(new Vector2(1, playlist_height), transition_duration, EasingTypes.OutQuint); FadeIn(transition_duration, EasingTypes.OutQuint); diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 561f81d6c3..c22a6e7411 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -51,9 +51,12 @@ namespace osu.Game.Overlays.Settings.Sections.General Spacing = new Vector2(0f, 5f); } + private InputManager inputManager; + [BackgroundDependencyLoader(permitNulls: true)] - private void load(OsuColour colours, APIAccess api) + private void load(OsuColour colours, APIAccess api, UserInputManager inputManager) { + this.inputManager = inputManager; this.colours = colours; api?.Register(this); } @@ -160,12 +163,12 @@ namespace osu.Game.Overlays.Settings.Sections.General break; } - form?.TriggerFocus(); + if (form != null) inputManager.ChangeFocus(form); } protected override bool OnFocus(InputState state) { - form?.TriggerFocus(); + if (form != null) inputManager.ChangeFocus(form); return base.OnFocus(state); } @@ -174,6 +177,7 @@ namespace osu.Game.Overlays.Settings.Sections.General private TextBox username; private TextBox password; private APIAccess api; + private InputManager inputManager; private void performLogin() { @@ -182,8 +186,9 @@ namespace osu.Game.Overlays.Settings.Sections.General } [BackgroundDependencyLoader(permitNulls: true)] - private void load(APIAccess api, OsuConfigManager config) + private void load(APIAccess api, OsuConfigManager config, UserInputManager inputManager) { + this.inputManager = inputManager; this.api = api; Direction = FillDirection.Vertical; Spacing = new Vector2(0, 5); @@ -235,9 +240,9 @@ namespace osu.Game.Overlays.Settings.Sections.General Schedule(() => { if (string.IsNullOrEmpty(username.Text)) - username.TriggerFocus(); + inputManager.ChangeFocus(username); else - password.TriggerFocus(); + inputManager.ChangeFocus(password); }); return base.OnFocus(state); diff --git a/osu.Game/Overlays/SettingsOverlay.cs b/osu.Game/Overlays/SettingsOverlay.cs index 943545e858..474631fd1e 100644 --- a/osu.Game/Overlays/SettingsOverlay.cs +++ b/osu.Game/Overlays/SettingsOverlay.cs @@ -134,12 +134,13 @@ namespace osu.Game.Overlays FadeTo(0, TRANSITION_LENGTH / 2); searchTextBox.HoldFocus = false; - searchTextBox.TriggerFocusLost(); + if (searchTextBox.HasFocus) + InputManager.ChangeFocus(null); } protected override bool OnFocus(InputState state) { - searchTextBox.TriggerFocus(state); + InputManager.ChangeFocus(searchTextBox); return false; } diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 7c7863acd1..94bc60a6ca 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -154,7 +154,8 @@ namespace osu.Game.Screens.Select public void Deactivate() { searchTextBox.HoldFocus = false; - searchTextBox.TriggerFocusLost(); + if (searchTextBox.HasFocus) + inputManager.ChangeFocus(searchTextBox); } public void Activate() @@ -164,9 +165,13 @@ namespace osu.Game.Screens.Select private readonly Bindable ruleset = new Bindable(); - [BackgroundDependencyLoader(permitNulls:true)] - private void load(OsuColour colours, OsuGame osu) + private InputManager inputManager; + + [BackgroundDependencyLoader(permitNulls: true)] + private void load(OsuColour colours, OsuGame osu, UserInputManager inputManager) { + this.inputManager = inputManager; + sortTabs.AccentColour = colours.GreenLight; if (osu != null) From 013b4f9b899f12ffeb019d4938d814545d1448ba Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 28 May 2017 21:09:44 +0900 Subject: [PATCH 097/129] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 8baad1b948..91fc2f2906 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 8baad1b9484b9f35724e2f965c18cfe710907d80 +Subproject commit 91fc2f290642eaaa2d365ca02558f92eba9009ca From ed8b34d5edf45e132ada94c6f5f96310955dcf20 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 28 May 2017 21:11:46 +0900 Subject: [PATCH 098/129] Fix drift when dragging chat beyond bounds --- osu.Game/Overlays/ChatOverlay.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 686a1d513a..fec5f11129 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -135,17 +135,20 @@ namespace osu.Game.Overlays channelTabs.Current.ValueChanged += newChannel => CurrentChannel = newChannel; } + private double startDragChatHeight; + protected override bool OnDragStart(InputState state) { - if (channelTabs.Hovering) - return true; + if (!channelTabs.Hovering) + return base.OnDragStart(state); - return base.OnDragStart(state); + startDragChatHeight = chatHeight.Value; + return true; } protected override bool OnDrag(InputState state) { - chatHeight.Value = Height - state.Mouse.Delta.Y / Parent.DrawSize.Y; + chatHeight.Value = startDragChatHeight - (state.Mouse.Position.Y - state.Mouse.PositionMouseDown.Value.Y) / Parent.DrawSize.Y; return base.OnDrag(state); } From 3644198c6e615f46412549f3e2cb1e1a6c148fb6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 28 May 2017 21:20:11 +0900 Subject: [PATCH 099/129] Fix CI issues --- osu.Game/Overlays/LoginOverlay.cs | 1 - .../Overlays/Settings/Sections/General/LoginSettings.cs | 9 +-------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index e2c2148201..c3f41270ce 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Overlays.Settings.Sections.General; using OpenTK.Graphics; -using osu.Framework.Input; namespace osu.Game.Overlays { diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index c22a6e7411..00ca50927e 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -237,14 +237,7 @@ namespace osu.Game.Overlays.Settings.Sections.General protected override bool OnFocus(InputState state) { - Schedule(() => - { - if (string.IsNullOrEmpty(username.Text)) - inputManager.ChangeFocus(username); - else - inputManager.ChangeFocus(password); - }); - + Schedule(() => { inputManager.ChangeFocus(string.IsNullOrEmpty(username.Text) ? username : password); }); return base.OnFocus(state); } } From 18bcec723a4f8fbc4b89421432a0438d4aa7445f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 28 May 2017 21:29:41 +0900 Subject: [PATCH 100/129] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 91fc2f2906..0b9053ec3d 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 91fc2f290642eaaa2d365ca02558f92eba9009ca +Subproject commit 0b9053ec3d39b486165992374752b280c5eeef06 From bc47dedf27d5119243da88c340aebd7231973c74 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 28 May 2017 21:34:15 +0900 Subject: [PATCH 101/129] Add non-null assertion --- osu.Game/Overlays/ChatOverlay.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index fec5f11129..d442fe5db0 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -148,6 +148,8 @@ namespace osu.Game.Overlays protected override bool OnDrag(InputState state) { + Trace.Assert(state.Mouse.PositionMouseDown != null); + chatHeight.Value = startDragChatHeight - (state.Mouse.Position.Y - state.Mouse.PositionMouseDown.Value.Y) / Parent.DrawSize.Y; return base.OnDrag(state); } From 9e5a53aae7c6d3909744303005b0369a761e12b7 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 10:53:55 +0900 Subject: [PATCH 102/129] Fix possible nullrefs. --- osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs b/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs index e65bc4a99f..10f8e846ed 100644 --- a/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs +++ b/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs @@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Objects var hitObjectY = y as DrawableHitObject; // If either of the two drawables are not hit objects, fall back to the base comparer - if ((hitObjectX ?? hitObjectY) == null) + if ((hitObjectX?.HitObject ?? hitObjectY?.HitObject) == null) return base.Compare(x, y); // Compare by start time @@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Objects var hitObjectY = y as DrawableHitObject; // If either of the two drawables are not hit objects, fall back to the base comparer - if ((hitObjectX ?? hitObjectY) == null) + if ((hitObjectX?.HitObject ?? hitObjectY?.HitObject) == null) return base.Compare(x, y); // Compare by start time From cf3743f698c84aca72f19ef9349963b03420b299 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 10:56:42 +0900 Subject: [PATCH 103/129] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 16da101e76..aa3e296968 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 16da101e76389f6b227fde511ddda8c8783f55ec +Subproject commit aa3e296968873208ca4460b00c0b82fe3aa8ff5c From cdf4fcea023d994839d5d2f0582229379e4464e2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 11:07:17 +0900 Subject: [PATCH 104/129] Fix input being reversed. --- osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs index 636c84d9dc..0a8bc2d44a 100644 --- a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs @@ -29,8 +29,6 @@ namespace osu.Game.Rulesets.Mania.Timing private readonly List drawableControlPoints; - protected override IComparer DepthComparer => new HitObjectStartTimeComparer(); - public ControlPointContainer(IEnumerable timingChanges) { drawableControlPoints = timingChanges.Select(t => new DrawableControlPoint(t)).ToList(); @@ -131,6 +129,8 @@ namespace osu.Game.Rulesets.Mania.Timing /// private class AutoTimeRelativeContainer : Container { + protected override IComparer DepthComparer => new HitObjectReverseStartTimeComparer(); + public override void InvalidateFromChild(Invalidation invalidation) { // We only want to re-compute our size when a child's size or position has changed From cd1da469c743784433187adf80a7efe08c7f3fc8 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 11:09:26 +0900 Subject: [PATCH 105/129] Cleanup + actually fix possible nullrefs. --- osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs b/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs index 10f8e846ed..b089856dcb 100644 --- a/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs +++ b/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs @@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Objects var hitObjectY = y as DrawableHitObject; // If either of the two drawables are not hit objects, fall back to the base comparer - if ((hitObjectX?.HitObject ?? hitObjectY?.HitObject) == null) + if (hitObjectX?.HitObject == null || hitObjectY?.HitObject == null) return base.Compare(x, y); // Compare by start time @@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Objects var hitObjectY = y as DrawableHitObject; // If either of the two drawables are not hit objects, fall back to the base comparer - if ((hitObjectX?.HitObject ?? hitObjectY?.HitObject) == null) + if (hitObjectX?.HitObject == null || hitObjectY?.HitObject == null) return base.Compare(x, y); // Compare by start time From e5e73b31b61c932fc39408e5a650369a4ad3cd6d Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 11:42:43 +0900 Subject: [PATCH 106/129] Cleanup + slight xmldoc improvements. --- .../Scoring/ManiaScoreProcessor.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index 12c8386ae7..95c5c58d51 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -105,6 +105,16 @@ namespace osu.Game.Rulesets.Mania.Scoring /// private const double hp_increase_miss = -0.125; + /// + /// The MISS HP multiplier. This is multiplied to the miss hp increase. + /// + private double hpMissMultiplier = 1; + + /// + /// The HIT HP multiplier. This is multiplied to hit hp increases. + /// + private double hpMultiplier = 1; + /// /// The cumulative combo portion of the score. /// @@ -141,16 +151,6 @@ namespace osu.Game.Rulesets.Mania.Scoring /// private int totalHits; - /// - /// The MISS HP multiplier. - /// - private double hpMissMultiplier = 1; - - /// - /// The HIT HP multiplier. - /// - private double hpMultiplier = 1; - public ManiaScoreProcessor() { } From f17b8acd13d5afffc865f543761cfce2680702b3 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 11:45:16 +0900 Subject: [PATCH 107/129] Remove erroneous tab. --- osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index 95c5c58d51..ebf99206ee 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -228,7 +228,7 @@ namespace osu.Game.Rulesets.Mania.Scoring switch (judgement.Result) { case HitResult.Miss: - Health.Value += hpMissMultiplier * hp_increase_miss; + Health.Value += hpMissMultiplier * hp_increase_miss; break; case HitResult.Hit: if (isTick) From e63108bd75ecdf69169432aeb2bcfdc0e43b76b3 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 11:56:31 +0900 Subject: [PATCH 108/129] Add base for bar lines. --- osu.Game.Rulesets.Mania/Objects/Barline.cs | 9 +++++++++ .../Objects/Drawables/DrawableBarline.cs | 7 +++++++ .../Objects/Drawables/DrawableMajorBarline.cs | 7 +++++++ osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj | 3 +++ 4 files changed, 26 insertions(+) create mode 100644 osu.Game.Rulesets.Mania/Objects/Barline.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs diff --git a/osu.Game.Rulesets.Mania/Objects/Barline.cs b/osu.Game.Rulesets.Mania/Objects/Barline.cs new file mode 100644 index 0000000000..a9ce0559dc --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Barline.cs @@ -0,0 +1,9 @@ +using osu.Game.Rulesets.Objects; + +namespace osu.Game.Rulesets.Mania.Objects +{ + public class Barline : HitObject + { + public bool IsMajor; + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs new file mode 100644 index 0000000000..605b9f83df --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs @@ -0,0 +1,7 @@ +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + public class DrawableBarline + { + + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs new file mode 100644 index 0000000000..607cc66012 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs @@ -0,0 +1,7 @@ +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + public class DrawableMajorBarline + { + + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 7a8ec25fe4..b45ce3c5df 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -62,6 +62,8 @@ + + @@ -70,6 +72,7 @@ + From 6101fe98e1df4a7cf2e3f1dae39aae021facccf5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 12:10:29 +0900 Subject: [PATCH 109/129] Always ApplyDefaults after parsing beatmaps to make sure hit objects are in their most loaded state. --- osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs | 3 ++ .../Rulesets/Objects/Legacy/ConvertSlider.cs | 34 +++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs index cb1d9d2fcd..c6aac3bb71 100644 --- a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs @@ -428,6 +428,9 @@ namespace osu.Game.Beatmaps.Formats break; } } + + foreach (var hitObject in beatmap.HitObjects) + hitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.Difficulty); } internal enum LegacySampleBank diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs index 7580404e81..ddee0c3154 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs @@ -6,20 +6,36 @@ using System; using System.Collections.Generic; using OpenTK; using osu.Game.Audio; +using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Database; namespace osu.Game.Rulesets.Objects.Legacy { internal abstract class ConvertSlider : HitObject, IHasCurve { + /// + /// Scoring distance with a speed-adjusted beat length of 1 second. + /// + private const float base_scoring_distance = 100; + + public readonly SliderCurve Curve = new SliderCurve(); + public List ControlPoints { get; set; } public CurveType CurveType { get; set; } - public double Distance { get; set; } + + public double Distance + { + get { return Curve.Distance; } + set { Curve.Distance = value; } + } public List RepeatSamples { get; set; } public int RepeatCount { get; set; } = 1; - public double EndTime { get; set; } - public double Duration { get; set; } + public double EndTime => StartTime + RepeatCount * Curve.Distance / Velocity; + public double Duration => EndTime - StartTime; + + public double Velocity; public Vector2 PositionAt(double progress) { @@ -35,5 +51,17 @@ namespace osu.Game.Rulesets.Objects.Legacy { throw new NotImplementedException(); } + + public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) + { + base.ApplyDefaults(controlPointInfo, difficulty); + + TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); + DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime); + + double scoringDistance = base_scoring_distance * difficulty.SliderMultiplier / difficultyPoint.SpeedMultiplier; + + Velocity = scoringDistance / timingPoint.BeatLength; + } } } From 231b1ae6102f18651a45120c69888c31b22246af Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 12:19:38 +0900 Subject: [PATCH 110/129] We don't need a curve. --- osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs index ddee0c3154..b42cd47abb 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs @@ -18,21 +18,15 @@ namespace osu.Game.Rulesets.Objects.Legacy /// private const float base_scoring_distance = 100; - public readonly SliderCurve Curve = new SliderCurve(); - public List ControlPoints { get; set; } public CurveType CurveType { get; set; } - public double Distance - { - get { return Curve.Distance; } - set { Curve.Distance = value; } - } + public double Distance { get; set; } public List RepeatSamples { get; set; } public int RepeatCount { get; set; } = 1; - public double EndTime => StartTime + RepeatCount * Curve.Distance / Velocity; + public double EndTime => StartTime + RepeatCount * Distance / Velocity; public double Duration => EndTime - StartTime; public double Velocity; From c137ee822c98529d3590fdc14f53a976b4bb6fca Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 12:19:51 +0900 Subject: [PATCH 111/129] Give velocity a sane default value. --- osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs index b42cd47abb..8c2aead5ff 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs @@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Objects.Legacy public double EndTime => StartTime + RepeatCount * Distance / Velocity; public double Duration => EndTime - StartTime; - public double Velocity; + public double Velocity = 1; public Vector2 PositionAt(double progress) { From 79d249e5ad428e0fc784e1eaf2a363fcf0873219 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 29 May 2017 13:48:31 +0900 Subject: [PATCH 112/129] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index aa3e296968..0f3db5da09 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit aa3e296968873208ca4460b00c0b82fe3aa8ff5c +Subproject commit 0f3db5da09d0e7c4d2ef3057030e018f34ba536e From ee7158aa9514c47dce10209aee6d84aed8fbdf20 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 14:44:42 +0900 Subject: [PATCH 113/129] Implement bar lines. --- osu.Game.Rulesets.Mania/Objects/Barline.cs | 14 +++- .../Objects/Drawables/DrawableBarline.cs | 69 ++++++++++++++++++- .../Objects/Drawables/DrawableMajorBarline.cs | 7 -- .../UI/ManiaHitRenderer.cs | 29 ++++++++ osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 51 ++++++++++---- .../osu.Game.Rulesets.Mania.csproj | 1 - 6 files changed, 146 insertions(+), 25 deletions(-) delete mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs diff --git a/osu.Game.Rulesets.Mania/Objects/Barline.cs b/osu.Game.Rulesets.Mania/Objects/Barline.cs index a9ce0559dc..9b229a8d52 100644 --- a/osu.Game.Rulesets.Mania/Objects/Barline.cs +++ b/osu.Game.Rulesets.Mania/Objects/Barline.cs @@ -1,9 +1,19 @@ +using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Objects { - public class Barline : HitObject + public class Barline : ManiaHitObject { - public bool IsMajor; + /// + /// The control point which this bar line is part of. + /// + public TimingControlPoint ControlPoint; + + /// + /// The index of the beat which this bar line represents within the control point. + /// This is a "major" beat at % == 0. + /// + public int BeatIndex; } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs index 605b9f83df..eee32a9da3 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs @@ -1,7 +1,72 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using OpenTK; +using OpenTK.Input; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Game.Rulesets.Objects.Drawables; + namespace osu.Game.Rulesets.Mania.Objects.Drawables { - public class DrawableBarline + /// + /// Visualises a . Although this derives DrawableManiaHitObject, + /// this does not handle input/sound like a normal hit object. + /// + public class DrawableBarline : DrawableManiaHitObject { - + public DrawableBarline(Barline hitObject) + : base(hitObject, null) + { + AutoSizeAxes = Axes.Y; + RelativeSizeAxes = Axes.X; + + Add(new Box + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Height = 1 + }); + + int signatureRelativeIndex = hitObject.BeatIndex % (int)hitObject.ControlPoint.TimeSignature; + + switch (signatureRelativeIndex) + { + case 0: + Add(new EquilateralTriangle + { + Name = "Left triangle", + Anchor = Anchor.BottomLeft, + Origin = Anchor.TopCentre, + Size = new Vector2(12), + X = -9, + Rotation = 90, + BypassAutoSizeAxes = Axes.Both + }); + + Add(new EquilateralTriangle + { + Name = "Right triangle", + Anchor = Anchor.BottomRight, + Origin = Anchor.TopCentre, + Size = new Vector2(12), + X = 9, + Rotation = -90, + BypassAutoSizeAxes = Axes.Both, + }); + break; + case 1: + case 3: + Alpha = 0.2f; + break; + } + } + + protected override void UpdateState(ArmedState state) + { + } } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs deleted file mode 100644 index 607cc66012..0000000000 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace osu.Game.Rulesets.Mania.Objects.Drawables -{ - public class DrawableMajorBarline - { - - } -} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 95b7979e43..871306b98c 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -6,9 +6,11 @@ using System.Collections.Generic; using System.Linq; using OpenTK; using OpenTK.Input; +using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Lists; +using osu.Framework.MathUtils; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Beatmaps; @@ -85,6 +87,33 @@ namespace osu.Game.Rulesets.Mania.UI }; } + [BackgroundDependencyLoader] + private void load() + { + var maniaPlayfield = (ManiaPlayfield)Playfield; + + double lastObjectTime = (Objects.LastOrDefault() as IHasEndTime)?.EndTime ?? Objects.LastOrDefault()?.StartTime ?? double.MaxValue; + + SortedList timingPoints = Beatmap.ControlPointInfo.TimingPoints; + for (int i = 0; i < timingPoints.Count; i++) + { + TimingControlPoint point = timingPoints[i]; + + double endTime = i < timingPoints.Count - 1 ? timingPoints[i + 1].Time - point.BeatLength : lastObjectTime + point.BeatLength * (int)point.TimeSignature; + + int index = 0; + for (double t = timingPoints[i].Time; Precision.DefinitelyBigger(endTime, t); t += point.BeatLength, index++) + { + maniaPlayfield.Add(new DrawableBarline(new Barline + { + StartTime = t, + ControlPoint = point, + BeatIndex = index + })); + } + } + } + public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this); protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(); diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index ff763f87c4..dcf725e091 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -21,6 +21,7 @@ using osu.Game.Rulesets.Mania.Timing; using osu.Framework.Input; using osu.Framework.Graphics.Transforms; using osu.Framework.MathUtils; +using osu.Game.Rulesets.Mania.Objects.Drawables; namespace osu.Game.Rulesets.Mania.UI { @@ -77,27 +78,40 @@ namespace osu.Game.Rulesets.Mania.UI { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - RelativeSizeAxes = Axes.Y, - AutoSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Both, Masking = true, Children = new Drawable[] { - new Box + new Container { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black - }, - columns = new FillFlowContainer - { - Name = "Columns", + Name = "Masked elements", + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, - Direction = FillDirection.Horizontal, - Padding = new MarginPadding { Left = 1, Right = 1 }, - Spacing = new Vector2(1, 0) + Masking = true, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black + }, + columns = new FillFlowContainer + { + Name = "Columns", + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Direction = FillDirection.Horizontal, + Padding = new MarginPadding { Left = 1, Right = 1 }, + Spacing = new Vector2(1, 0) + } + } }, new Container { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Top = HIT_TARGET_POSITION }, Children = new[] @@ -105,7 +119,10 @@ namespace osu.Game.Rulesets.Mania.UI barlineContainer = new ControlPointContainer(timingChanges) { Name = "Bar lines", - RelativeSizeAxes = Axes.Both, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.Y + // Width is set in the Update method } } } @@ -190,6 +207,7 @@ namespace osu.Game.Rulesets.Mania.UI } public override void Add(DrawableHitObject h) => Columns.ElementAt(h.HitObject.Column).Add(h); + public void Add(DrawableBarline barline) => barlineContainer.Add(barline); protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { @@ -234,6 +252,13 @@ namespace osu.Game.Rulesets.Mania.UI TransformTo(() => TimeSpan, newTimeSpan, duration, easing, new TransformTimeSpan()); } + protected override void Update() + { + // Due to masking differences, it is not possible to get the width of the columns container automatically + // While masking on effectively only the Y-axis, so we need to set the width of the bar line container manually + barlineContainer.Width = columns.Width; + } + private class TransformTimeSpan : Transform { public override double CurrentValue diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index b45ce3c5df..cc5e6dd81e 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -63,7 +63,6 @@ - From 44f1d906eac658aa586e1bc2ec326a8194f74f64 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 14:47:51 +0900 Subject: [PATCH 114/129] Store tick count locally, remove HoldNote TickCount. --- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 5 ----- osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs | 8 ++++++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index 3550d561c1..3d988d9dda 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -61,11 +61,6 @@ namespace osu.Game.Rulesets.Mania.Objects tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate; } - /// - /// Total number of hold note ticks. - /// - public int TotalTicks => Ticks.Count(); - /// /// The scoring scoring ticks of the hold note. /// diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index ebf99206ee..798d4b8c5b 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Linq; using osu.Game.Beatmaps; using osu.Game.Database; using osu.Game.Rulesets.Mania.Judgements; @@ -170,6 +171,8 @@ namespace osu.Game.Rulesets.Mania.Scoring { foreach (var obj in beatmap.HitObjects) { + var holdNote = obj as HoldNote; + if (obj is Note) { AddJudgement(new ManiaJudgement @@ -178,7 +181,7 @@ namespace osu.Game.Rulesets.Mania.Scoring ManiaResult = ManiaHitResult.Perfect }); } - else if (obj is HoldNote) + else if (holdNote != null) { // Head AddJudgement(new ManiaJudgement @@ -188,7 +191,8 @@ namespace osu.Game.Rulesets.Mania.Scoring }); // Ticks - for (int i = 0; i < ((HoldNote)obj).TotalTicks; i++) + int tickCount = holdNote.Ticks.Count(); + for (int i = 0; i < tickCount; i++) { AddJudgement(new HoldNoteTickJudgement { From 4fce0c11891fdc8fbc7457391a8b9d406574e785 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 15:01:13 +0900 Subject: [PATCH 115/129] Rename Barline -> BarLine. --- osu.Game.Rulesets.Mania/Objects/{Barline.cs => BarLine.cs} | 2 +- .../Drawables/{DrawableBarline.cs => DrawableBarLine.cs} | 6 +++--- osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs | 2 +- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 2 +- osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) rename osu.Game.Rulesets.Mania/Objects/{Barline.cs => BarLine.cs} (92%) rename osu.Game.Rulesets.Mania/Objects/Drawables/{DrawableBarline.cs => DrawableBarLine.cs} (92%) diff --git a/osu.Game.Rulesets.Mania/Objects/Barline.cs b/osu.Game.Rulesets.Mania/Objects/BarLine.cs similarity index 92% rename from osu.Game.Rulesets.Mania/Objects/Barline.cs rename to osu.Game.Rulesets.Mania/Objects/BarLine.cs index 9b229a8d52..b635977fd1 100644 --- a/osu.Game.Rulesets.Mania/Objects/Barline.cs +++ b/osu.Game.Rulesets.Mania/Objects/BarLine.cs @@ -3,7 +3,7 @@ using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Objects { - public class Barline : ManiaHitObject + public class BarLine : ManiaHitObject { /// /// The control point which this bar line is part of. diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs similarity index 92% rename from osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs rename to osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs index eee32a9da3..9b1e1e4e3d 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs @@ -12,12 +12,12 @@ using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Mania.Objects.Drawables { /// - /// Visualises a . Although this derives DrawableManiaHitObject, + /// Visualises a . Although this derives DrawableManiaHitObject, /// this does not handle input/sound like a normal hit object. /// - public class DrawableBarline : DrawableManiaHitObject + public class DrawableBarLine : DrawableManiaHitObject { - public DrawableBarline(Barline hitObject) + public DrawableBarLine(BarLine hitObject) : base(hitObject, null) { AutoSizeAxes = Axes.Y; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 871306b98c..4ddb7ad42a 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -104,7 +104,7 @@ namespace osu.Game.Rulesets.Mania.UI int index = 0; for (double t = timingPoints[i].Time; Precision.DefinitelyBigger(endTime, t); t += point.BeatLength, index++) { - maniaPlayfield.Add(new DrawableBarline(new Barline + maniaPlayfield.Add(new DrawableBarLine(new BarLine { StartTime = t, ControlPoint = point, diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index dcf725e091..d1b6fbaf7c 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -207,7 +207,7 @@ namespace osu.Game.Rulesets.Mania.UI } public override void Add(DrawableHitObject h) => Columns.ElementAt(h.HitObject.Column).Add(h); - public void Add(DrawableBarline barline) => barlineContainer.Add(barline); + public void Add(DrawableBarLine barline) => barlineContainer.Add(barline); protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index cc5e6dd81e..3d5614bd90 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -62,7 +62,7 @@ - + @@ -71,7 +71,7 @@ - + From 32550bda4f796c9b8f4694a77d7a3348fb967052 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 15:18:06 +0900 Subject: [PATCH 116/129] Make drawable bar line a bit more sane. --- .../Objects/Drawables/DrawableBarLine.cs | 57 +++++++++---------- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 10 ++-- 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs index 9b1e1e4e3d..e253989ebc 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs @@ -17,8 +17,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables /// public class DrawableBarLine : DrawableManiaHitObject { - public DrawableBarLine(BarLine hitObject) - : base(hitObject, null) + public DrawableBarLine(BarLine barLine) + : base(barLine, null) { AutoSizeAxes = Axes.Y; RelativeSizeAxes = Axes.X; @@ -31,38 +31,35 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Height = 1 }); - int signatureRelativeIndex = hitObject.BeatIndex % (int)hitObject.ControlPoint.TimeSignature; + bool isMajor = barLine.BeatIndex % (int)barLine.ControlPoint.TimeSignature == 0; - switch (signatureRelativeIndex) + if (isMajor) { - case 0: - Add(new EquilateralTriangle - { - Name = "Left triangle", - Anchor = Anchor.BottomLeft, - Origin = Anchor.TopCentre, - Size = new Vector2(12), - X = -9, - Rotation = 90, - BypassAutoSizeAxes = Axes.Both - }); + Add(new EquilateralTriangle + { + Name = "Left triangle", + Anchor = Anchor.BottomLeft, + Origin = Anchor.TopCentre, + Size = new Vector2(12), + X = -9, + Rotation = 90, + BypassAutoSizeAxes = Axes.Both + }); - Add(new EquilateralTriangle - { - Name = "Right triangle", - Anchor = Anchor.BottomRight, - Origin = Anchor.TopCentre, - Size = new Vector2(12), - X = 9, - Rotation = -90, - BypassAutoSizeAxes = Axes.Both, - }); - break; - case 1: - case 3: - Alpha = 0.2f; - break; + Add(new EquilateralTriangle + { + Name = "Right triangle", + Anchor = Anchor.BottomRight, + Origin = Anchor.TopCentre, + Size = new Vector2(12), + X = 9, + Rotation = -90, + BypassAutoSizeAxes = Axes.Both, + }); } + + if (!isMajor && barLine.BeatIndex % 2 == 1) + Alpha = 0.2f; } protected override void UpdateState(ArmedState state) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index d1b6fbaf7c..2e6b63579e 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -58,7 +58,7 @@ namespace osu.Game.Rulesets.Mania.UI private readonly FlowContainer columns; public IEnumerable Columns => columns.Children; - private readonly ControlPointContainer barlineContainer; + private readonly ControlPointContainer barLineContainer; private List normalColumnColours = new List(); private Color4 specialColumnColour; @@ -116,7 +116,7 @@ namespace osu.Game.Rulesets.Mania.UI Padding = new MarginPadding { Top = HIT_TARGET_POSITION }, Children = new[] { - barlineContainer = new ControlPointContainer(timingChanges) + barLineContainer = new ControlPointContainer(timingChanges) { Name = "Bar lines", Anchor = Anchor.TopCentre, @@ -207,7 +207,7 @@ namespace osu.Game.Rulesets.Mania.UI } public override void Add(DrawableHitObject h) => Columns.ElementAt(h.HitObject.Column).Add(h); - public void Add(DrawableBarLine barline) => barlineContainer.Add(barline); + public void Add(DrawableBarLine barline) => barLineContainer.Add(barline); protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { @@ -242,7 +242,7 @@ namespace osu.Game.Rulesets.Mania.UI timeSpan = MathHelper.Clamp(timeSpan, time_span_min, time_span_max); - barlineContainer.TimeSpan = value; + barLineContainer.TimeSpan = value; Columns.ForEach(c => c.ControlPointContainer.TimeSpan = value); } } @@ -256,7 +256,7 @@ namespace osu.Game.Rulesets.Mania.UI { // Due to masking differences, it is not possible to get the width of the columns container automatically // While masking on effectively only the Y-axis, so we need to set the width of the bar line container manually - barlineContainer.Width = columns.Width; + barLineContainer.Width = columns.Width; } private class TransformTimeSpan : Transform From 4b6f2efa76a469cf039712fbaed361ad340697d3 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 15:30:05 +0900 Subject: [PATCH 117/129] Cleanups. --- osu.Game.Rulesets.Mania/Objects/BarLine.cs | 3 +- .../Objects/Drawables/DrawableBarLine.cs | 35 +++++++++++-------- .../UI/ManiaHitRenderer.cs | 1 + 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/BarLine.cs b/osu.Game.Rulesets.Mania/Objects/BarLine.cs index b635977fd1..50e326086e 100644 --- a/osu.Game.Rulesets.Mania/Objects/BarLine.cs +++ b/osu.Game.Rulesets.Mania/Objects/BarLine.cs @@ -1,5 +1,4 @@ using osu.Game.Beatmaps.ControlPoints; -using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Objects { @@ -12,7 +11,7 @@ namespace osu.Game.Rulesets.Mania.Objects /// /// The index of the beat which this bar line represents within the control point. - /// This is a "major" beat at % == 0. + /// This is a "major" bar line if % == 0. /// public int BeatIndex; } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs index e253989ebc..7554472507 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs @@ -1,10 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using OpenTK; -using OpenTK.Input; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Objects.Drawables; @@ -17,18 +14,28 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables /// public class DrawableBarLine : DrawableManiaHitObject { + /// + /// Height of major bar line triangles. + /// + private const float triangle_height = 12; + + /// + /// Offset of the major bar line triangles from the sides of the bar line. + /// + private const float triangle_offset = 9; + public DrawableBarLine(BarLine barLine) - : base(barLine, null) + : base(barLine) { - AutoSizeAxes = Axes.Y; RelativeSizeAxes = Axes.X; + Height = 1; Add(new Box { + Name = "Bar line", Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - Height = 1 + RelativeSizeAxes = Axes.Both, }); bool isMajor = barLine.BeatIndex % (int)barLine.ControlPoint.TimeSignature == 0; @@ -40,10 +47,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Name = "Left triangle", Anchor = Anchor.BottomLeft, Origin = Anchor.TopCentre, - Size = new Vector2(12), - X = -9, - Rotation = 90, - BypassAutoSizeAxes = Axes.Both + Size = new Vector2(triangle_height), + X = -triangle_offset, + Rotation = 90 }); Add(new EquilateralTriangle @@ -51,10 +57,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Name = "Right triangle", Anchor = Anchor.BottomRight, Origin = Anchor.TopCentre, - Size = new Vector2(12), - X = 9, - Rotation = -90, - BypassAutoSizeAxes = Axes.Both, + Size = new Vector2(triangle_height), + X = triangle_offset, + Rotation = -90 }); } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 4ddb7ad42a..57477147d5 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -99,6 +99,7 @@ namespace osu.Game.Rulesets.Mania.UI { TimingControlPoint point = timingPoints[i]; + // Stop on the beat before the next timing point, or if there is no next timing point stop slightly past the last object double endTime = i < timingPoints.Count - 1 ? timingPoints[i + 1].Time - point.BeatLength : lastObjectTime + point.BeatLength * (int)point.TimeSignature; int index = 0; From 0327adcba8e14c3caf78e9390289f7c54f72659d Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 29 May 2017 15:35:50 +0900 Subject: [PATCH 118/129] Update HoldNote.cs --- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index 3d988d9dda..92f570476e 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -1,8 +1,7 @@ -// 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.Collections.Generic; -using System.Linq; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Database; using osu.Game.Rulesets.Objects.Types; From 586fc782cf5ec2da379f518d3924bafe50fd43d5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 16:00:14 +0900 Subject: [PATCH 119/129] Fix line endings. --- osu.Game.Rulesets.Mania/Objects/BarLine.cs | 37 +++-- .../Objects/Drawables/DrawableBarLine.cs | 146 +++++++++--------- 2 files changed, 93 insertions(+), 90 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/BarLine.cs b/osu.Game.Rulesets.Mania/Objects/BarLine.cs index 50e326086e..76a3d3920d 100644 --- a/osu.Game.Rulesets.Mania/Objects/BarLine.cs +++ b/osu.Game.Rulesets.Mania/Objects/BarLine.cs @@ -1,18 +1,21 @@ -using osu.Game.Beatmaps.ControlPoints; - -namespace osu.Game.Rulesets.Mania.Objects -{ - public class BarLine : ManiaHitObject - { - /// - /// The control point which this bar line is part of. - /// - public TimingControlPoint ControlPoint; - - /// - /// The index of the beat which this bar line represents within the control point. - /// This is a "major" bar line if % == 0. - /// - public int BeatIndex; - } +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Beatmaps.ControlPoints; + +namespace osu.Game.Rulesets.Mania.Objects +{ + public class BarLine : ManiaHitObject + { + /// + /// The control point which this bar line is part of. + /// + public TimingControlPoint ControlPoint; + + /// + /// The index of the beat which this bar line represents within the control point. + /// This is a "major" bar line if % == 0. + /// + public int BeatIndex; + } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs index 7554472507..0b4d8b2d4e 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs @@ -1,74 +1,74 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; -using osu.Game.Rulesets.Objects.Drawables; - -namespace osu.Game.Rulesets.Mania.Objects.Drawables -{ - /// - /// Visualises a . Although this derives DrawableManiaHitObject, - /// this does not handle input/sound like a normal hit object. - /// - public class DrawableBarLine : DrawableManiaHitObject - { - /// - /// Height of major bar line triangles. - /// - private const float triangle_height = 12; - - /// - /// Offset of the major bar line triangles from the sides of the bar line. - /// - private const float triangle_offset = 9; - - public DrawableBarLine(BarLine barLine) - : base(barLine) - { - RelativeSizeAxes = Axes.X; - Height = 1; - - Add(new Box - { - Name = "Bar line", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.Both, - }); - - bool isMajor = barLine.BeatIndex % (int)barLine.ControlPoint.TimeSignature == 0; - - if (isMajor) - { - Add(new EquilateralTriangle - { - Name = "Left triangle", - Anchor = Anchor.BottomLeft, - Origin = Anchor.TopCentre, - Size = new Vector2(triangle_height), - X = -triangle_offset, - Rotation = 90 - }); - - Add(new EquilateralTriangle - { - Name = "Right triangle", - Anchor = Anchor.BottomRight, - Origin = Anchor.TopCentre, - Size = new Vector2(triangle_height), - X = triangle_offset, - Rotation = -90 - }); - } - - if (!isMajor && barLine.BeatIndex % 2 == 1) - Alpha = 0.2f; - } - - protected override void UpdateState(ArmedState state) - { - } - } +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Game.Rulesets.Objects.Drawables; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + /// + /// Visualises a . Although this derives DrawableManiaHitObject, + /// this does not handle input/sound like a normal hit object. + /// + public class DrawableBarLine : DrawableManiaHitObject + { + /// + /// Height of major bar line triangles. + /// + private const float triangle_height = 12; + + /// + /// Offset of the major bar line triangles from the sides of the bar line. + /// + private const float triangle_offset = 9; + + public DrawableBarLine(BarLine barLine) + : base(barLine) + { + RelativeSizeAxes = Axes.X; + Height = 1; + + Add(new Box + { + Name = "Bar line", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.Both, + }); + + bool isMajor = barLine.BeatIndex % (int)barLine.ControlPoint.TimeSignature == 0; + + if (isMajor) + { + Add(new EquilateralTriangle + { + Name = "Left triangle", + Anchor = Anchor.BottomLeft, + Origin = Anchor.TopCentre, + Size = new Vector2(triangle_height), + X = -triangle_offset, + Rotation = 90 + }); + + Add(new EquilateralTriangle + { + Name = "Right triangle", + Anchor = Anchor.BottomRight, + Origin = Anchor.TopCentre, + Size = new Vector2(triangle_height), + X = triangle_offset, + Rotation = -90 + }); + } + + if (!isMajor && barLine.BeatIndex % 2 == 1) + Alpha = 0.2f; + } + + protected override void UpdateState(ArmedState state) + { + } + } } \ No newline at end of file From e529ced131563ef930d0eafdc4cf06c3c8026580 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 16:18:01 +0900 Subject: [PATCH 120/129] Fix mania-specific beatmaps not setting samples correctly. --- .../Beatmaps/ManiaBeatmapConverter.cs | 22 ++++++++++++++++++- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 3 +++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 125d8cdded..0ed2a0ba6f 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -13,6 +13,7 @@ using osu.Game.Rulesets.Mania.MathUtils; using osu.Game.Database; using osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy; using OpenTK; +using osu.Game.Audio; namespace osu.Game.Rulesets.Mania.Beatmaps { @@ -161,9 +162,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps pattern.Add(new HoldNote { StartTime = HitObject.StartTime, - Samples = HitObject.Samples, Duration = endTimeData.Duration, Column = column, + Head = { Samples = sampleInfoListAt(HitObject.StartTime) }, + Tail = { Samples = sampleInfoListAt(endTimeData.EndTime) }, }); } else if (positionData != null) @@ -178,6 +180,24 @@ namespace osu.Game.Rulesets.Mania.Beatmaps return pattern; } + + /// + /// Retrieves the sample info list at a point in time. + /// + /// The time to retrieve the sample info list from. + /// + private SampleInfoList sampleInfoListAt(double time) + { + var curveData = HitObject as IHasCurve; + + if (curveData == null) + return HitObject.Samples; + + double segmentTime = (curveData.EndTime - HitObject.StartTime) / curveData.RepeatCount; + + int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime); + return curveData.RepeatSamples[index]; + } } } } diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index c241c4cf41..8cd757734c 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -58,6 +58,9 @@ namespace osu.Game.Rulesets.Mania.Objects TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate; + + Head.ApplyDefaults(controlPointInfo, difficulty); + Tail.ApplyDefaults(controlPointInfo, difficulty); } /// From 718eeb6df8e0ef6be1cfd78f66f9e52461806fb0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 29 May 2017 16:18:07 +0900 Subject: [PATCH 121/129] Use linq to tidy up casting --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 1c303ee175..8d113f4918 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -6,6 +6,7 @@ using osu.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; +using System.Linq; namespace osu.Game.Graphics.UserInterface { @@ -21,13 +22,13 @@ namespace osu.Game.Graphics.UserInterface TabContainer.Spacing = new Vector2(padding, 0f); Current.ValueChanged += tab => { - foreach (TabItem t in TabContainer.Children) + foreach (var t in TabContainer.Children.OfType()) { var tIndex = TabContainer.IndexOf(t); var tabIndex = TabContainer.IndexOf(TabMap[tab]); - ((BreadcrumbTabItem)t).State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible; - ((BreadcrumbTabItem)t).Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, EasingTypes.OutQuint); + t.State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible; + t.Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, EasingTypes.OutQuint); } }; } From 31cc6917bc5b11774a8d557a86902692e9a95e85 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 29 May 2017 17:20:55 +0900 Subject: [PATCH 122/129] Tidy up code, improve transition, add directionality --- osu.Game/Overlays/Mods/ModButton.cs | 57 ++++++++++++++++------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 70197ba444..f13b60a3ca 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -36,59 +36,64 @@ namespace osu.Game.Overlays.Mods public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty; - private const EasingTypes mod_switch_easing = EasingTypes.InOutQuint; - private const double mod_switch_duration = 100; + private const EasingTypes mod_switch_easing = EasingTypes.InOutSine; + private const double mod_switch_duration = 140; - private int _selectedIndex = -1; - private int selectedIndex + // A selected index of -1 means not selected. + private int selectedIndex = -1; + + protected int SelectedIndex { get { - return _selectedIndex; + return selectedIndex; } set { - if (value == _selectedIndex) return; + if (value == selectedIndex) return; bool beforeSelected = Selected; - _selectedIndex = value; + int direction = value < selectedIndex ? -1 : 1; + + selectedIndex = value; if (value >= Mods.Length) - { - _selectedIndex = -1; - } + selectedIndex = -1; else if (value <= -2) - { - _selectedIndex = Mods.Length - 1; - } + selectedIndex = Mods.Length - 1; + if (beforeSelected ^ Selected) { iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic); iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic); + displayMod(SelectedMod ?? Mods[0]); } else { - foregroundIcon.RotateTo(15f, mod_switch_duration, mod_switch_easing); - backgroundIcon.RotateTo(-15f, mod_switch_duration, mod_switch_easing); + const float rotate_angle = 16; + + foregroundIcon.RotateTo(rotate_angle * direction, mod_switch_duration, mod_switch_easing); + backgroundIcon.RotateTo(-rotate_angle * direction, mod_switch_duration, mod_switch_easing); + + backgroundIcon.Icon = SelectedMod.Icon; using (iconsContainer.BeginDelayedSequence(mod_switch_duration, true)) { - foregroundIcon.RotateTo(-15f); + foregroundIcon.RotateTo(-rotate_angle * direction); foregroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); - backgroundIcon.RotateTo(15f); + backgroundIcon.RotateTo(rotate_angle * direction); backgroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); + + iconsContainer.Schedule(() => displayMod(SelectedMod ?? Mods[0])); } } - foregroundIcon.Highlighted = Selected; - if (mod != null) - Scheduler.AddDelayed(() => displayMod(SelectedMod ?? Mods[0]), beforeSelected ^ Selected ? 0 : mod_switch_duration); + foregroundIcon.Highlighted = Selected; } } - public bool Selected => selectedIndex != -1; - + public bool Selected => SelectedIndex != -1; private Color4 selectedColour; public Color4 SelectedColour @@ -139,7 +144,7 @@ namespace osu.Game.Overlays.Mods // the mods from Mod, only multiple if Mod is a MultiMod - public override Mod SelectedMod => Mods.ElementAtOrDefault(selectedIndex); + public override Mod SelectedMod => Mods.ElementAtOrDefault(SelectedIndex); [BackgroundDependencyLoader] private void load(AudioManager audio) @@ -164,19 +169,19 @@ namespace osu.Game.Overlays.Mods public void SelectNext() { - (++selectedIndex == -1 ? sampleOff : sampleOn).Play(); + (++SelectedIndex == -1 ? sampleOff : sampleOn).Play(); Action?.Invoke(SelectedMod); } public void SelectPrevious() { - (--selectedIndex == -1 ? sampleOff : sampleOn).Play(); + (--SelectedIndex == -1 ? sampleOff : sampleOn).Play(); Action?.Invoke(SelectedMod); } public void Deselect() { - selectedIndex = -1; + SelectedIndex = -1; } private void displayMod(Mod mod) From 7960b5cf26ea4209aa57861c83c905e2600a7de0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 29 May 2017 18:03:40 +0900 Subject: [PATCH 123/129] More refactoring Also allows rotation when reaching the end of the available mods. --- osu.Game/Overlays/Mods/ModButton.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index f13b60a3ca..9ff19caff3 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -37,7 +37,7 @@ namespace osu.Game.Overlays.Mods public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty; private const EasingTypes mod_switch_easing = EasingTypes.InOutSine; - private const double mod_switch_duration = 140; + private const double mod_switch_duration = 120; // A selected index of -1 means not selected. private int selectedIndex = -1; @@ -52,31 +52,34 @@ namespace osu.Game.Overlays.Mods { if (value == selectedIndex) return; + int direction = value < selectedIndex ? -1 : 1; bool beforeSelected = Selected; - int direction = value < selectedIndex ? -1 : 1; - - selectedIndex = value; + Mod modBefore = SelectedMod ?? Mods[0]; if (value >= Mods.Length) selectedIndex = -1; - else if (value <= -2) + else if (value < -1) selectedIndex = Mods.Length - 1; + else + selectedIndex = value; - if (beforeSelected ^ Selected) + Mod modAfter = SelectedMod ?? Mods[0]; + + if (beforeSelected != Selected) { iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic); iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic); - displayMod(SelectedMod ?? Mods[0]); } - else + + if (modBefore != modAfter) { const float rotate_angle = 16; foregroundIcon.RotateTo(rotate_angle * direction, mod_switch_duration, mod_switch_easing); backgroundIcon.RotateTo(-rotate_angle * direction, mod_switch_duration, mod_switch_easing); - backgroundIcon.Icon = SelectedMod.Icon; + backgroundIcon.Icon = modAfter.Icon; using (iconsContainer.BeginDelayedSequence(mod_switch_duration, true)) { foregroundIcon.RotateTo(-rotate_angle * direction); @@ -85,7 +88,7 @@ namespace osu.Game.Overlays.Mods backgroundIcon.RotateTo(rotate_angle * direction); backgroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); - iconsContainer.Schedule(() => displayMod(SelectedMod ?? Mods[0])); + iconsContainer.Schedule(() => displayMod(modAfter)); } } From e4b876ff5b7e274a12bb80ab2b3f14384cf09f78 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 29 May 2017 18:10:02 +0900 Subject: [PATCH 124/129] Update ModButton.cs --- osu.Game/Overlays/Mods/ModButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 9ff19caff3..f7df67b66d 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -189,7 +189,7 @@ namespace osu.Game.Overlays.Mods private void displayMod(Mod mod) { - if(backgroundIcon != null) + if (backgroundIcon != null) backgroundIcon.Icon = foregroundIcon.Icon; foregroundIcon.Icon = mod.Icon; text.Text = mod.Name; From 2f063ee41d8e80663a1b6bb316bc74c5ce8a1060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 29 May 2017 18:20:51 +0200 Subject: [PATCH 125/129] Make triangle edges smooth again --- osu.Game/Graphics/Backgrounds/Triangles.cs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index 9a19819af8..2e4fb79079 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -24,6 +24,12 @@ namespace osu.Game.Graphics.Backgrounds { private const float triangle_size = 100; + /// + /// How many screen-space pixels are smoothed over. + /// Same behavior as Sprite's EdgeSmoothness. + /// + private const float edge_smoothness = 1; + public override bool HandleInput => false; public Color4 ColourLight = Color4.White; @@ -211,20 +217,28 @@ namespace osu.Game.Graphics.Backgrounds Shader.Bind(); Texture.TextureGL.Bind(); + Vector2 localInflationAmount = edge_smoothness * DrawInfo.MatrixInverse.ExtractScale().Xy; + foreach (TriangleParticle particle in Parts) { - var offset = new Vector2(particle.Scale * 0.5f, particle.Scale * 0.866f); + var offset = triangle_size * new Vector2(particle.Scale * 0.5f, particle.Scale * 0.866f); + var size = new Vector2(2 * offset.X, offset.Y); 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 + (particle.Position * Size + offset) * DrawInfo.Matrix, + (particle.Position * Size + new Vector2(-offset.X, offset.Y)) * DrawInfo.Matrix ); ColourInfo colourInfo = DrawInfo.Colour; colourInfo.ApplyChild(particle.Colour); - Texture.DrawTriangle(triangle, colourInfo, null, Shared.VertexBatch.Add); + Texture.DrawTriangle( + triangle, + colourInfo, + null, + Shared.VertexBatch.Add, + Vector2.Divide(localInflationAmount, size)); } Shader.Unbind(); From d3f2d480a8b8f637d7b8d65d55523ce338a3e6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 29 May 2017 18:24:17 +0200 Subject: [PATCH 126/129] Fix incorrect triangle state within the first frame --- osu.Game/Graphics/Backgrounds/Triangles.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index 2e4fb79079..dd46713102 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -109,6 +109,8 @@ namespace osu.Game.Graphics.Backgrounds Invalidate(Invalidation.DrawNode, shallPropagate: false); + addTriangles(false); + for (int i = 0; i < parts.Count; i++) { TriangleParticle newParticle = parts[i]; @@ -118,7 +120,6 @@ namespace osu.Game.Graphics.Backgrounds (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; @@ -132,8 +133,6 @@ namespace osu.Game.Graphics.Backgrounds if (bottomPos < 0) parts.RemoveAt(i); } - - addTriangles(false); } private void addTriangles(bool randomY) From db444a61cb466269fa943cfbf69b62ceb857f7f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 29 May 2017 18:30:49 +0200 Subject: [PATCH 127/129] Reduce per-triangle per-frame computation significantly --- osu.Game/Graphics/Backgrounds/Triangles.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index dd46713102..2ecaf9f7c7 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -109,27 +109,27 @@ namespace osu.Game.Graphics.Backgrounds Invalidate(Invalidation.DrawNode, shallPropagate: false); - addTriangles(false); + if (CreateNewTriangles) + addTriangles(false); + + float adjustedAlpha = HideAlphaDiscrepancies ? + // Cubically scale alpha to make it drop off more sharply. + (float)Math.Pow(DrawInfo.Colour.AverageColour.Linear.A, 3) : + 1; + + float movedDistance = ((float)Time.Elapsed / 950) * Velocity * (50 / DrawHeight) / triangleScale; for (int i = 0; i < parts.Count; i++) { TriangleParticle newParticle = parts[i]; - 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); + // Scale moved distance by the size of the triangle. Smaller triangles should move more slowly. + newParticle.Position.Y += -parts[i].Scale * movedDistance; 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.RemoveAt(i); } From 298c0f5757610b92c07ec6a2983c89ccc354a1c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 29 May 2017 19:08:06 +0200 Subject: [PATCH 128/129] Structure velocity code more clearly and avoid redundant parenthesis --- osu.Game/Graphics/Backgrounds/Triangles.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index 2ecaf9f7c7..7a2345a80c 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -23,6 +23,7 @@ namespace osu.Game.Graphics.Backgrounds public class Triangles : Drawable { private const float triangle_size = 100; + private const float base_velocity = 50; /// /// How many screen-space pixels are smoothed over. @@ -117,14 +118,18 @@ namespace osu.Game.Graphics.Backgrounds (float)Math.Pow(DrawInfo.Colour.AverageColour.Linear.A, 3) : 1; - float movedDistance = ((float)Time.Elapsed / 950) * Velocity * (50 / DrawHeight) / triangleScale; + float elapsedSeconds = (float)Time.Elapsed / 1000; + // Since position is relative, the velocity needs to scale inversely with DrawHeight. + // Since we will later multiply by the scale of individual triangles we normalize by + // dividing by triangleScale. + float movedDistance = -elapsedSeconds * Velocity * base_velocity / (DrawHeight * triangleScale); for (int i = 0; i < parts.Count; i++) { TriangleParticle newParticle = parts[i]; // Scale moved distance by the size of the triangle. Smaller triangles should move more slowly. - newParticle.Position.Y += -parts[i].Scale * movedDistance; + newParticle.Position.Y += parts[i].Scale * movedDistance; newParticle.Colour.A = adjustedAlpha; parts[i] = newParticle; From fde579262f085f8382157d197f854a04657406a6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 30 May 2017 09:54:29 +0900 Subject: [PATCH 129/129] User a simpler method to hide the background icon --- osu.Game/Overlays/Chat/ChatTabControl.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index 9c26632a8b..a281cff7db 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -223,8 +223,7 @@ namespace osu.Game.Overlays.Chat Depth = float.MaxValue; Width = 45; - icon.Icon = 0; - icon.X = 0; + icon.Alpha = 0; text.TextSize = 45; textBold.TextSize = 45;