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/Application/OpenSim.cs | 21 +++++++-- .../Framework/InterfaceCommander/Commander.cs | 5 +-- OpenSim/Region/Framework/Interfaces/ICommander.cs | 7 +++ OpenSim/Region/Framework/Scenes/SceneBase.cs | 51 ++++++++++++++++++++-- 4 files changed, 73 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 0cd708b..af42a3d 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -712,10 +712,25 @@ namespace OpenSim } else { - ICommander moduleCommander = SceneManager.CurrentOrFirstScene.GetCommander(helpArgs[0]); - if (moduleCommander != null) + // Messily we want to join all the help params back here + //string helpSubject = string.Join(" ", helpArgs); + + // FIXME: Very cheap hack to get transition help working. Will disappear very shortly. + if (helpArgs.Length == 1) { - m_console.Notice(moduleCommander.Help); + ICommander moduleCommander = SceneManager.CurrentOrFirstScene.GetCommander(helpArgs[0]); + if (moduleCommander != null) + { + m_console.Notice(moduleCommander.Help); + } + } + else + { + ICommand command = SceneManager.CurrentOrFirstScene.GetCommand(helpArgs[1]); + if (command != null) + { + m_console.Notice(command.Help); + } } } } diff --git a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs index 31a67f7..cd66295 100644 --- a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs +++ b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs @@ -59,7 +59,7 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander { StringBuilder sb = new StringBuilder(); - sb.AppendLine("===" + m_name + "==="); + sb.AppendLine("=== " + m_name + " ==="); foreach (ICommand com in m_commands.Values) { @@ -83,9 +83,6 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander m_generatedApiClassName += m_name.Substring(1); } - /// - /// Commands that this commander knows about - /// public Dictionary Commands { get { return m_commands; } 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