mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-17 12:03:07 +01:00
@@ -248,13 +248,12 @@ static void graph_draw_hovered_value(
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gfx_draw_dashed_line(dpi, info.coords.x, chartFrame.GetTop(), info.coords.x, info.coords.y, DEFAULT_DASHED_LENGTH, 0);
|
||||
gfx_draw_dashed_line(dpi, chartFrame.GetLeft() - 10, info.coords.y, info.coords.x, info.coords.y, DEFAULT_DASHED_LENGTH, 0);
|
||||
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);
|
||||
|
||||
if (cursorPosition.y > info.coords.y)
|
||||
{
|
||||
gfx_draw_dashed_line(dpi, info.coords.x, info.coords.y, info.coords.x, cursorPosition.y, DEFAULT_DASHED_LENGTH, 0);
|
||||
gfx_draw_dashed_line(dpi, { info.coords, { info.coords.x, cursorPosition.y } }, DEFAULT_DASHED_LENGTH, 0);
|
||||
}
|
||||
|
||||
gfx_draw_string_centred(
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
struct ScreenCoordsXY;
|
||||
|
||||
struct ScreenCoordsXY;
|
||||
struct ScreenLine;
|
||||
namespace OpenRCT2
|
||||
{
|
||||
interface IPlatformEnvironment;
|
||||
@@ -601,7 +602,7 @@ void gfx_draw_pickedup_peep(rct_drawpixelinfo* dpi);
|
||||
void gfx_draw_line(rct_drawpixelinfo* dpi, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t colour);
|
||||
void gfx_draw_line_software(rct_drawpixelinfo* dpi, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t colour);
|
||||
void gfx_draw_dashed_line(
|
||||
rct_drawpixelinfo* dpi, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t dashedLineSegmentLength, int32_t colour);
|
||||
rct_drawpixelinfo* dpi, const ScreenLine& screenLine, const int32_t dashedLineSegmentLength, const int32_t color);
|
||||
|
||||
// rect
|
||||
void gfx_fill_rect(rct_drawpixelinfo* dpi, int32_t left, int32_t top, int32_t right, int32_t bottom, int32_t colour);
|
||||
|
||||
@@ -212,8 +212,7 @@ void gfx_draw_line(rct_drawpixelinfo* dpi, int32_t x1, int32_t y1, int32_t x2, i
|
||||
}
|
||||
|
||||
void gfx_draw_dashed_line(
|
||||
rct_drawpixelinfo* dpi, const int32_t x1, const int32_t y1, const int32_t x2, const int32_t y2,
|
||||
const int32_t dashedLineSegmentLength, const int32_t colour)
|
||||
rct_drawpixelinfo* dpi, const ScreenLine& screenLine, const int32_t dashedLineSegmentLength, const int32_t color)
|
||||
{
|
||||
assert(dashedLineSegmentLength > 0);
|
||||
|
||||
@@ -222,24 +221,25 @@ void gfx_draw_dashed_line(
|
||||
{
|
||||
constexpr int32_t precisionFactor = 1000;
|
||||
|
||||
const int32_t dashedLineLength = std::hypot(x2 - x1, y2 - y1);
|
||||
const int32_t dashedLineLength = std::hypot(
|
||||
screenLine.GetRight() - screenLine.GetLeft(), screenLine.GetBottom() - screenLine.GetTop());
|
||||
const int32_t lineSegmentCount = dashedLineLength / dashedLineSegmentLength / 2;
|
||||
if (lineSegmentCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const int32_t lineXDist = std::abs(x2 - x1);
|
||||
const int32_t lineYDist = std::abs(y2 - y1);
|
||||
const int32_t lineXDist = std::abs(screenLine.GetRight() - screenLine.GetLeft());
|
||||
const int32_t lineYDist = std::abs(screenLine.GetBottom() - screenLine.GetTop());
|
||||
const int32_t dxPrecise = precisionFactor * lineXDist / lineSegmentCount / 2;
|
||||
const int32_t dyPrecise = precisionFactor * lineYDist / lineSegmentCount / 2;
|
||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
||||
|
||||
for (int32_t i = 0, x, y; i < lineSegmentCount; ++i)
|
||||
{
|
||||
x = x1 + dxPrecise * i * 2 / precisionFactor;
|
||||
y = y1 + dyPrecise * i * 2 / precisionFactor;
|
||||
dc->DrawLine(colour, x, y, x + dxPrecise / precisionFactor, y + dyPrecise / precisionFactor);
|
||||
x = screenLine.GetLeft() + dxPrecise * i * 2 / precisionFactor;
|
||||
y = screenLine.GetTop() + dyPrecise * i * 2 / precisionFactor;
|
||||
dc->DrawLine(color, x, y, x + dxPrecise / precisionFactor, y + dyPrecise / precisionFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user