From 67806c4247ab83893bb14577a782a20d7f376f68 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Wed, 17 May 2017 21:16:53 +0200 Subject: [PATCH 1/9] 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 2/9] 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 3/9] 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 7d28290a4a26b3fe2521c801374a797cc7176717 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 23 May 2017 17:35:40 +0200 Subject: [PATCH 4/9] 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 5/9] 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 6/9] 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 a9658ec66fbcc62e1b79214ffdda0a84ec3e44c0 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Thu, 25 May 2017 20:25:59 +0200 Subject: [PATCH 7/9] 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 1e4bca90f08e10a89c09729027e65db672f9b3a1 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 26 May 2017 12:10:16 +0200 Subject: [PATCH 8/9] 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 fde579262f085f8382157d197f854a04657406a6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 30 May 2017 09:54:29 +0900 Subject: [PATCH 9/9] 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;