Part of #12096: ScreenRect w/ gfx_fill_rect in libopenrct2ui (#12188)

This commit is contained in:
frutiemax 2020-07-10 12:59:08 -04:00 committed by GitHub
parent 4dc4bbea92
commit 0e96674a46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 43 additions and 37 deletions

View File

@ -32,7 +32,7 @@ static void graph_draw_months_uint8_t(
dpi, STR_GRAPH_LABEL, screenCoords - ScreenCoordsXY{ 0, 10 }, COLOUR_BLACK, gCommonFormatArgs);
// Draw month mark
gfx_fill_rect(dpi, screenCoords.x, screenCoords.y, screenCoords.x, screenCoords.y + 3, PALETTE_INDEX_10);
gfx_fill_rect(dpi, { screenCoords, screenCoords + ScreenCoordsXY{ 0, 3 } }, PALETTE_INDEX_10);
}
yearOver32 = (yearOver32 + 1) % 32;
@ -59,7 +59,7 @@ static void graph_draw_line_a_uint8_t(
gfx_draw_line(dpi, lastX, lastY + 1, x, y + 1, PALETTE_INDEX_10);
}
if (i == 0)
gfx_fill_rect(dpi, x, y, x + 2, y + 2, PALETTE_INDEX_10);
gfx_fill_rect(dpi, { { x, y }, { x + 2, y + 2 } }, PALETTE_INDEX_10);
lastX = x;
lastY = y;
@ -85,7 +85,7 @@ static void graph_draw_line_b_uint8_t(
if (lastX != -1)
gfx_draw_line(dpi, lastX, lastY, x, y, PALETTE_INDEX_21);
if (i == 0)
gfx_fill_rect(dpi, x - 1, y - 1, x + 1, y + 1, PALETTE_INDEX_21);
gfx_fill_rect(dpi, { { x - 1, y - 1 }, { x + 1, y + 1 } }, PALETTE_INDEX_21);
lastX = x;
lastY = y;
@ -119,7 +119,7 @@ static void graph_draw_months_money32(
gfx_draw_string_centred(dpi, STR_GRAPH_LABEL, screenCoords - ScreenCoordsXY{ 0, 10 }, COLOUR_BLACK, &monthFormat);
// Draw month mark
gfx_fill_rect(dpi, screenCoords.x, screenCoords.y, screenCoords.x, screenCoords.y + 3, PALETTE_INDEX_10);
gfx_fill_rect(dpi, { screenCoords, screenCoords + ScreenCoordsXY{ 0, 3 } }, PALETTE_INDEX_10);
}
yearOver32 = (yearOver32 + 1) % 32;
@ -147,7 +147,7 @@ static void graph_draw_line_a_money32(
gfx_draw_line(dpi, lastX, lastY + 1, x, y + 1, PALETTE_INDEX_10);
}
if (i == 0)
gfx_fill_rect(dpi, x, y, x + 2, y + 2, PALETTE_INDEX_10);
gfx_fill_rect(dpi, { { x, y }, { x + 2, y + 2 } }, PALETTE_INDEX_10);
lastX = x;
lastY = y;
@ -174,7 +174,7 @@ static void graph_draw_line_b_money32(
if (lastX != -1)
gfx_draw_line(dpi, lastX, lastY, x, y, PALETTE_INDEX_21);
if (i == 0)
gfx_fill_rect(dpi, x - 1, y - 1, x + 1, y + 1, PALETTE_INDEX_21);
gfx_fill_rect(dpi, { { x - 1, y - 1 }, { x + 1, y + 1 } }, PALETTE_INDEX_21);
lastX = x;
lastY = y;
@ -259,8 +259,9 @@ static void graph_draw_hovered_value(
gfx_draw_string_centred(
dpi, STR_FINANCES_SUMMARY_EXPENDITURE_VALUE, info.coords - ScreenCoordsXY{ 0, 16 }, COLOUR_BLACK, &info.money);
gfx_fill_rect(dpi, info.coords.x - 2, info.coords.y - 2, info.coords.x + 2, info.coords.y + 2, PALETTE_INDEX_10);
gfx_fill_rect(dpi, info.coords.x - 1, info.coords.y - 1, info.coords.x + 1, info.coords.y + 1, PALETTE_INDEX_21);
gfx_fill_rect(dpi, { { info.coords - ScreenCoordsXY{ 2, 2 } }, info.coords + ScreenCoordsXY{ 2, 2 } }, PALETTE_INDEX_10);
gfx_fill_rect(
dpi, { { info.coords - ScreenCoordsXY{ 1, 1 } }, { info.coords + ScreenCoordsXY{ 1, 1 } } }, PALETTE_INDEX_21);
}
void graph_draw_money32(

View File

@ -324,11 +324,10 @@ void InGameConsole::Draw(rct_drawpixelinfo* dpi) const
// Draw caret
if (_consoleCaretTicks < CONSOLE_CARET_FLASH_THRESHOLD)
{
int32_t caretX = screenCoords.x + gfx_get_string_width(_consoleCurrentLine);
int32_t caretY = screenCoords.y + lineHeight;
auto caret = screenCoords + ScreenCoordsXY{ gfx_get_string_width(_consoleCurrentLine), lineHeight };
uint8_t caretColour = ColourMapA[BASE_COLOUR(textColour)].lightest;
gfx_fill_rect(dpi, caretX, caretY, caretX + CONSOLE_CARET_WIDTH, caretY, caretColour);
gfx_fill_rect(dpi, { caret, caret + ScreenCoordsXY{ CONSOLE_CARET_WIDTH, 0 } }, caretColour);
}
// What about border colours?
@ -337,13 +336,15 @@ void InGameConsole::Draw(rct_drawpixelinfo* dpi) const
// Input area top border
gfx_fill_rect(
dpi, _consoleLeft, _consoleBottom - lineHeight - 11, _consoleRight, _consoleBottom - lineHeight - 11, borderColour1);
dpi, { { _consoleLeft, _consoleBottom - lineHeight - 11 }, { _consoleRight, _consoleBottom - lineHeight - 11 } },
borderColour1);
gfx_fill_rect(
dpi, _consoleLeft, _consoleBottom - lineHeight - 10, _consoleRight, _consoleBottom - lineHeight - 10, borderColour2);
dpi, { { _consoleLeft, _consoleBottom - lineHeight - 10 }, { _consoleRight, _consoleBottom - lineHeight - 10 } },
borderColour2);
// Input area bottom border
gfx_fill_rect(dpi, _consoleLeft, _consoleBottom - 1, _consoleRight, _consoleBottom - 1, borderColour1);
gfx_fill_rect(dpi, _consoleLeft, _consoleBottom - 0, _consoleRight, _consoleBottom - 0, borderColour2);
gfx_fill_rect(dpi, { { _consoleLeft, _consoleBottom - 1 }, { _consoleRight, _consoleBottom - 1 } }, borderColour1);
gfx_fill_rect(dpi, { { _consoleLeft, _consoleBottom }, { _consoleRight, _consoleBottom } }, borderColour2);
}
// Calculates the amount of visible lines, based on the console size, excluding the input line.

