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

Method OnDraw

engine/Poseidon/UI/Map/UIArcade.cpp:43–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41// Arcade Map subdisplays
42
43void CStaticAzimut::OnDraw(float alpha)
44{
45 CStatic::OnDraw(alpha);
46
47 CEdit* edit = dynamic_cast<CEdit*>(_parent->GetCtrl(_idcEdit));
48 PoseidonAssert(edit);
49 if (!edit)
50 {
51 return;
52 }
53 float azimut = edit->GetText() ? atof(edit->GetText()) : 0;
54 azimut = HDegree(azimut);
55
56 PackedColor color(Color(0.08, 0.08, 0.12, alpha));
57 float xc = _x + 0.5 * _w;
58 float zc = _y + 0.5 * _h;
59 const float r1 = 0.32;
60 const float r2 = 0.26;
61 const float diff = 0.08;
62 float x1 = xc + sin(azimut) * r1 * _w;
63 float z1 = zc - cos(azimut) * r1 * _h;
64 float x2 = xc + sin(azimut - diff) * r2 * _w;
65 float z2 = zc - cos(azimut - diff) * r2 * _h;
66 float x3 = xc + sin(azimut + diff) * r2 * _w;
67 float z3 = zc - cos(azimut + diff) * r2 * _h;
68
69 float w = GLOB_ENGINE->Width2D();
70 float h = GLOB_ENGINE->Height2D();
71
72 int xx1 = toIntFloor(x1 * w + 0.5);
73 int zz1 = toIntFloor(z1 * h + 0.5);
74 int xx2 = toIntFloor(x2 * w + 0.5);
75 int zz2 = toIntFloor(z2 * h + 0.5);
76 int xx3 = toIntFloor(x3 * w + 0.5);
77 int zz3 = toIntFloor(z3 * h + 0.5);
78
79 GLOB_ENGINE->DrawLine(Line2DPixel(xx1, zz1, xx2, zz2), color, color);
80 GLOB_ENGINE->DrawLine(Line2DPixel(xx2, zz2, xx3, zz3), color, color);
81 GLOB_ENGINE->DrawLine(Line2DPixel(xx3, zz3, xx1, zz1), color, color);
82}
83
84void CStaticAzimut::OnLButtonClick(float x, float y)
85{

Callers

nothing calls this directly

Calls 8

HDegreeFunction · 0.85
ColorClass · 0.85
Line2DPixelClass · 0.85
GetCtrlMethod · 0.45
GetTextMethod · 0.45
Width2DMethod · 0.45
Height2DMethod · 0.45
DrawLineMethod · 0.45

Tested by

no test coverage detected