mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-16 17:13:52 +00:00
- Extract renderItemTooltip() (510 LOC) from ChatMarkupRenderer into dedicated ItemTooltipRenderer class; chat_markup_renderer.cpp 766→192 LOC - Extract formatChatMessage(), detectChannelPrefix(), inputTextCallback() from render(); render() 711→376 LOC - Consolidate replaceGenderPlaceholders() from 3 copies into chat_utils::replaceGenderPlaceholders(); remove 118 LOC duplicate from quest_log_screen.cpp, update 8 call sites in window_manager.cpp - Delete chat_panel_commands.cpp (359 LOC) — absorb sendChatMessage, executeMacroText, PortBot helpers into chat_panel.cpp; move evaluateMacroConditionals to macro_eval_convenience.cpp - Delete chat_panel_utils.cpp (229 LOC) — absorb small utilities into chat_panel.cpp - Replace 3 forward declarations of evaluateMacroConditionals with #include "ui/chat/macro_evaluator.hpp" Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
58 lines
1.7 KiB
C++
58 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "game/world_packets.hpp"
|
|
#include "game/entity.hpp"
|
|
#include <algorithm>
|
|
#include <cctype>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
namespace wowee {
|
|
|
|
// Forward declarations
|
|
namespace game {
|
|
class GameHandler;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
/**
|
|
* 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);
|
|
|
|
} // namespace chat_utils
|
|
} // namespace ui
|
|
} // namespace wowee
|