MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / OnDraw

Method OnDraw

Descent3/CtlCfgElem.cpp:575–646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

573}
574
575void cfg_element::OnDraw() {
576 // draw text, then buttons, then...
577 UITextItem title(MONITOR9_NEWUI_FONT, m_title, NEWUI_MONITORFONT_COLOR);
578
579 int x = 0, i;
580
581 if (m_infocus) {
582 title.set_alpha(m_slot_alpha);
583 }
584
585 if (m_fnid != -1) {
586 UITextItem text(GADGET9_NEWUI_FONT, "?", NEWUI_GADGETFONT_COLOR);
587 if (m_curslot == CFGELEM_SLOT_CLEAR && CHECK_FLAG(m_flags, F_ELEM_HILITE)) {
588 m_xbtn_bmp_lit->draw(x, 0);
589 } else {
590 m_xbtn_bmp->draw(x, 0);
591 }
592 text.draw(x + (m_xbtn_bmp->width() - text.width()) / 2, 1 + (m_xbtn_bmp->height() - text.height()) / 2);
593 x += 28;
594 }
595
596 title.draw(x, 0);
597
598 if (m_fnid != -1) {
599 ct_type ctype[CTLBINDS_PER_FUNC];
600 uint8_t cfgflags[CTLBINDS_PER_FUNC];
601 ct_config_data cfgdata;
602 tCfgDataParts cfgparts;
603
604 x = CFGELEM_BTN_X;
605
606 Controller->get_controller_function(m_fnid, ctype, &cfgdata, cfgflags);
607 parse_config_data(&cfgparts, ctype[0], ctype[1], cfgdata);
608
609 for (i = 0; i < N_CFGELEM_SLOTS; i++) {
610 const char *txt;
611 uint8_t one_binding = (i == 0) ? cfgparts.bind_0 : cfgparts.bind_1;
612 uint8_t one_ctrlbind = (i == 0) ? cfgparts.ctrl_0 : cfgparts.ctrl_1;
613
614 txt = cfg_binding_text(ctype[i], one_ctrlbind, one_binding);
615
616 // draw button
617 if (CHECK_FLAG(m_flags, F_ELEM_HILITE) && m_curslot == i) {
618 m_btn_bmp_lit->draw(x, 0);
619 } else {
620 m_btn_bmp->draw(x, 0);
621 }
622
623 // draw text
624 if (txt) {
625 UITextItem text(GADGET9_NEWUI_FONT, txt, NEWUI_GADGETFONT_COLOR);
626
627 if (m_infocus) {
628 if (m_curslot == i) {
629 text.set_alpha(m_slot_alpha);
630 }
631 }
632

Callers

nothing calls this directly

Calls 7

parse_config_dataFunction · 0.85
cfg_binding_textFunction · 0.85
set_alphaMethod · 0.45
drawMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected