1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-26 00:04:43 +01:00

Close #12096: Use only ScreenRect on gfx_fill_rect (#12280)

This commit is contained in:
frutiemax
2020-07-15 21:34:57 -04:00
committed by GitHub
parent 289dc96f25
commit c474f2ddc0
11 changed files with 37 additions and 32 deletions

View File

@@ -951,7 +951,9 @@ static void window_multiplayer_groups_scrollpaint(rct_window* w, rct_drawpixelin
{
auto screenCoords = ScreenCoordsXY{ 0, 0 };
gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width - 1, dpi->y + dpi->height - 1, ColourMapA[w->colours[1]].mid_light);
auto dpiCoords = ScreenCoordsXY{ dpi->x, dpi->y };
gfx_fill_rect(
dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi->width - 1, dpi->height - 1 } }, ColourMapA[w->colours[1]].mid_light);
for (int32_t i = 0; i < network_get_num_actions(); i++)
{

View File

@@ -301,7 +301,8 @@ static void window_network_information_invalidate(rct_window* w)
static void graph_draw_bar(rct_drawpixelinfo* dpi, int32_t x, int32_t y, int32_t height, int32_t width, int32_t colour)
{
gfx_fill_rect(dpi, x, y, x + width, y + height, colour);
auto coords = ScreenCoordsXY{ x, y };
gfx_fill_rect(dpi, { coords, coords + ScreenCoordsXY{ width, height } }, colour);
}
static void window_network_draw_graph(
@@ -453,7 +454,7 @@ static void window_network_information_paint(rct_window* w, rct_drawpixelinfo* d
// Draw color stripe.
gfx_fill_rect(
dpi, screenCoords.x, screenCoords.y + 4, screenCoords.x + 4, screenCoords.y + 6,
dpi, { screenCoords + ScreenCoordsXY{ 0, 4 }, screenCoords + ScreenCoordsXY{ 4, 6 } },
NetworkTrafficGroupColors[i]);
// Draw text.

View File

@@ -573,7 +573,9 @@ static void window_object_load_error_paint(rct_window* w, rct_drawpixelinfo* dpi
static void window_object_load_error_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);
auto dpiCoords = ScreenCoordsXY{ dpi->x, dpi->y };
gfx_fill_rect(
dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi->width - 1, dpi->height - 1 } }, ColourMapA[w->colours[1]].mid_light);
const int32_t list_width = w->widgets[WIDX_SCROLL].width();
for (int32_t i = 0; i < w->no_list_items; i++)
@@ -586,19 +588,14 @@ static void window_object_load_error_scrollpaint(rct_window* w, rct_drawpixelinf
if (screenCoords.y + SCROLLABLE_ROW_HEIGHT < dpi->y)
continue;
auto screenRect = ScreenRect{ { 0, screenCoords.y }, { list_width, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1 } };
// If hovering over item, change the color and fill the backdrop.
if (i == w->selected_list_item)
gfx_fill_rect(
dpi, 0, screenCoords.y, list_width, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1,
ColourMapA[w->colours[1]].darker);
gfx_fill_rect(dpi, screenRect, ColourMapA[w->colours[1]].darker);
else if (i == highlighted_index)
gfx_fill_rect(
dpi, 0, screenCoords.y, list_width, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1,
ColourMapA[w->colours[1]].mid_dark);
gfx_fill_rect(dpi, screenRect, ColourMapA[w->colours[1]].mid_dark);
else if ((i & 1) != 0) // odd / even check
gfx_fill_rect(
dpi, 0, screenCoords.y, list_width, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1,
ColourMapA[w->colours[1]].light);
gfx_fill_rect(dpi, screenRect, ColourMapA[w->colours[1]].light);
// Draw the actual object entry's name...
screenCoords.x = NAME_COL_LEFT - 3;

View File

@@ -586,7 +586,9 @@ static void window_ride_list_paint(rct_window* w, rct_drawpixelinfo* dpi)
*/
static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex)
{
gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width, dpi->y + dpi->height, ColourMapA[w->colours[1]].mid_light);
auto dpiCoords = ScreenCoordsXY{ dpi->x, dpi->y };
gfx_fill_rect(
dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi->width, dpi->height } }, ColourMapA[w->colours[1]].mid_light);
auto y = 0;
for (auto i = 0; i < w->no_list_items; i++)

View File

