public void Add(string _message, ChatAudibleLevel _audible, ChatType _type, ChatSourceType _sourcetype, string _fromName, UUID _id, UUID _ownerid, Vector3 _position) { Reference.Log.Debug(_message + " ChatAudibleLevel:" + _audible.ToString() + " ChatType:" + _type.ToString() + " ChatSourceType:" + _sourcetype.ToString() + " FromName:" + _fromName); // name. string fromName = _fromName + ":"; lock (messageHistory) { messageHistory.Add(fromName); Reference.Viewer.GuiManager.ChatAddMessage(fromName); } // message. string msg = _message; if (_message.Length > maxMessageLength) { string tail = "・・・"; msg = _message.Substring(0, maxMessageLength - tail.Length); msg += tail; } // wide-char space -> 2 char space. msg = msg.Replace(" ", " "); // trim space. msg = msg.Trim(); List<int> colLen = new List<int>(); int colMaxLen = 16 * 2; int lenCounter = 0; for (int i = 0; i < msg.Length; i++) { char c = msg[i]; if (c < '!' || '~' < c) { lenCounter += 2; } else { lenCounter += 1; } if ((lenCounter >= colMaxLen) || ((i + 1) == msg.Length)) { colLen.Add(i + 1); lenCounter = 0; } } List<string> msgList = new List<string>(); for (int i = 0; i < colLen.Count; i++) { int start = (i > 0 ? colLen[i - 1] : 0); int length = (i > 0 ? colLen[i] - colLen[i - 1] : colLen[i]); string text = msg.Substring(start, length); msgList.Add(text); } for (int i = 0; i < msgList.Count; i++) { // message. string addMessage = " " + msgList[i]; lock (messageHistory) { messageHistory.Add(addMessage); Reference.Viewer.GuiManager.ChatAddMessage(addMessage); } } Reference.Viewer.Adapter.CallReceiveMessaged(_id.ToString(), _fromName, _message); }
void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourceType, string fromName, UUID id, UUID ownerid, Vector3 position) { if (type == ChatType.StartTyping || type == ChatType.StopTyping || audible != ChatAudibleLevel.Fully) return; if (!Session.Settings.DisplayChat) return; char[] splitChar = { ' ' }; string[] msg = message.Split(splitChar); bool action; if (msg[0].ToLower() == "/me") { action = true; message = String.Join(" ", msg, 1, msg.Length - 1); } else action = false; Display.Chat(Session.SessionNumber, fromName, message, action, type, sourceType); if (id == Session.Client.Self.AgentID) return; Dictionary<string, string> identifiers = new Dictionary<string, string>(); identifiers.Add("$name", fromName); identifiers.Add("$message", message); identifiers.Add("$id", id.ToString()); identifiers.Add("$ownerid", ownerid.ToString()); identifiers.Add("$ctype", type.ToString()); identifiers.Add("$stype", sourceType.ToString()); identifiers.Add("$pos", position.ToString()); for (int i = 0; i < msg.Length; i++) identifiers.Add("$" + (i + 1), msg[i]); ScriptSystem.TriggerEvents(Session.SessionNumber, ScriptSystem.EventTypes.Chat, identifiers); }