1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 17:42:29 +01:00

Use ScreenCoordsXY for Chat functions (#10084)

This commit is contained in:
Tulio Leao
2019-10-18 12:57:31 -03:00
committed by Michael Steenbeek
parent a5d654b592
commit e1a9e6005d
2 changed files with 8 additions and 7 deletions

View File

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

View File

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