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

Function mswin_menu_window_select_menu

win/win32/mhmenu.c:137–274  ·  view source on GitHub ↗

-----------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

135}
136/*-----------------------------------------------------------------------------*/
137int
138mswin_menu_window_select_menu(HWND hWnd, int how, MENU_ITEM_P **_selected,
139 BOOL activate)
140{
141 PNHMenuWindow data;
142 int ret_val;
143 MENU_ITEM_P *selected = NULL;
144 int i;
145 char *ap;
146
147 assert(_selected != NULL);
148 *_selected = NULL;
149 ret_val = -1;
150
151 data = (PNHMenuWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
152
153 /* force activate for certain menu types */
154 if (data->type == MENU_TYPE_MENU
155 && (how == PICK_ONE || how == PICK_ANY)) {
156 activate = TRUE;
157 }
158
159 data->is_active = activate && !GetNHApp()->regNetHackMode;
160
161 /* set menu type */
162 SetMenuListType(hWnd, how);
163
164 /* Ok, now give items a unique accelerators */
165 if (data->type == MENU_TYPE_MENU) {
166 char next_char = 'a';
167
168 data->menui.menu.gacc[0] = '\0';
169 ap = data->menui.menu.gacc;
170 for (i = 0; i < data->menui.menu.size; i++) {
171 if (data->menui.menu.items[i].accelerator != 0) {
172 if (isalpha(data->menui.menu.items[i].accelerator)) {
173 next_char = (char)(data->menui.menu.items[i].accelerator + 1);
174 }
175 } else if (NHMENU_IS_SELECTABLE(data->menui.menu.items[i])) {
176 if (isalpha(next_char)) {
177 data->menui.menu.items[i].accelerator = next_char;
178 } else {
179 if (next_char > 'z')
180 next_char = 'A';
181 else if (next_char > 'Z')
182 next_char = 'a';
183
184 data->menui.menu.items[i].accelerator = next_char;
185 }
186
187 next_char++;
188 }
189 }
190
191 /* collect group accelerators */
192 for (i = 0; i < data->menui.menu.size; i++) {
193 if (data->how != PICK_NONE) {
194 if (data->menui.menu.items[i].group_accel

Callers 2

mswin_display_nhwindowFunction · 0.70
mswin_select_menuFunction · 0.70

Calls 9

GetNHAppFunction · 0.70
SetMenuListTypeFunction · 0.70
reset_menu_countFunction · 0.70
LayoutMenuFunction · 0.70
mswin_popup_displayFunction · 0.70
mswin_layout_main_windowFunction · 0.70
mswin_popup_destroyFunction · 0.70
mswin_winid_from_handleFunction · 0.70
panicFunction · 0.50

Tested by

no test coverage detected