mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-16 11:33:03 +01:00
Integrate tooltip text and num lines
This commit is contained in:
@@ -263,10 +263,6 @@
|
||||
#define RCT2_ADDRESS_CURRENT_SUPPORT_SEGMENTS 0x0141E9B4
|
||||
#define RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT 0x0141E9D8
|
||||
|
||||
// size: 500 chars
|
||||
#define RCT2_ADDRESS_TOOLTIP_TEXT_BUFFER 0x0141FE44
|
||||
#define RCT2_ADDRESS_TOOLTIP_TEXT_HEIGHT 0x01420044
|
||||
|
||||
#define RCT2_ADDRESS_HCURSOR_START 0x01423598
|
||||
#define RCT2_ADDRESS_HCURSOR_ARROW 0x01423598
|
||||
#define RCT2_ADDRESS_HCURSOR_BLANK 0x0142359C
|
||||
@@ -622,6 +618,8 @@
|
||||
#define RCT2_ADDRESS_CURRENT_WINDOW_COLOUR_3 0x0141F742
|
||||
#define RCT2_ADDRESS_CURRENT_WINDOW_COLOUR_4 0x0141F743
|
||||
|
||||
#define RCT2_ADDRESS_TOOLTIP_TEXT_BUFFER 0x0141FE44
|
||||
#define RCT2_ADDRESS_TOOLTIP_TEXT_HEIGHT 0x01420044
|
||||
#define RCT2_ADDRESS_WINDOW_LIST 0x01420078
|
||||
#define RCT2_ADDRESS_NEW_WINDOW_PTR 0x014234B8
|
||||
|
||||
|
||||
@@ -31,12 +31,11 @@ static rct_widget window_tooltip_widgets[] = {
|
||||
{ WIDGETS_END },
|
||||
};
|
||||
|
||||
static void window_tooltip_onclose(rct_window *w);
|
||||
static void window_tooltip_update(rct_window *w);
|
||||
static void window_tooltip_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
||||
|
||||
static rct_window_event_list window_tooltip_events = {
|
||||
window_tooltip_onclose,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
@@ -66,6 +65,9 @@ static rct_window_event_list window_tooltip_events = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static utf8 _tooltipText[512];
|
||||
static sint16 _tooltipNumLines;
|
||||
|
||||
void window_tooltip_reset(int x, int y)
|
||||
{
|
||||
gTooltipCursorX = x;
|
||||
@@ -76,8 +78,6 @@ void window_tooltip_reset(int x, int y)
|
||||
gInputFlags &= ~INPUT_FLAG_4;
|
||||
}
|
||||
|
||||
uint8* gTooltip_text_buffer = RCT2_ADDRESS(RCT2_ADDRESS_TOOLTIP_TEXT_BUFFER, uint8);
|
||||
|
||||
void window_tooltip_show(rct_string_id id, int x, int y)
|
||||
{
|
||||
rct_window *w;
|
||||
@@ -87,7 +87,6 @@ void window_tooltip_show(rct_string_id id, int x, int y)
|
||||
if (w != NULL)
|
||||
return;
|
||||
|
||||
RCT2_GLOBAL(0x0142006C, sint32) = -1;
|
||||
char* buffer = gCommonStringFormatBuffer;
|
||||
|
||||
format_string(buffer, id, gCommonFormatArgs);
|
||||
@@ -103,13 +102,13 @@ void window_tooltip_show(rct_string_id id, int x, int y)
|
||||
int numLines, fontSpriteBase;
|
||||
tooltip_text_width = gfx_wrap_string(buffer, tooltip_text_width + 1, &numLines, &fontSpriteBase);
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TEXT_HEIGHT, sint16) = numLines;
|
||||
_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;
|
||||
|
||||
memcpy(gTooltip_text_buffer, buffer, 512);
|
||||
memcpy(_tooltipText, buffer, sizeof(_tooltipText));
|
||||
|
||||
x = clamp(0, x - (width / 2), gScreenWidth - width);
|
||||
|
||||
@@ -173,17 +172,6 @@ void window_tooltip_close()
|
||||
window_close_by_class(WC_TOOLTIP);
|
||||
gTooltipTimeout = 0;
|
||||
gTooltipWidget.window_classification = 255;
|
||||
RCT2_GLOBAL(0x0142006C, sint32) = -1;
|
||||
RCT2_GLOBAL(0x009DE51E, uint8) = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006EA578
|
||||
*/
|
||||
static void window_tooltip_onclose(rct_window *w)
|
||||
{
|
||||
RCT2_GLOBAL(0x009BC3B0, uint8) = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,8 +180,7 @@ static void window_tooltip_onclose(rct_window *w)
|
||||
*/
|
||||
static void window_tooltip_update(rct_window *w)
|
||||
{
|
||||
if (RCT2_GLOBAL(0x009DE51E, uint8) == 0)
|
||||
gTooltipNotShownTicks = 0;
|
||||
gTooltipNotShownTicks = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,5 +213,5 @@ static void window_tooltip_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
// Text
|
||||
left = w->x + ((w->width + 1) / 2) - 1;
|
||||
top = w->y + 1;
|
||||
draw_string_centred_raw(dpi, left, top, RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TEXT_HEIGHT, uint16), (char *)gTooltip_text_buffer);
|
||||
draw_string_centred_raw(dpi, left, top, _tooltipNumLines, _tooltipText);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user