diff options
author | rubidium <rubidium@openttd.org> | 2013-05-19 14:49:25 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2013-05-19 14:49:25 +0000 |
commit | ef7befdbd8b0d30e6ce121f4348799692b66d0ba (patch) | |
tree | 28be79f13ddeae1d11020509170c094fdf416746 /src/main_gui.cpp | |
parent | 50ae992b47f581d8a50892942438bfe7e3f62141 (diff) | |
download | openttd-ef7befdbd8b0d30e6ce121f4348799692b66d0ba.tar.xz |
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
Diffstat (limited to 'src/main_gui.cpp')
-rw-r--r-- | src/main_gui.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 5cced077f..235238e4b 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -29,6 +29,7 @@ #include "company_func.h" #include "toolbar_gui.h" #include "statusbar_gui.h" +#include "linkgraph/linkgraph_gui.h" #include "tilehighlight_func.h" #include "hotkeys.h" @@ -239,6 +240,11 @@ enum { struct MainWindow : Window { + uint refresh; + + static const uint LINKGRAPH_REFRESH_PERIOD = 0xff; + static const uint LINKGRAPH_DELAY = 0xf; + MainWindow() : Window() { this->InitNested(&_main_window_desc, 0); @@ -247,6 +253,18 @@ struct MainWindow : Window NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_M_VIEWPORT); nvp->InitializeViewport(this, TileXY(32, 32), ZOOM_LVL_VIEWPORT); + + this->viewport->overlay = new LinkGraphOverlay(this, WID_M_VIEWPORT, 0, 0, 3); + this->refresh = LINKGRAPH_DELAY; + } + + virtual void OnTick() + { + if (--refresh == 0) { + this->viewport->overlay->RebuildCache(); + this->GetWidget<NWidgetBase>(WID_M_VIEWPORT)->SetDirty(this); + this->refresh = LINKGRAPH_REFRESH_PERIOD; + } } virtual void OnPaint() @@ -416,6 +434,7 @@ struct MainWindow : Window this->viewport->scrollpos_y += ScaleByZoom(delta.y, this->viewport->zoom); this->viewport->dest_scrollpos_x = this->viewport->scrollpos_x; this->viewport->dest_scrollpos_y = this->viewport->scrollpos_y; + this->refresh = LINKGRAPH_DELAY; } virtual void OnMouseWheel(int wheel) @@ -430,6 +449,7 @@ struct MainWindow : Window if (this->viewport != NULL) { NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_M_VIEWPORT); nvp->UpdateViewportCoordinates(this); + this->refresh = LINKGRAPH_DELAY; } } |