1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 08:13:31 +08:00

Make the channel selection overlay hide/resize with chat

This commit is contained in:
DrabWeb 2017-05-29 21:23:03 -03:00
parent 50e50ce67e
commit 745e2e5e18

View File

@ -29,6 +29,7 @@ namespace osu.Game.Overlays
public class ChatOverlay : FocusedOverlayContainer, IOnlineComponent
{
private const float textbox_height = 60;
private const float channel_selection_min_height = 0.3f;
private ScheduledDelegate messageRequest;
@ -48,6 +49,7 @@ namespace osu.Game.Overlays
private readonly ChatTabControl channelTabs;
private readonly Container chatContainer;
private readonly Box chatBackground;
private readonly Box tabBackground;
@ -55,13 +57,12 @@ namespace osu.Game.Overlays
private readonly ChannelSelectionOverlay channelSelection;
protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || channelSelection.Contains(screenSpacePos);
protected override bool InternalContains(Vector2 screenSpacePos) => chatContainer.Contains(screenSpacePos) || channelSelection.Contains(screenSpacePos);
public ChatOverlay()
{
RelativeSizeAxes = Axes.Both;
RelativePositionAxes = Axes.Both;
Size = new Vector2(1, DEFAULT_HEIGHT);
Anchor = Anchor.BottomLeft;
Origin = Anchor.BottomLeft;
@ -71,10 +72,21 @@ namespace osu.Game.Overlays
{
channelSelection = new ChannelSelectionOverlay //todo: temporary placement
{
Origin = Anchor.BottomLeft,
Height = 400,
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft,
RelativeSizeAxes = Axes.Both,
Height = 1f - DEFAULT_HEIGHT,
State = Visibility.Visible,
},
chatContainer = new Container
{
Name = @"chat container",
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.Both,
Height = DEFAULT_HEIGHT,
Children = new[]
{
new Container
{
Name = @"chat area",
@ -140,9 +152,16 @@ namespace osu.Game.Overlays
},
}
},
},
},
};
channelTabs.Current.ValueChanged += newChannel => CurrentChannel = newChannel;
channelSelection.StateChanged += (overlay, state) =>
{
if (state == Visibility.Visible && 1f - chatHeight.Value < channel_selection_min_height)
chatHeight.Value = 1f - channel_selection_min_height;
};
}
private double startDragChatHeight;
@ -211,7 +230,9 @@ namespace osu.Game.Overlays
chatHeight = config.GetBindable<double>(OsuSetting.ChatDisplayHeight);
chatHeight.ValueChanged += h =>
{
Height = (float)h;
chatContainer.Height = (float)h;
channelSelection.Height = 1f - (float)h;
if (channelSelection.Height < channel_selection_min_height) channelSelection.Hide();
tabBackground.FadeTo(Height == 1 ? 1 : 0.8f, 200);
};
chatHeight.TriggerChange();