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

Method getLineX

src/Interface/Text.cpp:463–497  ·  view source on GitHub ↗

* Calculates the starting X position for a line of text. * @param line The line number (0 = first, etc). * @return The X position in pixels. */

Source from the content-addressed store, hash-verified

461 * @return The X position in pixels.
462 */
463int Text::getLineX(int line) const
464{
465 int x = 0;
466 switch (_lang->getTextDirection())
467 {
468 case DIRECTION_LTR:
469 switch (_align)
470 {
471 case ALIGN_LEFT:
472 break;
473 case ALIGN_CENTER:
474 x = (int)ceil((getWidth() + _font->getSpacing() - _lineWidth[line]) / 2.0);
475 break;
476 case ALIGN_RIGHT:
477 x = getWidth() - 1 - _lineWidth[line];
478 break;
479 }
480 break;
481 case DIRECTION_RTL:
482 switch (_align)
483 {
484 case ALIGN_LEFT:
485 x = getWidth() - 1;
486 break;
487 case ALIGN_CENTER:
488 x = getWidth() - (int)ceil((getWidth() + _font->getSpacing() - _lineWidth[line]) / 2.0);
489 break;
490 case ALIGN_RIGHT:
491 x = _lineWidth[line];
492 break;
493 }
494 break;
495 }
496 return x;
497}
498
499namespace
500{

Callers

nothing calls this directly

Calls 2

getTextDirectionMethod · 0.80
getSpacingMethod · 0.80

Tested by

no test coverage detected