From 00a3cbd6fa9d84fe28b3a7f033e2452d6a3f1d69 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 6 Feb 2009 18:18:01 +0000 Subject: * Implement help from the region console * So at the moment once can type 'help terrain fill' as well as 'terrain fill help' * Current implementation is a transient hack that should be tidied up soon --- OpenSim/Region/Framework/Interfaces/ICommander.cs | 7 ++++ OpenSim/Region/Framework/Scenes/SceneBase.cs | 51 +++++++++++++++++++++-- 2 files changed, 54 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Interfaces/ICommander.cs b/OpenSim/Region/Framework/Interfaces/ICommander.cs index 17a2e4a..f94e8e8 100644 --- a/OpenSim/Region/Framework/Interfaces/ICommander.cs +++ b/OpenSim/Region/Framework/Interfaces/ICommander.cs @@ -25,6 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Collections.Generic; + namespace OpenSim.Region.Framework.Interfaces { public interface ICommander @@ -39,6 +41,11 @@ namespace OpenSim.Region.Framework.Interfaces /// string Help { get; } + /// + /// The commands available for this commander + /// + Dictionary Commands { get; } + void ProcessConsoleCommand(string function, string[] args); void RegisterCommand(string commandName, ICommand command); void Run(string function, object[] args); diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 6d61e9f..e58d3ce 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -61,17 +61,24 @@ namespace OpenSim.Region.Framework.Scenes /// /// The module interfaces available from this scene. /// - protected Dictionary > ModuleInterfaces = new Dictionary >(); + protected Dictionary> ModuleInterfaces = new Dictionary>(); protected Dictionary ModuleAPIMethods = new Dictionary(); + + /// + /// The module commanders available from this scene + /// protected Dictionary m_moduleCommanders = new Dictionary(); /// + /// The module commands available for this scene + /// + protected Dictionary m_moduleCommands = new Dictionary(); + + /// /// Registered classes that are capable of creating entities. /// - protected Dictionary m_entityCreators = new Dictionary(); - - //API module interfaces + protected Dictionary m_entityCreators = new Dictionary(); /// /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is @@ -278,11 +285,47 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Register a module commander. + /// + /// public void RegisterModuleCommander(ICommander commander) { lock (m_moduleCommanders) { m_moduleCommanders.Add(commander.Name, commander); + + lock (m_moduleCommands) + { + foreach (ICommand command in commander.Commands.Values) + { + if (m_moduleCommands.ContainsKey(command.Name)) + { + m_log.ErrorFormat( + "[MODULES]: Module commander {0} tried to register the command {1} which has already been registered", + commander.Name, command.Name); + continue; + } + + m_moduleCommands[command.Name] = command; + } + } + } + } + + /// + /// Get an available module command + /// + /// + /// The command if it was found, null if no command is available with that name + public ICommand GetCommand(string commandName) + { + lock (m_moduleCommands) + { + if (m_moduleCommands.ContainsKey(commandName)) + return m_moduleCommands[commandName]; + else + return null; } } -- cgit v1.1