Exemplo n.º 1
0
static void input_update_tooltip(rct_window *w, rct_widgetindex widgetIndex, sint32 x, sint32 y)
{
	if (gTooltipWidget.window_classification == 255) {
		if (gTooltipCursorX == x && gTooltipCursorY == y) {
			_tooltipNotShownTicks++;
			if (_tooltipNotShownTicks > 50) {
				gTooltipTimeout = 0;
				window_tooltip_open(w, widgetIndex, x, y);
			}
		}
	} else {
		reset_tooltip_not_shown();

		if (w == NULL ||
			gTooltipWidget.window_classification != w->classification ||
			gTooltipWidget.window_number != w->number ||
			gTooltipWidget.widget_index != widgetIndex
		) {
			window_tooltip_close();
		}

		gTooltipTimeout += gTicksSinceLastUpdate;
		if (gTooltipTimeout >= 8000) {
			window_close_by_class(WC_TOOLTIP);
		}
	}
}
Exemplo n.º 2
0
void window_tooltip_show(rct_string_id id, int32_t x, int32_t y)
{
    rct_window* w;
    int32_t width, height;

    w = window_find_by_class(WC_ERROR);
    if (w != nullptr)
        return;

    char* buffer = gCommonStringFormatBuffer;

    format_string(buffer, sizeof(gCommonStringFormatBuffer), id, gCommonFormatArgs);
    gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;

    int32_t tooltip_text_width;
    tooltip_text_width = gfx_get_string_width_new_lined(buffer);
    buffer = gCommonStringFormatBuffer;
    tooltip_text_width = std::min(tooltip_text_width, 196);

    gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;

    int32_t numLines, fontSpriteBase;
    tooltip_text_width = gfx_wrap_string(buffer, tooltip_text_width + 1, &numLines, &fontSpriteBase);

    _tooltipNumLines = numLines;
    width = tooltip_text_width + 3;
    height = ((numLines + 1) * font_get_line_height(gCurrentFontSpriteBase)) + 4;
    window_tooltip_widgets[WIDX_BACKGROUND].right = width;
    window_tooltip_widgets[WIDX_BACKGROUND].bottom = height;

    std::memcpy(_tooltipText, buffer, sizeof(_tooltipText));

    int32_t screenWidth = context_get_width();
    int32_t screenHeight = context_get_height();
    x = std::clamp(x - (width / 2), 0, screenWidth - width);

    // TODO The cursor size will be relative to the window DPI.
    //      The amount to offset the y should be adjusted.

    int32_t max_y = screenHeight - height;
    y += 26; // Normally, we'd display the tooltip 26 lower
    if (y > max_y)
        // If y is too large, the tooltip could be forced below the cursor if we'd just clamped y,
        // so we'll subtract a bit more
        y -= height + 40;
    y = std::clamp(y, 22, max_y);

    w = window_create(x, y, width, height, &window_tooltip_events, WC_TOOLTIP, WF_TRANSPARENT | WF_STICK_TO_FRONT);
    w->widgets = window_tooltip_widgets;

    reset_tooltip_not_shown();
}
Exemplo n.º 3
0
/**
 *
 *  rct2: 0x006EA580
 */
static void window_tooltip_update(rct_window* w)
{
    reset_tooltip_not_shown();
}