mirror of https://github.com/OpenRCT2/OpenRCT2.git
Use dpi ref in everything outside the drawing folder
This commit is contained in:
parent
fc0e0d029a
commit
0139c8d19e
|
@ -549,21 +549,21 @@ void CustomListView::MouseUp(const ScreenCoordsXY& pos)
|
|||
}
|
||||
}
|
||||
|
||||
void CustomListView::Paint(WindowBase* w, DrawPixelInfo* dpi, const ScrollBar* scroll) const
|
||||
void CustomListView::Paint(WindowBase* w, DrawPixelInfo& dpi, const ScrollBar* scroll) const
|
||||
{
|
||||
auto paletteIndex = ColourMapA[w->colours[1]].mid_light;
|
||||
GfxFillRect(dpi, { { dpi->x, dpi->y }, { dpi->x + dpi->width, dpi->y + dpi->height } }, paletteIndex);
|
||||
GfxFillRect(&dpi, { { dpi.x, dpi.y }, { dpi.x + dpi.width, dpi.y + dpi.height } }, paletteIndex);
|
||||
|
||||
int32_t y = ShowColumnHeaders ? COLUMN_HEADER_HEIGHT : 0;
|
||||
for (size_t i = 0; i < Items.size(); i++)
|
||||
{
|
||||
if (y > dpi->y + dpi->height)
|
||||
if (y > dpi.y + dpi.height)
|
||||
{
|
||||
// Past the scroll view area
|
||||
break;
|
||||
}
|
||||
|
||||
if (y + LIST_ROW_HEIGHT >= dpi->y)
|
||||
if (y + LIST_ROW_HEIGHT >= dpi.y)
|
||||
{
|
||||
const auto& itemIndex = static_cast<int32_t>(SortedItems[i]);
|
||||
const auto& item = Items[itemIndex];
|
||||
|
@ -583,19 +583,19 @@ void CustomListView::Paint(WindowBase* w, DrawPixelInfo* dpi, const ScrollBar* s
|
|||
if (isSelected)
|
||||
{
|
||||
GfxFilterRect(
|
||||
dpi, { { dpi->x, y }, { dpi->x + dpi->width, y + (LIST_ROW_HEIGHT - 1) } },
|
||||
&dpi, { { dpi.x, y }, { dpi.x + dpi.width, y + (LIST_ROW_HEIGHT - 1) } },
|
||||
FilterPaletteID::PaletteDarken2);
|
||||
}
|
||||
else if (isHighlighted)
|
||||
{
|
||||
GfxFilterRect(
|
||||
dpi, { { dpi->x, y }, { dpi->x + dpi->width, y + (LIST_ROW_HEIGHT - 1) } },
|
||||
&dpi, { { dpi.x, y }, { dpi.x + dpi.width, y + (LIST_ROW_HEIGHT - 1) } },
|
||||
FilterPaletteID::PaletteDarken2);
|
||||
}
|
||||
else if (isStriped)
|
||||
{
|
||||
GfxFillRect(
|
||||
dpi, { { dpi->x, y }, { dpi->x + dpi->width, y + (LIST_ROW_HEIGHT - 1) } },
|
||||
&dpi, { { dpi.x, y }, { dpi.x + dpi.width, y + (LIST_ROW_HEIGHT - 1) } },
|
||||
ColourMapA[w->colours[1]].lighter | 0x1000000);
|
||||
}
|
||||
|
||||
|
@ -641,7 +641,7 @@ void CustomListView::Paint(WindowBase* w, DrawPixelInfo* dpi, const ScrollBar* s
|
|||
y = scroll->v_top;
|
||||
|
||||
auto bgColour = ColourMapA[w->colours[1]].mid_light;
|
||||
GfxFillRect(dpi, { { dpi->x, y }, { dpi->x + dpi->width, y + 12 } }, bgColour);
|
||||
GfxFillRect(&dpi, { { dpi.x, y }, { dpi.x + dpi.width, y + 12 } }, bgColour);
|
||||
|
||||
int32_t x = 0;
|
||||
for (int32_t j = 0; j < static_cast<int32_t>(Columns.size()); j++)
|
||||
|
@ -665,7 +665,7 @@ void CustomListView::Paint(WindowBase* w, DrawPixelInfo* dpi, const ScrollBar* s
|
|||
}
|
||||
|
||||
void CustomListView::PaintHeading(
|
||||
WindowBase* w, DrawPixelInfo* dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const std::string& text,
|
||||
WindowBase* w, DrawPixelInfo& dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const std::string& text,
|
||||
ColumnSortOrder sortOrder, bool isPressed) const
|
||||
{
|
||||
auto boxFlags = 0;
|
||||
|
@ -673,7 +673,7 @@ void CustomListView::PaintHeading(
|
|||
{
|
||||
boxFlags = INSET_RECT_FLAG_BORDER_INSET;
|
||||
}
|
||||
GfxFillRectInset(dpi, { pos, pos + ScreenCoordsXY{ size.width - 1, size.height - 1 } }, w->colours[1], boxFlags);
|
||||
GfxFillRectInset(&dpi, { pos, pos + ScreenCoordsXY{ size.width - 1, size.height - 1 } }, w->colours[1], boxFlags);
|
||||
if (!text.empty())
|
||||
{
|
||||
PaintCell(dpi, pos, size, text.c_str(), false);
|
||||
|
@ -683,18 +683,18 @@ void CustomListView::PaintHeading(
|
|||
{
|
||||
auto ft = Formatter();
|
||||
ft.Add<StringId>(STR_UP);
|
||||
DrawTextBasic(*dpi, pos + ScreenCoordsXY{ size.width - 1, 0 }, STR_BLACK_STRING, ft, { TextAlignment::RIGHT });
|
||||
DrawTextBasic(dpi, pos + ScreenCoordsXY{ size.width - 1, 0 }, STR_BLACK_STRING, ft, { TextAlignment::RIGHT });
|
||||
}
|
||||
else if (sortOrder == ColumnSortOrder::Descending)
|
||||
{
|
||||
auto ft = Formatter();
|
||||
ft.Add<StringId>(STR_DOWN);
|
||||
DrawTextBasic(*dpi, pos + ScreenCoordsXY{ size.width - 1, 0 }, STR_BLACK_STRING, ft, { TextAlignment::RIGHT });
|
||||
DrawTextBasic(dpi, pos + ScreenCoordsXY{ size.width - 1, 0 }, STR_BLACK_STRING, ft, { TextAlignment::RIGHT });
|
||||
}
|
||||
}
|
||||
|
||||
void CustomListView::PaintSeperator(
|
||||
DrawPixelInfo* dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const char* text) const
|
||||
DrawPixelInfo& dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const char* text) const
|
||||
{
|
||||
auto hasText = text != nullptr && text[0] != '\0';
|
||||
auto left = pos.x + 4;
|
||||
|
@ -712,7 +712,7 @@ void CustomListView::PaintSeperator(
|
|||
// Draw string
|
||||
Formatter ft;
|
||||
ft.Add<const char*>(text);
|
||||
DrawTextBasic(*dpi, { centreX, pos.y }, STR_STRING, ft, { baseColour, TextAlignment::CENTRE });
|
||||
DrawTextBasic(dpi, { centreX, pos.y }, STR_STRING, ft, { baseColour, TextAlignment::CENTRE });
|
||||
|
||||
// Get string dimensions
|
||||
FormatStringLegacy(gCommonStringFormatBuffer, sizeof(gCommonStringFormatBuffer), STR_STRING, ft.Data());
|
||||
|
@ -723,44 +723,44 @@ void CustomListView::PaintSeperator(
|
|||
// Draw light horizontal rule
|
||||
auto lightLineLeftTop1 = ScreenCoordsXY{ left, lineY0 };
|
||||
auto lightLineRightBottom1 = ScreenCoordsXY{ strLeft, lineY0 };
|
||||
GfxDrawLine(dpi, { lightLineLeftTop1, lightLineRightBottom1 }, lightColour);
|
||||
GfxDrawLine(&dpi, { lightLineLeftTop1, lightLineRightBottom1 }, lightColour);
|
||||
|
||||
auto lightLineLeftTop2 = ScreenCoordsXY{ strRight, lineY0 };
|
||||
auto lightLineRightBottom2 = ScreenCoordsXY{ right, lineY0 };
|
||||
GfxDrawLine(dpi, { lightLineLeftTop2, lightLineRightBottom2 }, lightColour);
|
||||
GfxDrawLine(&dpi, { lightLineLeftTop2, lightLineRightBottom2 }, lightColour);
|
||||
|
||||
// Draw dark horizontal rule
|
||||
auto darkLineLeftTop1 = ScreenCoordsXY{ left, lineY1 };
|
||||
auto darkLineRightBottom1 = ScreenCoordsXY{ strLeft, lineY1 };
|
||||
GfxDrawLine(dpi, { darkLineLeftTop1, darkLineRightBottom1 }, darkColour);
|
||||
GfxDrawLine(&dpi, { darkLineLeftTop1, darkLineRightBottom1 }, darkColour);
|
||||
|
||||
auto darkLineLeftTop2 = ScreenCoordsXY{ strRight, lineY1 };
|
||||
auto darkLineRightBottom2 = ScreenCoordsXY{ right, lineY1 };
|
||||
GfxDrawLine(dpi, { darkLineLeftTop2, darkLineRightBottom2 }, darkColour);
|
||||
GfxDrawLine(&dpi, { darkLineLeftTop2, darkLineRightBottom2 }, darkColour);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Draw light horizontal rule
|
||||
auto lightLineLeftTop1 = ScreenCoordsXY{ left, lineY0 };
|
||||
auto lightLineRightBottom1 = ScreenCoordsXY{ right, lineY0 };
|
||||
GfxDrawLine(dpi, { lightLineLeftTop1, lightLineRightBottom1 }, lightColour);
|
||||
GfxDrawLine(&dpi, { lightLineLeftTop1, lightLineRightBottom1 }, lightColour);
|
||||
|
||||
// Draw dark horizontal rule
|
||||
auto darkLineLeftTop1 = ScreenCoordsXY{ left, lineY1 };
|
||||
auto darkLineRightBottom1 = ScreenCoordsXY{ right, lineY1 };
|
||||
GfxDrawLine(dpi, { darkLineLeftTop1, darkLineRightBottom1 }, darkColour);
|
||||
GfxDrawLine(&dpi, { darkLineLeftTop1, darkLineRightBottom1 }, darkColour);
|
||||
}
|
||||
}
|
||||
|
||||
void CustomListView::PaintCell(
|
||||
DrawPixelInfo* dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const char* text, bool isHighlighted) const
|
||||
DrawPixelInfo& dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const char* text, bool isHighlighted) const
|
||||
{
|
||||
StringId stringId = isHighlighted ? STR_WINDOW_COLOUR_2_STRINGID : STR_BLACK_STRING;
|
||||
|
||||
auto ft = Formatter();
|
||||
ft.Add<StringId>(STR_STRING);
|
||||
ft.Add<const char*>(text);
|
||||
DrawTextEllipsised(*dpi, pos, size.width, stringId, ft, {});
|
||||
DrawTextEllipsised(dpi, pos, size.width, stringId, ft, {});
|
||||
}
|
||||
|
||||
std::optional<RowColumn> CustomListView::GetItemIndexAt(const ScreenCoordsXY& pos)
|
||||
|
|
|
@ -136,15 +136,15 @@ namespace OpenRCT2::Ui::Windows
|
|||
void MouseOver(const ScreenCoordsXY& pos, bool isMouseDown);
|
||||
void MouseDown(const ScreenCoordsXY& pos);
|
||||
void MouseUp(const ScreenCoordsXY& pos);
|
||||
void Paint(WindowBase* w, DrawPixelInfo* dpi, const ScrollBar* scroll) const;
|
||||
void Paint(WindowBase* w, DrawPixelInfo& dpi, const ScrollBar* scroll) const;
|
||||
|
||||
private:
|
||||
void PaintHeading(
|
||||
WindowBase* w, DrawPixelInfo* dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const std::string& text,
|
||||
WindowBase* w, DrawPixelInfo& dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const std::string& text,
|
||||
ColumnSortOrder sortOrder, bool isPressed) const;
|
||||
void PaintSeperator(DrawPixelInfo* dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const char* text) const;
|
||||
void PaintSeperator(DrawPixelInfo& dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const char* text) const;
|
||||
void PaintCell(
|
||||
DrawPixelInfo* dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const char* text, bool isHighlighted) const;
|
||||
DrawPixelInfo& dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const char* text, bool isHighlighted) const;
|
||||
std::optional<RowColumn> GetItemIndexAt(const ScreenCoordsXY& pos);
|
||||
Widget* GetWidget() const;
|
||||
void Invalidate();
|
||||
|
|
|
@ -751,7 +751,7 @@ namespace OpenRCT2::Ui::Windows
|
|||
const auto& info = GetInfo(this);
|
||||
if (scrollIndex < static_cast<int32_t>(info.ListViews.size()))
|
||||
{
|
||||
info.ListViews[scrollIndex].Paint(this, &dpi, &scrolls[scrollIndex]);
|
||||
info.ListViews[scrollIndex].Paint(this, dpi, &scrolls[scrollIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -115,11 +115,11 @@ void DrawingEngineDispose()
|
|||
}
|
||||
}
|
||||
|
||||
DrawPixelInfo* DrawingEngineGetDpi()
|
||||
DrawPixelInfo& DrawingEngineGetDpi()
|
||||
{
|
||||
auto context = GetContext();
|
||||
auto drawingEngine = context->GetDrawingEngine();
|
||||
return drawingEngine->GetDrawingPixelInfo();
|
||||
return *(drawingEngine->GetDrawingPixelInfo());
|
||||
}
|
||||
|
||||
bool DrawingEngineHasDirtyOptimisations()
|
||||
|
|
|
@ -25,7 +25,7 @@ void DrawingEngineSetPalette(const GamePalette& colours);
|
|||
void DrawingEngineCopyRect(int32_t x, int32_t y, int32_t width, int32_t height, int32_t dx, int32_t dy);
|
||||
void DrawingEngineDispose();
|
||||
|
||||
DrawPixelInfo* DrawingEngineGetDpi();
|
||||
DrawPixelInfo& DrawingEngineGetDpi();
|
||||
bool DrawingEngineHasDirtyOptimisations();
|
||||
void DrawingEngineInvalidateImage(uint32_t image);
|
||||
void DrawingEngineSetVSync(bool vsync);
|
||||
|
|
|
@ -2801,8 +2801,7 @@ void Peep::Paint(PaintSession& session, int32_t imageDirection) const
|
|||
}
|
||||
}
|
||||
|
||||
DrawPixelInfo* dpi = &session.DPI;
|
||||
if (dpi->zoom_level > ZoomLevel{ 2 })
|
||||
if (session.DPI.zoom_level > ZoomLevel{ 2 })
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -479,8 +479,8 @@ static void ViewportMove(const ScreenCoordsXY& coords, WindowBase* w, Viewport*
|
|||
|
||||
if (DrawingEngineHasDirtyOptimisations())
|
||||
{
|
||||
DrawPixelInfo* dpi = DrawingEngineGetDpi();
|
||||
WindowDrawAll(*dpi, left, top, right, bottom);
|
||||
DrawPixelInfo& dpi = DrawingEngineGetDpi();
|
||||
WindowDrawAll(dpi, left, top, right, bottom);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -531,8 +531,8 @@ static void ViewportMove(const ScreenCoordsXY& coords, WindowBase* w, Viewport*
|
|||
|
||||
if (DrawingEngineHasDirtyOptimisations())
|
||||
{
|
||||
DrawPixelInfo* dpi = DrawingEngineGetDpi();
|
||||
ViewportShiftPixels(*dpi, w, viewport, x_diff, y_diff);
|
||||
DrawPixelInfo& dpi = DrawingEngineGetDpi();
|
||||
ViewportShiftPixels(dpi, w, viewport, x_diff, y_diff);
|
||||
}
|
||||
|
||||
*viewport = view_copy;
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace WindowCloseFlags
|
|||
} // namespace WindowCloseFlags
|
||||
|
||||
static void WindowDrawCore(DrawPixelInfo& dpi, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom);
|
||||
static void WindowDrawSingle(DrawPixelInfo* dpi, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom);
|
||||
static void WindowDrawSingle(DrawPixelInfo& dpi, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom);
|
||||
|
||||
std::list<std::shared_ptr<WindowBase>>::iterator WindowGetIterator(const WindowBase* w)
|
||||
{
|
||||
|
@ -1203,56 +1203,55 @@ static void WindowDrawCore(DrawPixelInfo& dpi, WindowBase& w, int32_t left, int3
|
|||
auto* v = (*it).get();
|
||||
if ((&w == v || (v->flags & WF_TRANSPARENT)) && WindowIsVisible(*v))
|
||||
{
|
||||
WindowDrawSingle(&dpi, *v, left, top, right, bottom);
|
||||
WindowDrawSingle(dpi, *v, left, top, right, bottom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void WindowDrawSingle(DrawPixelInfo* dpi, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom)
|
||||
static void WindowDrawSingle(DrawPixelInfo& dpi, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom)
|
||||
{
|
||||
// Copy dpi so we can crop it
|
||||
DrawPixelInfo copy = *dpi;
|
||||
dpi = ©
|
||||
DrawPixelInfo copy = dpi;
|
||||
|
||||
// Clamp left to 0
|
||||
int32_t overflow = left - dpi->x;
|
||||
int32_t overflow = left - copy.x;
|
||||
if (overflow > 0)
|
||||
{
|
||||
dpi->x += overflow;
|
||||
dpi->width -= overflow;
|
||||
if (dpi->width <= 0)
|
||||
copy.x += overflow;
|
||||
copy.width -= overflow;
|
||||
if (copy.width <= 0)
|
||||
return;
|
||||
dpi->pitch += overflow;
|
||||
dpi->bits += overflow;
|
||||
copy.pitch += overflow;
|
||||
copy.bits += overflow;
|
||||
}
|
||||
|
||||
// Clamp width to right
|
||||
overflow = dpi->x + dpi->width - right;
|
||||
overflow = copy.x + copy.width - right;
|
||||
if (overflow > 0)
|
||||
{
|
||||
dpi->width -= overflow;
|
||||
if (dpi->width <= 0)
|
||||
copy.width -= overflow;
|
||||
if (copy.width <= 0)
|
||||
return;
|
||||
dpi->pitch += overflow;
|
||||
copy.pitch += overflow;
|
||||
}
|
||||
|
||||
// Clamp top to 0
|
||||
overflow = top - dpi->y;
|
||||
overflow = top - copy.y;
|
||||
if (overflow > 0)
|
||||
{
|
||||
dpi->y += overflow;
|
||||
dpi->height -= overflow;
|
||||
if (dpi->height <= 0)
|
||||
copy.y += overflow;
|
||||
copy.height -= overflow;
|
||||
if (copy.height <= 0)
|
||||
return;
|
||||
dpi->bits += (dpi->width + dpi->pitch) * overflow;
|
||||
copy.bits += (copy.width + copy.pitch) * overflow;
|
||||
}
|
||||
|
||||
// Clamp height to bottom
|
||||
overflow = dpi->y + dpi->height - bottom;
|
||||
overflow = copy.y + copy.height - bottom;
|
||||
if (overflow > 0)
|
||||
{
|
||||
dpi->height -= overflow;
|
||||
if (dpi->height <= 0)
|
||||
copy.height -= overflow;
|
||||
if (copy.height <= 0)
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1266,7 +1265,7 @@ static void WindowDrawSingle(DrawPixelInfo* dpi, WindowBase& w, int32_t left, in
|
|||
gCurrentWindowColours[2] = NOT_TRANSLUCENT(w.colours[2]);
|
||||
gCurrentWindowColours[3] = NOT_TRANSLUCENT(w.colours[3]);
|
||||
|
||||
WindowEventPaintCall(&w, *dpi);
|
||||
WindowEventPaintCall(&w, copy);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1190,8 +1190,7 @@ void VehicleVisualMiniGolfPlayer(
|
|||
return;
|
||||
}
|
||||
|
||||
DrawPixelInfo* edi = &session.DPI;
|
||||
if (edi->zoom_level >= ZoomLevel{ 2 })
|
||||
if (session.DPI.zoom_level >= ZoomLevel{ 2 })
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1227,8 +1226,7 @@ void VehicleVisualMiniGolfBall(
|
|||
return;
|
||||
}
|
||||
|
||||
DrawPixelInfo* edi = &session.DPI;
|
||||
if (edi->zoom_level >= ZoomLevel{ 1 })
|
||||
if (session.DPI.zoom_level >= ZoomLevel{ 1 })
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -134,8 +134,7 @@ static void SpiralSlidePaintTileFront(
|
|||
PaintAddImageAsParent(session, imageId, { 16, 16, height }, { { 8, 0, height + 3 }, { 8, 16, 108 } });
|
||||
}
|
||||
|
||||
DrawPixelInfo* dpi = &session.DPI;
|
||||
if (dpi->zoom_level <= ZoomLevel{ 0 } && ride.slide_in_use != 0)
|
||||
if (session.DPI.zoom_level <= ZoomLevel{ 0 } && ride.slide_in_use != 0)
|
||||
{
|
||||
uint8_t slide_progress = ride.spiral_slide_progress;
|
||||
if (slide_progress != 0)
|
||||
|
|
Loading…
Reference in New Issue