mirror of
https://github.com/ppy/osu.git
synced 2025-02-19 07:42:58 +08:00
use AddTabItem instead + Bindable for ChannelSelectorTabItem
This commit is contained in:
parent
0e3fb55d5e
commit
94484974f9
@ -14,15 +14,20 @@ using osu.Game.Graphics.UserInterface;
|
|||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Chat
|
namespace osu.Game.Overlays.Chat
|
||||||
{
|
{
|
||||||
public class ChatTabControl : OsuTabControl<Channel>
|
public class ChatTabControl : OsuTabControl<Channel>
|
||||||
{
|
{
|
||||||
protected override TabItem<Channel> CreateTabItem(Channel value) => value.Id == ChatOverlay.CHANNEL_SELECTOR_ID ? new ChannelTabItem.ChannelSelectorTabItem(value) : new ChannelTabItem(value);
|
protected override TabItem<Channel> CreateTabItem(Channel value) => new ChannelTabItem(value);
|
||||||
|
|
||||||
private const float shear_width = 10;
|
private const float shear_width = 10;
|
||||||
|
|
||||||
|
private Bindable<bool> channelSelectorActive = new Bindable<bool>();
|
||||||
|
|
||||||
|
public Bindable<bool> ChannelSelectorActive => channelSelectorActive;
|
||||||
|
|
||||||
public ChatTabControl()
|
public ChatTabControl()
|
||||||
{
|
{
|
||||||
TabContainer.Margin = new MarginPadding { Left = 50 };
|
TabContainer.Margin = new MarginPadding { Left = 50 };
|
||||||
@ -38,10 +43,7 @@ namespace osu.Game.Overlays.Chat
|
|||||||
Padding = new MarginPadding(10),
|
Padding = new MarginPadding(10),
|
||||||
});
|
});
|
||||||
|
|
||||||
AddItem(new Channel
|
AddTabItem(new ChannelTabItem.ChannelSelectorTabItem(new Channel(), channelSelectorActive));
|
||||||
{
|
|
||||||
Id = ChatOverlay.CHANNEL_SELECTOR_ID,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChannelTabItem : TabItem<Channel>
|
private class ChannelTabItem : TabItem<Channel>
|
||||||
@ -200,8 +202,21 @@ namespace osu.Game.Overlays.Chat
|
|||||||
|
|
||||||
public class ChannelSelectorTabItem : ChannelTabItem
|
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<bool> activeBindable;
|
||||||
|
|
||||||
|
public ChannelSelectorTabItem(Channel value, Bindable<bool> active) : base(value)
|
||||||
|
{
|
||||||
|
activeBindable = active;
|
||||||
Depth = float.MaxValue;
|
Depth = float.MaxValue;
|
||||||
Width = 60;
|
Width = 60;
|
||||||
|
|
||||||
|
@ -44,8 +44,6 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
public const float TAB_AREA_HEIGHT = 50;
|
public const float TAB_AREA_HEIGHT = 50;
|
||||||
|
|
||||||
public const int CHANNEL_SELECTOR_ID = -1;
|
|
||||||
|
|
||||||
private GetMessagesRequest fetchReq;
|
private GetMessagesRequest fetchReq;
|
||||||
|
|
||||||
private readonly ChatTabControl channelTabs;
|
private readonly ChatTabControl channelTabs;
|
||||||
@ -264,16 +262,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
if (currentChannel == value) return;
|
if (currentChannel == value) return;
|
||||||
|
|
||||||
if (value.Id == CHANNEL_SELECTOR_ID)
|
if (channelTabs.ChannelSelectorActive) return;
|
||||||
{
|
|
||||||
//channel selector popout
|
|
||||||
currentChannel = value;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (currentChannel?.Id == CHANNEL_SELECTOR_ID)
|
|
||||||
{
|
|
||||||
//channel selector popin
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentChannel != null)
|
if (currentChannel != null)
|
||||||
currentChannelContainer.Clear(false);
|
currentChannelContainer.Clear(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user