//
// Radegast Metaverse Client
-// Copyright (c) 2009, Radegast Development Team
+// Copyright (c) 2009-2014, Radegast Development Team
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
private UUID session;
private IMTextManager textManager;
private object AvatarListSyncRoot = new object();
+ private List<string> chatHistory = new List<string>();
+ private int chatPointer;
ManualResetEvent WaitForSessionStart = new ManualResetEvent(false);
// Callbacks
RegisterClientEvents(client);
- client.Self.RequestJoinGroupChat(session);
-
+ if (!client.Self.GroupChatSessions.ContainsKey(session))
+ {
+ client.Self.RequestJoinGroupChat(session);
+ }
UpdateFontSize();
+ Load += new EventHandler(GroupIMTabWindow_Load);
}
private void RegisterClientEvents(GridClient client)
client.Self.GroupChatJoined += new EventHandler<GroupChatJoinedEventArgs>(Self_GroupChatJoined);
client.Self.ChatSessionMemberAdded += new EventHandler<ChatSessionMemberAddedEventArgs>(Self_ChatSessionMemberAdded);
client.Self.ChatSessionMemberLeft += new EventHandler<ChatSessionMemberLeftEventArgs>(Self_ChatSessionMemberLeft);
- client.Avatars.UUIDNameReply += new EventHandler<UUIDNameReplyEventArgs>(Avatars_UUIDNameReply);
+ instance.Names.NameUpdated += new EventHandler<UUIDNameReplyEventArgs>(Names_NameUpdated);
instance.Netcom.ClientConnected += new EventHandler<EventArgs>(Netcom_Connected);
instance.Netcom.ClientDisconnected += new EventHandler<DisconnectedEventArgs>(Netcom_Disconnected);
instance.GlobalSettings.OnSettingChanged += new Settings.SettingChangedCallback(GlobalSettings_OnSettingChanged);
client.Self.GroupChatJoined -= new EventHandler<GroupChatJoinedEventArgs>(Self_GroupChatJoined);
client.Self.ChatSessionMemberAdded -= new EventHandler<ChatSessionMemberAddedEventArgs>(Self_ChatSessionMemberAdded);
client.Self.ChatSessionMemberLeft -= new EventHandler<ChatSessionMemberLeftEventArgs>(Self_ChatSessionMemberLeft);
- client.Avatars.UUIDNameReply -= new EventHandler<UUIDNameReplyEventArgs>(Avatars_UUIDNameReply);
+ instance.Names.NameUpdated -= new EventHandler<UUIDNameReplyEventArgs>(Names_NameUpdated);
instance.Netcom.ClientConnected -= new EventHandler<EventArgs>(Netcom_Connected);
instance.Netcom.ClientDisconnected -= new EventHandler<DisconnectedEventArgs>(Netcom_Disconnected);
instance.GlobalSettings.OnSettingChanged -= new Settings.SettingChangedCallback(GlobalSettings_OnSettingChanged);
RegisterClientEvents(client);
}
+ void GroupIMTabWindow_Load(object sender, EventArgs e)
+ {
+ UpdateParticipantList();
+ }
+
private void IMTabWindow_Disposed(object sender, EventArgs e)
{
if (instance.Netcom.IsLoggedIn)
{
if (e.Key == "chat_font_size")
UpdateFontSize();
+ else if (e.Key == "display_name_mode")
+ UpdateParticipantList();
}
void Netcom_Disconnected(object sender, DisconnectedEventArgs e)
RefreshControls();
}
- void Avatars_UUIDNameReply(object sender, UUIDNameReplyEventArgs e)
+ void Names_NameUpdated(object sender, UUIDNameReplyEventArgs e)
{
if (InvokeRequired)
{
- if (IsHandleCreated)
- BeginInvoke(new MethodInvoker(() => Avatars_UUIDNameReply(sender, e)));
+ if (!instance.MonoRuntime || IsHandleCreated)
+ BeginInvoke(new MethodInvoker(() => Names_NameUpdated(sender, e)));
return;
}
{
if (InvokeRequired)
{
- if (IsHandleCreated)
+ if (!instance.MonoRuntime || IsHandleCreated)
BeginInvoke(new MethodInvoker(UpdateParticipantList));
return;
}
Participants.Items.Clear();
List<ChatSessionMember> participants;
- List<UUID> nameLookup = new List<UUID>();
if (client.Self.GroupChatSessions.TryGetValue(session, out participants))
{
ChatSessionMember participant = members[i];
ListViewItem item = new ListViewItem();
item.Name = participant.AvatarKey.ToString();
- if (instance.nameCache.ContainsKey(participant.AvatarKey))
- {
- item.Text = instance.nameCache[participant.AvatarKey];
- }
- else
- {
- item.Text = RadegastInstance.INCOMPLETE_NAME;
- nameLookup.Add(participant.AvatarKey);
- }
+ item.Text = instance.Names.Get(participant.AvatarKey);
+ item.Tag = participant.AvatarKey;
+
if (participant.IsModerator)
item.Font = new Font(item.Font, FontStyle.Bold);
Participants.Items.Add(item);
}
-
- if (nameLookup.Count > 0)
- client.Avatars.RequestAvatarNames(nameLookup);
}
Participants.Sort();
if (InvokeRequired)
{
- if (IsHandleCreated)
+ if (!instance.MonoRuntime || IsHandleCreated)
Invoke(new MethodInvoker(() => Self_GroupChatJoined(sender, e)));
return;
}
{
if (InvokeRequired)
{
- if (IsHandleCreated)
+ if (!instance.MonoRuntime || IsHandleCreated)
BeginInvoke(new MethodInvoker(RefreshControls));
return;
}
}
}
- private void cbxInput_KeyUp(object sender, KeyEventArgs e)
+ void ChatHistoryPrev()
+ {
+ if (chatPointer == 0) return;
+ chatPointer--;
+ if (chatHistory.Count > chatPointer)
+ {
+ cbxInput.Text = chatHistory[chatPointer];
+ cbxInput.SelectionStart = cbxInput.Text.Length;
+ cbxInput.SelectionLength = 0;
+ }
+ }
+
+ void ChatHistoryNext()
{
+ if (chatPointer == chatHistory.Count) return;
+ chatPointer++;
+ if (chatPointer == chatHistory.Count)
+ {
+ cbxInput.Text = string.Empty;
+ return;
+ }
+ cbxInput.Text = chatHistory[chatPointer];
+ cbxInput.SelectionStart = cbxInput.Text.Length;
+ cbxInput.SelectionLength = 0;
+ }
+
+
+ private void cbxInput_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Up && e.Modifiers == Keys.Control)
+ {
+ e.Handled = e.SuppressKeyPress = true;
+ ChatHistoryPrev();
+ return;
+ }
+
+ if (e.KeyCode == Keys.Down && e.Modifiers == Keys.Control)
+ {
+ e.Handled = e.SuppressKeyPress = true;
+ ChatHistoryNext();
+ return;
+ }
+
if (e.KeyCode != Keys.Enter) return;
- e.SuppressKeyPress = true;
+ e.Handled = e.SuppressKeyPress = true;
SendMsg();
}
{
if (cbxInput.Text.Length == 0) return;
+ chatHistory.Add(cbxInput.Text);
+ chatPointer = chatHistory.Count;
+
string message = cbxInput.Text.Replace(ChatInputBox.NewlineMarker, "\n");
if (instance.GlobalSettings["mu_emotes"].AsBoolean() && message.StartsWith(":"))
instance.MainForm.ProcessLink(e.LinkText);
}
- private void cbxInput_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter) e.SuppressKeyPress = true;
- }
-
public UUID SessionId
{
get { return session; }
{
pnlChatInput.Height = cbxInput.Height + 7;
}
+
+ private void avatarContext_Opening(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ if (Participants.SelectedItems.Count != 1)
+ {
+ e.Cancel = true;
+ return;
+ }
+
+ UUID av = (UUID)Participants.SelectedItems[0].Tag;
+
+ if (av == client.Self.AgentID)
+ {
+ ctxMute.Enabled = ctxPay.Enabled = ctxStartIM.Enabled = false;
+ }
+ else
+ {
+ ctxMute.Enabled = ctxPay.Enabled = ctxStartIM.Enabled = true;
+
+ bool isMuted = client.Self.MuteList.Find(me => me.Type == MuteType.Resident && me.ID == av) != null;
+ ctxMute.Text = isMuted ? "Unmute" : "Mute";
+ }
+ }
+
+ private void ctxProfile_Click(object sender, EventArgs e)
+ {
+ if (Participants.SelectedItems.Count != 1) return;
+ UUID av = (UUID)Participants.SelectedItems[0].Tag;
+ string name = instance.Names.Get(av);
+
+ instance.MainForm.ShowAgentProfile(name, av);
+ }
+
+ private void ctxPay_Click(object sender, EventArgs e)
+ {
+ if (Participants.SelectedItems.Count != 1) return;
+ UUID av = (UUID)Participants.SelectedItems[0].Tag;
+ string name = instance.Names.Get(av);
+
+ new frmPay(instance, av, name, false).ShowDialog();
+ }
+
+ private void ctxStartIM_Click(object sender, EventArgs e)
+ {
+ if (Participants.SelectedItems.Count != 1) return;
+ UUID av = (UUID)Participants.SelectedItems[0].Tag;
+ string name = instance.Names.Get(av);
+
+ instance.TabConsole.ShowIMTab(av, name, true);
+ }
+
+ private void ctxOfferTP_Click(object sender, EventArgs e)
+ {
+ if (Participants.SelectedItems.Count != 1) return;
+ UUID av = (UUID)Participants.SelectedItems[0].Tag;
+ client.Self.SendTeleportLure(av, "Join me in " + client.Network.CurrentSim.Name + "!");
+ }
+
+ private void ctxReqestLure_Click(object sender, EventArgs e)
+ {
+ if (Participants.SelectedItems.Count != 1) return;
+ UUID av = (UUID)Participants.SelectedItems[0].Tag;
+ instance.MainForm.AddNotification(new ntfSendLureRequest(instance, av));
+ }
+
+ private void ctxEject_Click(object sender, EventArgs e)
+ {
+ if (Participants.SelectedItems.Count != 1) return;
+ UUID av = (UUID)Participants.SelectedItems[0].Tag;
+ instance.Client.Groups.EjectUser(session, av);
+ }
+
+ private void ctxBan_Click(object sender, EventArgs e)
+ {
+ if (Participants.SelectedItems.Count != 1) return;
+ UUID av = (UUID)Participants.SelectedItems[0].Tag;
+ }
+
+ private void ctxMute_Click(object sender, EventArgs e)
+ {
+ if (Participants.SelectedItems.Count != 1) return;
+ UUID av = (UUID)Participants.SelectedItems[0].Tag;
+ if (av == client.Self.AgentID) return;
+
+ if (ctxMute.Text == "Mute")
+ {
+ client.Self.UpdateMuteListEntry(MuteType.Resident, av, instance.Names.GetLegacyName(av));
+ }
+ else
+ {
+ client.Self.RemoveMuteListEntry(av, instance.Names.GetLegacyName(av));
+ }
+ }
}
}