1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-04 13:42:55 +01:00

Part of #12096: ScreenRect for gfx_fill_rect in libopenrct2 (#12109)

This commit is contained in:
frutiemax
2020-07-08 13:07:26 -04:00
committed by GitHub
parent 280a21fa30
commit bf2b8073cb
7 changed files with 28 additions and 19 deletions

View File

@@ -179,8 +179,10 @@ void intro_draw(rct_drawpixelinfo* dpi)
// Draw a white rectangle for the logo background (gives a bit of white margin)
gfx_fill_rect(
dpi, (screenWidth / 2) - 320 + 50, _introStateCounter + 50, (screenWidth / 2) - 320 + 50 + 540,
_introStateCounter + 50 + 425, BORDER_COLOUR_PUBLISHER);
dpi,
{ { (screenWidth / 2) - 320 + 50, _introStateCounter + 50 },
{ (screenWidth / 2) - 320 + 50 + 540, _introStateCounter + 50 + 425 } },
BORDER_COLOUR_PUBLISHER);
// Draw Infogrames logo
gfx_draw_sprite(dpi, SPR_INTRO_INFOGRAMES_00, { (screenWidth / 2) - 320 + 69, _introStateCounter + 69 }, 0);

View File

@@ -580,7 +580,7 @@ void mask_init()
void gfx_draw_pixel(rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t colour)
{
gfx_fill_rect(dpi, coords.x, coords.y, coords.x, coords.y, colour);
gfx_fill_rect(dpi, { coords, coords }, colour);
}
void gfx_filter_pixel(rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, FILTER_PALETTE_ID palette)

View File

@@ -16,7 +16,6 @@
#include <optional>
#include <vector>
struct ScreenCoordsXY;
struct ScreenCoordsXY;
struct ScreenLine;
@@ -607,6 +606,7 @@ void gfx_draw_dashed_line(
// 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);
void gfx_filter_rect(

View File

@@ -182,12 +182,17 @@ 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;
if (drawingEngine != nullptr)
{
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
dc->FillRect(colour, left, top, right, bottom);
dc->FillRect(colour, rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetBottom());
}
}

View File

@@ -9,6 +9,7 @@
#include "../common.h"
#include "../interface/Colour.h"
#include "../world/Location.hpp"
#include "Drawing.h"
/**
@@ -90,15 +91,15 @@ void gfx_fill_rect_inset(
if (flags & INSET_RECT_FLAG_BORDER_NONE)
{
gfx_fill_rect(dpi, left, top, right, bottom, fill);
gfx_fill_rect(dpi, { { left, top }, { right, bottom } }, fill);
}
else if (flags & INSET_RECT_FLAG_BORDER_INSET)
{
// Draw outline of box
gfx_fill_rect(dpi, left, top, left, bottom, shadow);
gfx_fill_rect(dpi, left + 1, top, right, top, shadow);
gfx_fill_rect(dpi, right, top + 1, right, bottom - 1, hilight);
gfx_fill_rect(dpi, left + 1, bottom, right, bottom, hilight);
gfx_fill_rect(dpi, { { left, top }, { left, bottom } }, shadow);
gfx_fill_rect(dpi, { { left + 1, top }, { right, top } }, shadow);
gfx_fill_rect(dpi, { { right, top + 1 }, { right, bottom - 1 } }, hilight);
gfx_fill_rect(dpi, { { left + 1, bottom }, { right, bottom } }, hilight);
if (!(flags & INSET_RECT_FLAG_FILL_NONE))
{
@@ -113,16 +114,16 @@ void gfx_fill_rect_inset(
fill = ColourMapA[colour].lighter;
}
}
gfx_fill_rect(dpi, left + 1, top + 1, right - 1, bottom - 1, fill);
gfx_fill_rect(dpi, { { left + 1, top + 1 }, { right - 1, bottom - 1 } }, fill);
}
}
else
{
// Draw outline of box
gfx_fill_rect(dpi, left, top, left, bottom - 1, hilight);
gfx_fill_rect(dpi, left + 1, top, right - 1, top, hilight);
gfx_fill_rect(dpi, right, top, right, bottom - 1, shadow);
gfx_fill_rect(dpi, left, bottom, right, bottom, shadow);
gfx_fill_rect(dpi, { { left, top }, { left, bottom - 1 } }, hilight);
gfx_fill_rect(dpi, { { left + 1, top }, { right - 1, top } }, hilight);
gfx_fill_rect(dpi, { { right, top }, { right, bottom - 1 } }, shadow);
gfx_fill_rect(dpi, { { left, bottom }, { right, bottom } }, shadow);
if (!(flags & INSET_RECT_FLAG_FILL_NONE))
{
@@ -130,7 +131,7 @@ void gfx_fill_rect_inset(
{
fill = ColourMapA[COLOUR_BLACK].light;
}
gfx_fill_rect(dpi, left + 1, top + 1, right - 1, bottom - 1, fill);
gfx_fill_rect(dpi, { { left + 1, top + 1 }, { right - 1, bottom - 1 } }, fill);
}
}
}

View File

@@ -98,11 +98,12 @@ static void DrawText(rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, TextP
if (paint->UnderlineText)
{
gfx_fill_rect(
dpi, alignedCoords.x, alignedCoords.y + 11, alignedCoords.x + width, alignedCoords.y + 11, text_palette[1]);
dpi, { { alignedCoords + ScreenCoordsXY{ 0, 11 } }, { alignedCoords + ScreenCoordsXY{ width, 11 } } },
text_palette[1]);
if (text_palette[2] != 0)
{
gfx_fill_rect(
dpi, alignedCoords.x + 1, alignedCoords.y + 12, alignedCoords.x + width + 1, alignedCoords.y + 12,
dpi, { { alignedCoords + ScreenCoordsXY{ 1, 12 } }, { alignedCoords + ScreenCoordsXY{ width + 1, 12 } } },
text_palette[2]);
}
}

View File

@@ -191,7 +191,7 @@ void chat_draw(rct_drawpixelinfo* dpi, uint8_t chatBackgroundColor)
int32_t caretX = screenCoords.x + gfx_get_string_width(lineBuffer);
int32_t caretY = screenCoords.y + 14;
gfx_fill_rect(dpi, caretX, caretY, caretX + 6, caretY + 1, PALETTE_INDEX_56);
gfx_fill_rect(dpi, { { caretX, caretY }, { caretX + 6, caretY + 1 } }, PALETTE_INDEX_56);
}
}
}