View File

@ -535,7 +535,7 @@ void CustomListView::MouseUp(const ScreenCoordsXY& pos)
void CustomListView::Paint(rct_window* w, rct_drawpixelinfo* dpi, const rct_scroll* scroll) const
{
auto paletteIndex = ColourMapA[w->colours[1]].mid_light;
gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width, dpi->y + dpi->height, paletteIndex);
gfx_fill_rect(dpi, { { dpi->x, dpi->y }, { dpi->x + dpi->width, dpi->y + dpi->height } }, paletteIndex);
int32_t y = ShowColumnHeaders ? COLUMN_HEADER_HEIGHT : 0;
for (size_t i = 0; i < Items.size(); i++)
@ -566,7 +566,7 @@ void CustomListView::Paint(rct_window* w, rct_drawpixelinfo* dpi, const rct_scro
else if (isStriped)
{
gfx_fill_rect(
dpi, dpi->x, y, dpi->x + dpi->width, y + (LIST_ROW_HEIGHT - 1),
dpi, { { dpi->x, y }, { dpi->x + dpi->width, y + (LIST_ROW_HEIGHT - 1) } },
ColourMapA[w->colours[1]].lighter | 0x1000000);
}
@ -608,7 +608,7 @@ void CustomListView::Paint(rct_window* w, rct_drawpixelinfo* dpi, const rct_scro
y = scroll->v_top;
auto bgColour = ColourMapA[w->colours[1]].mid_light;
gfx_fill_rect(dpi, dpi->x, y, dpi->x + dpi->width, y + 12, bgColour);
gfx_fill_rect(dpi, { { dpi->x, y }, { dpi->x + dpi->width, y + 12 } }, bgColour);
int32_t x = 0;
for (int32_t j = 0; j < static_cast<int32_t>(Columns.size()); j++)

View File

@ -347,8 +347,8 @@ static void window_dropdown_paint(rct_window* w, rct_drawpixelinfo* dpi)
}
else
{
gfx_fill_rect(dpi, l, t, r, b, ColourMapA[w->colours[0]].mid_dark);
gfx_fill_rect(dpi, l, t + 1, r, b + 1, ColourMapA[w->colours[0]].lightest);
gfx_fill_rect(dpi, { { l, t }, { r, b } }, ColourMapA[w->colours[0]].mid_dark);
gfx_fill_rect(dpi, { { l, t + 1 }, { r, b + 1 } }, ColourMapA[w->colours[0]].lightest);
}
}
else

