From 2ae3ce8b91e03e201efbb88cb13a862830d3d148 Mon Sep 17 00:00:00 2001 From: naoey Date: Thu, 3 Aug 2017 20:55:52 +0530 Subject: [PATCH 01/17] Add ability to close chat tabs. --- osu.Game/Overlays/Chat/ChatTabControl.cs | 45 +++++++++++++++++++++--- osu.Game/Overlays/ChatOverlay.cs | 12 +++++++ 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index 4ff9169877..b44d50e936 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -16,15 +16,16 @@ using osu.Game.Online.Chat; using OpenTK; using OpenTK.Graphics; using osu.Framework.Configuration; +using System; namespace osu.Game.Overlays.Chat { public class ChatTabControl : OsuTabControl { - protected override TabItem CreateTabItem(Channel value) => new ChannelTabItem(value); - private const float shear_width = 10; + public Action OnRequestLeave; + public readonly Bindable ChannelSelectorActive = new Bindable(); private readonly ChannelTabItem.ChannelSelectorTabItem selectorTab; @@ -49,6 +50,14 @@ namespace osu.Game.Overlays.Chat ChannelSelectorActive.BindTo(selectorTab.Active); } + protected override TabItem CreateTabItem(Channel value) + { + ChannelTabItem tab = new ChannelTabItem(value); + tab.OnRequestClose = () => OnRequestLeave?.Invoke(value); + + return tab; + } + protected override void SelectTab(TabItem tab) { if (tab is ChannelTabItem.ChannelSelectorTabItem) @@ -68,12 +77,17 @@ namespace osu.Game.Overlays.Chat private Color4 backgroundHover; private Color4 backgroundActive; + protected override bool isClosable => !Pinned; + private readonly SpriteText text; private readonly SpriteText textBold; + private readonly Button closeButton; private readonly Box box; private readonly Box highlightBox; private readonly SpriteIcon icon; + public Action OnRequestClose; + private void updateState() { if (Active) @@ -88,6 +102,7 @@ namespace osu.Game.Overlays.Chat { this.ResizeTo(new Vector2(Width, 1.1f), transition_length, Easing.OutQuint); + closeButton?.MoveToX(-5f, 0.5f, EasingTypes.OutElastic); box.FadeColour(backgroundActive, transition_length, Easing.OutQuint); highlightBox.FadeIn(transition_length, Easing.OutQuint); @@ -99,6 +114,7 @@ namespace osu.Game.Overlays.Chat { this.ResizeTo(new Vector2(Width, 1), transition_length, Easing.OutQuint); + closeButton?.MoveToX(5f, 0.5f, EasingTypes.InElastic); box.FadeColour(backgroundInactive, transition_length, Easing.OutQuint); highlightBox.FadeOut(transition_length, Easing.OutQuint); @@ -108,6 +124,8 @@ namespace osu.Game.Overlays.Chat protected override bool OnHover(InputState state) { + closeButton?.FadeIn(1f, EasingTypes.InBounce); + if (!Active) box.FadeColour(backgroundHover, transition_length, Easing.OutQuint); return true; @@ -115,6 +133,7 @@ namespace osu.Game.Overlays.Chat protected override void OnHoverLost(InputState state) { + closeButton?.FadeOut(1f, EasingTypes.OutBounce); updateState(); } @@ -204,13 +223,31 @@ namespace osu.Game.Overlays.Chat Font = @"Exo2.0-Bold", TextSize = 18, }, - } - } + }, + }, }; + + if (isClosable) + { + Add(closeButton = new Button + { + Alpha = 0, + Width = 20, + Height = 20, + Margin = new MarginPadding { Right = 10 }, + Origin = Anchor.CentreRight, + Anchor = Anchor.CentreRight, + Text = @"x", + BackgroundColour = Color4.Transparent, + Action = () => OnRequestClose?.Invoke(), + }); + } } public class ChannelSelectorTabItem : ChannelTabItem { + protected override bool isClosable => false; + public ChannelSelectorTabItem(Channel value) : base(value) { Depth = float.MaxValue; diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 29b7548ada..cc4177edc6 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -160,6 +160,7 @@ namespace osu.Game.Overlays channelTabs = new ChatTabControl { RelativeSizeAxes = Axes.Both, + OnRequestLeave = removeChannel, }, } }, @@ -305,6 +306,7 @@ namespace osu.Game.Overlays addChannel(channels.Find(c => c.Name == @"#lobby")); channelSelection.OnRequestJoin = addChannel; + channelSelection.OnRequestLeave = removeChannel; channelSelection.Sections = new[] { new ChannelSection @@ -391,6 +393,16 @@ namespace osu.Game.Overlays channel.Joined.Value = true; } + private void removeChannel(Channel channel) + { + if (channel == null) return; + + careChannels.Remove(channel); + channelTabs.RemoveItem(channel); + + channel.Joined.Value = false; + } + private void fetchInitialMessages(Channel channel) { var req = new GetMessagesRequest(new List { channel }, null); From 3b6ffadcc7207c24a081df017d64686752bb9893 Mon Sep 17 00:00:00 2001 From: naoey Date: Thu, 3 Aug 2017 22:02:25 +0530 Subject: [PATCH 02/17] Renaming to match framework changes. - IsClosable -> IsRemovable - EasingTypes -> Easing - Also remove all messages on a channel being un-joined --- osu.Game/Overlays/Chat/ChatTabControl.cs | 14 +++++++------- osu.Game/Overlays/Chat/DrawableChannel.cs | 7 +++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index b44d50e936..735a37e334 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -77,7 +77,7 @@ namespace osu.Game.Overlays.Chat private Color4 backgroundHover; private Color4 backgroundActive; - protected override bool isClosable => !Pinned; + protected override bool IsRemovable => !Pinned; private readonly SpriteText text; private readonly SpriteText textBold; @@ -102,7 +102,7 @@ namespace osu.Game.Overlays.Chat { this.ResizeTo(new Vector2(Width, 1.1f), transition_length, Easing.OutQuint); - closeButton?.MoveToX(-5f, 0.5f, EasingTypes.OutElastic); + closeButton?.MoveToX(-5f, 0.5f, Easing.OutElastic); box.FadeColour(backgroundActive, transition_length, Easing.OutQuint); highlightBox.FadeIn(transition_length, Easing.OutQuint); @@ -114,7 +114,7 @@ namespace osu.Game.Overlays.Chat { this.ResizeTo(new Vector2(Width, 1), transition_length, Easing.OutQuint); - closeButton?.MoveToX(5f, 0.5f, EasingTypes.InElastic); + closeButton?.MoveToX(5f, 0.5f, Easing.InElastic); box.FadeColour(backgroundInactive, transition_length, Easing.OutQuint); highlightBox.FadeOut(transition_length, Easing.OutQuint); @@ -124,7 +124,7 @@ namespace osu.Game.Overlays.Chat protected override bool OnHover(InputState state) { - closeButton?.FadeIn(1f, EasingTypes.InBounce); + closeButton?.FadeIn(1f, Easing.InBounce); if (!Active) box.FadeColour(backgroundHover, transition_length, Easing.OutQuint); @@ -133,7 +133,7 @@ namespace osu.Game.Overlays.Chat protected override void OnHoverLost(InputState state) { - closeButton?.FadeOut(1f, EasingTypes.OutBounce); + closeButton?.FadeOut(1f, Easing.OutBounce); updateState(); } @@ -227,7 +227,7 @@ namespace osu.Game.Overlays.Chat }, }; - if (isClosable) + if (IsRemovable) { Add(closeButton = new Button { @@ -246,7 +246,7 @@ namespace osu.Game.Overlays.Chat public class ChannelSelectorTabItem : ChannelTabItem { - protected override bool isClosable => false; + protected override bool IsRemovable => false; public ChannelSelectorTabItem(Channel value) : base(value) { diff --git a/osu.Game/Overlays/Chat/DrawableChannel.cs b/osu.Game/Overlays/Chat/DrawableChannel.cs index 8a2fa95ed1..3736a97981 100644 --- a/osu.Game/Overlays/Chat/DrawableChannel.cs +++ b/osu.Game/Overlays/Chat/DrawableChannel.cs @@ -46,6 +46,7 @@ namespace osu.Game.Overlays.Chat }; channel.NewMessagesArrived += newMessagesArrived; + channel.Joined.ValueChanged += channelJoinStatusChanged; } [BackgroundDependencyLoader] @@ -64,6 +65,7 @@ namespace osu.Game.Overlays.Chat { base.Dispose(isDisposing); Channel.NewMessagesArrived -= newMessagesArrived; + Channel.Joined.ValueChanged -= channelJoinStatusChanged; } private void newMessagesArrived(IEnumerable newMessages) @@ -90,6 +92,11 @@ namespace osu.Game.Overlays.Chat } } + private void channelJoinStatusChanged(bool joined) + { + if (!joined) flow.Clear(); + } + private void scrollToEnd() => ScheduleAfterChildren(() => scroll.ScrollToEnd()); } } From 8dbbc623c73e1b3731fcfe4c6e7d870e95691793 Mon Sep 17 00:00:00 2001 From: naoey Date: Sat, 5 Aug 2017 10:22:06 +0530 Subject: [PATCH 03/17] Add next tab selection logic in game, make IsRemovable public. - Don't clear DrawableChannel when unjoined --- osu.Game/Overlays/Chat/ChatTabControl.cs | 21 ++++++++++++++++++--- osu.Game/Overlays/Chat/DrawableChannel.cs | 7 ------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index 735a37e334..baa6fb3ab6 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -53,7 +53,7 @@ namespace osu.Game.Overlays.Chat protected override TabItem CreateTabItem(Channel value) { ChannelTabItem tab = new ChannelTabItem(value); - tab.OnRequestClose = () => OnRequestLeave?.Invoke(value); + tab.OnRequestClose = () => onTabClose(tab); return tab; } @@ -71,13 +71,28 @@ namespace osu.Game.Overlays.Chat base.SelectTab(tab); } + private void onTabClose(TabItem tab) + { + int totalTabs = TabContainer.Children.Count - 1; // account for selectorTab + int currentIndex = MathHelper.Clamp(TabContainer.IndexOf(tab), 1, totalTabs); + + if (tab == SelectedTab && totalTabs > 1) + // Select the tab after tab-to-be-removed's index, or the tab before if current == last + SelectTab(TabContainer.Children[currentIndex == totalTabs ? currentIndex - 1 : currentIndex + 1]); + else if (totalTabs == 1 && !selectorTab.Active) + // Open channel selection overlay if all channel tabs will be closed after removing this tab + SelectTab(selectorTab); + + OnRequestLeave?.Invoke(tab.Value); + } + private class ChannelTabItem : TabItem { private Color4 backgroundInactive; private Color4 backgroundHover; private Color4 backgroundActive; - protected override bool IsRemovable => !Pinned; + public override bool IsRemovable => !Pinned; private readonly SpriteText text; private readonly SpriteText textBold; @@ -246,7 +261,7 @@ namespace osu.Game.Overlays.Chat public class ChannelSelectorTabItem : ChannelTabItem { - protected override bool IsRemovable => false; + public override bool IsRemovable => false; public ChannelSelectorTabItem(Channel value) : base(value) { diff --git a/osu.Game/Overlays/Chat/DrawableChannel.cs b/osu.Game/Overlays/Chat/DrawableChannel.cs index 3736a97981..8a2fa95ed1 100644 --- a/osu.Game/Overlays/Chat/DrawableChannel.cs +++ b/osu.Game/Overlays/Chat/DrawableChannel.cs @@ -46,7 +46,6 @@ namespace osu.Game.Overlays.Chat }; channel.NewMessagesArrived += newMessagesArrived; - channel.Joined.ValueChanged += channelJoinStatusChanged; } [BackgroundDependencyLoader] @@ -65,7 +64,6 @@ namespace osu.Game.Overlays.Chat { base.Dispose(isDisposing); Channel.NewMessagesArrived -= newMessagesArrived; - Channel.Joined.ValueChanged -= channelJoinStatusChanged; } private void newMessagesArrived(IEnumerable newMessages) @@ -92,11 +90,6 @@ namespace osu.Game.Overlays.Chat } } - private void channelJoinStatusChanged(bool joined) - { - if (!joined) flow.Clear(); - } - private void scrollToEnd() => ScheduleAfterChildren(() => scroll.ScrollToEnd()); } } From 381c709639ec9f3bbac4d93a4b3e1dc962be5b4a Mon Sep 17 00:00:00 2001 From: naoey Date: Fri, 11 Aug 2017 10:10:55 +0530 Subject: [PATCH 04/17] Fix selectorTab Depth if it's wonky when new tabs are added. --- osu.Game/Overlays/Chat/ChatTabControl.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index baa6fb3ab6..ef4760d166 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -50,6 +50,15 @@ namespace osu.Game.Overlays.Chat ChannelSelectorActive.BindTo(selectorTab.Active); } + protected override void AddTabItem(TabItem item, bool addToDropdown = true) + { + if (selectorTab.Depth < float.MaxValue) + // performTabSort might've made selectorTab's position wonky, fix it + TabContainer.ChangeChildDepth(selectorTab, float.MaxValue); + + base.AddTabItem(item, addToDropdown); + } + protected override TabItem CreateTabItem(Channel value) { ChannelTabItem tab = new ChannelTabItem(value); From 4f7ae1ed8b6ecc2bee77d24b269b980031a0a7dc Mon Sep 17 00:00:00 2001 From: naoey Date: Thu, 17 Aug 2017 08:20:44 +0530 Subject: [PATCH 05/17] Clear messages when the current channel is removed. - Stop using TabContainer.Children --- osu.Game/Overlays/Chat/ChatTabControl.cs | 4 ++-- osu.Game/Overlays/ChatOverlay.cs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index ef4760d166..5f8db6fa71 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -82,12 +82,12 @@ namespace osu.Game.Overlays.Chat private void onTabClose(TabItem tab) { - int totalTabs = TabContainer.Children.Count - 1; // account for selectorTab + int totalTabs = TabContainer.Count - 1; // account for selectorTab int currentIndex = MathHelper.Clamp(TabContainer.IndexOf(tab), 1, totalTabs); if (tab == SelectedTab && totalTabs > 1) // Select the tab after tab-to-be-removed's index, or the tab before if current == last - SelectTab(TabContainer.Children[currentIndex == totalTabs ? currentIndex - 1 : currentIndex + 1]); + SelectTab(TabContainer[currentIndex == totalTabs ? currentIndex - 1 : currentIndex + 1]); else if (totalTabs == 1 && !selectorTab.Active) // Open channel selection overlay if all channel tabs will be closed after removing this tab SelectTab(selectorTab); diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index cc4177edc6..855fb5a1d6 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -397,7 +397,11 @@ namespace osu.Game.Overlays { if (channel == null) return; + if (channel == CurrentChannel) + currentChannelContainer.Clear(false); + careChannels.Remove(channel); + loadedChannels.Remove(loadedChannels.Find(c => c.Channel == channel)); channelTabs.RemoveItem(channel); channel.Joined.Value = false; From 7ad4c046dbe06f30a2b564db87d46f8fc1c8e8a7 Mon Sep 17 00:00:00 2001 From: naoey Date: Fri, 18 Aug 2017 13:35:48 +0530 Subject: [PATCH 06/17] Make current value behaviour between channels and tabs consistent. - Trim whitespace --- osu.Game/Overlays/Chat/ChatTabControl.cs | 5 ++++- osu.Game/Overlays/ChatOverlay.cs | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index 5f8db6fa71..c11e474b76 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -57,6 +57,9 @@ namespace osu.Game.Overlays.Chat TabContainer.ChangeChildDepth(selectorTab, float.MaxValue); base.AddTabItem(item, addToDropdown); + + if (SelectedTab == null) + SelectTab(item); } protected override TabItem CreateTabItem(Channel value) @@ -149,7 +152,7 @@ namespace osu.Game.Overlays.Chat protected override bool OnHover(InputState state) { closeButton?.FadeIn(1f, Easing.InBounce); - + if (!Active) box.FadeColour(backgroundHover, transition_length, Easing.OutQuint); return true; diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 855fb5a1d6..6f8bf69779 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -398,7 +398,10 @@ namespace osu.Game.Overlays if (channel == null) return; if (channel == CurrentChannel) + { + currentChannel = null; currentChannelContainer.Clear(false); + } careChannels.Remove(channel); loadedChannels.Remove(loadedChannels.Find(c => c.Channel == channel)); From 2cace0e1ab045c172b9571dcd0154b56751decfe Mon Sep 17 00:00:00 2001 From: naoey Date: Thu, 24 Aug 2017 09:48:53 +0530 Subject: [PATCH 07/17] Don't use virtual methods in ctor, always create closeButton. --- osu.Game/Overlays/Chat/ChatTabControl.cs | 41 ++++++++++++------------ 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index c11e474b76..5b65f7c036 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -45,7 +45,7 @@ namespace osu.Game.Overlays.Chat Margin = new MarginPadding(10), }); - AddTabItem(selectorTab = new ChannelTabItem.ChannelSelectorTabItem(new Channel { Name = "+" })); + base.AddTabItem(selectorTab = new ChannelTabItem.ChannelSelectorTabItem(new Channel { Name = "+" })); ChannelSelectorActive.BindTo(selectorTab.Active); } @@ -129,7 +129,7 @@ namespace osu.Game.Overlays.Chat { this.ResizeTo(new Vector2(Width, 1.1f), transition_length, Easing.OutQuint); - closeButton?.MoveToX(-5f, 0.5f, Easing.OutElastic); + closeButton.MoveToX(-5f, 0.5f, Easing.OutElastic); box.FadeColour(backgroundActive, transition_length, Easing.OutQuint); highlightBox.FadeIn(transition_length, Easing.OutQuint); @@ -141,7 +141,7 @@ namespace osu.Game.Overlays.Chat { this.ResizeTo(new Vector2(Width, 1), transition_length, Easing.OutQuint); - closeButton?.MoveToX(5f, 0.5f, Easing.InElastic); + closeButton.MoveToX(5f, 0.5f, Easing.InElastic); box.FadeColour(backgroundInactive, transition_length, Easing.OutQuint); highlightBox.FadeOut(transition_length, Easing.OutQuint); @@ -151,7 +151,8 @@ namespace osu.Game.Overlays.Chat protected override bool OnHover(InputState state) { - closeButton?.FadeIn(1f, Easing.InBounce); + if (IsRemovable) + closeButton.FadeIn(1f, Easing.InBounce); if (!Active) box.FadeColour(backgroundHover, transition_length, Easing.OutQuint); @@ -160,7 +161,9 @@ namespace osu.Game.Overlays.Chat protected override void OnHoverLost(InputState state) { - closeButton?.FadeOut(1f, Easing.OutBounce); + if (closeButton.IsPresent) + closeButton.FadeOut(1f, Easing.OutBounce); + updateState(); } @@ -250,25 +253,21 @@ namespace osu.Game.Overlays.Chat Font = @"Exo2.0-Bold", TextSize = 18, }, + closeButton = new Button + { + Alpha = 0, + Width = 20, + Height = 20, + Margin = new MarginPadding { Right = 10 }, + Origin = Anchor.CentreRight, + Anchor = Anchor.CentreRight, + Text = @"x", + BackgroundColour = Color4.Transparent, + Action = delegate { if (IsRemovable) OnRequestClose?.Invoke(); }, + }, }, }, }; - - if (IsRemovable) - { - Add(closeButton = new Button - { - Alpha = 0, - Width = 20, - Height = 20, - Margin = new MarginPadding { Right = 10 }, - Origin = Anchor.CentreRight, - Anchor = Anchor.CentreRight, - Text = @"x", - BackgroundColour = Color4.Transparent, - Action = () => OnRequestClose?.Invoke(), - }); - } } public class ChannelSelectorTabItem : ChannelTabItem From 6291bd5ced4d8834afbb7b8e9ec5d90e575106a9 Mon Sep 17 00:00:00 2001 From: naoey Date: Thu, 24 Aug 2017 10:40:42 +0530 Subject: [PATCH 08/17] Handle null current channel in setter, update framework. --- osu-framework | 2 +- osu.Game/Overlays/ChatOverlay.cs | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/osu-framework b/osu-framework index 1ba1e8ef1e..d492c2ffe6 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 1ba1e8ef1e5ec0466632be02492023a081cb85ab +Subproject commit d492c2ffe6ce5dac2a8e05118d86e6907186329b diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 38432860c3..b20019ed1a 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -334,7 +334,15 @@ namespace osu.Game.Overlays set { - if (currentChannel == value || value == null) return; + if (currentChannel == value) return; + + if (value == null) + { + currentChannel = null; + textbox.Current.Disabled = true; + currentChannelContainer.Clear(false); + return; + } currentChannel = value; @@ -397,11 +405,7 @@ namespace osu.Game.Overlays { if (channel == null) return; - if (channel == CurrentChannel) - { - currentChannel = null; - currentChannelContainer.Clear(false); - } + if (channel == CurrentChannel) CurrentChannel = null; careChannels.Remove(channel); loadedChannels.Remove(loadedChannels.Find(c => c.Channel == channel)); From e834e0e9580aa3762812be9ac29e6a6be1e959d2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Sep 2017 21:07:53 +0900 Subject: [PATCH 09/17] Fix incorrect initialisation order causing mania key bindings to not work --- osu.Game/Rulesets/UI/RulesetContainer.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index a7472f4dbc..e2701faca0 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -75,7 +75,11 @@ namespace osu.Game.Rulesets.UI internal RulesetContainer(Ruleset ruleset) { Ruleset = ruleset; + } + [BackgroundDependencyLoader] + private void load() + { KeyBindingInputManager = CreateInputManager(); KeyBindingInputManager.RelativeSizeAxes = Axes.Both; } From f70b4839bd80834720e2d205f097d014ec30bfb8 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 6 Sep 2017 21:22:23 +0900 Subject: [PATCH 10/17] Remove a few unnecessary attributes in OsuTestCase. --- osu.Desktop.Tests/Visual/OsuTestCase.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Desktop.Tests/Visual/OsuTestCase.cs b/osu.Desktop.Tests/Visual/OsuTestCase.cs index e366aecb21..1b48ded4e2 100644 --- a/osu.Desktop.Tests/Visual/OsuTestCase.cs +++ b/osu.Desktop.Tests/Visual/OsuTestCase.cs @@ -1,17 +1,14 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using NUnit.Framework; using osu.Framework.Desktop.Platform; using osu.Framework.Testing; using osu.Game; namespace osu.Desktop.Tests.Visual { - [TestFixture] public abstract class OsuTestCase : TestCase { - [Test] public override void RunTest() { using (var host = new HeadlessGameHost(realtime: false)) From 940c45b6d199fafcec8f440a9c68ae93746eb361 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Sep 2017 21:43:20 +0900 Subject: [PATCH 11/17] Fix visual styling and code styling --- osu.Game/Overlays/Chat/ChatTabControl.cs | 72 ++++++++++++++++++------ 1 file changed, 55 insertions(+), 17 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index 5b65f7c036..6498761832 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -64,10 +64,10 @@ namespace osu.Game.Overlays.Chat protected override TabItem CreateTabItem(Channel value) { - ChannelTabItem tab = new ChannelTabItem(value); - tab.OnRequestClose = () => onTabClose(tab); + ChannelTabItem tab = new ChannelTabItem(value); + tab.OnRequestClose = () => onTabClose(tab); - return tab; + return tab; } protected override void SelectTab(TabItem tab) @@ -108,7 +108,7 @@ namespace osu.Game.Overlays.Chat private readonly SpriteText text; private readonly SpriteText textBold; - private readonly Button closeButton; + private readonly ClickableContainer closeButton; private readonly Box box; private readonly Box highlightBox; private readonly SpriteIcon icon; @@ -129,7 +129,6 @@ namespace osu.Game.Overlays.Chat { this.ResizeTo(new Vector2(Width, 1.1f), transition_length, Easing.OutQuint); - closeButton.MoveToX(-5f, 0.5f, Easing.OutElastic); box.FadeColour(backgroundActive, transition_length, Easing.OutQuint); highlightBox.FadeIn(transition_length, Easing.OutQuint); @@ -141,7 +140,6 @@ namespace osu.Game.Overlays.Chat { this.ResizeTo(new Vector2(Width, 1), transition_length, Easing.OutQuint); - closeButton.MoveToX(5f, 0.5f, Easing.InElastic); box.FadeColour(backgroundInactive, transition_length, Easing.OutQuint); highlightBox.FadeOut(transition_length, Easing.OutQuint); @@ -152,7 +150,7 @@ namespace osu.Game.Overlays.Chat protected override bool OnHover(InputState state) { if (IsRemovable) - closeButton.FadeIn(1f, Easing.InBounce); + closeButton.FadeIn(200, Easing.OutQuint); if (!Active) box.FadeColour(backgroundHover, transition_length, Easing.OutQuint); @@ -161,9 +159,7 @@ namespace osu.Game.Overlays.Chat protected override void OnHoverLost(InputState state) { - if (closeButton.IsPresent) - closeButton.FadeOut(1f, Easing.OutBounce); - + closeButton.FadeOut(200, Easing.OutQuint); updateState(); } @@ -253,23 +249,65 @@ namespace osu.Game.Overlays.Chat Font = @"Exo2.0-Bold", TextSize = 18, }, - closeButton = new Button + closeButton = new CloseButton { Alpha = 0, - Width = 20, - Height = 20, - Margin = new MarginPadding { Right = 10 }, + Margin = new MarginPadding { Right = 20 }, Origin = Anchor.CentreRight, Anchor = Anchor.CentreRight, - Text = @"x", - BackgroundColour = Color4.Transparent, - Action = delegate { if (IsRemovable) OnRequestClose?.Invoke(); }, + Action = delegate + { + if (IsRemovable) OnRequestClose?.Invoke(); + }, }, }, }, }; } + public class CloseButton : ClickableContainer + { + private SpriteIcon icon; + + public CloseButton() + { + Size = new Vector2(20); + + Child = icon = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Scale = new Vector2(0.75f), + Icon = FontAwesome.fa_close, + RelativeSizeAxes = Axes.Both, + }; + } + + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + icon.ScaleTo(0.5f, 1000, Easing.OutQuint); + return base.OnMouseDown(state, args); + } + + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) + { + icon.ScaleTo(0.75f, 1000, Easing.OutElastic); + return base.OnMouseUp(state, args); + } + + protected override bool OnHover(InputState state) + { + icon.FadeColour(Color4.Red, 200, Easing.OutQuint); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + icon.FadeColour(Color4.White, 200, Easing.OutQuint); + base.OnHoverLost(state); + } + } + public class ChannelSelectorTabItem : ChannelTabItem { public override bool IsRemovable => false; From a7fa66b9f91b710ba9969757b6c6d21159879bc2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Sep 2017 22:41:03 +0900 Subject: [PATCH 12/17] Fix CI issue --- osu.Game/Overlays/Chat/ChatTabControl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index 6498761832..b68bdac3b3 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -267,7 +267,7 @@ namespace osu.Game.Overlays.Chat public class CloseButton : ClickableContainer { - private SpriteIcon icon; + private readonly SpriteIcon icon; public CloseButton() { From 4f49a0c18387f6c4d3d2f3ea124f9742c468d1bb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Sep 2017 22:58:21 +0900 Subject: [PATCH 13/17] Simplify action --- osu.Game/Overlays/Chat/ChatTabControl.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index b68bdac3b3..83c0c17bc2 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -62,13 +62,7 @@ namespace osu.Game.Overlays.Chat SelectTab(item); } - protected override TabItem CreateTabItem(Channel value) - { - ChannelTabItem tab = new ChannelTabItem(value); - tab.OnRequestClose = () => onTabClose(tab); - - return tab; - } + protected override TabItem CreateTabItem(Channel value) => new ChannelTabItem(value) { OnRequestClose = onTabClose }; protected override void SelectTab(TabItem tab) { @@ -113,7 +107,7 @@ namespace osu.Game.Overlays.Chat private readonly Box highlightBox; private readonly SpriteIcon icon; - public Action OnRequestClose; + public Action OnRequestClose; private void updateState() { @@ -257,7 +251,7 @@ namespace osu.Game.Overlays.Chat Anchor = Anchor.CentreRight, Action = delegate { - if (IsRemovable) OnRequestClose?.Invoke(); + if (IsRemovable) OnRequestClose?.Invoke(this); }, }, }, From da294c96051fa950a1634ac64daaa1adeeeda51e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Sep 2017 23:10:08 +0900 Subject: [PATCH 14/17] Don't use base call when we don't have to --- osu.Game/Overlays/Chat/ChatTabControl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index 83c0c17bc2..ca195a7830 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -45,7 +45,7 @@ namespace osu.Game.Overlays.Chat Margin = new MarginPadding(10), }); - base.AddTabItem(selectorTab = new ChannelTabItem.ChannelSelectorTabItem(new Channel { Name = "+" })); + AddTabItem(selectorTab = new ChannelTabItem.ChannelSelectorTabItem(new Channel { Name = "+" })); ChannelSelectorActive.BindTo(selectorTab.Active); } From e5308b624700cd77bb3f56e68cd844906cf15e6a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Sep 2017 23:12:32 +0900 Subject: [PATCH 15/17] Method rename --- 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 ca195a7830..9f1028c168 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -62,7 +62,7 @@ namespace osu.Game.Overlays.Chat SelectTab(item); } - protected override TabItem CreateTabItem(Channel value) => new ChannelTabItem(value) { OnRequestClose = onTabClose }; + protected override TabItem CreateTabItem(Channel value) => new ChannelTabItem(value) { OnRequestClose = tabCloseRequested }; protected override void SelectTab(TabItem tab) { @@ -77,7 +77,7 @@ namespace osu.Game.Overlays.Chat base.SelectTab(tab); } - private void onTabClose(TabItem tab) + private void tabCloseRequested(TabItem tab) { int totalTabs = TabContainer.Count - 1; // account for selectorTab int currentIndex = MathHelper.Clamp(TabContainer.IndexOf(tab), 1, totalTabs); From ef9b87e8c7b32b0cdcedaf2b52280731a0efa5e4 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 7 Sep 2017 16:15:25 +0900 Subject: [PATCH 16/17] Make column lights not increase in brightness when successfully pressed --- osu.Game.Rulesets.Mania/UI/Column.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index a8f5b4919d..d5bc7cc659 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -198,7 +198,7 @@ namespace osu.Game.Rulesets.Mania.UI { if (action == Action) { - background.FadeTo(background.Alpha + 0.2f, 50, Easing.OutQuint); + background.FadeTo(0.6f, 50, Easing.OutQuint); keyIcon.ScaleTo(1.4f, 50, Easing.OutQuint); } From b085208d247d9a78fb66d659321a3a6e46a5d1a7 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 7 Sep 2017 16:15:33 +0900 Subject: [PATCH 17/17] Remove unused code --- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index d3dc920fc6..ce91fda023 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -11,7 +11,6 @@ using osu.Framework.Graphics.Containers; using System; using osu.Game.Graphics; using osu.Framework.Allocation; -using OpenTK.Input; using System.Linq; using System.Collections.Generic; using osu.Framework.Configuration; @@ -25,12 +24,6 @@ namespace osu.Game.Rulesets.Mania.UI { public const float HIT_TARGET_POSITION = 50; - /// - /// Default column keys, expanding outwards from the middle as more column are added. - /// E.g. 2 columns use FJ, 4 columns use DFJK, 6 use SDFJKL, etc... - /// - private static readonly Key[] default_keys = { Key.A, Key.S, Key.D, Key.F, Key.J, Key.K, Key.L, Key.Semicolon }; - private SpecialColumnPosition specialColumnPosition; /// /// The style to use for the special column.