Use dpi ref in Widget.cpp

This commit is contained in:
Gymnasiast 2023-04-03 21:32:58 +02:00 committed by duncanspumpkin
parent 96d77ed8f7
commit 90d21dbe14
4 changed files with 116 additions and 116 deletions

View File

@ -22,32 +22,32 @@
#include <openrct2/sprites.h>
#include <openrct2/util/Util.h>
static void WidgetFrameDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetResizeDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetButtonDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetTabDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetFlatButtonDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetTextButton(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetTextCentred(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetText(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetTextInset(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetTextBoxDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetGroupboxDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetCaptionDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetCheckboxDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetCloseboxDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetScrollDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetFrameDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetResizeDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetButtonDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetTabDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetFlatButtonDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetTextButton(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetTextCentred(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetText(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetTextInset(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetTextBoxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetGroupboxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetCaptionDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetCheckboxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetCloseboxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetScrollDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
static void WidgetHScrollbarDraw(
DrawPixelInfo* dpi, const ScrollBar& scroll, int32_t l, int32_t t, int32_t r, int32_t b, int32_t colour);
DrawPixelInfo& dpi, const ScrollBar& scroll, int32_t l, int32_t t, int32_t r, int32_t b, int32_t colour);
static void WidgetVScrollbarDraw(
DrawPixelInfo* dpi, const ScrollBar& scroll, int32_t l, int32_t t, int32_t r, int32_t b, int32_t colour);
static void WidgetDrawImage(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex);
DrawPixelInfo& dpi, const ScrollBar& scroll, int32_t l, int32_t t, int32_t r, int32_t b, int32_t colour);
static void WidgetDrawImage(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
/**
*
* rct2: 0x006EB2A8
*/
void WidgetDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
void WidgetDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex)
{
const auto* widget = GetWidgetByIndex(w, widgetIndex);
if (widget == nullptr)
@ -117,7 +117,7 @@ void WidgetDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
*
* rct2: 0x006EB6CE
*/
static void WidgetFrameDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
static void WidgetFrameDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex)
{
// Get the widget
const auto& widget = w.widgets[widgetIndex];
@ -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))
@ -144,14 +144,14 @@ static void WidgetFrameDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widge
// Draw the resize sprite at the bottom right corner
leftTop = w.windowPos + ScreenCoordsXY{ widget.right - 18, widget.bottom - 18 };
GfxDrawSprite(*dpi, ImageId(SPR_RESIZE, colour & 0x7F), leftTop);
GfxDrawSprite(dpi, ImageId(SPR_RESIZE, colour & 0x7F), leftTop);
}
/**
*
* rct2: 0x006EB765
*/
static void WidgetResizeDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
static void WidgetResizeDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex)
{
// Get the widget
const auto& widget = w.widgets[widgetIndex];
@ -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))
@ -175,14 +175,14 @@ static void WidgetResizeDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widg
// Draw the resize sprite at the bottom right corner
leftTop = w.windowPos + ScreenCoordsXY{ widget.right - 18, widget.bottom - 18 };
GfxDrawSprite(*dpi, ImageId(SPR_RESIZE, colour & 0x7F), leftTop);
GfxDrawSprite(dpi, ImageId(SPR_RESIZE, colour & 0x7F), leftTop);
}
/**
*
* rct2: 0x006EB8E5
*/
static void WidgetButtonDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
static void WidgetButtonDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex)
{
// Get the widget
const auto& widget = w.widgets[widgetIndex];
@ -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);
}
@ -214,7 +214,7 @@ static void WidgetButtonDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widg
*
* rct2: 0x006EB806
*/
static void WidgetTabDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
static void WidgetTabDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex)
{
// Get the widget
auto& widget = w.widgets[widgetIndex];
@ -256,14 +256,14 @@ static void WidgetTabDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetI
auto image = widget.image.WithIndex(newIndex).WithPrimary(colour);
// Draw disabled image
GfxDrawSprite(*dpi, image, leftTop);
GfxDrawSprite(dpi, image, leftTop);
}
/**
*
* rct2: 0x006EB861
*/
static void WidgetFlatButtonDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
static void WidgetFlatButtonDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex)
{
if (!WidgetIsDisabled(w, widgetIndex) && WidgetIsHighlighted(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
@ -303,7 +303,7 @@ static void WidgetFlatButtonDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex
*
* rct2: 0x006EBBEB
*/
static void WidgetTextButton(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
static void WidgetTextButton(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex)
{
// Get the widget
const auto& widget = w.widgets[widgetIndex];
@ -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)
@ -334,7 +334,7 @@ static void WidgetTextButton(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widg
*
* rct2: 0x006EBC41
*/
static void WidgetTextCentred(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
static void WidgetTextCentred(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex)
{
// Get the widget
const auto& widget = w.widgets[widgetIndex];
@ -368,11 +368,11 @@ static void WidgetTextCentred(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex wid
ScreenCoordsXY coords = { (topLeft.x + r + 1) / 2 - 1, topLeft.y };
if (widget.type == WindowWidgetType::LabelCentred)
{
DrawTextWrapped(*dpi, coords, widget.width() - 2, stringId, ft, { colour, TextAlignment::CENTRE });
DrawTextWrapped(dpi, coords, widget.width() - 2, stringId, ft, { colour, TextAlignment::CENTRE });
}
else
{
DrawTextEllipsised(*dpi, coords, widget.width() - 2, stringId, ft, { colour, TextAlignment::CENTRE });
DrawTextEllipsised(dpi, coords, widget.width() - 2, stringId, ft, { colour, TextAlignment::CENTRE });
}
}
@ -380,7 +380,7 @@ static void WidgetTextCentred(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex wid
*
* rct2: 0x006EBD52
*/
static void WidgetText(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
static void WidgetText(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex)
{
// Get the widget
const auto& widget = w.widgets[widgetIndex];
@ -417,11 +417,11 @@ static void WidgetText(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetInde
ScreenCoordsXY coords = { l + 1, t };
if (widget.type == WindowWidgetType::LabelCentred)
{
DrawTextWrapped(*dpi, coords, r - l, stringId, ft, { colour, TextAlignment::CENTRE });
DrawTextWrapped(dpi, coords, r - l, stringId, ft, { colour, TextAlignment::CENTRE });
}
else
{
DrawTextEllipsised(*dpi, coords, r - l, stringId, ft, colour);
DrawTextEllipsised(dpi, coords, r - l, stringId, ft, colour);
}
}
@ -429,7 +429,7 @@ static void WidgetText(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetInde
*
* rct2: 0x006EBD1F
*/
static void WidgetTextInset(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
static void WidgetTextInset(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex)
{
// Get the widget
const auto& widget = w.widgets[widgetIndex];
@ -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);
}
@ -469,7 +469,7 @@ static std::pair<StringId, void*> WidgetGetStringidAndArgs(const Widget& widget)
*
* rct2: 0x006EB535
*/
static void WidgetGroupboxDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
static void WidgetGroupboxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex)
{
// Get the widget
const auto& widget = w.widgets[widgetIndex];
@ -491,7 +491,7 @@ static void WidgetGroupboxDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex wi
OpenRCT2::FormatStringLegacy(buffer, sizeof(buffer), stringId, formatArgs);
auto ft = Formatter();
ft.Add<utf8*>(buffer);
DrawTextBasic(*dpi, { l, t }, STR_STRING, ft, { colour });
DrawTextBasic(dpi, { l, t }, STR_STRING, ft, { colour });
textRight = l + GfxGetStringWidth(buffer, FontStyle::Medium) + 1;
}
@ -506,31 +506,31 @@ 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);
}
/**
*
* rct2: 0x006EB2F9
*/
static void WidgetCaptionDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
static void WidgetCaptionDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex)
{
// Get the widget
const auto* widget = &w.widgets[widgetIndex];
@ -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
@ -571,7 +571,7 @@ static void WidgetCaptionDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex wid
}
topLeft.x += width / 2;
DrawTextEllipsised(
*dpi, topLeft, width, widget->text, Formatter::Common(),
dpi, topLeft, width, widget->text, Formatter::Common(),
{ COLOUR_WHITE | static_cast<uint8_t>(COLOUR_FLAG_OUTLINE), TextAlignment::CENTRE });
}
@ -579,7 +579,7 @@ static void WidgetCaptionDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex wid
*
* rct2: 0x006EBB85
*/
static void WidgetCloseboxDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
static void WidgetCloseboxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex)
{
// Get the widget
const auto& widget = w.widgets[widgetIndex];
@ -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;
@ -609,14 +609,14 @@ static void WidgetCloseboxDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex wi
if (WidgetIsDisabled(w, widgetIndex))
colour |= COLOUR_FLAG_INSET;
DrawTextEllipsised(*dpi, topLeft, widget.width() - 2, widget.text, Formatter::Common(), { colour, TextAlignment::CENTRE });
DrawTextEllipsised(dpi, topLeft, widget.width() - 2, widget.text, Formatter::Common(), { colour, TextAlignment::CENTRE });
}
/**
*
* rct2: 0x006EBAD9
*/
static void WidgetCheckboxDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
static void WidgetCheckboxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex)
{
// Get the widget
const auto& widget = w.widgets[widgetIndex];
@ -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))
{
@ -641,7 +641,7 @@ static void WidgetCheckboxDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex wi
if (WidgetIsPressed(w, widgetIndex))
{
GfxDrawString(
*dpi, { midLeft - ScreenCoordsXY{ 0, 5 } }, static_cast<const char*>(CheckBoxMarkString),
dpi, { midLeft - ScreenCoordsXY{ 0, 5 } }, static_cast<const char*>(CheckBoxMarkString),
{ static_cast<colour_t>(NOT_TRANSLUCENT(colour)) });
}
@ -650,14 +650,14 @@ static void WidgetCheckboxDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex wi
return;
auto [stringId, formatArgs] = WidgetGetStringidAndArgs(widget);
GfxDrawStringLeftCentred(*dpi, stringId, formatArgs, colour, { midLeft + ScreenCoordsXY{ 14, 0 } });
GfxDrawStringLeftCentred(dpi, stringId, formatArgs, colour, { midLeft + ScreenCoordsXY{ 14, 0 } });
}
/**
*
* rct2: 0x006EBD96
*/
static void WidgetScrollDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
static void WidgetScrollDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex)
{
// Get the widget
int32_t scrollIndex = WindowGetScrollDataIndex(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++;
@ -703,22 +703,22 @@ static void WidgetScrollDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widg
bottomRight.x++;
// Create a new inner scroll dpi
DrawPixelInfo scroll_dpi = *dpi;
DrawPixelInfo scroll_dpi = dpi;
// Clip the scroll dpi against the outer dpi
int32_t cl = std::max<int32_t>(dpi->x, topLeft.x);
int32_t ct = std::max<int32_t>(dpi->y, topLeft.y);
int32_t cr = std::min<int32_t>(dpi->x + dpi->width, bottomRight.x);
int32_t cb = std::min<int32_t>(dpi->y + dpi->height, bottomRight.y);
int32_t cl = std::max<int32_t>(dpi.x, topLeft.x);
int32_t ct = std::max<int32_t>(dpi.y, topLeft.y);
int32_t cr = std::min<int32_t>(dpi.x + dpi.width, bottomRight.x);
int32_t cb = std::min<int32_t>(dpi.y + dpi.height, bottomRight.y);
// Set the respective dpi attributes
scroll_dpi.x = cl - topLeft.x + scroll.h_left;
scroll_dpi.y = ct - topLeft.y + scroll.v_top;
scroll_dpi.width = cr - cl;
scroll_dpi.height = cb - ct;
scroll_dpi.bits += cl - dpi->x;
scroll_dpi.bits += (ct - dpi->y) * (dpi->width + dpi->pitch);
scroll_dpi.pitch = (dpi->width + dpi->pitch) - scroll_dpi.width;
scroll_dpi.bits += cl - dpi.x;
scroll_dpi.bits += (ct - dpi.y) * (dpi.width + dpi.pitch);
scroll_dpi.pitch = (dpi.width + dpi.pitch) - scroll_dpi.width;
// Draw the scroll contents
if (scroll_dpi.width > 0 && scroll_dpi.height > 0)
@ -726,23 +726,23 @@ static void WidgetScrollDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widg
}
static void WidgetHScrollbarDraw(
DrawPixelInfo* dpi, const ScrollBar& scroll, int32_t l, int32_t t, int32_t r, int32_t b, int32_t colour)
DrawPixelInfo& dpi, const ScrollBar& scroll, int32_t l, int32_t t, int32_t r, int32_t b, int32_t colour)
{
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);
GfxDrawString(*dpi, { l + 1, t }, static_cast<const char*>(BlackLeftArrowString), {});
GfxFillRectInset(&dpi, { { l, t }, { l + (SCROLLBAR_WIDTH - 1), b } }, colour, flags);
GfxDrawString(dpi, { l + 1, t }, static_cast<const char*>(BlackLeftArrowString), {});
}
// Thumb
@ -751,55 +751,55 @@ 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);
GfxDrawString(*dpi, { r - 6, t }, static_cast<const char*>(BlackRightArrowString), {});
GfxFillRectInset(&dpi, { { r - (SCROLLBAR_WIDTH - 1), t }, { r, b } }, colour, flags);
GfxDrawString(dpi, { r - 6, t }, static_cast<const char*>(BlackRightArrowString), {});
}
}
static void WidgetVScrollbarDraw(
DrawPixelInfo* dpi, const ScrollBar& scroll, int32_t l, int32_t t, int32_t r, int32_t b, int32_t colour)
DrawPixelInfo& dpi, const ScrollBar& scroll, int32_t l, int32_t t, int32_t r, int32_t b, int32_t colour)
{
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), {});
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), {});
GfxDrawString(dpi, { l + 1, b - (SCROLLBAR_WIDTH - 1) }, static_cast<const char*>(BlackDownArrowString), {});
}
/**
*
* rct2: 0x006EB951
*/
static void WidgetDrawImage(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
static void WidgetDrawImage(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex)
{
// Get the widget
const auto& widget = w.widgets[widgetIndex];
@ -825,12 +825,12 @@ static void WidgetDrawImage(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widge
// Draw greyed out (light border bottom right shadow)
colour = w.colours[widget.colour];
colour = ColourMapA[NOT_TRANSLUCENT(colour)].lighter;
GfxDrawSpriteSolid(dpi, image, screenCoords + ScreenCoordsXY{ 1, 1 }, colour);
GfxDrawSpriteSolid(&dpi, image, screenCoords + ScreenCoordsXY{ 1, 1 }, colour);
// Draw greyed out (dark)
colour = w.colours[widget.colour];
colour = ColourMapA[NOT_TRANSLUCENT(colour)].mid_light;
GfxDrawSpriteSolid(dpi, image, screenCoords, colour);
GfxDrawSpriteSolid(&dpi, image, screenCoords, colour);
}
else
{
@ -844,7 +844,7 @@ static void WidgetDrawImage(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widge
else
image = image.WithPrimary(colour);
GfxDrawSprite(*dpi, image, screenCoords);
GfxDrawSprite(dpi, image, screenCoords);
}
}
@ -1121,7 +1121,7 @@ void WidgetSetCheckboxValue(WindowBase& w, WidgetIndex widgetIndex, bool value)
WidgetSetPressed(w, widgetIndex, value);
}
static void WidgetTextBoxDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex)
static void WidgetTextBoxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex)
{
// Get the widget
const auto& widget = w.widgets[widgetIndex];
@ -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();
@ -1148,7 +1148,7 @@ static void WidgetTextBoxDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex wid
{
u8string wrappedString;
GfxWrapString(widget.string, bottomRight.x - topLeft.x - 5, FontStyle::Medium, &wrappedString, nullptr);
DrawText(*dpi, { topLeft.x + 2, topLeft.y }, { w.colours[1] }, wrappedString.c_str(), true);
DrawText(dpi, { topLeft.x + 2, topLeft.y }, { w.colours[1] }, wrappedString.c_str(), true);
}
return;
}
@ -1158,7 +1158,7 @@ static void WidgetTextBoxDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex wid
u8string wrappedString;
GfxWrapString(gTextBoxInput, bottomRight.x - topLeft.x - 5 - 6, FontStyle::Medium, &wrappedString, nullptr);
DrawText(*dpi, { topLeft.x + 2, topLeft.y }, { w.colours[1] }, wrappedString.c_str(), true);
DrawText(dpi, { topLeft.x + 2, topLeft.y }, { w.colours[1] }, wrappedString.c_str(), true);
// Make a trimmed view of the string for measuring the width.
int32_t curX = topLeft.x
@ -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);
}
}