View File

@ -567,8 +567,10 @@ static void window_editor_inventions_list_paint(rct_window* w, rct_drawpixelinfo
// Preview background
widget = &w->widgets[WIDX_PREVIEW];
gfx_fill_rect(
dpi, w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1, w->windowPos.x + widget->right - 1,
w->windowPos.y + widget->bottom - 1, ColourMapA[w->colours[1]].darkest);
dpi,
{ w->windowPos + ScreenCoordsXY{ widget->left + 1, widget->top + 1 },
w->windowPos + ScreenCoordsXY{ widget->right - 1, widget->bottom - 1 } },
ColourMapA[w->colours[1]].darkest);
researchItem = &_editorInventionsListDraggedItem;
if (researchItem->IsNull())

View File

@ -1001,8 +1001,10 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
// Preview background
widget = &w->widgets[WIDX_PREVIEW];
gfx_fill_rect(
dpi, w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1, w->windowPos.x + widget->right - 1,
w->windowPos.y + widget->bottom - 1, ColourMapA[w->colours[1]].darkest);
dpi,
{ w->windowPos + ScreenCoordsXY{ widget->left + 1, widget->top + 1 },
w->windowPos + ScreenCoordsXY{ widget->right - 1, widget->bottom - 1 } },
ColourMapA[w->colours[1]].darkest);
// Draw number of selected items
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER))

View File

