mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #208 from duncanspumpkin/window_tooltip_cleanup
Window tooltip cleanup
This commit is contained in:
commit
9de7af5075
|
@ -1585,10 +1585,8 @@ int gfx_wrap_string(char* buffer, int width, int* num_lines, int* font_height)
|
|||
unsigned int max_width = 0;
|
||||
rct_g1_element g1_element;
|
||||
|
||||
uint16* current_font_sprite_base = RCT2_ADDRESS(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16);
|
||||
|
||||
*num_lines = 0;
|
||||
*font_height = 0;
|
||||
*font_height = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16);
|
||||
|
||||
// Pointer to the start of the current word
|
||||
unsigned char* curr_word = NULL;
|
||||
|
@ -1650,7 +1648,7 @@ int gfx_wrap_string(char* buffer, int width, int* num_lines, int* font_height)
|
|||
}
|
||||
}
|
||||
|
||||
line_width += RCT2_ADDRESS(RCT2_ADDRESS_FONT_CHAR_WIDTH, uint8)[*current_font_sprite_base + (*curr_char - 0x20)];
|
||||
line_width += RCT2_ADDRESS(RCT2_ADDRESS_FONT_CHAR_WIDTH, uint8)[*font_height + (*curr_char - 0x20)];
|
||||
|
||||
if ((int)line_width <= width) {
|
||||
continue;
|
||||
|
@ -1694,7 +1692,7 @@ int gfx_wrap_string(char* buffer, int width, int* num_lines, int* font_height)
|
|||
line_width = 0;
|
||||
curr_word = 0;
|
||||
}
|
||||
|
||||
if (max_width == 0)return line_width;
|
||||
return max_width;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ extern int gLastDrawStringY;
|
|||
int gfx_load_g1();
|
||||
void gfx_load_character_widths();
|
||||
|
||||
int gfx_wrap_string(char* buffer, int width, int* num_lines, int* font_height);
|
||||
void gfx_clear(rct_drawpixelinfo *dpi, int colour);
|
||||
void gfx_draw_pixel(rct_drawpixelinfo *dpi, int x, int y, int colour);
|
||||
void gfx_draw_line(rct_drawpixelinfo *dpi, int x1, int y1, int x2, int y2, int colour);
|
||||
|
|
|
@ -250,6 +250,12 @@ static void window_game_bottom_toolbar_tooltip()
|
|||
tool_tip_index = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__asm mov ax, tool_tip_index
|
||||
#else
|
||||
__asm__("mov ax, %[tool_tip_index] " :[tool_tip_index] "+m" (tool_tip_index));
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "string_ids.h"
|
||||
#include "widget.h"
|
||||
#include "window.h"
|
||||
#include "gfx.h"
|
||||
|
||||
enum {
|
||||
WIDX_BACKGROUND
|
||||
|
@ -114,30 +115,29 @@ void window_tooltip_open(rct_window *widgetWindow, int widgetIndex, int x, int y
|
|||
return;
|
||||
|
||||
RCT2_GLOBAL(0x0142006C, sint32) = -1;
|
||||
char* buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);
|
||||
|
||||
format_string((char*)0x0141ED68, widget->tooltip, (void*)0x013CE952);
|
||||
format_string(buffer, widget->tooltip, (void*)0x013CE952);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224;
|
||||
|
||||
esi = 0x0141ED68;
|
||||
RCT2_CALLFUNC_X(0x006C23B1, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
ecx &= 0xFFFF;
|
||||
if (ecx > 196)
|
||||
ecx = 196;
|
||||
int tooltip_text_width = ecx, tooltip_text_height = 0;
|
||||
//gfx_get_string_width_new_lined
|
||||
RCT2_CALLFUNC_X(0x006C23B1, &eax, &ebx, &tooltip_text_width, &edx, &buffer, &edi, &ebp);
|
||||
buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);
|
||||
tooltip_text_width &= 0xFFFF;
|
||||
if (tooltip_text_width > 196)
|
||||
tooltip_text_width = 196;
|
||||
|
||||
esi = 0x0141ED68;
|
||||
edi = ecx + 1;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224;
|
||||
RCT2_CALLFUNC_X(0x006C21E2, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
ecx &= 0xFFFF;
|
||||
edi &= 0xFFFF;
|
||||
tooltip_text_width = gfx_wrap_string(buffer, tooltip_text_width + 1, &tooltip_text_height, &ebx);
|
||||
|
||||
RCT2_GLOBAL(0x01420044, sint16) = edi;
|
||||
width = ecx + 3;
|
||||
height = ((edi + 1) * 10) + 4;
|
||||
RCT2_GLOBAL(0x01420044, sint16) = tooltip_text_height;
|
||||
width = tooltip_text_width + 3;
|
||||
height = ((tooltip_text_height + 1) * 10) + 4;
|
||||
window_tooltip_widgets[WIDX_BACKGROUND].right = width;
|
||||
window_tooltip_widgets[WIDX_BACKGROUND].bottom = height;
|
||||
|
||||
memcpy((void*)0x0141FE44, (void*)0x0141ED68, 512);
|
||||
memcpy((void*)0x0141FE44, (void*)buffer, 512);
|
||||
|
||||
x = clamp(0, x - (width / 2), RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - width);
|
||||
y = clamp(22, y + 26, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - height - 40);
|
||||
|
|
Loading…
Reference in New Issue