MCPcopy Create free account
hub / github.com/NetHack/NetHack / populate_races

Method populate_races

win/Qt/qt_plsel.cpp:423–449  ·  view source on GitHub ↗

update the race column in the PlayerSelector widget

Source from the content-addressed store, hash-verified

421
422// update the race column in the PlayerSelector widget
423void
424NetHackQtPlayerSelector::populate_races()
425{
426 //
427 // entry for each row in race column shows race's generic monster tile
428 // (always gender-specific) and race's name (never gender-specific)
429 //
430 QTableWidgetItem *item;
431 glyph_info gi;
432 int v, gf, gn = chosen_gend, al = chosen_align;
433 // if no role yet, use cleric so that alignment won't rule anything out
434 int ro = role->currentRow(), cl = cleric_role_row;
435 bool is_f = (gn == 1);
436 NetHackQtGlyphs& glyphs = qt_settings->glyphs();
437 for (int j = 0; races[j].noun; ++j) {
438 gf = monnum_to_glyph(races[j].mnum, is_f ? FEMALE : MALE);
439 map_glyphinfo(0, 0, gf, 0, &gi);
440 v = ((ro < 0 || validrace(ro, j))
441 && (al < 0 || validalign((ro >= 0) ? ro : cl, j, al)));
442 item = race->item(j, 0);
443 item->setText(races[j].noun);
444 item->setIcon(QIcon(glyphs.glyph(gf, gi.gm.tileidx)));
445 item->setFlags(v ? Qt::ItemIsEnabled | Qt::ItemIsSelectable
446 : Qt::NoItemFlags);
447 }
448 race->repaint();
449}
450
451void NetHackQtPlayerSelector::Randomize()
452{

Callers

nothing calls this directly

Calls 6

map_glyphinfoFunction · 0.85
validraceFunction · 0.85
validalignFunction · 0.85
glyphMethod · 0.80
repaintMethod · 0.60
setIconMethod · 0.45

Tested by

no test coverage detected