MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / draw

Method draw

src/Interface/Text.cpp:520–624  ·  view source on GitHub ↗

* Draws all the characters in the text with a really * nasty complex gritty text rendering algorithm logic stuff. */

Source from the content-addressed store, hash-verified

518 * nasty complex gritty text rendering algorithm logic stuff.
519 */
520void Text::draw()
521{
522 Surface::draw();
523 if (_text.empty() || _font == 0)
524 {
525 return;
526 }
527
528 // Show text borders for debugging
529 if (Options::debugUi)
530 {
531 SDL_Rect r;
532 r.w = getWidth();
533 r.h = getHeight();
534 r.x = 0;
535 r.y = 0;
536 this->drawRect(&r, 5);
537 r.w-=2;
538 r.h-=2;
539 r.x++;
540 r.y++;
541 this->drawRect(&r, 0);
542 }
543
544 int x = 0, y = 0, line = 0, height = 0;
545 Font *font = _font;
546 int color = _color;
547 std::wstring *s = &_text;
548
549 for (std::vector<int>::iterator i = _lineHeight.begin(); i != _lineHeight.end(); ++i)
550 {
551 height += *i;
552 }
553
554 switch (_valign)
555 {
556 case ALIGN_TOP:
557 y = 0;
558 break;
559 case ALIGN_MIDDLE:
560 y = (int)ceil((getHeight() - height) / 2.0);
561 break;
562 case ALIGN_BOTTOM:
563 y = getHeight() - height;
564 break;
565 }
566
567 x = getLineX(line);
568
569 if (_wrap)
570 {
571 s = &_wrappedText;
572 }
573
574 // Set up text color
575 int mul = 1;
576 if (_contrast)
577 {

Callers

nothing calls this directly

Calls 10

ShaderSurfaceFunction · 0.85
ShaderCropFunction · 0.85
ShaderScalarFunction · 0.85
drawRectMethod · 0.80
getTextDirectionMethod · 0.80
getCharSizeMethod · 0.80
getCharMethod · 0.80
emptyMethod · 0.45
setXMethod · 0.45
setYMethod · 0.45

Tested by

no test coverage detected