mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 10:42:54 +08:00
Make the channel selection overlay hide/resize with chat
This commit is contained in:
parent
50e50ce67e
commit
745e2e5e18
@ -29,6 +29,7 @@ namespace osu.Game.Overlays
|
|||||||
public class ChatOverlay : FocusedOverlayContainer, IOnlineComponent
|
public class ChatOverlay : FocusedOverlayContainer, IOnlineComponent
|
||||||
{
|
{
|
||||||
private const float textbox_height = 60;
|
private const float textbox_height = 60;
|
||||||
|
private const float channel_selection_min_height = 0.3f;
|
||||||
|
|
||||||
private ScheduledDelegate messageRequest;
|
private ScheduledDelegate messageRequest;
|
||||||
|
|
||||||
@ -48,6 +49,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private readonly ChatTabControl channelTabs;
|
private readonly ChatTabControl channelTabs;
|
||||||
|
|
||||||
|
private readonly Container chatContainer;
|
||||||
private readonly Box chatBackground;
|
private readonly Box chatBackground;
|
||||||
private readonly Box tabBackground;
|
private readonly Box tabBackground;
|
||||||
|
|
||||||
@ -55,13 +57,12 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private readonly ChannelSelectionOverlay channelSelection;
|
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()
|
public ChatOverlay()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
RelativePositionAxes = Axes.Both;
|
RelativePositionAxes = Axes.Both;
|
||||||
Size = new Vector2(1, DEFAULT_HEIGHT);
|
|
||||||
Anchor = Anchor.BottomLeft;
|
Anchor = Anchor.BottomLeft;
|
||||||
Origin = Anchor.BottomLeft;
|
Origin = Anchor.BottomLeft;
|
||||||
|
|
||||||
@ -71,10 +72,21 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
channelSelection = new ChannelSelectionOverlay //todo: temporary placement
|
channelSelection = new ChannelSelectionOverlay //todo: temporary placement
|
||||||
{
|
{
|
||||||
Origin = Anchor.BottomLeft,
|
Anchor = Anchor.TopLeft,
|
||||||
Height = 400,
|
Origin = Anchor.TopLeft,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Height = 1f - DEFAULT_HEIGHT,
|
||||||
State = Visibility.Visible,
|
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
|
new Container
|
||||||
{
|
{
|
||||||
Name = @"chat area",
|
Name = @"chat area",
|
||||||
@ -140,9 +152,16 @@ namespace osu.Game.Overlays
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
channelTabs.Current.ValueChanged += newChannel => CurrentChannel = newChannel;
|
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;
|
private double startDragChatHeight;
|
||||||
@ -211,7 +230,9 @@ namespace osu.Game.Overlays
|
|||||||
chatHeight = config.GetBindable<double>(OsuSetting.ChatDisplayHeight);
|
chatHeight = config.GetBindable<double>(OsuSetting.ChatDisplayHeight);
|
||||||
chatHeight.ValueChanged += h =>
|
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);
|
tabBackground.FadeTo(Height == 1 ? 1 : 0.8f, 200);
|
||||||
};
|
};
|
||||||
chatHeight.TriggerChange();
|
chatHeight.TriggerChange();
|
||||||
|
Loading…
Reference in New Issue
Block a user