| 383 | } |
| 384 | |
| 385 | void draw_text(const char *str, int left, int top, int r, int g, int b, int a, int cursor, int maxwidth) |
| 386 | { |
| 387 | #define TEXTINDEX(idx) if(idx == cursor) { cx = x; cy = y; cc = str[idx]; } |
| 388 | #define TEXTTAB(idx) TEXTGETCOLUMN |
| 389 | #define TEXTWHITE(idx) |
| 390 | #define TEXTLINE(idx) |
| 391 | #define TEXTCOLOR(idx) text_color(str[idx], colorstack, sizeof(colorstack), colorpos, color, a); |
| 392 | #define TEXTIGRAPH(idx) queue_igraph((uchar)str[idx], left+x, top+y), x += FONTH + 1; |
| 393 | #define TEXTCHAR(idx) x += draw_char(c, left+x, top+y) + 1; |
| 394 | #define TEXTWORD TEXTWORDSKELETON |
| 395 | char colorstack[10]; |
| 396 | bvec color(r, g, b); |
| 397 | int colorpos = 0, cx = INT_MIN, cy = 0, cc = ' '; |
| 398 | colorstack[0] = 'c'; //indicate user color |
| 399 | igraphbatch.setsize(0); |
| 400 | glBlendFunc(GL_SRC_ALPHA, curfont->tex->bpp==32 ? GL_ONE_MINUS_SRC_ALPHA : GL_ONE); |
| 401 | glBindTexture(GL_TEXTURE_2D, curfont->tex->id); |
| 402 | glBegin(GL_QUADS); |
| 403 | glColor4ub(color.x, color.y, color.z, a); |
| 404 | TEXTSKELETON |
| 405 | glEnd(); |
| 406 | if(cursor >= 0) |
| 407 | { |
| 408 | if(cx == INT_MIN) { cx = x; cy = y; } |
| 409 | if(maxwidth != -1 && cx >= maxwidth) { cx = 0; cy += FONTH; } |
| 410 | int cw = curfont->chars.inrange(cc-33) ? curfont->chars[cc-33].w + 1 : curfont->defaultw; |
| 411 | rendercursor(left+cx, top+cy, cw); |
| 412 | } |
| 413 | render_igraphs(); |
| 414 | #undef TEXTINDEX |
| 415 | #undef TEXTTAB |
| 416 | #undef TEXTWHITE |
| 417 | #undef TEXTLINE |
| 418 | #undef TEXTCOLOR |
| 419 | #undef TEXTIGRAPH |
| 420 | #undef TEXTCHAR |
| 421 | #undef TEXTWORD |
| 422 | } |
| 423 | |
| 424 | void reloadfonts() |
| 425 | { |
no test coverage detected