From bfd36e2e836f92539e68bba077104d5016c5bf8b Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 4 Sep 2007 13:43:56 +0000 Subject: Some work on Module loading/management. Some more modules templates classes (hoping that someone will pick some of these and work on implementing them). Early version of the "Dynamic Texture Module", although currently there are no render modules included (so not really functional without them). Added osSetDynamicTextureURL script function, for attaching a dynamic texture to a prim. Some work on the console command handling. Added "change-region " and "exit-region" so that after the use of change-region, the commands entered will apply to that region only. Then use exit-region to return to the top level (so commands then function as they did before and either apply to all regions or to the first region) (Note: this hasn't been tested very much) --- OpenSim/Region/Environment/ModuleLoader.cs | 74 +++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/Environment/ModuleLoader.cs') diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs index 1787a57..e8e7bc2 100644 --- a/OpenSim/Region/Environment/ModuleLoader.cs +++ b/OpenSim/Region/Environment/ModuleLoader.cs @@ -14,37 +14,51 @@ namespace OpenSim.Region.Environment public Dictionary LoadedAssemblys = new Dictionary(); + public List LoadedModules = new List(); + public Dictionary LoadedSharedModules = new Dictionary(); + public ModuleLoader() { } /// - /// Really just a test method for loading a set of currently internal modules + /// Should have a module factory? /// /// - public void CreateDefaultModules(Scene scene) + public void CreateDefaultModules(Scene scene, string exceptModules) { - //Testing IRegionModule ideas XferModule xferManager = new XferModule(); xferManager.Initialise(scene); scene.AddModule(xferManager.GetName(), xferManager); + LoadedModules.Add(xferManager); ChatModule chatModule = new ChatModule(); chatModule.Initialise(scene); scene.AddModule(chatModule.GetName(), chatModule); + LoadedModules.Add(chatModule); AvatarProfilesModule avatarProfiles = new AvatarProfilesModule(); avatarProfiles.Initialise(scene); scene.AddModule(avatarProfiles.GetName(), avatarProfiles); + LoadedModules.Add(avatarProfiles); - this.LoadModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene); + this.LoadRegionModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene); + } - // Post Initialise Modules, which most likely shouldn't be here - // but should rather be in a separate method that is called after all modules are loaded/created/intialised - xferManager.PostInitialise(); - // chatModule.PostInitialise(); //for now leave this disabled as it would start up a partially working irc bot - avatarProfiles.PostInitialise(); + public void LoadDefaultSharedModules(string exceptModules) + { + DynamicTextureModule dynamicModule = new DynamicTextureModule(); + this.LoadedSharedModules.Add(dynamicModule.GetName(), dynamicModule); + } + + public void InitialiseSharedModules(Scene scene) + { + foreach (IRegionModule module in this.LoadedSharedModules.Values) + { + module.Initialise(scene); + scene.AddModule(module.GetName(), module); //should be doing this? + } } /// @@ -53,18 +67,33 @@ namespace OpenSim.Region.Environment /// /// /// - public void LoadSharedModule(string dllName, string moduleName, Scene scene) + public void LoadSharedModule(string dllName, string moduleName) { + IRegionModule module = this.LoadModule(dllName, moduleName); + if (module != null) + { + this.LoadedSharedModules.Add(module.GetName(), module); + } + } + public void LoadRegionModule(string dllName, string moduleName, Scene scene) + { + IRegionModule module = this.LoadModule(dllName, moduleName); + if (module != null) + { + module.Initialise(scene); + scene.AddModule(module.GetName(), module); + LoadedModules.Add(module); + } } /// - /// Loads a external Module (if not already loaded) and creates a new instance of it for the passed Scene. + /// Loads a external Module (if not already loaded) and creates a new instance of it. /// /// /// /// - public void LoadModule(string dllName, string moduleName, Scene scene) + public IRegionModule LoadModule(string dllName, string moduleName) { Assembly pluginAssembly = null; if (LoadedAssemblys.ContainsKey(dllName)) @@ -97,13 +126,26 @@ namespace OpenSim.Region.Environment } pluginAssembly = null; - if (module.GetName() == moduleName) + if ((module != null ) || (module.GetName() == moduleName)) { - module.Initialise(scene); - scene.AddModule(moduleName, module); - module.PostInitialise(); //shouldn't be done here + return module; + } + + return null; + + } + + public void PostInitialise() + { + foreach (IRegionModule module in this.LoadedSharedModules.Values) + { + module.PostInitialise(); } + foreach (IRegionModule module in this.LoadedModules) + { + module.PostInitialise(); + } } public void ClearCache() -- cgit v1.1