feat: add /reload command to re-initialize addon system

Add AddonManager::reload() which saves all SavedVariables, shuts down the
Lua VM, re-initializes it, rescans .toc files, and reloads all addons.
Wire /reload, /reloadui, /rl slash commands that call reload() and fire
VARIABLES_LOADED + PLAYER_LOGIN + PLAYER_ENTERING_WORLD lifecycle events.
Essential for addon development and troubleshooting.
This commit is contained in:
Kelsi 2026-03-20 16:17:04 -07:00
parent 23ebfc7e85
commit 21ead2aa4b
3 changed files with 51 additions and 0 deletions

View file

@ -6035,6 +6035,30 @@ void GameScreen::sendChatMessage(game::GameHandler& gameHandler) {
return;
}
// /reload or /reloadui — reload all addons (save variables, re-init Lua, re-scan .toc files)
if (cmdLower == "reload" || cmdLower == "reloadui" || cmdLower == "rl") {
auto* am = core::Application::getInstance().getAddonManager();
if (am) {
am->reload();
am->fireEvent("VARIABLES_LOADED");
am->fireEvent("PLAYER_LOGIN");
am->fireEvent("PLAYER_ENTERING_WORLD");
game::MessageChatData rlMsg;
rlMsg.type = game::ChatType::SYSTEM;
rlMsg.language = game::ChatLanguage::UNIVERSAL;
rlMsg.message = "Interface reloaded.";
gameHandler.addLocalChatMessage(rlMsg);
} else {
game::MessageChatData rlMsg;
rlMsg.type = game::ChatType::SYSTEM;
rlMsg.language = game::ChatLanguage::UNIVERSAL;
rlMsg.message = "Addon system not available.";
gameHandler.addLocalChatMessage(rlMsg);
}
chatInputBuffer[0] = '\0';
return;
}
// /stopmacro [conditions]
// Halts execution of the current macro (remaining lines are skipped).
// With a condition block, only stops if the conditions evaluate to true.