/** * @brief Try to autoplace an item at a position * when right-click was used in the inventory. * @param[in] node The context node * @param[in] mouseX X mouse coordinates. * @param[in] mouseY Y mouse coordinates. */ static void UI_ContainerNodeAutoPlace (uiNode_t* node, int mouseX, int mouseY) { if (!ui_inventory) return; /* don't allow this in tactical missions */ if (CL_BattlescapeRunning()) return; const int sel = cl_selected->integer; if (sel < 0) return; assert(EXTRADATA(node).super.container); int fromX, fromY; Item* ic = UI_BaseInventoryNodeGetItem(node, mouseX, mouseY, &fromX, &fromY); Com_DPrintf(DEBUG_CLIENT, "UI_ContainerNodeAutoPlace: item %i/%i selected from scrollable container.\n", fromX, fromY); if (!ic) return; UI_ContainerNodeAutoPlaceItem(node, ic); /* Update display of scroll buttons. */ UI_BaseInventoryNodeUpdateScroll(node); }
void uiBaseInventoryNode::onMouseDown (uiNode_t *node, int x, int y, int button) { switch (button) { case K_MOUSE1: { /* start drag and drop */ int fromX, fromY; dragInfoIC = UI_BaseInventoryNodeGetItem(node, x, y, &fromX, &fromY); if (dragInfoIC) { dragInfoFromX = fromX; dragInfoFromY = fromY; oldMouseX = x; oldMouseY = y; UI_SetMouseCapture(node); EXTRADATA(node).super.lastSelectedId = dragInfoIC->def()->idx; if (EXTRADATA(node).super.onSelect) { UI_ExecuteEventActions(node, EXTRADATA(node).super.onSelect); } } break; } case K_MOUSE2: if (UI_DNDIsDragging()) { UI_DNDAbort(); } else { /* auto place */ UI_ContainerNodeAutoPlace(node, x, y); } break; default: break; } }
/** * @brief Custom tooltip for container node * @param[in] node Node we request to draw tooltip * @param[in] x,y Position of the mouse */ void uiBaseInventoryNode::drawTooltip (const uiNode_t* node, int x, int y) const { /* Find out where the mouse is. */ const Item* itemHover = UI_BaseInventoryNodeGetItem(node, x, y, nullptr, nullptr); if (!itemHover) return; static char tooltiptext[MAX_VAR * 2]; const int itemToolTipWidth = 250; /* Get name and info about item */ UI_GetItemTooltip(*itemHover, tooltiptext, sizeof(tooltiptext)); #ifdef DEBUG /* Display stored container-coordinates of the item. */ Q_strcat(tooltiptext, sizeof(tooltiptext), "\n%i/%i", itemHover->getX(), itemHover->getY()); #endif UI_DrawTooltip(tooltiptext, x, y, itemToolTipWidth); }