@@ -330,7 +330,9 @@ static void window_shortcut_scrollmouseover(rct_window* w, int32_t scrollIndex,
*/
static void window_shortcut_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);
auto dpiCoords = ScreenCoordsXY{ dpi->x, dpi->y };
gfx_fill_rect(
dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi->width - 1, dpi->height - 1 } }, ColourMapA[w->colours[1]].mid_light);
// TODO: the line below is a workaround for what is presumably a bug with dpi->width
// see https://github.com/OpenRCT2/OpenRCT2/issues/11238 for details
@@ -353,8 +355,8 @@ static void window_shortcut_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, i
if (ShortcutList[i].ShortcutId == SHORTCUT_UNDEFINED)
{
const int32_t top = y + (SCROLLABLE_ROW_HEIGHT / 2) - 1;
gfx_fill_rect(dpi, 0, top, scrollWidth, top, ColourMapA[w->colours[0]].mid_dark);
gfx_fill_rect(dpi, 0, top + 1, scrollWidth, top + 1, ColourMapA[w->colours[0]].lightest);
gfx_fill_rect(dpi, { { 0, top }, { scrollWidth, top } }, ColourMapA[w->colours[0]].mid_dark);
gfx_fill_rect(dpi, { { 0, top + 1 }, { scrollWidth, top + 1 } }, ColourMapA[w->colours[0]].lightest);
continue;
}

View File

@@ -674,7 +674,9 @@ static constexpr const uint32_t staffCostumeSprites[] = {
*/
void window_staff_list_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);
auto dpiCoords = ScreenCoordsXY{ dpi->x, dpi->y };
gfx_fill_rect(
dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi->width - 1, dpi->height - 1 } }, ColourMapA[w->colours[1]].mid_light);
// How much space do we have for the name and action columns? (Discount scroll area and icons.)
const int32_t nonIconSpace = w->widgets[WIDX_STAFF_LIST_LIST].width() - 15 - 68;

View File

@@ -315,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, screenCoords.y + 9, cursorX + width, screenCoords.y + 9, colour + 5);
gfx_fill_rect(dpi, { { cursorX, screenCoords.y + 9 }, { cursorX + width, screenCoords.y + 9 } }, colour + 5);
}
cur_drawn++;
@@ -431,7 +431,8 @@ static void draw_ime_composition(rct_drawpixelinfo* dpi, int cursorX, int cursor
int height = 10;
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);
dpi, { screenCoords - ScreenCoordsXY{ 1, 1 }, screenCoords + ScreenCoordsXY{ width + 1, height + 1 } },
PALETTE_INDEX_12);
gfx_fill_rect(dpi, { screenCoords, screenCoords + ScreenCoordsXY{ width, height } }, PALETTE_INDEX_0);
gfx_draw_string(dpi, static_cast<const char*>(gTextInput->ImeBuffer), COLOUR_DARK_GREEN, screenCoords);
}

View File

@@ -894,12 +894,16 @@ void window_themes_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t sc
{
colour = ColourMapA[w->colours[1]].mid_dark;
gfx_fill_rect(
dpi, 0, screenCoords.y + _row_height - 2, window_themes_widgets[WIDX_THEMES_LIST].right,
screenCoords.y + _row_height - 2, colour);
dpi,
{ { 0, screenCoords.y + _row_height - 2 },
{ window_themes_widgets[WIDX_THEMES_LIST].right, screenCoords.y + _row_height - 2 } },
colour);
colour = ColourMapA[w->colours[1]].lightest;
gfx_fill_rect(
dpi, 0, screenCoords.y + _row_height - 1, window_themes_widgets[WIDX_THEMES_LIST].right,
screenCoords.y + _row_height - 1, colour);
dpi,
{ { 0, screenCoords.y + _row_height - 1 },
{ window_themes_widgets[WIDX_THEMES_LIST].right, screenCoords.y + _row_height - 1 } },
colour);
}
}

View File

@@ -519,7 +519,7 @@ static void window_track_list_paint(rct_window* w, rct_drawpixelinfo* dpi)
rct_widget* widget = &window_track_list_widgets[WIDX_TRACK_PREVIEW];
auto screenPos = w->windowPos + ScreenCoordsXY{ widget->left + 1, widget->top + 1 };
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);
if (_loadedTrackDesignIndex != trackIndex)
{

View File

@@ -605,7 +605,6 @@ void gfx_draw_dashed_line(
rct_drawpixelinfo* dpi, const ScreenLine& screenLine, const int32_t dashedLineSegmentLength, const int32_t color);
// rect
void gfx_fill_rect(rct_drawpixelinfo* dpi, int32_t left, int32_t top, int32_t right, int32_t bottom, int32_t colour);
void gfx_fill_rect(rct_drawpixelinfo* dpi, const ScreenRect& rect, int32_t colour);
void gfx_fill_rect_inset(
rct_drawpixelinfo* dpi, int16_t left, int16_t top, int16_t right, int16_t bottom, int32_t colour, uint8_t flags);

View File

@@ -181,11 +181,6 @@ void gfx_clear(rct_drawpixelinfo* dpi, uint8_t paletteIndex)
}
}
void gfx_fill_rect(rct_drawpixelinfo* dpi, int32_t left, int32_t top, int32_t right, int32_t bottom, int32_t colour)
{
gfx_fill_rect(dpi, { { left, top }, { right, bottom } }, colour);
}
void gfx_fill_rect(rct_drawpixelinfo* dpi, const ScreenRect& rect, int32_t colour)
{
auto drawingEngine = dpi->DrawingEngine;