Viewport: Do bounding boxes and link graph/route overlays in threaded part
This commit is contained in:
@@ -381,10 +381,9 @@ void LinkGraphOverlay::RefreshDrawCache()
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the linkgraph overlay or some part of it, in the area given.
|
||||
* @param dpi Area to be drawn to.
|
||||
* Prepare to draw the linkgraph overlay or some part of it.
|
||||
*/
|
||||
void LinkGraphOverlay::Draw(const DrawPixelInfo *dpi)
|
||||
void LinkGraphOverlay::PrepareDraw()
|
||||
{
|
||||
if (this->dirty) {
|
||||
this->RebuildCache();
|
||||
@@ -394,6 +393,14 @@ void LinkGraphOverlay::Draw(const DrawPixelInfo *dpi)
|
||||
this->last_update_number = GetWindowUpdateNumber();
|
||||
this->RefreshDrawCache();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the linkgraph overlay or some part of it, in the area given.
|
||||
* @param dpi Area to be drawn to.
|
||||
*/
|
||||
void LinkGraphOverlay::Draw(const DrawPixelInfo *dpi) const
|
||||
{
|
||||
this->DrawLinks(dpi);
|
||||
this->DrawStationDots(dpi);
|
||||
}
|
||||
@@ -409,7 +416,7 @@ void LinkGraphOverlay::DrawLinks(const DrawPixelInfo *dpi) const
|
||||
if (!this->IsLinkVisible(i->from_pt, i->to_pt, dpi, width + 2)) continue;
|
||||
if (!Station::IsValidID(i->from_id)) continue;
|
||||
if (!Station::IsValidID(i->to_id)) continue;
|
||||
this->DrawContent(i->from_pt, i->to_pt, i->prop);
|
||||
this->DrawContent(dpi, i->from_pt, i->to_pt, i->prop);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,7 +426,7 @@ void LinkGraphOverlay::DrawLinks(const DrawPixelInfo *dpi) const
|
||||
* @param ptb Destination of the link.
|
||||
* @param cargo Properties of the link.
|
||||
*/
|
||||
void LinkGraphOverlay::DrawContent(Point pta, Point ptb, const LinkProperties &cargo) const
|
||||
void LinkGraphOverlay::DrawContent(const DrawPixelInfo *dpi, Point pta, Point ptb, const LinkProperties &cargo) const
|
||||
{
|
||||
uint usage_or_plan = std::min(cargo.capacity * 2 + 1, cargo.Usage());
|
||||
int colour = LinkGraphOverlay::LINK_COLOURS[_settings_client.gui.linkgraph_colours][usage_or_plan * lengthof(LinkGraphOverlay::LINK_COLOURS[0]) / (cargo.capacity * 2 + 2)];
|
||||
@@ -431,13 +438,13 @@ void LinkGraphOverlay::DrawContent(Point pta, Point ptb, const LinkProperties &c
|
||||
int side = _settings_game.vehicle.road_side ? 1 : -1;
|
||||
if (abs(pta.x - ptb.x) < abs(pta.y - ptb.y)) {
|
||||
int offset_x = (pta.y > ptb.y ? 1 : -1) * side * width;
|
||||
GfxDrawLine(pta.x + offset_x, pta.y, ptb.x + offset_x, ptb.y, colour, width, dash);
|
||||
GfxDrawLine(dpi, pta.x + offset_x, pta.y, ptb.x + offset_x, ptb.y, colour, width, dash);
|
||||
} else {
|
||||
int offset_y = (pta.x < ptb.x ? 1 : -1) * side * width;
|
||||
GfxDrawLine(pta.x, pta.y + offset_y, ptb.x, ptb.y + offset_y, colour, width, dash);
|
||||
GfxDrawLine(dpi, pta.x, pta.y + offset_y, ptb.x, ptb.y + offset_y, colour, width, dash);
|
||||
}
|
||||
|
||||
GfxDrawLine(pta.x, pta.y, ptb.x, ptb.y, _colour_gradient[COLOUR_GREY][1], width);
|
||||
GfxDrawLine(dpi, pta.x, pta.y, ptb.x, ptb.y, _colour_gradient[COLOUR_GREY][1], width);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -456,7 +463,7 @@ void LinkGraphOverlay::DrawStationDots(const DrawPixelInfo *dpi) const
|
||||
|
||||
uint r = width * 2 + width * 2 * std::min<uint>(200, i->quantity) / 200;
|
||||
|
||||
LinkGraphOverlay::DrawVertex(pt.x, pt.y, r,
|
||||
LinkGraphOverlay::DrawVertex(dpi, pt.x, pt.y, r,
|
||||
_colour_gradient[st->owner != OWNER_NONE ?
|
||||
(Colours)Company::Get(st->owner)->colour : COLOUR_GREY][5],
|
||||
_colour_gradient[COLOUR_GREY][1]);
|
||||
@@ -471,20 +478,20 @@ void LinkGraphOverlay::DrawStationDots(const DrawPixelInfo *dpi) const
|
||||
* @param colour Colour with which the vertex will be filled.
|
||||
* @param border_colour Colour for the border of the vertex.
|
||||
*/
|
||||
/* static */ void LinkGraphOverlay::DrawVertex(int x, int y, int size, int colour, int border_colour)
|
||||
/* static */ void LinkGraphOverlay::DrawVertex(const DrawPixelInfo *dpi, int x, int y, int size, int colour, int border_colour)
|
||||
{
|
||||
size--;
|
||||
int w1 = size / 2;
|
||||
int w2 = size / 2 + size % 2;
|
||||
|
||||
GfxFillRect(x - w1, y - w1, x + w2, y + w2, colour);
|
||||
GfxFillRect(dpi, x - w1, y - w1, x + w2, y + w2, colour);
|
||||
|
||||
w1++;
|
||||
w2++;
|
||||
GfxDrawLine(x - w1, y - w1, x + w2, y - w1, border_colour);
|
||||
GfxDrawLine(x - w1, y + w2, x + w2, y + w2, border_colour);
|
||||
GfxDrawLine(x - w1, y - w1, x - w1, y + w2, border_colour);
|
||||
GfxDrawLine(x + w2, y - w1, x + w2, y + w2, border_colour);
|
||||
GfxDrawLine(dpi, x - w1, y - w1, x + w2, y - w1, border_colour);
|
||||
GfxDrawLine(dpi, x - w1, y + w2, x + w2, y + w2, border_colour);
|
||||
GfxDrawLine(dpi, x - w1, y - w1, x - w1, y + w2, border_colour);
|
||||
GfxDrawLine(dpi, x + w2, y - w1, x + w2, y + w2, border_colour);
|
||||
}
|
||||
|
||||
bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond)
|
||||
|
Reference in New Issue
Block a user