1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

Use dpi ref in rect and line drawing functions

This commit is contained in:
Gymnasiast
2023-04-03 23:16:34 +02:00
committed by duncanspumpkin
parent 2941f6f7a5
commit bb83a80eab
47 changed files with 276 additions and 278 deletions

View File

@@ -134,7 +134,7 @@ static void WidgetFrameDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widge
uint8_t colour = w.colours[widget.colour];
// Draw the frame
GfxFillRectInset(&dpi, { leftTop, { r, b } }, colour, press);
GfxFillRectInset(dpi, { leftTop, { r, b } }, colour, press);
// Check if the window can be resized
if (!(w.flags & WF_RESIZABLE))
@@ -165,7 +165,7 @@ static void WidgetResizeDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widg
uint8_t colour = w.colours[widget.colour];
// Draw the panel
GfxFillRectInset(&dpi, { leftTop, { r, b } }, colour, 0);
GfxFillRectInset(dpi, { leftTop, { r, b } }, colour, 0);
// Check if the window can be resized
if (!(w.flags & WF_RESIZABLE))
@@ -200,12 +200,12 @@ static void WidgetButtonDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widg
if (static_cast<int32_t>(widget.image.ToUInt32()) == -2)
{
// Draw border with no fill
GfxFillRectInset(&dpi, rect, colour, press | INSET_RECT_FLAG_FILL_NONE);
GfxFillRectInset(dpi, rect, colour, press | INSET_RECT_FLAG_FILL_NONE);
return;
}
// Draw the border with fill
GfxFillRectInset(&dpi, rect, colour, press);
GfxFillRectInset(dpi, rect, colour, press);
WidgetDrawImage(dpi, w, widgetIndex);
}
@@ -287,12 +287,12 @@ static void WidgetFlatButtonDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex
if (static_cast<int32_t>(widget.image.ToUInt32()) == -2)
{
// Draw border with no fill
GfxFillRectInset(&dpi, rect, colour, INSET_RECT_FLAG_BORDER_INSET | INSET_RECT_FLAG_FILL_NONE);
GfxFillRectInset(dpi, rect, colour, INSET_RECT_FLAG_BORDER_INSET | INSET_RECT_FLAG_FILL_NONE);
return;
}
// Draw the border with fill
GfxFillRectInset(&dpi, rect, colour, INSET_RECT_FLAG_BORDER_INSET);
GfxFillRectInset(dpi, rect, colour, INSET_RECT_FLAG_BORDER_INSET);
}
// Draw image
@@ -317,7 +317,7 @@ static void WidgetTextButton(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widg
// Border
uint8_t press = WidgetIsPressed(w, widgetIndex) || WidgetIsActiveTool(w, widgetIndex) ? INSET_RECT_FLAG_BORDER_INSET : 0;
GfxFillRectInset(&dpi, rect, colour, press);
GfxFillRectInset(dpi, rect, colour, press);
// Button caption
if (widget.type != WindowWidgetType::TableHeader)
@@ -441,7 +441,7 @@ static void WidgetTextInset(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widge
// Get the colour
uint8_t colour = w.colours[widget.colour];
GfxFillRectInset(&dpi, rect, colour, INSET_RECT_F_60);
GfxFillRectInset(dpi, rect, colour, INSET_RECT_F_60);
WidgetText(dpi, w, widgetIndex);
}
@@ -506,24 +506,24 @@ static void WidgetGroupboxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex wi
uint8_t colour = w.colours[widget.colour] & 0x7F;
// Border left of text
GfxFillRect(&dpi, { { l, t }, { l + 4, t } }, ColourMapA[colour].mid_dark);
GfxFillRect(&dpi, { { l + 1, t + 1 }, { l + 4, t + 1 } }, ColourMapA[colour].lighter);
GfxFillRect(dpi, { { l, t }, { l + 4, t } }, ColourMapA[colour].mid_dark);
GfxFillRect(dpi, { { l + 1, t + 1 }, { l + 4, t + 1 } }, ColourMapA[colour].lighter);
// Border right of text
GfxFillRect(&dpi, { { textRight, t }, { r - 1, t } }, ColourMapA[colour].mid_dark);
GfxFillRect(&dpi, { { textRight, t + 1 }, { r - 2, t + 1 } }, ColourMapA[colour].lighter);
GfxFillRect(dpi, { { textRight, t }, { r - 1, t } }, ColourMapA[colour].mid_dark);
GfxFillRect(dpi, { { textRight, t + 1 }, { r - 2, t + 1 } }, ColourMapA[colour].lighter);
// Border right
GfxFillRect(&dpi, { { r - 1, t + 1 }, { r - 1, b - 1 } }, ColourMapA[colour].mid_dark);
GfxFillRect(&dpi, { { r, t }, { r, b } }, ColourMapA[colour].lighter);
GfxFillRect(dpi, { { r - 1, t + 1 }, { r - 1, b - 1 } }, ColourMapA[colour].mid_dark);
GfxFillRect(dpi, { { r, t }, { r, b } }, ColourMapA[colour].lighter);
// Border bottom
GfxFillRect(&dpi, { { l, b - 1 }, { r - 2, b - 1 } }, ColourMapA[colour].mid_dark);
GfxFillRect(&dpi, { { l, b }, { r - 1, b } }, ColourMapA[colour].lighter);
GfxFillRect(dpi, { { l, b - 1 }, { r - 2, b - 1 } }, ColourMapA[colour].mid_dark);
GfxFillRect(dpi, { { l, b }, { r - 1, b } }, ColourMapA[colour].lighter);
// Border left
GfxFillRect(&dpi, { { l, t + 1 }, { l, b - 2 } }, ColourMapA[colour].mid_dark);
GfxFillRect(&dpi, { { l + 1, t + 2 }, { l + 1, b - 2 } }, ColourMapA[colour].lighter);
GfxFillRect(dpi, { { l, t + 1 }, { l, b - 2 } }, ColourMapA[colour].mid_dark);
GfxFillRect(dpi, { { l + 1, t + 2 }, { l + 1, b - 2 } }, ColourMapA[colour].lighter);
}
/**
@@ -546,15 +546,15 @@ static void WidgetCaptionDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex wid
if (w.flags & WF_10)
press |= INSET_RECT_FLAG_FILL_MID_LIGHT;
GfxFillRectInset(&dpi, { topLeft, bottomRight }, colour, press);
GfxFillRectInset(dpi, { topLeft, bottomRight }, colour, press);
// Black caption bars look slightly green, this fixes that
if (colour == 0)
GfxFillRect(
&dpi, { { topLeft + ScreenCoordsXY{ 1, 1 } }, { bottomRight - ScreenCoordsXY{ 1, 1 } } }, ColourMapA[colour].dark);
dpi, { { topLeft + ScreenCoordsXY{ 1, 1 } }, { bottomRight - ScreenCoordsXY{ 1, 1 } } }, ColourMapA[colour].dark);
else
GfxFilterRect(
&dpi, { { topLeft + ScreenCoordsXY{ 1, 1 } }, { bottomRight - ScreenCoordsXY{ 1, 1 } } },
dpi, { { topLeft + ScreenCoordsXY{ 1, 1 } }, { bottomRight - ScreenCoordsXY{ 1, 1 } } },
FilterPaletteID::PaletteDarken3);
// Draw text
@@ -599,7 +599,7 @@ static void WidgetCloseboxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex wi
uint8_t colour = w.colours[widget.colour];
// Draw the button
GfxFillRectInset(&dpi, { topLeft, bottomRight }, colour, press);
GfxFillRectInset(dpi, { topLeft, bottomRight }, colour, press);
if (widget.text == STR_NONE)
return;
@@ -630,7 +630,7 @@ static void WidgetCheckboxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex wi
colour_t colour = w.colours[widget.colour];
// checkbox
GfxFillRectInset(&dpi, { midLeft - ScreenCoordsXY{ 0, 5 }, midLeft + ScreenCoordsXY{ 9, 4 } }, colour, INSET_RECT_F_60);
GfxFillRectInset(dpi, { midLeft - ScreenCoordsXY{ 0, 5 }, midLeft + ScreenCoordsXY{ 9, 4 } }, colour, INSET_RECT_F_60);
if (WidgetIsDisabled(w, widgetIndex))
{
@@ -672,7 +672,7 @@ static void WidgetScrollDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widg
uint8_t colour = w.colours[widget.colour];
// Draw the border
GfxFillRectInset(&dpi, { topLeft, bottomRight }, colour, INSET_RECT_F_60);
GfxFillRectInset(dpi, { topLeft, bottomRight }, colour, INSET_RECT_F_60);
// Inflate by -1
topLeft.x++;
@@ -730,18 +730,18 @@ static void WidgetHScrollbarDraw(
{
colour &= 0x7F;
// Trough
GfxFillRect(&dpi, { { l + SCROLLBAR_WIDTH, t }, { r - SCROLLBAR_WIDTH, b } }, ColourMapA[colour].lighter);
GfxFillRect(&dpi, { { l + SCROLLBAR_WIDTH, t }, { r - SCROLLBAR_WIDTH, b } }, 0x1000000 | ColourMapA[colour].mid_dark);
GfxFillRect(&dpi, { { l + SCROLLBAR_WIDTH, t + 2 }, { r - SCROLLBAR_WIDTH, t + 2 } }, ColourMapA[colour].mid_dark);
GfxFillRect(&dpi, { { l + SCROLLBAR_WIDTH, t + 3 }, { r - SCROLLBAR_WIDTH, t + 3 } }, ColourMapA[colour].lighter);
GfxFillRect(&dpi, { { l + SCROLLBAR_WIDTH, t + 7 }, { r - SCROLLBAR_WIDTH, t + 7 } }, ColourMapA[colour].mid_dark);
GfxFillRect(&dpi, { { l + SCROLLBAR_WIDTH, t + 8 }, { r - SCROLLBAR_WIDTH, t + 8 } }, ColourMapA[colour].lighter);
GfxFillRect(dpi, { { l + SCROLLBAR_WIDTH, t }, { r - SCROLLBAR_WIDTH, b } }, ColourMapA[colour].lighter);
GfxFillRect(dpi, { { l + SCROLLBAR_WIDTH, t }, { r - SCROLLBAR_WIDTH, b } }, 0x1000000 | ColourMapA[colour].mid_dark);
GfxFillRect(dpi, { { l + SCROLLBAR_WIDTH, t + 2 }, { r - SCROLLBAR_WIDTH, t + 2 } }, ColourMapA[colour].mid_dark);
GfxFillRect(dpi, { { l + SCROLLBAR_WIDTH, t + 3 }, { r - SCROLLBAR_WIDTH, t + 3 } }, ColourMapA[colour].lighter);
GfxFillRect(dpi, { { l + SCROLLBAR_WIDTH, t + 7 }, { r - SCROLLBAR_WIDTH, t + 7 } }, ColourMapA[colour].mid_dark);
GfxFillRect(dpi, { { l + SCROLLBAR_WIDTH, t + 8 }, { r - SCROLLBAR_WIDTH, t + 8 } }, ColourMapA[colour].lighter);
// Left button
{
uint8_t flags = (scroll.flags & HSCROLLBAR_LEFT_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0;
GfxFillRectInset(&dpi, { { l, t }, { l + (SCROLLBAR_WIDTH - 1), b } }, colour, flags);
GfxFillRectInset(dpi, { { l, t }, { l + (SCROLLBAR_WIDTH - 1), b } }, colour, flags);
GfxDrawString(dpi, { l + 1, t }, static_cast<const char*>(BlackLeftArrowString), {});
}
@@ -751,14 +751,14 @@ static void WidgetHScrollbarDraw(
int16_t right = std::min(r - SCROLLBAR_WIDTH, l + scroll.h_thumb_right - 1);
uint8_t flags = (scroll.flags & HSCROLLBAR_THUMB_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0;
GfxFillRectInset(&dpi, { { left, t }, { right, b } }, colour, flags);
GfxFillRectInset(dpi, { { left, t }, { right, b } }, colour, flags);
}
// Right button
{
uint8_t flags = (scroll.flags & HSCROLLBAR_RIGHT_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0;
GfxFillRectInset(&dpi, { { r - (SCROLLBAR_WIDTH - 1), t }, { r, b } }, colour, flags);
GfxFillRectInset(dpi, { { r - (SCROLLBAR_WIDTH - 1), t }, { r, b } }, colour, flags);
GfxDrawString(dpi, { r - 6, t }, static_cast<const char*>(BlackRightArrowString), {});
}
}
@@ -768,29 +768,29 @@ static void WidgetVScrollbarDraw(
{
colour &= 0x7F;
// Trough
GfxFillRect(&dpi, { { l, t + SCROLLBAR_WIDTH }, { r, b - SCROLLBAR_WIDTH } }, ColourMapA[colour].lighter);
GfxFillRect(&dpi, { { l, t + SCROLLBAR_WIDTH }, { r, b - SCROLLBAR_WIDTH } }, 0x1000000 | ColourMapA[colour].mid_dark);
GfxFillRect(&dpi, { { l + 2, t + SCROLLBAR_WIDTH }, { l + 2, b - SCROLLBAR_WIDTH } }, ColourMapA[colour].mid_dark);
GfxFillRect(&dpi, { { l + 3, t + SCROLLBAR_WIDTH }, { l + 3, b - SCROLLBAR_WIDTH } }, ColourMapA[colour].lighter);
GfxFillRect(&dpi, { { l + 7, t + SCROLLBAR_WIDTH }, { l + 7, b - SCROLLBAR_WIDTH } }, ColourMapA[colour].mid_dark);
GfxFillRect(&dpi, { { l + 8, t + SCROLLBAR_WIDTH }, { l + 8, b - SCROLLBAR_WIDTH } }, ColourMapA[colour].lighter);
GfxFillRect(dpi, { { l, t + SCROLLBAR_WIDTH }, { r, b - SCROLLBAR_WIDTH } }, ColourMapA[colour].lighter);
GfxFillRect(dpi, { { l, t + SCROLLBAR_WIDTH }, { r, b - SCROLLBAR_WIDTH } }, 0x1000000 | ColourMapA[colour].mid_dark);
GfxFillRect(dpi, { { l + 2, t + SCROLLBAR_WIDTH }, { l + 2, b - SCROLLBAR_WIDTH } }, ColourMapA[colour].mid_dark);
GfxFillRect(dpi, { { l + 3, t + SCROLLBAR_WIDTH }, { l + 3, b - SCROLLBAR_WIDTH } }, ColourMapA[colour].lighter);
GfxFillRect(dpi, { { l + 7, t + SCROLLBAR_WIDTH }, { l + 7, b - SCROLLBAR_WIDTH } }, ColourMapA[colour].mid_dark);
GfxFillRect(dpi, { { l + 8, t + SCROLLBAR_WIDTH }, { l + 8, b - SCROLLBAR_WIDTH } }, ColourMapA[colour].lighter);
// Up button
GfxFillRectInset(
&dpi, { { l, t }, { r, t + (SCROLLBAR_WIDTH - 1) } }, colour,
dpi, { { l, t }, { r, t + (SCROLLBAR_WIDTH - 1) } }, colour,
((scroll.flags & VSCROLLBAR_UP_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0));
GfxDrawString(dpi, { l + 1, t - 1 }, static_cast<const char*>(BlackUpArrowString), {});
// Thumb
GfxFillRectInset(
&dpi,
dpi,
{ { l, std::max(t + SCROLLBAR_WIDTH, t + scroll.v_thumb_top - 1) },
{ r, std::min(b - SCROLLBAR_WIDTH, t + scroll.v_thumb_bottom - 1) } },
colour, ((scroll.flags & VSCROLLBAR_THUMB_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0));
// Down button
GfxFillRectInset(
&dpi, { { l, b - (SCROLLBAR_WIDTH - 1) }, { r, b } }, colour,
dpi, { { l, b - (SCROLLBAR_WIDTH - 1) }, { r, b } }, colour,
((scroll.flags & VSCROLLBAR_DOWN_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0));
GfxDrawString(dpi, { l + 1, b - (SCROLLBAR_WIDTH - 1) }, static_cast<const char*>(BlackDownArrowString), {});
}
@@ -1136,8 +1136,8 @@ static void WidgetTextBoxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex wid
bool active = w.classification == gCurrentTextBox.window.classification && w.number == gCurrentTextBox.window.number
&& widgetIndex == gCurrentTextBox.widget_index;
// GfxFillRectInset(&dpi, l, t, r, b, colour, 0x20 | (!active ? 0x40 : 0x00));
GfxFillRectInset(&dpi, { topLeft, bottomRight }, colour, INSET_RECT_F_60);
// GfxFillRectInset(dpi, l, t, r, b, colour, 0x20 | (!active ? 0x40 : 0x00));
GfxFillRectInset(dpi, { topLeft, bottomRight }, colour, INSET_RECT_F_60);
// Figure out where the text should be positioned vertically.
topLeft.y = w.windowPos.y + widget.textTop();
@@ -1180,7 +1180,7 @@ static void WidgetTextBoxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex wid
{
colour = ColourMapA[w.colours[1]].mid_light;
auto y = topLeft.y + (widget.height() - 1);
GfxFillRect(&dpi, { { curX, y }, { curX + width, y } }, colour + 5);
GfxFillRect(dpi, { { curX, y }, { curX + width, y } }, colour + 5);
}
}