1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-23 06:44:38 +01:00

Close #11561: Use ScreenCoordsXY in gfx_draw_string()

* Fix #11572 create gfx_draw_string() overload

created the overload and changed all calls of the old function to the new (using const ScreenCoordsXY&)

...
This commit is contained in:
TomasZilinek
2020-05-10 14:49:15 +02:00
committed by GitHub
parent 783494df68
commit 9fde6a74c3
23 changed files with 219 additions and 191 deletions

View File

@@ -304,29 +304,28 @@ void InGameConsole::Draw(rct_drawpixelinfo* dpi) const
INSET_RECT_FLAG_BORDER_INSET);
std::string lineBuffer;
int32_t x = _consoleLeft + CONSOLE_EDGE_PADDING;
int32_t y = _consoleTop + CONSOLE_EDGE_PADDING;
auto screenCoords = ScreenCoordsXY{ _consoleLeft + CONSOLE_EDGE_PADDING, _consoleTop + CONSOLE_EDGE_PADDING };
// Draw text inside console
for (std::size_t i = 0; i < _consoleLines.size() && i < static_cast<size_t>(maxLines); i++)
{
const size_t index = i + _consoleScrollPos;
lineBuffer = colourFormatStr + _consoleLines[index];
gfx_draw_string(dpi, lineBuffer.c_str(), textColour, x, y);
y += lineHeight;
gfx_draw_string(dpi, lineBuffer.c_str(), textColour, screenCoords);
screenCoords.y += lineHeight;
}
y = _consoleBottom - lineHeight - CONSOLE_EDGE_PADDING - 1;
screenCoords.y = _consoleBottom - lineHeight - CONSOLE_EDGE_PADDING - 1;
// Draw current line
lineBuffer = colourFormatStr + _consoleCurrentLine;
gfx_draw_string(dpi, lineBuffer.c_str(), TEXT_COLOUR_255, x, y);
gfx_draw_string(dpi, lineBuffer.c_str(), TEXT_COLOUR_255, screenCoords);
// Draw caret
if (_consoleCaretTicks < CONSOLE_CARET_FLASH_THRESHOLD)
{
int32_t caretX = x + gfx_get_string_width(_consoleCurrentLine);
int32_t caretY = y + lineHeight;
int32_t caretX = screenCoords.x + gfx_get_string_width(_consoleCurrentLine);
int32_t caretY = screenCoords.y + lineHeight;
uint8_t caretColour = ColourMapA[BASE_COLOUR(textColour)].lightest;
gfx_fill_rect(dpi, caretX, caretY, caretX + CONSOLE_CARET_WIDTH, caretY, caretColour);