diff --git a/Dalamud/Game/Command/CommandInfo.cs b/Dalamud/Game/Command/CommandInfo.cs
index 536843a74..3905a843c 100644
--- a/Dalamud/Game/Command/CommandInfo.cs
+++ b/Dalamud/Game/Command/CommandInfo.cs
@@ -1,13 +1,34 @@
namespace Dalamud.Game.Command {
+ ///
+ /// This class describes a registered command.
+ ///
public sealed class CommandInfo {
+ ///
+ /// The function to be executed when the command is dispatched.
+ ///
+ /// The command itself.
+ /// The arguments supplied to the command, ready for parsing.
public delegate void HandlerDelegate(string command, string arguments);
+ ///
+ /// A which will be called when the command is dispatched.
+ ///
public HandlerDelegate Handler { get; }
+ ///
+ /// The help message for this command.
+ ///
public string HelpMessage { get; set; } = string.Empty;
+ ///
+ /// If this command should be shown in the help output.
+ ///
public bool ShowInHelp { get; set; } = true;
+ ///
+ /// Create a new CommandInfo with the provided handler.
+ ///
+ ///
public CommandInfo(HandlerDelegate handler) {
Handler = handler;
}
diff --git a/Dalamud/Game/Command/CommandManager.cs b/Dalamud/Game/Command/CommandManager.cs
index 3588572c6..aad85dfec 100644
--- a/Dalamud/Game/Command/CommandManager.cs
+++ b/Dalamud/Game/Command/CommandManager.cs
@@ -7,11 +7,17 @@ using Dalamud.Game.Internal.Libc;
using Serilog;
namespace Dalamud.Game.Command {
+ ///
+ /// This class manages registered in-game slash commands.
+ ///
public sealed class CommandManager {
private readonly Dalamud dalamud;
private readonly Dictionary commandMap = new Dictionary();
+ ///
+ /// Read-only list of all registered commands.
+ ///
public ReadOnlyDictionary Commands =>
new ReadOnlyDictionary(this.commandMap);
@@ -27,7 +33,7 @@ namespace Dalamud.Game.Command {
new Regex(@"^La commande texte “(?.+)” n'existe pas\.$",
RegexOptions.Compiled);
- private readonly Regex CommandRegex;
+ private readonly Regex currentLangCommandRegex;
public CommandManager(Dalamud dalamud, ClientLanguage language) {
@@ -35,16 +41,16 @@ namespace Dalamud.Game.Command {
switch (language) {
case ClientLanguage.Japanese:
- this.CommandRegex = this.commandRegexJp;
+ this.currentLangCommandRegex = this.commandRegexJp;
break;
case ClientLanguage.English:
- this.CommandRegex = this.commandRegexEn;
+ this.currentLangCommandRegex = this.commandRegexEn;
break;
case ClientLanguage.German:
- this.CommandRegex = this.commandRegexDe;
+ this.currentLangCommandRegex = this.commandRegexDe;
break;
case ClientLanguage.French:
- this.CommandRegex = this.commandRegexFr;
+ this.currentLangCommandRegex = this.commandRegexFr;
break;
}
@@ -54,7 +60,7 @@ namespace Dalamud.Game.Command {
private void OnChatMessage(XivChatType type, uint senderId, ref StdString sender,
ref StdString message, ref bool isHandled) {
if (type == XivChatType.GatheringSystemMessage && senderId == 0) {
- var cmdMatch = this.CommandRegex.Match(message.Value).Groups["command"];
+ var cmdMatch = this.currentLangCommandRegex.Match(message.Value).Groups["command"];
if (cmdMatch.Success) {
// Yes, it's a chat command.
var command = cmdMatch.Value;
@@ -92,6 +98,12 @@ namespace Dalamud.Game.Command {
return true;
}
+ ///
+ /// Dispatch the handling of a command.
+ ///
+ /// The command to dispatch.
+ /// The provided arguments.
+ /// A object describing this command.
public void DispatchCommand(string command, string argument, CommandInfo info) {
try {
info.Handler(command, argument);
@@ -101,6 +113,12 @@ namespace Dalamud.Game.Command {
}
}
+ ///
+ /// Add a command handler, which you can use to add your own custom commands to the in-game chat.
+ ///
+ /// The command to register.
+ /// A object describing the command.
+ /// If adding was successful.
public bool AddHandler(string command, CommandInfo info) {
if (info == null) throw new ArgumentNullException(nameof(info), "Command handler is null.");
@@ -113,6 +131,11 @@ namespace Dalamud.Game.Command {
}
}
+ ///
+ /// Remove a command from the command handlers.
+ ///
+ /// The command to remove.
+ /// If the removal was successful.
public bool RemoveHandler(string command) {
return this.commandMap.Remove(command);
}