fix: polish lobby chat and joystick
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6508ec0f8203b6d4e868b5a74194a926
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+42
@@ -24,10 +24,13 @@ namespace XGame
|
||||
private TMP_InputField inputField;
|
||||
private TMP_Text inputPlaceholder;
|
||||
private TMP_Text inputValue;
|
||||
private TMP_Text collapsedPreviewText;
|
||||
private ScrollRect scrollMessages;
|
||||
private bool opening;
|
||||
private int openVersion;
|
||||
private int localPlayerId;
|
||||
private string collapsedDefaultText;
|
||||
private string lastCollapsedPreview;
|
||||
private readonly Queue<GameObject> messageRows = new Queue<GameObject>();
|
||||
|
||||
public Action<string> OnSendWorldChat;
|
||||
@@ -89,7 +92,10 @@ namespace XGame
|
||||
inputField = null;
|
||||
inputPlaceholder = null;
|
||||
inputValue = null;
|
||||
collapsedPreviewText = null;
|
||||
scrollMessages = null;
|
||||
collapsedDefaultText = null;
|
||||
lastCollapsedPreview = null;
|
||||
opening = false;
|
||||
}
|
||||
|
||||
@@ -128,6 +134,12 @@ namespace XGame
|
||||
scrollMessages = FindComponent<ScrollRect>("Scroll_Messages");
|
||||
inputPlaceholder = FindComponent<TMP_Text>("Txt_InputPlaceholder");
|
||||
inputValue = FindComponent<TMP_Text>("Txt_InputValue");
|
||||
collapsedPreviewText = FindComponent<TMP_Text>("Txt_CollapsedPlaceholder");
|
||||
if (collapsedPreviewText != null && string.IsNullOrEmpty(collapsedDefaultText))
|
||||
{
|
||||
collapsedDefaultText = collapsedPreviewText.text;
|
||||
}
|
||||
RefreshCollapsedPreview();
|
||||
EnsureInputField();
|
||||
}
|
||||
|
||||
@@ -142,6 +154,8 @@ namespace XGame
|
||||
{
|
||||
inputField.onSubmit.RemoveListener(OnInputSubmitted);
|
||||
inputField.onSubmit.AddListener(OnInputSubmitted);
|
||||
inputField.onEndEdit.RemoveListener(OnInputEndEdit);
|
||||
inputField.onEndEdit.AddListener(OnInputEndEdit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,6 +273,11 @@ namespace XGame
|
||||
SendCurrentInput();
|
||||
}
|
||||
|
||||
private void OnInputEndEdit(string text)
|
||||
{
|
||||
SendCurrentInput();
|
||||
}
|
||||
|
||||
private void SendCurrentInput()
|
||||
{
|
||||
string text = inputField == null ? string.Empty : inputField.text;
|
||||
@@ -271,6 +290,7 @@ namespace XGame
|
||||
{
|
||||
text = text.Substring(0, MaxInputLength);
|
||||
}
|
||||
Debug.Log("[WorldChatModule] send world chat length=" + text.Length);
|
||||
OnSendWorldChat?.Invoke(text);
|
||||
ClearInput();
|
||||
FocusInput();
|
||||
@@ -326,6 +346,28 @@ namespace XGame
|
||||
{
|
||||
StartCoroutine(ScrollToBottomNextFrame());
|
||||
}
|
||||
SetCollapsedPreview(message, isSelf);
|
||||
}
|
||||
|
||||
private void SetCollapsedPreview(WorldChatMessageMsg message, bool isSelf)
|
||||
{
|
||||
string name = isSelf ? "\u6211" : message.PlayerName;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
name = "\u73A9\u5BB6";
|
||||
}
|
||||
lastCollapsedPreview = name + ": " + (message.Text ?? string.Empty);
|
||||
RefreshCollapsedPreview();
|
||||
}
|
||||
|
||||
private void RefreshCollapsedPreview()
|
||||
{
|
||||
if (collapsedPreviewText != null)
|
||||
{
|
||||
collapsedPreviewText.text = string.IsNullOrEmpty(lastCollapsedPreview)
|
||||
? (collapsedDefaultText ?? string.Empty)
|
||||
: lastCollapsedPreview;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator ScrollToBottomNextFrame()
|
||||
+3
-3
@@ -6,6 +6,6 @@ MonoImporter:
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user