Added custom OpenSB help text categories and descriptions

This commit is contained in:
lonaasan 2024-09-06 23:29:02 +02:00
parent 90db1e0fba
commit 57e9d13e6a
2 changed files with 16 additions and 2 deletions

View File

@ -2,8 +2,14 @@
"basicHelpText": "Basic commands are: {}",
"adminHelpText": "Admin commands are: {}",
"debugHelpText": "Debug commands are: {}",
"openSbHelpText": "OpenSB commands are: {}",
"openSbDebugHelpText": "OpenSB Debug commands are: {}",
"debugCommands": {
"openSbDebugCommands": {
"run": "Usage /run <lua>. Executes a script on the player and outputs the return value to chat."
},
"openSbCommands": {
"swap": "Usage /swap <name>. Swaps the current character, case-insensitive, only substring required."
}
}

View File

@ -53,12 +53,14 @@ String CommandProcessor::help(ConnectionId connectionId, String const& argumentS
auto assets = Root::singleton().assets();
auto basicCommands = assets->json("/help.config:basicCommands");
auto openSbCommands = assets->json("/help.config:openSbCommands");
auto adminCommands = assets->json("/help.config:adminCommands");
auto debugCommands = assets->json("/help.config:debugCommands");
auto openSbDebugCommands = assets->json("/help.config:openSbDebugCommands");
if (arguments.size()) {
if (arguments.size() >= 1) {
if (auto helpText = basicCommands.optString(arguments[0]).orMaybe(adminCommands.optString(arguments[0])).orMaybe(debugCommands.optString(arguments[0])))
if (auto helpText = basicCommands.optString(arguments[0]).orMaybe(openSbCommands.optString(arguments[0])).orMaybe(adminCommands.optString(arguments[0])).orMaybe(debugCommands.optString(arguments[0])).orMaybe(openSbDebugCommands.optString(arguments[0])))
return *helpText;
}
}
@ -74,12 +76,18 @@ String CommandProcessor::help(ConnectionId connectionId, String const& argumentS
String basicHelpFormat = assets->json("/help.config:basicHelpText").toString();
res = res + strf(basicHelpFormat.utf8Ptr(), commandDescriptions(basicCommands));
String openSbHelpFormat = assets->json("/help.config:openSbHelpText").toString();
res = res + "\n" + strf(openSbHelpFormat.utf8Ptr(), commandDescriptions(openSbCommands));
if (!adminCheck(connectionId, "")) {
String adminHelpFormat = assets->json("/help.config:adminHelpText").toString();
res = res + "\n" + strf(adminHelpFormat.utf8Ptr(), commandDescriptions(adminCommands));
String debugHelpFormat = assets->json("/help.config:debugHelpText").toString();
res = res + "\n" + strf(debugHelpFormat.utf8Ptr(), commandDescriptions(debugCommands));
String openSbDebugHelpFormat = assets->json("/help.config:openSbDebugHelpText").toString();
res = res + "\n" + strf(openSbDebugHelpFormat.utf8Ptr(), commandDescriptions(openSbDebugCommands));
}
res = res + "\n" + basicCommands.getString("help");