[Commands] Extend #devtools Functionality (#4425)

This commit is contained in:
Alex King 2024-07-22 21:44:34 -04:00 committed by GitHub
parent b6fb8daae8
commit 098498dedd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 8 deletions

View File

@ -9338,6 +9338,7 @@ void Client::ShowDevToolsMenu()
std::string menu_reload_eight; std::string menu_reload_eight;
std::string menu_reload_nine; std::string menu_reload_nine;
std::string menu_toggle; std::string menu_toggle;
std::string window_toggle;
/** /**
* Search entity commands * Search entity commands
@ -9403,9 +9404,14 @@ void Client::ShowDevToolsMenu()
/** /**
* Show window status * Show window status
*/ */
menu_toggle = Saylink::Silent("#devtools enable", "Enable"); menu_toggle = Saylink::Silent("#devtools menu enable", "Enable");
if (IsDevToolsEnabled()) { if (IsDevToolsEnabled()) {
menu_toggle = Saylink::Silent("#devtools disable", "Disable"); menu_toggle = Saylink::Silent("#devtools menu disable", "Disable");
}
window_toggle = Saylink::Silent("#devtools window enable", "Enable");
if (GetDisplayMobInfoWindow()) {
window_toggle = Saylink::Silent("#devtools window disable", "Disable");
} }
/** /**
@ -9426,11 +9432,19 @@ void Client::ShowDevToolsMenu()
Message( Message(
Chat::White, Chat::White,
fmt::format( fmt::format(
"Toggle | {}", "Toggle Menu | {}",
menu_toggle menu_toggle
).c_str() ).c_str()
); );
Message(
Chat::White,
fmt::format(
"Toggle Window | {}",
window_toggle
).c_str()
);
Message( Message(
Chat::White, Chat::White,
fmt::format( fmt::format(

View File

@ -112,7 +112,7 @@ int command_init(void)
command_add("delpetition", "[petition number] - Delete a petition", AccountStatus::ApprenticeGuide, command_delpetition) || command_add("delpetition", "[petition number] - Delete a petition", AccountStatus::ApprenticeGuide, command_delpetition) ||
command_add("depop", "[Start Spawn Timer] - Depop your NPC target and optionally start their spawn timer (false by default)", AccountStatus::Guide, command_depop) || command_add("depop", "[Start Spawn Timer] - Depop your NPC target and optionally start their spawn timer (false by default)", AccountStatus::Guide, command_depop) ||
command_add("depopzone", "[Start Spawn Timers] - Depop the zone and optionally start spawn timers (false by default)", AccountStatus::GMAdmin, command_depopzone) || command_add("depopzone", "[Start Spawn Timers] - Depop the zone and optionally start spawn timers (false by default)", AccountStatus::GMAdmin, command_depopzone) ||
command_add("devtools", "[Enable|Disable] - Manages Developer Tools (send no parameter for menu)", AccountStatus::GMMgmt, command_devtools) || command_add("devtools", "[menu|window] [enable|disable] - Manages Developer Tools (send no parameter for menu)", AccountStatus::GMMgmt, command_devtools) ||
command_add("disablerecipe", "[Recipe ID] - Disables a Recipe", AccountStatus::QuestTroupe, command_disablerecipe) || command_add("disablerecipe", "[Recipe ID] - Disables a Recipe", AccountStatus::QuestTroupe, command_disablerecipe) ||
command_add("disarmtrap", "Analog for ldon disarm trap for the newer clients since we still don't have it working.", AccountStatus::QuestTroupe, command_disarmtrap) || command_add("disarmtrap", "Analog for ldon disarm trap for the newer clients since we still don't have it working.", AccountStatus::QuestTroupe, command_disarmtrap) ||
command_add("door", "Door editing command", AccountStatus::QuestTroupe, command_door) || command_add("door", "Door editing command", AccountStatus::QuestTroupe, command_door) ||

View File

@ -3,11 +3,19 @@
void command_devtools(Client *c, const Seperator *sep) void command_devtools(Client *c, const Seperator *sep)
{ {
bool is_disable = !strcasecmp(sep->arg[1], "disable"); const uint16 arguments = sep->argnum;
bool is_enable = !strcasecmp(sep->arg[1], "enable"); if (arguments != 2) {
c->ShowDevToolsMenu();
return;
}
if (is_disable || is_enable) { const std::string& type = sep->arg[1];
c->SetDevToolsEnabled(is_enable); const bool toggle = Strings::ToBool(sep->arg[2]);
if (Strings::EqualFold(type, "menu")) {
c->SetDevToolsEnabled(toggle);
} else if (Strings::EqualFold(type, "window")) {
c->SetDisplayMobInfoWindow(toggle);
} }
c->ShowDevToolsMenu(); c->ShowDevToolsMenu();