diff options
Diffstat (limited to 'src/toolbar_gui.cpp')
-rw-r--r-- | src/toolbar_gui.cpp | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 7cb18de3d..c583b1506 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -13,7 +13,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" @@ -22,6 +25,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" @@ -874,10 +878,54 @@ static CallBackFunction MenuClickBuildAir(int index) static CallBackFunction ToolbarForestClick(Window *w) { - PopupMainToolbMenu(w, WID_TN_LANDSCAPE, STR_LANDSCAPING_MENU_LANDSCAPING, 3); + // ПОДЗЕМЕЛЬЕ: + // Временно все меню будет храниться здесь. С пункта 3 и выше + PopupMainToolbMenu(w, WID_TN_LANDSCAPE, STR_LANDSCAPING_MENU_LANDSCAPING, 10); 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. * @@ -891,6 +939,7 @@ static CallBackFunction MenuClickForest(int index) case 1: ShowBuildTreesToolbar(); break; case 2: return SelectSignTool(); } + ToMenuClickUnderground(index); return CBF_NONE; } |