Add input box to ChatOverlay.

This commit is contained in:
Dean Herbert 2017-02-19 18:02:25 +09:00
parent 520e040396
commit aac4ba2baa
2 changed files with 39 additions and 5 deletions

View File

@ -21,8 +21,8 @@ public class DrawableChannel : Container
public DrawableChannel(Channel channel)
{
this.channel = channel;
newMessages(channel.Messages);
channel.NewMessagesArrived += newMessages;
newMessagesArrived(channel.Messages);
channel.NewMessagesArrived += newMessagesArrived;
RelativeSizeAxes = Axes.Both;
@ -56,16 +56,16 @@ public DrawableChannel(Channel channel)
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
channel.NewMessagesArrived -= newMessages;
channel.NewMessagesArrived -= newMessagesArrived;
}
[BackgroundDependencyLoader]
private void load()
{
newMessages(channel.Messages);
newMessagesArrived(channel.Messages);
}
private void newMessages(IEnumerable<Message> newMessages)
private void newMessagesArrived(IEnumerable<Message> newMessages)
{
if (!IsLoaded) return;

View File

@ -19,6 +19,10 @@
using osu.Game.Online.API.Requests;
using osu.Game.Online.Chat;
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
{
@ -32,6 +36,8 @@ public class ChatOverlay : OverlayContainer, IOnlineComponent
protected override Container<Drawable> Content => content;
private FocusedTextBox inputTextBox;
private APIAccess api;
public ChatOverlay()
@ -52,10 +58,38 @@ public ChatOverlay()
content = new Container
{
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]
private void load(APIAccess api)
{