MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / OnDraw

Method OnDraw

engine/Poseidon/UI/InGame/InGameUIDraw.cpp:495–597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

493}
494
495void UIActions::OnDraw()
496{
497 AIUnit* unit = GWorld->FocusOn();
498 if (!unit)
499 {
500 return;
501 }
502
503 int n = Size();
504 saturate(n, 1, _rows);
505
506 float alpha = GetAlpha();
507 if (alpha <= 0.01)
508 {
509 return;
510 }
511
512 PackedColor bgColorA = PackedColorRGB(_bgColor, toIntFloor(_bgColor.A8() * alpha));
513 PackedColor selColorA = PackedColorRGB(_selColor, toIntFloor(_selColor.A8() * alpha));
514 PackedColor textColorA = PackedColorRGB(_textColor, toIntFloor(_textColor.A8() * alpha));
515
516 bool canUp = false;
517 bool canDown = false;
518
519 AUTO_STATIC_ARRAY(DrawActionInfo, array, 16);
520 array.Resize(n);
521 if (Size() == 0)
522 {
523 array[0].text = LocalizeString(IDS_NO_ACTION);
524 array[0].selected = false;
525 }
526 else
527 {
528 int selected = FindSelected();
529 PoseidonAssert(selected >= 0);
530 int offset = 0;
531 if (selected >= n)
532 {
533 offset = selected - n + 1;
534 }
535 canUp = offset > 0;
536 canDown = Size() > offset + _rows;
537 for (int i = 0; i < n; i++)
538 {
539 const UIAction& action = Get(offset + i);
540
541 array[i].text = action.GetDisplayName(unit);
542 array[i].selected = offset + i == selected;
543 }
544 }
545
546 const int w = GLOB_ENGINE->Width2D();
547 const int h = GLOB_ENGINE->Height2D();
548 const float border = 0.005;
549
550 float height = n * _h + 2 * border;
551 float top = _bottom - height;
552 float width = 0;

Callers 1

DrawHUDMethod · 0.45

Calls 15

saturateFunction · 0.85
LocalizeStringFunction · 0.85
saturateMaxFunction · 0.85
DrawFrameFunction · 0.85
Line2DPixelClass · 0.85
FocusOnMethod · 0.80
AUTO_STATIC_ARRAYFunction · 0.70
PackedColorRGBFunction · 0.50
GetFunction · 0.50
Rect2DPixelClass · 0.50
Point2DFloatClass · 0.50
A8Method · 0.45

Tested by

no test coverage detected