mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-17 03:53:07 +01:00
implement utf8, part 19
This commit is contained in:
@@ -128,6 +128,12 @@ int gfx_clip_string(utf8 *text, int width)
|
||||
utf8 *clipCh = text;
|
||||
int codepoint;
|
||||
while ((codepoint = utf8_get_next(ch, &nextCh)) != 0) {
|
||||
if (utf8_is_format_code(codepoint)) {
|
||||
ch = nextCh;
|
||||
ch += utf8_get_format_code_arg_length(codepoint);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) { backup[i] = nextCh[i]; };
|
||||
for (int i = 0; i < 3; i++) { nextCh[i] = '.'; }
|
||||
nextCh[3] = 0;
|
||||
@@ -175,9 +181,9 @@ int gfx_wrap_string(utf8 *text, int width, int *outNumLines, int *outFontHeight)
|
||||
|
||||
utf8 *ch = text;
|
||||
utf8 *firstCh = text;
|
||||
utf8 *lastCh;
|
||||
utf8 *nextCh;
|
||||
int codepoint;
|
||||
while ((codepoint = utf8_get_next(ch, &lastCh)) != 0) {
|
||||
while ((codepoint = utf8_get_next(ch, &nextCh)) != 0) {
|
||||
if (codepoint == ' ') {
|
||||
currentWord = ch;
|
||||
currentWidth = lineWidth;
|
||||
@@ -189,15 +195,19 @@ int gfx_wrap_string(utf8 *text, int width, int *outNumLines, int *outFontHeight)
|
||||
currentWord = NULL;
|
||||
firstCh = ch;
|
||||
continue;
|
||||
} else if (utf8_is_format_code(codepoint)) {
|
||||
ch = nextCh;
|
||||
ch += utf8_get_format_code_arg_length(codepoint);
|
||||
continue;
|
||||
}
|
||||
|
||||
uint8 saveCh = *lastCh;
|
||||
*lastCh = 0;
|
||||
uint8 saveCh = *nextCh;
|
||||
*nextCh = 0;
|
||||
lineWidth = gfx_get_string_width(firstCh);
|
||||
*lastCh = saveCh;
|
||||
*nextCh = saveCh;
|
||||
|
||||
if (lineWidth <= width) {
|
||||
ch = lastCh;
|
||||
ch = nextCh;
|
||||
} else if (currentWord == NULL) {
|
||||
// Single word is longer than line, insert null terminator
|
||||
ch += utf8_insert_codepoint(ch, 0);
|
||||
|
||||
@@ -959,7 +959,7 @@ void process_mouse_over(int x, int y)
|
||||
int ebx, esi, edi, ebp;
|
||||
|
||||
cursorId = CURSOR_ARROW;
|
||||
RCT2_GLOBAL(0x9A9808, sint16) = -1;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_MAP_TOOLTIP_ARGS, sint16) = -1;
|
||||
window = window_find_from_point(x, y);
|
||||
|
||||
if (window != NULL) {
|
||||
|
||||
@@ -151,5 +151,5 @@ static void window_map_tooltip_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_TOOLTIP_ARGS, rct_string_id) == (rct_string_id)STR_NONE)
|
||||
return;
|
||||
|
||||
gfx_draw_string_centred_wrapped(dpi, (void*)0x009A9808, w->x + (w->width / 2), w->y + (w->height / 2), w->width, 1162, 0);
|
||||
gfx_draw_string_centred_wrapped(dpi, (void*)RCT2_ADDRESS_MAP_TOOLTIP_ARGS, w->x + (w->width / 2), w->y + (w->height / 2), w->width, 1162, 0);
|
||||
}
|
||||
Reference in New Issue
Block a user