2.0.0 #92
@@ -44,6 +44,8 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
private float _currentWindowOpacity = DefaultWindowOpacity;
|
||||
private bool _isWindowPinned;
|
||||
private bool _showRulesOverlay;
|
||||
private bool _refocusChatInput;
|
||||
private string? _refocusChatInputKey;
|
||||
|
||||
private string? _selectedChannelKey;
|
||||
private bool _scrollToBottom = true;
|
||||
@@ -308,8 +310,6 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
_draftMessages.TryGetValue(channel.Key, out var draft);
|
||||
draft ??= string.Empty;
|
||||
|
||||
using (ImRaii.Disabled(!canSend))
|
||||
{
|
||||
var style = ImGui.GetStyle();
|
||||
var sendButtonWidth = 100f * ImGuiHelpers.GlobalScale;
|
||||
var counterWidth = ImGui.CalcTextSize($"{MaxMessageLength}/{MaxMessageLength}").X;
|
||||
@@ -317,7 +317,15 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
|
||||
ImGui.SetNextItemWidth(-reservedWidth);
|
||||
var inputId = $"##chat-input-{channel.Key}";
|
||||
var send = ImGui.InputText(inputId, ref draft, MaxMessageLength, ImGuiInputTextFlags.EnterReturnsTrue);
|
||||
if (_refocusChatInput && string.Equals(_refocusChatInputKey, channel.Key, StringComparison.Ordinal))
|
||||
{
|
||||
ImGui.SetKeyboardFocusHere();
|
||||
_refocusChatInput = false;
|
||||
_refocusChatInputKey = null;
|
||||
}
|
||||
ImGui.InputText(inputId, ref draft, MaxMessageLength);
|
||||
var enterPressed = ImGui.IsItemFocused()
|
||||
&& (ImGui.IsKeyPressed(ImGuiKey.Enter) || ImGui.IsKeyPressed(ImGuiKey.KeypadEnter));
|
||||
_draftMessages[channel.Key] = draft;
|
||||
|
||||
ImGui.SameLine();
|
||||
@@ -340,14 +348,22 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, sendHovered);
|
||||
ImGui.PushStyleColor(ImGuiCol.ButtonActive, sendActive);
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 6f * ImGuiHelpers.GlobalScale);
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PaperPlane, "Send", 100f * ImGuiHelpers.GlobalScale, center: true))
|
||||
var sendClicked = false;
|
||||
using (ImRaii.Disabled(!canSend))
|
||||
{
|
||||
send = true;
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PaperPlane, $"Send##chat-send-{channel.Key}", 100f * ImGuiHelpers.GlobalScale, center: true))
|
||||
{
|
||||
sendClicked = true;
|
||||
}
|
||||
}
|
||||
ImGui.PopStyleVar();
|
||||
ImGui.PopStyleColor(3);
|
||||
|
||||
if (send && TrySendDraft(channel, draft))
|
||||
if (canSend && (enterPressed || sendClicked))
|
||||
{
|
||||
_refocusChatInput = true;
|
||||
_refocusChatInputKey = channel.Key;
|
||||
if (TrySendDraft(channel, draft))
|
||||
{
|
||||
_draftMessages[channel.Key] = string.Empty;
|
||||
_scrollToBottom = true;
|
||||
@@ -969,6 +985,12 @@ public sealed class ZoneChatUi : WindowMediatorSubscriberBase
|
||||
_draftMessages.Remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
if (_refocusChatInputKey is not null && !existingKeys.Contains(_refocusChatInputKey))
|
||||
{
|
||||
_refocusChatInputKey = null;
|
||||
_refocusChatInput = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawConnectionControls()
|
||||
|
||||
Reference in New Issue
Block a user