From e1a9e6005d74a73a08f8647c11c6025a19ce1dc7 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Fri, 18 Oct 2019 12:57:31 -0300 Subject: [PATCH] Use ScreenCoordsXY for Chat functions (#10084) --- src/openrct2/interface/Chat.cpp | 12 ++++++------ src/openrct2/interface/Chat.h | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/openrct2/interface/Chat.cpp b/src/openrct2/interface/Chat.cpp index 801e6cb8e0..fef0df3b23 100644 --- a/src/openrct2/interface/Chat.cpp +++ b/src/openrct2/interface/Chat.cpp @@ -157,7 +157,7 @@ void chat_draw(rct_drawpixelinfo* dpi, uint8_t chatBackgroundColor) safe_strcpy(lineBuffer, chat_history_get(i), sizeof(lineBuffer)); - stringHeight = chat_history_draw_string(dpi, (void*)&lineCh, x, y, _chatWidth - 10) + 5; + stringHeight = chat_history_draw_string(dpi, (void*)&lineCh, ScreenCoordsXY(x, y), _chatWidth - 10) + 5; gfx_set_dirty_blocks(x, y - stringHeight, x + _chatWidth, y + 20); if ((y - stringHeight) < 50) @@ -275,7 +275,7 @@ static void chat_clear_input() // This method is the same as gfx_draw_string_left_wrapped. // But this adjusts the initial Y coordinate depending of the number of lines. -int32_t chat_history_draw_string(rct_drawpixelinfo* dpi, void* args, int32_t x, int32_t y, int32_t width) +int32_t chat_history_draw_string(rct_drawpixelinfo* dpi, void* args, ScreenCoordsXY screenCoords, int32_t width) { int32_t fontSpriteBase, lineHeight, lineY, numLines; @@ -291,20 +291,20 @@ int32_t chat_history_draw_string(rct_drawpixelinfo* dpi, void* args, int32_t x, gCurrentFontFlags = 0; - int32_t expectedY = y - (numLines * lineHeight); + int32_t expectedY = screenCoords.y - (numLines * lineHeight); if (expectedY < 50) { return (numLines * lineHeight); // Skip drawing, return total height. } - lineY = y; + lineY = screenCoords.y; for (int32_t line = 0; line <= numLines; ++line) { - gfx_draw_string(dpi, buffer, TEXT_COLOUR_254, x, lineY - (numLines * lineHeight)); + gfx_draw_string(dpi, buffer, TEXT_COLOUR_254, screenCoords.x, lineY - (numLines * lineHeight)); buffer = get_string_end(buffer) + 1; lineY += lineHeight; } - return lineY - y; + return lineY - screenCoords.y; } // Wrap string without drawing, useful to get the height of a wrapped string. diff --git a/src/openrct2/interface/Chat.h b/src/openrct2/interface/Chat.h index 2653f9a1d5..82379bb81d 100644 --- a/src/openrct2/interface/Chat.h +++ b/src/openrct2/interface/Chat.h @@ -11,6 +11,7 @@ #define _CHAT_H_ #include "../common.h" +#include "../world/Location.hpp" #define CHAT_HISTORY_SIZE 10 #define CHAT_INPUT_SIZE 1024 @@ -41,6 +42,6 @@ void chat_history_add(const char* src); void chat_input(CHAT_INPUT input); int32_t chat_string_wrapped_get_height(void* args, int32_t width); -int32_t chat_history_draw_string(rct_drawpixelinfo* dpi, void* args, int32_t x, int32_t y, int32_t width); +int32_t chat_history_draw_string(rct_drawpixelinfo* dpi, void* args, ScreenCoordsXY screenCoords, int32_t width); #endif