summaryrefslogtreecommitdiff
path: root/src/toolbar_gui.cpp
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-10-30 11:13:12 +0100
committerErich Eckner <git@eckner.net>2022-01-16 21:58:15 +0100
commit0c5ba5b7bf9a9dfa78c026f4da656940a460f47d (patch)
treed2a44494bbd70425b8f9e0e22b8c4e4dd8223001 /src/toolbar_gui.cpp
parent523901887827768d6bff347ddb57787b295cc9e1 (diff)
downloadopenttd-0c5ba5b7bf9a9dfa78c026f4da656940a460f47d.tar.xz
underground patch applied
Diffstat (limited to 'src/toolbar_gui.cpp')
-rw-r--r--src/toolbar_gui.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index 13c52f2b4..068a1962e 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -11,7 +11,10 @@
#include "gui.h"
#include "window_gui.h"
#include "window_func.h"
+#include "layer_gui.h"
+#include "layer_func.h"
#include "viewport_func.h"
+#include "landscape.h"
#include "command_func.h"
#include "vehicle_gui.h"
#include "rail_gui.h"
@@ -21,6 +24,7 @@
#include "vehicle_func.h"
#include "sound_func.h"
#include "terraform_gui.h"
+#include "underground_gui.h"
#include "strings_func.h"
#include "company_func.h"
#include "company_gui.h"
@@ -980,6 +984,48 @@ static CallBackFunction ToolbarForestClick(Window *w)
return CBF_NONE;
}
+bool ScrollWindowRel(ViewportData *viewport, int dx, int dy)
+{
+ Point pt = RemapCoords(dx, dy, 0);
+
+ viewport->dest_scrollpos_x += pt.x;
+ viewport->dest_scrollpos_y += pt.y;
+ return true;
+}
+
+void SelectLayer(ViewportData *viewport, int layer)
+{
+ if (layer < 0) layer = 0;
+ if (uint(layer) >= LayerCount()) layer = LayerCount() - 1;
+
+ int delta_layer = calculateLayer(viewport) - layer;
+ bool res = ScrollWindowRel(viewport, 0, -delta_layer * LayerSizeY() * TILE_SIZE);
+}
+
+void SelectLayerInMainWindow(int layer)
+{
+ Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
+ SelectLayer(w->viewport, layer);
+ w->InvalidateData();
+}
+
+/**
+ * Handle click on the entry in the underground menu.
+ *
+ * @param index Menu entry clicked.
+ */
+static void ToMenuClickUnderground(int index)
+{
+ switch (index) {
+ case 4: ShowUndergroundToolbar(); break;
+
+ case 6: SelectLayerInMainWindow(index-6); break;
+ case 7: SelectLayerInMainWindow(index-6); break;
+ case 8: SelectLayerInMainWindow(index-6); break;
+ case 9: SelectLayerInMainWindow(index-6); break;
+ }
+}
+
/**
* Handle click on the entry in the landscaping menu.
*
@@ -993,6 +1039,7 @@ static CallBackFunction MenuClickForest(int index)
case 1: ShowBuildTreesToolbar(); break;
case 2: return SelectSignTool();
}
+ ToMenuClickUnderground(index);
return CBF_NONE;
}