diff --git a/src/interface/console.c b/src/interface/console.c index e5790bfd91..7d4e2d0e0e 100644 --- a/src/interface/console.c +++ b/src/interface/console.c @@ -124,7 +124,7 @@ void console_update() } // Remove unwated characters in console input - utf8_remove_format_codes(_consoleCurrentLine); + utf8_remove_format_codes(_consoleCurrentLine, false); } // Flash the caret diff --git a/src/localisation/language.cpp b/src/localisation/language.cpp index 0ef13d5156..9ce07e3f7a 100644 --- a/src/localisation/language.cpp +++ b/src/localisation/language.cpp @@ -118,13 +118,13 @@ const utf8 BlackLeftArrowString[] = { (utf8)0xC2, (utf8)0x8E, (utf8)0xE2, (utf8 const utf8 BlackRightArrowString[] = { (utf8)0xC2, (utf8)0x8E, (utf8)0xE2, (utf8)0x96, (utf8)0xB6, (utf8)0x00 }; const utf8 CheckBoxMarkString[] = { (utf8)0xE2, (utf8)0x9C, (utf8)0x93, (utf8)0x00 }; -void utf8_remove_format_codes(utf8 *text) +void utf8_remove_format_codes(utf8 *text, bool allowcolours) { utf8 *dstCh = text; utf8 *ch = text; int codepoint; while ((codepoint = utf8_get_next(ch, (const utf8**)&ch)) != 0) { - if (!utf8_is_format_code(codepoint)) { + if (!utf8_is_format_code(codepoint) || (allowcolours && utf8_is_colour_code(codepoint))) { dstCh = utf8_write_codepoint(dstCh, codepoint); } } diff --git a/src/localisation/language.h b/src/localisation/language.h index deb19f23a3..2bc21de39b 100644 --- a/src/localisation/language.h +++ b/src/localisation/language.h @@ -79,7 +79,7 @@ uint32 utf8_get_next(const utf8 *char_ptr, const utf8 **nextchar_ptr); utf8 *utf8_write_codepoint(utf8 *dst, uint32 codepoint); int utf8_insert_codepoint(utf8 *dst, uint32 codepoint); bool utf8_is_codepoint_start(utf8 *text); -void utf8_remove_format_codes(utf8 *text); +void utf8_remove_format_codes(utf8 *text, bool allowcolours); int utf8_get_codepoint_length(int codepoint); int utf8_length(const utf8 *text); wchar_t *utf8_to_widechar(const utf8 *src); diff --git a/src/localisation/localisation.c b/src/localisation/localisation.c index 3ef750efd6..c8331c81eb 100644 --- a/src/localisation/localisation.c +++ b/src/localisation/localisation.c @@ -143,6 +143,12 @@ bool utf8_is_format_code(int codepoint) return false; } +bool utf8_is_colour_code(int codepoint) +{ + if (codepoint >= FORMAT_COLOUR_CODE_START && codepoint <= FORMAT_COLOUR_CODE_END) return true; + return false; +} + bool utf8_should_use_sprite_for_codepoint(int codepoint) { switch (codepoint) { diff --git a/src/localisation/localisation.h b/src/localisation/localisation.h index ac255f5b91..a471a1eeee 100644 --- a/src/localisation/localisation.h +++ b/src/localisation/localisation.h @@ -27,6 +27,7 @@ #include "string_ids.h" bool utf8_is_format_code(int codepoint); +bool utf8_is_colour_code(int codepoint); bool utf8_should_use_sprite_for_codepoint(int codepoint); int font_sprite_get_codepoint_offset(int codepoint); int utf8_get_format_code_arg_length(int codepoint); diff --git a/src/network/network.cpp b/src/network/network.cpp index 00f4176845..1e29aeaa3c 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -209,6 +209,7 @@ void NetworkPlayer::SetName(const char* name) { safe_strcpy((char*)NetworkPlayer::name, name, sizeof(NetworkPlayer::name)); NetworkPlayer::name[sizeof(NetworkPlayer::name) - 1] = 0; + utf8_remove_format_codes((utf8*)NetworkPlayer::name, false); } void NetworkPlayer::AddMoneySpent(money32 cost) @@ -992,7 +993,9 @@ const char* Network::FormatChat(NetworkPlayer* fromplayer, const char* text) } lineCh = utf8_write_codepoint(lineCh, FORMAT_OUTLINE); lineCh = utf8_write_codepoint(lineCh, FORMAT_WHITE); + char* ptrtext = lineCh; safe_strcpy(lineCh, text, 800); + utf8_remove_format_codes((utf8*)ptrtext, true); return formatted; } diff --git a/src/windows/multiplayer.c b/src/windows/multiplayer.c index 5c1f31ba08..460f6d68a3 100644 --- a/src/windows/multiplayer.c +++ b/src/windows/multiplayer.c @@ -440,7 +440,7 @@ static void window_multiplayer_players_scrollpaint(rct_window *w, rct_drawpixeli if (action != -999) { RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = network_get_action_name_string_id(action); } - gfx_draw_string_left(dpi, 1191, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0, 256, y - 1); + gfx_draw_string_left_clipped(dpi, 1191, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0, 256, y - 1, 100); // Draw ping lineCh = buffer; diff --git a/src/windows/player.c b/src/windows/player.c index 0f717ffedf..dd94715a39 100644 --- a/src/windows/player.c +++ b/src/windows/player.c @@ -206,7 +206,7 @@ void window_player_open(uint8 id) int player = network_get_player_index(id); window = window_bring_to_front_by_number(WC_PLAYER, id); if (window == NULL) { - window = window_create_auto_pos(210, 134, &window_player_overview_events, WC_PLAYER, WF_RESIZABLE); + window = window_create_auto_pos(240, 170, &window_player_overview_events, WC_PLAYER, WF_RESIZABLE); window->number = id; window->page = 0; window->viewport_focus_coordinates.y = 0; diff --git a/src/windows/text_input.c b/src/windows/text_input.c index f83223451a..7cf1027832 100644 --- a/src/windows/text_input.c +++ b/src/windows/text_input.c @@ -118,7 +118,7 @@ void window_text_input_open(rct_window* call_w, int call_widget, rct_string_id t // from crashing the game. text_input[maxLength - 1] = '\0'; - utf8_remove_format_codes(text_input); + utf8_remove_format_codes(text_input, false); // This is the text displayed above the input box input_text_description = description;