Esempio n. 1
0
/**
 * @brief Wrapper for UI tooltips
 */
void UI_Tooltip (const uiNode_t* node, int x, int y)
{
	const char* string;
	const char* key = nullptr;
	const char* tooltip = nullptr;
	static const int maxWidth = 200;

	/* check values */
	if (node->key)
		key = Key_KeynumToString(node->key->key);
	if (node->tooltip)
		tooltip = UI_GetReferenceString(node, node->tooltip);

	/* normalize */
	if (tooltip && tooltip[0] == '\0')
		tooltip = nullptr;
	if (key && key[0] == '\0')
		key = nullptr;

	/* create tooltip */
	if (key && tooltip) {
		char buf[MAX_VAR];
		Com_sprintf(buf, sizeof(buf), _("Key: %s"), key);
		string = va("%s\n%s", tooltip, buf);
	} else if (tooltip) {
		string = tooltip;
	} else if (key) {
		string = va(_("Key: %s"), key);
	} else {
		return;
	}

	UI_DrawTooltip(string, x, y, maxWidth);
}
Esempio n. 2
0
/**
 * @brief Custom tooltip of todo node
 * @param[in] node Node we request to draw tooltip
 * @param[in] x,y Position of the mouse
 */
static void UI_TodoNodeDrawTooltip (uiNode_t* node, int x, int y)
{
    const int tooltipWidth = 250;
    static char tooltiptext[1024];

    const char* text = UI_GetReferenceString(node, node->text);
    if (!text)
        return;

    tooltiptext[0] = '\0';
    Q_strcat(tooltiptext, sizeof(tooltiptext), "%s", text);
    UI_DrawTooltip(tooltiptext, x, y, tooltipWidth);
}
Esempio n. 3
0
/**
 * @brief Custom tooltip of tab 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 uiTabNode::drawTooltip (uiNode_t *node, int x, int y)
{
	uiNode_t *option;
	const int tooltipWidth = 250;

	option = UI_TabNodeTabAtPosition(node, x, y);
	if (option == NULL)
		return;

	if (!OPTIONEXTRADATA(option).truncated)
		return;

	const char *label = CL_Translate(OPTIONEXTRADATA(option).label);
	UI_DrawTooltip(label, x, y, tooltipWidth);
}
Esempio n. 4
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);
}
Esempio n. 5
0
/**
 * @brief Custom tooltip of tab 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
 */
static void UI_TabNodeDrawTooltip (uiNode_t *node, int x, int y)
{
    uiNode_t *option;
    const int tooltipWidth = 250;
    const char *label;

    option = UI_TabNodeTabAtPosition(node, x, y);
    if (option == NULL)
        return;

    if (!OPTIONEXTRADATA(option).truncated)
        return;

    label = OPTIONEXTRADATA(option).label;
    if (label[0] == '_')
        label = _(label + 1);

    UI_DrawTooltip(label, x, y, tooltipWidth);
}
Esempio n. 6
0
/**
 * @brief Custom tooltip
 * @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
 */
static void UI_BaseMapNodeDrawTooltip (uiNode_t *node, int x, int y)
{
	int col, row;
	building_t *building;
	const int itemToolTipWidth = 250;
	char *tooltipText;
	base_t *base = B_GetCurrentSelectedBase();

	UI_BaseMapGetCellAtPos(node, x, y, &col, &row);
	if (col == -1)
		return;

	building = base->map[row][col].building;
	if (!building)
		return;

	tooltipText = _(building->name);
	if (!B_CheckBuildingDependencesStatus(building))
		tooltipText = va("%s\n%s %s", tooltipText, _("not operational, depends on"), _(building->dependsBuilding->name));
	UI_DrawTooltip(tooltipText, x, y, itemToolTipWidth);
}
Esempio n. 7
0
/**
 * @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);
	}
}