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

Function menuitem_invert_test

src/windows.c:1561–1589  ·  view source on GitHub ↗

* Window port helper function for menu invert routines to move the decision * logic into one place instead of 7 different window-port routines. */

Source from the content-addressed store, hash-verified

1559 * logic into one place instead of 7 different window-port routines.
1560 */
1561boolean
1562menuitem_invert_test(
1563 int mode UNUSED, /* 0: invert; 1: select; 2: deselect */
1564 unsigned itemflags, /* itemflags for the item */
1565 boolean is_selected) /* current selection status of the item */
1566{
1567 boolean skipinvert = (itemflags & MENU_ITEMFLAGS_SKIPINVERT) != 0;
1568
1569 if (!skipinvert) /* if not flagged SKIPINVERT, always pass test */
1570 return TRUE;
1571 /*
1572 * mode 0: inverting current on/off state;
1573 * 1: unconditionally setting on;
1574 * 2: unconditionally setting off.
1575 * menuinvertmode 0: treat entries flagged with skipinvert as ordinary
1576 * (same as if not flagged);
1577 * menuinvertmode 1: don't toggle bulk invert or bulk select entries On;
1578 * allow toggling to Off (for invert and deselect;
1579 * select doesn't do Off);
1580 * menuinvertmode 2: don't toggle skipinvert entries either On or Off
1581 * when any bulk change is performed.
1582 */
1583 if (iflags.menuinvertmode == 2) {
1584 return FALSE;
1585 } else if (iflags.menuinvertmode == 1) {
1586 return is_selected ? TRUE : FALSE;
1587 }
1588 return TRUE;
1589}
1590
1591/*
1592 * helper routine if a window port wants to extract the glyph

Callers 14

set_all_on_pageFunction · 0.85
unset_all_on_pageFunction · 0.85
invert_all_on_pageFunction · 0.85
invert_allFunction · 0.85
process_menu_windowFunction · 0.85
AllMethod · 0.85
ChooseNoneMethod · 0.85
InvertMethod · 0.85
onListCharFunction · 0.85
menu_operationFunction · 0.85
select_allFunction · 0.85
select_noneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected