================= Item_Bind_HandleKey ================= */
| 9521 | ================= |
| 9522 | */ |
| 9523 | qboolean Item_Bind_HandleKey(itemDef_t *item, int key, qboolean down) |
| 9524 | { |
| 9525 | int id; |
| 9526 | int i; |
| 9527 | menuDef_t *menu; |
| 9528 | |
| 9529 | if (key == A_MOUSE1 && Rect_ContainsPoint(&item->window.rect, DC->cursorx, DC->cursory) && !g_waitingForKey) |
| 9530 | { |
| 9531 | if (down) |
| 9532 | { |
| 9533 | g_waitingForKey = qtrue; |
| 9534 | g_bindItem = item; |
| 9535 | |
| 9536 | // Set all others in the menu to grey |
| 9537 | menu = (menuDef_t *) item->parent; |
| 9538 | for (i=0;i<menu->itemCount;++i) |
| 9539 | { |
| 9540 | if (menu->items[i] == item) |
| 9541 | { |
| 9542 | continue; |
| 9543 | } |
| 9544 | menu->items[i]->window.flags |= WINDOW_INACTIVE; |
| 9545 | } |
| 9546 | |
| 9547 | } |
| 9548 | return qtrue; |
| 9549 | } |
| 9550 | else if (key == A_ENTER && !g_waitingForKey) |
| 9551 | { |
| 9552 | if (down) |
| 9553 | { |
| 9554 | g_waitingForKey = qtrue; |
| 9555 | g_bindItem = item; |
| 9556 | |
| 9557 | // Set all others in the menu to grey |
| 9558 | menu = (menuDef_t *) item->parent; |
| 9559 | for (i=0;i<menu->itemCount;++i) |
| 9560 | { |
| 9561 | if (menu->items[i] == item) |
| 9562 | { |
| 9563 | continue; |
| 9564 | } |
| 9565 | menu->items[i]->window.flags |= WINDOW_INACTIVE; |
| 9566 | } |
| 9567 | |
| 9568 | } |
| 9569 | return qtrue; |
| 9570 | } |
| 9571 | else |
| 9572 | { |
| 9573 | if (!g_waitingForKey || g_bindItem == NULL) |
| 9574 | { |
| 9575 | return qfalse; |
| 9576 | } |
| 9577 | |
| 9578 | if (key & K_CHAR_FLAG) |
| 9579 | { |
| 9580 | return qtrue; |
no test coverage detected