Use dpi ref in Graph.cpp and InGameConsole.cpp

This commit is contained in:
Gymnasiast 2023-04-03 21:41:56 +02:00 committed by duncanspumpkin
parent f98818f8e5
commit f09df5a06a
7 changed files with 50 additions and 50 deletions

View File

@ -146,7 +146,7 @@ public:
{
auto bgColour = ThemeGetColour(WindowClass::Chat, 0);
ChatDraw(dpi, bgColour);
_inGameConsole.Draw(dpi);
_inGameConsole.Draw(*dpi);
}
// Window

View File

@ -16,7 +16,7 @@
namespace Graph
{
static void DrawMonths(DrawPixelInfo* dpi, const uint8_t* history, int32_t count, const ScreenCoordsXY& origCoords)
static void DrawMonths(DrawPixelInfo& dpi, const uint8_t* history, int32_t count, const ScreenCoordsXY& origCoords)
{
auto& date = GetDate();
int32_t currentMonth = date.GetMonth();
@ -31,11 +31,11 @@ namespace Graph
auto ft = Formatter();
ft.Add<uint32_t>(DateGameShortMonthNames[DateGetMonth((yearOver32 / 4) + MONTH_COUNT)]);
DrawTextBasic(
*dpi, screenCoords - ScreenCoordsXY{ 0, 10 }, STR_GRAPH_LABEL, ft,
dpi, screenCoords - ScreenCoordsXY{ 0, 10 }, STR_GRAPH_LABEL, ft,
{ FontStyle::Small, TextAlignment::CENTRE });
// Draw month mark
GfxFillRect(dpi, { screenCoords, screenCoords + ScreenCoordsXY{ 0, 3 } }, PALETTE_INDEX_10);
GfxFillRect(&dpi, { screenCoords, screenCoords + ScreenCoordsXY{ 0, 3 } }, PALETTE_INDEX_10);
}
yearOver32 = (yearOver32 + 1) % 32;
@ -43,7 +43,7 @@ namespace Graph
}
}
static void DrawLineA(DrawPixelInfo* dpi, const uint8_t* history, int32_t count, const ScreenCoordsXY& origCoords)
static void DrawLineA(DrawPixelInfo& dpi, const uint8_t* history, int32_t count, const ScreenCoordsXY& origCoords)
{
auto lastCoords = ScreenCoordsXY{ -1, -1 };
auto coords = origCoords;
@ -59,11 +59,11 @@ namespace Graph
auto rightBottom1 = coords + ScreenCoordsXY{ 1, 1 };
auto leftTop2 = lastCoords + ScreenCoordsXY{ 0, 1 };
auto rightBottom2 = coords + ScreenCoordsXY{ 0, 1 };
GfxDrawLine(dpi, { leftTop1, rightBottom1 }, PALETTE_INDEX_10);
GfxDrawLine(dpi, { leftTop2, rightBottom2 }, PALETTE_INDEX_10);
GfxDrawLine(&dpi, { leftTop1, rightBottom1 }, PALETTE_INDEX_10);
GfxDrawLine(&dpi, { leftTop2, rightBottom2 }, PALETTE_INDEX_10);
}
if (i == 0)
GfxFillRect(dpi, { coords, coords + ScreenCoordsXY{ 2, 2 } }, PALETTE_INDEX_10);
GfxFillRect(&dpi, { coords, coords + ScreenCoordsXY{ 2, 2 } }, PALETTE_INDEX_10);
lastCoords = coords;
}
@ -71,7 +71,7 @@ namespace Graph
}
}
static void DrawLineB(DrawPixelInfo* dpi, const uint8_t* history, int32_t count, const ScreenCoordsXY& origCoords)
static void DrawLineB(DrawPixelInfo& dpi, const uint8_t* history, int32_t count, const ScreenCoordsXY& origCoords)
{
auto lastCoords = ScreenCoordsXY{ -1, -1 };
auto coords = origCoords;
@ -85,10 +85,10 @@ namespace Graph
{
auto leftTop = lastCoords;
auto rightBottom = coords;
GfxDrawLine(dpi, { leftTop, rightBottom }, PALETTE_INDEX_21);
GfxDrawLine(&dpi, { leftTop, rightBottom }, PALETTE_INDEX_21);
}
if (i == 0)
GfxFillRect(dpi, { coords - ScreenCoordsXY{ 1, 1 }, coords + ScreenCoordsXY{ 1, 1 } }, PALETTE_INDEX_21);
GfxFillRect(&dpi, { coords - ScreenCoordsXY{ 1, 1 }, coords + ScreenCoordsXY{ 1, 1 } }, PALETTE_INDEX_21);
lastCoords = coords;
}
@ -96,7 +96,7 @@ namespace Graph
}
}
void Draw(DrawPixelInfo* dpi, uint8_t* history, int32_t count, const ScreenCoordsXY& screenPos)
void Draw(DrawPixelInfo& dpi, uint8_t* history, int32_t count, const ScreenCoordsXY& screenPos)
{
DrawMonths(dpi, history, count, screenPos);
DrawLineA(dpi, history, count, screenPos);
@ -152,7 +152,7 @@ static const FinancialTooltipInfo FinanceTooltipInfoFromMoney(
namespace Graph
{
static void DrawMonths(DrawPixelInfo* dpi, const money64* history, int32_t count, const ScreenCoordsXY& origCoords)
static void DrawMonths(DrawPixelInfo& dpi, const money64* history, int32_t count, const ScreenCoordsXY& origCoords)
{
auto& date = GetDate();
int32_t currentMonth = date.GetMonth();
@ -167,11 +167,11 @@ namespace Graph
auto ft = Formatter();
ft.Add<StringId>(DateGameShortMonthNames[DateGetMonth((yearOver32 / 4) + MONTH_COUNT)]);
DrawTextBasic(
*dpi, screenCoords - ScreenCoordsXY{ 0, 10 }, STR_GRAPH_LABEL, ft,
dpi, screenCoords - ScreenCoordsXY{ 0, 10 }, STR_GRAPH_LABEL, ft,
{ FontStyle::Small, TextAlignment::CENTRE });
// Draw month mark
GfxFillRect(dpi, { screenCoords, screenCoords + ScreenCoordsXY{ 0, 3 } }, PALETTE_INDEX_10);
GfxFillRect(&dpi, { screenCoords, screenCoords + ScreenCoordsXY{ 0, 3 } }, PALETTE_INDEX_10);
}
yearOver32 = (yearOver32 + 1) % 32;
@ -180,7 +180,7 @@ namespace Graph
}
static void DrawLineA(
DrawPixelInfo* dpi, const money64* history, int32_t count, const ScreenCoordsXY& origCoords, int32_t modifier,
DrawPixelInfo& dpi, const money64* history, int32_t count, const ScreenCoordsXY& origCoords, int32_t modifier,
int32_t offset)
{
auto lastCoords = ScreenCoordsXY{ -1, -1 };
@ -197,11 +197,11 @@ namespace Graph
auto rightBottom1 = coords + ScreenCoordsXY{ 1, 1 };
auto leftTop2 = lastCoords + ScreenCoordsXY{ 0, 1 };
auto rightBottom2 = coords + ScreenCoordsXY{ 0, 1 };
GfxDrawLine(dpi, { leftTop1, rightBottom1 }, PALETTE_INDEX_10);
GfxDrawLine(dpi, { leftTop2, rightBottom2 }, PALETTE_INDEX_10);
GfxDrawLine(&dpi, { leftTop1, rightBottom1 }, PALETTE_INDEX_10);
GfxDrawLine(&dpi, { leftTop2, rightBottom2 }, PALETTE_INDEX_10);
}
if (i == 0)
GfxFillRect(dpi, { coords, coords + ScreenCoordsXY{ 2, 2 } }, PALETTE_INDEX_10);
GfxFillRect(&dpi, { coords, coords + ScreenCoordsXY{ 2, 2 } }, PALETTE_INDEX_10);
lastCoords = coords;
}
@ -210,7 +210,7 @@ namespace Graph
}
static void DrawLineB(
DrawPixelInfo* dpi, const money64* history, int32_t count, const ScreenCoordsXY& origCoords, int32_t modifier,
DrawPixelInfo& dpi, const money64* history, int32_t count, const ScreenCoordsXY& origCoords, int32_t modifier,
int32_t offset)
{
auto lastCoords = ScreenCoordsXY{ -1, -1 };
@ -225,10 +225,10 @@ namespace Graph
{
auto leftTop = lastCoords;
auto rightBottom = coords;
GfxDrawLine(dpi, { leftTop, rightBottom }, PALETTE_INDEX_21);
GfxDrawLine(&dpi, { leftTop, rightBottom }, PALETTE_INDEX_21);
}
if (i == 0)
GfxFillRect(dpi, { coords - ScreenCoordsXY{ 1, 1 }, coords + ScreenCoordsXY{ 1, 1 } }, PALETTE_INDEX_21);
GfxFillRect(&dpi, { coords - ScreenCoordsXY{ 1, 1 }, coords + ScreenCoordsXY{ 1, 1 } }, PALETTE_INDEX_21);
lastCoords = coords;
}
@ -237,7 +237,7 @@ namespace Graph
}
static void DrawHoveredValue(
DrawPixelInfo* dpi, const money64* history, const int32_t historyCount, const ScreenCoordsXY& screenCoords,
DrawPixelInfo& dpi, const money64* history, const int32_t historyCount, const ScreenCoordsXY& screenCoords,
const int32_t modifier, const int32_t offset)
{
const auto cursorPosition = ContextGetCursorPositionScaled();
@ -254,26 +254,26 @@ namespace Graph
{
return;
}
GfxDrawDashedLine(dpi, { { info.coords.x, chartFrame.GetTop() }, info.coords }, DefaultDashedLength, 0);
GfxDrawDashedLine(dpi, { { chartFrame.GetLeft() - 10, info.coords.y }, info.coords }, DefaultDashedLength, 0);
GfxDrawDashedLine(&dpi, { { info.coords.x, chartFrame.GetTop() }, info.coords }, DefaultDashedLength, 0);
GfxDrawDashedLine(&dpi, { { chartFrame.GetLeft() - 10, info.coords.y }, info.coords }, DefaultDashedLength, 0);
if (cursorPosition.y > info.coords.y)
{
GfxDrawDashedLine(dpi, { info.coords, { info.coords.x, cursorPosition.y } }, DefaultDashedLength, 0);
GfxDrawDashedLine(&dpi, { info.coords, { info.coords.x, cursorPosition.y } }, DefaultDashedLength, 0);
}
auto ft = Formatter();
ft.Add<money64>(info.money);
DrawTextBasic(
*dpi, info.coords - ScreenCoordsXY{ 0, 16 }, STR_FINANCES_SUMMARY_EXPENDITURE_VALUE, ft, { TextAlignment::CENTRE });
dpi, info.coords - ScreenCoordsXY{ 0, 16 }, STR_FINANCES_SUMMARY_EXPENDITURE_VALUE, ft, { TextAlignment::CENTRE });
GfxFillRect(dpi, { { info.coords - ScreenCoordsXY{ 2, 2 } }, info.coords + ScreenCoordsXY{ 2, 2 } }, PALETTE_INDEX_10);
GfxFillRect(&dpi, { { info.coords - ScreenCoordsXY{ 2, 2 } }, info.coords + ScreenCoordsXY{ 2, 2 } }, PALETTE_INDEX_10);
GfxFillRect(
dpi, { { info.coords - ScreenCoordsXY{ 1, 1 } }, { info.coords + ScreenCoordsXY{ 1, 1 } } }, PALETTE_INDEX_21);
&dpi, { { info.coords - ScreenCoordsXY{ 1, 1 } }, { info.coords + ScreenCoordsXY{ 1, 1 } } }, PALETTE_INDEX_21);
}
void Draw(
DrawPixelInfo* dpi, const money64* history, const int32_t count, const ScreenCoordsXY& screenCoords,
DrawPixelInfo& dpi, const money64* history, const int32_t count, const ScreenCoordsXY& screenCoords,
const int32_t modifier, const int32_t offset)
{
DrawMonths(dpi, history, count, screenCoords);

View File

@ -15,8 +15,8 @@
namespace Graph
{
void Draw(DrawPixelInfo* dpi, uint8_t* history, int32_t count, const ScreenCoordsXY& screenPos);
void Draw(DrawPixelInfo& dpi, uint8_t* history, int32_t count, const ScreenCoordsXY& screenPos);
void Draw(
DrawPixelInfo* dpi, const money64* history, const int32_t count, const ScreenCoordsXY& coords, const int32_t modifier,
DrawPixelInfo& dpi, const money64* history, const int32_t count, const ScreenCoordsXY& coords, const int32_t modifier,
const int32_t offset);
} // namespace Graph

View File

@ -264,7 +264,7 @@ void InGameConsole::Update()
_consoleCaretTicks = (_consoleCaretTicks + 1) % 30;
}
void InGameConsole::Draw(DrawPixelInfo* dpi) const
void InGameConsole::Draw(DrawPixelInfo& dpi) const
{
if (!_isOpen)
return;
@ -292,18 +292,18 @@ void InGameConsole::Draw(DrawPixelInfo* dpi) const
Invalidate();
// Give console area a translucent effect.
GfxFilterRect(dpi, { _consoleTopLeft, _consoleBottomRight }, FilterPaletteID::Palette51);
GfxFilterRect(&dpi, { _consoleTopLeft, _consoleBottomRight }, FilterPaletteID::Palette51);
// Make input area more opaque.
GfxFilterRect(
dpi, { { _consoleTopLeft.x, _consoleBottomRight.y - lineHeight - 10 }, _consoleBottomRight - ScreenCoordsXY{ 0, 1 } },
&dpi, { { _consoleTopLeft.x, _consoleBottomRight.y - lineHeight - 10 }, _consoleBottomRight - ScreenCoordsXY{ 0, 1 } },
FilterPaletteID::Palette51);
// Paint background colour.
uint8_t backgroundColour = ThemeGetColour(WindowClass::Console, 0);
GfxFillRectInset(dpi, { _consoleTopLeft, _consoleBottomRight }, backgroundColour, INSET_RECT_FLAG_FILL_NONE);
GfxFillRectInset(&dpi, { _consoleTopLeft, _consoleBottomRight }, backgroundColour, INSET_RECT_FLAG_FILL_NONE);
GfxFillRectInset(
dpi, { _consoleTopLeft + ScreenCoordsXY{ 1, 1 }, _consoleBottomRight - ScreenCoordsXY{ 1, 1 } }, backgroundColour,
&dpi, { _consoleTopLeft + ScreenCoordsXY{ 1, 1 }, _consoleBottomRight - ScreenCoordsXY{ 1, 1 } }, backgroundColour,
INSET_RECT_FLAG_BORDER_INSET);
std::string lineBuffer;
@ -314,7 +314,7 @@ void InGameConsole::Draw(DrawPixelInfo* dpi) const
{
const size_t index = i + _consoleScrollPos;
lineBuffer = _colourFormatStr + _consoleLines[index];
GfxDrawString(*dpi, screenCoords, lineBuffer.c_str(), { textColour, InGameConsoleGetFontStyle() });
GfxDrawString(dpi, screenCoords, lineBuffer.c_str(), { textColour, InGameConsoleGetFontStyle() });
screenCoords.y += lineHeight;
}
@ -322,14 +322,14 @@ void InGameConsole::Draw(DrawPixelInfo* dpi) const
// Draw current line
lineBuffer = _colourFormatStr + _consoleCurrentLine;
DrawText(*dpi, screenCoords, { TEXT_COLOUR_255, InGameConsoleGetFontStyle() }, lineBuffer.c_str(), true);
DrawText(dpi, screenCoords, { TEXT_COLOUR_255, InGameConsoleGetFontStyle() }, lineBuffer.c_str(), true);
// Draw caret
if (_consoleCaretTicks < CONSOLE_CARET_FLASH_THRESHOLD)
{
auto caret = screenCoords + ScreenCoordsXY{ _caretScreenPosX, lineHeight };
uint8_t caretColour = ColourMapA[BASE_COLOUR(textColour)].lightest;
GfxFillRect(dpi, { caret, caret + ScreenCoordsXY{ CONSOLE_CARET_WIDTH, 1 } }, caretColour);
GfxFillRect(&dpi, { caret, caret + ScreenCoordsXY{ CONSOLE_CARET_WIDTH, 1 } }, caretColour);
}
// What about border colours?
@ -338,21 +338,21 @@ void InGameConsole::Draw(DrawPixelInfo* dpi) const
// Input area top border
GfxFillRect(
dpi,
&dpi,
{ { _consoleTopLeft.x, _consoleBottomRight.y - lineHeight - 11 },
{ _consoleBottomRight.x, _consoleBottomRight.y - lineHeight - 11 } },
borderColour1);
GfxFillRect(
dpi,
&dpi,
{ { _consoleTopLeft.x, _consoleBottomRight.y - lineHeight - 10 },
{ _consoleBottomRight.x, _consoleBottomRight.y - lineHeight - 10 } },
borderColour2);
// Input area bottom border
GfxFillRect(
dpi, { { _consoleTopLeft.x, _consoleBottomRight.y - 1 }, { _consoleBottomRight.x, _consoleBottomRight.y - 1 } },
&dpi, { { _consoleTopLeft.x, _consoleBottomRight.y - 1 }, { _consoleBottomRight.x, _consoleBottomRight.y - 1 } },
borderColour1);
GfxFillRect(dpi, { { _consoleTopLeft.x, _consoleBottomRight.y }, _consoleBottomRight }, borderColour2);
GfxFillRect(&dpi, { { _consoleTopLeft.x, _consoleBottomRight.y }, _consoleBottomRight }, borderColour2);
}
// Calculates the amount of visible lines, based on the console size, excluding the input line.

