diff options
author | Erich Eckner <git@eckner.net> | 2018-11-06 10:32:32 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2022-01-16 21:58:16 +0100 |
commit | 94e9383935c0d2b12d067748b18c757f73a93fad (patch) | |
tree | 348e4c3026a21f841b0605b8c94f92c3e1176705 | |
parent | 064f10e263a1609727ba1ed96d05e53187ca47f1 (diff) | |
download | openttd-94e9383935c0d2b12d067748b18c757f73a93fad.tar.xz |
separate menu entry for underground stuff
-rw-r--r-- | src/lang/english.txt | 4 | ||||
-rw-r--r-- | src/lang/russian.txt | 3 | ||||
-rw-r--r-- | src/toolbar_gui.cpp | 145 | ||||
-rw-r--r-- | src/widgets/toolbar_widget.h | 1 |
4 files changed, 104 insertions, 49 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt index aeefcb49f..5381a0105 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -477,10 +477,10 @@ STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION :Airport constru STR_LANDSCAPING_MENU_LANDSCAPING :Landscaping STR_LANDSCAPING_MENU_PLANT_TREES :Plant trees STR_LANDSCAPING_MENU_PLACE_SIGN :Place sign +############ range ends here -STR_LANDSCAPING_MENU_SEPARATOR1 : +############ range for underground menu starts STR_LANDSCAPING_MENU_UNDERGROUND :Special constructions -STR_LANDSCAPING_MENU_SEPARATOR2 : STR_LANDSCAPING_MENU_LAYER_1 :Surface STR_LANDSCAPING_MENU_LAYER_2 :Undergroound (-1) STR_LANDSCAPING_MENU_LAYER_3 :Undergroound (-2) diff --git a/src/lang/russian.txt b/src/lang/russian.txt index c4c113f45..eca8f7891 100644 --- a/src/lang/russian.txt +++ b/src/lang/russian.txt @@ -605,10 +605,9 @@ STR_LANDSCAPING_MENU_PLANT_TREES :Высадка STR_LANDSCAPING_MENU_PLACE_SIGN :Поставить метку # Underground menu -###length 7 +###length 6 STR_LANDSCAPING_MENU_SEPARATOR1 : STR_LANDSCAPING_MENU_UNDERGROUND :Спец. конструкции -STR_LANDSCAPING_MENU_SEPARATOR2 : STR_LANDSCAPING_MENU_LAYER_1 :Поверхность STR_LANDSCAPING_MENU_LAYER_2 :Подземелье (-1) STR_LANDSCAPING_MENU_LAYER_3 :Подземелье (-2) diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 068a1962e..b0a00a383 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -984,62 +984,52 @@ 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. + * Handle click on the entry in the landscaping menu. * * @param index Menu entry clicked. + * @return #CBF_NONE */ -static void ToMenuClickUnderground(int index) +static CallBackFunction MenuClickForest(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; + case 0: ShowTerraformToolbar(); break; + case 1: ShowBuildTreesToolbar(); break; + case 2: return SelectSignTool(); } + return CBF_NONE; } +/* --- Underground button menu --- */ + /** - * Handle click on the entry in the landscaping menu. + * Handle click on the entry in the underground menu. * * @param index Menu entry clicked. * @return #CBF_NONE */ -static CallBackFunction MenuClickForest(int index) +static CallBackFunction MenuClickUnderground(int index) { - switch (index) { - case 0: ShowTerraformToolbar(); break; - case 1: ShowBuildTreesToolbar(); break; - case 2: return SelectSignTool(); + if (index==0) { + ShowUndergroundToolbar(); + return CBF_NONE; } - ToMenuClickUnderground(index); + index -= 1; + if ((index<0) || (uint(index) >= LayerCount())) + return CBF_NONE; + Window *w = FindWindowById(WC_MAIN_WINDOW, 0); + int delta_layer = calculateLayer(w->viewport) - index; + Point pt = RemapCoords(0, -delta_layer * LayerSizeY() * TILE_SIZE, 0); + w->viewport->dest_scrollpos_x += pt.x; + w->viewport->dest_scrollpos_y += pt.y; + w->InvalidateData(); + return CBF_NONE; +} + +static CallBackFunction ToolbarUndergroundClick(Window *w) +{ + PopupMainToolbMenu(w, WID_TN_UNDERGROUND, STR_LANDSCAPING_MENU_UNDERGROUND, 5); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -1353,9 +1343,10 @@ static MenuClickedProc * const _menu_clicked_procs[] = { MenuClickBuildWater, // 24 MenuClickBuildAir, // 25 MenuClickForest, // 26 - MenuClickMusicWindow, // 27 - MenuClickNewspaper, // 28 - MenuClickHelp, // 29 + MenuClickUnderground, // 27 + MenuClickMusicWindow, // 28 + MenuClickNewspaper, // 29 + MenuClickHelp, // 30 }; /** Full blown container to make it behave exactly as we want :) */ @@ -1520,7 +1511,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override { static const uint SMALLEST_ARRANGEMENT = 14; - static const uint BIGGEST_ARRANGEMENT = 20; + static const uint BIGGEST_ARRANGEMENT = 21; /* The number of buttons of each row of the toolbar should match the number of items which we want to be visible. * The total number of buttons should be equal to arrangable_count * 2. @@ -1787,6 +1778,67 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { WID_TN_ZOOM_OUT, WID_TN_SWITCH_BAR, }; + static const byte arrange21[] = { + WID_TN_PAUSE, + WID_TN_FAST_FORWARD, + WID_TN_SETTINGS, + WID_TN_SMALL_MAP, + WID_TN_TOWNS, + WID_TN_SUBSIDIES, + WID_TN_STATIONS, + WID_TN_FINANCES, + WID_TN_COMPANIES, + WID_TN_STORY, + WID_TN_GOAL, + WID_TN_GRAPHS, + WID_TN_LEAGUE, + WID_TN_INDUSTRIES, + WID_TN_TRAINS, + WID_TN_ROADVEHS, + WID_TN_SHIPS, + WID_TN_AIRCRAFT, + WID_TN_ZOOM_IN, + WID_TN_ZOOM_OUT, + WID_TN_RAILS, + WID_TN_ROADS, + WID_TN_WATER, + WID_TN_AIR, + WID_TN_LANDSCAPE, + WID_TN_UNDERGROUND, + WID_TN_MUSIC_SOUND, + WID_TN_MESSAGES, + WID_TN_HELP, + // lower toolbar + WID_TN_PAUSE, + WID_TN_FAST_FORWARD, + WID_TN_SAVE, + WID_TN_SMALL_MAP, + WID_TN_TOWNS, + WID_TN_SUBSIDIES, + WID_TN_STATIONS, + WID_TN_FINANCES, + WID_TN_COMPANIES, + WID_TN_STORY, + WID_TN_GOAL, + WID_TN_GRAPHS, + WID_TN_LEAGUE, + WID_TN_INDUSTRIES, + WID_TN_TRAINS, + WID_TN_ROADVEHS, + WID_TN_SHIPS, + WID_TN_AIRCRAFT, + WID_TN_ZOOM_IN, + WID_TN_ZOOM_OUT, + WID_TN_RAILS, + WID_TN_ROADS, + WID_TN_WATER, + WID_TN_AIR, + WID_TN_LANDSCAPE, + WID_TN_UNDERGROUND, + WID_TN_MUSIC_SOUND, + WID_TN_MESSAGES, + WID_TN_HELP, + }; static const byte arrange_all[] = { WID_TN_PAUSE, WID_TN_FAST_FORWARD, @@ -1815,6 +1867,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { WID_TN_WATER, WID_TN_AIR, WID_TN_LANDSCAPE, + WID_TN_UNDERGROUND, WID_TN_MUSIC_SOUND, WID_TN_MESSAGES, WID_TN_HELP @@ -1829,7 +1882,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { } /* Introduce the split toolbar */ - static const byte * const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20 }; + static const byte * const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20, arrange21 }; button_count = arrangable_count = full_buttons; spacer_count = this->spacers; @@ -1986,6 +2039,7 @@ static ToolbarButtonProc * const _toolbar_button_procs[] = { ToolbarBuildWaterClick, ToolbarBuildAirClick, ToolbarForestClick, + ToolbarUndergroundClick, ToolbarMusicClick, ToolbarNewspaperClick, ToolbarHelpClick, @@ -2234,6 +2288,7 @@ static NWidgetBase *MakeMainToolbar(int *biggest_index) SPR_IMG_BUILDWATER, // WID_TN_WATER SPR_IMG_BUILDAIR, // WID_TN_AIR SPR_IMG_LANDSCAPING, // WID_TN_LANDSCAPE + SPR_IMG_LANDSCAPING, // WID_TN_UNDERGROUND SPR_IMG_MUSIC, // WID_TN_MUSIC_SOUND SPR_IMG_MESSAGES, // WID_TN_MESSAGES SPR_IMG_QUERY, // WID_TN_HELP diff --git a/src/widgets/toolbar_widget.h b/src/widgets/toolbar_widget.h index d68de4970..0b4e53227 100644 --- a/src/widgets/toolbar_widget.h +++ b/src/widgets/toolbar_widget.h @@ -41,6 +41,7 @@ enum ToolbarNormalWidgets { WID_TN_WATER, ///< Water building toolbar. WID_TN_AIR, ///< Airport building toolbar. WID_TN_LANDSCAPE, ///< Landscaping toolbar. + WID_TN_UNDERGROUND, ///< Landscaping toolbar. WID_TN_MUSIC_SOUND, ///< Music/sound configuration menu. WID_TN_MESSAGES, ///< Messages menu. WID_TN_HELP, ///< Help menu. |