OpenTTD Source  1.11.0-beta1
toolbar_gui.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "stdafx.h"
11 #include "gui.h"
12 #include "window_gui.h"
13 #include "window_func.h"
14 #include "viewport_func.h"
15 #include "command_func.h"
16 #include "vehicle_gui.h"
17 #include "rail_gui.h"
18 #include "road.h"
19 #include "road_gui.h"
20 #include "date_func.h"
21 #include "vehicle_func.h"
22 #include "sound_func.h"
23 #include "terraform_gui.h"
24 #include "strings_func.h"
25 #include "company_func.h"
26 #include "company_gui.h"
27 #include "vehicle_base.h"
28 #include "cheat_func.h"
29 #include "transparency_gui.h"
30 #include "screenshot.h"
31 #include "signs_func.h"
32 #include "fios.h"
33 #include "console_gui.h"
34 #include "news_gui.h"
35 #include "ai/ai_gui.hpp"
36 #include "tilehighlight_func.h"
37 #include "smallmap_gui.h"
38 #include "graph_gui.h"
39 #include "textbuf_gui.h"
41 #include "newgrf_debug.h"
42 #include "hotkeys.h"
43 #include "engine_base.h"
44 #include "highscore.h"
45 #include "game/game.hpp"
46 #include "goal_base.h"
47 #include "story_base.h"
48 #include "toolbar_gui.h"
49 #include "framerate_type.h"
50 #include "guitimer_func.h"
51 #include "screenshot_gui.h"
52 
53 #include "widgets/toolbar_widget.h"
54 
55 #include "network/network.h"
56 #include "network/network_gui.h"
57 #include "network/network_func.h"
58 
59 #include "safeguards.h"
60 
61 
63 uint _toolbar_width = 0;
64 
65 RailType _last_built_railtype;
66 RoadType _last_built_roadtype;
67 RoadType _last_built_tramtype;
68 
71  TB_NORMAL,
72  TB_UPPER,
73  TB_LOWER
74 };
75 
78  CBF_NONE,
79  CBF_PLACE_SIGN,
80  CBF_PLACE_LANDINFO,
81 };
82 
84 
85 
90  uint checkmark_width;
91 public:
92  bool checked;
93 
94  DropDownListCheckedItem(StringID string, int result, bool masked, bool checked) : DropDownListStringItem(string, result, masked), checked(checked)
95  {
96  this->checkmark_width = GetStringBoundingBox(STR_JUST_CHECKMARK).width + 3;
97  }
98 
99  uint Width() const
100  {
101  return DropDownListStringItem::Width() + this->checkmark_width;
102  }
103 
104  void Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const
105  {
106  bool rtl = _current_text_dir == TD_RTL;
107  if (this->checked) {
108  DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, STR_JUST_CHECKMARK, sel ? TC_WHITE : TC_BLACK);
109  }
110  DrawString(left + WD_FRAMERECT_LEFT + (rtl ? 0 : this->checkmark_width), right - WD_FRAMERECT_RIGHT - (rtl ? this->checkmark_width : 0), top, this->String(), sel ? TC_WHITE : TC_BLACK);
111  }
112 };
113 
118  Dimension icon_size;
119  Dimension lock_size;
120 public:
121  bool greyed;
122 
123  DropDownListCompanyItem(int result, bool masked, bool greyed) : DropDownListItem(result, masked), greyed(greyed)
124  {
125  this->icon_size = GetSpriteSize(SPR_COMPANY_ICON);
126  this->lock_size = GetSpriteSize(SPR_LOCK);
127  }
128 
129  bool Selectable() const override
130  {
131  return true;
132  }
133 
134  uint Width() const override
135  {
136  CompanyID company = (CompanyID)this->result;
137  SetDParam(0, company);
138  SetDParam(1, company);
139  return GetStringBoundingBox(STR_COMPANY_NAME_COMPANY_NUM).width + this->icon_size.width + this->lock_size.width + 6;
140  }
141 
142  uint Height(uint width) const override
143  {
144  return std::max(std::max(this->icon_size.height, this->lock_size.height) + 2U, (uint)FONT_HEIGHT_NORMAL);
145  }
146 
147  void Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const override
148  {
149  CompanyID company = (CompanyID)this->result;
150  bool rtl = _current_text_dir == TD_RTL;
151 
152  /* It's possible the company is deleted while the dropdown is open */
153  if (!Company::IsValidID(company)) return;
154 
155  int icon_offset = (bottom - top - icon_size.height) / 2;
156  int text_offset = (bottom - top - FONT_HEIGHT_NORMAL) / 2;
157  int lock_offset = (bottom - top - lock_size.height) / 2;
158 
159  DrawCompanyIcon(company, rtl ? right - this->icon_size.width - WD_FRAMERECT_RIGHT : left + WD_FRAMERECT_LEFT, top + icon_offset);
160  if (NetworkCompanyIsPassworded(company)) {
161  DrawSprite(SPR_LOCK, PAL_NONE, rtl ? left + WD_FRAMERECT_LEFT : right - this->lock_size.width - WD_FRAMERECT_RIGHT, top + lock_offset);
162  }
163 
164  SetDParam(0, company);
165  SetDParam(1, company);
166  TextColour col;
167  if (this->greyed) {
168  col = (sel ? TC_SILVER : TC_GREY) | TC_NO_SHADE;
169  } else {
170  col = sel ? TC_WHITE : TC_BLACK;
171  }
172  DrawString(left + WD_FRAMERECT_LEFT + (rtl ? 3 + this->lock_size.width : 3 + this->icon_size.width), right - WD_FRAMERECT_RIGHT - (rtl ? 3 + this->icon_size.width : 3 + this->lock_size.width), top + text_offset, STR_COMPANY_NAME_COMPANY_NUM, col);
173  }
174 };
175 
183 static void PopupMainToolbMenu(Window *w, int widget, DropDownList &&list, int def)
184 {
185  ShowDropDownList(w, std::move(list), def, widget, 0, true, true);
186  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
187 }
188 
196 static void PopupMainToolbMenu(Window *w, int widget, StringID string, int count)
197 {
198  DropDownList list;
199  for (int i = 0; i < count; i++) {
200  list.emplace_back(new DropDownListStringItem(string + i, i, false));
201  }
202  PopupMainToolbMenu(w, widget, std::move(list), 0);
203 }
204 
206 static const int CTMN_CLIENT_LIST = -1;
207 static const int CTMN_NEW_COMPANY = -2;
208 static const int CTMN_SPECTATE = -3;
209 static const int CTMN_SPECTATOR = -4;
210 
217 static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0)
218 {
219  DropDownList list;
220 
221  switch (widget) {
222  case WID_TN_COMPANIES:
223  if (!_networking) break;
224 
225  /* Add the client list button for the companies menu */
226  list.emplace_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, CTMN_CLIENT_LIST, false));
227 
229  list.emplace_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_NEW_COMPANY, CTMN_NEW_COMPANY, NetworkMaxCompaniesReached()));
230  } else {
231  list.emplace_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, NetworkMaxSpectatorsReached()));
232  }
233  break;
234 
235  case WID_TN_STORY:
236  list.emplace_back(new DropDownListStringItem(STR_STORY_BOOK_SPECTATOR, CTMN_SPECTATOR, false));
237  break;
238 
239  case WID_TN_GOAL:
240  list.emplace_back(new DropDownListStringItem(STR_GOALS_SPECTATOR, CTMN_SPECTATOR, false));
241  break;
242  }
243 
244  for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
245  if (!Company::IsValidID(c)) continue;
246  list.emplace_back(new DropDownListCompanyItem(c, false, HasBit(grey, c)));
247  }
248 
250 }
251 
252 
253 static ToolbarMode _toolbar_mode;
254 
255 static CallBackFunction SelectSignTool()
256 {
257  if (_last_started_action == CBF_PLACE_SIGN) {
259  return CBF_NONE;
260  } else {
261  SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, HT_RECT, WC_MAIN_TOOLBAR, 0);
262  return CBF_PLACE_SIGN;
263  }
264 }
265 
266 /* --- Pausing --- */
267 
268 static CallBackFunction ToolbarPauseClick(Window *w)
269 {
270  if (_networking && !_network_server) return CBF_NONE; // only server can pause the game
271 
273  if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP);
274  }
275  return CBF_NONE;
276 }
277 
285 {
286  _fast_forward ^= true;
287  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
288  return CBF_NONE;
289 }
290 
295  OME_GAMEOPTIONS,
296  OME_SETTINGS,
297  OME_SCRIPT_SETTINGS,
298  OME_NEWGRFSETTINGS,
299  OME_TRANSPARENCIES,
300  OME_SHOW_TOWNNAMES,
301  OME_SHOW_STATIONNAMES,
302  OME_SHOW_WAYPOINTNAMES,
303  OME_SHOW_SIGNS,
304  OME_SHOW_COMPETITOR_SIGNS,
305  OME_FULL_ANIMATION,
306  OME_FULL_DETAILS,
307  OME_TRANSPARENTBUILDINGS,
308  OME_SHOW_STATIONSIGNS,
309 };
310 
318 {
319  DropDownList list;
320  list.emplace_back(new DropDownListStringItem(STR_SETTINGS_MENU_GAME_OPTIONS, OME_GAMEOPTIONS, false));
321  list.emplace_back(new DropDownListStringItem(STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE, OME_SETTINGS, false));
322  /* Changes to the per-AI settings don't get send from the server to the clients. Clients get
323  * the settings once they join but never update it. As such don't show the window at all
324  * to network clients. */
325  if (!_networking || _network_server) list.emplace_back(new DropDownListStringItem(STR_SETTINGS_MENU_SCRIPT_SETTINGS, OME_SCRIPT_SETTINGS, false));
326  list.emplace_back(new DropDownListStringItem(STR_SETTINGS_MENU_NEWGRF_SETTINGS, OME_NEWGRFSETTINGS, false));
327  list.emplace_back(new DropDownListStringItem(STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS, OME_TRANSPARENCIES, false));
328  list.emplace_back(new DropDownListItem(-1, false));
329  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED, OME_SHOW_TOWNNAMES, false, HasBit(_display_opt, DO_SHOW_TOWN_NAMES)));
330  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_STATION_NAMES_DISPLAYED, OME_SHOW_STATIONNAMES, false, HasBit(_display_opt, DO_SHOW_STATION_NAMES)));
331  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_WAYPOINTS_DISPLAYED, OME_SHOW_WAYPOINTNAMES, false, HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES)));
332  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_SIGNS_DISPLAYED, OME_SHOW_SIGNS, false, HasBit(_display_opt, DO_SHOW_SIGNS)));
333  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_SHOW_COMPETITOR_SIGNS, OME_SHOW_COMPETITOR_SIGNS, false, HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS)));
334  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_ANIMATION, OME_FULL_ANIMATION, false, HasBit(_display_opt, DO_FULL_ANIMATION)));
335  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_DETAIL, OME_FULL_DETAILS, false, HasBit(_display_opt, DO_FULL_DETAIL)));
336  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS, false, IsTransparencySet(TO_HOUSES)));
337  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS, false, IsTransparencySet(TO_SIGNS)));
338 
339  ShowDropDownList(w, std::move(list), 0, WID_TN_SETTINGS, 140, true, true);
340  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
341  return CBF_NONE;
342 }
343 
351 {
352  switch (index) {
353  case OME_GAMEOPTIONS: ShowGameOptions(); return CBF_NONE;
354  case OME_SETTINGS: ShowGameSettings(); return CBF_NONE;
355  case OME_SCRIPT_SETTINGS: ShowAIConfigWindow(); return CBF_NONE;
356  case OME_NEWGRFSETTINGS: ShowNewGRFSettings(!_networking && _settings_client.gui.UserIsAllowedToChangeNewGRFs(), true, true, &_grfconfig); return CBF_NONE;
357  case OME_TRANSPARENCIES: ShowTransparencyToolbar(); break;
358 
359  case OME_SHOW_TOWNNAMES: ToggleBit(_display_opt, DO_SHOW_TOWN_NAMES); break;
360  case OME_SHOW_STATIONNAMES: ToggleBit(_display_opt, DO_SHOW_STATION_NAMES); break;
361  case OME_SHOW_WAYPOINTNAMES: ToggleBit(_display_opt, DO_SHOW_WAYPOINT_NAMES); break;
362  case OME_SHOW_SIGNS: ToggleBit(_display_opt, DO_SHOW_SIGNS); break;
363  case OME_SHOW_COMPETITOR_SIGNS:
366  break;
367  case OME_FULL_ANIMATION: ToggleBit(_display_opt, DO_FULL_ANIMATION); CheckBlitter(); break;
368  case OME_FULL_DETAILS: ToggleBit(_display_opt, DO_FULL_DETAIL); break;
369  case OME_TRANSPARENTBUILDINGS: ToggleTransparency(TO_HOUSES); break;
370  case OME_SHOW_STATIONSIGNS: ToggleTransparency(TO_SIGNS); break;
371  }
373  return CBF_NONE;
374 }
375 
380  SLEME_SAVE_SCENARIO = 0,
381  SLEME_LOAD_SCENARIO,
382  SLEME_SAVE_HEIGHTMAP,
383  SLEME_LOAD_HEIGHTMAP,
384  SLEME_EXIT_TOINTRO,
385  SLEME_EXIT_GAME = 6,
386  SLEME_MENUCOUNT,
387 };
388 
393  SLNME_SAVE_GAME = 0,
394  SLNME_LOAD_GAME,
395  SLNME_EXIT_TOINTRO,
396  SLNME_EXIT_GAME = 4,
397  SLNME_MENUCOUNT,
398 };
399 
407 {
408  PopupMainToolbMenu(w, WID_TN_SAVE, STR_FILE_MENU_SAVE_GAME, SLNME_MENUCOUNT);
409  return CBF_NONE;
410 }
411 
419 {
420  PopupMainToolbMenu(w, WID_TE_SAVE, STR_SCENEDIT_FILE_MENU_SAVE_SCENARIO, SLEME_MENUCOUNT);
421  return CBF_NONE;
422 }
423 
430 static CallBackFunction MenuClickSaveLoad(int index = 0)
431 {
432  if (_game_mode == GM_EDITOR) {
433  switch (index) {
434  case SLEME_SAVE_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_SAVE); break;
435  case SLEME_LOAD_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_LOAD); break;
436  case SLEME_SAVE_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,SLO_SAVE); break;
437  case SLEME_LOAD_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,SLO_LOAD); break;
438  case SLEME_EXIT_TOINTRO: AskExitToGameMenu(); break;
439  case SLEME_EXIT_GAME: HandleExitGameRequest(); break;
440  }
441  } else {
442  switch (index) {
443  case SLNME_SAVE_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_SAVE); break;
444  case SLNME_LOAD_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break;
445  case SLNME_EXIT_TOINTRO: AskExitToGameMenu(); break;
446  case SLNME_EXIT_GAME: HandleExitGameRequest(); break;
447  }
448  }
449  return CBF_NONE;
450 }
451 
452 /* --- Map button menu --- */
453 
454 enum MapMenuEntries {
455  MME_SHOW_SMALLMAP = 0,
456  MME_SHOW_EXTRAVIEWPORTS,
457  MME_SHOW_LINKGRAPH,
458  MME_SHOW_SIGNLISTS,
459  MME_SHOW_TOWNDIRECTORY,
460  MME_SHOW_INDUSTRYDIRECTORY,
461 };
462 
463 static CallBackFunction ToolbarMapClick(Window *w)
464 {
465  DropDownList list;
466  list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP, false));
467  list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS, false));
468  list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_LINGRAPH_LEGEND, MME_SHOW_LINKGRAPH, false));
469  list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false));
470  PopupMainToolbMenu(w, WID_TN_SMALL_MAP, std::move(list), 0);
471  return CBF_NONE;
472 }
473 
474 static CallBackFunction ToolbarScenMapTownDir(Window *w)
475 {
476  DropDownList list;
477  list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP, false));
478  list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS, false));
479  list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false));
480  list.emplace_back(new DropDownListStringItem(STR_TOWN_MENU_TOWN_DIRECTORY, MME_SHOW_TOWNDIRECTORY, false));
481  list.emplace_back(new DropDownListStringItem(STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, MME_SHOW_INDUSTRYDIRECTORY, false));
482  PopupMainToolbMenu(w, WID_TE_SMALL_MAP, std::move(list), 0);
483  return CBF_NONE;
484 }
485 
493 {
494  switch (index) {
495  case MME_SHOW_SMALLMAP: ShowSmallMap(); break;
496  case MME_SHOW_EXTRAVIEWPORTS: ShowExtraViewportWindow(); break;
497  case MME_SHOW_LINKGRAPH: ShowLinkGraphLegend(); break;
498  case MME_SHOW_SIGNLISTS: ShowSignList(); break;
499  case MME_SHOW_TOWNDIRECTORY: ShowTownDirectory(); break;
500  case MME_SHOW_INDUSTRYDIRECTORY: ShowIndustryDirectory(); break;
501  }
502  return CBF_NONE;
503 }
504 
505 /* --- Town button menu --- */
506 
507 static CallBackFunction ToolbarTownClick(Window *w)
508 {
509  PopupMainToolbMenu(w, WID_TN_TOWNS, STR_TOWN_MENU_TOWN_DIRECTORY, (_settings_game.economy.found_town == TF_FORBIDDEN) ? 1 : 2);
510  return CBF_NONE;
511 }
512 
520 {
521  switch (index) {
522  case 0: ShowTownDirectory(); break;
523  case 1: // setting could be changed when the dropdown was open
524  if (_settings_game.economy.found_town != TF_FORBIDDEN) ShowFoundTownWindow();
525  break;
526  }
527  return CBF_NONE;
528 }
529 
530 /* --- Subidies button menu --- */
531 
532 static CallBackFunction ToolbarSubsidiesClick(Window *w)
533 {
534  PopupMainToolbMenu(w, WID_TN_SUBSIDIES, STR_SUBSIDIES_MENU_SUBSIDIES, 1);
535  return CBF_NONE;
536 }
537 
545 {
546  switch (index) {
547  case 0: ShowSubsidiesList(); break;
548  }
549  return CBF_NONE;
550 }
551 
552 /* --- Stations button menu --- */
553 
554 static CallBackFunction ToolbarStationsClick(Window *w)
555 {
557  return CBF_NONE;
558 }
559 
567 {
569  return CBF_NONE;
570 }
571 
572 /* --- Finances button menu --- */
573 
574 static CallBackFunction ToolbarFinancesClick(Window *w)
575 {
577  return CBF_NONE;
578 }
579 
587 {
589  return CBF_NONE;
590 }
591 
592 /* --- Company's button menu --- */
593 
594 static CallBackFunction ToolbarCompaniesClick(Window *w)
595 {
597  return CBF_NONE;
598 }
599 
607 {
608  if (_networking) {
609  switch (index) {
610  case CTMN_CLIENT_LIST:
611  ShowClientList();
612  return CBF_NONE;
613 
614  case CTMN_NEW_COMPANY:
615  if (_network_server) {
617  } else {
618  NetworkSendCommand(0, CCA_NEW, 0, CMD_COMPANY_CTRL, nullptr, nullptr, _local_company);
619  }
620  return CBF_NONE;
621 
622  case CTMN_SPECTATE:
623  if (_network_server) {
626  } else {
628  }
629  return CBF_NONE;
630  }
631  }
632  ShowCompany((CompanyID)index);
633  return CBF_NONE;
634 }
635 
636 /* --- Story button menu --- */
637 
638 static CallBackFunction ToolbarStoryClick(Window *w)
639 {
641  return CBF_NONE;
642 }
643 
651 {
653  return CBF_NONE;
654 }
655 
656 /* --- Goal button menu --- */
657 
658 static CallBackFunction ToolbarGoalClick(Window *w)
659 {
661  return CBF_NONE;
662 }
663 
671 {
673  return CBF_NONE;
674 }
675 
676 /* --- Graphs button menu --- */
677 
678 static CallBackFunction ToolbarGraphsClick(Window *w)
679 {
680  PopupMainToolbMenu(w, WID_TN_GRAPHS, STR_GRAPH_MENU_OPERATING_PROFIT_GRAPH, (_toolbar_mode == TB_NORMAL) ? 6 : 8);
681  return CBF_NONE;
682 }
683 
691 {
692  switch (index) {
693  case 0: ShowOperatingProfitGraph(); break;
694  case 1: ShowIncomeGraph(); break;
695  case 2: ShowDeliveredCargoGraph(); break;
696  case 3: ShowPerformanceHistoryGraph(); break;
697  case 4: ShowCompanyValueGraph(); break;
698  case 5: ShowCargoPaymentRates(); break;
699  /* functions for combined graphs/league button */
700  case 6: ShowCompanyLeagueTable(); break;
701  case 7: ShowPerformanceRatingDetail(); break;
702  }
703  return CBF_NONE;
704 }
705 
706 /* --- League button menu --- */
707 
708 static CallBackFunction ToolbarLeagueClick(Window *w)
709 {
710  PopupMainToolbMenu(w, WID_TN_LEAGUE, STR_GRAPH_MENU_COMPANY_LEAGUE_TABLE, _networking ? 2 : 3);
711  return CBF_NONE;
712 }
713 
721 {
722  switch (index) {
723  case 0: ShowCompanyLeagueTable(); break;
724  case 1: ShowPerformanceRatingDetail(); break;
725  case 2: ShowHighscoreTable(); break;
726  }
727  return CBF_NONE;
728 }
729 
730 /* --- Industries button menu --- */
731 
732 static CallBackFunction ToolbarIndustryClick(Window *w)
733 {
734  /* Disable build-industry menu if we are a spectator */
735  PopupMainToolbMenu(w, WID_TN_INDUSTRIES, STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, (_local_company == COMPANY_SPECTATOR) ? 2 : 3);
736  return CBF_NONE;
737 }
738 
746 {
747  switch (index) {
748  case 0: ShowIndustryDirectory(); break;
749  case 1: ShowIndustryCargoesWindow(); break;
750  case 2: ShowBuildIndustryWindow(); break;
751  }
752  return CBF_NONE;
753 }
754 
755 /* --- Trains button menu + 1 helper function for all vehicles. --- */
756 
757 static void ToolbarVehicleClick(Window *w, VehicleType veh)
758 {
759  int dis = ~0;
760 
761  for (const Vehicle *v : Vehicle::Iterate()) {
762  if (v->type == veh && v->IsPrimaryVehicle()) ClrBit(dis, v->owner);
763  }
765 }
766 
767 
768 static CallBackFunction ToolbarTrainClick(Window *w)
769 {
770  ToolbarVehicleClick(w, VEH_TRAIN);
771  return CBF_NONE;
772 }
773 
781 {
782  ShowVehicleListWindow((CompanyID)index, VEH_TRAIN);
783  return CBF_NONE;
784 }
785 
786 /* --- Road vehicle button menu --- */
787 
788 static CallBackFunction ToolbarRoadClick(Window *w)
789 {
790  ToolbarVehicleClick(w, VEH_ROAD);
791  return CBF_NONE;
792 }
793 
801 {
802  ShowVehicleListWindow((CompanyID)index, VEH_ROAD);
803  return CBF_NONE;
804 }
805 
806 /* --- Ship button menu --- */
807 
808 static CallBackFunction ToolbarShipClick(Window *w)
809 {
810  ToolbarVehicleClick(w, VEH_SHIP);
811  return CBF_NONE;
812 }
813 
821 {
822  ShowVehicleListWindow((CompanyID)index, VEH_SHIP);
823  return CBF_NONE;
824 }
825 
826 /* --- Aircraft button menu --- */
827 
828 static CallBackFunction ToolbarAirClick(Window *w)
829 {
830  ToolbarVehicleClick(w, VEH_AIRCRAFT);
831  return CBF_NONE;
832 }
833 
841 {
842  ShowVehicleListWindow((CompanyID)index, VEH_AIRCRAFT);
843  return CBF_NONE;
844 }
845 
846 /* --- Zoom in button --- */
847 
848 static CallBackFunction ToolbarZoomInClick(Window *w)
849 {
851  w->HandleButtonClick((_game_mode == GM_EDITOR) ? (byte)WID_TE_ZOOM_IN : (byte)WID_TN_ZOOM_IN);
852  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
853  }
854  return CBF_NONE;
855 }
856 
857 /* --- Zoom out button --- */
858 
859 static CallBackFunction ToolbarZoomOutClick(Window *w)
860 {
862  w->HandleButtonClick((_game_mode == GM_EDITOR) ? (byte)WID_TE_ZOOM_OUT : (byte)WID_TN_ZOOM_OUT);
863  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
864  }
865  return CBF_NONE;
866 }
867 
868 /* --- Rail button menu --- */
869 
870 static CallBackFunction ToolbarBuildRailClick(Window *w)
871 {
872  ShowDropDownList(w, GetRailTypeDropDownList(), _last_built_railtype, WID_TN_RAILS, 140, true, true);
873  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
874  return CBF_NONE;
875 }
876 
884 {
885  _last_built_railtype = (RailType)index;
886  ShowBuildRailToolbar(_last_built_railtype);
887  return CBF_NONE;
888 }
889 
890 /* --- Road button menu --- */
891 
892 static CallBackFunction ToolbarBuildRoadClick(Window *w)
893 {
894  ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TN_ROADS, 140, true, true);
895  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
896  return CBF_NONE;
897 }
898 
906 {
907  _last_built_roadtype = (RoadType)index;
908  ShowBuildRoadToolbar(_last_built_roadtype);
909  return CBF_NONE;
910 }
911 
912 /* --- Tram button menu --- */
913 
914 static CallBackFunction ToolbarBuildTramClick(Window *w)
915 {
916  ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TN_TRAMS, 140, true, true);
917  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
918  return CBF_NONE;
919 }
920 
928 {
929  _last_built_tramtype = (RoadType)index;
930  ShowBuildRoadToolbar(_last_built_tramtype);
931  return CBF_NONE;
932 }
933 
934 /* --- Water button menu --- */
935 
936 static CallBackFunction ToolbarBuildWaterClick(Window *w)
937 {
938  DropDownList list;
939  list.emplace_back(new DropDownListIconItem(SPR_IMG_BUILD_CANAL, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 0, false));
940  ShowDropDownList(w, std::move(list), 0, WID_TN_WATER, 140, true, true);
941  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
942  return CBF_NONE;
943 }
944 
952 {
954  return CBF_NONE;
955 }
956 
957 /* --- Airport button menu --- */
958 
959 static CallBackFunction ToolbarBuildAirClick(Window *w)
960 {
961  DropDownList list;
962  list.emplace_back(new DropDownListIconItem(SPR_IMG_AIRPORT, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 0, false));
963  ShowDropDownList(w, std::move(list), 0, WID_TN_AIR, 140, true, true);
964  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
965  return CBF_NONE;
966 }
967 
975 {
977  return CBF_NONE;
978 }
979 
980 /* --- Forest button menu --- */
981 
982 static CallBackFunction ToolbarForestClick(Window *w)
983 {
984  DropDownList list;
985  list.emplace_back(new DropDownListIconItem(SPR_IMG_LANDSCAPING, PAL_NONE, STR_LANDSCAPING_MENU_LANDSCAPING, 0, false));
986  list.emplace_back(new DropDownListIconItem(SPR_IMG_PLANTTREES, PAL_NONE, STR_LANDSCAPING_MENU_PLANT_TREES, 1, false));
987  list.emplace_back(new DropDownListIconItem(SPR_IMG_SIGN, PAL_NONE, STR_LANDSCAPING_MENU_PLACE_SIGN, 2, false));
988  ShowDropDownList(w, std::move(list), 0, WID_TN_LANDSCAPE, 100, true, true);
989  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
990  return CBF_NONE;
991 }
992 
1000 {
1001  switch (index) {
1002  case 0: ShowTerraformToolbar(); break;
1003  case 1: ShowBuildTreesToolbar(); break;
1004  case 2: return SelectSignTool();
1005  }
1006  return CBF_NONE;
1007 }
1008 
1009 /* --- Music button menu --- */
1010 
1011 static CallBackFunction ToolbarMusicClick(Window *w)
1012 {
1013  PopupMainToolbMenu(w, _game_mode == GM_EDITOR ? (int)WID_TE_MUSIC_SOUND : (int)WID_TN_MUSIC_SOUND, STR_TOOLBAR_SOUND_MUSIC, 1);
1014  return CBF_NONE;
1015 }
1016 
1024 {
1025  ShowMusicWindow();
1026  return CBF_NONE;
1027 }
1028 
1029 /* --- Newspaper button menu --- */
1030 
1031 static CallBackFunction ToolbarNewspaperClick(Window *w)
1032 {
1033  PopupMainToolbMenu(w, WID_TN_MESSAGES, STR_NEWS_MENU_LAST_MESSAGE_NEWS_REPORT, 3);
1034  return CBF_NONE;
1035 }
1036 
1044 {
1045  switch (index) {
1046  case 0: ShowLastNewsMessage(); break;
1047  case 1: ShowMessageHistory(); break;
1048  case 2: DeleteAllMessages(); break;
1049  }
1050  return CBF_NONE;
1051 }
1052 
1053 /* --- Help button menu --- */
1054 
1055 static CallBackFunction PlaceLandBlockInfo()
1056 {
1057  if (_last_started_action == CBF_PLACE_LANDINFO) {
1059  return CBF_NONE;
1060  } else {
1061  SetObjectToPlace(SPR_CURSOR_QUERY, PAL_NONE, HT_RECT, WC_MAIN_TOOLBAR, 0);
1062  return CBF_PLACE_LANDINFO;
1063  }
1064 }
1065 
1066 static CallBackFunction ToolbarHelpClick(Window *w)
1067 {
1068  PopupMainToolbMenu(w, _game_mode == GM_EDITOR ? (int)WID_TE_HELP : (int)WID_TN_HELP, STR_ABOUT_MENU_LAND_BLOCK_INFO, _settings_client.gui.newgrf_developer_tools ? 10 : 7);
1069  return CBF_NONE;
1070 }
1071 
1080 {
1081  extern bool _draw_bounding_boxes;
1082  /* Always allow to toggle them off */
1083  if (_settings_client.gui.newgrf_developer_tools || _draw_bounding_boxes) {
1084  _draw_bounding_boxes = !_draw_bounding_boxes;
1086  }
1087 }
1088 
1097 {
1098  extern bool _draw_dirty_blocks;
1099  /* Always allow to toggle them off */
1100  if (_settings_client.gui.newgrf_developer_tools || _draw_dirty_blocks) {
1101  _draw_dirty_blocks = !_draw_dirty_blocks;
1103  }
1104 }
1105 
1111 {
1114  /* If you open a savegame as scenario there may already be link graphs.*/
1116  SetDate(new_date, 0);
1117 }
1118 
1125 {
1126  switch (index) {
1127  case 0: return PlaceLandBlockInfo();
1128  case 2: IConsoleSwitch(); break;
1129  case 3: ShowAIDebugWindow(); break;
1130  case 4: ShowScreenshotWindow(); break;
1131  case 5: ShowFramerateWindow(); break;
1132  case 6: ShowAboutWindow(); break;
1133  case 7: ShowSpriteAlignerWindow(); break;
1134  case 8: ToggleBoundingBoxes(); break;
1135  case 9: ToggleDirtyBlocks(); break;
1136  }
1137  return CBF_NONE;
1138 }
1139 
1140 /* --- Switch toolbar button --- */
1141 
1142 static CallBackFunction ToolbarSwitchClick(Window *w)
1143 {
1144  if (_toolbar_mode != TB_LOWER) {
1145  _toolbar_mode = TB_LOWER;
1146  } else {
1147  _toolbar_mode = TB_UPPER;
1148  }
1149 
1150  w->ReInit();
1151  w->SetWidgetLoweredState(_game_mode == GM_EDITOR ? (uint)WID_TE_SWITCH_BAR : (uint)WID_TN_SWITCH_BAR, _toolbar_mode == TB_LOWER);
1152  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1153  return CBF_NONE;
1154 }
1155 
1156 /* --- Scenario editor specific handlers. */
1157 
1162 {
1164  ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, w, CS_NUMERAL, QSF_ENABLE_DEFAULT);
1165  _left_button_clicked = false;
1166  return CBF_NONE;
1167 }
1168 
1169 static CallBackFunction ToolbarScenDateBackward(Window *w)
1170 {
1171  /* don't allow too fast scrolling */
1172  if (!(w->flags & WF_TIMEOUT) || w->timeout_timer <= 1) {
1174  w->SetDirty();
1175 
1177  }
1178  _left_button_clicked = false;
1179  return CBF_NONE;
1180 }
1181 
1182 static CallBackFunction ToolbarScenDateForward(Window *w)
1183 {
1184  /* don't allow too fast scrolling */
1185  if (!(w->flags & WF_TIMEOUT) || w->timeout_timer <= 1) {
1187  w->SetDirty();
1188 
1190  }
1191  _left_button_clicked = false;
1192  return CBF_NONE;
1193 }
1194 
1195 static CallBackFunction ToolbarScenGenLand(Window *w)
1196 {
1198  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1199 
1201  return CBF_NONE;
1202 }
1203 
1204 
1205 static CallBackFunction ToolbarScenGenTown(Window *w)
1206 {
1208  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1209  ShowFoundTownWindow();
1210  return CBF_NONE;
1211 }
1212 
1213 static CallBackFunction ToolbarScenGenIndustry(Window *w)
1214 {
1216  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1217  ShowBuildIndustryWindow();
1218  return CBF_NONE;
1219 }
1220 
1221 static CallBackFunction ToolbarScenBuildRoadClick(Window *w)
1222 {
1223  ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TE_ROADS, 140, true, true);
1224  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1225  return CBF_NONE;
1226 }
1227 
1235 {
1236  _last_built_roadtype = (RoadType)index;
1237  ShowBuildRoadScenToolbar(_last_built_roadtype);
1238  return CBF_NONE;
1239 }
1240 
1241 static CallBackFunction ToolbarScenBuildTramClick(Window *w)
1242 {
1243  ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TE_TRAMS, 140, true, true);
1244  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1245  return CBF_NONE;
1246 }
1247 
1255 {
1256  _last_built_tramtype = (RoadType)index;
1257  ShowBuildRoadScenToolbar(_last_built_tramtype);
1258  return CBF_NONE;
1259 }
1260 
1261 static CallBackFunction ToolbarScenBuildDocks(Window *w)
1262 {
1264  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1266  return CBF_NONE;
1267 }
1268 
1269 static CallBackFunction ToolbarScenPlantTrees(Window *w)
1270 {
1272  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1273  ShowBuildTreesToolbar();
1274  return CBF_NONE;
1275 }
1276 
1277 static CallBackFunction ToolbarScenPlaceSign(Window *w)
1278 {
1280  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1281  return SelectSignTool();
1282 }
1283 
1284 static CallBackFunction ToolbarBtn_NULL(Window *w)
1285 {
1286  return CBF_NONE;
1287 }
1288 
1289 typedef CallBackFunction MenuClickedProc(int index);
1290 
1291 static MenuClickedProc * const _menu_clicked_procs[] = {
1292  nullptr, // 0
1293  nullptr, // 1
1294  MenuClickSettings, // 2
1295  MenuClickSaveLoad, // 3
1296  MenuClickMap, // 4
1297  MenuClickTown, // 5
1298  MenuClickSubsidies, // 6
1299  MenuClickStations, // 7
1300  MenuClickFinances, // 8
1301  MenuClickCompany, // 9
1302  MenuClickStory, // 10
1303  MenuClickGoal, // 11
1304  MenuClickGraphs, // 12
1305  MenuClickLeague, // 13
1306  MenuClickIndustry, // 14
1307  MenuClickShowTrains, // 15
1308  MenuClickShowRoad, // 16
1309  MenuClickShowShips, // 17
1310  MenuClickShowAir, // 18
1311  MenuClickMap, // 19
1312  nullptr, // 20
1313  MenuClickBuildRail, // 21
1314  MenuClickBuildRoad, // 22
1315  MenuClickBuildTram, // 23
1316  MenuClickBuildWater, // 24
1317  MenuClickBuildAir, // 25
1318  MenuClickForest, // 26
1319  MenuClickMusicWindow, // 27
1320  MenuClickNewspaper, // 28
1321  MenuClickHelp, // 29
1322 };
1323 
1327 protected:
1328  uint spacers;
1329 
1330 public:
1332  {
1333  }
1334 
1341  {
1342  return type == WWT_IMGBTN || type == WWT_IMGBTN_2 || type == WWT_PUSHIMGBTN;
1343  }
1344 
1345  void SetupSmallestSize(Window *w, bool init_array) override
1346  {
1347  this->smallest_x = 0; // Biggest child
1348  this->smallest_y = 0; // Biggest child
1349  this->fill_x = 1;
1350  this->fill_y = 0;
1351  this->resize_x = 1; // We only resize in this direction
1352  this->resize_y = 0; // We never resize in this direction
1353  this->spacers = 0;
1354 
1355  uint nbuttons = 0;
1356  /* First initialise some variables... */
1357  for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
1358  child_wid->SetupSmallestSize(w, init_array);
1359  this->smallest_y = std::max(this->smallest_y, child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom);
1360  if (this->IsButton(child_wid->type)) {
1361  nbuttons++;
1362  this->smallest_x = std::max(this->smallest_x, child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right);
1363  } else if (child_wid->type == NWID_SPACER) {
1364  this->spacers++;
1365  }
1366  }
1367 
1368  /* ... then in a second pass make sure the 'current' heights are set. Won't change ever. */
1369  for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
1370  child_wid->current_y = this->smallest_y;
1371  if (!this->IsButton(child_wid->type)) {
1372  child_wid->current_x = child_wid->smallest_x;
1373  }
1374  }
1375  _toolbar_width = nbuttons * this->smallest_x;
1376  }
1377 
1378  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
1379  {
1380  assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
1381 
1382  this->pos_x = x;
1383  this->pos_y = y;
1384  this->current_x = given_width;
1385  this->current_y = given_height;
1386 
1387  /* Figure out what are the visible buttons */
1388  memset(this->visible, 0, sizeof(this->visible));
1389  uint arrangable_count, button_count, spacer_count;
1390  const byte *arrangement = GetButtonArrangement(given_width, arrangable_count, button_count, spacer_count);
1391  for (uint i = 0; i < arrangable_count; i++) {
1392  this->visible[arrangement[i]] = true;
1393  }
1394 
1395  /* Create us ourselves a quick lookup table */
1396  NWidgetBase *widgets[WID_TN_END];
1397  for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
1398  if (child_wid->type == NWID_SPACER) continue;
1399  widgets[((NWidgetCore*)child_wid)->index] = child_wid;
1400  }
1401 
1402  /* Now assign the widgets to their rightful place */
1403  uint position = 0; // Place to put next child relative to origin of the container.
1404  uint spacer_space = std::max(0, (int)given_width - (int)(button_count * this->smallest_x)); // Remaining spacing for 'spacer' widgets
1405  uint button_space = given_width - spacer_space; // Remaining spacing for the buttons
1406  uint spacer_i = 0;
1407  uint button_i = 0;
1408 
1409  /* Index into the arrangement indices. The macro lastof cannot be used here! */
1410  const byte *cur_wid = rtl ? &arrangement[arrangable_count - 1] : arrangement;
1411  for (uint i = 0; i < arrangable_count; i++) {
1412  NWidgetBase *child_wid = widgets[*cur_wid];
1413  /* If we have to give space to the spacers, do that */
1414  if (spacer_space != 0) {
1415  NWidgetBase *possible_spacer = rtl ? child_wid->next : child_wid->prev;
1416  if (possible_spacer != nullptr && possible_spacer->type == NWID_SPACER) {
1417  uint add = spacer_space / (spacer_count - spacer_i);
1418  position += add;
1419  spacer_space -= add;
1420  spacer_i++;
1421  }
1422  }
1423 
1424  /* Buttons can be scaled, the others not. */
1425  if (this->IsButton(child_wid->type)) {
1426  child_wid->current_x = button_space / (button_count - button_i);
1427  button_space -= child_wid->current_x;
1428  button_i++;
1429  }
1430  child_wid->AssignSizePosition(sizing, x + position, y, child_wid->current_x, this->current_y, rtl);
1431  position += child_wid->current_x;
1432 
1433  if (rtl) {
1434  cur_wid--;
1435  } else {
1436  cur_wid++;
1437  }
1438  }
1439  }
1440 
1441  void Draw(const Window *w) override
1442  {
1443  /* Draw brown-red toolbar bg. */
1444  GfxFillRect(this->pos_x, this->pos_y, this->pos_x + this->current_x - 1, this->pos_y + this->current_y - 1, PC_VERY_DARK_RED);
1445  GfxFillRect(this->pos_x, this->pos_y, this->pos_x + this->current_x - 1, this->pos_y + this->current_y - 1, PC_DARK_RED, FILLRECT_CHECKER);
1446 
1447  bool rtl = _current_text_dir == TD_RTL;
1448  for (NWidgetBase *child_wid = rtl ? this->tail : this->head; child_wid != nullptr; child_wid = rtl ? child_wid->prev : child_wid->next) {
1449  if (child_wid->type == NWID_SPACER) continue;
1450  if (!this->visible[((NWidgetCore*)child_wid)->index]) continue;
1451 
1452  child_wid->Draw(w);
1453  }
1454  }
1455 
1456  NWidgetCore *GetWidgetFromPos(int x, int y) override
1457  {
1458  if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return nullptr;
1459 
1460  for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
1461  if (child_wid->type == NWID_SPACER) continue;
1462  if (!this->visible[((NWidgetCore*)child_wid)->index]) continue;
1463 
1464  NWidgetCore *nwid = child_wid->GetWidgetFromPos(x, y);
1465  if (nwid != nullptr) return nwid;
1466  }
1467  return nullptr;
1468  }
1469 
1478  virtual const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const = 0;
1479 };
1480 
1483  const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override
1484  {
1485  static const uint SMALLEST_ARRANGEMENT = 14;
1486  static const uint BIGGEST_ARRANGEMENT = 20;
1487 
1488  /* The number of buttons of each row of the toolbar should match the number of items which we want to be visible.
1489  * The total number of buttons should be equal to arrangable_count * 2.
1490  * No bad things happen, but we could see strange behaviours if we have buttons < (arrangable_count * 2) like a
1491  * pause button appearing on the right of the lower toolbar and weird resizing of the widgets even if there is
1492  * enough space.
1493  */
1494  static const byte arrange14[] = {
1495  WID_TN_PAUSE,
1497  WID_TN_TRAINS,
1499  WID_TN_SHIPS,
1503  WID_TN_RAILS,
1504  WID_TN_ROADS,
1505  WID_TN_WATER,
1506  WID_TN_AIR,
1509  // lower toolbar
1511  WID_TN_SAVE,
1513  WID_TN_TOWNS,
1518  WID_TN_GRAPHS,
1522  WID_TN_HELP,
1524  };
1525  static const byte arrange15[] = {
1526  WID_TN_PAUSE,
1529  WID_TN_TRAINS,
1531  WID_TN_SHIPS,
1533  WID_TN_RAILS,
1534  WID_TN_ROADS,
1535  WID_TN_WATER,
1536  WID_TN_AIR,
1541  // lower toolbar
1542  WID_TN_PAUSE,
1545  WID_TN_SAVE,
1546  WID_TN_TOWNS,
1551  WID_TN_GRAPHS,
1555  WID_TN_HELP,
1557  };
1558  static const byte arrange16[] = {
1559  WID_TN_PAUSE,
1563  WID_TN_TRAINS,
1565  WID_TN_SHIPS,
1567  WID_TN_RAILS,
1568  WID_TN_ROADS,
1569  WID_TN_WATER,
1570  WID_TN_AIR,
1575  // lower toolbar
1576  WID_TN_PAUSE,
1578  WID_TN_SAVE,
1579  WID_TN_TOWNS,
1584  WID_TN_GRAPHS,
1588  WID_TN_HELP,
1592  };
1593  static const byte arrange17[] = {
1594  WID_TN_PAUSE,
1599  WID_TN_TRAINS,
1601  WID_TN_SHIPS,
1603  WID_TN_RAILS,
1604  WID_TN_ROADS,
1605  WID_TN_WATER,
1606  WID_TN_AIR,
1611  // lower toolbar
1612  WID_TN_PAUSE,
1614  WID_TN_SAVE,
1617  WID_TN_TOWNS,
1621  WID_TN_GRAPHS,
1625  WID_TN_HELP,
1629  };
1630  static const byte arrange18[] = {
1631  WID_TN_PAUSE,
1635  WID_TN_TOWNS,
1641  WID_TN_RAILS,
1642  WID_TN_ROADS,
1643  WID_TN_WATER,
1644  WID_TN_AIR,
1649  // lower toolbar
1650  WID_TN_PAUSE,
1652  WID_TN_SAVE,
1654  WID_TN_TOWNS,
1657  WID_TN_GRAPHS,
1658  WID_TN_TRAINS,
1660  WID_TN_SHIPS,
1664  WID_TN_HELP,
1668  };
1669  static const byte arrange19[] = {
1670  WID_TN_PAUSE,
1674  WID_TN_TOWNS,
1676  WID_TN_TRAINS,
1678  WID_TN_SHIPS,
1680  WID_TN_RAILS,
1681  WID_TN_ROADS,
1682  WID_TN_WATER,
1683  WID_TN_AIR,
1689  // lower toolbar
1690  WID_TN_PAUSE,
1692  WID_TN_SAVE,
1697  WID_TN_GRAPHS,
1700  WID_TN_RAILS,
1701  WID_TN_ROADS,
1702  WID_TN_WATER,
1703  WID_TN_AIR,
1705  WID_TN_HELP,
1709  };
1710  static const byte arrange20[] = {
1711  WID_TN_PAUSE,
1715  WID_TN_TOWNS,
1717  WID_TN_TRAINS,
1719  WID_TN_SHIPS,
1721  WID_TN_RAILS,
1722  WID_TN_ROADS,
1723  WID_TN_WATER,
1724  WID_TN_AIR,
1727  WID_TN_GOAL,
1731  // lower toolbar
1732  WID_TN_PAUSE,
1734  WID_TN_SAVE,
1739  WID_TN_GRAPHS,
1742  WID_TN_RAILS,
1743  WID_TN_ROADS,
1744  WID_TN_WATER,
1745  WID_TN_AIR,
1747  WID_TN_STORY,
1748  WID_TN_HELP,
1752  };
1753  static const byte arrange_all[] = {
1754  WID_TN_PAUSE,
1757  WID_TN_SAVE,
1759  WID_TN_TOWNS,
1764  WID_TN_STORY,
1765  WID_TN_GOAL,
1766  WID_TN_GRAPHS,
1767  WID_TN_LEAGUE,
1769  WID_TN_TRAINS,
1771  WID_TN_SHIPS,
1775  WID_TN_RAILS,
1776  WID_TN_ROADS,
1777  WID_TN_TRAMS,
1778  WID_TN_WATER,
1779  WID_TN_AIR,
1783  WID_TN_HELP
1784  };
1785 
1786  /* If at least BIGGEST_ARRANGEMENT fit, just spread all the buttons nicely */
1787  uint full_buttons = std::max(CeilDiv(width, this->smallest_x), SMALLEST_ARRANGEMENT);
1788  if (full_buttons > BIGGEST_ARRANGEMENT) {
1789  button_count = arrangable_count = lengthof(arrange_all);
1790  spacer_count = this->spacers;
1791  return arrange_all;
1792  }
1793 
1794  /* Introduce the split toolbar */
1795  static const byte * const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20 };
1796 
1797  button_count = arrangable_count = full_buttons;
1798  spacer_count = this->spacers;
1799  return arrangements[full_buttons - SMALLEST_ARRANGEMENT] + ((_toolbar_mode == TB_LOWER) ? full_buttons : 0);
1800  }
1801 };
1802 
1805  uint panel_widths[2];
1806 
1807  void SetupSmallestSize(Window *w, bool init_array) override
1808  {
1809  this->NWidgetToolbarContainer::SetupSmallestSize(w, init_array);
1810 
1811  /* Find the size of panel_widths */
1812  uint i = 0;
1813  for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
1814  if (child_wid->type == NWID_SPACER || this->IsButton(child_wid->type)) continue;
1815 
1816  assert(i < lengthof(this->panel_widths));
1817  this->panel_widths[i++] = child_wid->current_x;
1818  _toolbar_width += child_wid->current_x;
1819  }
1820  }
1821 
1822  const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override
1823  {
1824  static const byte arrange_all[] = {
1825  WID_TE_PAUSE,
1828  WID_TE_SAVE,
1829  WID_TE_SPACER,
1837  WID_TE_ROADS,
1838  WID_TE_TRAMS,
1839  WID_TE_WATER,
1840  WID_TE_TREES,
1841  WID_TE_SIGNS,
1843  WID_TE_HELP,
1844  };
1845  static const byte arrange_nopanel[] = {
1846  WID_TE_PAUSE,
1849  WID_TE_SAVE,
1857  WID_TE_ROADS,
1858  WID_TE_TRAMS,
1859  WID_TE_WATER,
1860  WID_TE_TREES,
1861  WID_TE_SIGNS,
1863  WID_TE_HELP,
1864  };
1865  static const byte arrange_switch[] = {
1871  WID_TE_ROADS,
1872  WID_TE_TRAMS,
1873  WID_TE_WATER,
1874  WID_TE_TREES,
1875  WID_TE_SIGNS,
1877  // lower toolbar
1878  WID_TE_PAUSE,
1881  WID_TE_SAVE,
1887  WID_TE_HELP,
1889  };
1890 
1891  /* If we can place all buttons *and* the panels, show them. */
1892  uint min_full_width = (lengthof(arrange_all) - lengthof(this->panel_widths)) * this->smallest_x + this->panel_widths[0] + this->panel_widths[1];
1893  if (width >= min_full_width) {
1894  width -= this->panel_widths[0] + this->panel_widths[1];
1895  arrangable_count = lengthof(arrange_all);
1896  button_count = arrangable_count - 2;
1897  spacer_count = this->spacers;
1898  return arrange_all;
1899  }
1900 
1901  /* Otherwise don't show the date panel and if we can't fit half the buttons and the panels anymore, split the toolbar in two */
1902  uint min_small_width = (lengthof(arrange_switch) - lengthof(this->panel_widths)) * this->smallest_x / 2 + this->panel_widths[1];
1903  if (width > min_small_width) {
1904  width -= this->panel_widths[1];
1905  arrangable_count = lengthof(arrange_nopanel);
1906  button_count = arrangable_count - 1;
1907  spacer_count = this->spacers - 1;
1908  return arrange_nopanel;
1909  }
1910 
1911  /* Split toolbar */
1912  width -= this->panel_widths[1];
1913  arrangable_count = lengthof(arrange_switch) / 2;
1914  button_count = arrangable_count - 1;
1915  spacer_count = 0;
1916  return arrange_switch + ((_toolbar_mode == TB_LOWER) ? arrangable_count : 0);
1917  }
1918 };
1919 
1920 /* --- Toolbar handling for the 'normal' case */
1921 
1922 typedef CallBackFunction ToolbarButtonProc(Window *w);
1923 
1924 static ToolbarButtonProc * const _toolbar_button_procs[] = {
1925  ToolbarPauseClick,
1929  ToolbarMapClick,
1930  ToolbarTownClick,
1931  ToolbarSubsidiesClick,
1932  ToolbarStationsClick,
1933  ToolbarFinancesClick,
1934  ToolbarCompaniesClick,
1935  ToolbarStoryClick,
1936  ToolbarGoalClick,
1937  ToolbarGraphsClick,
1938  ToolbarLeagueClick,
1939  ToolbarIndustryClick,
1940  ToolbarTrainClick,
1941  ToolbarRoadClick,
1942  ToolbarShipClick,
1943  ToolbarAirClick,
1944  ToolbarZoomInClick,
1945  ToolbarZoomOutClick,
1946  ToolbarBuildRailClick,
1947  ToolbarBuildRoadClick,
1948  ToolbarBuildTramClick,
1949  ToolbarBuildWaterClick,
1950  ToolbarBuildAirClick,
1951  ToolbarForestClick,
1952  ToolbarMusicClick,
1953  ToolbarNewspaperClick,
1954  ToolbarHelpClick,
1955  ToolbarSwitchClick,
1956 };
1957 
1958 enum MainToolbarHotkeys {
1959  MTHK_PAUSE,
1960  MTHK_FASTFORWARD,
1961  MTHK_SETTINGS,
1962  MTHK_SAVEGAME,
1963  MTHK_LOADGAME,
1964  MTHK_SMALLMAP,
1965  MTHK_TOWNDIRECTORY,
1966  MTHK_SUBSIDIES,
1967  MTHK_STATIONS,
1968  MTHK_FINANCES,
1969  MTHK_COMPANIES,
1970  MTHK_STORY,
1971  MTHK_GOAL,
1972  MTHK_GRAPHS,
1973  MTHK_LEAGUE,
1974  MTHK_INDUSTRIES,
1975  MTHK_TRAIN_LIST,
1976  MTHK_ROADVEH_LIST,
1977  MTHK_SHIP_LIST,
1978  MTHK_AIRCRAFT_LIST,
1979  MTHK_ZOOM_IN,
1980  MTHK_ZOOM_OUT,
1981  MTHK_BUILD_RAIL,
1982  MTHK_BUILD_ROAD,
1983  MTHK_BUILD_TRAM,
1984  MTHK_BUILD_DOCKS,
1985  MTHK_BUILD_AIRPORT,
1986  MTHK_BUILD_TREES,
1987  MTHK_MUSIC,
1988  MTHK_LANDINFO,
1989  MTHK_AI_DEBUG,
1990  MTHK_SMALL_SCREENSHOT,
1991  MTHK_ZOOMEDIN_SCREENSHOT,
1992  MTHK_DEFAULTZOOM_SCREENSHOT,
1993  MTHK_GIANT_SCREENSHOT,
1994  MTHK_CHEATS,
1995  MTHK_TERRAFORM,
1996  MTHK_EXTRA_VIEWPORT,
1997  MTHK_CLIENT_LIST,
1998  MTHK_SIGN_LIST,
1999 };
2000 
2003  GUITimer timer;
2004 
2005  MainToolbarWindow(WindowDesc *desc) : Window(desc)
2006  {
2007  this->InitNested(0);
2008 
2009  _last_started_action = CBF_NONE;
2010  CLRBITS(this->flags, WF_WHITE_BORDER);
2011  this->SetWidgetDisabledState(WID_TN_PAUSE, _networking && !_network_server); // if not server, disable pause button
2012  this->SetWidgetDisabledState(WID_TN_FAST_FORWARD, _networking); // if networking, disable fast-forward button
2013  PositionMainToolbar(this);
2015 
2016  this->timer.SetInterval(MILLISECONDS_PER_TICK);
2017  }
2018 
2019  void FindWindowPlacementAndResize(int def_width, int def_height) override
2020  {
2022  }
2023 
2024  void OnPaint() override
2025  {
2026  /* If spectator, disable all construction buttons
2027  * ie : Build road, rail, ships, airports and landscaping
2028  * Since enabled state is the default, just disable when needed */
2030  /* disable company list drop downs, if there are no companies */
2032 
2035 
2036  this->DrawWidgets();
2037  }
2038 
2039  void OnClick(Point pt, int widget, int click_count) override
2040  {
2041  if (_game_mode != GM_MENU && !this->IsWidgetDisabled(widget)) _toolbar_button_procs[widget](this);
2042  }
2043 
2044  void OnDropdownSelect(int widget, int index) override
2045  {
2046  CallBackFunction cbf = _menu_clicked_procs[widget](index);
2047  if (cbf != CBF_NONE) _last_started_action = cbf;
2048  }
2049 
2050  EventState OnHotkey(int hotkey) override
2051  {
2052  CallBackFunction cbf = CBF_NONE;
2053  switch (hotkey) {
2054  case MTHK_PAUSE: ToolbarPauseClick(this); break;
2055  case MTHK_FASTFORWARD: ToolbarFastForwardClick(this); break;
2056  case MTHK_SETTINGS: ShowGameOptions(); break;
2057  case MTHK_SAVEGAME: MenuClickSaveLoad(); break;
2058  case MTHK_LOADGAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break;
2059  case MTHK_SMALLMAP: ShowSmallMap(); break;
2060  case MTHK_TOWNDIRECTORY: ShowTownDirectory(); break;
2061  case MTHK_SUBSIDIES: ShowSubsidiesList(); break;
2062  case MTHK_STATIONS: ShowCompanyStations(_local_company); break;
2063  case MTHK_FINANCES: ShowCompanyFinances(_local_company); break;
2064  case MTHK_COMPANIES: ShowCompany(_local_company); break;
2065  case MTHK_STORY: ShowStoryBook(_local_company); break;
2066  case MTHK_GOAL: ShowGoalsList(_local_company); break;
2067  case MTHK_GRAPHS: ShowOperatingProfitGraph(); break;
2068  case MTHK_LEAGUE: ShowCompanyLeagueTable(); break;
2069  case MTHK_INDUSTRIES: ShowBuildIndustryWindow(); break;
2070  case MTHK_TRAIN_LIST: ShowVehicleListWindow(_local_company, VEH_TRAIN); break;
2071  case MTHK_ROADVEH_LIST: ShowVehicleListWindow(_local_company, VEH_ROAD); break;
2072  case MTHK_SHIP_LIST: ShowVehicleListWindow(_local_company, VEH_SHIP); break;
2073  case MTHK_AIRCRAFT_LIST: ShowVehicleListWindow(_local_company, VEH_AIRCRAFT); break;
2074  case MTHK_ZOOM_IN: ToolbarZoomInClick(this); break;
2075  case MTHK_ZOOM_OUT: ToolbarZoomOutClick(this); break;
2076  case MTHK_BUILD_RAIL: ShowBuildRailToolbar(_last_built_railtype); break;
2077  case MTHK_BUILD_ROAD: ShowBuildRoadToolbar(_last_built_roadtype); break;
2078  case MTHK_BUILD_TRAM: ShowBuildRoadToolbar(_last_built_tramtype); break;
2079  case MTHK_BUILD_DOCKS: ShowBuildDocksToolbar(); break;
2080  case MTHK_BUILD_AIRPORT: ShowBuildAirToolbar(); break;
2081  case MTHK_BUILD_TREES: ShowBuildTreesToolbar(); break;
2082  case MTHK_MUSIC: ShowMusicWindow(); break;
2083  case MTHK_AI_DEBUG: ShowAIDebugWindow(); break;
2084  case MTHK_SMALL_SCREENSHOT: MakeScreenshotWithConfirm(SC_VIEWPORT); break;
2085  case MTHK_ZOOMEDIN_SCREENSHOT: MakeScreenshotWithConfirm(SC_ZOOMEDIN); break;
2086  case MTHK_DEFAULTZOOM_SCREENSHOT: MakeScreenshotWithConfirm(SC_DEFAULTZOOM); break;
2087  case MTHK_GIANT_SCREENSHOT: MakeScreenshotWithConfirm(SC_WORLD); break;
2088  case MTHK_CHEATS: if (!_networking) ShowCheatWindow(); break;
2089  case MTHK_TERRAFORM: ShowTerraformToolbar(); break;
2090  case MTHK_EXTRA_VIEWPORT: ShowExtraViewportWindowForTileUnderCursor(); break;
2091  case MTHK_CLIENT_LIST: if (_networking) ShowClientList(); break;
2092  case MTHK_SIGN_LIST: ShowSignList(); break;
2093  case MTHK_LANDINFO: cbf = PlaceLandBlockInfo(); break;
2094  default: return ES_NOT_HANDLED;
2095  }
2096  if (cbf != CBF_NONE) _last_started_action = cbf;
2097  return ES_HANDLED;
2098  }
2099 
2100  void OnPlaceObject(Point pt, TileIndex tile) override
2101  {
2102  switch (_last_started_action) {
2103  case CBF_PLACE_SIGN:
2104  PlaceProc_Sign(tile);
2105  break;
2106 
2107  case CBF_PLACE_LANDINFO:
2108  ShowLandInfo(tile);
2109  break;
2110 
2111  default: NOT_REACHED();
2112  }
2113  }
2114 
2115  void OnPlaceObjectAbort() override
2116  {
2117  _last_started_action = CBF_NONE;
2118  }
2119 
2120  void OnRealtimeTick(uint delta_ms) override
2121  {
2122  if (!this->timer.Elapsed(delta_ms)) return;
2123  this->timer.SetInterval(MILLISECONDS_PER_TICK);
2124 
2125  if (this->IsWidgetLowered(WID_TN_PAUSE) != !!_pause_mode) {
2128  }
2129 
2130  if (this->IsWidgetLowered(WID_TN_FAST_FORWARD) != !!_fast_forward) {
2133  }
2134  }
2135 
2136  void OnTimeout() override
2137  {
2138  /* We do not want to automatically raise the pause, fast forward and
2139  * switchbar buttons; they have to stay down when pressed etc. */
2140  for (uint i = WID_TN_SETTINGS; i < WID_TN_SWITCH_BAR; i++) {
2141  if (this->IsWidgetLowered(i)) {
2142  this->RaiseWidget(i);
2143  this->SetWidgetDirty(i);
2144  }
2145  }
2146  }
2147 
2153  void OnInvalidateData(int data = 0, bool gui_scope = true) override
2154  {
2155  if (!gui_scope) return;
2157  }
2158 
2159  static HotkeyList hotkeys;
2160 };
2161 
2162 const uint16 _maintoolbar_pause_keys[] = {WKC_F1, WKC_PAUSE, 0};
2163 const uint16 _maintoolbar_zoomin_keys[] = {WKC_NUM_PLUS, WKC_EQUALS, WKC_SHIFT | WKC_EQUALS, WKC_SHIFT | WKC_F5, 0};
2164 const uint16 _maintoolbar_zoomout_keys[] = {WKC_NUM_MINUS, WKC_MINUS, WKC_SHIFT | WKC_MINUS, WKC_SHIFT | WKC_F6, 0};
2165 const uint16 _maintoolbar_smallmap_keys[] = {WKC_F4, 'M', 0};
2166 
2167 static Hotkey maintoolbar_hotkeys[] = {
2168  Hotkey(_maintoolbar_pause_keys, "pause", MTHK_PAUSE),
2169  Hotkey((uint16)0, "fastforward", MTHK_FASTFORWARD),
2170  Hotkey(WKC_F2, "settings", MTHK_SETTINGS),
2171  Hotkey(WKC_F3, "saveload", MTHK_SAVEGAME),
2172  Hotkey((uint16)0, "load_game", MTHK_LOADGAME),
2173  Hotkey(_maintoolbar_smallmap_keys, "smallmap", MTHK_SMALLMAP),
2174  Hotkey(WKC_F5, "town_list", MTHK_TOWNDIRECTORY),
2175  Hotkey(WKC_F6, "subsidies", MTHK_SUBSIDIES),
2176  Hotkey(WKC_F7, "station_list", MTHK_STATIONS),
2177  Hotkey(WKC_F8, "finances", MTHK_FINANCES),
2178  Hotkey(WKC_F9, "companies", MTHK_COMPANIES),
2179  Hotkey((uint16)0, "story_book", MTHK_STORY),
2180  Hotkey((uint16)0, "goal_list", MTHK_GOAL),
2181  Hotkey(WKC_F10, "graphs", MTHK_GRAPHS),
2182  Hotkey(WKC_F11, "league", MTHK_LEAGUE),
2183  Hotkey(WKC_F12, "industry_list", MTHK_INDUSTRIES),
2184  Hotkey(WKC_SHIFT | WKC_F1, "train_list", MTHK_TRAIN_LIST),
2185  Hotkey(WKC_SHIFT | WKC_F2, "roadveh_list", MTHK_ROADVEH_LIST),
2186  Hotkey(WKC_SHIFT | WKC_F3, "ship_list", MTHK_SHIP_LIST),
2187  Hotkey(WKC_SHIFT | WKC_F4, "aircraft_list", MTHK_AIRCRAFT_LIST),
2188  Hotkey(_maintoolbar_zoomin_keys, "zoomin", MTHK_ZOOM_IN),
2189  Hotkey(_maintoolbar_zoomout_keys, "zoomout", MTHK_ZOOM_OUT),
2190  Hotkey(WKC_SHIFT | WKC_F7, "build_rail", MTHK_BUILD_RAIL),
2191  Hotkey(WKC_SHIFT | WKC_F8, "build_road", MTHK_BUILD_ROAD),
2192  Hotkey((uint16)0, "build_tram", MTHK_BUILD_TRAM),
2193  Hotkey(WKC_SHIFT | WKC_F9, "build_docks", MTHK_BUILD_DOCKS),
2194  Hotkey(WKC_SHIFT | WKC_F10, "build_airport", MTHK_BUILD_AIRPORT),
2195  Hotkey(WKC_SHIFT | WKC_F11, "build_trees", MTHK_BUILD_TREES),
2196  Hotkey(WKC_SHIFT | WKC_F12, "music", MTHK_MUSIC),
2197  Hotkey((uint16)0, "ai_debug", MTHK_AI_DEBUG),
2198  Hotkey(WKC_CTRL | 'S', "small_screenshot", MTHK_SMALL_SCREENSHOT),
2199  Hotkey(WKC_CTRL | 'P', "zoomedin_screenshot", MTHK_ZOOMEDIN_SCREENSHOT),
2200  Hotkey(WKC_CTRL | 'D', "defaultzoom_screenshot", MTHK_DEFAULTZOOM_SCREENSHOT),
2201  Hotkey((uint16)0, "giant_screenshot", MTHK_GIANT_SCREENSHOT),
2202  Hotkey(WKC_CTRL | WKC_ALT | 'C', "cheats", MTHK_CHEATS),
2203  Hotkey('L', "terraform", MTHK_TERRAFORM),
2204  Hotkey('V', "extra_viewport", MTHK_EXTRA_VIEWPORT),
2205  Hotkey((uint16)0, "client_list", MTHK_CLIENT_LIST),
2206  Hotkey((uint16)0, "sign_list", MTHK_SIGN_LIST),
2207  Hotkey((uint16)0, "land_info", MTHK_LANDINFO),
2208  HOTKEY_LIST_END
2209 };
2210 HotkeyList MainToolbarWindow::hotkeys("maintoolbar", maintoolbar_hotkeys);
2211 
2212 static NWidgetBase *MakeMainToolbar(int *biggest_index)
2213 {
2215  static const SpriteID toolbar_button_sprites[] = {
2216  SPR_IMG_PAUSE, // WID_TN_PAUSE
2217  SPR_IMG_FASTFORWARD, // WID_TN_FAST_FORWARD
2218  SPR_IMG_SETTINGS, // WID_TN_SETTINGS
2219  SPR_IMG_SAVE, // WID_TN_SAVE
2220  SPR_IMG_SMALLMAP, // WID_TN_SMALL_MAP
2221  SPR_IMG_TOWN, // WID_TN_TOWNS
2222  SPR_IMG_SUBSIDIES, // WID_TN_SUBSIDIES
2223  SPR_IMG_COMPANY_LIST, // WID_TN_STATIONS
2224  SPR_IMG_COMPANY_FINANCE, // WID_TN_FINANCES
2225  SPR_IMG_COMPANY_GENERAL, // WID_TN_COMPANIES
2226  SPR_IMG_STORY_BOOK, // WID_TN_STORY
2227  SPR_IMG_GOAL, // WID_TN_GOAL
2228  SPR_IMG_GRAPHS, // WID_TN_GRAPHS
2229  SPR_IMG_COMPANY_LEAGUE, // WID_TN_LEAGUE
2230  SPR_IMG_INDUSTRY, // WID_TN_INDUSTRIES
2231  SPR_IMG_TRAINLIST, // WID_TN_TRAINS
2232  SPR_IMG_TRUCKLIST, // WID_TN_ROADVEHS
2233  SPR_IMG_SHIPLIST, // WID_TN_SHIPS
2234  SPR_IMG_AIRPLANESLIST, // WID_TN_AIRCRAFT
2235  SPR_IMG_ZOOMIN, // WID_TN_ZOOMIN
2236  SPR_IMG_ZOOMOUT, // WID_TN_ZOOMOUT
2237  SPR_IMG_BUILDRAIL, // WID_TN_RAILS
2238  SPR_IMG_BUILDROAD, // WID_TN_ROADS
2239  SPR_IMG_BUILDTRAMS, // WID_TN_TRAMS
2240  SPR_IMG_BUILDWATER, // WID_TN_WATER
2241  SPR_IMG_BUILDAIR, // WID_TN_AIR
2242  SPR_IMG_LANDSCAPING, // WID_TN_LANDSCAPE
2243  SPR_IMG_MUSIC, // WID_TN_MUSIC_SOUND
2244  SPR_IMG_MESSAGES, // WID_TN_MESSAGES
2245  SPR_IMG_QUERY, // WID_TN_HELP
2246  SPR_IMG_SWITCH_TOOLBAR, // WID_TN_SWITCH_BAR
2247  };
2248 
2250  for (uint i = 0; i < WID_TN_END; i++) {
2251  switch (i) {
2252  case WID_TN_SMALL_MAP:
2253  case WID_TN_FINANCES:
2254  case WID_TN_VEHICLE_START:
2255  case WID_TN_ZOOM_IN:
2257  case WID_TN_MUSIC_SOUND:
2258  hor->Add(new NWidgetSpacer(0, 0));
2259  break;
2260  }
2261  hor->Add(new NWidgetLeaf(i == WID_TN_SAVE ? WWT_IMGBTN_2 : WWT_IMGBTN, COLOUR_GREY, i, toolbar_button_sprites[i], STR_TOOLBAR_TOOLTIP_PAUSE_GAME + i));
2262  }
2263 
2264  *biggest_index = std::max<int>(*biggest_index, WID_TN_SWITCH_BAR);
2265  return hor;
2266 }
2267 
2268 static const NWidgetPart _nested_toolbar_normal_widgets[] = {
2270 };
2271 
2272 static WindowDesc _toolb_normal_desc(
2273  WDP_MANUAL, nullptr, 0, 0,
2275  WDF_NO_FOCUS,
2276  _nested_toolbar_normal_widgets, lengthof(_nested_toolbar_normal_widgets),
2277  &MainToolbarWindow::hotkeys
2278 );
2279 
2280 
2281 /* --- Toolbar handling for the scenario editor */
2282 
2283 static MenuClickedProc * const _scen_toolbar_dropdown_procs[] = {
2284  nullptr, // 0
2285  nullptr, // 1
2286  MenuClickSettings, // 2
2287  MenuClickSaveLoad, // 3
2288  nullptr, // 4
2289  nullptr, // 5
2290  nullptr, // 6
2291  nullptr, // 7
2292  MenuClickMap, // 8
2293  nullptr, // 9
2294  nullptr, // 10
2295  nullptr, // 11
2296  nullptr, // 12
2297  nullptr, // 13
2298  ToolbarScenBuildRoad, // 14
2299  ToolbarScenBuildTram, // 15
2300  nullptr, // 16
2301  nullptr, // 17
2302  nullptr, // 18
2303  nullptr, // 19
2304  MenuClickMusicWindow, // 20
2305  MenuClickHelp, // 21
2306  nullptr, // 22
2307 };
2308 
2309 static ToolbarButtonProc * const _scen_toolbar_button_procs[] = {
2310  ToolbarPauseClick,
2314  ToolbarBtn_NULL,
2316  ToolbarScenDateBackward,
2317  ToolbarScenDateForward,
2318  ToolbarScenMapTownDir,
2319  ToolbarZoomInClick,
2320  ToolbarZoomOutClick,
2321  ToolbarScenGenLand,
2322  ToolbarScenGenTown,
2323  ToolbarScenGenIndustry,
2324  ToolbarScenBuildRoadClick,
2325  ToolbarScenBuildTramClick,
2326  ToolbarScenBuildDocks,
2327  ToolbarScenPlantTrees,
2328  ToolbarScenPlaceSign,
2329  ToolbarBtn_NULL,
2330  ToolbarMusicClick,
2331  ToolbarHelpClick,
2332  ToolbarSwitchClick,
2333 };
2334 
2335 enum MainToolbarEditorHotkeys {
2336  MTEHK_PAUSE,
2337  MTEHK_FASTFORWARD,
2338  MTEHK_SETTINGS,
2339  MTEHK_SAVEGAME,
2340  MTEHK_GENLAND,
2341  MTEHK_GENTOWN,
2342  MTEHK_GENINDUSTRY,
2343  MTEHK_BUILD_ROAD,
2344  MTEHK_BUILD_TRAM,
2345  MTEHK_BUILD_DOCKS,
2346  MTEHK_BUILD_TREES,
2347  MTEHK_SIGN,
2348  MTEHK_MUSIC,
2349  MTEHK_LANDINFO,
2350  MTEHK_SMALL_SCREENSHOT,
2351  MTEHK_ZOOMEDIN_SCREENSHOT,
2352  MTEHK_DEFAULTZOOM_SCREENSHOT,
2353  MTEHK_GIANT_SCREENSHOT,
2354  MTEHK_ZOOM_IN,
2355  MTEHK_ZOOM_OUT,
2356  MTEHK_TERRAFORM,
2357  MTEHK_SMALLMAP,
2358  MTEHK_EXTRA_VIEWPORT,
2359 };
2360 
2362  GUITimer timer;
2363 
2365  {
2366  this->InitNested(0);
2367 
2368  _last_started_action = CBF_NONE;
2369  CLRBITS(this->flags, WF_WHITE_BORDER);
2370  PositionMainToolbar(this);
2372 
2373  this->timer.SetInterval(MILLISECONDS_PER_TICK);
2374  }
2375 
2376  void FindWindowPlacementAndResize(int def_width, int def_height) override
2377  {
2379  }
2380 
2381  void OnPaint() override
2382  {
2387 
2388  this->DrawWidgets();
2389  }
2390 
2391  void DrawWidget(const Rect &r, int widget) const override
2392  {
2393  switch (widget) {
2394  case WID_TE_DATE:
2396  DrawString(r.left, r.right, (this->height - FONT_HEIGHT_NORMAL) / 2, STR_WHITE_DATE_LONG, TC_FROMSTRING, SA_HOR_CENTER);
2397  break;
2398 
2399  case WID_TE_SPACER: {
2400  int height = r.bottom - r.top;
2401  if (height > 2 * FONT_HEIGHT_NORMAL) {
2402  DrawString(r.left, r.right, (height + 1) / 2 - FONT_HEIGHT_NORMAL, STR_SCENEDIT_TOOLBAR_OPENTTD, TC_FROMSTRING, SA_HOR_CENTER);
2403  DrawString(r.left, r.right, (height + 1) / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER);
2404  } else {
2405  DrawString(r.left, r.right, (height - FONT_HEIGHT_NORMAL) / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER);
2406  }
2407  break;
2408  }
2409  }
2410  }
2411 
2412  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
2413  {
2414  switch (widget) {
2415  case WID_TE_SPACER:
2416  size->width = std::max(GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_OPENTTD).width, GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR).width) + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
2417  break;
2418 
2419  case WID_TE_DATE:
2420  SetDParam(0, ConvertYMDToDate(MAX_YEAR, 0, 1));
2421  *size = GetStringBoundingBox(STR_WHITE_DATE_LONG);
2422  size->height = std::max(size->height, GetSpriteSize(SPR_IMG_SAVE).height + WD_IMGBTN_TOP + WD_IMGBTN_BOTTOM);
2423  break;
2424  }
2425  }
2426 
2427  void OnClick(Point pt, int widget, int click_count) override
2428  {
2429  if (_game_mode == GM_MENU) return;
2430  CallBackFunction cbf = _scen_toolbar_button_procs[widget](this);
2431  if (cbf != CBF_NONE) _last_started_action = cbf;
2432  }
2433 
2434  void OnDropdownSelect(int widget, int index) override
2435  {
2436  CallBackFunction cbf = _scen_toolbar_dropdown_procs[widget](index);
2437  if (cbf != CBF_NONE) _last_started_action = cbf;
2438  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
2439  }
2440 
2441  EventState OnHotkey(int hotkey) override
2442  {
2443  CallBackFunction cbf = CBF_NONE;
2444  switch (hotkey) {
2445  case MTEHK_PAUSE: ToolbarPauseClick(this); break;
2446  case MTEHK_FASTFORWARD: ToolbarFastForwardClick(this); break;
2447  case MTEHK_SETTINGS: ShowGameOptions(); break;
2448  case MTEHK_SAVEGAME: MenuClickSaveLoad(); break;
2449  case MTEHK_GENLAND: ToolbarScenGenLand(this); break;
2450  case MTEHK_GENTOWN: ToolbarScenGenTown(this); break;
2451  case MTEHK_GENINDUSTRY: ToolbarScenGenIndustry(this); break;
2452  case MTEHK_BUILD_ROAD: ToolbarScenBuildRoadClick(this); break;
2453  case MTEHK_BUILD_TRAM: ToolbarScenBuildTramClick(this); break;
2454  case MTEHK_BUILD_DOCKS: ToolbarScenBuildDocks(this); break;
2455  case MTEHK_BUILD_TREES: ToolbarScenPlantTrees(this); break;
2456  case MTEHK_SIGN: cbf = ToolbarScenPlaceSign(this); break;
2457  case MTEHK_MUSIC: ShowMusicWindow(); break;
2458  case MTEHK_LANDINFO: cbf = PlaceLandBlockInfo(); break;
2459  case MTEHK_SMALL_SCREENSHOT: MakeScreenshotWithConfirm(SC_VIEWPORT); break;
2460  case MTEHK_ZOOMEDIN_SCREENSHOT: MakeScreenshotWithConfirm(SC_ZOOMEDIN); break;
2461  case MTEHK_DEFAULTZOOM_SCREENSHOT: MakeScreenshotWithConfirm(SC_DEFAULTZOOM); break;
2462  case MTEHK_GIANT_SCREENSHOT: MakeScreenshotWithConfirm(SC_WORLD); break;
2463  case MTEHK_ZOOM_IN: ToolbarZoomInClick(this); break;
2464  case MTEHK_ZOOM_OUT: ToolbarZoomOutClick(this); break;
2465  case MTEHK_TERRAFORM: ShowEditorTerraformToolbar(); break;
2466  case MTEHK_SMALLMAP: ShowSmallMap(); break;
2467  case MTEHK_EXTRA_VIEWPORT: ShowExtraViewportWindowForTileUnderCursor(); break;
2468  default: return ES_NOT_HANDLED;
2469  }
2470  if (cbf != CBF_NONE) _last_started_action = cbf;
2471  return ES_HANDLED;
2472  }
2473 
2474  void OnPlaceObject(Point pt, TileIndex tile) override
2475  {
2476  switch (_last_started_action) {
2477  case CBF_PLACE_SIGN:
2478  PlaceProc_Sign(tile);
2479  break;
2480 
2481  case CBF_PLACE_LANDINFO:
2482  ShowLandInfo(tile);
2483  break;
2484 
2485  default: NOT_REACHED();
2486  }
2487  }
2488 
2489  void OnPlaceObjectAbort() override
2490  {
2491  _last_started_action = CBF_NONE;
2492  }
2493 
2494  void OnTimeout() override
2495  {
2499  }
2500 
2501  void OnRealtimeTick(uint delta_ms) override
2502  {
2503  if (!this->timer.Elapsed(delta_ms)) return;
2504  this->timer.SetInterval(MILLISECONDS_PER_TICK);
2505 
2506  if (this->IsWidgetLowered(WID_TE_PAUSE) != !!_pause_mode) {
2508  this->SetDirty();
2509  }
2510 
2511  if (this->IsWidgetLowered(WID_TE_FAST_FORWARD) != !!_fast_forward) {
2513  this->SetDirty();
2514  }
2515  }
2516 
2522  void OnInvalidateData(int data = 0, bool gui_scope = true) override
2523  {
2524  if (!gui_scope) return;
2526  }
2527 
2528  void OnQueryTextFinished(char *str) override
2529  {
2530  /* Was 'cancel' pressed? */
2531  if (str == nullptr) return;
2532 
2533  int32 value;
2534  if (!StrEmpty(str)) {
2535  value = atoi(str);
2536  } else {
2537  /* An empty string means revert to the default */
2538  value = DEF_START_YEAR;
2539  }
2540  SetStartingYear(value);
2541 
2542  this->SetDirty();
2543  }
2544 
2545  static HotkeyList hotkeys;
2546 };
2547 
2548 static Hotkey scenedit_maintoolbar_hotkeys[] = {
2549  Hotkey(_maintoolbar_pause_keys, "pause", MTEHK_PAUSE),
2550  Hotkey((uint16)0, "fastforward", MTEHK_FASTFORWARD),
2551  Hotkey(WKC_F2, "settings", MTEHK_SETTINGS),
2552  Hotkey(WKC_F3, "saveload", MTEHK_SAVEGAME),
2553  Hotkey(WKC_F4, "gen_land", MTEHK_GENLAND),
2554  Hotkey(WKC_F5, "gen_town", MTEHK_GENTOWN),
2555  Hotkey(WKC_F6, "gen_industry", MTEHK_GENINDUSTRY),
2556  Hotkey(WKC_F7, "build_road", MTEHK_BUILD_ROAD),
2557  Hotkey((uint16)0, "build_tram", MTEHK_BUILD_TRAM),
2558  Hotkey(WKC_F8, "build_docks", MTEHK_BUILD_DOCKS),
2559  Hotkey(WKC_F9, "build_trees", MTEHK_BUILD_TREES),
2560  Hotkey(WKC_F10, "build_sign", MTEHK_SIGN),
2561  Hotkey(WKC_F11, "music", MTEHK_MUSIC),
2562  Hotkey(WKC_F12, "land_info", MTEHK_LANDINFO),
2563  Hotkey(WKC_CTRL | 'S', "small_screenshot", MTEHK_SMALL_SCREENSHOT),
2564  Hotkey(WKC_CTRL | 'P', "zoomedin_screenshot", MTEHK_ZOOMEDIN_SCREENSHOT),
2565  Hotkey(WKC_CTRL | 'D', "defaultzoom_screenshot", MTEHK_DEFAULTZOOM_SCREENSHOT),
2566  Hotkey((uint16)0, "giant_screenshot", MTEHK_GIANT_SCREENSHOT),
2567  Hotkey(_maintoolbar_zoomin_keys, "zoomin", MTEHK_ZOOM_IN),
2568  Hotkey(_maintoolbar_zoomout_keys, "zoomout", MTEHK_ZOOM_OUT),
2569  Hotkey('L', "terraform", MTEHK_TERRAFORM),
2570  Hotkey('M', "smallmap", MTEHK_SMALLMAP),
2571  Hotkey('V', "extra_viewport", MTEHK_EXTRA_VIEWPORT),
2572  HOTKEY_LIST_END
2573 };
2574 HotkeyList ScenarioEditorToolbarWindow::hotkeys("scenedit_maintoolbar", scenedit_maintoolbar_hotkeys);
2575 
2576 static const NWidgetPart _nested_toolb_scen_inner_widgets[] = {
2577  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_PAUSE), SetDataTip(SPR_IMG_PAUSE, STR_TOOLBAR_TOOLTIP_PAUSE_GAME),
2578  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_FAST_FORWARD), SetDataTip(SPR_IMG_FASTFORWARD, STR_TOOLBAR_TOOLTIP_FORWARD),
2579  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SETTINGS), SetDataTip(SPR_IMG_SETTINGS, STR_TOOLBAR_TOOLTIP_OPTIONS),
2580  NWidget(WWT_IMGBTN_2, COLOUR_GREY, WID_TE_SAVE), SetDataTip(SPR_IMG_SAVE, STR_SCENEDIT_TOOLBAR_TOOLTIP_SAVE_SCENARIO_LOAD_SCENARIO),
2582  NWidget(WWT_PANEL, COLOUR_GREY, WID_TE_SPACER), EndContainer(),
2584  NWidget(WWT_PANEL, COLOUR_GREY, WID_TE_DATE_PANEL),
2585  NWidget(NWID_HORIZONTAL), SetPIP(3, 2, 3),
2586  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_DATE_BACKWARD), SetDataTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_BACKWARD),
2587  NWidget(WWT_EMPTY, COLOUR_GREY, WID_TE_DATE), SetDataTip(STR_NULL, STR_SCENEDIT_TOOLBAR_TOOLTIP_SET_DATE),
2588  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_DATE_FORWARD), SetDataTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_FORWARD),
2589  EndContainer(),
2590  EndContainer(),
2592  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SMALL_MAP), SetDataTip(SPR_IMG_SMALLMAP, STR_SCENEDIT_TOOLBAR_TOOLTIP_DISPLAY_MAP_TOWN_DIRECTORY),
2594  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_ZOOM_IN), SetDataTip(SPR_IMG_ZOOMIN, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_IN),
2595  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_ZOOM_OUT), SetDataTip(SPR_IMG_ZOOMOUT, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_OUT),
2597  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_LAND_GENERATE), SetDataTip(SPR_IMG_LANDSCAPING, STR_SCENEDIT_TOOLBAR_LANDSCAPE_GENERATION),
2598  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_TOWN_GENERATE), SetDataTip(SPR_IMG_TOWN, STR_SCENEDIT_TOOLBAR_TOWN_GENERATION),
2599  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_INDUSTRY), SetDataTip(SPR_IMG_INDUSTRY, STR_SCENEDIT_TOOLBAR_INDUSTRY_GENERATION),
2600  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_ROADS), SetDataTip(SPR_IMG_BUILDROAD, STR_SCENEDIT_TOOLBAR_ROAD_CONSTRUCTION),
2601  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_TRAMS), SetDataTip(SPR_IMG_BUILDTRAMS, STR_SCENEDIT_TOOLBAR_TRAM_CONSTRUCTION),
2602  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_WATER), SetDataTip(SPR_IMG_BUILDWATER, STR_TOOLBAR_TOOLTIP_BUILD_SHIP_DOCKS),
2603  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_TREES), SetDataTip(SPR_IMG_PLANTTREES, STR_SCENEDIT_TOOLBAR_PLANT_TREES),
2604  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_SIGNS), SetDataTip(SPR_IMG_SIGN, STR_SCENEDIT_TOOLBAR_PLACE_SIGN),
2606  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_MUSIC_SOUND), SetDataTip(SPR_IMG_MUSIC, STR_TOOLBAR_TOOLTIP_SHOW_SOUND_MUSIC_WINDOW),
2607  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_HELP), SetDataTip(SPR_IMG_QUERY, STR_TOOLBAR_TOOLTIP_LAND_BLOCK_INFORMATION),
2608  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SWITCH_BAR), SetDataTip(SPR_IMG_SWITCH_TOOLBAR, STR_TOOLBAR_TOOLTIP_SWITCH_TOOLBAR),
2609 };
2610 
2611 static NWidgetBase *MakeScenarioToolbar(int *biggest_index)
2612 {
2613  return MakeNWidgets(_nested_toolb_scen_inner_widgets, lengthof(_nested_toolb_scen_inner_widgets), biggest_index, new NWidgetScenarioToolbarContainer());
2614 }
2615 
2616 static const NWidgetPart _nested_toolb_scen_widgets[] = {
2617  NWidgetFunction(MakeScenarioToolbar),
2618 };
2619 
2620 static WindowDesc _toolb_scen_desc(
2621  WDP_MANUAL, nullptr, 0, 0,
2623  WDF_NO_FOCUS,
2624  _nested_toolb_scen_widgets, lengthof(_nested_toolb_scen_widgets),
2625  &ScenarioEditorToolbarWindow::hotkeys
2626 );
2627 
2630 {
2631  /* Clean old GUI values; railtype is (re)set by rail_gui.cpp */
2632  _last_built_roadtype = ROADTYPE_ROAD;
2633  _last_built_tramtype = ROADTYPE_TRAM;
2634 
2635  if (_game_mode == GM_EDITOR) {
2636  new ScenarioEditorToolbarWindow(&_toolb_scen_desc);
2637  } else {
2638  new MainToolbarWindow(&_toolb_normal_desc);
2639  }
2640 }
VEH_AIRCRAFT
@ VEH_AIRCRAFT
Aircraft vehicle type.
Definition: vehicle_type.h:27
SaveLoadEditorMenuEntries
SaveLoadEditorMenuEntries
SaveLoad entries in scenario editor mode.
Definition: toolbar_gui.cpp:379
WID_TE_LAND_GENERATE
@ WID_TE_LAND_GENERATE
Land generation.
Definition: toolbar_widget.h:64
DO_SHOW_COMPETITOR_SIGNS
@ DO_SHOW_COMPETITOR_SIGNS
Display signs, station names and waypoint names of opponent companies. Buoys and oilrig-stations are ...
Definition: openttd.h:49
ShowNewGRFSettings
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
Definition: newgrf_gui.cpp:1994
game.hpp
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:718
MenuClickFinances
static CallBackFunction MenuClickFinances(int index)
Handle click on the entry in the finances overview menu.
Definition: toolbar_gui.cpp:586
ShowSpriteAlignerWindow
void ShowSpriteAlignerWindow()
Show the window for aligning sprites.
Definition: newgrf_debug_gui.cpp:1098
ShowIndustryCargoesWindow
void ShowIndustryCargoesWindow()
Open the industry and cargoes window with an industry.
Definition: industry_gui.cpp:3045
ScenarioEditorToolbarWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: toolbar_gui.cpp:2434
PopupMainToolbMenu
static void PopupMainToolbMenu(Window *w, int widget, DropDownList &&list, int def)
Pop up a generic text only menu.
Definition: toolbar_gui.cpp:183
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
WID_TN_BUILDING_TOOLS_START
@ WID_TN_BUILDING_TOOLS_START
Helper for the offset of the building tools.
Definition: toolbar_widget.h:37
WID_TN_SAVE
@ WID_TN_SAVE
Save menu.
Definition: toolbar_widget.h:18
sound_func.h
_last_started_action
static CallBackFunction _last_started_action
Last started user action.
Definition: toolbar_gui.cpp:83
WID_TN_COMPANIES
@ WID_TN_COMPANIES
Company menu.
Definition: toolbar_widget.h:24
WID_TN_FINANCES
@ WID_TN_FINANCES
Finance menu.
Definition: toolbar_widget.h:23
WWT_IMGBTN_2
@ WWT_IMGBTN_2
(Toggle) Button with diff image when clicked
Definition: widget_type.h:51
NWidgetFunction
static NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition: widget_type.h:1145
FT_SCENARIO
@ FT_SCENARIO
old or new scenario
Definition: fileio_type.h:19
MenuClickTown
static CallBackFunction MenuClickTown(int index)
Handle click on one of the entries in the Town menu.
Definition: toolbar_gui.cpp:519
DropDownListItem::result
int result
Result code to return to window on selection.
Definition: dropdown_type.h:24
vehicle_gui.h
WID_TN_ROADS
@ WID_TN_ROADS
Road building menu.
Definition: toolbar_widget.h:39
CTMN_NEW_COMPANY
static const int CTMN_NEW_COMPANY
Create a new company.
Definition: toolbar_gui.cpp:207
TO_HOUSES
@ TO_HOUSES
town buildings
Definition: transparency.h:25
Window::timeout_timer
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
Definition: window_gui.h:314
WID_TN_WATER
@ WID_TN_WATER
Water building toolbar.
Definition: toolbar_widget.h:41
ShowGoalsList
void ShowGoalsList(CompanyID company)
Open a goal list window.
Definition: goal_gui.cpp:351
GetRailTypeDropDownList
DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option)
Create a drop down list for all the rail types of the local company.
Definition: rail_gui.cpp:1985
ShowExtraViewportWindow
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
Definition: viewport_gui.cpp:168
HotkeyList
List of hotkeys for a window.
Definition: hotkeys.h:40
GUISettings::newgrf_developer_tools
bool newgrf_developer_tools
activate NewGRF developer tools and allow modifying NewGRFs in an existing game
Definition: settings_type.h:163
MenuClickIndustry
static CallBackFunction MenuClickIndustry(int index)
Handle click on the entry in the Industry menu.
Definition: toolbar_gui.cpp:745
LinkGraphSchedule::ShiftDates
void ShiftDates(int interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
Definition: linkgraphschedule.cpp:134
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
ZOOM_OUT
@ ZOOM_OUT
Zoom out (get helicopter view).
Definition: viewport_type.h:82
command_func.h
MenuClickGraphs
static CallBackFunction MenuClickGraphs(int index)
Handle click on the entry in the Graphs menu.
Definition: toolbar_gui.cpp:690
PositionMainToolbar
int PositionMainToolbar(Window *w)
(Re)position main toolbar window at the screen.
Definition: window.cpp:3505
NetworkMaxSpectatorsReached
bool NetworkMaxSpectatorsReached()
Check if max_spectatos has been reached on the server (local check only).
Definition: network_client.cpp:1332
ShowBuildAirToolbar
Window * ShowBuildAirToolbar()
Open the build airport toolbar window.
Definition: airport_gui.cpp:216
WID_TE_ROADS
@ WID_TE_ROADS
Road building menu.
Definition: toolbar_widget.h:67
PC_DARK_RED
static const uint8 PC_DARK_RED
Dark red palette colour.
Definition: gfx_func.h:210
toolbar_gui.h
smallmap_gui.h
ShowStoryBook
void ShowStoryBook(CompanyID company, uint16 page_id=INVALID_STORY_PAGE)
Raise or create the story book window for company, at page page_id.
Definition: story_gui.cpp:1062
guitimer_func.h
Window::ReInit
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:995
IsTransparencySet
static bool IsTransparencySet(TransparencyOption to)
Check if the transparency option bit is set and if we aren't in the game menu (there's never transpar...
Definition: transparency.h:48
NWidgetContainer::Add
void Add(NWidgetBase *wid)
Append widget wid to container.
Definition: widget.cpp:951
WID_TE_SAVE
@ WID_TE_SAVE
Save menu.
Definition: toolbar_widget.h:56
ToolbarFastForwardClick
static CallBackFunction ToolbarFastForwardClick(Window *w)
Toggle fast forward mode.
Definition: toolbar_gui.cpp:284
NWidgetToolbarContainer::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: toolbar_gui.cpp:1456
signs_func.h
WID_TN_AIR
@ WID_TN_AIR
Airport building toolbar.
Definition: toolbar_widget.h:42
company_gui.h
TF_FORBIDDEN
@ TF_FORBIDDEN
Forbidden.
Definition: town_type.h:94
WID_TN_STORY
@ WID_TN_STORY
Story menu.
Definition: toolbar_widget.h:25
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:50
Window::viewport
ViewportData * viewport
Pointer to viewport data, if present.
Definition: window_gui.h:326
_network_server
bool _network_server
network-server is active
Definition: network.cpp:53
NWidgetToolbarContainer::Draw
void Draw(const Window *w) override
Definition: toolbar_gui.cpp:1441
DropDownList
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
Definition: dropdown_type.h:99
WID_TE_ZOOM_IN
@ WID_TE_ZOOM_IN
Zoom in the main viewport.
Definition: toolbar_widget.h:62
LinkGraphSchedule::instance
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
Definition: linkgraphschedule.h:52
ToolbarSaveClick
static CallBackFunction ToolbarSaveClick(Window *w)
Handle click on Save button in toolbar in normal game mode.
Definition: toolbar_gui.cpp:406
MainToolbarWindow::OnRealtimeTick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition: toolbar_gui.cpp:2120
WID_TE_WATER
@ WID_TE_WATER
Water building toolbar.
Definition: toolbar_widget.h:69
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
WID_TE_PAUSE
@ WID_TE_PAUSE
Pause the game.
Definition: toolbar_widget.h:53
WID_TE_DATE
@ WID_TE_DATE
The date of the scenario.
Definition: toolbar_widget.h:58
ZOOM_NONE
@ ZOOM_NONE
Hack, used to update the button status.
Definition: viewport_type.h:83
WID_TN_STATIONS
@ WID_TN_STATIONS
Station menu.
Definition: toolbar_widget.h:22
SetDate
void SetDate(Date date, DateFract fract)
Set the date.
Definition: date.cpp:36
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1133
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
ai_gui.hpp
NWidgetSpacer
Spacer widget.
Definition: widget_type.h:528
WC_SIGN_LIST
@ WC_SIGN_LIST
Sign list; Window numbers:
Definition: window_type.h:271
ClrBit
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
Definition: bitmath_func.hpp:151
NetworkServerDoMove
void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
Handle the tid-bits of moving a client from one company to another.
Definition: network_server.cpp:2013
WID_TN_GOAL
@ WID_TN_GOAL
Goal menu.
Definition: toolbar_widget.h:26
WDF_NO_FOCUS
@ WDF_NO_FOCUS
This window won't get focus/make any other window lose focus when click.
Definition: window_gui.h:210
ToolbarScenSaveOrLoad
static CallBackFunction ToolbarScenSaveOrLoad(Window *w)
Handle click on SaveLoad button in toolbar in the scenario editor.
Definition: toolbar_gui.cpp:418
NWidgetScenarioToolbarContainer::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: toolbar_gui.cpp:1807
FILLRECT_CHECKER
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
Definition: gfx_type.h:288
WID_TE_ZOOM_OUT
@ WID_TE_ZOOM_OUT
Zoom out the main viewport.
Definition: toolbar_widget.h:63
Year
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
Definition: date_type.h:18
ShowMessageHistory
void ShowMessageHistory()
Display window with news messages history.
Definition: news_gui.cpp:1253
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:250
vehicle_base.h
DoZoomInOutWindow
bool DoZoomInOutWindow(ZoomStateChange how, Window *w)
Zooms a viewport in a window in or out.
Definition: main_gui.cpp:91
screenshot_gui.h
ShowGameOptions
void ShowGameOptions()
Open the game options window.
Definition: settings_gui.cpp:686
NWidgetLeaf
Leaf widget.
Definition: widget_type.h:769
WID_TN_PAUSE
@ WID_TN_PAUSE
Pause the game.
Definition: toolbar_widget.h:15
ShowLandInfo
void ShowLandInfo(TileIndex tile)
Show land information window.
Definition: misc_gui.cpp:400
goal_base.h
DropDownListItem
Base list item class from which others are derived.
Definition: dropdown_type.h:22
ShowGameSettings
void ShowGameSettings()
Open advanced settings window.
Definition: settings_gui.cpp:2403
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:79
DrawString
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:636
SC_ZOOMEDIN
@ SC_ZOOMEDIN
Fully zoomed in screenshot of the visible area.
Definition: screenshot.h:21
ShowBuildRailToolbar
Window * ShowBuildRailToolbar(RailType railtype)
Open the build rail toolbar window for a specific rail type.
Definition: rail_gui.cpp:858
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
CallBackFunction
CallBackFunction
Callback functions.
Definition: toolbar_gui.cpp:77
newgrf_debug.h
network_gui.h
MainToolbarWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: toolbar_gui.cpp:2050
NWidgetScenarioToolbarContainer
Container for the scenario editor's toolbar.
Definition: toolbar_gui.cpp:1804
_display_opt
byte _display_opt
What do we want to draw/do?
Definition: transparency_gui.cpp:26
ScenarioEditorToolbarWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: toolbar_gui.cpp:2441
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:222
WID_TE_DATE_FORWARD
@ WID_TE_DATE_FORWARD
Increase the date of the scenario.
Definition: toolbar_widget.h:60
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_func.h:95
WID_TN_END
@ WID_TN_END
Helper for knowing the amount of widgets.
Definition: toolbar_widget.h:48
Window::HandleButtonClick
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
Definition: window.cpp:635
ROADTYPE_ROAD
@ ROADTYPE_ROAD
Basic road type.
Definition: road_type.h:24
MenuClickMap
static CallBackFunction MenuClickMap(int index)
Handle click on one of the entries in the Map menu.
Definition: toolbar_gui.cpp:492
fios.h
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
NWidgetBase::smallest_y
uint smallest_y
Smallest vertical size of the widget in a filled window.
Definition: widget_type.h:170
MakeNWidgets
NWidgetContainer * MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index, NWidgetContainer *container)
Construct a nested widget tree from an array of parts.
Definition: widget.cpp:2799
MenuClickBuildTram
static CallBackFunction MenuClickBuildTram(int index)
Handle click on the entry in the Build Tram menu.
Definition: toolbar_gui.cpp:927
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1871
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:199
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:909
ShowExtraViewportWindowForTileUnderCursor
void ShowExtraViewportWindowForTileUnderCursor()
Show a new Extra Viewport window.
Definition: viewport_gui.cpp:183
WID_TE_TOWN_GENERATE
@ WID_TE_TOWN_GENERATE
Town building window.
Definition: toolbar_widget.h:65
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1013
WID_TE_DATE_PANEL
@ WID_TE_DATE_PANEL
Container for the date widgets.
Definition: toolbar_widget.h:72
toolbar_widget.h
WD_IMGBTN_BOTTOM
@ WD_IMGBTN_BOTTOM
Bottom offset of image in the button.
Definition: window_gui.h:41
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:838
DropDownListCompanyItem
Drop down list entry for showing a company entry, with companies 'blob'.
Definition: toolbar_gui.cpp:117
WID_TN_ZOOM_OUT
@ WID_TN_ZOOM_OUT
Zoom out the main viewport.
Definition: toolbar_widget.h:36
textbuf_gui.h
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:548
WID_TN_TRAMS
@ WID_TN_TRAMS
Tram building menu.
Definition: toolbar_widget.h:40
OptionMenuEntries
OptionMenuEntries
Game Option button menu entries.
Definition: toolbar_gui.cpp:294
MainToolbarWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: toolbar_gui.cpp:2136
screenshot.h
PM_UNPAUSED
@ PM_UNPAUSED
A normal unpaused game.
Definition: openttd.h:59
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
NWidgetBase::Draw
virtual void Draw(const Window *w)=0
NWidgetBase::prev
NWidgetBase * prev
Pointer to previous widget in container. Managed by parent container widget.
Definition: widget_type.h:179
WindowDesc
High level window description.
Definition: window_gui.h:166
WID_TN_LEAGUE
@ WID_TN_LEAGUE
Company league menu.
Definition: toolbar_widget.h:28
COMPANY_FIRST
@ COMPANY_FIRST
First company, same as owner.
Definition: company_type.h:22
CTMN_SPECTATE
static const int CTMN_SPECTATE
Become spectator.
Definition: toolbar_gui.cpp:208
MainToolbarWindow::OnPlaceObject
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
Definition: toolbar_gui.cpp:2100
window_gui.h
DO_FULL_ANIMATION
@ DO_FULL_ANIMATION
Perform palette animation.
Definition: openttd.h:46
ShowCompanyFinances
void ShowCompanyFinances(CompanyID company)
Open the finances window of a company.
Definition: company_gui.cpp:480
ZOOM_IN
@ ZOOM_IN
Zoom in (get more detailed view).
Definition: viewport_type.h:81
WID_TE_SPACER
@ WID_TE_SPACER
Spacer with "scenario editor" text.
Definition: toolbar_widget.h:57
ScenarioEditorToolbarWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: toolbar_gui.cpp:2412
ScenarioEditorToolbarWindow::FindWindowPlacementAndResize
void FindWindowPlacementAndResize(int def_width, int def_height) override
Resize window towards the default size.
Definition: toolbar_gui.cpp:2376
WID_TN_MUSIC_SOUND
@ WID_TN_MUSIC_SOUND
Music/sound configuration menu.
Definition: toolbar_widget.h:44
ScenarioEditorToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: toolbar_gui.cpp:2489
WID_TN_HELP
@ WID_TN_HELP
Help menu.
Definition: toolbar_widget.h:46
GUITimer
Definition: guitimer_func.h:13
_roadtypes_type
RoadTypes _roadtypes_type
Bitmap of road/tram types.
Definition: road_cmd.cpp:57
NWidgetToolbarContainer::GetButtonArrangement
virtual const byte * GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const =0
Get the arrangement of the buttons for the toolbar.
WID_TN_SHIPS
@ WID_TN_SHIPS
Ship menu.
Definition: toolbar_widget.h:33
SLO_LOAD
@ SLO_LOAD
File is being loaded.
Definition: fileio_type.h:49
ShowSignList
Window * ShowSignList()
Open the sign list window.
Definition: signs_gui.cpp:400
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
NWidgetScenarioToolbarContainer::GetButtonArrangement
const byte * GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override
Get the arrangement of the buttons for the toolbar.
Definition: toolbar_gui.cpp:1822
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:322
WKC_EQUALS
@ WKC_EQUALS
= Equals
Definition: gfx_type.h:97
_date
Date _date
Current date in days (day counter)
Definition: date.cpp:27
SLO_SAVE
@ SLO_SAVE
File is being saved.
Definition: fileio_type.h:50
CTMN_CLIENT_LIST
static const int CTMN_CLIENT_LIST
Enum for the Company Toolbar's network related buttons.
Definition: toolbar_gui.cpp:206
tilehighlight_func.h
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:568
ToolbarScenBuildTram
static CallBackFunction ToolbarScenBuildTram(int index)
Handle click on the entry in the Build Tram menu.
Definition: toolbar_gui.cpp:1254
DoCommandP
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Definition: command.cpp:541
NWidgetContainer::tail
NWidgetBase * tail
Pointer to last widget in container.
Definition: widget_type.h:382
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1861
CMD_PAUSE
@ CMD_PAUSE
pause the game
Definition: command_type.h:256
NetworkMaxCompaniesReached
bool NetworkMaxCompaniesReached()
Check if max_companies has been reached on the server (local check only).
Definition: network_client.cpp:1323
NWidgetBase::type
WidgetType type
Type of the widget / nested widget.
Definition: widget_type.h:161
WID_TE_DATE_BACKWARD
@ WID_TE_DATE_BACKWARD
Reduce the date of the scenario.
Definition: toolbar_widget.h:59
MIN_YEAR
static const Year MIN_YEAR
The absolute minimum & maximum years in OTTD.
Definition: date_type.h:83
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:320
_toolbar_width
uint _toolbar_width
Width of the toolbar, shared by statusbar.
Definition: toolbar_gui.cpp:63
WF_WHITE_BORDER
@ WF_WHITE_BORDER
Window white border counter bit mask.
Definition: window_gui.h:240
ShowCompanyStations
void ShowCompanyStations(CompanyID company)
Opens window with list of company's stations.
Definition: station_gui.cpp:780
SaveLoadNormalMenuEntries
SaveLoadNormalMenuEntries
SaveLoad entries in normal game mode.
Definition: toolbar_gui.cpp:392
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:984
highscore.h
NWidgetBase::smallest_x
uint smallest_x
Smallest horizontal size of the widget in a filled window.
Definition: widget_type.h:169
WD_FRAMERECT_LEFT
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:60
WID_TN_SETTINGS
@ WID_TN_SETTINGS
Settings menu.
Definition: toolbar_widget.h:17
NWidgetBase::AssignSizePosition
virtual void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)=0
ConvertYMDToDate
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: date.cpp:148
IsInsideBS
static bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
Definition: math_func.hpp:188
WID_TN_LANDSCAPE
@ WID_TN_LANDSCAPE
Landscaping toolbar.
Definition: toolbar_widget.h:43
ROADTYPE_TRAM
@ ROADTYPE_TRAM
Trams.
Definition: road_type.h:25
WD_FRAMERECT_RIGHT
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:61
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:719
MenuClickShowShips
static CallBackFunction MenuClickShowShips(int index)
Handle click on the entry in the Ships menu.
Definition: toolbar_gui.cpp:820
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:124
AllocateToolbar
void AllocateToolbar()
Allocate the toolbar.
Definition: toolbar_gui.cpp:2629
ShowFramerateWindow
void ShowFramerateWindow()
Open the general framerate window.
Definition: framerate_gui.cpp:1004
MenuClickBuildAir
static CallBackFunction MenuClickBuildAir(int index)
Handle click on the entry in the Build Air menu.
Definition: toolbar_gui.cpp:974
ToolbarOptionsClick
static CallBackFunction ToolbarOptionsClick(Window *w)
Handle click on Options button in toolbar.
Definition: toolbar_gui.cpp:317
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:14
ShowDropDownList
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
Definition: dropdown.cpp:453
_pause_mode
PauseMode _pause_mode
The current pause mode.
Definition: gfx.cpp:47
MenuClickShowRoad
static CallBackFunction MenuClickShowRoad(int index)
Handle click on the entry in the Road Vehicles menu.
Definition: toolbar_gui.cpp:800
MenuClickBuildRail
static CallBackFunction MenuClickBuildRail(int index)
Handle click on the entry in the Build Rail menu.
Definition: toolbar_gui.cpp:883
road_gui.h
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:80
linkgraph_gui.h
CCA_NEW
@ CCA_NEW
Create a new company.
Definition: company_type.h:65
NWidgetToolbarContainer::IsButton
bool IsButton(WidgetType type) const
Check whether the given widget type is a button for us.
Definition: toolbar_gui.cpp:1340
GameSettings::economy
EconomySettings economy
settings to change the economy
Definition: settings_type.h:557
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:392
MAX_COMPANIES
@ MAX_COMPANIES
Maximum number of companies.
Definition: company_type.h:23
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:45
DropDownListStringItem
Common string list item.
Definition: dropdown_type.h:39
DO_SHOW_STATION_NAMES
@ DO_SHOW_STATION_NAMES
Display station names.
Definition: openttd.h:44
safeguards.h
ShowQueryString
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
Definition: misc_gui.cpp:1131
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:310
WF_TIMEOUT
@ WF_TIMEOUT
Window timeout counter.
Definition: window_gui.h:232
CLIENT_ID_SERVER
@ CLIENT_ID_SERVER
Servers always have this ID.
Definition: network_type.h:41
MenuClickSubsidies
static CallBackFunction MenuClickSubsidies(int index)
Handle click on the entry in the Subsidies menu.
Definition: toolbar_gui.cpp:544
MenuClickShowAir
static CallBackFunction MenuClickShowAir(int index)
Handle click on the entry in the Aircraft menu.
Definition: toolbar_gui.cpp:840
MenuClickSaveLoad
static CallBackFunction MenuClickSaveLoad(int index=0)
Handle click on one of the entries in the SaveLoad menu.
Definition: toolbar_gui.cpp:430
ToggleDirtyBlocks
void ToggleDirtyBlocks()
Toggle drawing of the dirty blocks.
Definition: toolbar_gui.cpp:1096
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:60
TC_NO_SHADE
@ TC_NO_SHADE
Do not add shading to this text colour.
Definition: gfx_type.h:274
_networking
bool _networking
are we in networking mode?
Definition: network.cpp:52
DrawSprite
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:974
ToolbarScenDatePanel
static CallBackFunction ToolbarScenDatePanel(Window *w)
Called when clicking at the date panel of the scenario editor toolbar.
Definition: toolbar_gui.cpp:1161
road.h
MainToolbarWindow::FindWindowPlacementAndResize
void FindWindowPlacementAndResize(int def_width, int def_height) override
Resize window towards the default size.
Definition: toolbar_gui.cpp:2019
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
EconomySettings::found_town
TownFounding found_town
town founding.
Definition: settings_type.h:490
WID_TN_SUBSIDIES
@ WID_TN_SUBSIDIES
Subsidy menu.
Definition: toolbar_widget.h:21
CheckBlitter
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
Definition: gfxinit.cpp:329
NWidgetContainer::head
NWidgetBase * head
Pointer to first widget in container.
Definition: widget_type.h:381
NWidgetToolbarContainer::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: toolbar_gui.cpp:1345
date_func.h
ShowCheatWindow
void ShowCheatWindow()
Open cheat window.
Definition: cheat_gui.cpp:416
stdafx.h
ShowSaveLoadDialog
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
Definition: fios_gui.cpp:920
FT_SAVEGAME
@ FT_SAVEGAME
old or new savegame
Definition: fileio_type.h:18
MainToolbarWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: toolbar_gui.cpp:2153
DO_FULL_DETAIL
@ DO_FULL_DETAIL
Also draw details of track and roads.
Definition: openttd.h:47
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:22
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
GfxFillRect
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
Definition: gfx.cpp:110
ToggleBoundingBoxes
void ToggleBoundingBoxes()
Toggle drawing of sprites' bounding boxes.
Definition: toolbar_gui.cpp:1079
ScenarioEditorToolbarWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: toolbar_gui.cpp:2427
MenuClickCompany
static CallBackFunction MenuClickCompany(int index)
Handle click on the entry in the Company menu.
Definition: toolbar_gui.cpp:606
MainToolbarWindow
Main toolbar.
Definition: toolbar_gui.cpp:2002
WID_TN_ROADVEHS
@ WID_TN_ROADVEHS
Road vehicle menu.
Definition: toolbar_widget.h:32
viewport_func.h
NetworkCompanyIsPassworded
bool NetworkCompanyIsPassworded(CompanyID company_id)
Check if the company we want to join requires a password.
Definition: network.cpp:213
NWidgetBase::current_y
uint current_y
Current vertical size (after resizing).
Definition: widget_type.h:173
ToolbarScenBuildRoad
static CallBackFunction ToolbarScenBuildRoad(int index)
Handle click on the entry in the Build Road menu.
Definition: toolbar_gui.cpp:1234
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
WID_TE_SETTINGS
@ WID_TE_SETTINGS
Settings menu.
Definition: toolbar_widget.h:55
NWidgetBase::next
NWidgetBase * next
Pointer to next widget in container. Managed by parent container widget.
Definition: widget_type.h:178
WID_TN_AIRCRAFT
@ WID_TN_AIRCRAFT
Aircraft menu.
Definition: toolbar_widget.h:34
WidgetType
WidgetType
Window widget types, nested widget types, and nested widget part types.
Definition: widget_type.h:44
DrawCompanyIcon
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
Definition: company_cmd.cpp:141
_network_own_client_id
ClientID _network_own_client_id
Our client identifier.
Definition: network.cpp:59
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:909
ShowHighscoreTable
void ShowHighscoreTable(int difficulty=SP_CUSTOM, int8 rank=-1)
Show the highscore table for a given difficulty.
Definition: highscore_gui.cpp:230
WID_TE_SIGNS
@ WID_TE_SIGNS
Sign building.
Definition: toolbar_widget.h:71
MenuClickStory
static CallBackFunction MenuClickStory(int index)
Handle click on the entry in the Story menu.
Definition: toolbar_gui.cpp:650
ScenarioEditorToolbarWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: toolbar_gui.cpp:2528
NWidgetMainToolbarContainer
Container for the 'normal' main toolbar.
Definition: toolbar_gui.cpp:1482
rail_gui.h
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
WWT_PUSHIMGBTN
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:103
NWidgetBase::fill_y
uint fill_y
Vertical fill stepsize (from initial size, 0 means not resizable).
Definition: widget_type.h:163
MakeMainToolbar
static NWidgetBase * MakeMainToolbar(int *biggest_index)
Definition: toolbar_gui.cpp:2212
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:185
vehicle_func.h
WID_TE_HELP
@ WID_TE_HELP
Help menu.
Definition: toolbar_widget.h:74
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:998
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:77
Pool::PoolItem<&_vehicle_pool >::Iterate
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:378
strings_func.h
WID_TE_TREES
@ WID_TE_TREES
Tree building toolbar.
Definition: toolbar_widget.h:70
terraform_gui.h
ScenarioEditorToolbarWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: toolbar_gui.cpp:2522
MainToolbarWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: toolbar_gui.cpp:2024
SC_WORLD
@ SC_WORLD
World screenshot.
Definition: screenshot.h:23
ShowBuildDocksScenToolbar
Window * ShowBuildDocksScenToolbar()
Open the build water toolbar window for the scenario editor.
Definition: dock_gui.cpp:398
graph_gui.h
MenuClickHelp
static CallBackFunction MenuClickHelp(int index)
Choose the proper callback function for the main toolbar's help menu.
Definition: toolbar_gui.cpp:1124
PC_VERY_DARK_RED
static const uint8 PC_VERY_DARK_RED
Almost-black red palette colour.
Definition: gfx_func.h:209
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:175
Pool::PoolItem<&_company_pool >::GetNumItems
static size_t GetNumItems()
Returns number of valid items in the pool.
Definition: pool_type.hpp:359
DeleteAllMessages
void DeleteAllMessages()
Delete all messages and their corresponding window (if any).
Definition: window.cpp:3416
WIDGET_LIST_END
static const int WIDGET_LIST_END
indicate the end of widgets' list for vararg functions
Definition: widget_type.h:20
NetworkSendCommand
void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company)
Prepare a DoCommand to be send over the network.
Definition: network_command.cpp:136
Window::SetWidgetsLoweredState
void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets,...)
Sets the lowered/raised status of a list of widgets.
Definition: window.cpp:555
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:177
ScenarioEditorToolbarWindow
Definition: toolbar_gui.cpp:2361
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1113
ShowTransparencyToolbar
void ShowTransparencyToolbar()
Show the transparency toolbar.
Definition: transparency_gui.cpp:159
COMPANY_SPECTATOR
@ COMPANY_SPECTATOR
The client is spectating.
Definition: company_type.h:35
NWidgetBase::fill_x
uint fill_x
Horizontal fill stepsize (from initial size, 0 means not resizable).
Definition: widget_type.h:162
framerate_type.h
InvalidateWindowClassesData
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
Definition: window.cpp:3337
SetStartingYear
void SetStartingYear(Year year)
Set the starting year for a scenario.
Definition: toolbar_gui.cpp:1110
MenuClickGoal
static CallBackFunction MenuClickGoal(int index)
Handle click on the entry in the Goal menu.
Definition: toolbar_gui.cpp:670
WID_TN_SMALL_MAP
@ WID_TN_SMALL_MAP
Small map menu.
Definition: toolbar_widget.h:19
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
MenuClickBuildWater
static CallBackFunction MenuClickBuildWater(int index)
Handle click on the entry in the Build Waterways menu.
Definition: toolbar_gui.cpp:951
ShowLastNewsMessage
void ShowLastNewsMessage()
Show previous news item.
Definition: news_gui.cpp:1037
PM_PAUSED_NORMAL
@ PM_PAUSED_NORMAL
A game normally paused.
Definition: openttd.h:60
Window::SetWidgetsDisabledState
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
Definition: window.cpp:536
WID_TN_TOWNS
@ WID_TN_TOWNS
Town menu.
Definition: toolbar_widget.h:20
MenuClickNewspaper
static CallBackFunction MenuClickNewspaper(int index)
Handle click on the entry in the Newspaper menu.
Definition: toolbar_gui.cpp:1043
NWidgetToolbarContainer
Full blown container to make it behave exactly as we want :)
Definition: toolbar_gui.cpp:1325
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:165
Window::IsWidgetLowered
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:493
ShowSmallMap
void ShowSmallMap()
Show the smallmap window.
Definition: smallmap_gui.cpp:1856
ShowAIDebugWindow
Window * ShowAIDebugWindow(CompanyID show_company)
Open the AI debug window and select the given company.
Definition: ai_gui.cpp:1534
MainToolbarWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: toolbar_gui.cpp:2039
EventState
EventState
State of handling an event.
Definition: window_type.h:717
HT_RECT
@ HT_RECT
rectangle (stations, depots, ...)
Definition: tilehighlight_type.h:21
transparency_gui.h
WID_TE_SMALL_MAP
@ WID_TE_SMALL_MAP
Small map menu.
Definition: toolbar_widget.h:61
DO_SHOW_SIGNS
@ DO_SHOW_SIGNS
Display signs.
Definition: openttd.h:45
news_gui.h
width
int width
Width in pixels of our display surface.
Definition: win32_v.cpp:48
WD_IMGBTN_TOP
@ WD_IMGBTN_TOP
Top offset of image in the button.
Definition: window_gui.h:40
PlaceProc_Sign
void PlaceProc_Sign(TileIndex tile)
PlaceProc function, called when someone pressed the button if the sign-tool is selected.
Definition: signs_cmd.cpp:131
ScenarioEditorToolbarWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: toolbar_gui.cpp:2391
FT_HEIGHTMAP
@ FT_HEIGHTMAP
heightmap file
Definition: fileio_type.h:20
WID_TN_MESSAGES
@ WID_TN_MESSAGES
Messages menu.
Definition: toolbar_widget.h:45
SC_DEFAULTZOOM
@ SC_DEFAULTZOOM
Zoomed to default zoom level screenshot of the visible area.
Definition: screenshot.h:22
WC_MAIN_WINDOW
@ WC_MAIN_WINDOW
Main window; Window numbers:
Definition: window_type.h:44
GameCreationSettings::starting_year
Year starting_year
starting date
Definition: settings_type.h:281
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
MenuClickSettings
static CallBackFunction MenuClickSettings(int index)
Handle click on one of the entries in the Options button menu.
Definition: toolbar_gui.cpp:350
DO_SHOW_TOWN_NAMES
@ DO_SHOW_TOWN_NAMES
Display town names.
Definition: openttd.h:43
company_func.h
NWidgetScenarioToolbarContainer::panel_widths
uint panel_widths[2]
The width of the two panels (the text panel and date panel)
Definition: toolbar_gui.cpp:1805
WID_TN_INDUSTRIES
@ WID_TN_INDUSTRIES
Industry menu.
Definition: toolbar_widget.h:29
CMD_COMPANY_CTRL
@ CMD_COMPANY_CTRL
used in multiplayer to create a new companies etc.
Definition: command_type.h:281
NWidgetContainer
Baseclass for container widgets.
Definition: widget_type.h:367
TO_SIGNS
@ TO_SIGNS
signs
Definition: transparency.h:23
ShowLinkGraphLegend
void ShowLinkGraphLegend()
Open a link graph legend window.
Definition: linkgraph_gui.cpp:470
DEF_START_YEAR
static const Year DEF_START_YEAR
The default starting year.
Definition: date_type.h:86
GUITimer::Elapsed
bool Elapsed(uint delta)
Test if a timer has elapsed.
Definition: guitimer_func.h:55
network.h
_grfconfig
GRFConfig * _grfconfig
First item in list of current GRF set up.
Definition: newgrf_config.cpp:170
MILLISECONDS_PER_TICK
static const uint MILLISECONDS_PER_TICK
The number of milliseconds per game tick.
Definition: gfx_type.h:310
window_func.h
WID_TE_FAST_FORWARD
@ WID_TE_FAST_FORWARD
Fast forward the game.
Definition: toolbar_widget.h:54
MenuClickMusicWindow
static CallBackFunction MenuClickMusicWindow(int index)
Handle click on the entry in the Music menu.
Definition: toolbar_gui.cpp:1023
ToggleBit
static T ToggleBit(T &x, const uint8 y)
Toggles a bit in a variable.
Definition: bitmath_func.hpp:181
Window::ToggleWidgetLoweredState
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
Definition: window_gui.h:463
SoundSettings::click_beep
bool click_beep
Beep on a random selection of buttons.
Definition: settings_type.h:186
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:377
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:319
CTMN_SPECTATOR
static const int CTMN_SPECTATOR
Show a company window as spectator.
Definition: toolbar_gui.cpp:209
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition: terraform_gui.cpp:356
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1610
WDP_MANUAL
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
Definition: window_gui.h:153
ToggleTransparency
static void ToggleTransparency(TransparencyOption to)
Toggle the transparency option bit.
Definition: transparency.h:69
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1075
SC_VIEWPORT
@ SC_VIEWPORT
Screenshot of viewport.
Definition: screenshot.h:19
MakeScreenshotWithConfirm
void MakeScreenshotWithConfirm(ScreenshotType t)
Make a screenshot.
Definition: screenshot.cpp:853
WID_TN_ZOOM_IN
@ WID_TN_ZOOM_IN
Zoom in the main viewport.
Definition: toolbar_widget.h:35
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:176
NetworkClientRequestMove
void NetworkClientRequestMove(CompanyID company_id, const char *pass)
Notify the server of this client wanting to be moved to another company.
Definition: network_client.cpp:1233
ShowBuildRoadToolbar
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
Definition: road_gui.cpp:888
INVALID_COMPANY
@ INVALID_COMPANY
An invalid company.
Definition: company_type.h:30
engine_base.h
NWidgetMainToolbarContainer::GetButtonArrangement
const byte * GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override
Get the arrangement of the buttons for the toolbar.
Definition: toolbar_gui.cpp:1483
console_gui.h
MenuClickShowTrains
static CallBackFunction MenuClickShowTrains(int index)
Handle click on the entry in the Train menu.
Definition: toolbar_gui.cpp:780
WID_TE_SWITCH_BAR
@ WID_TE_SWITCH_BAR
Only available when toolbar has been split to switch between different subsets.
Definition: toolbar_widget.h:75
WID_TE_INDUSTRY
@ WID_TE_INDUSTRY
Industry building window.
Definition: toolbar_widget.h:66
gui.h
CeilDiv
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Definition: math_func.hpp:254
MenuClickStations
static CallBackFunction MenuClickStations(int index)
Handle click on the entry in the Stations menu.
Definition: toolbar_gui.cpp:566
Window
Data structure for an opened window.
Definition: window_gui.h:276
NWidgetToolbarContainer::spacers
uint spacers
Number of spacer widgets in this toolbar.
Definition: toolbar_gui.cpp:1328
GetRoadTypes
RoadTypes GetRoadTypes(bool introduces)
Get list of road types, regardless of company availability.
Definition: road.cpp:216
SizingType
SizingType
Different forms of sizing nested widgets, using NWidgetBase::AssignSizePosition()
Definition: widget_type.h:109
NWidgetToolbarContainer::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: toolbar_gui.cpp:1378
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:318
Window::RaiseWidget
void RaiseWidget(byte widget_index)
Marks a widget as raised.
Definition: window_gui.h:483
WID_TN_FAST_FORWARD
@ WID_TN_FAST_FORWARD
Fast forward the game.
Definition: toolbar_widget.h:16
SetObjectToPlace
void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowClass window_class, WindowNumber window_num)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
Definition: viewport.cpp:3373
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:602
WID_TN_SWITCH_BAR
@ WID_TN_SWITCH_BAR
Only available when toolbar has been split to switch between different subsets.
Definition: toolbar_widget.h:47
IConsoleSwitch
void IConsoleSwitch()
Toggle in-game console between opened and closed.
Definition: console_gui.cpp:437
WID_TE_TRAMS
@ WID_TE_TRAMS
Tram building menu.
Definition: toolbar_widget.h:68
Window::IsWidgetDisabled
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
Definition: window_gui.h:421
ScenarioEditorToolbarWindow::OnPlaceObject
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
Definition: toolbar_gui.cpp:2474
NWidgetCore
Base class for a 'real' widget.
Definition: widget_type.h:282
story_base.h
WKC_MINUS
@ WKC_MINUS
Definition: gfx_type.h:104
Window::SetWidgetDirty
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:597
ShowAIConfigWindow
void ShowAIConfigWindow()
Open the AI config window.
Definition: ai_gui.cpp:971
MenuClickLeague
static CallBackFunction MenuClickLeague(int index)
Handle click on the entry in the CompanyLeague menu.
Definition: toolbar_gui.cpp:720
ShowCompany
void ShowCompany(CompanyID company)
Show the window with the overview of the company.
Definition: company_gui.cpp:2751
GUISettings::UserIsAllowedToChangeNewGRFs
bool UserIsAllowedToChangeNewGRFs() const
Returns true when the user has sufficient privileges to edit newgrfs on a running game.
Definition: settings_type.h:174
HandleZoomMessage
void HandleZoomMessage(Window *w, const Viewport *vp, byte widget_zoom_in, byte widget_zoom_out)
Update the status of the zoom-buttons according to the zoom-level of the viewport.
Definition: viewport.cpp:478
ScenarioEditorToolbarWindow::OnRealtimeTick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition: toolbar_gui.cpp:2501
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition: vehicle_type.h:26
ToolbarMode
ToolbarMode
Toobar modes.
Definition: toolbar_gui.cpp:70
ROADTYPES_NONE
@ ROADTYPES_NONE
No roadtypes.
Definition: road_type.h:37
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
ScenarioEditorToolbarWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: toolbar_gui.cpp:2494
WID_TE_MUSIC_SOUND
@ WID_TE_MUSIC_SOUND
Music/sound configuration menu.
Definition: toolbar_widget.h:73
WID_TN_VEHICLE_START
@ WID_TN_VEHICLE_START
Helper for the offset of the vehicle menus.
Definition: toolbar_widget.h:30
NWidgetBase::resize_x
uint resize_x
Horizontal resize step (0 means not resizable).
Definition: widget_type.h:164
WC_MAIN_TOOLBAR
@ WC_MAIN_TOOLBAR
Main toolbar (the long bar at the top); Window numbers:
Definition: window_type.h:51
ScenarioEditorToolbarWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: toolbar_gui.cpp:2381
QSF_ENABLE_DEFAULT
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
Definition: textbuf_gui.h:21
DO_SHOW_WAYPOINT_NAMES
@ DO_SHOW_WAYPOINT_NAMES
Display waypoint names.
Definition: openttd.h:48
CLRBITS
#define CLRBITS(x, y)
Clears several bits in a variable.
Definition: bitmath_func.hpp:166
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:172
DropDownListItem::masked
bool masked
Masked and unselectable item.
Definition: dropdown_type.h:25
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3421
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:453
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition: gfx.cpp:39
NWidgetCore::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:912
TD_RTL
@ TD_RTL
Text is written right-to-left by default.
Definition: strings_type.h:24
network_func.h
_current_text_dir
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:48
CS_NUMERAL
@ CS_NUMERAL
Only numeric ones.
Definition: string_type.h:28
WID_TN_TRAINS
@ WID_TN_TRAINS
Train menu.
Definition: toolbar_widget.h:31
DropDownListIconItem
List item with icon and string.
Definition: dropdown_type.h:81
MenuClickForest
static CallBackFunction MenuClickForest(int index)
Handle click on the entry in the landscaping menu.
Definition: toolbar_gui.cpp:999
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:565
MenuClickBuildRoad
static CallBackFunction MenuClickBuildRoad(int index)
Handle click on the entry in the Build Road menu.
Definition: toolbar_gui.cpp:905
DropDownListCheckedItem
Drop down list entry for showing a checked/unchecked toggle item.
Definition: toolbar_gui.cpp:89
MainToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: toolbar_gui.cpp:2115
ShowEditorTerraformToolbar
Window * ShowEditorTerraformToolbar()
Show the toolbar for terraforming in the scenario editor.
Definition: terraform_gui.cpp:748
PopupMainCompanyToolbMenu
static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey=0)
Pop up a generic company list menu.
Definition: toolbar_gui.cpp:217
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:22
MainToolbarWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: toolbar_gui.cpp:2044
ShowBuildDocksToolbar
Window * ShowBuildDocksToolbar()
Open the build water toolbar window.
Definition: dock_gui.cpp:357
Window::FindWindowPlacementAndResize
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
Resize window towards the default size.
Definition: window.cpp:1526
hotkeys.h
cheat_func.h
ShowBuildRoadScenToolbar
Window * ShowBuildRoadScenToolbar(RoadType roadtype)
Show the road building toolbar in the scenario editor.
Definition: road_gui.cpp:975
MAX_YEAR
static const Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date,...
Definition: date_type.h:94
WID_TN_GRAPHS
@ WID_TN_GRAPHS
Graph menu.
Definition: toolbar_widget.h:27
NWidgetToolbarContainer::visible
bool visible[WID_TN_END]
The visible headers.
Definition: toolbar_gui.cpp:1326
WID_TN_RAILS
@ WID_TN_RAILS
Rail building menu.
Definition: toolbar_widget.h:38