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

Method populate_roles

win/Qt/qt_plsel.cpp:389–420  ·  view source on GitHub ↗

update the role column in the PlayerSelector widget

Source from the content-addressed store, hash-verified

387
388// update the role column in the PlayerSelector widget
389void
390NetHackQtPlayerSelector::populate_roles()
391{
392 //
393 // entry for each row in the role column shows a player-character tile
394 // (always gender-specific) and role's name (sometimes gender-specific)
395 //
396 QTableWidgetItem *item;
397 const char *rolename;
398 glyph_info gi;
399 int v, gf, gn = chosen_gend, al = chosen_align;
400 // if no race yet, we use human for gender check (gender doesn't affect
401 // race but we need a valid race when filtering Valkyrie out or back in)
402 int ra = race->currentRow(), hu = human_race_row;
403 bool is_f = (gn == 1);
404 NetHackQtGlyphs& glyphs = qt_settings->glyphs();
405 for (int i = 0; roles[i].name.m; ++i) {
406 rolename = (is_f && roles[i].name.f) ? roles[i].name.f
407 : roles[i].name.m;
408 gf = monnum_to_glyph(roles[i].mnum, is_f ? FEMALE : MALE);
409 map_glyphinfo(0, 0, gf, 0, &gi);
410 v = ((ra < 0 || validrace(i, ra))
411 && (gn < 0 || validgend(i, (ra >= 0) ? ra : hu, gn))
412 && (al < 0 || validalign(i, (ra >= 0) ? ra : hu, al)));
413 item = role->item(i, 0);
414 item->setText(rolename);
415 item->setIcon(QIcon(glyphs.glyph(gf, gi.gm.tileidx)));
416 item->setFlags(v ? Qt::ItemIsEnabled | Qt::ItemIsSelectable
417 : Qt::NoItemFlags);
418 }
419 role->repaint(); // role->update() seems to be inadequate
420}
421
422// update the race column in the PlayerSelector widget
423void

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected