コード例 #1
0
/**
 * @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);
}
コード例 #2
0
ファイル: ui_node_container.cpp プロジェクト: jklemmack/ufoai
/**
 * @brief Custom tooltip for container node
 * @param[in] node Node we request to draw tooltip
 * @param[in] x Position x of the mouse
 * @param[in] y Position y of the mouse
 */
void uiContainerNode::drawTooltip (uiNode_t *node, int x, int y)
{
	static char tooltiptext[MAX_VAR * 2];
	const invList_t *itemHover;
	vec2_t nodepos;

	UI_GetNodeAbsPos(node, nodepos);

	/* Find out where the mouse is. */
	itemHover = UI_ContainerNodeGetItemAtPosition(node, x, y);

	if (itemHover) {
		const int itemToolTipWidth = 250;

		/* Get name and info about item */
		UI_GetItemTooltip(itemHover->item, tooltiptext, sizeof(tooltiptext));
#ifdef DEBUG
		/* Display stored container-coordinates of the item. */
		Q_strcat(tooltiptext, va("\n%i/%i", itemHover->x, itemHover->y), sizeof(tooltiptext));
#endif
		UI_DrawTooltip(tooltiptext, x, y, itemToolTipWidth);
	}
}