//
// Radegast Metaverse Client
-// Copyright (c) 2009-2011, Radegast Development Team
+// Copyright (c) 2009-2014, Radegast Development Team
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
{
public class ChatTextManager : IDisposable
{
+ public event EventHandler<ChatLineAddedArgs> ChatLineAdded;
+
private RadegastInstance instance;
private RadegastNetcom netcom { get { return instance.Netcom; } }
private GridClient client { get { return instance.Client; } }
if (e.Message.ToLower().Contains("autopilot canceled")) return; //workaround the stupid autopilot alerts
ChatBufferItem item = new ChatBufferItem(
- DateTime.Now, "Alert message: " + e.Message, ChatBufferTextStyle.Alert);
+ DateTime.Now, "Alert message", UUID.Zero, ": " + e.Message, ChatBufferTextStyle.Alert);
ProcessBufferItem(item, true);
}
public void PrintStartupMessage()
{
ChatBufferItem title = new ChatBufferItem(
- DateTime.Now, Properties.Resources.RadegastTitle + "." + RadegastBuild.CurrentRev, ChatBufferTextStyle.StartupTitle);
+ DateTime.Now, "", UUID.Zero, Properties.Resources.RadegastTitle + "." + RadegastBuild.CurrentRev, ChatBufferTextStyle.StartupTitle);
ChatBufferItem ready = new ChatBufferItem(
- DateTime.Now, "Ready.", ChatBufferTextStyle.StatusBlue);
+ DateTime.Now, "", UUID.Zero, "Ready.", ChatBufferTextStyle.StatusBlue);
ProcessBufferItem(title, true);
ProcessBufferItem(ready, true);
public void ProcessBufferItem(ChatBufferItem item, bool addToBuffer)
{
+ if (ChatLineAdded != null)
+ {
+ ChatLineAdded(this, new ChatLineAddedArgs(item));
+ }
+
lock (SyncChat)
{
- instance.LogClientMessage("chat.txt", item.Text);
+ instance.LogClientMessage("chat.txt", item.From + item.Text);
if (addToBuffer) textBuffer.Add(item);
if (showTimestamps)
break;
}
- textPrinter.PrintTextLine(item.Text);
+ if (item.Style == ChatBufferTextStyle.Normal && item.ID != UUID.Zero && instance.GlobalSettings["av_name_link"])
+ {
+ textPrinter.InsertLink(item.From, string.Format("secondlife:///app/agent/{0}/about", item.ID));
+ textPrinter.PrintTextLine(item.Text);
+ }
+ else
+ {
+ textPrinter.PrintTextLine(item.From + item.Text);
+ }
}
}
{
StringBuilder sb = new StringBuilder();
- sb.AppendFormat("(channel {0}) {1}", e.Channel, client.Self.Name);
-
switch (e.Type)
{
case ChatType.Normal:
sb.Append(e.Message);
ChatBufferItem item = new ChatBufferItem(
- DateTime.Now, sb.ToString(), ChatBufferTextStyle.StatusDarkBlue);
+ DateTime.Now, string.Format("(channel {0}) {1}", e.Channel, client.Self.Name), client.Self.AgentID, sb.ToString(), ChatBufferTextStyle.StatusDarkBlue);
ProcessBufferItem(item, true);
null != client.Self.MuteList.Find(me => me.Type == MuteType.Resident && me.ID == e.SourceID)
) return;
+ // Check if it's script debug
+ if (e.Type == ChatType.Debug && !instance.GlobalSettings["show_script_errors"])
+ {
+ return;
+ }
+
// Check if sender object is muted
if (e.SourceType == ChatSourceType.Object &&
null != client.Self.MuteList.Find(me =>
{
instance.RLV.TryProcessCMD(e);
#if !DEBUG
- return;
+ if (!instance.RLV.EnabledDebugCommands) {
+ return;
+ }
#endif
}
+ ChatBufferItem item = new ChatBufferItem();
+ item.ID = e.SourceID;
+ item.RawMessage = e;
StringBuilder sb = new StringBuilder();
- // if (e.SourceType == ChatSourceType.Object) {
- // sb.Append(e.Position + " ");
- // }
+
if (e.SourceType == ChatSourceType.Agent)
{
- sb.Append(instance.Names.Get(e.SourceID, e.FromName));
+ item.From = instance.Names.Get(e.SourceID, e.FromName);
}
else
{
- sb.Append(e.FromName);
+ item.From = e.FromName;
}
- bool isEmote = e.Message.StartsWith("/me ");
+ bool isEmote = e.Message.ToLower().StartsWith("/me ");
if (!isEmote)
{
sb.Append(e.Message);
}
- ChatBufferItem item = new ChatBufferItem();
item.Timestamp = DateTime.Now;
item.Text = sb.ToString();
{
item.Style = ChatBufferTextStyle.OwnerSay;
}
+ else if (e.Type == ChatType.Debug)
+ {
+ item.Style = ChatBufferTextStyle.Error;
+ }
else
{
item.Style = ChatBufferTextStyle.ObjectChat;
set { textPrinter = value; }
}
}
+
+ public class ChatLineAddedArgs : EventArgs
+ {
+ ChatBufferItem mItem;
+ public ChatBufferItem Item { get { return mItem; } }
+
+ public ChatLineAddedArgs(ChatBufferItem item)
+ {
+ mItem = item;
+ }
+ }
}