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

Method StartMessageProcessing

src/window_message.cpp:134–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134void Window_Message::StartMessageProcessing(PendingMessage pm) {
135 text.clear();
136 pending_message = std::move(pm);
137
138 if (!IsVisible()) {
139 DebugLogResetFrameCounter();
140 }
141 DebugLog("{}: MSG START");
142
143 if (!pending_message.IsActive()) {
144 return;
145 }
146
147 const auto& lines = pending_message.GetLines();
148
149 int num_lines = 0;
150 auto append = [&](const std::string& line) {
151 bool force_page_break = (!line.empty() && line.back() == '\f');
152
153 text.append(line, 0, line.size() - force_page_break);
154 if (line.empty() || text.back() != '\n') {
155 text.push_back('\n');
156 }
157 ++num_lines;
158
159 if (num_lines == GetMaxLinesPerPage() || force_page_break) {
160 text.push_back('\f');
161 num_lines = 0;
162 }
163 };
164
165 if (pending_message.IsWordWrapped()) {
166 for (const std::string& line : lines) {
167 /* TODO: don't take commands like \> \< into account when word-wrapping */
168 Game_Message::WordWrap(
169 line,
170 width - 24,
171 [&](std::string_view wrapped_line) {
172 append(std::string(wrapped_line));
173 }
174 );
175 }
176 } else {
177 for (const std::string& line : lines) {
178 append(line);
179 }
180 }
181
182 if (text.empty() || text.back() != '\f') {
183 text.push_back('\f');
184 }
185
186 item_max = min(4, pending_message.GetNumChoices());
187
188 text_index = text.data();
189
190 DebugLog("{}: MSG TEXT \n{}", text);
191

Callers 1

SetPendingMessageMethod · 0.80

Calls 11

WordWrapFunction · 0.85
minFunction · 0.85
IsWordWrappedMethod · 0.80
GetNumChoicesMethod · 0.80
dataMethod · 0.80
DebugLogFunction · 0.70
clearMethod · 0.45
IsActiveMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected