* Draw a string to the screen. * * @param string The string to draw. * @param left The most left position where to draw the string. * @param top The most top position where to draw the string. * @param fgColour The foreground colour of the text. * @param bgColour The background colour of the text. */
| 456 | * @param bgColour The background colour of the text. |
| 457 | */ |
| 458 | void GUI_DrawText(const char *string, int16 left, int16 top, uint8 fgColour, uint8 bgColour) |
| 459 | { |
| 460 | uint8 colours[2]; |
| 461 | uint16 x; |
| 462 | uint16 y; |
| 463 | const char *s; |
| 464 | |
| 465 | if (g_fontCurrent == NULL) return; |
| 466 | |
| 467 | if (left < 0) left = 0; |
| 468 | if (top < 0) top = 0; |
| 469 | if (left > SCREEN_WIDTH) return; |
| 470 | if (top > SCREEN_HEIGHT) return; |
| 471 | |
| 472 | colours[0] = bgColour; |
| 473 | colours[1] = fgColour; |
| 474 | |
| 475 | GUI_InitColors(colours, 0, 1); |
| 476 | |
| 477 | s = string; |
| 478 | x = left; |
| 479 | y = top; |
| 480 | while (*s != '\0') { |
| 481 | uint16 width; |
| 482 | |
| 483 | if (*s == '\n' || *s == '\r') { |
| 484 | x = left; |
| 485 | y += g_fontCurrent->height; |
| 486 | |
| 487 | while (*s == '\n' || *s == '\r') s++; |
| 488 | } |
| 489 | |
| 490 | width = Font_GetCharWidth(*s); |
| 491 | |
| 492 | if (x + width > SCREEN_WIDTH) { |
| 493 | x = left; |
| 494 | y += g_fontCurrent->height; |
| 495 | } |
| 496 | if (y > SCREEN_HEIGHT) break; |
| 497 | |
| 498 | GUI_DrawChar(*s, x, y); |
| 499 | |
| 500 | x += width; |
| 501 | s++; |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | /** |
| 506 | * Draw a string to the screen, and so some magic. |
no test coverage detected