1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:22:55 +08:00

Merge pull request #786 from Jorolf/channel-selector-tab-item

Add an "Add new channel" tab
This commit is contained in:
Dean Herbert 2017-05-30 10:05:26 +09:00 committed by GitHub
commit 03ac700838
2 changed files with 48 additions and 1 deletions

View File

@ -14,6 +14,7 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Chat;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Configuration;
namespace osu.Game.Overlays.Chat
{
@ -23,6 +24,8 @@ namespace osu.Game.Overlays.Chat
private const float shear_width = 10;
public readonly Bindable<bool> ChannelSelectorActive = new Bindable<bool>();
public ChatTabControl()
{
TabContainer.Margin = new MarginPadding { Left = 50 };
@ -37,6 +40,8 @@ namespace osu.Game.Overlays.Chat
TextSize = 20,
Padding = new MarginPadding(10),
});
AddTabItem(new ChannelTabItem.ChannelSelectorTabItem(new Channel { Name = "+" }, ChannelSelectorActive));
}
private class ChannelTabItem : TabItem<Channel>
@ -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
{
@ -114,6 +120,11 @@ namespace osu.Game.Overlays.Chat
backgroundHover = colours.Gray7;
highlightBox.Colour = colours.Yellow;
}
protected override void LoadComplete()
{
base.LoadComplete();
updateState();
}
@ -159,7 +170,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 +202,40 @@ namespace osu.Game.Overlays.Chat
}
};
}
public class ChannelSelectorTabItem : ChannelTabItem
{
public override bool Active
{
get { return base.Active; }
set
{
activeBindable.Value = value;
base.Active = value;
}
}
private readonly Bindable<bool> activeBindable;
public ChannelSelectorTabItem(Channel value, Bindable<bool> active) : base(value)
{
activeBindable = active;
Depth = float.MaxValue;
Width = 45;
icon.Alpha = 0;
text.TextSize = 45;
textBold.TextSize = 45;
}
[BackgroundDependencyLoader]
private new void load(OsuColour colour)
{
backgroundInactive = colour.Gray2;
backgroundActive = colour.Gray3;
}
}
}
}
}

View File

@ -260,6 +260,8 @@ namespace osu.Game.Overlays
{
if (currentChannel == value) return;
if (channelTabs.ChannelSelectorActive) return;
if (currentChannel != null)
currentChannelContainer.Clear(false);