mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 09:02:58 +08:00
Add input box to ChatOverlay.
This commit is contained in:
parent
520e040396
commit
aac4ba2baa
@ -21,8 +21,8 @@ namespace osu.Game.Online.Chat.Drawables
|
|||||||
public DrawableChannel(Channel channel)
|
public DrawableChannel(Channel channel)
|
||||||
{
|
{
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
newMessages(channel.Messages);
|
newMessagesArrived(channel.Messages);
|
||||||
channel.NewMessagesArrived += newMessages;
|
channel.NewMessagesArrived += newMessagesArrived;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
@ -56,16 +56,16 @@ namespace osu.Game.Online.Chat.Drawables
|
|||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
channel.NewMessagesArrived -= newMessages;
|
channel.NewMessagesArrived -= newMessagesArrived;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
newMessages(channel.Messages);
|
newMessagesArrived(channel.Messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void newMessages(IEnumerable<Message> newMessages)
|
private void newMessagesArrived(IEnumerable<Message> newMessages)
|
||||||
{
|
{
|
||||||
if (!IsLoaded) return;
|
if (!IsLoaded) return;
|
||||||
|
|
||||||
|
@ -19,6 +19,10 @@ using osu.Game.Online.API;
|
|||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
using osu.Game.Online.Chat.Drawables;
|
using osu.Game.Online.Chat.Drawables;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Screens.Select;
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
@ -32,6 +36,8 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
|
private FocusedTextBox inputTextBox;
|
||||||
|
|
||||||
private APIAccess api;
|
private APIAccess api;
|
||||||
|
|
||||||
public ChatOverlay()
|
public ChatOverlay()
|
||||||
@ -52,10 +58,38 @@ namespace osu.Game.Overlays
|
|||||||
content = new Container
|
content = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding { Bottom = 50 },
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 50,
|
||||||
|
Padding = new MarginPadding(5),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
inputTextBox = new FocusedTextBox
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
PlaceholderText = "type your message",
|
||||||
|
Exit = () => State = Visibility.Hidden,
|
||||||
|
OnCommit = postMessage,
|
||||||
|
HoldFocus = true,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void postMessage(TextBox sender, bool newText)
|
||||||
|
{
|
||||||
|
var postText = sender.Text;
|
||||||
|
//todo: do something with postText.
|
||||||
|
|
||||||
|
sender.Text = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(APIAccess api)
|
private void load(APIAccess api)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user