public void SetChat(int chatId) { currentChatId = chatId; state = MessageViewState.Chat; newMessageTask = beginDisplayingMessages(); }
public void SetLastMessageReceived(string topic, Message message) { lastMessageReceived = new MessageViewState() { label = "Last Message Received:", message = message }; lastMessageReceivedMeta = $"{topic} (time: {System.DateTime.Now.TimeOfDay})"; redrawGUI = true; }
public void SetChannel(int?channelId) { currentChannelId = channelId; //Sets our state, so the program knows if we're in a channel or chat state = MessageViewState.Channel; newMessageTask = beginDisplayingMessages().ContinueWith(t => Console.WriteLine("Message fetcher stopped")); }
public void AddServiceResponse(int serviceID, Message response) { lastCompletedServiceRequest = activeServices.Find(s => s.serviceID == serviceID); activeServices.Remove(lastCompletedServiceRequest); lastCompletedServiceResponse = new MessageViewState() { serviceID = serviceID, timestamp = Time.time, topic = lastCompletedServiceRequest.topic, message = response, label = $"{lastCompletedServiceRequest.topic} Service Response", }; }
/// <summary> /// Displays a MessageViewState /// </summary> /// <param name="msgView">The message view to draw</param> /// <param name="y">The Y position to draw at</param> /// <param name="showElapsedTime">Whether to add elapsed time to the title</param> /// <returns>The new Y position to draw at</returns> float ShowMessage(MessageViewState msgView, float y, bool showElapsedTime = false) { if (msgView == null) { return(y); } // Start scrollviews float height = msgView.contentRect.height > 0 ? Mathf.Min(msgView.contentRect.height, 200) : 200; Rect panelRect = new Rect(0, y + 5, 325, height); msgView.scrollPosition = GUI.BeginScrollView(panelRect, msgView.scrollPosition, msgView.contentRect); GUILayout.BeginVertical("box"); // Paste contents of message if (showElapsedTime) { GUILayout.Label($"{msgView.label} ({Time.time - msgView.timestamp})", labelStyle); } else { GUILayout.Label(msgView.label, labelStyle); } GUILayout.Label(msgView.message.ToString(), messageStyle); GUILayout.EndVertical(); GUI.EndScrollView(); // Update size of internal rect view if (GUILayoutUtility.GetLastRect().height > 1 && GUILayoutUtility.GetLastRect().width > 1) { msgView.contentRect = GUILayoutUtility.GetLastRect(); } return(panelRect.yMax); }