#pragma once #include "game/world_packets.hpp" #include "game/opcode_table.hpp" #include "game/handler_types.hpp" #include "network/packet.hpp" #include #include #include #include #include namespace wowee { namespace game { class GameHandler; class ChatHandler { public: using PacketHandler = std::function; using DispatchTable = std::unordered_map; explicit ChatHandler(GameHandler& owner); void registerOpcodes(DispatchTable& table); // --- Public API (delegated from GameHandler) --- void sendChatMessage(ChatType type, const std::string& message, const std::string& target = ""); void sendTextEmote(uint32_t textEmoteId, uint64_t targetGuid = 0); void joinChannel(const std::string& channelName, const std::string& password = ""); void leaveChannel(const std::string& channelName); std::string getChannelByIndex(int index) const; int getChannelIndex(const std::string& channelName) const; const std::vector& getJoinedChannels() const { return joinedChannels_; } void autoJoinDefaultChannels(); void addLocalChatMessage(const MessageChatData& msg); void addSystemChatMessage(const std::string& message); void toggleAfk(const std::string& message); void toggleDnd(const std::string& message); void replyToLastWhisper(const std::string& message); // ---- Methods moved from GameHandler ---- void submitGmTicket(const std::string& text); void handleMotd(network::Packet& packet); void handleNotification(network::Packet& packet); // --- State accessors --- std::deque& getChatHistory() { return chatHistory_; } const std::deque& getChatHistory() const { return chatHistory_; } size_t getMaxChatHistory() const { return maxChatHistory_; } void setMaxChatHistory(size_t n) { maxChatHistory_ = n; } // Chat auto-join settings (aliased from handler_types.hpp) using ChatAutoJoin = game::ChatAutoJoin; ChatAutoJoin chatAutoJoin; private: // --- Packet handlers --- void handleMessageChat(network::Packet& packet); void handleTextEmote(network::Packet& packet); void handleChannelNotify(network::Packet& packet); void handleChannelList(network::Packet& packet); GameHandler& owner_; // --- State --- std::deque chatHistory_; size_t maxChatHistory_ = 100; std::vector joinedChannels_; }; } // namespace game } // namespace wowee