MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / drawWrappedBody

Method drawWrappedBody

3ds/source/ScriptRequestOverlays.cpp:91–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91void ScriptTileOverlay::drawWrappedBody(const std::string& text, int bodyY) const
92{
93 TextPool& text_pool = TextPool::get();
94 const float maxW = (float)(ScriptTile::UI_W - 2 * ScriptTile::PAD);
95 std::string wrapped = StringUtils::wrap(text, BODY_SIZE, maxW);
96
97 // Cut to the lines that fit above the button row rather than letting the
98 // paragraph run under it.
99 const float lineH = StringUtils::textHeight("A", BODY_SIZE);
100 const int maxLines = std::max(1, (int)((buttonRowY() - 6 - bodyY) / (lineH > 0 ? lineH : 1)));
101 int lines = 1;
102 for (size_t i = 0; i < wrapped.size(); i++) {
103 if (wrapped[i] == '\n' && ++lines > maxLines) {
104 wrapped = wrapped.substr(0, i) + "...";
105 break;
106 }
107 }
108 text_pool.drawWrapped(wrapped, (float)(ScriptTile::UI_X + ScriptTile::PAD), (float)bodyY, BODY_SIZE, COLOR_TEXT, maxW, ScriptTile::Z);
109}
110
111/* ---- gui_message -------------------------------------------------------- */
112

Callers

nothing calls this directly

Calls 4

getFunction · 0.85
buttonRowYFunction · 0.85
drawWrappedMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected