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

Method OnDraw

engine/Poseidon/UI/Controls/UIControlsHTML.cpp:244–570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242#define DRAW_TABLE_BORDERS 0
243
244void CHTML::OnDraw(float alpha)
245{
246 const int w = GLOB_ENGINE->Width2D();
247 const int h = GLOB_ENGINE->Height2D();
248
249 float xx = toInt(_x * w) + 0.5;
250 float yy = toInt(_y * h) + 0.5;
251 float ww = toInt(_w * w);
252 float hh = toInt(_h * h);
253
254 PackedColor pictureColor = PackedColor(Color(1, 1, 1, 0.6 * alpha));
255 PackedColor pictureColorSelected = PackedColor(Color(1, 1, 1, alpha));
256 PackedColor bgColor = ModAlpha(_bgColor, alpha);
257
258 MipInfo mip = GLOB_ENGINE->TextBank()->UseMipmap(nullptr, 0, 0);
259 GLOB_ENGINE->Draw2D(mip, bgColor, Rect2DPixel(xx, yy, ww, hh));
260
261 if (_sections.Size() <= 0)
262 {
263 return;
264 }
265 HTMLSection& section = _sections[_currentSection];
266
267 float top = _y;
268 bool bottom = false;
269
270 for (int r = 0; r < section.rows.Size(); r++)
271 {
272 HTMLRow& row = section.rows[r];
273 if (!bottom && row.bottom)
274 {
275 bottom = true;
276 top = _y + _h;
277 for (int rr = r; rr < section.rows.Size(); rr++)
278 {
279 top -= _scale * section.rows[rr].height;
280 }
281 }
282 float left;
283 switch (row.align)
284 {
285 case HARight:
286 left = _x + _w - _scale * (row.width + textBorder);
287 break;
288 case HACenter:
289 left = _x + 0.5 * (_w - _scale * row.width);
290 break;
291 default:
292 PoseidonAssert(row.align == HALeft);
293 left = _x + _scale * textBorder;
294 break;
295 }
296 for (int f = row.firstField; f <= row.lastField; f++)
297 {
298 if (f >= section.fields.Size())
299 {
300 continue;
301 }

Callers

nothing calls this directly

Calls 15

ColorClass · 0.85
SubstringMethod · 0.80
Draw3DMethod · 0.80
DrawLine3DMethod · 0.80
DrawText3DMethod · 0.80
ModAlphaFunction · 0.70
Point2DFloatClass · 0.70
Rect2DFloatClass · 0.70
toIntFunction · 0.50
PackedColorClass · 0.50
Rect2DPixelClass · 0.50
Width2DMethod · 0.45

Tested by

no test coverage detected