diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 9bf1f9a053..aaf27bb195 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -609,6 +609,7 @@ namespace OpenSim.Framework void SendAgentAlertMessage(string message, bool modal); void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url); + void SendDialog(string objectname, LLUUID objectID, LLUUID ownerID, string msg, LLUUID textureID, int ch, string[] buttonlabels); bool AddMoney(int debit); void SendSunPos(LLVector3 sunPos, LLVector3 sunVel); diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index c68c3c76ed..4aceac007f 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -1299,10 +1299,28 @@ namespace OpenSim.Region.ClientStack loadURL.Data.OwnerIsGroup = groupOwned; loadURL.Data.Message = Helpers.StringToField(message); loadURL.Data.URL = Helpers.StringToField(url); - OutPacket(loadURL, ThrottleOutPacketType.Task); } + public void SendDialog(string objectname, LLUUID objectID, LLUUID ownerID, string msg, LLUUID textureID, int ch, string[] buttonlabels) + { + ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog); + dialog.Data.ObjectID = objectID; + dialog.Data.ObjectName = Helpers.StringToField(objectname); + dialog.Data.FirstName = Helpers.StringToField(this.FirstName); + dialog.Data.LastName = Helpers.StringToField(this.LastName); + dialog.Data.Message = Helpers.StringToField(msg); + dialog.Data.ImageID = textureID; + dialog.Data.ChatChannel = ch; + ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[buttonlabels.Length]; + for (int i = 0; i < buttonlabels.Length; i++) + { + buttons[i] = new ScriptDialogPacket.ButtonsBlock(); + buttons[i].ButtonLabel = Helpers.StringToField(buttonlabels[i]); + } + dialog.Buttons = buttons; + OutPacket(dialog, ThrottleOutPacketType.Task); + } public void SendPreLoadSound(LLUUID objectID, LLUUID ownerID, LLUUID soundID) { @@ -2617,6 +2635,23 @@ namespace OpenSim.Region.ClientStack OnChatFromViewer(this, args); } break; + case PacketType.ScriptDialogReply: + ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack; + int ch = rdialog.Data.ChatChannel; + byte[] msg = rdialog.Data.ButtonLabel; + if (OnChatFromViewer != null) + { + ChatFromViewerArgs args = new ChatFromViewerArgs(); + args.Channel = ch; + args.From = String.Empty; + args.Message = Helpers.FieldToUTF8String(msg); + args.Type = ChatTypeEnum.Shout; + args.Position = new LLVector3(); + args.Scene = Scene; + args.Sender = this; + OnChatFromViewer(this, args); + } + break; case PacketType.ImprovedInstantMessage: ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack; string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName); diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 464a29ae2d..c99cac0590 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1727,6 +1727,14 @@ namespace OpenSim.Region.Environment.Scenes } } + public void SendDialogToUser(LLUUID avatarID, string objectName, LLUUID objectID, LLUUID ownerID,string message,LLUUID TextureID,int ch,string[] buttonlabels) + { + if (m_scenePresences.ContainsKey(avatarID)) + { + m_scenePresences[avatarID].ControllingClient.SendDialog(objectName,objectID,ownerID,message,TextureID,ch,buttonlabels); + } + } + /// /// /// diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index b5663deaa1..6ae74e6bc9 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -320,6 +320,10 @@ namespace SimpleApp { } + public virtual void SendDialog(string objectname, LLUUID objectID, LLUUID ownerID, string msg, LLUUID textureID, int ch, string[] buttonlabels) + { + } + public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, byte[] color, diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 8ef33d75f2..9d228fa41f 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -2487,7 +2487,19 @@ namespace OpenSim.Region.ScriptEngine.Common public void llDialog(string avatar, string message, LSL_Types.list buttons, int chat_channel) { - NotImplemented("llDialog"); + LLUUID av = new LLUUID(); + if (!LLUUID.TryParse(avatar,out av)) + { + LSLError("First parameter to llDialog needs to be a key"); + return; + } + string[] buts = new string[buttons.Length]; + for(int i = 0; i < buttons.Length; i++) + { + buts[i] = buttons.Data[i].ToString(); + } + World.SendDialogToUser(av, m_host.Name, m_host.UUID, m_host.OwnerID, message, new LLUUID("00000000-0000-2222-3333-100000001000"), chat_channel, buts); + //NotImplemented("llDialog"); } public void llVolumeDetect(int detect)