mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 02:22:56 +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)
|
||||
{
|
||||
this.channel = channel;
|
||||
newMessages(channel.Messages);
|
||||
channel.NewMessagesArrived += newMessages;
|
||||
newMessagesArrived(channel.Messages);
|
||||
channel.NewMessagesArrived += newMessagesArrived;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
@ -56,16 +56,16 @@ namespace osu.Game.Online.Chat.Drawables
|
||||
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;
|
||||
|
||||
|
@ -19,6 +19,10 @@ using osu.Game.Online.API;
|
||||
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 @@ namespace osu.Game.Overlays
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private FocusedTextBox inputTextBox;
|
||||
|
||||
private APIAccess api;
|
||||
|
||||
public ChatOverlay()
|
||||
@ -52,10 +58,38 @@ namespace osu.Game.Overlays
|
||||
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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user