diff options
author | Justin Clarke Casey | 2008-12-18 18:49:05 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-12-18 18:49:05 +0000 |
commit | 4f88f25913c2125b6797500932e7a20288b95bfc (patch) | |
tree | bfb13bbd9f295522a6f0c71d398df173cc31c337 /OpenSim | |
parent | This may fix mantis #2855. There was a race condition on the TextureDownloadM... (diff) | |
download | opensim-SC-4f88f25913c2125b6797500932e7a20288b95bfc.zip opensim-SC-4f88f25913c2125b6797500932e7a20288b95bfc.tar.gz opensim-SC-4f88f25913c2125b6797500932e7a20288b95bfc.tar.bz2 opensim-SC-4f88f25913c2125b6797500932e7a20288b95bfc.tar.xz |
* refactor: move gestures code out from Scene into its own module
Diffstat (limited to 'OpenSim')
3 files changed, 155 insertions, 45 deletions
diff --git a/OpenSim/Region/Environment/Interfaces/IGesturesModule.cs b/OpenSim/Region/Environment/Interfaces/IGesturesModule.cs new file mode 100644 index 0000000..a070f62 --- /dev/null +++ b/OpenSim/Region/Environment/Interfaces/IGesturesModule.cs | |||
@@ -0,0 +1,50 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using OpenMetaverse; | ||
29 | using OpenSim.Framework; | ||
30 | |||
31 | namespace OpenSim.Region.Environment | ||
32 | { | ||
33 | public interface IGesturesModule | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// Active a gesture | ||
37 | /// </summary> | ||
38 | /// <param name="client"></param> | ||
39 | /// <param name="assetId"></param> | ||
40 | /// <param name="gestureId"></param> | ||
41 | void ActivateGesture(IClientAPI client, UUID assetId, UUID gestureId); | ||
42 | |||
43 | /// <summary> | ||
44 | /// Deactivate a gesture | ||
45 | /// </summary> | ||
46 | /// <param name="client"></param> | ||
47 | /// <param name="gestureId"></param> | ||
48 | void DeactivateGesture(IClientAPI client, UUID gestureId); | ||
49 | } | ||
50 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Gestures/GesturesModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Gestures/GesturesModule.cs new file mode 100644 index 0000000..5f0f4f9 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/Avatar/Gestures/GesturesModule.cs | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using log4net; | ||
29 | using Nini.Config; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Framework.Communications; | ||
33 | using OpenSim.Framework.Communications.Cache; | ||
34 | using OpenSim.Region.Environment.Interfaces; | ||
35 | using OpenSim.Region.Environment.Scenes; | ||
36 | using System.Reflection; | ||
37 | |||
38 | namespace OpenSim.Region.Environment.Modules.Avatar.Gestures | ||
39 | { | ||
40 | public class GesturesModule : IRegionModule, IGesturesModule | ||
41 | { | ||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | protected Scene m_scene; | ||
45 | |||
46 | public void Initialise(Scene scene, IConfigSource source) | ||
47 | { | ||
48 | m_scene = scene; | ||
49 | m_scene.RegisterModuleInterface<IGesturesModule>(this); | ||
50 | } | ||
51 | |||
52 | public void PostInitialise() {} | ||
53 | public void Close() {} | ||
54 | public string Name { get { return "Gestures Module"; } } | ||
55 | public bool IsSharedModule { get { return false; } } | ||
56 | |||
57 | public virtual void ActivateGesture(IClientAPI client, UUID assetId, UUID gestureId) | ||
58 | { | ||
59 | CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId); | ||
60 | |||
61 | if (userInfo != null) | ||
62 | { | ||
63 | InventoryItemBase item = userInfo.RootFolder.FindItem(gestureId); | ||
64 | if (item != null) | ||
65 | { | ||
66 | item.Flags = 1; | ||
67 | userInfo.UpdateItem(item); | ||
68 | } | ||
69 | else | ||
70 | m_log.ErrorFormat( | ||
71 | "[GESTURES]: Unable to find gesture to activate {0} for {1}", gestureId, client.Name); | ||
72 | } | ||
73 | else | ||
74 | m_log.ErrorFormat("[GESTURES]: Unable to find user {0}", client.Name); | ||
75 | } | ||
76 | |||
77 | public virtual void DeactivateGesture(IClientAPI client, UUID gestureId) | ||
78 | { | ||
79 | CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId); | ||
80 | |||
81 | if (userInfo != null) | ||
82 | { | ||
83 | InventoryItemBase item = userInfo.RootFolder.FindItem(gestureId); | ||
84 | if (item != null) | ||
85 | { | ||
86 | item.Flags = 0; | ||
87 | userInfo.UpdateItem(item); | ||
88 | } | ||
89 | else | ||
90 | m_log.ErrorFormat( | ||
91 | "[GESTURES]: Unable to find gesture to deactivate {0} for {1}", gestureId, client.Name); | ||
92 | } | ||
93 | else | ||
94 | m_log.ErrorFormat("[GESTURES]: Unable to find user {0}", client.Name); | ||
95 | } | ||
96 | } | ||
97 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 7a4c385..72748b6 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -1778,7 +1778,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1778 | return sceneObject; | 1778 | return sceneObject; |
1779 | } | 1779 | } |
1780 | 1780 | ||
1781 | void AdaptTree(ref PrimitiveBaseShape tree) | 1781 | protected void AdaptTree(ref PrimitiveBaseShape tree) |
1782 | { | 1782 | { |
1783 | // Tree size has to be adapted depending on its type | 1783 | // Tree size has to be adapted depending on its type |
1784 | switch ((Tree)tree.State) | 1784 | switch ((Tree)tree.State) |
@@ -2450,9 +2450,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
2450 | client.OnRegionHandleRequest += RegionHandleRequest; | 2450 | client.OnRegionHandleRequest += RegionHandleRequest; |
2451 | client.OnUnackedTerrain += TerrainUnAcked; | 2451 | client.OnUnackedTerrain += TerrainUnAcked; |
2452 | 2452 | ||
2453 | //Gesture | 2453 | IGesturesModule gesturesModule = RequestModuleInterface<IGesturesModule>(); |
2454 | client.OnActivateGesture += ActivateGesture; | 2454 | if (gesturesModule != null) |
2455 | client.OnDeactivateGesture += DeactivateGesture; | 2455 | { |
2456 | client.OnActivateGesture += gesturesModule.ActivateGesture; | ||
2457 | client.OnDeactivateGesture += gesturesModule.DeactivateGesture; | ||
2458 | } | ||
2459 | |||
2456 | //sound | 2460 | //sound |
2457 | client.OnSoundTrigger += SoundTrigger; | 2461 | client.OnSoundTrigger += SoundTrigger; |
2458 | 2462 | ||
@@ -2478,47 +2482,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
2478 | 2482 | ||
2479 | } | 2483 | } |
2480 | 2484 | ||
2481 | // Gesture | ||
2482 | public virtual void ActivateGesture(IClientAPI client, UUID assetId, UUID gestureId) | ||
2483 | { | ||
2484 | // UserProfileCacheService User = CommsManager.SecureInventoryService.UpdateItem(gestureid, agentID); | ||
2485 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId); | ||
2486 | |||
2487 | if (userInfo != null) | ||
2488 | { | ||
2489 | InventoryItemBase item = userInfo.RootFolder.FindItem(gestureId); | ||
2490 | if (item != null) | ||
2491 | { | ||
2492 | item.Flags = 1; | ||
2493 | userInfo.UpdateItem(item); | ||
2494 | } | ||
2495 | else m_log.Error("Unable to find gesture"); | ||
2496 | } | ||
2497 | else m_log.Error("Gesture : Unable to find user "); | ||
2498 | |||
2499 | m_log.DebugFormat("Asset : {0} gesture :{1}", gestureId.ToString(), assetId.ToString()); | ||
2500 | } | ||
2501 | |||
2502 | public virtual void DeactivateGesture(IClientAPI client, UUID gestureId) | ||
2503 | { | ||
2504 | // UserProfileCacheService User = CommsManager.SecureInventoryService.UpdateItem(gestureid, agentID); | ||
2505 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId); | ||
2506 | |||
2507 | if (userInfo != null) | ||
2508 | { | ||
2509 | InventoryItemBase item = userInfo.RootFolder.FindItem(gestureId); | ||
2510 | if (item != null) | ||
2511 | { | ||
2512 | item.Flags = 0; | ||
2513 | userInfo.UpdateItem(item); | ||
2514 | } | ||
2515 | else m_log.Error("Unable to find gesture"); | ||
2516 | } | ||
2517 | else m_log.Error("Gesture : Unable to find user "); | ||
2518 | |||
2519 | m_log.DebugFormat("gesture : {0} ", gestureId.ToString()); | ||
2520 | } | ||
2521 | |||
2522 | /// <summary> | 2485 | /// <summary> |
2523 | /// Teleport an avatar to their home region | 2486 | /// Teleport an avatar to their home region |
2524 | /// </summary> | 2487 | /// </summary> |