mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 06:32:55 +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,78 +72,96 @@ 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,
|
||||||
},
|
},
|
||||||
new Container
|
chatContainer = new Container
|
||||||
{
|
{
|
||||||
Name = @"chat area",
|
Name = @"chat container",
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding { Top = TAB_AREA_HEIGHT },
|
Height = DEFAULT_HEIGHT,
|
||||||
Children = new Drawable[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
chatBackground = new Box
|
new Container
|
||||||
{
|
{
|
||||||
|
Name = @"chat area",
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
},
|
Padding = new MarginPadding { Top = TAB_AREA_HEIGHT },
|
||||||
currentChannelContainer = new Container
|
Children = new Drawable[]
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Padding = new MarginPadding
|
|
||||||
{
|
{
|
||||||
Bottom = textbox_height + padding
|
chatBackground = new Box
|
||||||
},
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
currentChannelContainer = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding
|
||||||
|
{
|
||||||
|
Bottom = textbox_height + padding
|
||||||
|
},
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = textbox_height,
|
||||||
|
Padding = new MarginPadding
|
||||||
|
{
|
||||||
|
Top = padding * 2,
|
||||||
|
Bottom = padding * 2,
|
||||||
|
Left = ChatLine.LEFT_PADDING + padding * 2,
|
||||||
|
Right = padding * 2,
|
||||||
|
},
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
inputTextBox = new FocusedTextBox
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Height = 1,
|
||||||
|
PlaceholderText = "type your message",
|
||||||
|
Exit = () => State = Visibility.Hidden,
|
||||||
|
OnCommit = postMessage,
|
||||||
|
HoldFocus = true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomLeft,
|
Name = @"tabs area",
|
||||||
Origin = Anchor.BottomLeft,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = textbox_height,
|
Height = TAB_AREA_HEIGHT,
|
||||||
Padding = new MarginPadding
|
|
||||||
{
|
|
||||||
Top = padding * 2,
|
|
||||||
Bottom = padding * 2,
|
|
||||||
Left = ChatLine.LEFT_PADDING + padding * 2,
|
|
||||||
Right = padding * 2,
|
|
||||||
},
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
inputTextBox = new FocusedTextBox
|
tabBackground = new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Height = 1,
|
Colour = Color4.Black,
|
||||||
PlaceholderText = "type your message",
|
},
|
||||||
Exit = () => State = Visibility.Hidden,
|
channelTabs = new ChatTabControl
|
||||||
OnCommit = postMessage,
|
{
|
||||||
HoldFocus = true,
|
RelativeSizeAxes = Axes.Both,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
Name = @"tabs area",
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Height = TAB_AREA_HEIGHT,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
tabBackground = new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = Color4.Black,
|
|
||||||
},
|
},
|
||||||
channelTabs = new ChatTabControl
|
},
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
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