From 3370d581e1c5297721a05db857a016e1d728018f Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 23 Apr 2008 12:21:54 +0000 Subject: * Patch #1026 - llDialog support -- Thanks Melanie! --- OpenSim/Region/ClientStack/ClientView.cs | 27 ++++++++++ .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 6 +++ .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 63 ++++++++++++++++++---- 3 files changed, 87 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index a58f88f..9e8830f 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -233,6 +233,7 @@ namespace OpenSim.Region.ClientStack private RequestAsset handlerRequestAsset = null; // OnRequestAsset; private UUIDNameRequest handlerTeleportHomeRequest = null; + private ScriptAnswer handlerScriptAnswer = null; /* Properties */ @@ -789,6 +790,8 @@ namespace OpenSim.Region.ClientStack public event UUIDNameRequest OnTeleportHomeRequest; + public event ScriptAnswer OnScriptAnswer; + #region Scene/Avatar to Client /// @@ -2484,6 +2487,20 @@ namespace OpenSim.Region.ClientStack return true; } + public void SendScriptQuestion(LLUUID taskID, string taskName, string ownerName, LLUUID itemID, int question) + { + ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion); + scriptQuestion.Data = new ScriptQuestionPacket.DataBlock(); + // TODO: don't create new blocks if recycling an old packet + scriptQuestion.Data.TaskID = taskID; + scriptQuestion.Data.ItemID = itemID; + scriptQuestion.Data.Questions = question; + scriptQuestion.Data.ObjectName = Helpers.StringToField(taskName); + scriptQuestion.Data.ObjectOwner = Helpers.StringToField(ownerName); + + OutPacket(scriptQuestion, ThrottleOutPacketType.Task); + } + protected virtual bool Logout(IClientAPI client, Packet packet) { m_log.Info("[CLIENT]: Got a logout request"); @@ -3840,6 +3857,16 @@ namespace OpenSim.Region.ClientStack } break; + case PacketType.ScriptAnswerYes: + ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack; + + handlerScriptAnswer = OnScriptAnswer; + if (handlerScriptAnswer != null) + { + handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions); + } + break; + #endregion #region Inventory/Asset/Other related packets diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 199653d..4f9024c 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -166,6 +166,8 @@ namespace OpenSim.Region.Examples.SimpleModule public event ObjectIncludeInSearch OnObjectIncludeInSearch; public event UUIDNameRequest OnTeleportHomeRequest; + public event ScriptAnswer OnScriptAnswer; + #pragma warning restore 67 @@ -593,5 +595,9 @@ namespace OpenSim.Region.Examples.SimpleModule public void SetClientInfo(ClientInfo info) { } + + public void SendScriptQuestion(LLUUID objectID, string taskName, string ownerName, LLUUID itemID, int question) + { + } } } diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index a8eb824..3dff98f 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -69,6 +69,8 @@ namespace OpenSim.Region.ScriptEngine.Common private DateTime m_timer = DateTime.Now; private string m_state = "default"; + private bool m_waitingForScriptAnswer=false; + public string State { @@ -1950,11 +1952,6 @@ namespace OpenSim.Region.ScriptEngine.Common m_host.AddScriptLPS(1); - // Cannot combine debit with anything else since the new debit perms dialog has been introduced. - if((perm & BuiltIn_Commands_BaseClass.PERMISSION_DEBIT) != 0 && - perm != BuiltIn_Commands_BaseClass.PERMISSION_DEBIT) - perm &= ~BuiltIn_Commands_BaseClass.PERMISSION_DEBIT;// Silently ignore debit request - bool attachment=false; // Attachments not implemented yet. TODO: reflect real attachemnt state if(attachment && agent == m_host.OwnerID) @@ -1993,15 +1990,48 @@ namespace OpenSim.Region.ScriptEngine.Common } } - // TODO: Implement perms dialog sending + if (World.m_innerScene.ScenePresences.ContainsKey(agentID)) + { + string ownerName=resolveName(m_host.ParentGroup.RootPart.OwnerID); + if(ownerName == String.Empty) + ownerName="(hippos)"; + + ScenePresence presence = World.m_innerScene.ScenePresences[agentID]; + if(!m_waitingForScriptAnswer) + { + m_host.TaskInventory[invItemID].PermsGranter=agentID; + m_host.TaskInventory[invItemID].PermsMask=0; + presence.ControllingClient.OnScriptAnswer+=handleScriptAnswer; + m_waitingForScriptAnswer=true; + } + + presence.ControllingClient.SendScriptQuestion(m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); + return; + } - // Refuse perms for now + // Requested agent is not in range, refuse perms m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {(int)0}); - - NotImplemented("llRequestPermissions"); } + void handleScriptAnswer(IClientAPI client, LLUUID taskID, LLUUID itemID, int answer) + { + if(taskID != m_host.UUID) + return; + + LLUUID invItemID=InventorySelf(); + + if(invItemID == LLUUID.Zero) + return; + + client.OnScriptAnswer-=handleScriptAnswer; + m_waitingForScriptAnswer=false; + + m_host.TaskInventory[invItemID].PermsMask=answer; + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( + m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {(int)answer}); + } + public string llGetPermissionsKey() { m_host.AddScriptLPS(1); @@ -3924,9 +3954,24 @@ namespace OpenSim.Region.ScriptEngine.Common LSLError("First parameter to llDialog needs to be a key"); return; } + if(buttons.Length > 12) + { + LSLError("No more than 12 buttons can be shown"); + return; + } string[] buts = new string[buttons.Length]; for(int i = 0; i < buttons.Length; i++) { + if(buttons.Data[i].ToString() == String.Empty) + { + LSLError("button label cannot be blank"); + return; + } + if(buttons.Data[i].ToString().Length > 24) + { + LSLError("button label cannot be longer than 24 characters"); + return; + } 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); -- cgit v1.1