diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lang/english.txt | 5 | ||||
-rw-r--r-- | src/lang/russian.txt | 5 | ||||
-rw-r--r-- | src/toolbar_gui.cpp | 149 | ||||
-rw-r--r-- | src/widgets/toolbar_widget.h | 1 |
4 files changed, 108 insertions, 52 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt index a2a8645d9..82a8c3a5e 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -455,9 +455,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 -STR_LANDSCAPING_MENU_SEPARATOR1 : +############ range ends here + +############ 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 1648e903b..88d19d740 100644 --- a/src/lang/russian.txt +++ b/src/lang/russian.txt @@ -581,9 +581,10 @@ STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION :Строите STR_LANDSCAPING_MENU_LANDSCAPING :Ландшафт STR_LANDSCAPING_MENU_PLANT_TREES :Высадка деревьев STR_LANDSCAPING_MENU_PLACE_SIGN :Поставить метку -STR_LANDSCAPING_MENU_SEPARATOR1 : +############ range ends here + +############ range for underground menu starts 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 eceff4e94..b9b2fbd31 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -972,68 +972,56 @@ static CallBackFunction MenuClickBuildAir(int index) static CallBackFunction ToolbarForestClick(Window *w) { - // : - // . 3 - PopupMainToolbMenu(w, WID_TN_LANDSCAPE, STR_LANDSCAPING_MENU_LANDSCAPING, 10); + PopupMainToolbMenu(w, WID_TN_LANDSCAPE, STR_LANDSCAPING_MENU_LANDSCAPING, 3); 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; } @@ -1352,9 +1340,10 @@ static MenuClickedProc * const _menu_clicked_procs[] = { MenuClickBuildWater, // 23 MenuClickBuildAir, // 24 MenuClickForest, // 25 - MenuClickMusicWindow, // 26 - MenuClickNewspaper, // 27 - MenuClickHelp, // 28 + MenuClickUnderground, // 26 + MenuClickMusicWindow, // 27 + MenuClickNewspaper, // 28 + MenuClickHelp, // 29 }; /** Full blown container to make it behave exactly as we want :) */ @@ -1519,7 +1508,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { /* virtual */ const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const { 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. @@ -1786,6 +1775,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, @@ -1813,6 +1863,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 @@ -1827,7 +1878,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; @@ -1978,6 +2029,7 @@ static ToolbarButtonProc * const _toolbar_button_procs[] = { ToolbarBuildWaterClick, ToolbarBuildAirClick, ToolbarForestClick, + ToolbarUndergroundClick, ToolbarMusicClick, ToolbarNewspaperClick, ToolbarHelpClick, @@ -2260,6 +2312,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 c317fc957..280d0f969 100644 --- a/src/widgets/toolbar_widget.h +++ b/src/widgets/toolbar_widget.h @@ -42,6 +42,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. |