mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-26 08:14: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:
@@ -252,14 +252,16 @@ static void window_text_input_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
{
|
||||
window_draw_widgets(w, dpi);
|
||||
|
||||
int32_t y = w->windowPos.y + 25;
|
||||
ScreenCoordsXY screenCoords;
|
||||
screenCoords.y = w->windowPos.y + 25;
|
||||
|
||||
int32_t no_lines = 0;
|
||||
int32_t font_height = 0;
|
||||
|
||||
gfx_draw_string_centred(dpi, input_text_description, w->windowPos.x + WW / 2, y, w->colours[1], &TextInputDescriptionArgs);
|
||||
gfx_draw_string_centred(
|
||||
dpi, input_text_description, w->windowPos.x + WW / 2, screenCoords.y, w->colours[1], &TextInputDescriptionArgs);
|
||||
|
||||
y += 25;
|
||||
screenCoords.y += 25;
|
||||
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
||||
gCurrentFontFlags = 0;
|
||||
@@ -272,9 +274,10 @@ static void window_text_input_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
gfx_wrap_string(wrapped_string, WW - (24 + 13), &no_lines, &font_height);
|
||||
|
||||
gfx_fill_rect_inset(
|
||||
dpi, w->windowPos.x + 10, y, w->windowPos.x + WW - 10, y + 10 * (no_lines + 1) + 3, w->colours[1], INSET_RECT_F_60);
|
||||
dpi, w->windowPos.x + 10, screenCoords.y, w->windowPos.x + WW - 10, screenCoords.y + 10 * (no_lines + 1) + 3,
|
||||
w->colours[1], INSET_RECT_F_60);
|
||||
|
||||
y += 1;
|
||||
screenCoords.y += 1;
|
||||
|
||||
char* wrap_pointer = wrapped_string;
|
||||
size_t char_count = 0;
|
||||
@@ -284,7 +287,8 @@ static void window_text_input_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
int32_t cursorY = 0;
|
||||
for (int32_t line = 0; line <= no_lines; line++)
|
||||
{
|
||||
gfx_draw_string(dpi, wrap_pointer, w->colours[1], w->windowPos.x + 12, y);
|
||||
screenCoords.x = w->windowPos.x + 12;
|
||||
gfx_draw_string(dpi, wrap_pointer, w->colours[1], screenCoords);
|
||||
|
||||
size_t string_length = get_string_size(wrap_pointer) - 1;
|
||||
|
||||
@@ -294,7 +298,7 @@ static void window_text_input_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
char temp_string[TEXT_INPUT_SIZE] = { 0 };
|
||||
std::memcpy(temp_string, wrap_pointer, gTextInput->SelectionStart - char_count);
|
||||
cursorX = w->windowPos.x + 13 + gfx_get_string_width(temp_string);
|
||||
cursorY = y;
|
||||
cursorY = screenCoords.y;
|
||||
|
||||
int32_t width = 6;
|
||||
if (gTextInput->SelectionStart < strlen(text_input))
|
||||
@@ -311,7 +315,7 @@ static void window_text_input_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
{
|
||||
uint8_t colour = ColourMapA[w->colours[1]].mid_light;
|
||||
// TODO: palette index addition
|
||||
gfx_fill_rect(dpi, cursorX, y + 9, cursorX + width, y + 9, colour + 5);
|
||||
gfx_fill_rect(dpi, cursorX, screenCoords.y + 9, cursorX + width, screenCoords.y + 9, colour + 5);
|
||||
}
|
||||
|
||||
cur_drawn++;
|
||||
@@ -323,13 +327,13 @@ static void window_text_input_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
char_count++;
|
||||
char_count += string_length;
|
||||
|
||||
y += 10;
|
||||
screenCoords.y += 10;
|
||||
}
|
||||
|
||||
if (!cur_drawn)
|
||||
{
|
||||
cursorX = gLastDrawStringX;
|
||||
cursorY = y - 10;
|
||||
cursorY = screenCoords.y - 10;
|
||||
}
|
||||
|
||||
// IME composition
|
||||
@@ -421,12 +425,12 @@ static void window_text_input_invalidate(rct_window* w)
|
||||
static void draw_ime_composition(rct_drawpixelinfo* dpi, int cursorX, int cursorY)
|
||||
{
|
||||
int compositionWidth = gfx_get_string_width(gTextInput->ImeBuffer);
|
||||
int x = cursorX - (compositionWidth / 2);
|
||||
int y = cursorY + 13;
|
||||
ScreenCoordsXY screenCoords(cursorX - (compositionWidth / 2), cursorY + 13);
|
||||
int width = compositionWidth;
|
||||
int height = 10;
|
||||
|
||||
gfx_fill_rect(dpi, x - 1, y - 1, x + width + 1, y + height + 1, PALETTE_INDEX_12);
|
||||
gfx_fill_rect(dpi, x, y, x + width, y + height, PALETTE_INDEX_0);
|
||||
gfx_draw_string(dpi, static_cast<const char*>(gTextInput->ImeBuffer), COLOUR_DARK_GREEN, x, y);
|
||||
gfx_fill_rect(
|
||||
dpi, screenCoords.x - 1, screenCoords.y - 1, screenCoords.x + width + 1, screenCoords.y + height + 1, PALETTE_INDEX_12);
|
||||
gfx_fill_rect(dpi, screenCoords.x, screenCoords.y, screenCoords.x + width, screenCoords.y + height, PALETTE_INDEX_0);
|
||||
gfx_draw_string(dpi, static_cast<const char*>(gTextInput->ImeBuffer), COLOUR_DARK_GREEN, screenCoords);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user