mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
Improve chat with local echo, slash shortcuts, colored input, and clickable URLs
Sent messages now appear immediately in chat log. Channel shortcuts (/s, /g, /p, /w, etc.) switch the chat type dropdown and color the input text to match. URLs in chat are clickable and open in the system browser.
This commit is contained in:
parent
6d719f2c52
commit
394e1a3f31
2 changed files with 203 additions and 48 deletions
|
|
@ -1804,6 +1804,27 @@ void GameHandler::sendChatMessage(ChatType type, const std::string& message, con
|
|||
// Build and send packet
|
||||
auto packet = MessageChatPacket::build(type, language, message, target);
|
||||
socket->send(packet);
|
||||
|
||||
// Add local echo so the player sees their own message immediately
|
||||
MessageChatData echo;
|
||||
echo.senderGuid = playerGuid;
|
||||
echo.language = language;
|
||||
echo.message = message;
|
||||
|
||||
// Look up player name
|
||||
auto nameIt = playerNameCache.find(playerGuid);
|
||||
if (nameIt != playerNameCache.end()) {
|
||||
echo.senderName = nameIt->second;
|
||||
}
|
||||
|
||||
if (type == ChatType::WHISPER) {
|
||||
echo.type = ChatType::WHISPER_INFORM;
|
||||
echo.senderName = target; // "To [target]: message"
|
||||
} else {
|
||||
echo.type = type;
|
||||
}
|
||||
|
||||
addLocalChatMessage(echo);
|
||||
}
|
||||
|
||||
void GameHandler::handleMessageChat(network::Packet& packet) {
|
||||
|
|
@ -1815,6 +1836,15 @@ void GameHandler::handleMessageChat(network::Packet& packet) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Skip server echo of our own messages (we already added a local echo)
|
||||
if (data.senderGuid == playerGuid && data.senderGuid != 0) {
|
||||
// Still track whisper sender for /r even if it's our own whisper-inform
|
||||
if (data.type == ChatType::WHISPER && !data.senderName.empty()) {
|
||||
lastWhisperSender_ = data.senderName;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Add to chat history
|
||||
chatHistory.push_back(data);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue