Redraw connecting link graph overlay links when moving station sign

Add test console command
This commit is contained in:
Jonathan G Rennison
2020-09-18 18:58:16 +01:00
parent a0f78a8071
commit 3b49f892fa
6 changed files with 104 additions and 2 deletions

View File

@@ -16,6 +16,7 @@
#include "../viewport_func.h"
#include "../smallmap_gui.h"
#include "../zoom_func.h"
#include "../landscape.h"
#include "../core/geometry_func.hpp"
#include "../widgets/link_graph_legend_widget.h"
@@ -81,6 +82,29 @@ bool LinkGraphOverlay::CacheStillValid() const
}
}
void LinkGraphOverlay::MarkStationViewportLinksDirty(const Station *st)
{
if (this->window->viewport) {
Viewport *vp = this->window->viewport;
const Point pt = RemapCoords2(TileX(st->xy) * TILE_SIZE, TileY(st->xy) * TILE_SIZE);
const int padding = ScaleByZoom(3 * this->scale, vp->zoom);
MarkViewportDirty(vp, pt.x - padding, pt.y - padding, pt.x + padding, pt.y - padding);
const int block_radius = ScaleByZoom(10, vp->zoom);
for (LinkList::iterator i(this->cached_links.begin()); i != this->cached_links.end(); ++i) {
if (i->from_id == st->index) {
const Station *stb = Station::GetIfValid(i->to_id);
if (stb == nullptr) continue;
MarkViewportLineDirty(vp, pt, RemapCoords2(TileX(stb->xy) * TILE_SIZE, TileY(stb->xy) * TILE_SIZE), block_radius);
} else if (i->to_id == st->index) {
const Station *sta = Station::GetIfValid(i->from_id);
if (sta == nullptr) continue;
MarkViewportLineDirty(vp, RemapCoords2(TileX(sta->xy) * TILE_SIZE, TileY(sta->xy) * TILE_SIZE), pt, block_radius);
}
}
}
}
/**
* Rebuild the cache and recalculate which links and stations to be shown.
*/