implement utf8, part 23 (bug fixes)

This commit is contained in:
IntelOrca 2015-08-01 16:40:15 +01:00
parent de7088cb25
commit d228d13918
12 changed files with 54 additions and 68 deletions

View File

@ -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}

View File

@ -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);

View File

@ -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));
}
}

View File

@ -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
};

View File

@ -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);
}
/**

View File

@ -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();

View File

@ -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();

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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;