MCPcopy Create free account
hub / github.com/assaultcube/AC / rendermenutexturepreview

Function rendermenutexturepreview

source/src/menus.cpp:1429–1453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1427FVAR(menupicturesize, 0.1f, 1.6f, 5.0f);
1428
1429void rendermenutexturepreview(char *previewtexture, int w, const char *title)
1430{
1431 static Texture *pt = NULL;
1432 static uint last_pt = 0;
1433 bool ispicture = title != NULL;
1434 uint cur_pt = hthash(previewtexture);
1435 if(cur_pt != last_pt)
1436 {
1437 silent_texture_load = ispicture;
1438 defformatstring(texpath)("packages/textures/%s", previewtexture);
1439 pt = textureload(texpath, ispicture ? 3 : 0);
1440 last_pt = cur_pt;
1441 silent_texture_load = false;
1442 }
1443 if(pt && pt != notexture && pt->xs && pt->ys)
1444 {
1445 int xs = (VIRTW * (ispicture ? menupicturesize : menutexturesize)) / 4, ys = (xs * pt->ys) / pt->xs, ysmax = (3 * VIRTH) / 2;
1446 if(ys > ysmax) ys = ysmax, xs = (ys * pt->xs) / pt->ys;
1447 int x = (6 * VIRTW + w - 2 * xs) / 4, y = VIRTH - ys / 2 - 2 * FONTH;
1448 extern int fullbrightlevel;
1449 framedquadtexture(pt->id, x, y, xs, ys, FONTH / 2, fullbrightlevel);
1450 defformatstring(res)("%dx%d", pt->xs, pt->ys);
1451 draw_text(title ? title : res, x, y + ys + 2 * FONTH);
1452 }
1453}
1454
1455void gmenu::render()
1456{

Callers 1

renderMethod · 0.85

Calls 4

textureloadFunction · 0.85
framedquadtextureFunction · 0.85
draw_textFunction · 0.85
hthashFunction · 0.70

Tested by

no test coverage detected