MCPcopy Create free account
hub / github.com/EasyRPG/Player / AddMessage

Method AddMessage

src/message_overlay.cpp:63–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63void MessageOverlay::AddMessage(const std::string& message, Color color) {
64 if (message.empty()) {
65 return;
66 }
67
68 if (message == last_message) {
69 // The message matches the previous message -> increase counter
70 messages.back().repeat_count++;
71 messages.back().hidden = false;
72 // Keep the old message (with a new counter) on the screen
73 counter = 0;
74
75 dirty = true;
76 return;
77 }
78
79 last_message = message;
80
81 Game_Message::WordWrap(
82 message,
83 Player::screen_width - 6, // hardcoded to screen width because the bitmap is not initialized early enough
84 [&](std::string_view line) {
85 messages.emplace_back(std::string(line), color);
86 }, *Font::DefaultBitmapFont()
87 );
88
89 while (messages.size() > (unsigned)message_max) {
90 messages.pop_front();
91 }
92
93 dirty = true;
94}
95
96void MessageOverlay::Update() {
97 if (!DisplayUi) {

Callers 1

WriteLogFunction · 0.80

Calls 3

WordWrapFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected