mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 15:16:38 +09:00
Merge remote-tracking branch 'upstream/master' into quit-chat-channels
This commit is contained in:
@ -6,23 +6,23 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays.Chat;
|
||||
using osu.Game.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
@ -37,7 +37,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
private readonly LoadingAnimation loading;
|
||||
|
||||
private readonly FocusedTextBox inputTextBox;
|
||||
private readonly FocusedTextBox textbox;
|
||||
|
||||
private APIAccess api;
|
||||
|
||||
@ -130,7 +130,7 @@ namespace osu.Game.Overlays
|
||||
},
|
||||
Children = new Drawable[]
|
||||
{
|
||||
inputTextBox = new FocusedTextBox
|
||||
textbox = new FocusedTextBox
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Height = 1,
|
||||
@ -176,7 +176,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
if (state == Visibility.Visible)
|
||||
{
|
||||
inputTextBox.HoldFocus = false;
|
||||
textbox.HoldFocus = false;
|
||||
if (1f - chatHeight.Value < channel_selection_min_height)
|
||||
{
|
||||
chatContainer.ResizeHeightTo(1f - channel_selection_min_height, 800, Easing.OutQuint);
|
||||
@ -187,7 +187,7 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
else
|
||||
{
|
||||
inputTextBox.HoldFocus = true;
|
||||
textbox.HoldFocus = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -243,8 +243,8 @@ namespace osu.Game.Overlays
|
||||
|
||||
protected override void OnFocus(InputState state)
|
||||
{
|
||||
//this is necessary as inputTextBox is masked away and therefore can't get focus :(
|
||||
InputManager.ChangeFocus(inputTextBox);
|
||||
//this is necessary as textbox is masked away and therefore can't get focus :(
|
||||
GetContainingInputManager().ChangeFocus(textbox);
|
||||
base.OnFocus(state);
|
||||
}
|
||||
|
||||
@ -253,7 +253,7 @@ namespace osu.Game.Overlays
|
||||
this.MoveToY(0, transition_length, Easing.OutQuint);
|
||||
this.FadeIn(transition_length, Easing.OutQuint);
|
||||
|
||||
inputTextBox.HoldFocus = true;
|
||||
textbox.HoldFocus = true;
|
||||
base.PopIn();
|
||||
}
|
||||
|
||||
@ -262,7 +262,7 @@ namespace osu.Game.Overlays
|
||||
this.MoveToY(Height, transition_length, Easing.InSine);
|
||||
this.FadeOut(transition_length, Easing.InSine);
|
||||
|
||||
inputTextBox.HoldFocus = false;
|
||||
textbox.HoldFocus = false;
|
||||
base.PopOut();
|
||||
}
|
||||
|
||||
@ -338,7 +338,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
currentChannel = value;
|
||||
|
||||
inputTextBox.Current.Disabled = currentChannel.ReadOnly;
|
||||
textbox.Current.Disabled = currentChannel.ReadOnly;
|
||||
channelTabs.Current.Value = value;
|
||||
|
||||
var loaded = loadedChannels.Find(d => d.Channel == value);
|
||||
@ -433,6 +433,7 @@ namespace osu.Game.Overlays
|
||||
if (fetchReq != null) return;
|
||||
|
||||
fetchReq = new GetMessagesRequest(careChannels, lastMessageId);
|
||||
|
||||
fetchReq.Success += delegate (List<Message> messages)
|
||||
{
|
||||
foreach (var group in messages.Where(m => m.TargetType == TargetType.Channel).GroupBy(m => m.TargetId))
|
||||
@ -443,6 +444,7 @@ namespace osu.Game.Overlays
|
||||
Debug.Write("success!");
|
||||
fetchReq = null;
|
||||
};
|
||||
|
||||
fetchReq.Failure += delegate
|
||||
{
|
||||
Debug.Write("failure!");
|
||||
@ -456,51 +458,42 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
var postText = textbox.Text;
|
||||
|
||||
textbox.Text = string.Empty;
|
||||
|
||||
if (string.IsNullOrEmpty(postText))
|
||||
return;
|
||||
|
||||
var target = currentChannel;
|
||||
|
||||
if (target == null) return;
|
||||
|
||||
if (!api.IsLoggedIn)
|
||||
{
|
||||
currentChannel?.AddNewMessages(new ErrorMessage("Please login to participate in chat!"));
|
||||
textbox.Text = string.Empty;
|
||||
target.AddNewMessages(new ErrorMessage("Please login to participate in chat!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentChannel == null) return;
|
||||
|
||||
if (postText[0] == '/')
|
||||
{
|
||||
// TODO: handle commands
|
||||
currentChannel.AddNewMessages(new ErrorMessage("Chat commands are not supported yet!"));
|
||||
textbox.Text = string.Empty;
|
||||
target.AddNewMessages(new ErrorMessage("Chat commands are not supported yet!"));
|
||||
return;
|
||||
}
|
||||
|
||||
var message = new Message
|
||||
var message = new LocalEchoMessage
|
||||
{
|
||||
Sender = api.LocalUser.Value,
|
||||
Timestamp = DateTimeOffset.Now,
|
||||
TargetType = TargetType.Channel, //TODO: read this from currentChannel
|
||||
TargetId = currentChannel.Id,
|
||||
TargetType = TargetType.Channel, //TODO: read this from channel
|
||||
TargetId = target.Id,
|
||||
Content = postText
|
||||
};
|
||||
|
||||
textbox.ReadOnly = true;
|
||||
var req = new PostMessageRequest(message);
|
||||
|
||||
req.Failure += e =>
|
||||
{
|
||||
textbox.FlashColour(Color4.Red, 1000);
|
||||
textbox.ReadOnly = false;
|
||||
};
|
||||
|
||||
req.Success += m =>
|
||||
{
|
||||
currentChannel.AddNewMessages(m);
|
||||
|
||||
textbox.ReadOnly = false;
|
||||
textbox.Text = string.Empty;
|
||||
};
|
||||
target.AddLocalEcho(message);
|
||||
req.Failure += e => target.ReplaceMessage(message, null);
|
||||
req.Success += m => target.ReplaceMessage(message, m);
|
||||
|
||||
api.Queue(req);
|
||||
}
|
||||
|
Reference in New Issue
Block a user