diff --git a/data/language/english_uk.txt b/data/language/english_uk.txt index 8b2e44754b..4f323a14c7 100644 --- a/data/language/english_uk.txt +++ b/data/language/english_uk.txt @@ -3822,3 +3822,4 @@ STR_5482 :{WINDOW_COLOUR_2}Time since last inspection: {BLACK}1 minute STR_5483 :{BLACK}({COMMA16} weeks remaining) STR_5484 :{BLACK}({COMMA16} week remaining) STR_5485 :{SMALLFONT}{STRING} +STR_5486 :{BLACK}{COMMA16} diff --git a/src/config.c b/src/config.c index a2de18bdfb..6ad85f1ee4 100644 --- a/src/config.c +++ b/src/config.c @@ -705,13 +705,13 @@ static config_line *_configLines = NULL; * @param resultPath Pointer to where the absolute path of the RCT2 installation directory will be copied to. * @returns 1 if successful, otherwise 0. */ -static bool config_find_rct2_path(char *resultPath) +static bool config_find_rct2_path(utf8 *resultPath) { int i; log_verbose("searching common installation locations."); - const char *searchLocations[] = { + const utf8 *searchLocations[] = { "C:\\Program Files\\Infogrames\\RollerCoaster Tycoon 2", "C:\\Program Files (x86)\\Infogrames\\RollerCoaster Tycoon 2", "C:\\Program Files\\Infogrames Interactive\\RollerCoaster Tycoon 2", @@ -734,8 +734,8 @@ static bool config_find_rct2_path(char *resultPath) bool config_find_or_browse_install_directory() { - char path[MAX_PATH]; - char *installPath; + utf8 path[MAX_PATH]; + utf8 *installPath; if (config_find_rct2_path(path)) { SafeFree(gConfigGeneral.game_path); diff --git a/src/drawing/string.c b/src/drawing/string.c index eafed0fa68..e9d04a01e1 100644 --- a/src/drawing/string.c +++ b/src/drawing/string.c @@ -229,7 +229,7 @@ int gfx_wrap_string(utf8 *text, int width, int *outNumLines, int *outFontHeight) numCharactersOnLine = 0; } } - + maxWidth = max(maxWidth, lineWidth); *outFontHeight = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16); return maxWidth == 0 ? lineWidth : maxWidth; } @@ -608,15 +608,7 @@ void draw_string_centred_raw(rct_drawpixelinfo *dpi, int x, int y, int numLines, text += 2; } - y += 10; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) <= 224) - continue; - - y -= 4; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) <= 448) - continue; - - y += 12; + y += font_get_line_height(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16)); } } diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index 1e9cf1b16d..cf642ed4b1 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -1825,6 +1825,8 @@ enum { STR_X_WEEKS_REMAINING = 5483, STR_1_WEEK_REMAINING = 5484, + STR_LAND_TOOL_SIZE_VALUE = 5486, + // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working STR_COUNT = 32768 }; diff --git a/src/openrct2.c b/src/openrct2.c index 8b8f21ee83..c6f10dbabe 100644 --- a/src/openrct2.c +++ b/src/openrct2.c @@ -39,8 +39,8 @@ #include "world/mapgen.h" int gOpenRCT2StartupAction = STARTUP_ACTION_TITLE; -char gOpenRCT2StartupActionPath[512] = { 0 }; -char gExePath[MAX_PATH]; +utf8 gOpenRCT2StartupActionPath[512] = { 0 }; +utf8 gExePath[MAX_PATH]; // This should probably be changed later and allow a custom selection of things to initialise like SDL_INIT bool gOpenRCT2Headless = false; @@ -112,19 +112,18 @@ static void openrct2_copy_files_over(const char *originalDirectory, const char * static void openrct2_set_exe_path() { - char exePath[MAX_PATH]; - char tempPath[MAX_PATH]; - char *exeDelimiter; - int pathEnd; + wchar_t exePath[MAX_PATH]; + wchar_t tempPath[MAX_PATH]; + wchar_t *exeDelimiter; int exeDelimiterIndex; - GetModuleFileName(NULL, exePath, MAX_PATH); - exeDelimiter = strrchr(exePath, platform_get_path_separator()); + GetModuleFileNameW(NULL, exePath, MAX_PATH); + exeDelimiter = wcsrchr(exePath, platform_get_path_separator()); exeDelimiterIndex = (int)(exeDelimiter - exePath); - pathEnd = strlen(exePath) - (strlen(exePath) - exeDelimiterIndex); - strncpy(tempPath, exePath, pathEnd); - tempPath[pathEnd] = '\0'; - _fullpath(gExePath, tempPath, MAX_PATH); + lstrcpynW(tempPath, exePath, exeDelimiterIndex + 1); + tempPath[exeDelimiterIndex] = L'\0'; + _wfullpath(exePath, tempPath, MAX_PATH); + WideCharToMultiByte(CP_UTF8, 0, exePath, countof(exePath), gExePath, countof(gExePath), NULL, NULL); } /** diff --git a/src/platform/platform.h b/src/platform/platform.h index 6554170c29..685e057af3 100644 --- a/src/platform/platform.h +++ b/src/platform/platform.h @@ -119,7 +119,7 @@ unsigned int platform_get_ticks(); void platform_get_user_directory(char *outPath, const char *subDirectory); void platform_show_messagebox(char *message); int platform_open_common_file_dialog(int type, char *title, char *filename, char *filterPattern, char *filterName); -char *platform_open_directory_browser(char *title); +utf8 *platform_open_directory_browser(utf8 *title); uint8 platform_get_locale_currency(); uint16 platform_get_locale_language(); uint8 platform_get_locale_measurement_format(); diff --git a/src/platform/windows.c b/src/platform/windows.c index 4fdd323165..5577cacb0e 100644 --- a/src/platform/windows.c +++ b/src/platform/windows.c @@ -413,8 +413,11 @@ int platform_open_common_file_dialog(int type, utf8 *title, utf8 *filename, utf8 lstrcpyW((wchar_t*)0x01423800, wcfilterName); // Copy filter pattern - lstrcpyW((wchar_t*)0x01423800 + lstrlenW(wcfilterName) + 1, wcfilterPattern); - *((wchar_t*)(0x01423800 + lstrlenW(wcfilterName) + 1 + lstrlenW(wcfilterPattern) + 1)) = 0; + int wcfilterNameLength = lstrlenW(wcfilterName); + int wcfilterPatternLength = lstrlenW(wcfilterPattern); + + lstrcpyW((wchar_t*)0x01423800 + wcfilterNameLength + 1, wcfilterPattern); + *((wchar_t*)((wchar_t*)0x01423800 + wcfilterNameLength + 1 + wcfilterPatternLength + 1)) = 0; openFileName.lpstrFilter = (wchar_t*)0x01423800; // @@ -440,13 +443,15 @@ int platform_open_common_file_dialog(int type, utf8 *title, utf8 *filename, utf8 return result; } -char *platform_open_directory_browser(char *title) +utf8 *platform_open_directory_browser(utf8 *title) { - BROWSEINFO bi; - char pszBuffer[MAX_PATH]; + BROWSEINFOW bi; + wchar_t pszBuffer[MAX_PATH], wctitle[256]; LPITEMIDLIST pidl; LPMALLOC lpMalloc; + MultiByteToWideChar(CP_UTF8, 0, title, -1, wctitle, countof(wctitle)); + // Initialize COM if (FAILED(CoInitializeEx(0, COINIT_APARTMENTTHREADED))) { CoUninitialize(); @@ -466,19 +471,20 @@ char *platform_open_directory_browser(char *title) bi.hwndOwner = NULL; bi.pidlRoot = NULL; bi.pszDisplayName = pszBuffer; - bi.lpszTitle = title; + bi.lpszTitle = wctitle; bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; bi.lpfn = NULL; bi.lParam = 0; - char *outPath = NULL; + utf8 *outPath = NULL; - if (pidl = SHBrowseForFolder(&bi)) { + if (pidl = SHBrowseForFolderW(&bi)) { // Copy the path directory to the buffer - if (SHGetPathFromIDList(pidl, pszBuffer)) { + if (SHGetPathFromIDListW(pidl, pszBuffer)) { // Store pszBuffer (and the path) in the outPath - outPath = (char*) malloc(strlen(pszBuffer)+1); - strcpy(outPath, pszBuffer); + int outPathCapacity = lstrlenW(pszBuffer) * 4 + 1; + outPath = (utf8*)malloc(outPathCapacity); + WideCharToMultiByte(CP_UTF8, 0, pszBuffer, countof(pszBuffer), outPath, outPathCapacity, NULL, NULL); } } CoUninitialize(); diff --git a/src/windows/editor_inventions_list.c b/src/windows/editor_inventions_list.c index cd5c30fb66..06ca44417d 100644 --- a/src/windows/editor_inventions_list.c +++ b/src/windows/editor_inventions_list.c @@ -804,7 +804,7 @@ static void window_editor_inventions_list_scrollpaint(rct_window *w, rct_drawpix int left, top, bottom, itemY, disableItemMovement; sint32 researchItemEndMarker; rct_string_id stringId; - char buffer[256], *ptr; + utf8 buffer[256], *ptr; // Draw background colour = RCT2_GLOBAL(0x0141FC48 + (w->colours[1] * 8), uint8); @@ -856,8 +856,9 @@ static void window_editor_inventions_list_scrollpaint(rct_window *w, rct_drawpix stringId = research_item_get_name(researchItem->entryIndex & 0xFFFFFF); ptr = buffer; - if (!disableItemMovement) - *ptr++ = colour & 0xFF; + if (!disableItemMovement) { + ptr = utf8_write_codepoint(ptr, colour & 0xFF); + } format_string(ptr, stringId, NULL); diff --git a/src/windows/land.c b/src/windows/land.c index 7e8c0e385b..f69fe7e1ce 100644 --- a/src/windows/land.c +++ b/src/windows/land.c @@ -375,11 +375,7 @@ static void window_land_paint(rct_window *w, rct_drawpixelinfo *dpi) // FEATURE larger land tool size support if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) > 7) { - RCT2_GLOBAL(0x009BC677, char) = FORMAT_BLACK; - RCT2_GLOBAL(0x009BC678, char) = FORMAT_COMMA16; - RCT2_GLOBAL(0x009BC679, char) = 0; - RCT2_GLOBAL(0x013CE952, sint16) = RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16); - gfx_draw_string_centred(dpi, 3165, x, y - 2, 0, (void*)0x013CE952); + gfx_draw_string_centred(dpi, STR_LAND_TOOL_SIZE_VALUE, x, y - 2, 0, &RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)); } x = w->x + (window_land_widgets[WIDX_PREVIEW].left + window_land_widgets[WIDX_PREVIEW].right) / 2 + 17; diff --git a/src/windows/map.c b/src/windows/map.c index d8d39826bd..6741fecca2 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -798,11 +798,7 @@ static void window_map_paint(rct_window *w, rct_drawpixelinfo *dpi) // Draw land tool size if (widget_is_active_tool(w, WIDX_SET_LAND_RIGHTS) && RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) > 7) { - RCT2_GLOBAL(0x009BC677, char) = FORMAT_BLACK; - RCT2_GLOBAL(0x009BC678, char) = FORMAT_COMMA16; - RCT2_GLOBAL(0x009BC679, char) = 0; - RCT2_GLOBAL(0x013CE952, sint16) = RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16); - gfx_draw_string_centred(dpi, 3165, x, y - 2, 0, (void*)0x013CE952); + gfx_draw_string_centred(dpi, STR_LAND_TOOL_SIZE_VALUE, x, y - 2, 0, &RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)); } y = w->y + window_map_widgets[WIDX_LAND_TOOL].bottom + 5; diff --git a/src/windows/tooltip.c b/src/windows/tooltip.c index 6f836cc1a0..c474aaab7e 100644 --- a/src/windows/tooltip.c +++ b/src/windows/tooltip.c @@ -112,24 +112,21 @@ void window_tooltip_open(rct_window *widgetWindow, int widgetIndex, int x, int y char* buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char); format_string(buffer, widget->tooltip, (void*)0x013CE952); - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; - - int tooltip_text_width = 0, tooltip_text_height = 0; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = FONT_SPRITE_BASE_MEDIUM; + int tooltip_text_width; tooltip_text_width = gfx_get_string_width_new_lined(buffer); buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char); - tooltip_text_width &= 0xFFFF; - if (tooltip_text_width > 196) - tooltip_text_width = 196; + tooltip_text_width = min(tooltip_text_width, 196); - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = FONT_SPRITE_BASE_MEDIUM; - int fontHeight; - tooltip_text_width = gfx_wrap_string(buffer, tooltip_text_width + 1, &tooltip_text_height, &fontHeight); + int numLines, fontSpriteBase; + tooltip_text_width = gfx_wrap_string(buffer, tooltip_text_width + 1, &numLines, &fontSpriteBase); - RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TEXT_HEIGHT, sint16) = tooltip_text_height; + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TEXT_HEIGHT, sint16) = numLines; width = tooltip_text_width + 3; - height = ((tooltip_text_height + 1) * 10) + 4; + height = ((numLines + 1) * font_get_line_height(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16))) + 4; window_tooltip_widgets[WIDX_BACKGROUND].right = width; window_tooltip_widgets[WIDX_BACKGROUND].bottom = height; @@ -220,6 +217,6 @@ static void window_tooltip_paint(rct_window *w, rct_drawpixelinfo *dpi) // Text left = w->x + ((w->width + 1) / 2) - 1; - top = w->y + 1; + top = w->y + 2; draw_string_centred_raw(dpi, left, top, RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TEXT_HEIGHT, uint16), gTooltip_text_buffer); } \ No newline at end of file diff --git a/src/windows/water.c b/src/windows/water.c index 5b2e4c2a5e..c3e2b7e81d 100644 --- a/src/windows/water.c +++ b/src/windows/water.c @@ -240,11 +240,7 @@ static void window_water_paint(rct_window *w, rct_drawpixelinfo *dpi) window_draw_widgets(w, dpi); // FEATURE larger land tool size support if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) > 7) { - RCT2_GLOBAL(0x009BC677, char) = FORMAT_BLACK; - RCT2_GLOBAL(0x009BC678, char) = FORMAT_COMMA16; - RCT2_GLOBAL(0x009BC679, char) = 0; - RCT2_GLOBAL(0x013CE952, sint16) = RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16); - gfx_draw_string_centred(dpi, 3165, x, y - 2, 0, (void*)0x013CE952); + gfx_draw_string_centred(dpi, STR_LAND_TOOL_SIZE_VALUE, x, y - 2, 0, &RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16)); } y = w->y + window_water_widgets[WIDX_PREVIEW].bottom + 5;