View File

@ -65,7 +65,7 @@ namespace OpenRCT2::Ui
void Scroll(int32_t linesToScroll);
void Update();
void Draw(DrawPixelInfo* dpi) const;
void Draw(DrawPixelInfo& dpi) const;
private:
void ClearInput();

View File

@ -656,7 +656,7 @@ public:
// X axis labels and values
coords = graphTopLeft + ScreenCoordsXY{ 98, 17 };
Graph::Draw(&dpi, gCashHistory, 64, coords, yAxisScale, 128);
Graph::Draw(dpi, gCashHistory, 64, coords, yAxisScale, 128);
}
#pragma endregion
@ -713,7 +713,7 @@ public:
// X axis labels and values
coords = graphTopLeft + ScreenCoordsXY{ 98, 17 };
Graph::Draw(&dpi, gParkValueHistory, 64, coords, yAxisScale, 0);
Graph::Draw(dpi, gParkValueHistory, 64, coords, yAxisScale, 0);
}
#pragma endregion
@ -772,7 +772,7 @@ public:
// X axis labels and values
screenPos = graphTopLeft + ScreenCoordsXY{ 98, 17 };
Graph::Draw(&dpi, gWeeklyProfitHistory, 64, screenPos, yAxisScale, 128);
Graph::Draw(dpi, gWeeklyProfitHistory, 64, screenPos, yAxisScale, 128);
}
#pragma endregion

View File

@ -723,7 +723,7 @@ private:
// Graph
screenPos = windowPos + ScreenCoordsXY{ widget->left + 47, widget->top + 26 };
Graph::Draw(&dpi, gParkRatingHistory, 32, screenPos);
Graph::Draw(dpi, gParkRatingHistory, 32, screenPos);
}
#pragma endregion
@ -808,7 +808,7 @@ private:
cappedHistory[i] = std::numeric_limits<uint8_t>::max();
}
}
Graph::Draw(&dpi, cappedHistory, static_cast<int32_t>(std::size(cappedHistory)), screenPos);
Graph::Draw(dpi, cappedHistory, static_cast<int32_t>(std::size(cappedHistory)), screenPos);
}
#pragma endregion