From ad002835d3ce2ad1eaf3d151a4403e1825d56b55 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 12 Nov 2007 20:25:59 +0000 Subject: [PATCH] enable typing animation for chat, maybe --- OpenSim/Framework/IClientAPI.cs | 2 + .../ClientStack/ClientView.ProcessPackets.cs | 6 +- .../Region/Environment/Modules/ChatModule.cs | 124 ++++++++++-------- .../Environment/Scenes/ScenePresence.cs | 21 ++- bin/data/avataranimations.xml | 1 + 5 files changed, 94 insertions(+), 60 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 1a6d5e58dd..a7238fd6af 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -50,6 +50,8 @@ namespace OpenSim.Framework Whisper = 0, Say = 1, Shout = 2, + StartTyping = 4, + StopTyping = 5, Broadcast = 0xFF } ; diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs index 7414340c3a..978f34e7c7 100644 --- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs +++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs @@ -83,11 +83,7 @@ namespace OpenSim.Region.ClientStack break; case PacketType.ChatFromViewer: ChatFromViewerPacket inchatpack = (ChatFromViewerPacket) Pack; - if (Helpers.FieldToUTF8String(inchatpack.ChatData.Message) == "") - { - //empty message so don't bother with it - break; - } + string fromName = ""; //ClientAvatar.firstname + " " + ClientAvatar.lastname; byte[] message = inchatpack.ChatData.Message; byte type = inchatpack.ChatData.Type; diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index f12612ebf6..d5edc6d6b8 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs @@ -143,7 +143,6 @@ namespace OpenSim.Region.Environment.Modules new LLVector3(scene.RegionInfo.RegionLocX*256, scene.RegionInfo.RegionLocY*256, 0); fromName = avatar.Firstname + " " + avatar.Lastname; fromAgentID = e.Sender.AgentId; - avatar = null; } string typeName; @@ -166,82 +165,101 @@ namespace OpenSim.Region.Environment.Modules break; } - m_log.Verbose("CHAT", - fromName + " (" + e.Channel + " @ " + scene.RegionInfo.RegionName + ") " + typeName + ": " + - e.Message); - - if (m_irc.Connected) + if (e.Message.Length > 0) { - m_irc.PrivMsg(fromName, scene.RegionInfo.RegionName, e.Message); - } + m_log.Verbose("CHAT", + fromName + " (" + e.Channel + " @ " + scene.RegionInfo.RegionName + ") " + typeName + ": " + + e.Message); - if (e.Channel == 0) - { - foreach (Scene m_scene in m_scenes) + if (m_irc.Connected) { - m_scene.ForEachScenePresence(delegate(ScenePresence presence) + m_irc.PrivMsg(fromName, scene.RegionInfo.RegionName, e.Message); + } + + if (e.Channel == 0) + { + foreach (Scene m_scene in m_scenes) + { + m_scene.ForEachScenePresence(delegate(ScenePresence presence) { if (!presence.IsChildAgent) { int dis = -100000; LLVector3 avatarRegionPos = presence.AbsolutePosition + - new LLVector3( - scene.RegionInfo.RegionLocX * 256, - scene.RegionInfo.RegionLocY * 256, - 0); + new LLVector3( + scene.RegionInfo.RegionLocX * 256, + scene.RegionInfo.RegionLocY * 256, + 0); dis = Math.Abs((int)avatarRegionPos.GetDistanceTo(fromRegionPos)); switch (e.Type) { - case ChatTypeEnum.Whisper: - if (dis < m_whisperdistance) - { - //should change so the message is sent through the avatar rather than direct to the ClientView - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - case ChatTypeEnum.Say: - if (dis < m_saydistance) - { - //Console.WriteLine("sending chat"); - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - case ChatTypeEnum.Shout: - if (dis < m_shoutdistance) - { - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - - case ChatTypeEnum.Broadcast: + case ChatTypeEnum.Whisper: + if (dis < m_whisperdistance) + { + //should change so the message is sent through the avatar rather than direct to the ClientView presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, fromAgentID); - break; - default: - break; + } + break; + case ChatTypeEnum.Say: + if (dis < m_saydistance) + { + //Console.WriteLine("sending chat"); + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + case ChatTypeEnum.Shout: + if (dis < m_shoutdistance) + { + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + + case ChatTypeEnum.Broadcast: + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + break; + default: + break; } } }); + } } } + else + { + if (avatar != null) + { + switch (e.Type) + { + case ChatTypeEnum.StartTyping: + avatar.setTyping(true); + break; + case ChatTypeEnum.StopTyping: + avatar.setTyping(false); + break; + } + } + } + } } diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 76d307fa35..ab19973b55 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -53,6 +53,8 @@ namespace OpenSim.Region.Environment.Scenes private LLVector3 m_requestedSitOffset = new LLVector3(); private float m_sitAvatarHeight = 2.0f; + private bool m_isTyping = false; + private Quaternion m_bodyRot; private byte[] m_visualParams; private AvatarWearable[] m_wearables; @@ -367,7 +369,6 @@ namespace OpenSim.Region.Environment.Scenes AddToPhysicalScene(); m_physicsActor.Flying = isFlying; - m_scene.SendAllSceneObjectsToClient(this); } @@ -662,6 +663,10 @@ namespace OpenSim.Region.Environment.Scenes { SendAnimPack(Animations.AnimsLLUUID["CROUCH"], 1); } + else if (m_isTyping) + { + SendAnimPack(Animations.AnimsLLUUID["TYPE"], 1); + } else { SendAnimPack(Animations.AnimsLLUUID["STAND"], 1); @@ -670,7 +675,6 @@ namespace OpenSim.Region.Environment.Scenes } } - protected void AddNewMovement(Vector3 vec, Quaternion rotation) { if (m_isChildAgent) @@ -708,6 +712,19 @@ namespace OpenSim.Region.Environment.Scenes m_forcesList.Add(newVelocity); } + public void setTyping(bool typing) + { + if (m_isChildAgent) + { + MainLog.Instance.Warn("setTyping called on child agent"); + return; + } + + m_isTyping = typing; + + UpdateMovementAnimations(true); + } + #endregion #region Overridden Methods diff --git a/bin/data/avataranimations.xml b/bin/data/avataranimations.xml index 2238474b56..2a537274ff 100644 --- a/bin/data/avataranimations.xml +++ b/bin/data/avataranimations.xml @@ -11,4 +11,5 @@ 7a4e87fe-de39-6fcb-6223-024b00893244 201f3fdf-cb1f-dbec-201f-7333e328ae7c 47f5f6fb-22e5-ae44-f871-73aaaf4a6022 + c541c47f-e0c0-058b-ad1a-d6ae3a4584d9