mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-28 17:24:47 +01:00
Refactor Graph to TitleCase (#13353)
This commit is contained in:
@@ -12,191 +12,101 @@
|
||||
#include <openrct2/localisation/Date.h>
|
||||
#include <openrct2/localisation/Localisation.h>
|
||||
|
||||
static void graph_draw_months_uint8_t(
|
||||
rct_drawpixelinfo* dpi, const uint8_t* history, int32_t count, int32_t baseX, int32_t baseY)
|
||||
namespace Graph
|
||||
{
|
||||
int32_t i, yearOver32, currentMonth, currentDay;
|
||||
|
||||
currentMonth = date_get_month(gDateMonthsElapsed);
|
||||
currentDay = gDateMonthTicks;
|
||||
yearOver32 = (currentMonth * 4) + (currentDay >> 14) - 31;
|
||||
auto screenCoords = ScreenCoordsXY{ baseX, baseY };
|
||||
for (i = count - 1; i >= 0; i--)
|
||||
static void DrawMonths(rct_drawpixelinfo* dpi, const uint8_t* history, int32_t count, int32_t baseX, int32_t baseY)
|
||||
{
|
||||
if (history[i] != 255 && yearOver32 % 4 == 0)
|
||||
int32_t i, yearOver32, currentMonth, currentDay;
|
||||
|
||||
currentMonth = date_get_month(gDateMonthsElapsed);
|
||||
currentDay = gDateMonthTicks;
|
||||
yearOver32 = (currentMonth * 4) + (currentDay >> 14) - 31;
|
||||
auto screenCoords = ScreenCoordsXY{ baseX, baseY };
|
||||
for (i = count - 1; i >= 0; i--)
|
||||
{
|
||||
// Draw month text
|
||||
auto ft = Formatter();
|
||||
ft.Add<uint32_t>(DateGameShortMonthNames[date_get_month((yearOver32 / 4) + MONTH_COUNT)]);
|
||||
gfx_draw_string_centred(dpi, STR_GRAPH_LABEL, screenCoords - ScreenCoordsXY{ 0, 10 }, COLOUR_BLACK, ft.Data());
|
||||
|
||||
// Draw month mark
|
||||
gfx_fill_rect(dpi, { screenCoords, screenCoords + ScreenCoordsXY{ 0, 3 } }, PALETTE_INDEX_10);
|
||||
}
|
||||
|
||||
yearOver32 = (yearOver32 + 1) % 32;
|
||||
screenCoords.x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
static void graph_draw_line_a_uint8_t(
|
||||
rct_drawpixelinfo* dpi, const uint8_t* history, int32_t count, int32_t baseX, int32_t baseY)
|
||||
{
|
||||
int32_t i, x, y, lastX, lastY;
|
||||
lastX = -1;
|
||||
lastY = -1;
|
||||
x = baseX;
|
||||
for (i = count - 1; i >= 0; i--)
|
||||
{
|
||||
if (history[i] != 255)
|
||||
{
|
||||
y = baseY + ((255 - history[i]) * 100) / 256;
|
||||
|
||||
if (lastX != -1)
|
||||
if (history[i] != 255 && yearOver32 % 4 == 0)
|
||||
{
|
||||
auto leftTop1 = ScreenCoordsXY{ lastX + 1, lastY + 1 };
|
||||
auto rightBottom1 = ScreenCoordsXY{ x + 1, y + 1 };
|
||||
auto leftTop2 = ScreenCoordsXY{ lastX, lastY + 1 };
|
||||
auto rightBottom2 = ScreenCoordsXY{ x, y + 1 };
|
||||
gfx_draw_line(dpi, { leftTop1, rightBottom1 }, PALETTE_INDEX_10);
|
||||
gfx_draw_line(dpi, { leftTop2, rightBottom2 }, PALETTE_INDEX_10);
|
||||
// Draw month text
|
||||
auto ft = Formatter();
|
||||
ft.Add<uint32_t>(DateGameShortMonthNames[date_get_month((yearOver32 / 4) + MONTH_COUNT)]);
|
||||
gfx_draw_string_centred(dpi, STR_GRAPH_LABEL, screenCoords - ScreenCoordsXY{ 0, 10 }, COLOUR_BLACK, ft.Data());
|
||||
|
||||
// Draw month mark
|
||||
gfx_fill_rect(dpi, { screenCoords, screenCoords + ScreenCoordsXY{ 0, 3 } }, PALETTE_INDEX_10);
|
||||
}
|
||||
if (i == 0)
|
||||
gfx_fill_rect(dpi, { { x, y }, { x + 2, y + 2 } }, PALETTE_INDEX_10);
|
||||
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
yearOver32 = (yearOver32 + 1) % 32;
|
||||
screenCoords.x += 6;
|
||||
}
|
||||
x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
static void graph_draw_line_b_uint8_t(
|
||||
rct_drawpixelinfo* dpi, const uint8_t* history, int32_t count, int32_t baseX, int32_t baseY)
|
||||
{
|
||||
int32_t i, x, y, lastX, lastY;
|
||||
|
||||
lastX = -1;
|
||||
lastY = -1;
|
||||
x = baseX;
|
||||
for (i = count - 1; i >= 0; i--)
|
||||
static void DrawLineA(rct_drawpixelinfo* dpi, const uint8_t* history, int32_t count, int32_t baseX, int32_t baseY)
|
||||
{
|
||||
if (history[i] != 255)
|
||||
int32_t i, x, y, lastX, lastY;
|
||||
lastX = -1;
|
||||
lastY = -1;
|
||||
x = baseX;
|
||||
for (i = count - 1; i >= 0; i--)
|
||||
{
|
||||
y = baseY + ((255 - history[i]) * 100) / 256;
|
||||
|
||||
if (lastX != -1)
|
||||
if (history[i] != 255)
|
||||
{
|
||||
auto leftTop = ScreenCoordsXY{ lastX, lastY };
|
||||
auto rightBottom = ScreenCoordsXY{ x, y };
|
||||
gfx_draw_line(dpi, { leftTop, rightBottom }, PALETTE_INDEX_21);
|
||||
y = baseY + ((255 - history[i]) * 100) / 256;
|
||||
|
||||
if (lastX != -1)
|
||||
{
|
||||
auto leftTop1 = ScreenCoordsXY{ lastX + 1, lastY + 1 };
|
||||
auto rightBottom1 = ScreenCoordsXY{ x + 1, y + 1 };
|
||||
auto leftTop2 = ScreenCoordsXY{ lastX, lastY + 1 };
|
||||
auto rightBottom2 = ScreenCoordsXY{ x, y + 1 };
|
||||
gfx_draw_line(dpi, { leftTop1, rightBottom1 }, PALETTE_INDEX_10);
|
||||
gfx_draw_line(dpi, { leftTop2, rightBottom2 }, PALETTE_INDEX_10);
|
||||
}
|
||||
if (i == 0)
|
||||
gfx_fill_rect(dpi, { { x, y }, { x + 2, y + 2 } }, PALETTE_INDEX_10);
|
||||
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
}
|
||||
if (i == 0)
|
||||
gfx_fill_rect(dpi, { { x - 1, y - 1 }, { x + 1, y + 1 } }, PALETTE_INDEX_21);
|
||||
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
x += 6;
|
||||
}
|
||||
x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
void graph_draw_uint8_t(rct_drawpixelinfo* dpi, uint8_t* history, int32_t count, int32_t baseX, int32_t baseY)
|
||||
{
|
||||
graph_draw_months_uint8_t(dpi, history, count, baseX, baseY);
|
||||
graph_draw_line_a_uint8_t(dpi, history, count, baseX, baseY);
|
||||
graph_draw_line_b_uint8_t(dpi, history, count, baseX, baseY);
|
||||
}
|
||||
|
||||
static void graph_draw_months_money32(
|
||||
rct_drawpixelinfo* dpi, const money32* history, int32_t count, int32_t baseX, int32_t baseY)
|
||||
{
|
||||
int32_t i, yearOver32, currentMonth, currentDay;
|
||||
|
||||
currentMonth = date_get_month(gDateMonthsElapsed);
|
||||
currentDay = gDateMonthTicks;
|
||||
yearOver32 = (currentMonth * 4) + (currentDay >> 14) - 31;
|
||||
auto screenCoords = ScreenCoordsXY{ baseX, baseY };
|
||||
for (i = count - 1; i >= 0; i--)
|
||||
static void DrawLineB(rct_drawpixelinfo* dpi, const uint8_t* history, int32_t count, int32_t baseX, int32_t baseY)
|
||||
{
|
||||
if (history[i] != MONEY32_UNDEFINED && yearOver32 % 4 == 0)
|
||||
int32_t i, x, y, lastX, lastY;
|
||||
|
||||
lastX = -1;
|
||||
lastY = -1;
|
||||
x = baseX;
|
||||
for (i = count - 1; i >= 0; i--)
|
||||
{
|
||||
// Draw month text
|
||||
int32_t monthFormat = DateGameShortMonthNames[date_get_month((yearOver32 / 4) + MONTH_COUNT)];
|
||||
gfx_draw_string_centred(dpi, STR_GRAPH_LABEL, screenCoords - ScreenCoordsXY{ 0, 10 }, COLOUR_BLACK, &monthFormat);
|
||||
|
||||
// Draw month mark
|
||||
gfx_fill_rect(dpi, { screenCoords, screenCoords + ScreenCoordsXY{ 0, 3 } }, PALETTE_INDEX_10);
|
||||
}
|
||||
|
||||
yearOver32 = (yearOver32 + 1) % 32;
|
||||
screenCoords.x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
static void graph_draw_line_a_money32(
|
||||
rct_drawpixelinfo* dpi, const money32* history, int32_t count, int32_t baseX, int32_t baseY, int32_t modifier,
|
||||
int32_t offset)
|
||||
{
|
||||
int32_t i, x, y, lastX, lastY;
|
||||
lastX = -1;
|
||||
lastY = -1;
|
||||
x = baseX;
|
||||
for (i = count - 1; i >= 0; i--)
|
||||
{
|
||||
if (history[i] != MONEY32_UNDEFINED)
|
||||
{
|
||||
y = baseY + 170 - 6 - ((((history[i] >> modifier) + offset) * 170) / 256);
|
||||
|
||||
if (lastX != -1)
|
||||
if (history[i] != 255)
|
||||
{
|
||||
auto leftTop1 = ScreenCoordsXY{ lastX + 1, lastY + 1 };
|
||||
auto rightBottom1 = ScreenCoordsXY{ x + 1, y + 1 };
|
||||
auto leftTop2 = ScreenCoordsXY{ lastX, lastY + 1 };
|
||||
auto rightBottom2 = ScreenCoordsXY{ x, y + 1 };
|
||||
gfx_draw_line(dpi, { leftTop1, rightBottom1 }, PALETTE_INDEX_10);
|
||||
gfx_draw_line(dpi, { leftTop2, rightBottom2 }, PALETTE_INDEX_10);
|
||||
y = baseY + ((255 - history[i]) * 100) / 256;
|
||||
|
||||
if (lastX != -1)
|
||||
{
|
||||
auto leftTop = ScreenCoordsXY{ lastX, lastY };
|
||||
auto rightBottom = ScreenCoordsXY{ x, y };
|
||||
gfx_draw_line(dpi, { leftTop, rightBottom }, PALETTE_INDEX_21);
|
||||
}
|
||||
if (i == 0)
|
||||
gfx_fill_rect(dpi, { { x - 1, y - 1 }, { x + 1, y + 1 } }, PALETTE_INDEX_21);
|
||||
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
}
|
||||
if (i == 0)
|
||||
gfx_fill_rect(dpi, { { x, y }, { x + 2, y + 2 } }, PALETTE_INDEX_10);
|
||||
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
x += 6;
|
||||
}
|
||||
x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
static void graph_draw_line_b_money32(
|
||||
rct_drawpixelinfo* dpi, const money32* history, int32_t count, int32_t baseX, int32_t baseY, int32_t modifier,
|
||||
int32_t offset)
|
||||
{
|
||||
int32_t i, x, y, lastX, lastY;
|
||||
|
||||
lastX = -1;
|
||||
lastY = -1;
|
||||
x = baseX;
|
||||
for (i = count - 1; i >= 0; i--)
|
||||
void Draw(rct_drawpixelinfo* dpi, uint8_t* history, int32_t count, int32_t baseX, int32_t baseY)
|
||||
{
|
||||
if (history[i] != MONEY32_UNDEFINED)
|
||||
{
|
||||
y = baseY + 170 - 6 - ((((history[i] >> modifier) + offset) * 170) / 256);
|
||||
|
||||
if (lastX != -1)
|
||||
{
|
||||
auto leftTop = ScreenCoordsXY{ lastX, lastY };
|
||||
auto rightBottom = ScreenCoordsXY{ x, y };
|
||||
gfx_draw_line(dpi, { leftTop, rightBottom }, PALETTE_INDEX_21);
|
||||
}
|
||||
if (i == 0)
|
||||
gfx_fill_rect(dpi, { { x - 1, y - 1 }, { x + 1, y + 1 } }, PALETTE_INDEX_21);
|
||||
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
}
|
||||
x += 6;
|
||||
DrawMonths(dpi, history, count, baseX, baseY);
|
||||
DrawLineA(dpi, history, count, baseX, baseY);
|
||||
DrawLineB(dpi, history, count, baseX, baseY);
|
||||
}
|
||||
}
|
||||
} // namespace Graph
|
||||
|
||||
struct FinancialTooltipInfo
|
||||
{
|
||||
@@ -204,18 +114,18 @@ struct FinancialTooltipInfo
|
||||
const money32 money{};
|
||||
};
|
||||
|
||||
static constexpr auto CHART_MAX_DATA_COUNT = 64;
|
||||
static constexpr auto CHART_MAX_INDEX = CHART_MAX_DATA_COUNT - 1;
|
||||
static constexpr auto CHART_DATA_WIDTH = 6;
|
||||
static constexpr auto CHART_MAX_WIDTH = CHART_MAX_INDEX * CHART_DATA_WIDTH;
|
||||
static constexpr auto CHART_MAX_HEIGHT = 164;
|
||||
static constexpr auto CURSOR_X_OFFSET = 3;
|
||||
static constexpr auto DEFAULT_DASHED_LENGTH = 2;
|
||||
static constexpr auto ChartMaxDataCount = 64;
|
||||
static constexpr auto ChartMaxIndex = ChartMaxDataCount - 1;
|
||||
static constexpr auto ChartDataWidth = 6;
|
||||
static constexpr auto ChartMaxWidth = ChartMaxIndex * ChartDataWidth;
|
||||
static constexpr auto ChartMaxHeight = 164;
|
||||
static constexpr auto CursorXOffset = 3;
|
||||
static constexpr auto DefaultDashedLength = 2;
|
||||
|
||||
static int32_t IndexForCursorAndHistory(const int32_t historyCount, const int32_t cursorX, const int32_t chartX)
|
||||
{
|
||||
const auto offsettedCursorX = cursorX + CURSOR_X_OFFSET;
|
||||
return (historyCount - 1) - (offsettedCursorX - chartX) / CHART_DATA_WIDTH;
|
||||
const auto offsettedCursorX = cursorX + CursorXOffset;
|
||||
return (historyCount - 1) - (offsettedCursorX - chartX) / ChartDataWidth;
|
||||
}
|
||||
|
||||
static const ScreenCoordsXY ScreenCoordsForHistoryIndex(
|
||||
@@ -223,8 +133,8 @@ static const ScreenCoordsXY ScreenCoordsForHistoryIndex(
|
||||
const int32_t offset)
|
||||
{
|
||||
ScreenCoordsXY coords;
|
||||
coords.x = chartX + CHART_DATA_WIDTH * (CHART_MAX_INDEX - index);
|
||||
coords.y = chartY + CHART_MAX_HEIGHT - ((((history[index] >> modifier) + offset) * 170) / 256);
|
||||
coords.x = chartX + ChartDataWidth * (ChartMaxIndex - index);
|
||||
coords.y = chartY + ChartMaxHeight - ((((history[index] >> modifier) + offset) * 170) / 256);
|
||||
return coords;
|
||||
}
|
||||
|
||||
@@ -244,47 +154,141 @@ static const FinancialTooltipInfo finance_tooltip_info_from_money(
|
||||
return { { coords.x, coords.y }, history[historyIndex] };
|
||||
}
|
||||
|
||||
static void graph_draw_hovered_value(
|
||||
rct_drawpixelinfo* dpi, const money32* history, const int32_t historyCount, const int32_t baseX, const int32_t baseY,
|
||||
const int32_t modifier, const int32_t offset)
|
||||
namespace Graph
|
||||
{
|
||||
const auto cursorPosition = context_get_cursor_position_scaled();
|
||||
const ScreenRect chartFrame{ { baseX, baseY }, { baseX + CHART_MAX_WIDTH, baseY + CHART_MAX_HEIGHT } };
|
||||
|
||||
if (!chartFrame.Contains(cursorPosition))
|
||||
static void DrawMonths(rct_drawpixelinfo* dpi, const money32* history, int32_t count, int32_t baseX, int32_t baseY)
|
||||
{
|
||||
return;
|
||||
int32_t i, yearOver32, currentMonth, currentDay;
|
||||
|
||||
currentMonth = date_get_month(gDateMonthsElapsed);
|
||||
currentDay = gDateMonthTicks;
|
||||
yearOver32 = (currentMonth * 4) + (currentDay >> 14) - 31;
|
||||
auto screenCoords = ScreenCoordsXY{ baseX, baseY };
|
||||
for (i = count - 1; i >= 0; i--)
|
||||
{
|
||||
if (history[i] != MONEY32_UNDEFINED && yearOver32 % 4 == 0)
|
||||
{
|
||||
// Draw month text
|
||||
int32_t monthFormat = DateGameShortMonthNames[date_get_month((yearOver32 / 4) + MONTH_COUNT)];
|
||||
gfx_draw_string_centred(
|
||||
dpi, STR_GRAPH_LABEL, screenCoords - ScreenCoordsXY{ 0, 10 }, COLOUR_BLACK, &monthFormat);
|
||||
|
||||
// Draw month mark
|
||||
gfx_fill_rect(dpi, { screenCoords, screenCoords + ScreenCoordsXY{ 0, 3 } }, PALETTE_INDEX_10);
|
||||
}
|
||||
|
||||
yearOver32 = (yearOver32 + 1) % 32;
|
||||
screenCoords.x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
const auto info = finance_tooltip_info_from_money(
|
||||
history, CHART_MAX_DATA_COUNT, modifier, offset, chartFrame, cursorPosition);
|
||||
|
||||
if (info.money == MONEY32_UNDEFINED)
|
||||
static void DrawLineA(
|
||||
rct_drawpixelinfo* dpi, const money32* history, int32_t count, int32_t baseX, int32_t baseY, int32_t modifier,
|
||||
int32_t offset)
|
||||
{
|
||||
return;
|
||||
}
|
||||
gfx_draw_dashed_line(dpi, { { info.coords.x, chartFrame.GetTop() }, info.coords }, DEFAULT_DASHED_LENGTH, 0);
|
||||
gfx_draw_dashed_line(dpi, { { chartFrame.GetLeft() - 10, info.coords.y }, info.coords }, DEFAULT_DASHED_LENGTH, 0);
|
||||
int32_t i, x, y, lastX, lastY;
|
||||
lastX = -1;
|
||||
lastY = -1;
|
||||
x = baseX;
|
||||
for (i = count - 1; i >= 0; i--)
|
||||
{
|
||||
if (history[i] != MONEY32_UNDEFINED)
|
||||
{
|
||||
y = baseY + 170 - 6 - ((((history[i] >> modifier) + offset) * 170) / 256);
|
||||
|
||||
if (cursorPosition.y > info.coords.y)
|
||||
{
|
||||
gfx_draw_dashed_line(dpi, { info.coords, { info.coords.x, cursorPosition.y } }, DEFAULT_DASHED_LENGTH, 0);
|
||||
if (lastX != -1)
|
||||
{
|
||||
auto leftTop1 = ScreenCoordsXY{ lastX + 1, lastY + 1 };
|
||||
auto rightBottom1 = ScreenCoordsXY{ x + 1, y + 1 };
|
||||
auto leftTop2 = ScreenCoordsXY{ lastX, lastY + 1 };
|
||||
auto rightBottom2 = ScreenCoordsXY{ x, y + 1 };
|
||||
gfx_draw_line(dpi, { leftTop1, rightBottom1 }, PALETTE_INDEX_10);
|
||||
gfx_draw_line(dpi, { leftTop2, rightBottom2 }, PALETTE_INDEX_10);
|
||||
}
|
||||
if (i == 0)
|
||||
gfx_fill_rect(dpi, { { x, y }, { x + 2, y + 2 } }, PALETTE_INDEX_10);
|
||||
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
}
|
||||
x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
gfx_draw_string_centred(
|
||||
dpi, STR_FINANCES_SUMMARY_EXPENDITURE_VALUE, info.coords - ScreenCoordsXY{ 0, 16 }, COLOUR_BLACK, &info.money);
|
||||
static void DrawLineB(
|
||||
rct_drawpixelinfo* dpi, const money32* history, int32_t count, int32_t baseX, int32_t baseY, int32_t modifier,
|
||||
int32_t offset)
|
||||
{
|
||||
int32_t i, x, y, lastX, lastY;
|
||||
|
||||
gfx_fill_rect(dpi, { { info.coords - ScreenCoordsXY{ 2, 2 } }, info.coords + ScreenCoordsXY{ 2, 2 } }, PALETTE_INDEX_10);
|
||||
gfx_fill_rect(
|
||||
dpi, { { info.coords - ScreenCoordsXY{ 1, 1 } }, { info.coords + ScreenCoordsXY{ 1, 1 } } }, PALETTE_INDEX_21);
|
||||
}
|
||||
lastX = -1;
|
||||
lastY = -1;
|
||||
x = baseX;
|
||||
for (i = count - 1; i >= 0; i--)
|
||||
{
|
||||
if (history[i] != MONEY32_UNDEFINED)
|
||||
{
|
||||
y = baseY + 170 - 6 - ((((history[i] >> modifier) + offset) * 170) / 256);
|
||||
|
||||
void graph_draw_money32(
|
||||
rct_drawpixelinfo* dpi, const money32* history, const int32_t count, const int32_t baseX, const int32_t baseY,
|
||||
const int32_t modifier, const int32_t offset)
|
||||
{
|
||||
graph_draw_months_money32(dpi, history, count, baseX, baseY);
|
||||
graph_draw_line_a_money32(dpi, history, count, baseX, baseY, modifier, offset);
|
||||
graph_draw_line_b_money32(dpi, history, count, baseX, baseY, modifier, offset);
|
||||
graph_draw_hovered_value(dpi, history, count, baseX, baseY, modifier, offset);
|
||||
}
|
||||
if (lastX != -1)
|
||||
{
|
||||
auto leftTop = ScreenCoordsXY{ lastX, lastY };
|
||||
auto rightBottom = ScreenCoordsXY{ x, y };
|
||||
gfx_draw_line(dpi, { leftTop, rightBottom }, PALETTE_INDEX_21);
|
||||
}
|
||||
if (i == 0)
|
||||
gfx_fill_rect(dpi, { { x - 1, y - 1 }, { x + 1, y + 1 } }, PALETTE_INDEX_21);
|
||||
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
}
|
||||
x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawHoveredValue(
|
||||
rct_drawpixelinfo* dpi, const money32* history, const int32_t historyCount, const int32_t baseX, const int32_t baseY,
|
||||
const int32_t modifier, const int32_t offset)
|
||||
{
|
||||
const auto cursorPosition = context_get_cursor_position_scaled();
|
||||
const ScreenRect chartFrame{ { baseX, baseY }, { baseX + ChartMaxWidth, baseY + ChartMaxHeight } };
|
||||
|
||||
if (!chartFrame.Contains(cursorPosition))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto info = finance_tooltip_info_from_money(
|
||||
history, ChartMaxDataCount, modifier, offset, chartFrame, cursorPosition);
|
||||
|
||||
if (info.money == MONEY32_UNDEFINED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
gfx_draw_dashed_line(dpi, { { info.coords.x, chartFrame.GetTop() }, info.coords }, DefaultDashedLength, 0);
|
||||
gfx_draw_dashed_line(dpi, { { chartFrame.GetLeft() - 10, info.coords.y }, info.coords }, DefaultDashedLength, 0);
|
||||
|
||||
if (cursorPosition.y > info.coords.y)
|
||||
{
|
||||
gfx_draw_dashed_line(dpi, { info.coords, { info.coords.x, cursorPosition.y } }, DefaultDashedLength, 0);
|
||||
}
|
||||
|
||||
gfx_draw_string_centred(
|
||||
dpi, STR_FINANCES_SUMMARY_EXPENDITURE_VALUE, info.coords - ScreenCoordsXY{ 0, 16 }, COLOUR_BLACK, &info.money);
|
||||
|
||||
gfx_fill_rect(
|
||||
dpi, { { info.coords - ScreenCoordsXY{ 2, 2 } }, info.coords + ScreenCoordsXY{ 2, 2 } }, PALETTE_INDEX_10);
|
||||
gfx_fill_rect(
|
||||
dpi, { { info.coords - ScreenCoordsXY{ 1, 1 } }, { info.coords + ScreenCoordsXY{ 1, 1 } } }, PALETTE_INDEX_21);
|
||||
}
|
||||
|
||||
void Draw(
|
||||
rct_drawpixelinfo* dpi, const money32* history, const int32_t count, const int32_t baseX, const int32_t baseY,
|
||||
const int32_t modifier, const int32_t offset)
|
||||
{
|
||||
DrawMonths(dpi, history, count, baseX, baseY);
|
||||
DrawLineA(dpi, history, count, baseX, baseY, modifier, offset);
|
||||
DrawLineB(dpi, history, count, baseX, baseY, modifier, offset);
|
||||
DrawHoveredValue(dpi, history, count, baseX, baseY, modifier, offset);
|
||||
}
|
||||
} // namespace Graph
|
||||
|
||||
@@ -13,9 +13,12 @@
|
||||
#include <openrct2/common.h>
|
||||
#include <openrct2/drawing/Drawing.h>
|
||||
|
||||
void graph_draw_uint8_t(rct_drawpixelinfo* dpi, uint8_t* history, int32_t count, int32_t baseX, int32_t baseY);
|
||||
void graph_draw_money32(
|
||||
rct_drawpixelinfo* dpi, const money32* history, const int32_t count, const int32_t baseX, const int32_t baseY,
|
||||
const int32_t modifier, const int32_t offset);
|
||||
namespace Graph
|
||||
{
|
||||
void Draw(rct_drawpixelinfo* dpi, uint8_t* history, int32_t count, int32_t baseX, int32_t baseY);
|
||||
void Draw(
|
||||
rct_drawpixelinfo* dpi, const money32* history, const int32_t count, const int32_t baseX, const int32_t baseY,
|
||||
const int32_t modifier, const int32_t offset);
|
||||
} // namespace Graph
|
||||
|
||||
#endif
|
||||
|
||||
@@ -766,7 +766,7 @@ static void window_finances_financial_graph_paint(rct_window* w, rct_drawpixelin
|
||||
// X axis labels and values
|
||||
x = graphLeft + 98;
|
||||
y = graphTop + 17;
|
||||
graph_draw_money32(dpi, gCashHistory, 64, x, y, yAxisScale, 128);
|
||||
Graph::Draw(dpi, gCashHistory, 64, x, y, yAxisScale, 128);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
@@ -871,7 +871,7 @@ static void window_finances_park_value_graph_paint(rct_window* w, rct_drawpixeli
|
||||
// X axis labels and values
|
||||
x = graphLeft + 98;
|
||||
y = graphTop + 17;
|
||||
graph_draw_money32(dpi, gParkValueHistory, 64, x, y, yAxisScale, 0);
|
||||
Graph::Draw(dpi, gParkValueHistory, 64, x, y, yAxisScale, 0);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
@@ -979,7 +979,7 @@ static void window_finances_profit_graph_paint(rct_window* w, rct_drawpixelinfo*
|
||||
|
||||
// X axis labels and values
|
||||
screenPos = { graphLeft + 98, graphTop + 17 };
|
||||
graph_draw_money32(dpi, gWeeklyProfitHistory, 64, screenPos.x, screenPos.y, yAxisScale, 128);
|
||||
Graph::Draw(dpi, gWeeklyProfitHistory, 64, screenPos.x, screenPos.y, yAxisScale, 128);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
@@ -926,7 +926,7 @@ static void window_park_rating_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
// Graph
|
||||
screenPos = w->windowPos + ScreenCoordsXY{ widget->left + 47, widget->top + 26 };
|
||||
|
||||
graph_draw_uint8_t(dpi, gParkRatingHistory, 32, screenPos.x, screenPos.y);
|
||||
Graph::Draw(dpi, gParkRatingHistory, 32, screenPos.x, screenPos.y);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
@@ -1061,7 +1061,7 @@ static void window_park_guests_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
// Graph
|
||||
screenPos = w->windowPos + ScreenCoordsXY{ widget->left + 47, widget->top + 26 };
|
||||
|
||||
graph_draw_uint8_t(dpi, gGuestsInParkHistory, 32, screenPos.x, screenPos.y);
|
||||
Graph::Draw(dpi, gGuestsInParkHistory, 32, screenPos.x, screenPos.y);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
Reference in New Issue
Block a user