Procházet zdrojové kódy

fix enable from config on some legacy modules

UbitUmarov před 7 měsíci
rodič
revize
c1c19784ff

+ 14 - 4
OpenSim/Region/OptionalModules/ViewerSupport/DynamicFloaterModule.cs

@@ -55,6 +55,8 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
 
         private Scene m_scene;
 
+        private bool m_Enabled = false;
+
         private Dictionary<UUID, Dictionary<int, FloaterData>> m_floaters = new Dictionary<UUID, Dictionary<int, FloaterData>>();
 
         public string Name
@@ -69,6 +71,11 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
 
         public void Initialise(IConfigSource config)
         {
+            IConfig moduleConfig = config.Configs["DynamicFloaterModule"];
+            if (moduleConfig != null)
+            {
+                m_Enabled = moduleConfig.GetBoolean("enabled", false);
+            }
         }
 
         public void Close()
@@ -77,10 +84,13 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
 
         public void AddRegion(Scene scene)
         {
-            m_scene = scene;
-            scene.EventManager.OnNewClient += OnNewClient;
-            scene.EventManager.OnClientClosed += OnClientClosed;
-            m_scene.RegisterModuleInterface<IDynamicFloaterModule>(this);
+            if(m_Enabled)
+            {
+                m_scene = scene;
+                scene.EventManager.OnNewClient += OnNewClient;
+                scene.EventManager.OnClientClosed += OnClientClosed;
+                m_scene.RegisterModuleInterface<IDynamicFloaterModule>(this);
+            }
         }
 
         public void RegionLoaded(Scene scene)

+ 18 - 7
OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs

@@ -49,6 +49,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
     {
         private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
 
+        private bool m_Enabled = false;
         private class MenuItemData
         {
             public string Title;
@@ -75,6 +76,11 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
 
         public void Initialise(IConfigSource config)
         {
+            IConfig moduleConfig = config.Configs["DynamicMenuModule"];
+            if (moduleConfig != null)
+            {
+                m_Enabled = moduleConfig.GetBoolean("enabled", false);
+            }
         }
 
         public void Close()
@@ -83,17 +89,22 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
 
         public void AddRegion(Scene scene)
         {
-            m_scene = scene;
-            scene.EventManager.OnRegisterCaps += OnRegisterCaps;
-            m_scene.RegisterModuleInterface<IDynamicMenuModule>(this);
+            if (m_Enabled)
+            {
+                m_scene = scene;
+                scene.EventManager.OnRegisterCaps += OnRegisterCaps;
+                m_scene.RegisterModuleInterface<IDynamicMenuModule>(this);
+            }
         }
 
         public void RegionLoaded(Scene scene)
         {
-            ISimulatorFeaturesModule featuresModule = m_scene.RequestModuleInterface<ISimulatorFeaturesModule>();
-
-            if (featuresModule != null)
-                featuresModule.OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest;
+            if (m_Enabled)
+            {
+                ISimulatorFeaturesModule featuresModule = m_scene.RequestModuleInterface<ISimulatorFeaturesModule>();
+                if (featuresModule != null)
+                    featuresModule.OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest;
+            }
         }
 
         public void RemoveRegion(Scene scene)

+ 2 - 1
OpenSim/Region/OptionalModules/ViewerSupport/SpecialUIModule.cs

@@ -54,11 +54,12 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
     public class SpecialUIModule : INonSharedRegionModule
     {
         private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
         private const string VIEWER_SUPPORT_DIR = "ViewerSupport";
 
         private Scene m_scene;
         private SimulatorFeaturesHelper m_Helper;
-        private bool m_Enabled;
+        private bool m_Enabled = false;
         private int m_UserLevel;
 
         public string Name