View File

@ -651,7 +651,7 @@ void WindowDrawWidgets(WindowBase& w, DrawPixelInfo& dpi)
if (w.windowPos.y + widget->top < dpi.y + dpi.height && w.windowPos.y + widget->bottom >= dpi.y)
{
if (w.IsLegacy())
WidgetDraw(&dpi, w, widgetIndex);
WidgetDraw(dpi, w, widgetIndex);
else
w.OnDrawWidget(widgetIndex, dpi);
}
@ -715,7 +715,7 @@ void Window::OnDraw(DrawPixelInfo& dpi)
void Window::OnDrawWidget(WidgetIndex widgetIndex, DrawPixelInfo& dpi)
{
WidgetDraw(&dpi, *this, widgetIndex);
WidgetDraw(dpi, *this, widgetIndex);
}
void Window::InitScrollWidgets()

View File

@ -253,8 +253,8 @@ public:
screenCoords = { windowPos.x + previewWidget->left, windowPos.y + previewWidget->top };
auto sprite = ImageId(gLandToolSize % 2 == 0 ? SPR_G2_MOUNTAIN_TOOL_EVEN : SPR_G2_MOUNTAIN_TOOL_ODD);
GfxDrawSprite(dpi, sprite, screenCoords);
WidgetDraw(&dpi, *this, WIDX_DECREMENT);
WidgetDraw(&dpi, *this, WIDX_INCREMENT);
WidgetDraw(dpi, *this, WIDX_DECREMENT);
WidgetDraw(dpi, *this, WIDX_INCREMENT);
}
screenCoords = { windowPos.x + previewWidget->midX(), windowPos.y + previewWidget->bottom + 5 };

View File

@ -163,7 +163,7 @@ constexpr Widget MakeDropdownButtonWidget(
}
void WidgetScrollUpdateThumbs(WindowBase& w, WidgetIndex widget_index);
void WidgetDraw(DrawPixelInfo* dpi, WindowBase& w, WidgetIndex widgetIndex);
void WidgetDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex widgetIndex);
bool WidgetIsDisabled(const WindowBase& w, WidgetIndex widgetIndex);
bool WidgetIsHoldable(const WindowBase& w, WidgetIndex widgetIndex);