refactor(chat): decompose into modular architecture, add GM commands, fix protocol
- Extract ChatPanel monolith into 15+ focused modules under ui/chat/
(ChatInput, ChatTabManager, ChatTabCompleter, ChatMarkupParser,
ChatMarkupRenderer, ChatCommandRegistry, ChatBubbleManager,
ChatSettings, MacroEvaluator, GameStateAdapter, InputModifierAdapter)
- Split 2700-line chat_panel_commands.cpp into 11 command modules
- Add GM command handling: 190-command data table, dot-prefix interception,
tab-completion, /gmhelp with category filter
- Fix ChatType enum to match WoW wire protocol (SAY=0x01 not 0x00);
values 0x00-0x1B shared across Vanilla/TBC/WotLK
- Fix BG_SYSTEM_* values from 82-84 (UB in bitmask shifts) to 0x24-0x26
- Fix infinite Enter key loop after teleport (disable TOGGLE_CHAT repeat,
add 2-frame input cooldown)
- Add tests: chat_markup_parser, chat_tab_completer, gm_commands,
macro_evaluator
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
2026-04-12 14:59:56 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "game/world_packets.hpp"
|
2026-04-12 15:46:03 +03:00
|
|
|
#include "game/entity.hpp"
|
refactor(chat): decompose into modular architecture, add GM commands, fix protocol
- Extract ChatPanel monolith into 15+ focused modules under ui/chat/
(ChatInput, ChatTabManager, ChatTabCompleter, ChatMarkupParser,
ChatMarkupRenderer, ChatCommandRegistry, ChatBubbleManager,
ChatSettings, MacroEvaluator, GameStateAdapter, InputModifierAdapter)
- Split 2700-line chat_panel_commands.cpp into 11 command modules
- Add GM command handling: 190-command data table, dot-prefix interception,
tab-completion, /gmhelp with category filter
- Fix ChatType enum to match WoW wire protocol (SAY=0x01 not 0x00);
values 0x00-0x1B shared across Vanilla/TBC/WotLK
- Fix BG_SYSTEM_* values from 82-84 (UB in bitmask shifts) to 0x24-0x26
- Fix infinite Enter key loop after teleport (disable TOGGLE_CHAT repeat,
add 2-frame input cooldown)
- Add tests: chat_markup_parser, chat_tab_completer, gm_commands,
macro_evaluator
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
2026-04-12 14:59:56 +03:00
|
|
|
#include <algorithm>
|
|
|
|
|
#include <cctype>
|
2026-04-12 15:46:03 +03:00
|
|
|
#include <memory>
|
refactor(chat): decompose into modular architecture, add GM commands, fix protocol
- Extract ChatPanel monolith into 15+ focused modules under ui/chat/
(ChatInput, ChatTabManager, ChatTabCompleter, ChatMarkupParser,
ChatMarkupRenderer, ChatCommandRegistry, ChatBubbleManager,
ChatSettings, MacroEvaluator, GameStateAdapter, InputModifierAdapter)
- Split 2700-line chat_panel_commands.cpp into 11 command modules
- Add GM command handling: 190-command data table, dot-prefix interception,
tab-completion, /gmhelp with category filter
- Fix ChatType enum to match WoW wire protocol (SAY=0x01 not 0x00);
values 0x00-0x1B shared across Vanilla/TBC/WotLK
- Fix BG_SYSTEM_* values from 82-84 (UB in bitmask shifts) to 0x24-0x26
- Fix infinite Enter key loop after teleport (disable TOGGLE_CHAT repeat,
add 2-frame input cooldown)
- Add tests: chat_markup_parser, chat_tab_completer, gm_commands,
macro_evaluator
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
2026-04-12 14:59:56 +03:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
namespace wowee {
|
|
|
|
|
|
2026-04-12 15:46:03 +03:00
|
|
|
// Forward declarations
|
|
|
|
|
namespace game {
|
|
|
|
|
class GameHandler;
|
|
|
|
|
}
|
refactor(chat): decompose into modular architecture, add GM commands, fix protocol
- Extract ChatPanel monolith into 15+ focused modules under ui/chat/
(ChatInput, ChatTabManager, ChatTabCompleter, ChatMarkupParser,
ChatMarkupRenderer, ChatCommandRegistry, ChatBubbleManager,
ChatSettings, MacroEvaluator, GameStateAdapter, InputModifierAdapter)
- Split 2700-line chat_panel_commands.cpp into 11 command modules
- Add GM command handling: 190-command data table, dot-prefix interception,
tab-completion, /gmhelp with category filter
- Fix ChatType enum to match WoW wire protocol (SAY=0x01 not 0x00);
values 0x00-0x1B shared across Vanilla/TBC/WotLK
- Fix BG_SYSTEM_* values from 82-84 (UB in bitmask shifts) to 0x24-0x26
- Fix infinite Enter key loop after teleport (disable TOGGLE_CHAT repeat,
add 2-frame input cooldown)
- Add tests: chat_markup_parser, chat_tab_completer, gm_commands,
macro_evaluator
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
2026-04-12 14:59:56 +03:00
|
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
namespace chat_utils {
|
|
|
|
|
|
|
|
|
|
/** Create a system-type chat message (used 15+ times throughout commands). */
|
|
|
|
|
inline game::MessageChatData makeSystemMessage(const std::string& text) {
|
|
|
|
|
game::MessageChatData msg;
|
|
|
|
|
msg.type = game::ChatType::SYSTEM;
|
|
|
|
|
msg.language = game::ChatLanguage::UNIVERSAL;
|
|
|
|
|
msg.message = text;
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Trim leading/trailing whitespace from a string. */
|
|
|
|
|
inline std::string trim(const std::string& s) {
|
|
|
|
|
size_t first = s.find_first_not_of(" \t\r\n");
|
|
|
|
|
if (first == std::string::npos) return "";
|
|
|
|
|
size_t last = s.find_last_not_of(" \t\r\n");
|
|
|
|
|
return s.substr(first, last - first + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Convert string to lowercase (returns copy). */
|
|
|
|
|
inline std::string toLower(std::string s) {
|
|
|
|
|
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) {
|
|
|
|
|
return static_cast<char>(std::tolower(c));
|
|
|
|
|
});
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-12 15:46:03 +03:00
|
|
|
/**
|
|
|
|
|
* Replace $g/$G gender, $n/$N name, $c/$C class, $r/$R race,
|
|
|
|
|
* $p/$o/$s/$S pronoun, $b/$B linebreak, and |n linebreak placeholders.
|
|
|
|
|
* Extracted from ChatPanel::replaceGenderPlaceholders (Phase 6.6).
|
|
|
|
|
*/
|
|
|
|
|
std::string replaceGenderPlaceholders(const std::string& text,
|
|
|
|
|
game::GameHandler& gameHandler);
|
|
|
|
|
|
|
|
|
|
/** Get display name for any entity (Player/Unit/GameObject). */
|
|
|
|
|
std::string getEntityDisplayName(const std::shared_ptr<game::Entity>& entity);
|
|
|
|
|
|
refactor(chat): decompose into modular architecture, add GM commands, fix protocol
- Extract ChatPanel monolith into 15+ focused modules under ui/chat/
(ChatInput, ChatTabManager, ChatTabCompleter, ChatMarkupParser,
ChatMarkupRenderer, ChatCommandRegistry, ChatBubbleManager,
ChatSettings, MacroEvaluator, GameStateAdapter, InputModifierAdapter)
- Split 2700-line chat_panel_commands.cpp into 11 command modules
- Add GM command handling: 190-command data table, dot-prefix interception,
tab-completion, /gmhelp with category filter
- Fix ChatType enum to match WoW wire protocol (SAY=0x01 not 0x00);
values 0x00-0x1B shared across Vanilla/TBC/WotLK
- Fix BG_SYSTEM_* values from 82-84 (UB in bitmask shifts) to 0x24-0x26
- Fix infinite Enter key loop after teleport (disable TOGGLE_CHAT repeat,
add 2-frame input cooldown)
- Add tests: chat_markup_parser, chat_tab_completer, gm_commands,
macro_evaluator
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
2026-04-12 14:59:56 +03:00
|
|
|
} // namespace chat_utils
|
|
|
|
|
} // namespace ui
|
|
|
|
|
} // namespace wowee
|