Browse Source

Chat Message Changes

This will need to be changed again to fix longer chat messages, but as long as a message doesn't trigger wordwrap in the message log this works.
pull/7983/head
NiteKat 10 months ago
parent
commit
f384704c3f
  1. 6
      Source/dapi/Server.cpp
  2. 2
      Source/qol/chatlog.cpp
  3. 1
      Source/qol/chatlog.h

6
Source/dapi/Server.cpp

@ -415,10 +415,10 @@ void Server::updateGameData()
update->set_connectedto(1);
for (auto chatLogLine = data->lastLogSize; chatLogLine < devilution::ChatLogLines.size(); chatLogLine++) {
for (auto chatLogLine = devilution::ChatLogLines.size() - (devilution::MessageCounter - data->lastLogSize); chatLogLine < devilution::ChatLogLines.size(); chatLogLine++) {
std::stringstream message;
for (auto &textLine : devilution::ChatLogLines[chatLogLine].colors) {
if (devilution::HasAnyOf(textLine.color, devilution::UiFlags::ColorWhitegold & devilution::UiFlags::ColorBlue))
if (devilution::HasAnyOf(textLine.color, devilution::UiFlags::ColorWhitegold) || devilution::HasAnyOf(textLine.color, devilution::UiFlags::ColorBlue))
message << textLine.text << ": ";
if (devilution::HasAnyOf(textLine.color, devilution::UiFlags::ColorWhite))
message << textLine.text;
@ -428,7 +428,7 @@ void Server::updateGameData()
*chatMessage = message.str();
}
}
data->lastLogSize = devilution::ChatLogLines.size();
data->lastLogSize = devilution::MessageCounter;
update->set_player(devilution::MyPlayerId);

2
Source/qol/chatlog.cpp

@ -28,12 +28,12 @@
namespace devilution {
std::vector<MultiColoredText> ChatLogLines;
unsigned int MessageCounter = 0;
namespace {
bool UnreadFlag = false;
size_t SkipLines;
unsigned int MessageCounter = 0;
constexpr int PaddingTop = 32;
constexpr int PaddingLeft = 32;

1
Source/qol/chatlog.h

@ -23,6 +23,7 @@ struct MultiColoredText {
extern bool ChatLogFlag;
extern std::vector<MultiColoredText> ChatLogLines;
extern unsigned int MessageCounter;
void ToggleChatLog();
void AddMessageToChatLog(std::string_view message, Player *player = nullptr, UiFlags flags = UiFlags::ColorWhite);

Loading…
Cancel
Save