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

Function plselAdjustLists

outdated/sys/wince/mhdlg.c:537–708  ·  view source on GitHub ↗

adjust role/race/alignment/gender list - filter out invalid combinations changed_sel points to the list where selection occurred (-1 if unknown) */

Source from the content-addressed store, hash-verified

535 (-1 if unknown)
536*/
537void
538plselAdjustLists(HWND hWnd, int changed_sel)
539{
540 HWND control_role, control_race, control_gender, control_align;
541 int initrole, initrace, initgend, initalign;
542 int i;
543 int ind;
544 int valid_opt;
545 TCHAR wbuf[255];
546
547 /* get control handles */
548 control_role = GetDlgItem(hWnd, IDC_PLSEL_ROLE_LIST);
549 control_race = GetDlgItem(hWnd, IDC_PLSEL_RACE_LIST);
550 control_gender = GetDlgItem(hWnd, IDC_PLSEL_GENDER_LIST);
551 control_align = GetDlgItem(hWnd, IDC_PLSEL_ALIGN_LIST);
552
553 /* get current selections */
554 ind = SendMessage(control_role, CB_GETCURSEL, 0, 0);
555 initrole = (ind == LB_ERR)
556 ? flags.initrole
557 : SendMessage(control_role, CB_GETITEMDATA, ind, 0);
558
559 ind = SendMessage(control_race, CB_GETCURSEL, 0, 0);
560 initrace = (ind == LB_ERR)
561 ? flags.initrace
562 : SendMessage(control_race, CB_GETITEMDATA, ind, 0);
563
564 ind = SendMessage(control_gender, CB_GETCURSEL, 0, 0);
565 initgend = (ind == LB_ERR)
566 ? flags.initgend
567 : SendMessage(control_gender, CB_GETITEMDATA, ind, 0);
568
569 ind = SendMessage(control_align, CB_GETCURSEL, 0, 0);
570 initalign = (ind == LB_ERR)
571 ? flags.initalign
572 : SendMessage(control_align, CB_GETITEMDATA, ind, 0);
573
574 /* intialize roles list */
575 if (changed_sel == -1) {
576 valid_opt = 0;
577
578 /* reset content and populate the list */
579 SendMessage(control_role, CB_RESETCONTENT, 0, 0);
580 for (i = 0; roles[i].name.m; i++) {
581 if (ok_role(i, initrace, initgend, initalign)) {
582 if (initgend >= 0 && flags.female && roles[i].name.f)
583 ind = SendMessage(
584 control_role, CB_ADDSTRING, (WPARAM) 0,
585 (LPARAM) NH_A2W(roles[i].name.f, wbuf, sizeof(wbuf)));
586 else
587 ind = SendMessage(
588 control_role, CB_ADDSTRING, (WPARAM) 0,
589 (LPARAM) NH_A2W(roles[i].name.m, wbuf, sizeof(wbuf)));
590
591 SendMessage(control_role, CB_SETITEMDATA, (WPARAM) ind,
592 (LPARAM) i);
593 if (i == initrole) {
594 SendMessage(control_role, CB_SETCURSEL, (WPARAM) ind,

Callers 2

PlayerSelectorDlgProcFunction · 0.85
plselInitDialogFunction · 0.85

Calls 4

ok_roleFunction · 0.85
ok_raceFunction · 0.85
ok_gendFunction · 0.85
ok_alignFunction · 0.85

Tested by

no test coverage detected