// ChatCommandRegistry — command registration + dispatch. // Replaces the 500-line if/else chain in sendChatMessage() (Phase 3.1). #pragma once #include "ui/chat/i_chat_command.hpp" #include #include #include #include namespace wowee { namespace ui { /** * Registry of all slash commands. * * dispatch() looks up the command by alias and calls execute(). * getCompletions() provides tab-completion for /command prefixes. */ class ChatCommandRegistry { public: /** Register a command (takes ownership). All aliases are mapped. */ void registerCommand(std::unique_ptr cmd); /** * Dispatch a slash command. * @param cmdLower lowercase command name (e.g. "cast", "whisper") * @param ctx context with args, gameHandler, services, etc. * @return result indicating if handled and whether to clear input */ ChatCommandResult dispatch(const std::string& cmdLower, ChatCommandContext& ctx); /** Get all command aliases matching a prefix (for tab completion). */ std::vector getCompletions(const std::string& prefix) const; /** Get help entries: (alias, helpText) for all registered commands. */ std::vector> getHelpEntries() const; /** Check if a command alias is registered. */ bool hasCommand(const std::string& alias) const; private: // alias → raw pointer (non-owning, commands_ owns the objects) std::unordered_map commandMap_; // Ownership of all registered commands std::vector> commands_; }; } // namespace ui } // namespace wowee