using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json.Linq; using TMPro; using UnityEngine; using UnityEngine.Networking; using UnityEngine.SceneManagement; using UnityEngine.UI; public class ChatroomMenu : MonoBehaviour { private readonly static WaitForSeconds _waitForSeconds2 = new(2f); private readonly static WaitForSeconds _waitForSeconds3 = new(3f); public TMP_Text statusText; public Button backButton; public Button sendButton; public TMP_InputField messageInputField; public GameObject content; public GameObject sampleObject; private string statusMessage; private Coroutine statusRoutine; private Coroutine refreshLoopRoutine; private bool shouldScrollToBottom = true; public Button downButton; private bool isPaused; public GameObject optionsPanel; public Button optionsPanelExitButton; public Button optionsPanelDeleteButton; public Button optionsPanelEditButton; public Button optionsPanelReportButton; public Button optionsPanelCopyButton; private ChatroomMessage selectedMessageForOptions; public GameObject editMessagePanelSample; private GameObject editMessagePanelCurrent; public GameObject reportMessagePanel; public Button reportMessagePanelExitButton; public Button reportMessagePanelSubmitButton; public TMP_InputField reportMessagePanelReportReason; public Dictionary customIcons; void Start() { reportMessagePanelReportReason.transform.GetChild(0).GetChild(1).GetComponent().textWrappingMode = TextWrappingModes.Normal; if (BazookaManager.Instance.GetAccountID() == null || BazookaManager.Instance.GetAccountName() == null || BazookaManager.Instance.GetAccountSession() == null) { sendButton.interactable = false; messageInputField.interactable = false; ShowStatus("Warning: You are not logged in. Please log in to send messages."); } backButton.onClick.AddListener(async () => await SceneManager.LoadSceneAsync("MainMenu")); sendButton.onClick.AddListener(async () => await HandleMessageSubmit()); downButton.onClick.AddListener(() => StartCoroutine(ScrollToBottom())); messageInputField.textComponent.textWrappingMode = TextWrappingModes.Normal; messageInputField.onSubmit.AddListener(async (_) => await HandleMessageSubmit()); refreshLoopRoutine = StartCoroutine(Loop()); optionsPanelExitButton.onClick.AddListener(() => { optionsPanel.SetActive(false); selectedMessageForOptions = null; }); optionsPanelDeleteButton.onClick.AddListener(async () => { if (selectedMessageForOptions != null) await HandleDelete(); }); optionsPanelDeleteButton.onClick.AddListener(optionsPanelExitButton.onClick.Invoke); optionsPanelEditButton.onClick.AddListener(() => { var editMessage = Instantiate(editMessagePanelSample, editMessagePanelSample.transform.parent); editMessagePanelCurrent = editMessage; var editMessageChild = editMessage.transform.GetChild(0); var editMessageChildExitButton = editMessageChild.GetChild(0).GetComponent