Part of #12097: Use ScreenRect on gfx_fill_rect_inset (1) (#12938)

* Part of #12097: Use ScreenRect on gfx_fill_rect_inset (1)

Co-authored-by: Tulio Leao <tupaschoal@gmail.com>
This commit is contained in:
frutiemaxandTulio Leao authored and GitHub committed 2020-09-16 00:02:22 -03:00
1 parent 48f1335559
commit af591c834b
8 files changed
+62 -52

No files matched your search

+8 -8
View File
@@ -815,8 +815,7 @@ static void window_new_ride_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, i
gfx_clear(dpi, ColourMapA[w->colours[1]].mid_light);
int32_t x = 1;
int32_t y = 1;
ScreenCoordsXY coords{ 1, 1 };
RideSelection* listItem = _windowNewRideListItems;
while (listItem->Type != RIDE_TYPE_NULL || listItem->EntryIndex != RIDE_ENTRY_INDEX_NULL)
{
@@ -826,7 +825,8 @@ static void window_new_ride_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, i
if (w->new_ride.SelectedRide == *listItem)
flags |= INSET_RECT_FLAG_BORDER_INSET;
if (w->new_ride.HighlightedRide == *listItem || flags != 0)
gfx_fill_rect_inset(dpi, x, y, x + 115, y + 115, w->colours[1], INSET_RECT_FLAG_FILL_MID_LIGHT | flags);
gfx_fill_rect_inset(
dpi, { coords, coords + ScreenCoordsXY{ 115, 115 } }, w->colours[1], INSET_RECT_FLAG_FILL_MID_LIGHT | flags);
// Draw ride image with feathered border
rideEntry = get_ride_entry(listItem->EntryIndex);
@@ -840,14 +840,14 @@ static void window_new_ride_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, i
imageId++;
}
gfx_draw_sprite_raw_masked(dpi, { x + 2, y + 2 }, SPR_NEW_RIDE_MASK, imageId);
gfx_draw_sprite_raw_masked(dpi, coords + ScreenCoordsXY{ 2, 2 }, SPR_NEW_RIDE_MASK, imageId);
// Next position
x += 116;
if (x >= 116 * 5 + 1)
coords.x += 116;
if (coords.x >= 116 * 5 + 1)
{
x = 1;
y += 116;
coords.x = 1;
coords.y += 116;
}
// Next item
+3 -5
View File
@@ -256,7 +256,7 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32
// Background
gfx_fill_rect_inset(
dpi, -1, y, 383, y + itemHeight - 1, w->colours[1], (INSET_RECT_FLAG_BORDER_INSET | INSET_RECT_FLAG_FILL_GREY));
dpi, { -1, y, 383, y + itemHeight - 1 }, w->colours[1], (INSET_RECT_FLAG_BORDER_INSET | INSET_RECT_FLAG_FILL_GREY));
// Date text
auto ft = Formatter::Common();
@@ -280,8 +280,7 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32
if (i == w->news.var_480 && w->news.var_482 == 1)
press = INSET_RECT_FLAG_BORDER_INSET;
}
gfx_fill_rect_inset(
dpi, screenCoords.x, screenCoords.y, screenCoords.x + 23, screenCoords.y + 23, w->colours[2], press);
gfx_fill_rect_inset(dpi, { screenCoords, screenCoords + ScreenCoordsXY{ 23, 23 } }, w->colours[2], press);
switch (newsItem.Type)
{
@@ -356,8 +355,7 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32
if (i == w->news.var_480 && w->news.var_482 == 2)
press = 0x20;
}
gfx_fill_rect_inset(
dpi, screenCoords.x, screenCoords.y, screenCoords.x + 23, screenCoords.y + 23, w->colours[2], press);
gfx_fill_rect_inset(dpi, { screenCoords, screenCoords + ScreenCoordsXY{ 23, 23 } }, w->colours[2], press);
gfx_draw_sprite(dpi, SPR_LOCATE, screenCoords, 0);
}
+10 -6
View File
@@ -1055,8 +1055,10 @@ static void window_park_rating_paint(rct_window* w, rct_drawpixelinfo* dpi)
// Graph border
gfx_fill_rect_inset(
dpi, screenPos.x + widget->left + 4, screenPos.y + widget->top + 15, screenPos.x + widget->right - 4,
screenPos.y + widget->bottom - 4, w->colours[1], INSET_RECT_F_30);
dpi,
{ screenPos + ScreenCoordsXY{ widget->left + 4, widget->top + 15 },
screenPos + ScreenCoordsXY{ widget->right - 4, widget->bottom - 4 } },
w->colours[1], INSET_RECT_F_30);
// Y axis labels
screenPos = screenPos + ScreenCoordsXY{ widget->left + 27, widget->top + 23 };
@@ -1065,7 +1067,7 @@ static void window_park_rating_paint(rct_window* w, rct_drawpixelinfo* dpi)
uint32_t axisValue = i * 200;
gfx_draw_string_right(dpi, STR_GRAPH_AXIS_LABEL, &axisValue, COLOUR_BLACK, screenPos + ScreenCoordsXY{ 10, 0 });
gfx_fill_rect_inset(
dpi, screenPos.x + 15, screenPos.y + 5, screenPos.x + w->width - 32, screenPos.y + 5, w->colours[2],
dpi, { screenPos + ScreenCoordsXY{ 15, 5 }, screenPos + ScreenCoordsXY{ w->width - 32, 5 } }, w->colours[2],
INSET_RECT_FLAG_BORDER_INSET);
screenPos.y += 20;
}
@@ -1186,8 +1188,10 @@ static void window_park_guests_paint(rct_window* w, rct_drawpixelinfo* dpi)
// Graph border
gfx_fill_rect_inset(
dpi, screenPos.x + widget->left + 4, screenPos.y + widget->top + 15, screenPos.x + widget->right - 4,
screenPos.y + widget->bottom - 4, w->colours[1], INSET_RECT_F_30);
dpi,
{ screenPos + ScreenCoordsXY{ widget->left + 4, widget->top + 15 },
screenPos + ScreenCoordsXY{ widget->right - 4, widget->bottom - 4 } },
w->colours[1], INSET_RECT_F_30);
// Y axis labels
screenPos = screenPos + ScreenCoordsXY{ widget->left + 27, widget->top + 23 };
@@ -1196,7 +1200,7 @@ static void window_park_guests_paint(rct_window* w, rct_drawpixelinfo* dpi)
uint32_t axisValue = i * 1000;
gfx_draw_string_right(dpi, STR_GRAPH_AXIS_LABEL, &axisValue, COLOUR_BLACK, screenPos + ScreenCoordsXY{ 10, 0 });
gfx_fill_rect_inset(
dpi, screenPos.x + 15, screenPos.y + 5, screenPos.x + w->width - 32, screenPos.y + 5, w->colours[2],
dpi, { screenPos + ScreenCoordsXY{ 15, 5 }, screenPos + ScreenCoordsXY{ w->width - 32, 5 } }, w->colours[2],
INSET_RECT_FLAG_BORDER_INSET);
screenPos.y += 20;
}
+9 -8
View File
@@ -3805,9 +3805,10 @@ static void window_ride_operating_paint(rct_window* w, rct_drawpixelinfo* dpi)
// Horizontal rule between mode settings and depart settings
gfx_fill_rect_inset(
dpi, w->windowPos.x + window_ride_operating_widgets[WIDX_PAGE_BACKGROUND].left + 4, w->windowPos.y + 103,
w->windowPos.x + window_ride_operating_widgets[WIDX_PAGE_BACKGROUND].right - 5, w->windowPos.y + 104, w->colours[1],
INSET_RECT_FLAG_BORDER_INSET);
dpi,
{ w->windowPos + ScreenCoordsXY{ window_ride_operating_widgets[WIDX_PAGE_BACKGROUND].left + 4, 103 },
w->windowPos + ScreenCoordsXY{ window_ride_operating_widgets[WIDX_PAGE_BACKGROUND].right - 5, 104 } },
w->colours[1], INSET_RECT_FLAG_BORDER_INSET);
// Number of block sections
if (ride->mode == RIDE_MODE_CONTINUOUS_CIRCUIT_BLOCK_SECTIONED || ride->mode == RIDE_MODE_POWERED_LAUNCH_BLOCK_SECTIONED)
@@ -3857,7 +3858,8 @@ static void window_ride_locate_mechanic(rct_window* w)
static void window_ride_maintenance_draw_bar(
rct_window* w, rct_drawpixelinfo* dpi, int32_t x, int32_t y, int32_t value, int32_t colour)
{
gfx_fill_rect_inset(dpi, x, y, x + 149, y + 8, w->colours[1], INSET_RECT_F_30);
ScreenCoordsXY coords{ x, y };
gfx_fill_rect_inset(dpi, { coords, coords + ScreenCoordsXY{ 149, 8 } }, w->colours[1], INSET_RECT_F_30);
if (colour & BAR_BLINK)
{
colour &= ~BAR_BLINK;
@@ -3868,7 +3870,7 @@ static void window_ride_maintenance_draw_bar(
value = ((186 * ((value * 2) & 0xFF)) >> 8) & 0xFF;
if (value > 2)
{
gfx_fill_rect_inset(dpi, x + 2, y + 1, x + value + 1, y + 7, colour, 0);
gfx_fill_rect_inset(dpi, { coords + ScreenCoordsXY{ 2, 1 }, coords + ScreenCoordsXY{ value + 1, 7 } }, colour, 0);
}
}
@@ -5657,8 +5659,7 @@ static void window_ride_measurements_paint(rct_window* w, rct_drawpixelinfo* dpi
widgetCoords.x = w->windowPos.x + 4;
widgetCoords.y = w->windowPos.y + window_ride_measurements_widgets[WIDX_SELECT_NEARBY_SCENERY].bottom + 17;
gfx_fill_rect_inset(
dpi, widgetCoords.x, widgetCoords.y, w->windowPos.x + 312, widgetCoords.y + 1, w->colours[1],
INSET_RECT_FLAG_BORDER_INSET);
dpi, { widgetCoords, { w->windowPos.x + 312, widgetCoords.y + 1 } }, w->colours[1], INSET_RECT_FLAG_BORDER_INSET);
}
else
{
@@ -5708,7 +5709,7 @@ static void window_ride_measurements_paint(rct_window* w, rct_drawpixelinfo* dpi
// Horizontal rule
gfx_fill_rect_inset(
dpi, screenCoords.x, screenCoords.y - 6, screenCoords.x + 303, screenCoords.y - 5, w->colours[1],
dpi, { screenCoords - ScreenCoordsXY{ 0, 6 }, screenCoords + ScreenCoordsXY{ 303, -5 } }, w->colours[1],
INSET_RECT_FLAG_BORDER_INSET);
if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_NO_RAW_STATS))
+13 -12
View File
@@ -1205,7 +1205,7 @@ void window_scenery_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t s
uint8_t tabIndex = gWindowSceneryActiveTabIndex;
int16_t left = 0, top = 0;
ScreenCoordsXY topLeft{ 0, 0 };
for (int32_t sceneryTabItemIndex = 0; sceneryTabItemIndex < SCENERY_ENTRIES_PER_TAB + 1; ++sceneryTabItemIndex)
{
@@ -1220,8 +1220,8 @@ void window_scenery_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t s
if (w->scenery.SelectedScenery == currentSceneryGlobal)
{
gfx_fill_rect_inset(
dpi, left, top, left + SCENERY_BUTTON_WIDTH - 1, top + SCENERY_BUTTON_HEIGHT - 1, w->colours[1],
INSET_RECT_FLAG_FILL_MID_LIGHT);
dpi, { topLeft, topLeft + ScreenCoordsXY{ SCENERY_BUTTON_WIDTH - 1, SCENERY_BUTTON_HEIGHT - 1 } },
w->colours[1], INSET_RECT_FLAG_FILL_MID_LIGHT);
}
}
else
@@ -1229,20 +1229,21 @@ void window_scenery_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t s
if (tabSelectedScenery == currentSceneryGlobal)
{
gfx_fill_rect_inset(
dpi, left, top, left + SCENERY_BUTTON_WIDTH - 1, top + SCENERY_BUTTON_HEIGHT - 1, w->colours[1],
(INSET_RECT_FLAG_BORDER_INSET | INSET_RECT_FLAG_FILL_MID_LIGHT));
dpi, { topLeft, topLeft + ScreenCoordsXY{ SCENERY_BUTTON_WIDTH - 1, SCENERY_BUTTON_HEIGHT - 1 } },
w->colours[1], (INSET_RECT_FLAG_BORDER_INSET | INSET_RECT_FLAG_FILL_MID_LIGHT));
}
else if (w->scenery.SelectedScenery == currentSceneryGlobal)
{
gfx_fill_rect_inset(
dpi, left, top, left + SCENERY_BUTTON_WIDTH - 1, top + SCENERY_BUTTON_HEIGHT - 1, w->colours[1],
INSET_RECT_FLAG_FILL_MID_LIGHT);
dpi, { topLeft, topLeft + ScreenCoordsXY{ SCENERY_BUTTON_WIDTH - 1, SCENERY_BUTTON_HEIGHT - 1 } },
w->colours[1], INSET_RECT_FLAG_FILL_MID_LIGHT);
}
}
rct_scenery_entry* sceneryEntry;
rct_drawpixelinfo clipdpi;
if (clip_drawpixelinfo(&clipdpi, dpi, { left + 1, top + 1 }, SCENERY_BUTTON_WIDTH - 2, SCENERY_BUTTON_HEIGHT - 2))
if (clip_drawpixelinfo(
&clipdpi, dpi, topLeft + ScreenCoordsXY{ 1, 1 }, SCENERY_BUTTON_WIDTH - 2, SCENERY_BUTTON_HEIGHT - 2))
{
if (currentSceneryGlobal.SceneryType == SCENERY_TYPE_BANNER)
{
@@ -1352,11 +1353,11 @@ void window_scenery_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t s
}
}
left += SCENERY_BUTTON_WIDTH;
if (left >= 594)
topLeft.x += SCENERY_BUTTON_WIDTH;
if (topLeft.x >= 594)
{
top += SCENERY_BUTTON_HEIGHT;
left = 0;
topLeft.y += SCENERY_BUTTON_HEIGHT;
topLeft.x = 0;
}
}
}
+2 -1
View File
@@ -274,7 +274,8 @@ 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, screenCoords.y, w->windowPos.x + WW - 10, screenCoords.y + 10 * (no_lines + 1) + 3,
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);
screenCoords.y += 1;
+4 -6
View File
@@ -921,15 +921,13 @@ void window_themes_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t sc
}
gfx_draw_sprite(dpi, image, { _button_offset_x + 12 * j, screenCoords.y + _button_offset_y }, 0);
gfx_fill_rect_inset(
dpi, _button_offset_x + 12 * j, screenCoords.y + _check_offset_y, _button_offset_x + 12 * j + 9,
screenCoords.y + _check_offset_y + 10, w->colours[1], INSET_RECT_F_E0);
ScreenCoordsXY topLeft{ _button_offset_x + 12 * j, screenCoords.y + _check_offset_y };
ScreenCoordsXY bottomRight{ _button_offset_x + 12 * j + 9, screenCoords.y + _check_offset_y + 10 };
gfx_fill_rect_inset(dpi, { topLeft, bottomRight }, w->colours[1], INSET_RECT_F_E0);
if (colour & COLOUR_FLAG_TRANSLUCENT)
{
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_DARK;
gfx_draw_string(
dpi, static_cast<const char*>(CheckBoxMarkString), w->colours[1] & 0x7F,
{ _button_offset_x + 12 * j, screenCoords.y + _check_offset_y });
gfx_draw_string(dpi, static_cast<const char*>(CheckBoxMarkString), w->colours[1] & 0x7F, topLeft);
}
}
}
+13 -6
View File
@@ -131,16 +131,23 @@ void chat_draw(rct_drawpixelinfo* dpi, uint8_t chatBackgroundColor)
_chatHeight = 150;
}
gfx_set_dirty_blocks({ { _chatLeft, _chatTop - 5 }, { _chatRight, _chatBottom + 5 } }); // Background area + Textbox
ScreenCoordsXY topLeft{ _chatLeft, _chatTop };
ScreenCoordsXY bottomRight{ _chatRight, _chatBottom };
ScreenCoordsXY bottomLeft{ _chatLeft, _chatBottom };
gfx_set_dirty_blocks(
{ topLeft - ScreenCoordsXY{ 0, 5 }, bottomRight + ScreenCoordsXY{ 0, 5 } }); // Background area + Textbox
gfx_filter_rect(
dpi, { { _chatLeft, _chatTop - 5 }, { _chatRight, _chatBottom + 5 } }, PALETTE_51); // Opaque gray background
dpi, { topLeft - ScreenCoordsXY{ 0, 5 }, bottomRight + ScreenCoordsXY{ 0, 5 } },
PALETTE_51); // Opaque gray background
gfx_fill_rect_inset(
dpi, _chatLeft, _chatTop - 5, _chatRight, _chatBottom + 5, chatBackgroundColor, INSET_RECT_FLAG_FILL_NONE);
dpi, { topLeft - ScreenCoordsXY{ 0, 5 }, bottomRight + ScreenCoordsXY{ 0, 5 } }, chatBackgroundColor,
INSET_RECT_FLAG_FILL_NONE);
gfx_fill_rect_inset(
dpi, _chatLeft + 1, _chatTop - 4, _chatRight - 1, _chatBottom - inputLineHeight - 6, chatBackgroundColor,
INSET_RECT_FLAG_BORDER_INSET);
dpi, { topLeft + ScreenCoordsXY{ 1, -4 }, bottomRight - ScreenCoordsXY{ 1, inputLineHeight + 6 } },
chatBackgroundColor, INSET_RECT_FLAG_BORDER_INSET);
gfx_fill_rect_inset(
dpi, _chatLeft + 1, _chatBottom - inputLineHeight - 5, _chatRight - 1, _chatBottom + 4, chatBackgroundColor,
dpi, { bottomLeft + ScreenCoordsXY{ 1, -inputLineHeight - 5 }, bottomRight + ScreenCoordsXY{ -1, 4 } },
chatBackgroundColor,
INSET_RECT_FLAG_BORDER_INSET); // Textbox
}