display a menu of all available status condition options and let player toggled them on or off; returns True iff any changes are made */
| 1373 | /* display a menu of all available status condition options and let player |
| 1374 | toggled them on or off; returns True iff any changes are made */ |
| 1375 | boolean |
| 1376 | cond_menu(void) |
| 1377 | { |
| 1378 | static const char *const menutitle[2] = { |
| 1379 | "alphabetically", "by ranking" |
| 1380 | }; |
| 1381 | int i, res, idx = 0; |
| 1382 | int sequence[CONDITION_COUNT]; |
| 1383 | winid tmpwin; |
| 1384 | anything any; |
| 1385 | menu_item *picks = (menu_item *) 0; |
| 1386 | char mbuf[QBUFSZ]; |
| 1387 | boolean showmenu = TRUE; |
| 1388 | int clr = NO_COLOR; |
| 1389 | boolean changed = FALSE; |
| 1390 | |
| 1391 | do { |
| 1392 | for (i = 0; i < CONDITION_COUNT; ++i) { |
| 1393 | sequence[i] = i; |
| 1394 | } |
| 1395 | qsort((genericptr_t) sequence, CONDITION_COUNT, |
| 1396 | sizeof sequence[0], |
| 1397 | (gc.condmenu_sortorder) ? cond_cmp : menualpha_cmp); |
| 1398 | |
| 1399 | tmpwin = create_nhwindow(NHW_MENU); |
| 1400 | start_menu(tmpwin, MENU_BEHAVE_STANDARD); |
| 1401 | |
| 1402 | any = cg.zeroany; |
| 1403 | any.a_int = 1; |
| 1404 | Sprintf(mbuf, "change sort order from \"%s\" to \"%s\"", |
| 1405 | menutitle[gc.condmenu_sortorder], |
| 1406 | menutitle[1 - gc.condmenu_sortorder]); |
| 1407 | add_menu(tmpwin, &nul_glyphinfo, &any, 'S', 0, ATR_NONE, |
| 1408 | clr, mbuf, MENU_ITEMFLAGS_SKIPINVERT); |
| 1409 | any = cg.zeroany; |
| 1410 | Sprintf(mbuf, "sorted %s", menutitle[gc.condmenu_sortorder]); |
| 1411 | add_menu_heading(tmpwin, mbuf); |
| 1412 | for (i = 0; i < SIZE(condtests); i++) { |
| 1413 | idx = sequence[i]; |
| 1414 | Sprintf(mbuf, "cond_%-14s", condtests[idx].useroption); |
| 1415 | any = cg.zeroany; |
| 1416 | any.a_int = idx + 2; /* avoid zero and the sort change pick */ |
| 1417 | condtests[idx].choice = FALSE; |
| 1418 | add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, mbuf, |
| 1419 | condtests[idx].enabled |
| 1420 | ? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE); |
| 1421 | } |
| 1422 | |
| 1423 | end_menu(tmpwin, "Choose status conditions to toggle"); |
| 1424 | |
| 1425 | res = select_menu(tmpwin, PICK_ANY, &picks); |
| 1426 | destroy_nhwindow(tmpwin); |
| 1427 | showmenu = FALSE; |
| 1428 | if (res > 0) { |
| 1429 | for (i = 0; i < res; i++) { |
| 1430 | idx = picks[i].item.a_int; |
| 1431 | if (idx == 1) { |
| 1432 | /* sort change requested */ |
no test coverage detected