diff options
author | Robert Adams | 2012-02-17 09:12:41 -0800 |
---|---|---|
committer | Robert Adams | 2012-02-17 09:12:41 -0800 |
commit | 6baa13ab7aeb7d0ee08f2460f52961dbd79bada1 (patch) | |
tree | 164b3fb1a8ab98f125b98d39d4720cb915bf3fa8 | |
parent | Merge branch 'master' of /home/opensim/src/opensim (diff) | |
download | opensim-SC-6baa13ab7aeb7d0ee08f2460f52961dbd79bada1.zip opensim-SC-6baa13ab7aeb7d0ee08f2460f52961dbd79bada1.tar.gz opensim-SC-6baa13ab7aeb7d0ee08f2460f52961dbd79bada1.tar.bz2 opensim-SC-6baa13ab7aeb7d0ee08f2460f52961dbd79bada1.tar.xz |
Add new and updated script events
-rw-r--r-- | OpenSim/Region/Framework/Scenes/EventManager.cs | 58 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 12 |
2 files changed, 67 insertions, 3 deletions
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index d31d380..34d3da7 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -184,10 +184,62 @@ namespace OpenSim.Region.Framework.Scenes | |||
184 | 184 | ||
185 | public event ClientClosed OnClientClosed; | 185 | public event ClientClosed OnClientClosed; |
186 | 186 | ||
187 | // Fired when a script is created | ||
188 | // The indication that a new script exists in this region. | ||
189 | public delegate void NewScript(UUID clientID, SceneObjectPart part, UUID itemID); | ||
190 | public event NewScript OnNewScript; | ||
191 | public virtual void TriggerNewScript(UUID clientID, SceneObjectPart part, UUID itemID) | ||
192 | { | ||
193 | NewScript handlerNewScript = OnNewScript; | ||
194 | if (handlerNewScript != null) | ||
195 | { | ||
196 | foreach (NewScript d in handlerNewScript.GetInvocationList()) | ||
197 | { | ||
198 | try | ||
199 | { | ||
200 | d(clientID, part, itemID); | ||
201 | } | ||
202 | catch (Exception e) | ||
203 | { | ||
204 | m_log.ErrorFormat( | ||
205 | "[EVENT MANAGER]: Delegate for TriggerNewScript failed - continuing. {0} {1}", | ||
206 | e.Message, e.StackTrace); | ||
207 | } | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | |||
212 | //TriggerUpdateScript: triggered after Scene receives client's upload of updated script and stores it as asset | ||
213 | // An indication that the script has changed. | ||
214 | public delegate void UpdateScript(UUID clientID, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID); | ||
215 | public event UpdateScript OnUpdateScript; | ||
216 | public virtual void TriggerUpdateScript(UUID clientId, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID) | ||
217 | { | ||
218 | UpdateScript handlerUpdateScript = OnUpdateScript; | ||
219 | if (handlerUpdateScript != null) | ||
220 | { | ||
221 | foreach (UpdateScript d in handlerUpdateScript.GetInvocationList()) | ||
222 | { | ||
223 | try | ||
224 | { | ||
225 | d(clientId, itemId, primId, isScriptRunning, newAssetID); | ||
226 | } | ||
227 | catch (Exception e) | ||
228 | { | ||
229 | m_log.ErrorFormat( | ||
230 | "[EVENT MANAGER]: Delegate for TriggerUpdateScript failed - continuing. {0} {1}", | ||
231 | e.Message, e.StackTrace); | ||
232 | } | ||
233 | } | ||
234 | } | ||
235 | } | ||
236 | |||
187 | /// <summary> | 237 | /// <summary> |
188 | /// This is fired when a scene object property that a script might be interested in (such as color, scale or | 238 | /// ScriptChangedEvent is fired when a scene object property that a script might be interested |
189 | /// inventory) changes. Only enough information is sent for the LSL changed event | 239 | /// in (such as color, scale or inventory) changes. Only enough information sent is for the LSL changed event. |
190 | /// (see http://lslwiki.net/lslwiki/wakka.php?wakka=changed) | 240 | /// This is not an indication that the script has changed (see OnUpdateScript for that). |
241 | /// This event is sent to a script to tell it that some property changed on | ||
242 | /// the object the script is in. See http://lslwiki.net/lslwiki/wakka.php?wakka=changed . | ||
191 | /// </summary> | 243 | /// </summary> |
192 | public event ScriptChangedEvent OnScriptChangedEvent; | 244 | public event ScriptChangedEvent OnScriptChangedEvent; |
193 | public delegate void ScriptChangedEvent(uint localID, uint change); | 245 | public delegate void ScriptChangedEvent(uint localID, uint change); |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 9d9729e..6cc78b8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -283,6 +283,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
283 | { | 283 | { |
284 | remoteClient.SendAgentAlertMessage("Script saved", false); | 284 | remoteClient.SendAgentAlertMessage("Script saved", false); |
285 | } | 285 | } |
286 | |||
287 | // Tell anyone managing scripts that a script has been reloaded/changed | ||
288 | EventManager.TriggerUpdateScript(remoteClient.AgentId, itemId, primId, isScriptRunning, item.AssetID); | ||
289 | |||
286 | part.ParentGroup.ResumeScripts(); | 290 | part.ParentGroup.ResumeScripts(); |
287 | return errors; | 291 | return errors; |
288 | } | 292 | } |
@@ -1624,9 +1628,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1624 | // have state in inventory | 1628 | // have state in inventory |
1625 | part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); | 1629 | part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); |
1626 | 1630 | ||
1631 | // tell anyone watching that there is a new script in town | ||
1632 | EventManager.TriggerNewScript(agentID, part, copyID); | ||
1633 | |||
1627 | // m_log.InfoFormat("[PRIMINVENTORY]: " + | 1634 | // m_log.InfoFormat("[PRIMINVENTORY]: " + |
1628 | // "Rezzed script {0} into prim local ID {1} for user {2}", | 1635 | // "Rezzed script {0} into prim local ID {1} for user {2}", |
1629 | // item.inventoryName, localID, remoteClient.Name); | 1636 | // item.inventoryName, localID, remoteClient.Name); |
1637 | |||
1630 | part.ParentGroup.ResumeScripts(); | 1638 | part.ParentGroup.ResumeScripts(); |
1631 | 1639 | ||
1632 | return part; | 1640 | return part; |
@@ -1707,6 +1715,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1707 | 1715 | ||
1708 | part.Inventory.AddInventoryItem(taskItem, false); | 1716 | part.Inventory.AddInventoryItem(taskItem, false); |
1709 | part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); | 1717 | part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); |
1718 | |||
1719 | // tell anyone managing scripts that a new script exists | ||
1720 | EventManager.TriggerNewScript(agentID, part, taskItem.ItemID); | ||
1721 | |||
1710 | part.ParentGroup.ResumeScripts(); | 1722 | part.ParentGroup.ResumeScripts(); |
1711 | 1723 | ||
1712 | return part; | 1724 | return part; |