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

Method Refresh

src/dynrpg_textplugin.cpp:221–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219
220private:
221 void Refresh() {
222 if (texts.empty()) {
223 bitmap.reset();
224 return;
225 }
226
227 int width = 0;
228 int height = 0;
229
230 const FontRef& font = Font::Default();
231
232 for (auto& t : texts) {
233 PendingMessage pm(CommandCodeInserter);
234 pm.PushLine(t);
235 t = pm.GetLines().front();
236
237 Rect r = Text::GetSize(*font, t);
238 width = std::max(width, r.width);
239 height += r.height + 2;
240 }
241
242 bitmap = Bitmap::Create(width, height, true);
243
244 height = 0;
245 for (auto& t : texts) {
246 bitmap->TextDraw(0, height, color, t);
247 height += Text::GetSize(*font, t).height + 2;
248 }
249
250 SetPictureId(pic_id);
251 }
252
253 std::vector<std::string> texts;
254 BitmapRef bitmap;

Callers

nothing calls this directly

Calls 5

maxFunction · 0.85
TextDrawMethod · 0.80
emptyMethod · 0.45
resetMethod · 0.45
PushLineMethod · 0.45

Tested by

no test coverage detected