Improve combat messages: power-type-aware errors, fix chat line breaks, better wording

- getSpellCastResultString now returns "Not enough rage/energy/focus/runic power" based on player power type instead of always "Not enough mana"
- Fix NPC combat messages concatenating onto previous lines by combining prefix+body into single renderTextWithLinks call instead of TextWrapped+SameLine
- Improve generic error strings to be more WoW-authentic (Invalid target, Target not in line of sight, etc.)
This commit is contained in:
Kelsi 2026-02-19 19:33:02 -08:00
parent 6aac80e5b1
commit 76e1aef62d
3 changed files with 54 additions and 58 deletions

View file

@ -1054,55 +1054,27 @@ void GameScreen::renderChatWindow(game::GameHandler& gameHandler) {
}
if (msg.type == game::ChatType::SYSTEM) {
if (!tsPrefix.empty()) {
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.6f, 0.6f, 0.6f, 1.0f));
ImGui::TextWrapped("%s", tsPrefix.c_str());
ImGui::PopStyleColor();
ImGui::SameLine(0, 0);
}
renderTextWithLinks(processedMessage, color);
renderTextWithLinks(tsPrefix + processedMessage, color);
} else if (msg.type == game::ChatType::TEXT_EMOTE) {
if (!tsPrefix.empty()) {
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.6f, 0.6f, 0.6f, 1.0f));
ImGui::TextWrapped("%s", tsPrefix.c_str());
ImGui::PopStyleColor();
ImGui::SameLine(0, 0);
}
renderTextWithLinks(processedMessage, color);
renderTextWithLinks(tsPrefix + processedMessage, color);
} else if (!msg.senderName.empty()) {
if (msg.type == game::ChatType::MONSTER_SAY || msg.type == game::ChatType::MONSTER_YELL) {
std::string prefix = tsPrefix + msg.senderName + " says: ";
ImGui::PushStyleColor(ImGuiCol_Text, color);
ImGui::TextWrapped("%s", prefix.c_str());
ImGui::PopStyleColor();
ImGui::SameLine(0, 0);
renderTextWithLinks(processedMessage, color);
std::string fullMsg = tsPrefix + msg.senderName + " says: " + processedMessage;
renderTextWithLinks(fullMsg, color);
} else if (msg.type == game::ChatType::CHANNEL && !msg.channelName.empty()) {
int chIdx = gameHandler.getChannelIndex(msg.channelName);
std::string chDisplay = chIdx > 0
? "[" + std::to_string(chIdx) + ". " + msg.channelName + "]"
: "[" + msg.channelName + "]";
std::string prefix = tsPrefix + chDisplay + " [" + msg.senderName + "]: ";
ImGui::PushStyleColor(ImGuiCol_Text, color);
ImGui::TextWrapped("%s", prefix.c_str());
ImGui::PopStyleColor();
ImGui::SameLine(0, 0);
renderTextWithLinks(processedMessage, color);
std::string fullMsg = tsPrefix + chDisplay + " [" + msg.senderName + "]: " + processedMessage;
renderTextWithLinks(fullMsg, color);
} else {
std::string prefix = tsPrefix + "[" + std::string(getChatTypeName(msg.type)) + "] " + msg.senderName + ": ";
ImGui::PushStyleColor(ImGuiCol_Text, color);
ImGui::TextWrapped("%s", prefix.c_str());
ImGui::PopStyleColor();
ImGui::SameLine(0, 0);
renderTextWithLinks(processedMessage, color);
std::string fullMsg = tsPrefix + "[" + std::string(getChatTypeName(msg.type)) + "] " + msg.senderName + ": " + processedMessage;
renderTextWithLinks(fullMsg, color);
}
} else {
std::string prefix = tsPrefix + "[" + std::string(getChatTypeName(msg.type)) + "] ";
ImGui::PushStyleColor(ImGuiCol_Text, color);
ImGui::TextWrapped("%s", prefix.c_str());
ImGui::PopStyleColor();
ImGui::SameLine(0, 0);
renderTextWithLinks(processedMessage, color);
std::string fullMsg = tsPrefix + "[" + std::string(getChatTypeName(msg.type)) + "] " + processedMessage;
renderTextWithLinks(fullMsg, color);
}
}