| 1317 | } |
| 1318 | |
| 1319 | void hud_drawString(OffScreenBuffer* elem, Font* font, s32 x0, s32 y0, const char* str) |
| 1320 | { |
| 1321 | if (!font) { return; } |
| 1322 | |
| 1323 | s32 x = x0; |
| 1324 | s32 y = y0; |
| 1325 | for (char c = *str; c != 0; ) |
| 1326 | { |
| 1327 | if (c == '\n') |
| 1328 | { |
| 1329 | y += font->height + font->vertSpacing; |
| 1330 | x = x0; |
| 1331 | } |
| 1332 | else |
| 1333 | { |
| 1334 | if (c == ' ') |
| 1335 | { |
| 1336 | x += font->width; |
| 1337 | } |
| 1338 | else if (c >= font->minChar && c <= font->maxChar) |
| 1339 | { |
| 1340 | s32 charIndex = c - font->minChar; |
| 1341 | s32 offset = charIndex * 28; |
| 1342 | |
| 1343 | TextureData* glyph = &font->glyphs[charIndex]; |
| 1344 | offscreenBuffer_drawTexture(elem, glyph, x, y); |
| 1345 | x += glyph->width + font->horzSpacing; |
| 1346 | } |
| 1347 | } |
| 1348 | str++; |
| 1349 | c = *str; |
| 1350 | } |
| 1351 | } |
| 1352 | |
| 1353 | void hud_drawElementToScreen(OffScreenBuffer* elem, ScreenRect* rect, s32 x0, s32 y0, u8* framebuffer) |
| 1354 | { |
no test coverage detected