@ -1138,7 +1138,7 @@ static void window_editor_objective_options_rides_paint(rct_window* w, rct_drawp
static void window_editor_objective_options_rides_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex)
{
int32_t colour = ColourMapA[w->colours[1]].mid_light;
gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width - 1, dpi->y + dpi->height - 1, colour);
gfx_fill_rect(dpi, { { dpi->x, dpi->y }, { dpi->x + dpi->width - 1, dpi->y + dpi->height - 1 } }, colour);
for (int32_t i = 0; i < w->no_list_items; i++)
{

View File

@ -679,7 +679,7 @@ static void window_finances_summary_paint(rct_window* w, rct_drawpixelinfo* dpi)
// Darken every even row
if (i % 2 == 0)
gfx_fill_rect(
dpi, screenCoords.x, screenCoords.y - 1, screenCoords.x + 121, screenCoords.y + (TABLE_CELL_HEIGHT - 2),
dpi, { screenCoords - ScreenCoordsXY{ 0, 1 }, screenCoords + ScreenCoordsXY{ 121, (TABLE_CELL_HEIGHT - 2) } },
ColourMapA[w->colours[1]].lighter | 0x1000000);
gfx_draw_string_left(
@ -735,7 +735,8 @@ static void window_finances_summary_scrollpaint(rct_window* w, rct_drawpixelinfo
// Darken every even row
if (i % 2 == 0)
gfx_fill_rect(
dpi, screenCoords.x, screenCoords.y - 1, screenCoords.x + row_width, screenCoords.y + (TABLE_CELL_HEIGHT - 2),
dpi,
{ screenCoords - ScreenCoordsXY{ 0, 1 }, screenCoords + ScreenCoordsXY{ row_width, (TABLE_CELL_HEIGHT - 2) } },
ColourMapA[w->colours[1]].lighter | 0x1000000);
screenCoords.y += TABLE_CELL_HEIGHT;
@ -781,7 +782,7 @@ static void window_finances_summary_scrollpaint(rct_window* w, rct_drawpixelinfo
dpi, profit >= 0 ? STR_FINANCES_SUMMARY_INCOME_VALUE : STR_FINANCES_SUMMARY_LOSS_VALUE, &profit, COLOUR_BLACK,
screenCoords + ScreenCoordsXY{ EXPENDITURE_COLUMN_WIDTH, 0 });
gfx_fill_rect(
dpi, screenCoords.x + 10, screenCoords.y - 2, screenCoords.x + EXPENDITURE_COLUMN_WIDTH, screenCoords.y - 2,
dpi, { screenCoords + ScreenCoordsXY{ 10, -2 }, screenCoords + ScreenCoordsXY{ EXPENDITURE_COLUMN_WIDTH, -2 } },
PALETTE_INDEX_10);
screenCoords.x += EXPENDITURE_COLUMN_WIDTH;

View File

@ -1720,13 +1720,8 @@ void window_guest_rides_paint(rct_window* w, rct_drawpixelinfo* dpi)
*/
void window_guest_rides_scroll_paint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex)
{
int32_t left = dpi->x;
int32_t right = dpi->x + dpi->width - 1;
int32_t top = dpi->y;
int32_t bottom = dpi->y + dpi->height - 1;
auto colour = ColourMapA[w->colours[1]].mid_light;
gfx_fill_rect(dpi, left, top, right, bottom, colour);
gfx_fill_rect(dpi, { { dpi->x, dpi->y }, { dpi->x + dpi->width - 1, dpi->y + dpi->height - 1 } }, colour);
for (int32_t list_index = 0; list_index < w->no_list_items; list_index++)
{

View File

@ -745,7 +745,9 @@ static void window_guest_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
rct_peep_thought* thought;
// Background fill
gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width - 1, dpi->y + dpi->height - 1, ColourMapA[w->colours[1]].mid_light);
gfx_fill_rect(
dpi, { { dpi->x, dpi->y }, { dpi->x + dpi->width - 1, dpi->y + dpi->height - 1 } },
ColourMapA[w->colours[1]].mid_light);
switch (_window_guest_list_selected_tab)
{
case PAGE_INDIVIDUAL:

View File

@ -227,7 +227,7 @@ static void window_install_track_paint(rct_window* w, rct_drawpixelinfo* dpi)
rct_widget* widget = &window_install_track_widgets[WIDX_TRACK_PREVIEW];
auto screenPos = w->windowPos + ScreenCoordsXY{ widget->left + 1, widget->top + 1 };
int32_t colour = ColourMapA[w->colours[0]].darkest;
gfx_fill_rect(dpi, screenPos.x, screenPos.y, screenPos.x + 369, screenPos.y + 216, colour);
gfx_fill_rect(dpi, { screenPos, screenPos + ScreenCoordsXY{ 369, 216 } }, colour);
rct_g1_element g1temp = {};
g1temp.offset = _trackDesignPreviewPixels.data() + (_currentTrackPieceDirection * TRACK_PREVIEW_IMAGE_SIZE);

View File

@ -748,7 +748,9 @@ static void window_loadsave_paint(rct_window* w, rct_drawpixelinfo* dpi)
static void window_loadsave_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex)
{
gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width - 1, dpi->y + dpi->height - 1, ColourMapA[w->colours[1]].mid_light);
gfx_fill_rect(
dpi, { { dpi->x, dpi->y }, { dpi->x + dpi->width - 1, dpi->y + dpi->height - 1 } },
ColourMapA[w->colours[1]].mid_light);
const int32_t listWidth = w->widgets[WIDX_SCROLL].width();
const int32_t dateAnchor = w->widgets[WIDX_SORT_DATE].left + maxDateWidth + DATE_TIME_GAP;