OpenTTD Source  14.0-beta3
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 "vehicle_func.h"
21 #include "sound_func.h"
22 #include "terraform_gui.h"
23 #include "strings_func.h"
24 #include "company_func.h"
25 #include "company_gui.h"
26 #include "vehicle_base.h"
27 #include "cheat_func.h"
28 #include "transparency_gui.h"
29 #include "screenshot.h"
30 #include "signs_func.h"
31 #include "fios.h"
32 #include "console_gui.h"
33 #include "news_gui.h"
34 #include "ai/ai_gui.hpp"
35 #include "game/game_gui.hpp"
36 #include "script/script_gui.h"
37 #include "tilehighlight_func.h"
38 #include "smallmap_gui.h"
39 #include "graph_gui.h"
40 #include "textbuf_gui.h"
42 #include "newgrf_debug.h"
43 #include "hotkeys.h"
44 #include "engine_base.h"
45 #include "highscore.h"
46 #include "game/game.hpp"
47 #include "goal_base.h"
48 #include "story_base.h"
49 #include "toolbar_gui.h"
50 #include "framerate_type.h"
51 #include "screenshot_gui.h"
52 #include "misc_cmd.h"
53 #include "league_gui.h"
54 #include "league_base.h"
55 #include "timer/timer.h"
56 #include "timer/timer_window.h"
58 #include "help_gui.h"
59 
60 #include "widgets/toolbar_widget.h"
61 
62 #include "network/network.h"
63 #include "network/network_gui.h"
64 #include "network/network_func.h"
65 
66 #include "safeguards.h"
67 
68 
70 uint _toolbar_width = 0;
71 
72 RailType _last_built_railtype;
73 RoadType _last_built_roadtype;
74 RoadType _last_built_tramtype;
75 
78  TB_NORMAL,
79  TB_UPPER,
80  TB_LOWER
81 };
82 
85  CBF_NONE,
86  CBF_PLACE_SIGN,
87  CBF_PLACE_LANDINFO,
88 };
89 
91 
95 class DropDownListCompanyItem : public DropDownIcon<DropDownIcon<DropDownString<DropDownListItem>, true>> {
96 public:
97  DropDownListCompanyItem(CompanyID company, bool shaded) : DropDownIcon<DropDownIcon<DropDownString<DropDownListItem>, true>>(SPR_COMPANY_ICON, COMPANY_SPRITE_COLOUR(company), NetworkCompanyIsPassworded(company) ? SPR_LOCK : SPR_EMPTY, PAL_NONE, STR_NULL, company, false, shaded)
98  {
99  SetDParam(0, company);
100  SetDParam(1, company);
101  this->SetString(GetString(STR_COMPANY_NAME_COMPANY_NUM));
102  }
103 };
104 
112 static void PopupMainToolbarMenu(Window *w, WidgetID widget, DropDownList &&list, int def)
113 {
114  ShowDropDownList(w, std::move(list), def, widget, 0, true);
116 }
117 
124 static void PopupMainToolbarMenu(Window *w, WidgetID widget, const std::initializer_list<StringID> &strings)
125 {
126  DropDownList list;
127  int i = 0;
128  for (StringID string : strings) {
129  if (string == STR_NULL) {
130  list.push_back(std::make_unique<DropDownListDividerItem>(-1, false));
131  } else {
132  list.push_back(std::make_unique<DropDownListStringItem>(string, i, false));
133  i++;
134  }
135  }
136  PopupMainToolbarMenu(w, widget, std::move(list), 0);
137 }
138 
140 static const int CTMN_CLIENT_LIST = -1;
141 static const int CTMN_SPECTATE = -2;
142 static const int CTMN_SPECTATOR = -3;
143 
150 static void PopupMainCompanyToolbMenu(Window *w, WidgetID widget, CompanyMask grey = 0)
151 {
152  DropDownList list;
153 
154  switch (widget) {
155  case WID_TN_COMPANIES:
156  if (!_networking) break;
157 
158  /* Add the client list button for the companies menu */
159  list.push_back(std::make_unique<DropDownListStringItem>(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, CTMN_CLIENT_LIST, false));
160 
162  list.push_back(std::make_unique<DropDownListStringItem>(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, false));
163  }
164  break;
165  case WID_TN_STORY:
166  list.push_back(std::make_unique<DropDownListStringItem>(STR_STORY_BOOK_SPECTATOR, CTMN_SPECTATOR, false));
167  break;
168 
169  case WID_TN_GOAL:
170  list.push_back(std::make_unique<DropDownListStringItem>(STR_GOALS_SPECTATOR, CTMN_SPECTATOR, false));
171  break;
172  }
173 
174  for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
175  if (!Company::IsValidID(c)) continue;
176  list.push_back(std::make_unique<DropDownListCompanyItem>(c, HasBit(grey, c)));
177  }
178 
180 }
181 
182 static ToolbarMode _toolbar_mode;
183 
184 static CallBackFunction SelectSignTool()
185 {
186  if (_last_started_action == CBF_PLACE_SIGN) {
188  return CBF_NONE;
189  } else {
190  SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, HT_RECT, WC_MAIN_TOOLBAR, 0);
191  return CBF_PLACE_SIGN;
192  }
193 }
194 
195 /* --- Pausing --- */
196 
197 static CallBackFunction ToolbarPauseClick(Window *)
198 {
199  if (_networking && !_network_server) return CBF_NONE; // only server can pause the game
200 
202  if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP);
203  }
204  return CBF_NONE;
205 }
206 
213 {
214  if (_networking) return CBF_NONE; // no fast forward in network game
215 
216  ChangeGameSpeed(_game_speed == 100);
217 
219  return CBF_NONE;
220 }
221 
226  OME_GAMEOPTIONS,
227  OME_SETTINGS,
228  OME_AI_SETTINGS,
229  OME_GAMESCRIPT_SETTINGS,
230  OME_NEWGRFSETTINGS,
231  ONE_SANDBOX,
232  OME_TRANSPARENCIES,
233  OME_SHOW_TOWNNAMES,
234  OME_SHOW_STATIONNAMES,
235  OME_SHOW_WAYPOINTNAMES,
236  OME_SHOW_SIGNS,
237  OME_SHOW_COMPETITOR_SIGNS,
238  OME_FULL_ANIMATION,
239  OME_FULL_DETAILS,
240  OME_TRANSPARENTBUILDINGS,
241  OME_SHOW_STATIONSIGNS,
242 };
243 
251 {
252  DropDownList list;
253  list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_GAME_OPTIONS, OME_GAMEOPTIONS, false));
254  list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE, OME_SETTINGS, false));
255  /* Changes to the per-AI settings don't get send from the server to the clients. Clients get
256  * the settings once they join but never update it. As such don't show the window at all
257  * to network clients. */
258  if (!_networking || _network_server) {
259  list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_AI_SETTINGS, OME_AI_SETTINGS, false));
260  list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_GAMESCRIPT_SETTINGS, OME_GAMESCRIPT_SETTINGS, false));
261  }
262  list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_NEWGRF_SETTINGS, OME_NEWGRFSETTINGS, false));
263  if (_game_mode != GM_EDITOR) {
264  list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_SANDBOX_OPTIONS, ONE_SANDBOX, false));
265  }
266  list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS, OME_TRANSPARENCIES, false));
267  list.push_back(std::make_unique<DropDownListDividerItem>(-1, false));
268  list.push_back(std::make_unique<DropDownListCheckedItem>(HasBit(_display_opt, DO_SHOW_TOWN_NAMES), STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED, OME_SHOW_TOWNNAMES, false));
269  list.push_back(std::make_unique<DropDownListCheckedItem>(HasBit(_display_opt, DO_SHOW_STATION_NAMES), STR_SETTINGS_MENU_STATION_NAMES_DISPLAYED, OME_SHOW_STATIONNAMES, false));
270  list.push_back(std::make_unique<DropDownListCheckedItem>(HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES), STR_SETTINGS_MENU_WAYPOINTS_DISPLAYED, OME_SHOW_WAYPOINTNAMES, false));
271  list.push_back(std::make_unique<DropDownListCheckedItem>(HasBit(_display_opt, DO_SHOW_SIGNS), STR_SETTINGS_MENU_SIGNS_DISPLAYED, OME_SHOW_SIGNS, false));
272  list.push_back(std::make_unique<DropDownListCheckedItem>(HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS), STR_SETTINGS_MENU_SHOW_COMPETITOR_SIGNS, OME_SHOW_COMPETITOR_SIGNS, false));
273  list.push_back(std::make_unique<DropDownListCheckedItem>(HasBit(_display_opt, DO_FULL_ANIMATION), STR_SETTINGS_MENU_FULL_ANIMATION, OME_FULL_ANIMATION, false));
274  list.push_back(std::make_unique<DropDownListCheckedItem>(HasBit(_display_opt, DO_FULL_DETAIL), STR_SETTINGS_MENU_FULL_DETAIL, OME_FULL_DETAILS, false));
275  list.push_back(std::make_unique<DropDownListCheckedItem>(IsTransparencySet(TO_HOUSES), STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS, false));
276  list.push_back(std::make_unique<DropDownListCheckedItem>(IsTransparencySet(TO_SIGNS), STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS, false));
277 
278  ShowDropDownList(w, std::move(list), 0, WID_TN_SETTINGS, 140, true);
280  return CBF_NONE;
281 }
282 
290 {
291  switch (index) {
292  case OME_GAMEOPTIONS: ShowGameOptions(); return CBF_NONE;
293  case OME_SETTINGS: ShowGameSettings(); return CBF_NONE;
294  case OME_AI_SETTINGS: ShowAIConfigWindow(); return CBF_NONE;
295  case OME_GAMESCRIPT_SETTINGS: ShowGSConfigWindow(); return CBF_NONE;
296  case OME_NEWGRFSETTINGS: ShowNewGRFSettings(!_networking && _settings_client.gui.UserIsAllowedToChangeNewGRFs(), true, true, &_grfconfig); return CBF_NONE;
297  case ONE_SANDBOX: ShowCheatWindow(); break;
298  case OME_TRANSPARENCIES: ShowTransparencyToolbar(); break;
299 
300  case OME_SHOW_TOWNNAMES: ToggleBit(_display_opt, DO_SHOW_TOWN_NAMES); break;
301  case OME_SHOW_STATIONNAMES: ToggleBit(_display_opt, DO_SHOW_STATION_NAMES); break;
302  case OME_SHOW_WAYPOINTNAMES: ToggleBit(_display_opt, DO_SHOW_WAYPOINT_NAMES); break;
303  case OME_SHOW_SIGNS: ToggleBit(_display_opt, DO_SHOW_SIGNS); break;
304  case OME_SHOW_COMPETITOR_SIGNS:
307  break;
308  case OME_FULL_ANIMATION: ToggleBit(_display_opt, DO_FULL_ANIMATION); CheckBlitter(); break;
309  case OME_FULL_DETAILS: ToggleBit(_display_opt, DO_FULL_DETAIL); break;
310  case OME_TRANSPARENTBUILDINGS: ToggleTransparency(TO_HOUSES); break;
311  case OME_SHOW_STATIONSIGNS: ToggleTransparency(TO_SIGNS); break;
312  }
314  return CBF_NONE;
315 }
316 
321  SLEME_SAVE_SCENARIO = 0,
322  SLEME_LOAD_SCENARIO,
323  SLEME_SAVE_HEIGHTMAP,
324  SLEME_LOAD_HEIGHTMAP,
325  SLEME_EXIT_TOINTRO,
326  SLEME_EXIT_GAME,
327 };
328 
333  SLNME_SAVE_GAME = 0,
334  SLNME_LOAD_GAME,
335  SLNME_EXIT_TOINTRO,
336  SLNME_EXIT_GAME,
337 };
338 
346 {
347  PopupMainToolbarMenu(w, WID_TN_SAVE, {STR_FILE_MENU_SAVE_GAME, STR_FILE_MENU_LOAD_GAME, STR_FILE_MENU_QUIT_GAME,
348  STR_NULL, STR_FILE_MENU_EXIT});
349  return CBF_NONE;
350 }
351 
359 {
360  PopupMainToolbarMenu(w, WID_TE_SAVE, {STR_SCENEDIT_FILE_MENU_SAVE_SCENARIO, STR_SCENEDIT_FILE_MENU_LOAD_SCENARIO,
361  STR_SCENEDIT_FILE_MENU_SAVE_HEIGHTMAP, STR_SCENEDIT_FILE_MENU_LOAD_HEIGHTMAP,
362  STR_SCENEDIT_FILE_MENU_QUIT_EDITOR, STR_NULL, STR_SCENEDIT_FILE_MENU_QUIT});
363  return CBF_NONE;
364 }
365 
372 static CallBackFunction MenuClickSaveLoad(int index = 0)
373 {
374  if (_game_mode == GM_EDITOR) {
375  switch (index) {
376  case SLEME_SAVE_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_SAVE); break;
377  case SLEME_LOAD_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_LOAD); break;
378  case SLEME_SAVE_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP, SLO_SAVE); break;
379  case SLEME_LOAD_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP, SLO_LOAD); break;
380  case SLEME_EXIT_TOINTRO: AskExitToGameMenu(); break;
381  case SLEME_EXIT_GAME: HandleExitGameRequest(); break;
382  }
383  } else {
384  switch (index) {
385  case SLNME_SAVE_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_SAVE); break;
386  case SLNME_LOAD_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break;
387  case SLNME_EXIT_TOINTRO: AskExitToGameMenu(); break;
388  case SLNME_EXIT_GAME: HandleExitGameRequest(); break;
389  }
390  }
391  return CBF_NONE;
392 }
393 
394 /* --- Map button menu --- */
395 
396 enum MapMenuEntries {
397  MME_SHOW_SMALLMAP = 0,
398  MME_SHOW_EXTRAVIEWPORTS,
399  MME_SHOW_LINKGRAPH,
400  MME_SHOW_SIGNLISTS,
401  MME_SHOW_TOWNDIRECTORY,
402  MME_SHOW_INDUSTRYDIRECTORY,
403 };
404 
405 static CallBackFunction ToolbarMapClick(Window *w)
406 {
407  DropDownList list;
408  list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP, false));
409  list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_EXTRA_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS, false));
410  list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_LINGRAPH_LEGEND, MME_SHOW_LINKGRAPH, false));
411  list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false));
412  PopupMainToolbarMenu(w, WID_TN_SMALL_MAP, std::move(list), 0);
413  return CBF_NONE;
414 }
415 
416 static CallBackFunction ToolbarScenMapTownDir(Window *w)
417 {
418  DropDownList list;
419  list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP, false));
420  list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_EXTRA_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS, false));
421  list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false));
422  list.push_back(std::make_unique<DropDownListStringItem>(STR_TOWN_MENU_TOWN_DIRECTORY, MME_SHOW_TOWNDIRECTORY, false));
423  list.push_back(std::make_unique<DropDownListStringItem>(STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, MME_SHOW_INDUSTRYDIRECTORY, false));
424  PopupMainToolbarMenu(w, WID_TE_SMALL_MAP, std::move(list), 0);
425  return CBF_NONE;
426 }
427 
435 {
436  switch (index) {
437  case MME_SHOW_SMALLMAP: ShowSmallMap(); break;
438  case MME_SHOW_EXTRAVIEWPORTS: ShowExtraViewportWindow(); break;
439  case MME_SHOW_LINKGRAPH: ShowLinkGraphLegend(); break;
440  case MME_SHOW_SIGNLISTS: ShowSignList(); break;
441  case MME_SHOW_TOWNDIRECTORY: ShowTownDirectory(); break;
442  case MME_SHOW_INDUSTRYDIRECTORY: ShowIndustryDirectory(); break;
443  }
444  return CBF_NONE;
445 }
446 
447 /* --- Town button menu --- */
448 
449 static CallBackFunction ToolbarTownClick(Window *w)
450 {
452  PopupMainToolbarMenu(w, WID_TN_TOWNS, {STR_TOWN_MENU_TOWN_DIRECTORY});
453  } else {
454  PopupMainToolbarMenu(w, WID_TN_TOWNS, {STR_TOWN_MENU_TOWN_DIRECTORY, STR_TOWN_MENU_FOUND_TOWN});
455  }
456  return CBF_NONE;
457 }
458 
466 {
467  switch (index) {
468  case 0: ShowTownDirectory(); break;
469  case 1: // setting could be changed when the dropdown was open
470  if (_settings_game.economy.found_town != TF_FORBIDDEN) ShowFoundTownWindow();
471  break;
472  }
473  return CBF_NONE;
474 }
475 
476 /* --- Subidies button menu --- */
477 
478 static CallBackFunction ToolbarSubsidiesClick(Window *w)
479 {
480  PopupMainToolbarMenu(w, WID_TN_SUBSIDIES, {STR_SUBSIDIES_MENU_SUBSIDIES});
481  return CBF_NONE;
482 }
483 
490 {
491  ShowSubsidiesList();
492  return CBF_NONE;
493 }
494 
495 /* --- Stations button menu --- */
496 
497 static CallBackFunction ToolbarStationsClick(Window *w)
498 {
500  return CBF_NONE;
501 }
502 
510 {
512  return CBF_NONE;
513 }
514 
515 /* --- Finances button menu --- */
516 
517 static CallBackFunction ToolbarFinancesClick(Window *w)
518 {
520  return CBF_NONE;
521 }
522 
530 {
532  return CBF_NONE;
533 }
534 
535 /* --- Company's button menu --- */
536 
537 static CallBackFunction ToolbarCompaniesClick(Window *w)
538 {
540  return CBF_NONE;
541 }
542 
550 {
551  if (_networking) {
552  switch (index) {
553  case CTMN_CLIENT_LIST:
554  ShowClientList();
555  return CBF_NONE;
556 
557  case CTMN_SPECTATE:
558  if (_network_server) {
561  } else {
563  }
564  return CBF_NONE;
565  }
566  }
567  ShowCompany((CompanyID)index);
568  return CBF_NONE;
569 }
570 
571 /* --- Story button menu --- */
572 
573 static CallBackFunction ToolbarStoryClick(Window *w)
574 {
576  return CBF_NONE;
577 }
578 
586 {
588  return CBF_NONE;
589 }
590 
591 /* --- Goal button menu --- */
592 
593 static CallBackFunction ToolbarGoalClick(Window *w)
594 {
596  return CBF_NONE;
597 }
598 
606 {
608  return CBF_NONE;
609 }
610 
611 /* --- Graphs and League Table button menu --- */
612 
617 static const int GRMN_OPERATING_PROFIT_GRAPH = -1;
618 static const int GRMN_INCOME_GRAPH = -2;
619 static const int GRMN_DELIVERED_CARGO_GRAPH = -3;
620 static const int GRMN_PERFORMANCE_HISTORY_GRAPH = -4;
621 static const int GRMN_COMPANY_VALUE_GRAPH = -5;
622 static const int GRMN_CARGO_PAYMENT_RATES = -6;
623 static const int LTMN_PERFORMANCE_LEAGUE = -7;
624 static const int LTMN_PERFORMANCE_RATING = -8;
625 static const int LTMN_HIGHSCORE = -9;
626 
627 static void AddDropDownLeagueTableOptions(DropDownList &list)
628 {
629  if (LeagueTable::GetNumItems() > 0) {
630  for (LeagueTable *lt : LeagueTable::Iterate()) {
631  list.push_back(std::make_unique<DropDownListStringItem>(lt->title, lt->index, false));
632  }
633  } else {
634  list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_COMPANY_LEAGUE_TABLE, LTMN_PERFORMANCE_LEAGUE, false));
635  list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_DETAILED_PERFORMANCE_RATING, LTMN_PERFORMANCE_RATING, false));
636  if (!_networking) {
637  list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_HIGHSCORE, LTMN_HIGHSCORE, false));
638  }
639  }
640 }
641 
642 static CallBackFunction ToolbarGraphsClick(Window *w)
643 {
644  DropDownList list;
645 
646  list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_OPERATING_PROFIT_GRAPH, GRMN_OPERATING_PROFIT_GRAPH, false));
647  list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_INCOME_GRAPH, GRMN_INCOME_GRAPH, false));
648  list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_DELIVERED_CARGO_GRAPH, GRMN_DELIVERED_CARGO_GRAPH, false));
649  list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_PERFORMANCE_HISTORY_GRAPH, GRMN_PERFORMANCE_HISTORY_GRAPH, false));
650  list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_COMPANY_VALUE_GRAPH, GRMN_COMPANY_VALUE_GRAPH, false));
651  list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_CARGO_PAYMENT_RATES, GRMN_CARGO_PAYMENT_RATES, false));
652 
653  if (_toolbar_mode != TB_NORMAL) AddDropDownLeagueTableOptions(list);
654 
655  ShowDropDownList(w, std::move(list), GRMN_OPERATING_PROFIT_GRAPH, WID_TN_GRAPHS, 140, true);
657 
658  return CBF_NONE;
659 }
660 
661 static CallBackFunction ToolbarLeagueClick(Window *w)
662 {
663  DropDownList list;
664 
665  AddDropDownLeagueTableOptions(list);
666 
667  int selected = list[0]->result;
668  ShowDropDownList(w, std::move(list), selected, WID_TN_LEAGUE, 140, true);
670 
671  return CBF_NONE;
672 }
673 
681 {
682  switch (index) {
683  case GRMN_OPERATING_PROFIT_GRAPH: ShowOperatingProfitGraph(); break;
684  case GRMN_INCOME_GRAPH: ShowIncomeGraph(); break;
685  case GRMN_DELIVERED_CARGO_GRAPH: ShowDeliveredCargoGraph(); break;
686  case GRMN_PERFORMANCE_HISTORY_GRAPH: ShowPerformanceHistoryGraph(); break;
687  case GRMN_COMPANY_VALUE_GRAPH: ShowCompanyValueGraph(); break;
688  case GRMN_CARGO_PAYMENT_RATES: ShowCargoPaymentRates(); break;
689  case LTMN_PERFORMANCE_LEAGUE: ShowPerformanceLeagueTable(); break;
690  case LTMN_PERFORMANCE_RATING: ShowPerformanceRatingDetail(); break;
691  case LTMN_HIGHSCORE: ShowHighscoreTable(); break;
692  default: {
693  if (LeagueTable::IsValidID(index)) {
694  ShowScriptLeagueTable((LeagueTableID)index);
695  }
696  }
697  }
698  return CBF_NONE;
699 }
700 
701 
702 
703 /* --- Industries button menu --- */
704 
705 static CallBackFunction ToolbarIndustryClick(Window *w)
706 {
707  /* Disable build-industry menu if we are a spectator */
709  PopupMainToolbarMenu(w, WID_TN_INDUSTRIES, {STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, STR_INDUSTRY_MENU_INDUSTRY_CHAIN});
710  } else {
711  PopupMainToolbarMenu(w, WID_TN_INDUSTRIES, {STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, STR_INDUSTRY_MENU_INDUSTRY_CHAIN, STR_INDUSTRY_MENU_FUND_NEW_INDUSTRY});
712  }
713  return CBF_NONE;
714 }
715 
723 {
724  switch (index) {
725  case 0: ShowIndustryDirectory(); break;
726  case 1: ShowIndustryCargoesWindow(); break;
727  case 2: ShowBuildIndustryWindow(); break;
728  }
729  return CBF_NONE;
730 }
731 
732 /* --- Trains button menu + 1 helper function for all vehicles. --- */
733 
734 static void ToolbarVehicleClick(Window *w, VehicleType veh)
735 {
736  CompanyMask dis = 0;
737 
738  for (const Company *c : Company::Iterate()) {
739  if (c->group_all[veh].num_vehicle == 0) SetBit(dis, c->index);
740  }
742 }
743 
744 
745 static CallBackFunction ToolbarTrainClick(Window *w)
746 {
747  ToolbarVehicleClick(w, VEH_TRAIN);
748  return CBF_NONE;
749 }
750 
758 {
759  ShowVehicleListWindow((CompanyID)index, VEH_TRAIN);
760  return CBF_NONE;
761 }
762 
763 /* --- Road vehicle button menu --- */
764 
765 static CallBackFunction ToolbarRoadClick(Window *w)
766 {
767  ToolbarVehicleClick(w, VEH_ROAD);
768  return CBF_NONE;
769 }
770 
778 {
779  ShowVehicleListWindow((CompanyID)index, VEH_ROAD);
780  return CBF_NONE;
781 }
782 
783 /* --- Ship button menu --- */
784 
785 static CallBackFunction ToolbarShipClick(Window *w)
786 {
787  ToolbarVehicleClick(w, VEH_SHIP);
788  return CBF_NONE;
789 }
790 
798 {
799  ShowVehicleListWindow((CompanyID)index, VEH_SHIP);
800  return CBF_NONE;
801 }
802 
803 /* --- Aircraft button menu --- */
804 
805 static CallBackFunction ToolbarAirClick(Window *w)
806 {
807  ToolbarVehicleClick(w, VEH_AIRCRAFT);
808  return CBF_NONE;
809 }
810 
818 {
819  ShowVehicleListWindow((CompanyID)index, VEH_AIRCRAFT);
820  return CBF_NONE;
821 }
822 
823 /* --- Zoom in button --- */
824 
825 static CallBackFunction ToolbarZoomInClick(Window *w)
826 {
828  w->HandleButtonClick((_game_mode == GM_EDITOR) ? (WidgetID)WID_TE_ZOOM_IN : (WidgetID)WID_TN_ZOOM_IN);
830  }
831  return CBF_NONE;
832 }
833 
834 /* --- Zoom out button --- */
835 
836 static CallBackFunction ToolbarZoomOutClick(Window *w)
837 {
839  w->HandleButtonClick((_game_mode == GM_EDITOR) ? (WidgetID)WID_TE_ZOOM_OUT : (WidgetID)WID_TN_ZOOM_OUT);
841  }
842  return CBF_NONE;
843 }
844 
845 /* --- Rail button menu --- */
846 
847 static CallBackFunction ToolbarBuildRailClick(Window *w)
848 {
849  ShowDropDownList(w, GetRailTypeDropDownList(), _last_built_railtype, WID_TN_RAILS, 140, true);
851  return CBF_NONE;
852 }
853 
861 {
862  _last_built_railtype = (RailType)index;
863  ShowBuildRailToolbar(_last_built_railtype);
864  return CBF_NONE;
865 }
866 
867 /* --- Road button menu --- */
868 
869 static CallBackFunction ToolbarBuildRoadClick(Window *w)
870 {
871  ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TN_ROADS, 140, true);
873  return CBF_NONE;
874 }
875 
883 {
884  _last_built_roadtype = (RoadType)index;
885  ShowBuildRoadToolbar(_last_built_roadtype);
886  return CBF_NONE;
887 }
888 
889 /* --- Tram button menu --- */
890 
891 static CallBackFunction ToolbarBuildTramClick(Window *w)
892 {
893  ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TN_TRAMS, 140, true);
895  return CBF_NONE;
896 }
897 
905 {
906  _last_built_tramtype = (RoadType)index;
907  ShowBuildRoadToolbar(_last_built_tramtype);
908  return CBF_NONE;
909 }
910 
911 /* --- Water button menu --- */
912 
913 static CallBackFunction ToolbarBuildWaterClick(Window *w)
914 {
915  DropDownList list;
916  list.push_back(std::make_unique<DropDownListIconItem>(SPR_IMG_BUILD_CANAL, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 0, false));
917  ShowDropDownList(w, std::move(list), 0, WID_TN_WATER, 140, true);
919  return CBF_NONE;
920 }
921 
928 {
930  return CBF_NONE;
931 }
932 
933 /* --- Airport button menu --- */
934 
935 static CallBackFunction ToolbarBuildAirClick(Window *w)
936 {
937  DropDownList list;
938  list.push_back(std::make_unique<DropDownListIconItem>(SPR_IMG_AIRPORT, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 0, false));
939  ShowDropDownList(w, std::move(list), 0, WID_TN_AIR, 140, true);
941  return CBF_NONE;
942 }
943 
950 {
952  return CBF_NONE;
953 }
954 
955 /* --- Forest button menu --- */
956 
957 static CallBackFunction ToolbarForestClick(Window *w)
958 {
959  DropDownList list;
960  list.push_back(std::make_unique<DropDownListIconItem>(SPR_IMG_LANDSCAPING, PAL_NONE, STR_LANDSCAPING_MENU_LANDSCAPING, 0, false));
961  list.push_back(std::make_unique<DropDownListIconItem>(SPR_IMG_PLANTTREES, PAL_NONE, STR_LANDSCAPING_MENU_PLANT_TREES, 1, false));
962  list.push_back(std::make_unique<DropDownListIconItem>(SPR_IMG_SIGN, PAL_NONE, STR_LANDSCAPING_MENU_PLACE_SIGN, 2, false));
963  ShowDropDownList(w, std::move(list), 0, WID_TN_LANDSCAPE, 100, true);
965  return CBF_NONE;
966 }
967 
975 {
976  switch (index) {
977  case 0: ShowTerraformToolbar(); break;
978  case 1: ShowBuildTreesToolbar(); break;
979  case 2: return SelectSignTool();
980  }
981  return CBF_NONE;
982 }
983 
984 /* --- Music button menu --- */
985 
986 static CallBackFunction ToolbarMusicClick(Window *w)
987 {
988  PopupMainToolbarMenu(w, _game_mode == GM_EDITOR ? (WidgetID)WID_TE_MUSIC_SOUND : (WidgetID)WID_TN_MUSIC_SOUND, {STR_TOOLBAR_SOUND_MUSIC});
989  return CBF_NONE;
990 }
991 
998 {
999  ShowMusicWindow();
1000  return CBF_NONE;
1001 }
1002 
1003 /* --- Newspaper button menu --- */
1004 
1005 static CallBackFunction ToolbarNewspaperClick(Window *w)
1006 {
1007  PopupMainToolbarMenu(w, WID_TN_MESSAGES, {STR_NEWS_MENU_LAST_MESSAGE_NEWS_REPORT, STR_NEWS_MENU_MESSAGE_HISTORY_MENU, STR_NEWS_MENU_DELETE_ALL_MESSAGES});
1008  return CBF_NONE;
1009 }
1010 
1018 {
1019  switch (index) {
1020  case 0: ShowLastNewsMessage(); break;
1021  case 1: ShowMessageHistory(); break;
1022  case 2: DeleteAllMessages(); break;
1023  }
1024  return CBF_NONE;
1025 }
1026 
1027 /* --- Help button menu --- */
1028 
1029 static CallBackFunction PlaceLandBlockInfo()
1030 {
1031  if (_last_started_action == CBF_PLACE_LANDINFO) {
1033  return CBF_NONE;
1034  } else {
1035  SetObjectToPlace(SPR_CURSOR_QUERY, PAL_NONE, HT_RECT, WC_MAIN_TOOLBAR, 0);
1036  return CBF_PLACE_LANDINFO;
1037  }
1038 }
1039 
1040 static CallBackFunction ToolbarHelpClick(Window *w)
1041 {
1043  PopupMainToolbarMenu(w, _game_mode == GM_EDITOR ? (WidgetID)WID_TE_HELP : (WidgetID)WID_TN_HELP, {STR_ABOUT_MENU_LAND_BLOCK_INFO,
1044  STR_ABOUT_MENU_HELP, STR_NULL, STR_ABOUT_MENU_TOGGLE_CONSOLE, STR_ABOUT_MENU_AI_DEBUG,
1045  STR_ABOUT_MENU_SCREENSHOT, STR_ABOUT_MENU_SHOW_FRAMERATE, STR_ABOUT_MENU_ABOUT_OPENTTD,
1046  STR_ABOUT_MENU_SPRITE_ALIGNER, STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES, STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS,
1047  STR_ABOUT_MENU_TOGGLE_WIDGET_OUTLINES});
1048  } else {
1049  PopupMainToolbarMenu(w, _game_mode == GM_EDITOR ? (WidgetID)WID_TE_HELP : (WidgetID)WID_TN_HELP, {STR_ABOUT_MENU_LAND_BLOCK_INFO,
1050  STR_ABOUT_MENU_HELP, STR_NULL, STR_ABOUT_MENU_TOGGLE_CONSOLE, STR_ABOUT_MENU_AI_DEBUG,
1051  STR_ABOUT_MENU_SCREENSHOT, STR_ABOUT_MENU_SHOW_FRAMERATE, STR_ABOUT_MENU_ABOUT_OPENTTD});
1052  }
1053  return CBF_NONE;
1054 }
1055 
1064 {
1065  extern bool _draw_bounding_boxes;
1066  /* Always allow to toggle them off */
1067  if (_settings_client.gui.newgrf_developer_tools || _draw_bounding_boxes) {
1068  _draw_bounding_boxes = !_draw_bounding_boxes;
1070  }
1071 }
1072 
1081 {
1082  extern bool _draw_dirty_blocks;
1083  /* Always allow to toggle them off */
1084  if (_settings_client.gui.newgrf_developer_tools || _draw_dirty_blocks) {
1085  _draw_dirty_blocks = !_draw_dirty_blocks;
1087  }
1088 }
1089 
1095 {
1096  extern bool _draw_widget_outlines;
1097  /* Always allow to toggle them off */
1098  if (_settings_client.gui.newgrf_developer_tools || _draw_widget_outlines) {
1099  _draw_widget_outlines = !_draw_widget_outlines;
1101  }
1102 }
1103 
1109 {
1111  TimerGameCalendar::Date new_calendar_date = TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1);
1112  TimerGameEconomy::Date new_economy_date = new_calendar_date.base();
1113 
1114  /* We must set both Calendar and Economy dates to keep them in sync. Calendar first. */
1115  TimerGameCalendar::SetDate(new_calendar_date, 0);
1116 
1117  /* If you open a savegame as a scenario, there may already be link graphs and/or vehicles. These use economy date. */
1119  for (auto v : Vehicle::Iterate()) v->ShiftDates(new_economy_date - TimerGameEconomy::date);
1120 
1121  /* Only change the date after changing cached values above. */
1122  TimerGameEconomy::SetDate(new_economy_date, 0);
1123 }
1124 
1131 {
1132  switch (index) {
1133  case 0: return PlaceLandBlockInfo();
1134  case 1: ShowHelpWindow(); break;
1135  case 2: IConsoleSwitch(); break;
1137  case 4: ShowScreenshotWindow(); break;
1138  case 5: ShowFramerateWindow(); break;
1139  case 6: ShowAboutWindow(); break;
1140  case 7: ShowSpriteAlignerWindow(); break;
1141  case 8: ToggleBoundingBoxes(); break;
1142  case 9: ToggleDirtyBlocks(); break;
1143  case 10: ToggleWidgetOutlines(); break;
1144  }
1145  return CBF_NONE;
1146 }
1147 
1148 /* --- Switch toolbar button --- */
1149 
1150 static CallBackFunction ToolbarSwitchClick(Window *w)
1151 {
1152  if (_toolbar_mode != TB_LOWER) {
1153  _toolbar_mode = TB_LOWER;
1154  } else {
1155  _toolbar_mode = TB_UPPER;
1156  }
1157 
1158  w->ReInit();
1159  w->SetWidgetLoweredState(_game_mode == GM_EDITOR ? (WidgetID)WID_TE_SWITCH_BAR : (WidgetID)WID_TN_SWITCH_BAR, _toolbar_mode == TB_LOWER);
1160  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1161  return CBF_NONE;
1162 }
1163 
1164 /* --- Scenario editor specific handlers. */
1165 
1170 {
1172  ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, w, CS_NUMERAL, QSF_ENABLE_DEFAULT);
1173  return CBF_NONE;
1174 }
1175 
1176 static CallBackFunction ToolbarScenDateBackward(Window *w)
1177 {
1178  /* don't allow too fast scrolling */
1179  if (!(w->flags & WF_TIMEOUT) || w->timeout_timer <= 1) {
1181  w->SetDirty();
1182 
1184  }
1185  _left_button_clicked = false;
1186  return CBF_NONE;
1187 }
1188 
1189 static CallBackFunction ToolbarScenDateForward(Window *w)
1190 {
1191  /* don't allow too fast scrolling */
1192  if (!(w->flags & WF_TIMEOUT) || w->timeout_timer <= 1) {
1194  w->SetDirty();
1195 
1197  }
1198  _left_button_clicked = false;
1199  return CBF_NONE;
1200 }
1201 
1202 static CallBackFunction ToolbarScenGenLand(Window *w)
1203 {
1205  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1206 
1208  return CBF_NONE;
1209 }
1210 
1211 
1212 static CallBackFunction ToolbarScenGenTown(Window *w)
1213 {
1215  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1216  ShowFoundTownWindow();
1217  return CBF_NONE;
1218 }
1219 
1220 static CallBackFunction ToolbarScenGenIndustry(Window *w)
1221 {
1223  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1224  ShowBuildIndustryWindow();
1225  return CBF_NONE;
1226 }
1227 
1228 static CallBackFunction ToolbarScenBuildRoadClick(Window *w)
1229 {
1230  ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TE_ROADS, 140, true);
1231  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1232  return CBF_NONE;
1233 }
1234 
1242 {
1243  _last_built_roadtype = (RoadType)index;
1244  ShowBuildRoadScenToolbar(_last_built_roadtype);
1245  return CBF_NONE;
1246 }
1247 
1248 static CallBackFunction ToolbarScenBuildTramClick(Window *w)
1249 {
1250  ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TE_TRAMS, 140, true);
1251  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1252  return CBF_NONE;
1253 }
1254 
1262 {
1263  _last_built_tramtype = (RoadType)index;
1264  ShowBuildRoadScenToolbar(_last_built_tramtype);
1265  return CBF_NONE;
1266 }
1267 
1268 static CallBackFunction ToolbarScenBuildDocks(Window *w)
1269 {
1271  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1273  return CBF_NONE;
1274 }
1275 
1276 static CallBackFunction ToolbarScenPlantTrees(Window *w)
1277 {
1279  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1280  ShowBuildTreesToolbar();
1281  return CBF_NONE;
1282 }
1283 
1284 static CallBackFunction ToolbarScenPlaceSign(Window *w)
1285 {
1287  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1288  return SelectSignTool();
1289 }
1290 
1291 static CallBackFunction ToolbarBtn_NULL(Window *)
1292 {
1293  return CBF_NONE;
1294 }
1295 
1296 typedef CallBackFunction MenuClickedProc(int index);
1297 
1298 static MenuClickedProc * const _menu_clicked_procs[] = {
1299  nullptr, // 0
1300  nullptr, // 1
1301  MenuClickSettings, // 2
1302  MenuClickSaveLoad, // 3
1303  MenuClickMap, // 4
1304  MenuClickTown, // 5
1305  MenuClickSubsidies, // 6
1306  MenuClickStations, // 7
1307  MenuClickFinances, // 8
1308  MenuClickCompany, // 9
1309  MenuClickStory, // 10
1310  MenuClickGoal, // 11
1313  MenuClickIndustry, // 14
1314  MenuClickShowTrains, // 15
1315  MenuClickShowRoad, // 16
1316  MenuClickShowShips, // 17
1317  MenuClickShowAir, // 18
1318  MenuClickMap, // 19
1319  nullptr, // 20
1320  MenuClickBuildRail, // 21
1321  MenuClickBuildRoad, // 22
1322  MenuClickBuildTram, // 23
1323  MenuClickBuildWater, // 24
1324  MenuClickBuildAir, // 25
1325  MenuClickForest, // 26
1326  MenuClickMusicWindow, // 27
1327  MenuClickNewspaper, // 28
1328  MenuClickHelp, // 29
1329 };
1330 
1333 protected:
1334  uint spacers;
1335 
1336 public:
1338  {
1339  }
1340 
1347  {
1348  return type == WWT_IMGBTN || type == WWT_IMGBTN_2 || type == WWT_PUSHIMGBTN;
1349  }
1350 
1351  void SetupSmallestSize(Window *w) override
1352  {
1353  this->smallest_x = 0; // Biggest child
1354  this->smallest_y = 0; // Biggest child
1355  this->fill_x = 1;
1356  this->fill_y = 0;
1357  this->resize_x = 1; // We only resize in this direction
1358  this->resize_y = 0; // We never resize in this direction
1359  this->spacers = 0;
1360 
1361  uint nbuttons = 0;
1362  /* First initialise some variables... */
1363  for (const auto &child_wid : this->children) {
1364  child_wid->SetupSmallestSize(w);
1365  this->smallest_y = std::max(this->smallest_y, child_wid->smallest_y + child_wid->padding.Vertical());
1366  if (this->IsButton(child_wid->type)) {
1367  nbuttons++;
1368  this->smallest_x = std::max(this->smallest_x, child_wid->smallest_x + child_wid->padding.Horizontal());
1369  } else if (child_wid->type == NWID_SPACER) {
1370  this->spacers++;
1371  }
1372  }
1373 
1374  /* ... then in a second pass make sure the 'current' heights are set. Won't change ever. */
1375  for (const auto &child_wid : this->children) {
1376  child_wid->current_y = this->smallest_y;
1377  if (!this->IsButton(child_wid->type)) {
1378  child_wid->current_x = child_wid->smallest_x;
1379  }
1380  }
1381  _toolbar_width = nbuttons * this->smallest_x;
1382  }
1383 
1384  void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override
1385  {
1386  assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
1387 
1388  this->pos_x = x;
1389  this->pos_y = y;
1390  this->current_x = given_width;
1391  this->current_y = given_height;
1392 
1393  /* Figure out what are the visible buttons */
1394  uint arrangable_count, button_count, spacer_count;
1395  const WidgetID *arrangement = GetButtonArrangement(given_width, arrangable_count, button_count, spacer_count);
1396 
1397  /* Create us ourselves a quick lookup table from WidgetID to slot. */
1398  std::map<WidgetID, uint> lookup;
1399  for (auto it = std::begin(this->children); it != std::end(this->children); ++it) {
1400  NWidgetBase *nwid = it->get();
1401  nwid->current_x = 0; /* Hide widget, it will be revealed in the next step. */
1402  if (nwid->type == NWID_SPACER) continue;
1403  lookup[dynamic_cast<NWidgetCore *>(nwid)->index] = std::distance(this->children.begin(), it);
1404  }
1405 
1406  /* Now assign the widgets to their rightful place */
1407  uint position = 0; // Place to put next child relative to origin of the container.
1408  uint spacer_space = std::max(0, (int)given_width - (int)(button_count * this->smallest_x)); // Remaining spacing for 'spacer' widgets
1409  uint button_space = given_width - spacer_space; // Remaining spacing for the buttons
1410  uint spacer_i = 0;
1411  uint button_i = 0;
1412 
1413  /* Index into the arrangement indices. The macro lastof cannot be used here! */
1414  const WidgetID *slotp = rtl ? &arrangement[arrangable_count - 1] : arrangement;
1415  for (uint i = 0; i < arrangable_count; i++) {
1416  uint slot = lookup[*slotp];
1417  auto &child_wid = this->children[slot];
1418  /* If we have space to give to the spacers, do that. */
1419  if (spacer_space > 0 && slot > 0 && slot < this->children.size() - 1) {
1420  const auto &possible_spacer = this->children[slot + (rtl ? 1 : -1)];
1421  if (possible_spacer != nullptr && possible_spacer->type == NWID_SPACER) {
1422  uint add = spacer_space / (spacer_count - spacer_i);
1423  position += add;
1424  spacer_space -= add;
1425  spacer_i++;
1426  }
1427  }
1428 
1429  /* Buttons can be scaled, the others not. */
1430  if (this->IsButton(child_wid->type)) {
1431  child_wid->current_x = button_space / (button_count - button_i);
1432  button_space -= child_wid->current_x;
1433  button_i++;
1434  } else {
1435  child_wid->current_x = child_wid->smallest_x;
1436  }
1437  child_wid->AssignSizePosition(sizing, x + position, y, child_wid->current_x, this->current_y, rtl);
1438  position += child_wid->current_x;
1439 
1440  if (rtl) {
1441  slotp--;
1442  } else {
1443  slotp++;
1444  }
1445  }
1446  }
1447 
1448  void Draw(const Window *w) override
1449  {
1450  /* Draw brown-red toolbar bg. */
1451  const Rect r = this->GetCurrentRect();
1454 
1455  this->NWidgetContainer::Draw(w);
1456  }
1457 
1466  virtual const WidgetID *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const = 0;
1467 };
1468 
1471  const WidgetID *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override
1472  {
1473  static const uint SMALLEST_ARRANGEMENT = 14;
1474  static const uint BIGGEST_ARRANGEMENT = 20;
1475 
1476  /* The number of buttons of each row of the toolbar should match the number of items which we want to be visible.
1477  * The total number of buttons should be equal to arrangable_count * 2.
1478  * No bad things happen, but we could see strange behaviours if we have buttons < (arrangable_count * 2) like a
1479  * pause button appearing on the right of the lower toolbar and weird resizing of the widgets even if there is
1480  * enough space.
1481  */
1482  static const WidgetID arrange14[] = {
1483  WID_TN_PAUSE,
1485  WID_TN_TRAINS,
1487  WID_TN_SHIPS,
1491  WID_TN_RAILS,
1492  WID_TN_ROADS,
1493  WID_TN_WATER,
1494  WID_TN_AIR,
1497  // lower toolbar
1499  WID_TN_SAVE,
1501  WID_TN_TOWNS,
1506  WID_TN_GRAPHS,
1510  WID_TN_HELP,
1512  };
1513  static const WidgetID arrange15[] = {
1514  WID_TN_PAUSE,
1517  WID_TN_TRAINS,
1519  WID_TN_SHIPS,
1521  WID_TN_RAILS,
1522  WID_TN_ROADS,
1523  WID_TN_WATER,
1524  WID_TN_AIR,
1529  // lower toolbar
1530  WID_TN_PAUSE,
1533  WID_TN_SAVE,
1534  WID_TN_TOWNS,
1539  WID_TN_GRAPHS,
1543  WID_TN_HELP,
1545  };
1546  static const WidgetID arrange16[] = {
1547  WID_TN_PAUSE,
1551  WID_TN_TRAINS,
1553  WID_TN_SHIPS,
1555  WID_TN_RAILS,
1556  WID_TN_ROADS,
1557  WID_TN_WATER,
1558  WID_TN_AIR,
1563  // lower toolbar
1564  WID_TN_PAUSE,
1566  WID_TN_SAVE,
1567  WID_TN_TOWNS,
1572  WID_TN_GRAPHS,
1576  WID_TN_HELP,
1580  };
1581  static const WidgetID arrange17[] = {
1582  WID_TN_PAUSE,
1587  WID_TN_TRAINS,
1589  WID_TN_SHIPS,
1591  WID_TN_RAILS,
1592  WID_TN_ROADS,
1593  WID_TN_WATER,
1594  WID_TN_AIR,
1599  // lower toolbar
1600  WID_TN_PAUSE,
1602  WID_TN_SAVE,
1605  WID_TN_TOWNS,
1609  WID_TN_GRAPHS,
1613  WID_TN_HELP,
1617  };
1618  static const WidgetID arrange18[] = {
1619  WID_TN_PAUSE,
1623  WID_TN_TOWNS,
1629  WID_TN_RAILS,
1630  WID_TN_ROADS,
1631  WID_TN_WATER,
1632  WID_TN_AIR,
1637  // lower toolbar
1638  WID_TN_PAUSE,
1640  WID_TN_SAVE,
1642  WID_TN_TOWNS,
1645  WID_TN_GRAPHS,
1646  WID_TN_TRAINS,
1648  WID_TN_SHIPS,
1652  WID_TN_HELP,
1656  };
1657  static const WidgetID arrange19[] = {
1658  WID_TN_PAUSE,
1662  WID_TN_TOWNS,
1664  WID_TN_TRAINS,
1666  WID_TN_SHIPS,
1668  WID_TN_RAILS,
1669  WID_TN_ROADS,
1670  WID_TN_WATER,
1671  WID_TN_AIR,
1677  // lower toolbar
1678  WID_TN_PAUSE,
1680  WID_TN_SAVE,
1685  WID_TN_GRAPHS,
1688  WID_TN_RAILS,
1689  WID_TN_ROADS,
1690  WID_TN_WATER,
1691  WID_TN_AIR,
1693  WID_TN_HELP,
1697  };
1698  static const WidgetID arrange20[] = {
1699  WID_TN_PAUSE,
1703  WID_TN_TOWNS,
1705  WID_TN_TRAINS,
1707  WID_TN_SHIPS,
1709  WID_TN_RAILS,
1710  WID_TN_ROADS,
1711  WID_TN_WATER,
1712  WID_TN_AIR,
1715  WID_TN_GOAL,
1719  // lower toolbar
1720  WID_TN_PAUSE,
1722  WID_TN_SAVE,
1727  WID_TN_GRAPHS,
1730  WID_TN_RAILS,
1731  WID_TN_ROADS,
1732  WID_TN_WATER,
1733  WID_TN_AIR,
1735  WID_TN_STORY,
1736  WID_TN_HELP,
1740  };
1741  static const WidgetID arrange_all[] = {
1742  WID_TN_PAUSE,
1745  WID_TN_SAVE,
1747  WID_TN_TOWNS,
1752  WID_TN_STORY,
1753  WID_TN_GOAL,
1754  WID_TN_GRAPHS,
1755  WID_TN_LEAGUE,
1757  WID_TN_TRAINS,
1759  WID_TN_SHIPS,
1763  WID_TN_RAILS,
1764  WID_TN_ROADS,
1765  WID_TN_TRAMS,
1766  WID_TN_WATER,
1767  WID_TN_AIR,
1771  WID_TN_HELP
1772  };
1773 
1774  /* If at least BIGGEST_ARRANGEMENT fit, just spread all the buttons nicely */
1775  uint full_buttons = std::max(CeilDiv(width, this->smallest_x), SMALLEST_ARRANGEMENT);
1776  if (full_buttons > BIGGEST_ARRANGEMENT) {
1777  button_count = arrangable_count = lengthof(arrange_all);
1778  spacer_count = this->spacers;
1779  return arrange_all;
1780  }
1781 
1782  /* Introduce the split toolbar */
1783  static const WidgetID * const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20 };
1784 
1785  button_count = arrangable_count = full_buttons;
1786  spacer_count = this->spacers;
1787  return arrangements[full_buttons - SMALLEST_ARRANGEMENT] + ((_toolbar_mode == TB_LOWER) ? full_buttons : 0);
1788  }
1789 };
1790 
1793  uint panel_widths[2];
1794 
1795  void SetupSmallestSize(Window *w) override
1796  {
1798 
1799  /* Find the size of panel_widths */
1800  uint i = 0;
1801  for (const auto &child_wid : this->children) {
1802  if (child_wid->type == NWID_SPACER || this->IsButton(child_wid->type)) continue;
1803 
1804  assert(i < lengthof(this->panel_widths));
1805  this->panel_widths[i++] = child_wid->current_x;
1806  _toolbar_width += child_wid->current_x;
1807  }
1808  }
1809 
1810  const WidgetID *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override
1811  {
1812  static const WidgetID arrange_all[] = {
1813  WID_TE_PAUSE,
1816  WID_TE_SAVE,
1817  WID_TE_SPACER,
1825  WID_TE_ROADS,
1826  WID_TE_TRAMS,
1827  WID_TE_WATER,
1828  WID_TE_TREES,
1829  WID_TE_SIGNS,
1831  WID_TE_HELP,
1832  };
1833  static const WidgetID arrange_nopanel[] = {
1834  WID_TE_PAUSE,
1837  WID_TE_SAVE,
1845  WID_TE_ROADS,
1846  WID_TE_TRAMS,
1847  WID_TE_WATER,
1848  WID_TE_TREES,
1849  WID_TE_SIGNS,
1851  WID_TE_HELP,
1852  };
1853  static const WidgetID arrange_switch[] = {
1859  WID_TE_ROADS,
1860  WID_TE_TRAMS,
1861  WID_TE_WATER,
1862  WID_TE_TREES,
1863  WID_TE_SIGNS,
1865  // lower toolbar
1866  WID_TE_PAUSE,
1869  WID_TE_SAVE,
1875  WID_TE_HELP,
1877  };
1878 
1879  /* If we can place all buttons *and* the panels, show them. */
1880  uint min_full_width = (lengthof(arrange_all) - lengthof(this->panel_widths)) * this->smallest_x + this->panel_widths[0] + this->panel_widths[1];
1881  if (width >= min_full_width) {
1882  width -= this->panel_widths[0] + this->panel_widths[1];
1883  arrangable_count = lengthof(arrange_all);
1884  button_count = arrangable_count - 2;
1885  spacer_count = this->spacers;
1886  return arrange_all;
1887  }
1888 
1889  /* 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 */
1890  uint min_small_width = (lengthof(arrange_switch) - lengthof(this->panel_widths)) * this->smallest_x / 2 + this->panel_widths[1];
1891  if (width > min_small_width) {
1892  width -= this->panel_widths[1];
1893  arrangable_count = lengthof(arrange_nopanel);
1894  button_count = arrangable_count - 1;
1895  spacer_count = this->spacers - 1;
1896  return arrange_nopanel;
1897  }
1898 
1899  /* Split toolbar */
1900  width -= this->panel_widths[1];
1901  arrangable_count = lengthof(arrange_switch) / 2;
1902  button_count = arrangable_count - 1;
1903  spacer_count = 0;
1904  return arrange_switch + ((_toolbar_mode == TB_LOWER) ? arrangable_count : 0);
1905  }
1906 };
1907 
1908 /* --- Toolbar handling for the 'normal' case */
1909 
1910 typedef CallBackFunction ToolbarButtonProc(Window *w);
1911 
1912 static ToolbarButtonProc * const _toolbar_button_procs[] = {
1913  ToolbarPauseClick,
1917  ToolbarMapClick,
1918  ToolbarTownClick,
1919  ToolbarSubsidiesClick,
1920  ToolbarStationsClick,
1921  ToolbarFinancesClick,
1922  ToolbarCompaniesClick,
1923  ToolbarStoryClick,
1924  ToolbarGoalClick,
1925  ToolbarGraphsClick,
1926  ToolbarLeagueClick,
1927  ToolbarIndustryClick,
1928  ToolbarTrainClick,
1929  ToolbarRoadClick,
1930  ToolbarShipClick,
1931  ToolbarAirClick,
1932  ToolbarZoomInClick,
1933  ToolbarZoomOutClick,
1934  ToolbarBuildRailClick,
1935  ToolbarBuildRoadClick,
1936  ToolbarBuildTramClick,
1937  ToolbarBuildWaterClick,
1938  ToolbarBuildAirClick,
1939  ToolbarForestClick,
1940  ToolbarMusicClick,
1941  ToolbarNewspaperClick,
1942  ToolbarHelpClick,
1943  ToolbarSwitchClick,
1944 };
1945 
1948  MainToolbarWindow(WindowDesc *desc) : Window(desc)
1949  {
1950  this->InitNested(0);
1951 
1952  _last_started_action = CBF_NONE;
1953  CLRBITS(this->flags, WF_WHITE_BORDER);
1954  this->SetWidgetDisabledState(WID_TN_PAUSE, _networking && !_network_server); // if not server, disable pause button
1955  this->SetWidgetDisabledState(WID_TN_FAST_FORWARD, _networking); // if networking, disable fast-forward button
1956  PositionMainToolbar(this);
1958  }
1959 
1960  void FindWindowPlacementAndResize([[maybe_unused]] int def_width, [[maybe_unused]] int def_height) override
1961  {
1963  }
1964 
1965  void OnPaint() override
1966  {
1967  /* If spectator, disable all construction buttons
1968  * ie : Build road, rail, ships, airports and landscaping
1969  * Since enabled state is the default, just disable when needed */
1971  /* disable company list drop downs, if there are no companies */
1973 
1976 
1977  this->DrawWidgets();
1978  }
1979 
1980  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1981  {
1982  if (_game_mode != GM_MENU && !this->IsWidgetDisabled(widget)) _toolbar_button_procs[widget](this);
1983  }
1984 
1985  void OnDropdownSelect(WidgetID widget, int index) override
1986  {
1987  CallBackFunction cbf = _menu_clicked_procs[widget](index);
1988  if (cbf != CBF_NONE) _last_started_action = cbf;
1989  }
1990 
1991  EventState OnHotkey(int hotkey) override
1992  {
1993  CallBackFunction cbf = CBF_NONE;
1994  switch (hotkey) {
1995  case MTHK_PAUSE: ToolbarPauseClick(this); break;
1996  case MTHK_FASTFORWARD: ToolbarFastForwardClick(this); break;
1997  case MTHK_SETTINGS: ShowGameOptions(); break;
1998  case MTHK_SAVEGAME: MenuClickSaveLoad(); break;
1999  case MTHK_LOADGAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break;
2000  case MTHK_SMALLMAP: ShowSmallMap(); break;
2001  case MTHK_TOWNDIRECTORY: ShowTownDirectory(); break;
2002  case MTHK_SUBSIDIES: ShowSubsidiesList(); break;
2003  case MTHK_STATIONS: ShowCompanyStations(_local_company); break;
2004  case MTHK_FINANCES: ShowCompanyFinances(_local_company); break;
2005  case MTHK_COMPANIES: ShowCompany(_local_company); break;
2006  case MTHK_STORY: ShowStoryBook(_local_company); break;
2007  case MTHK_GOAL: ShowGoalsList(_local_company); break;
2008  case MTHK_GRAPHS: ShowOperatingProfitGraph(); break;
2009  case MTHK_LEAGUE: ShowFirstLeagueTable(); break;
2010  case MTHK_INDUSTRIES: ShowBuildIndustryWindow(); break;
2011  case MTHK_TRAIN_LIST: ShowVehicleListWindow(_local_company, VEH_TRAIN); break;
2012  case MTHK_ROADVEH_LIST: ShowVehicleListWindow(_local_company, VEH_ROAD); break;
2013  case MTHK_SHIP_LIST: ShowVehicleListWindow(_local_company, VEH_SHIP); break;
2014  case MTHK_AIRCRAFT_LIST: ShowVehicleListWindow(_local_company, VEH_AIRCRAFT); break;
2015  case MTHK_ZOOM_IN: ToolbarZoomInClick(this); break;
2016  case MTHK_ZOOM_OUT: ToolbarZoomOutClick(this); break;
2017  case MTHK_BUILD_RAIL: ShowBuildRailToolbar(_last_built_railtype); break;
2018  case MTHK_BUILD_ROAD: ShowBuildRoadToolbar(_last_built_roadtype); break;
2019  case MTHK_BUILD_TRAM: ShowBuildRoadToolbar(_last_built_tramtype); break;
2020  case MTHK_BUILD_DOCKS: ShowBuildDocksToolbar(); break;
2021  case MTHK_BUILD_AIRPORT: ShowBuildAirToolbar(); break;
2022  case MTHK_BUILD_TREES: ShowBuildTreesToolbar(); break;
2023  case MTHK_MUSIC: ShowMusicWindow(); break;
2024  case MTHK_SCRIPT_DEBUG: ShowScriptDebugWindow(); break;
2025  case MTHK_SMALL_SCREENSHOT: MakeScreenshotWithConfirm(SC_VIEWPORT); break;
2026  case MTHK_ZOOMEDIN_SCREENSHOT: MakeScreenshotWithConfirm(SC_ZOOMEDIN); break;
2027  case MTHK_DEFAULTZOOM_SCREENSHOT: MakeScreenshotWithConfirm(SC_DEFAULTZOOM); break;
2028  case MTHK_GIANT_SCREENSHOT: MakeScreenshotWithConfirm(SC_WORLD); break;
2029  case MTHK_CHEATS: if (!_networking) ShowCheatWindow(); break;
2030  case MTHK_TERRAFORM: ShowTerraformToolbar(); break;
2031  case MTHK_EXTRA_VIEWPORT: ShowExtraViewportWindowForTileUnderCursor(); break;
2032  case MTHK_CLIENT_LIST: if (_networking) ShowClientList(); break;
2033  case MTHK_SIGN_LIST: ShowSignList(); break;
2034  case MTHK_LANDINFO: cbf = PlaceLandBlockInfo(); break;
2035  default: return ES_NOT_HANDLED;
2036  }
2037  if (cbf != CBF_NONE) _last_started_action = cbf;
2038  return ES_HANDLED;
2039  }
2040 
2041  void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
2042  {
2043  switch (_last_started_action) {
2044  case CBF_PLACE_SIGN:
2045  PlaceProc_Sign(tile);
2046  break;
2047 
2048  case CBF_PLACE_LANDINFO:
2049  ShowLandInfo(tile);
2050  break;
2051 
2052  default: NOT_REACHED();
2053  }
2054  }
2055 
2056  void OnPlaceObjectAbort() override
2057  {
2058  _last_started_action = CBF_NONE;
2059  }
2060 
2062  IntervalTimer<TimerWindow> refresh_interval = {std::chrono::milliseconds(30), [this](auto) {
2063  if (this->IsWidgetLowered(WID_TN_PAUSE) != !!_pause_mode) {
2066  }
2067 
2068  if (this->IsWidgetLowered(WID_TN_FAST_FORWARD) != (_game_speed != 100)) {
2071  }
2072  }};
2073 
2074  void OnTimeout() override
2075  {
2076  /* We do not want to automatically raise the pause, fast forward and
2077  * switchbar buttons; they have to stay down when pressed etc. */
2078  for (WidgetID i = WID_TN_SETTINGS; i < WID_TN_SWITCH_BAR; i++) {
2079  this->RaiseWidgetWhenLowered(i);
2080  }
2081  }
2082 
2088  void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
2089  {
2090  if (!gui_scope) return;
2092  }
2093 
2094  static inline HotkeyList hotkeys{"maintoolbar", {
2095  Hotkey({WKC_F1, WKC_PAUSE}, "pause", MTHK_PAUSE),
2096  Hotkey(0, "fastforward", MTHK_FASTFORWARD),
2097  Hotkey(WKC_F2, "settings", MTHK_SETTINGS),
2098  Hotkey(WKC_F3, "saveload", MTHK_SAVEGAME),
2099  Hotkey(0, "load_game", MTHK_LOADGAME),
2100  Hotkey({WKC_F4, 'M'}, "smallmap", MTHK_SMALLMAP),
2101  Hotkey(WKC_F5, "town_list", MTHK_TOWNDIRECTORY),
2102  Hotkey(WKC_F6, "subsidies", MTHK_SUBSIDIES),
2103  Hotkey(WKC_F7, "station_list", MTHK_STATIONS),
2104  Hotkey(WKC_F8, "finances", MTHK_FINANCES),
2105  Hotkey(WKC_F9, "companies", MTHK_COMPANIES),
2106  Hotkey(0, "story_book", MTHK_STORY),
2107  Hotkey(0, "goal_list", MTHK_GOAL),
2108  Hotkey(WKC_F10, "graphs", MTHK_GRAPHS),
2109  Hotkey(WKC_F11, "league", MTHK_LEAGUE),
2110  Hotkey(WKC_F12, "industry_list", MTHK_INDUSTRIES),
2111  Hotkey(WKC_SHIFT | WKC_F1, "train_list", MTHK_TRAIN_LIST),
2112  Hotkey(WKC_SHIFT | WKC_F2, "roadveh_list", MTHK_ROADVEH_LIST),
2113  Hotkey(WKC_SHIFT | WKC_F3, "ship_list", MTHK_SHIP_LIST),
2114  Hotkey(WKC_SHIFT | WKC_F4, "aircraft_list", MTHK_AIRCRAFT_LIST),
2115  Hotkey({WKC_NUM_PLUS, WKC_EQUALS, WKC_SHIFT | WKC_EQUALS, WKC_SHIFT | WKC_F5}, "zoomin", MTHK_ZOOM_IN),
2116  Hotkey({WKC_NUM_MINUS, WKC_MINUS, WKC_SHIFT | WKC_MINUS, WKC_SHIFT | WKC_F6}, "zoomout", MTHK_ZOOM_OUT),
2117  Hotkey(WKC_SHIFT | WKC_F7, "build_rail", MTHK_BUILD_RAIL),
2118  Hotkey(WKC_SHIFT | WKC_F8, "build_road", MTHK_BUILD_ROAD),
2119  Hotkey(0, "build_tram", MTHK_BUILD_TRAM),
2120  Hotkey(WKC_SHIFT | WKC_F9, "build_docks", MTHK_BUILD_DOCKS),
2121  Hotkey(WKC_SHIFT | WKC_F10, "build_airport", MTHK_BUILD_AIRPORT),
2122  Hotkey(WKC_SHIFT | WKC_F11, "build_trees", MTHK_BUILD_TREES),
2123  Hotkey(WKC_SHIFT | WKC_F12, "music", MTHK_MUSIC),
2124  Hotkey(0, "ai_debug", MTHK_SCRIPT_DEBUG),
2125  Hotkey(WKC_CTRL | 'S', "small_screenshot", MTHK_SMALL_SCREENSHOT),
2126  Hotkey(WKC_CTRL | 'P', "zoomedin_screenshot", MTHK_ZOOMEDIN_SCREENSHOT),
2127  Hotkey(WKC_CTRL | 'D', "defaultzoom_screenshot", MTHK_DEFAULTZOOM_SCREENSHOT),
2128  Hotkey(0, "giant_screenshot", MTHK_GIANT_SCREENSHOT),
2129  Hotkey(WKC_CTRL | WKC_ALT | 'C', "cheats", MTHK_CHEATS),
2130  Hotkey('L', "terraform", MTHK_TERRAFORM),
2131  Hotkey('V', "extra_viewport", MTHK_EXTRA_VIEWPORT),
2132  Hotkey(0, "client_list", MTHK_CLIENT_LIST),
2133  Hotkey(0, "sign_list", MTHK_SIGN_LIST),
2134  Hotkey(0, "land_info", MTHK_LANDINFO),
2135  }};
2136 };
2137 
2138 static std::unique_ptr<NWidgetBase> MakeMainToolbar()
2139 {
2141  static const SpriteID toolbar_button_sprites[] = {
2142  SPR_IMG_PAUSE, // WID_TN_PAUSE
2143  SPR_IMG_FASTFORWARD, // WID_TN_FAST_FORWARD
2144  SPR_IMG_SETTINGS, // WID_TN_SETTINGS
2145  SPR_IMG_SAVE, // WID_TN_SAVE
2146  SPR_IMG_SMALLMAP, // WID_TN_SMALL_MAP
2147  SPR_IMG_TOWN, // WID_TN_TOWNS
2148  SPR_IMG_SUBSIDIES, // WID_TN_SUBSIDIES
2149  SPR_IMG_COMPANY_LIST, // WID_TN_STATIONS
2150  SPR_IMG_COMPANY_FINANCE, // WID_TN_FINANCES
2151  SPR_IMG_COMPANY_GENERAL, // WID_TN_COMPANIES
2152  SPR_IMG_STORY_BOOK, // WID_TN_STORY
2153  SPR_IMG_GOAL, // WID_TN_GOAL
2154  SPR_IMG_GRAPHS, // WID_TN_GRAPHS
2155  SPR_IMG_COMPANY_LEAGUE, // WID_TN_LEAGUE
2156  SPR_IMG_INDUSTRY, // WID_TN_INDUSTRIES
2157  SPR_IMG_TRAINLIST, // WID_TN_TRAINS
2158  SPR_IMG_TRUCKLIST, // WID_TN_ROADVEHS
2159  SPR_IMG_SHIPLIST, // WID_TN_SHIPS
2160  SPR_IMG_AIRPLANESLIST, // WID_TN_AIRCRAFT
2161  SPR_IMG_ZOOMIN, // WID_TN_ZOOMIN
2162  SPR_IMG_ZOOMOUT, // WID_TN_ZOOMOUT
2163  SPR_IMG_BUILDRAIL, // WID_TN_RAILS
2164  SPR_IMG_BUILDROAD, // WID_TN_ROADS
2165  SPR_IMG_BUILDTRAMS, // WID_TN_TRAMS
2166  SPR_IMG_BUILDWATER, // WID_TN_WATER
2167  SPR_IMG_BUILDAIR, // WID_TN_AIR
2168  SPR_IMG_LANDSCAPING, // WID_TN_LANDSCAPE
2169  SPR_IMG_MUSIC, // WID_TN_MUSIC_SOUND
2170  SPR_IMG_MESSAGES, // WID_TN_MESSAGES
2171  SPR_IMG_QUERY, // WID_TN_HELP
2172  SPR_IMG_SWITCH_TOOLBAR, // WID_TN_SWITCH_BAR
2173  };
2174 
2175  auto hor = std::make_unique<NWidgetMainToolbarContainer>();
2176  for (WidgetID i = 0; i < WID_TN_END; i++) {
2177  switch (i) {
2178  case WID_TN_SMALL_MAP:
2179  case WID_TN_FINANCES:
2180  case WID_TN_VEHICLE_START:
2181  case WID_TN_ZOOM_IN:
2183  case WID_TN_MUSIC_SOUND:
2184  hor->Add(std::make_unique<NWidgetSpacer>(0, 0));
2185  break;
2186  }
2187  auto leaf = std::make_unique<NWidgetLeaf>(i == WID_TN_SAVE ? WWT_IMGBTN_2 : WWT_IMGBTN, COLOUR_GREY, i, toolbar_button_sprites[i], STR_TOOLBAR_TOOLTIP_PAUSE_GAME + i);
2188  leaf->SetMinimalSize(20, 20);
2189  hor->Add(std::move(leaf));
2190  }
2191 
2192  return hor;
2193 }
2194 
2195 static constexpr NWidgetPart _nested_toolbar_normal_widgets[] = {
2197 };
2198 
2199 static WindowDesc _toolb_normal_desc(__FILE__, __LINE__,
2200  WDP_MANUAL, nullptr, 0, 0,
2203  std::begin(_nested_toolbar_normal_widgets), std::end(_nested_toolbar_normal_widgets),
2204  &MainToolbarWindow::hotkeys
2205 );
2206 
2207 
2208 /* --- Toolbar handling for the scenario editor */
2209 
2210 static MenuClickedProc * const _scen_toolbar_dropdown_procs[] = {
2211  nullptr, // 0
2212  nullptr, // 1
2213  MenuClickSettings, // 2
2214  MenuClickSaveLoad, // 3
2215  nullptr, // 4
2216  nullptr, // 5
2217  nullptr, // 6
2218  nullptr, // 7
2219  MenuClickMap, // 8
2220  nullptr, // 9
2221  nullptr, // 10
2222  nullptr, // 11
2223  nullptr, // 12
2224  nullptr, // 13
2225  ToolbarScenBuildRoad, // 14
2226  ToolbarScenBuildTram, // 15
2227  nullptr, // 16
2228  nullptr, // 17
2229  nullptr, // 18
2230  nullptr, // 19
2231  MenuClickMusicWindow, // 20
2232  MenuClickHelp, // 21
2233  nullptr, // 22
2234 };
2235 
2236 static ToolbarButtonProc * const _scen_toolbar_button_procs[] = {
2237  ToolbarPauseClick,
2241  ToolbarBtn_NULL,
2243  ToolbarScenDateBackward,
2244  ToolbarScenDateForward,
2245  ToolbarScenMapTownDir,
2246  ToolbarZoomInClick,
2247  ToolbarZoomOutClick,
2248  ToolbarScenGenLand,
2249  ToolbarScenGenTown,
2250  ToolbarScenGenIndustry,
2251  ToolbarScenBuildRoadClick,
2252  ToolbarScenBuildTramClick,
2253  ToolbarScenBuildDocks,
2254  ToolbarScenPlantTrees,
2255  ToolbarScenPlaceSign,
2256  ToolbarBtn_NULL,
2257  ToolbarMusicClick,
2258  ToolbarHelpClick,
2259  ToolbarSwitchClick,
2260 };
2261 
2262 enum MainToolbarEditorHotkeys {
2263  MTEHK_PAUSE,
2264  MTEHK_FASTFORWARD,
2265  MTEHK_SETTINGS,
2266  MTEHK_SAVEGAME,
2267  MTEHK_GENLAND,
2268  MTEHK_GENTOWN,
2269  MTEHK_GENINDUSTRY,
2270  MTEHK_BUILD_ROAD,
2271  MTEHK_BUILD_TRAM,
2272  MTEHK_BUILD_DOCKS,
2273  MTEHK_BUILD_TREES,
2274  MTEHK_SIGN,
2275  MTEHK_MUSIC,
2276  MTEHK_LANDINFO,
2277  MTEHK_SMALL_SCREENSHOT,
2278  MTEHK_ZOOMEDIN_SCREENSHOT,
2279  MTEHK_DEFAULTZOOM_SCREENSHOT,
2280  MTEHK_GIANT_SCREENSHOT,
2281  MTEHK_ZOOM_IN,
2282  MTEHK_ZOOM_OUT,
2283  MTEHK_TERRAFORM,
2284  MTEHK_SMALLMAP,
2285  MTEHK_EXTRA_VIEWPORT,
2286 };
2287 
2290  {
2291  this->InitNested(0);
2292 
2293  _last_started_action = CBF_NONE;
2294  CLRBITS(this->flags, WF_WHITE_BORDER);
2295  PositionMainToolbar(this);
2297  }
2298 
2299  void FindWindowPlacementAndResize([[maybe_unused]] int def_width, [[maybe_unused]] int def_height) override
2300  {
2302  }
2303 
2304  void OnPaint() override
2305  {
2310 
2311  this->DrawWidgets();
2312  }
2313 
2314  void SetStringParameters(WidgetID widget) const override
2315  {
2316  switch (widget) {
2317  case WID_TE_DATE:
2319  break;
2320  }
2321  }
2322 
2323  void DrawWidget(const Rect &r, WidgetID widget) const override
2324  {
2325  switch (widget) {
2326  case WID_TE_SPACER: {
2327  int height = r.Height();
2328  if (height > 2 * GetCharacterHeight(FS_NORMAL)) {
2329  DrawString(r.left, r.right, height / 2 - GetCharacterHeight(FS_NORMAL), STR_SCENEDIT_TOOLBAR_OPENTTD, TC_FROMSTRING, SA_HOR_CENTER);
2330  DrawString(r.left, r.right, height / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER);
2331  } else {
2332  DrawString(r.left, r.right, (height - GetCharacterHeight(FS_NORMAL)) / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER);
2333  }
2334  break;
2335  }
2336  }
2337  }
2338 
2339  void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
2340  {
2341  switch (widget) {
2342  case WID_TE_SPACER:
2343  size->width = std::max(GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_OPENTTD).width, GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR).width) + padding.width;
2344  break;
2345 
2346  case WID_TE_DATE:
2348  *size = GetStringBoundingBox(STR_JUST_DATE_LONG);
2349  break;
2350  }
2351  }
2352 
2353  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
2354  {
2355  if (_game_mode == GM_MENU) return;
2356  CallBackFunction cbf = _scen_toolbar_button_procs[widget](this);
2357  if (cbf != CBF_NONE) _last_started_action = cbf;
2358  }
2359 
2360  void OnDropdownSelect(WidgetID widget, int index) override
2361  {
2362  CallBackFunction cbf = _scen_toolbar_dropdown_procs[widget](index);
2363  if (cbf != CBF_NONE) _last_started_action = cbf;
2364  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
2365  }
2366 
2367  EventState OnHotkey(int hotkey) override
2368  {
2369  CallBackFunction cbf = CBF_NONE;
2370  switch (hotkey) {
2371  case MTEHK_PAUSE: ToolbarPauseClick(this); break;
2372  case MTEHK_FASTFORWARD: ToolbarFastForwardClick(this); break;
2373  case MTEHK_SETTINGS: ShowGameOptions(); break;
2374  case MTEHK_SAVEGAME: MenuClickSaveLoad(); break;
2375  case MTEHK_GENLAND: ToolbarScenGenLand(this); break;
2376  case MTEHK_GENTOWN: ToolbarScenGenTown(this); break;
2377  case MTEHK_GENINDUSTRY: ToolbarScenGenIndustry(this); break;
2378  case MTEHK_BUILD_ROAD: ToolbarScenBuildRoadClick(this); break;
2379  case MTEHK_BUILD_TRAM: ToolbarScenBuildTramClick(this); break;
2380  case MTEHK_BUILD_DOCKS: ToolbarScenBuildDocks(this); break;
2381  case MTEHK_BUILD_TREES: ToolbarScenPlantTrees(this); break;
2382  case MTEHK_SIGN: cbf = ToolbarScenPlaceSign(this); break;
2383  case MTEHK_MUSIC: ShowMusicWindow(); break;
2384  case MTEHK_LANDINFO: cbf = PlaceLandBlockInfo(); break;
2385  case MTEHK_SMALL_SCREENSHOT: MakeScreenshotWithConfirm(SC_VIEWPORT); break;
2386  case MTEHK_ZOOMEDIN_SCREENSHOT: MakeScreenshotWithConfirm(SC_ZOOMEDIN); break;
2387  case MTEHK_DEFAULTZOOM_SCREENSHOT: MakeScreenshotWithConfirm(SC_DEFAULTZOOM); break;
2388  case MTEHK_GIANT_SCREENSHOT: MakeScreenshotWithConfirm(SC_WORLD); break;
2389  case MTEHK_ZOOM_IN: ToolbarZoomInClick(this); break;
2390  case MTEHK_ZOOM_OUT: ToolbarZoomOutClick(this); break;
2391  case MTEHK_TERRAFORM: ShowEditorTerraformToolbar(); break;
2392  case MTEHK_SMALLMAP: ShowSmallMap(); break;
2393  case MTEHK_EXTRA_VIEWPORT: ShowExtraViewportWindowForTileUnderCursor(); break;
2394  default: return ES_NOT_HANDLED;
2395  }
2396  if (cbf != CBF_NONE) _last_started_action = cbf;
2397  return ES_HANDLED;
2398  }
2399 
2400  void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
2401  {
2402  switch (_last_started_action) {
2403  case CBF_PLACE_SIGN:
2404  PlaceProc_Sign(tile);
2405  break;
2406 
2407  case CBF_PLACE_LANDINFO:
2408  ShowLandInfo(tile);
2409  break;
2410 
2411  default: NOT_REACHED();
2412  }
2413  }
2414 
2415  void OnPlaceObjectAbort() override
2416  {
2417  _last_started_action = CBF_NONE;
2418  }
2419 
2420  void OnTimeout() override
2421  {
2425  }
2426 
2428  IntervalTimer<TimerWindow> refresh_interval = {std::chrono::milliseconds(30), [this](auto) {
2429  if (this->IsWidgetLowered(WID_TE_PAUSE) != !!_pause_mode) {
2431  this->SetDirty();
2432  }
2433 
2434  if (this->IsWidgetLowered(WID_TE_FAST_FORWARD) != (_game_speed != 100)) {
2436  this->SetDirty();
2437  }
2438  }};
2439 
2445  void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
2446  {
2447  if (!gui_scope) return;
2449  }
2450 
2451  void OnQueryTextFinished(char *str) override
2452  {
2453  /* Was 'cancel' pressed? */
2454  if (str == nullptr) return;
2455 
2457  if (!StrEmpty(str)) {
2458  value = atoi(str);
2459  } else {
2460  /* An empty string means revert to the default */
2461  value = CalendarTime::DEF_START_YEAR.base();
2462  }
2463  SetStartingYear(value);
2464 
2465  this->SetDirty();
2466  }
2467 
2468  static inline HotkeyList hotkeys{"scenedit_maintoolbar", {
2469  Hotkey({WKC_F1, WKC_PAUSE}, "pause", MTEHK_PAUSE),
2470  Hotkey(0, "fastforward", MTEHK_FASTFORWARD),
2471  Hotkey(WKC_F2, "settings", MTEHK_SETTINGS),
2472  Hotkey(WKC_F3, "saveload", MTEHK_SAVEGAME),
2473  Hotkey(WKC_F4, "gen_land", MTEHK_GENLAND),
2474  Hotkey(WKC_F5, "gen_town", MTEHK_GENTOWN),
2475  Hotkey(WKC_F6, "gen_industry", MTEHK_GENINDUSTRY),
2476  Hotkey(WKC_F7, "build_road", MTEHK_BUILD_ROAD),
2477  Hotkey(0, "build_tram", MTEHK_BUILD_TRAM),
2478  Hotkey(WKC_F8, "build_docks", MTEHK_BUILD_DOCKS),
2479  Hotkey(WKC_F9, "build_trees", MTEHK_BUILD_TREES),
2480  Hotkey(WKC_F10, "build_sign", MTEHK_SIGN),
2481  Hotkey(WKC_F11, "music", MTEHK_MUSIC),
2482  Hotkey(WKC_F12, "land_info", MTEHK_LANDINFO),
2483  Hotkey(WKC_CTRL | 'S', "small_screenshot", MTEHK_SMALL_SCREENSHOT),
2484  Hotkey(WKC_CTRL | 'P', "zoomedin_screenshot", MTEHK_ZOOMEDIN_SCREENSHOT),
2485  Hotkey(WKC_CTRL | 'D', "defaultzoom_screenshot", MTEHK_DEFAULTZOOM_SCREENSHOT),
2486  Hotkey(0, "giant_screenshot", MTEHK_GIANT_SCREENSHOT),
2487  Hotkey({WKC_NUM_PLUS, WKC_EQUALS, WKC_SHIFT | WKC_EQUALS, WKC_SHIFT | WKC_F5}, "zoomin", MTEHK_ZOOM_IN),
2488  Hotkey({WKC_NUM_MINUS, WKC_MINUS, WKC_SHIFT | WKC_MINUS, WKC_SHIFT | WKC_F6}, "zoomout", MTEHK_ZOOM_OUT),
2489  Hotkey('L', "terraform", MTEHK_TERRAFORM),
2490  Hotkey('M', "smallmap", MTEHK_SMALLMAP),
2491  Hotkey('V', "extra_viewport", MTEHK_EXTRA_VIEWPORT),
2492  }};
2493 };
2494 
2495 static constexpr NWidgetPart _nested_toolb_scen_inner_widgets[] = {
2496  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_PAUSE), SetDataTip(SPR_IMG_PAUSE, STR_TOOLBAR_TOOLTIP_PAUSE_GAME),
2497  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_FAST_FORWARD), SetDataTip(SPR_IMG_FASTFORWARD, STR_TOOLBAR_TOOLTIP_FORWARD),
2498  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SETTINGS), SetDataTip(SPR_IMG_SETTINGS, STR_TOOLBAR_TOOLTIP_OPTIONS),
2499  NWidget(WWT_IMGBTN_2, COLOUR_GREY, WID_TE_SAVE), SetDataTip(SPR_IMG_SAVE, STR_SCENEDIT_TOOLBAR_TOOLTIP_SAVE_SCENARIO_LOAD_SCENARIO),
2501  NWidget(WWT_PANEL, COLOUR_GREY, WID_TE_SPACER), EndContainer(),
2503  NWidget(WWT_PANEL, COLOUR_GREY, WID_TE_DATE_PANEL),
2504  NWidget(NWID_HORIZONTAL), SetPIP(2, 2, 2), SetPadding(1),
2505  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_DATE_BACKWARD), SetDataTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_BACKWARD), SetFill(0, 1),
2506  NWidget(WWT_TEXT, COLOUR_GREY, WID_TE_DATE), SetDataTip(STR_JUST_DATE_LONG, STR_SCENEDIT_TOOLBAR_TOOLTIP_SET_DATE), SetTextStyle(TC_WHITE), SetAlignment(SA_CENTER), SetFill(0, 1),
2507  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_DATE_FORWARD), SetDataTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_FORWARD), SetFill(0, 1),
2508  EndContainer(),
2509  EndContainer(),
2511  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SMALL_MAP), SetDataTip(SPR_IMG_SMALLMAP, STR_SCENEDIT_TOOLBAR_TOOLTIP_DISPLAY_MAP_TOWN_DIRECTORY),
2513  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_ZOOM_IN), SetDataTip(SPR_IMG_ZOOMIN, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_IN),
2514  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_ZOOM_OUT), SetDataTip(SPR_IMG_ZOOMOUT, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_OUT),
2516  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_LAND_GENERATE), SetDataTip(SPR_IMG_LANDSCAPING, STR_SCENEDIT_TOOLBAR_LANDSCAPE_GENERATION),
2517  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_TOWN_GENERATE), SetDataTip(SPR_IMG_TOWN, STR_SCENEDIT_TOOLBAR_TOWN_GENERATION),
2518  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_INDUSTRY), SetDataTip(SPR_IMG_INDUSTRY, STR_SCENEDIT_TOOLBAR_INDUSTRY_GENERATION),
2519  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_ROADS), SetDataTip(SPR_IMG_BUILDROAD, STR_SCENEDIT_TOOLBAR_ROAD_CONSTRUCTION),
2520  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_TRAMS), SetDataTip(SPR_IMG_BUILDTRAMS, STR_SCENEDIT_TOOLBAR_TRAM_CONSTRUCTION),
2521  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_WATER), SetDataTip(SPR_IMG_BUILDWATER, STR_TOOLBAR_TOOLTIP_BUILD_SHIP_DOCKS),
2522  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_TREES), SetDataTip(SPR_IMG_PLANTTREES, STR_SCENEDIT_TOOLBAR_PLANT_TREES),
2523  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_SIGNS), SetDataTip(SPR_IMG_SIGN, STR_SCENEDIT_TOOLBAR_PLACE_SIGN),
2525  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_MUSIC_SOUND), SetDataTip(SPR_IMG_MUSIC, STR_TOOLBAR_TOOLTIP_SHOW_SOUND_MUSIC_WINDOW),
2526  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_HELP), SetDataTip(SPR_IMG_QUERY, STR_TOOLBAR_TOOLTIP_LAND_BLOCK_INFORMATION),
2527  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SWITCH_BAR), SetDataTip(SPR_IMG_SWITCH_TOOLBAR, STR_TOOLBAR_TOOLTIP_SWITCH_TOOLBAR),
2528 };
2529 
2530 static std::unique_ptr<NWidgetBase> MakeScenarioToolbar()
2531 {
2532  return MakeNWidgets(std::begin(_nested_toolb_scen_inner_widgets), std::end(_nested_toolb_scen_inner_widgets), std::make_unique<NWidgetScenarioToolbarContainer>());
2533 }
2534 
2535 static constexpr NWidgetPart _nested_toolb_scen_widgets[] = {
2536  NWidgetFunction(MakeScenarioToolbar),
2537 };
2538 
2539 static WindowDesc _toolb_scen_desc(__FILE__, __LINE__,
2540  WDP_MANUAL, nullptr, 0, 0,
2543  std::begin(_nested_toolb_scen_widgets), std::end(_nested_toolb_scen_widgets),
2544  &ScenarioEditorToolbarWindow::hotkeys
2545 );
2546 
2549 {
2550  /* Clean old GUI values; railtype is (re)set by rail_gui.cpp */
2551  _last_built_roadtype = ROADTYPE_ROAD;
2552  _last_built_tramtype = ROADTYPE_TRAM;
2553 
2554  if (_game_mode == GM_EDITOR) {
2555  new ScenarioEditorToolbarWindow(&_toolb_scen_desc);
2556  } else {
2557  new MainToolbarWindow(&_toolb_normal_desc);
2558  }
2559 }
VEH_AIRCRAFT
@ VEH_AIRCRAFT
Aircraft vehicle type.
Definition: vehicle_type.h:27
ShowScriptDebugWindow
Window * ShowScriptDebugWindow(CompanyID show_company, bool new_window)
Open the Script debug window and select the given company.
Definition: script_gui.cpp:1332
SaveLoadEditorMenuEntries
SaveLoadEditorMenuEntries
SaveLoad entries in scenario editor mode.
Definition: toolbar_gui.cpp:320
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:52
ShowNewGRFSettings
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
Definition: newgrf_gui.cpp:2023
game.hpp
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:739
Window::timeout_timer
uint8_t timeout_timer
Timer value of the WF_TIMEOUT for flags.
Definition: window_gui.h:300
NWidgetToolbarContainer::AssignSizePosition
void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override
Definition: toolbar_gui.cpp:1384
MenuClickFinances
static CallBackFunction MenuClickFinances(int index)
Handle click on the entry in the finances overview menu.
Definition: toolbar_gui.cpp:529
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1141
ShowSpriteAlignerWindow
void ShowSpriteAlignerWindow()
Show the window for aligning sprites.
Definition: newgrf_debug_gui.cpp:1173
NWidgetContainer::children
std::vector< std::unique_ptr< NWidgetBase > > children
Child widgets in contaier.
Definition: widget_type.h:462
ShowIndustryCargoesWindow
void ShowIndustryCargoesWindow()
Open the industry and cargoes window with an industry.
Definition: industry_gui.cpp:3222
sound_func.h
_last_started_action
static CallBackFunction _last_started_action
Last started user action.
Definition: toolbar_gui.cpp:90
WWT_IMGBTN_2
@ WWT_IMGBTN_2
(Toggle) Button with diff image when clicked
Definition: widget_type.h:55
SetBit
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
Definition: bitmath_func.hpp:121
WID_TN_GOAL
@ WID_TN_GOAL
Goal menu.
Definition: toolbar_widget.h:26
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:465
Rect::Height
int Height() const
Get height of Rect.
Definition: geometry_type.hpp:91
vehicle_gui.h
TO_HOUSES
@ TO_HOUSES
town buildings
Definition: transparency.h:25
ShowGoalsList
void ShowGoalsList(CompanyID company)
Open a goal list window.
Definition: goal_gui.cpp:316
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:2372
WID_TN_SETTINGS
@ WID_TN_SETTINGS
Settings menu.
Definition: toolbar_widget.h:17
ShowExtraViewportWindow
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
Definition: viewport_gui.cpp:156
HotkeyList
List of hotkeys for a window.
Definition: hotkeys.h:37
WID_TN_TRAINS
@ WID_TN_TRAINS
Train menu.
Definition: toolbar_widget.h:31
GUISettings::newgrf_developer_tools
bool newgrf_developer_tools
activate NewGRF developer tools and allow modifying NewGRFs in an existing game
Definition: settings_type.h:216
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
MenuClickIndustry
static CallBackFunction MenuClickIndustry(int index)
Handle click on the entry in the Industry menu.
Definition: toolbar_gui.cpp:722
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:30
ZOOM_OUT
@ ZOOM_OUT
Zoom out (get helicopter view).
Definition: viewport_type.h:74
command_func.h
PositionMainToolbar
int PositionMainToolbar(Window *w)
(Re)position main toolbar window at the screen.
Definition: window.cpp:3370
ShowBuildAirToolbar
Window * ShowBuildAirToolbar()
Open the build airport toolbar window.
Definition: airport_gui.cpp:225
toolbar_gui.h
smallmap_gui.h
WID_TN_AIR
@ WID_TN_AIR
Airport building toolbar.
Definition: toolbar_widget.h:42
WID_TN_PAUSE
@ WID_TN_PAUSE
Pause the game.
Definition: toolbar_widget.h:15
timer_game_calendar.h
WID_TN_RAILS
@ WID_TN_RAILS
Rail building menu.
Definition: toolbar_widget.h:38
signs_func.h
MainToolbarWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: toolbar_gui.cpp:2088
company_gui.h
Window::SetWidgetDirty
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:552
TF_FORBIDDEN
@ TF_FORBIDDEN
Forbidden.
Definition: town_type.h:96
SetAlignment
constexpr NWidgetPart SetAlignment(StringAlignment align)
Widget part function for setting the alignment of text/images.
Definition: widget_type.h:1130
NetworkClientRequestMove
void NetworkClientRequestMove(CompanyID company_id, const std::string &pass)
Notify the server of this client wanting to be moved to another company.
Definition: network_client.cpp:1273
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:54
Window::viewport
ViewportData * viewport
Pointer to viewport data, if present.
Definition: window_gui.h:312
_network_server
bool _network_server
network-server is active
Definition: network.cpp:60
league_gui.h
NWidgetToolbarContainer::Draw
void Draw(const Window *w) override
Definition: toolbar_gui.cpp:1448
WID_TN_FAST_FORWARD
@ WID_TN_FAST_FORWARD
Fast forward the game.
Definition: toolbar_widget.h:16
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:210
IntervalTimer< TimerWindow >
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:345
IsTransparencySet
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
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:77
WID_TN_SUBSIDIES
@ WID_TN_SUBSIDIES
Subsidy menu.
Definition: toolbar_widget.h:21
WID_TE_DATE_FORWARD
@ WID_TE_DATE_FORWARD
Increase the date of the scenario.
Definition: toolbar_widget.h:60
ZOOM_NONE
@ ZOOM_NONE
Hack, used to update the button status.
Definition: viewport_type.h:75
MenuClickBuildWater
static CallBackFunction MenuClickBuildWater(int)
Handle click on the entry in the Build Waterways menu.
Definition: toolbar_gui.cpp:927
GRMN_OPERATING_PROFIT_GRAPH
static const int GRMN_OPERATING_PROFIT_GRAPH
Enum for the League Toolbar's and Graph Toolbar's related buttons.
Definition: toolbar_gui.cpp:617
misc_cmd.h
ai_gui.hpp
LeagueTable
Struct about custom league tables.
Definition: league_base.h:52
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1151
WC_SIGN_LIST
@ WC_SIGN_LIST
Sign list; Window numbers:
Definition: window_type.h:278
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:2029
WDF_NO_FOCUS
@ WDF_NO_FOCUS
This window won't get focus/make any other window lose focus when click.
Definition: window_gui.h:199
ToolbarScenSaveOrLoad
static CallBackFunction ToolbarScenSaveOrLoad(Window *w)
Handle click on SaveLoad button in toolbar in the scenario editor.
Definition: toolbar_gui.cpp:358
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:37
FILLRECT_CHECKER
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
Definition: gfx_type.h:294
SND_15_BEEP
@ SND_15_BEEP
19 == 0x13 GUI button click
Definition: sound_type.h:58
ShowMessageHistory
void ShowMessageHistory()
Display window with news messages history.
Definition: news_gui.cpp:1239
vehicle_base.h
DoZoomInOutWindow
bool DoZoomInOutWindow(ZoomStateChange how, Window *w)
Zooms a viewport in a window in or out.
Definition: main_gui.cpp:93
screenshot_gui.h
ShowGameOptions
void ShowGameOptions()
Open the game options window.
Definition: settings_gui.cpp:1183
ToolbarFastForwardClick
static CallBackFunction ToolbarFastForwardClick(Window *)
Toggle fast forward mode.
Definition: toolbar_gui.cpp:212
ShowLandInfo
void ShowLandInfo(TileIndex tile)
Show land information window.
Definition: misc_gui.cpp:377
CeilDiv
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Definition: math_func.hpp:320
goal_base.h
ShowGameSettings
void ShowGameSettings()
Open advanced settings window.
Definition: settings_gui.cpp:2893
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:54
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:911
CallBackFunction
CallBackFunction
Callback functions.
Definition: toolbar_gui.cpp:84
newgrf_debug.h
StrongType::Typedef
Templated helper to make a type-safe 'typedef' representing a single POD value.
Definition: strong_typedef_type.hpp:150
network_gui.h
MainToolbarWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: toolbar_gui.cpp:1991
NWidgetScenarioToolbarContainer
Container for the scenario editor's toolbar.
Definition: toolbar_gui.cpp:1792
_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:2367
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
NWidgetFunction
constexpr NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition: widget_type.h:1279
MenuClickGraphsOrLeague
static CallBackFunction MenuClickGraphsOrLeague(int index)
Handle click on the entry in the Graphs or CompanyLeague.
Definition: toolbar_gui.cpp:680
WID_TE_DATE
@ WID_TE_DATE
The date of the scenario.
Definition: toolbar_widget.h:58
MenuClickMap
static CallBackFunction MenuClickMap(int index)
Handle click on one of the entries in the Map menu.
Definition: toolbar_gui.cpp:434
fios.h
ScenarioEditorToolbarWindow::refresh_interval
IntervalTimer< TimerWindow > refresh_interval
Refresh the state of pause / game-speed on a regular interval.
Definition: toolbar_gui.cpp:2428
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
MenuClickMusicWindow
static CallBackFunction MenuClickMusicWindow(int)
Handle click on the entry in the Music menu.
Definition: toolbar_gui.cpp:997
NWidgetBase::smallest_y
uint smallest_y
Smallest vertical size of the widget in a filled window.
Definition: widget_type.h:231
MenuClickBuildTram
static CallBackFunction MenuClickBuildTram(int index)
Handle click on the entry in the Build Tram menu.
Definition: toolbar_gui.cpp:904
StrEmpty
bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:56
WID_TN_STATIONS
@ WID_TN_STATIONS
Station menu.
Definition: toolbar_widget.h:22
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1757
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:1038
ShowExtraViewportWindowForTileUnderCursor
void ShowExtraViewportWindowForTileUnderCursor()
Show a new Extra Viewport window.
Definition: viewport_gui.cpp:171
WID_TN_COMPANIES
@ WID_TN_COMPANIES
Company menu.
Definition: toolbar_widget.h:24
toolbar_widget.h
DropDownListCompanyItem
Company name list item, with company-colour icon, name, and lock components.
Definition: toolbar_gui.cpp:95
DropDownIcon
Drop down icon component.
Definition: dropdown_type.h:140
textbuf_gui.h
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:619
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:225
MainToolbarWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: toolbar_gui.cpp:2074
screenshot.h
PM_UNPAUSED
@ PM_UNPAUSED
A normal unpaused game.
Definition: openttd.h:63
WindowDesc
High level window description.
Definition: window_gui.h:153
WidgetID
int WidgetID
Widget ID.
Definition: window_type.h:18
WID_TN_SAVE
@ WID_TN_SAVE
Save menu.
Definition: toolbar_widget.h:18
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:141
window_gui.h
DO_FULL_ANIMATION
@ DO_FULL_ANIMATION
Perform palette animation.
Definition: openttd.h:49
WID_TE_PAUSE
@ WID_TE_PAUSE
Pause the game.
Definition: toolbar_widget.h:53
PopupMainToolbarMenu
static void PopupMainToolbarMenu(Window *w, WidgetID widget, DropDownList &&list, int def)
Pop up a generic text only menu.
Definition: toolbar_gui.cpp:112
ShowCompanyFinances
void ShowCompanyFinances(CompanyID company)
Open the finances window of a company.
Definition: company_gui.cpp:544
MenuClickBuildAir
static CallBackFunction MenuClickBuildAir(int)
Handle click on the entry in the Build Air menu.
Definition: toolbar_gui.cpp:949
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1188
ZOOM_IN
@ ZOOM_IN
Zoom in (get more detailed view).
Definition: viewport_type.h:73
ROADTYPES_NONE
@ ROADTYPES_NONE
No roadtypes.
Definition: road_type.h:39
ScenarioEditorToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: toolbar_gui.cpp:2415
PC_VERY_DARK_RED
static const uint8_t PC_VERY_DARK_RED
Almost-black red palette colour.
Definition: palette_func.h:60
_roadtypes_type
RoadTypes _roadtypes_type
Bitmap of road/tram types.
Definition: road_cmd.cpp:62
SLO_LOAD
@ SLO_LOAD
File is being loaded.
Definition: fileio_type.h:49
GRMN_COMPANY_VALUE_GRAPH
static const int GRMN_COMPANY_VALUE_GRAPH
Show company value graph.
Definition: toolbar_gui.cpp:621
WID_TE_WATER
@ WID_TE_WATER
Water building toolbar.
Definition: toolbar_widget.h:69
ShowSignList
Window * ShowSignList()
Open the sign list window.
Definition: signs_gui.cpp:399
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:308
WKC_EQUALS
@ WKC_EQUALS
= Equals
Definition: gfx_type.h:97
LinkGraphSchedule::ShiftDates
void ShiftDates(TimerGameEconomy::Date interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
Definition: linkgraphschedule.cpp:135
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:140
WID_TE_TOWN_GENERATE
@ WID_TE_TOWN_GENERATE
Town building window.
Definition: toolbar_widget.h:65
tilehighlight_func.h
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:639
ToolbarScenBuildTram
static CallBackFunction ToolbarScenBuildTram(int index)
Handle click on the entry in the Build Tram menu.
Definition: toolbar_gui.cpp:1261
WID_TE_HELP
@ WID_TE_HELP
Help menu.
Definition: toolbar_widget.h:74
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:203
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1747
NWidgetBase::type
WidgetType type
Type of the widget / nested widget.
Definition: widget_type.h:222
SetStartingYear
void SetStartingYear(TimerGameCalendar::Year year)
Set the starting year for a scenario.
Definition: toolbar_gui.cpp:1108
Window::HandleButtonClick
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
Definition: window.cpp:591
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:306
_toolbar_width
uint _toolbar_width
Width of the toolbar, shared by statusbar.
Definition: toolbar_gui.cpp:70
WF_WHITE_BORDER
@ WF_WHITE_BORDER
Window white border counter bit mask.
Definition: window_gui.h:230
game_gui.hpp
ShowCompanyStations
void ShowCompanyStations(CompanyID company)
Opens window with list of company's stations.
Definition: station_gui.cpp:782
SaveLoadNormalMenuEntries
SaveLoadNormalMenuEntries
SaveLoad entries in normal game mode.
Definition: toolbar_gui.cpp:332
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:941
highscore.h
MenuClickSubsidies
static CallBackFunction MenuClickSubsidies(int)
Handle click on the entry in the Subsidies menu.
Definition: toolbar_gui.cpp:489
NWidgetBase::smallest_x
uint smallest_x
Smallest horizontal size of the widget in a filled window.
Definition: widget_type.h:230
NWidgetScenarioToolbarContainer::SetupSmallestSize
void SetupSmallestSize(Window *w) override
Definition: toolbar_gui.cpp:1795
TimerGameCalendar::ConvertYMDToDate
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: timer_game_calendar.cpp:55
WID_TE_DATE_PANEL
@ WID_TE_DATE_PANEL
Container for the date widgets.
Definition: toolbar_widget.h:72
GRMN_CARGO_PAYMENT_RATES
static const int GRMN_CARGO_PAYMENT_RATES
Show cargo payment rates graph.
Definition: toolbar_gui.cpp:622
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:740
MenuClickShowShips
static CallBackFunction MenuClickShowShips(int index)
Handle click on the entry in the Ships menu.
Definition: toolbar_gui.cpp:797
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:135
AllocateToolbar
void AllocateToolbar()
Allocate the toolbar.
Definition: toolbar_gui.cpp:2548
NWidgetContainer::Draw
void Draw(const Window *w) override
Definition: widget.cpp:1175
ToolbarOptionsClick
static CallBackFunction ToolbarOptionsClick(Window *w)
Handle click on Options button in toolbar.
Definition: toolbar_gui.cpp:250
_pause_mode
PauseMode _pause_mode
The current pause mode.
Definition: gfx.cpp:50
MenuClickShowRoad
static CallBackFunction MenuClickShowRoad(int index)
Handle click on the entry in the Road Vehicles menu.
Definition: toolbar_gui.cpp:777
WID_TE_MUSIC_SOUND
@ WID_TE_MUSIC_SOUND
Music/sound configuration menu.
Definition: toolbar_widget.h:73
MenuClickBuildRail
static CallBackFunction MenuClickBuildRail(int index)
Handle click on the entry in the Build Rail menu.
Definition: toolbar_gui.cpp:860
road_gui.h
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:55
linkgraph_gui.h
WID_TE_SIGNS
@ WID_TE_SIGNS
Sign building.
Definition: toolbar_widget.h:71
Window::ReInit
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:953
WID_TE_TREES
@ WID_TE_TREES
Tree building toolbar.
Definition: toolbar_widget.h:70
LTMN_PERFORMANCE_RATING
static const int LTMN_PERFORMANCE_RATING
Show detailed performance rating.
Definition: toolbar_gui.cpp:624
NWidgetToolbarContainer::IsButton
bool IsButton(WidgetType type) const
Check whether the given widget type is a button for us.
Definition: toolbar_gui.cpp:1346
GameSettings::economy
EconomySettings economy
settings to change the economy
Definition: settings_type.h:628
ShowFramerateWindow
void ShowFramerateWindow()
Open the general framerate window.
Definition: framerate_gui.cpp:1030
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1258
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:49
DO_SHOW_STATION_NAMES
@ DO_SHOW_STATION_NAMES
Display station names.
Definition: openttd.h:47
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:1086
timer.h
GameCreationSettings::starting_year
TimerGameCalendar::Year starting_year
starting date
Definition: settings_type.h:341
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:294
WF_TIMEOUT
@ WF_TIMEOUT
Window timeout counter.
Definition: window_gui.h:222
MenuClickShowAir
static CallBackFunction MenuClickShowAir(int index)
Handle click on the entry in the Aircraft menu.
Definition: toolbar_gui.cpp:817
MenuClickSaveLoad
static CallBackFunction MenuClickSaveLoad(int index=0)
Handle click on one of the entries in the SaveLoad menu.
Definition: toolbar_gui.cpp:372
ToggleDirtyBlocks
void ToggleDirtyBlocks()
Toggle drawing of the dirty blocks.
Definition: toolbar_gui.cpp:1080
_networking
bool _networking
are we in networking mode?
Definition: network.cpp:59
ROADTYPE_ROAD
@ ROADTYPE_ROAD
Basic road type.
Definition: road_type.h:27
WID_TE_SPACER
@ WID_TE_SPACER
Spacer with "scenario editor" text.
Definition: toolbar_widget.h:57
LeagueTableID
uint8_t LeagueTableID
ID of a league table.
Definition: league_type.h:32
NWidgetToolbarContainer::SetupSmallestSize
void SetupSmallestSize(Window *w) override
Definition: toolbar_gui.cpp:1351
ToolbarScenDatePanel
static CallBackFunction ToolbarScenDatePanel(Window *w)
Called when clicking at the date panel of the scenario editor toolbar.
Definition: toolbar_gui.cpp:1169
road.h
TimerGameCalendar::SetDate
static void SetDate(Date date, DateFract fract)
Set the date.
Definition: timer_game_calendar.cpp:66
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
EconomySettings::found_town
TownFounding found_town
town founding.
Definition: settings_type.h:556
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
CheckBlitter
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
Definition: gfxinit.cpp:317
Window::IsWidgetDisabled
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
Definition: window_gui.h:410
TimerGameConst< struct Calendar >::MAX_YEAR
static constexpr TimerGame< struct Calendar >::Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date,...
Definition: timer_game_common.h:173
WDF_NO_CLOSE
@ WDF_NO_CLOSE
This window can't be interactively closed.
Definition: window_gui.h:200
league_base.h
TimerGameConst< struct Calendar >::DEF_START_YEAR
static constexpr TimerGame< struct Calendar >::Year DEF_START_YEAR
The default starting year.
Definition: timer_game_common.h:179
WID_TN_MESSAGES
@ WID_TN_MESSAGES
Messages menu.
Definition: toolbar_widget.h:45
PopupMainCompanyToolbMenu
static void PopupMainCompanyToolbMenu(Window *w, WidgetID widget, CompanyMask grey=0)
Pop up a generic company list menu.
Definition: toolbar_gui.cpp:150
ShowCheatWindow
void ShowCheatWindow()
Open cheat window.
Definition: cheat_gui.cpp:434
_game_speed
uint16_t _game_speed
Current game-speed; 100 is 1x, 0 is infinite.
Definition: gfx.cpp:39
stdafx.h
ShowSaveLoadDialog
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
Definition: fios_gui.cpp:914
FT_SAVEGAME
@ FT_SAVEGAME
old or new savegame
Definition: fileio_type.h:18
DO_FULL_DETAIL
@ DO_FULL_DETAIL
Also draw details of track and roads.
Definition: openttd.h:50
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:113
ToggleBoundingBoxes
void ToggleBoundingBoxes()
Toggle drawing of sprites' bounding boxes.
Definition: toolbar_gui.cpp:1063
SpriteID
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
MenuClickCompany
static CallBackFunction MenuClickCompany(int index)
Handle click on the entry in the Company menu.
Definition: toolbar_gui.cpp:549
ShowGSConfigWindow
void ShowGSConfigWindow()
Open the GS config window.
Definition: game_gui.cpp:476
MainToolbarWindow
Main toolbar.
Definition: toolbar_gui.cpp:1947
WID_TN_SHIPS
@ WID_TN_SHIPS
Ship menu.
Definition: toolbar_widget.h:33
viewport_func.h
NetworkCompanyIsPassworded
bool NetworkCompanyIsPassworded(CompanyID company_id)
Check if the company we want to join requires a password.
Definition: network.cpp:209
NWidgetBase::current_y
uint current_y
Current vertical size (after resizing).
Definition: widget_type.h:234
ToolbarScenBuildRoad
static CallBackFunction ToolbarScenBuildRoad(int index)
Handle click on the entry in the Build Road menu.
Definition: toolbar_gui.cpp:1241
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:45
WID_TN_END
@ WID_TN_END
Helper for knowing the amount of widgets.
Definition: toolbar_widget.h:48
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_type.h:339
Window::SetWidgetLoweredState
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:441
WID_TE_LAND_GENERATE
@ WID_TE_LAND_GENERATE
Land generation.
Definition: toolbar_widget.h:64
WidgetType
WidgetType
Window widget types, nested widget types, and nested widget part types.
Definition: widget_type.h:48
WID_TN_ROADVEHS
@ WID_TN_ROADVEHS
Road vehicle menu.
Definition: toolbar_widget.h:32
ShowHighscoreTable
void ShowHighscoreTable(int difficulty=SP_CUSTOM, int8_t rank=-1)
Show the highscore table for a given difficulty.
Definition: highscore_gui.cpp:236
Window::SetWidgetDisabledState
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:381
MakeNWidgets
std::unique_ptr< NWidgetBase > MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, std::unique_ptr< NWidgetBase > &&container)
Construct a nested widget tree from an array of parts.
Definition: widget.cpp:3137
MenuClickStory
static CallBackFunction MenuClickStory(int index)
Handle click on the entry in the Story menu.
Definition: toolbar_gui.cpp:585
NWidgetMainToolbarContainer
Container for the 'normal' main toolbar.
Definition: toolbar_gui.cpp:1470
Window::IsWidgetLowered
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:491
rail_gui.h
WWT_PUSHIMGBTN
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:111
NWidgetBase::fill_y
uint fill_y
Vertical fill stepsize (from initial size, 0 means not resizable).
Definition: widget_type.h:224
WID_TN_BUILDING_TOOLS_START
@ WID_TN_BUILDING_TOOLS_START
Helper for the offset of the building tools.
Definition: toolbar_widget.h:37
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:240
vehicle_func.h
GRMN_INCOME_GRAPH
static const int GRMN_INCOME_GRAPH
Show income graph.
Definition: toolbar_gui.cpp:618
PC_DARK_RED
static const uint8_t PC_DARK_RED
Dark red palette colour.
Definition: palette_func.h:61
Pool::PoolItem<&_league_table_pool >::Iterate
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:384
WID_TE_FAST_FORWARD
@ WID_TE_FAST_FORWARD
Fast forward the game.
Definition: toolbar_widget.h:54
strings_func.h
WID_TN_ROADS
@ WID_TN_ROADS
Road building menu.
Definition: toolbar_widget.h:39
NWidgetScenarioToolbarContainer::GetButtonArrangement
const WidgetID * 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:1810
MakeMainToolbar
static std::unique_ptr< NWidgetBase > MakeMainToolbar()
Definition: toolbar_gui.cpp:2138
terraform_gui.h
ShowDropDownList
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close)
Show a drop down list.
Definition: dropdown.cpp:349
MainToolbarWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: toolbar_gui.cpp:1965
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:403
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:1130
WID_TE_ZOOM_IN
@ WID_TE_ZOOM_IN
Zoom in the main viewport.
Definition: toolbar_widget.h:62
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:236
WID_TE_ZOOM_OUT
@ WID_TE_ZOOM_OUT
Zoom out the main viewport.
Definition: toolbar_widget.h:63
Pool::PoolItem<&_league_table_pool >::GetNumItems
static size_t GetNumItems()
Returns number of valid items in the pool.
Definition: pool_type.hpp:365
DeleteAllMessages
void DeleteAllMessages()
Delete all messages and close their corresponding window (if any).
Definition: window.cpp:3274
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:60
SetPIP
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1220
ScenarioEditorToolbarWindow
Definition: toolbar_gui.cpp:2288
WID_TN_ZOOM_IN
@ WID_TN_ZOOM_IN
Zoom in the main viewport.
Definition: toolbar_widget.h:35
ShowTransparencyToolbar
void ShowTransparencyToolbar()
Show the transparency toolbar.
Definition: transparency_gui.cpp:161
SetDParam
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings.cpp:104
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:223
GRMN_PERFORMANCE_HISTORY_GRAPH
static const int GRMN_PERFORMANCE_HISTORY_GRAPH
Show performance history graph.
Definition: toolbar_gui.cpp:620
WID_TN_MUSIC_SOUND
@ WID_TN_MUSIC_SOUND
Music/sound configuration menu.
Definition: toolbar_widget.h:44
GetMainWindow
Window * GetMainWindow()
Get the main window, i.e.
Definition: window.cpp:1128
WID_TE_SAVE
@ WID_TE_SAVE
Save menu.
Definition: toolbar_widget.h:56
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:3217
MenuClickGoal
static CallBackFunction MenuClickGoal(int index)
Handle click on the entry in the Goal menu.
Definition: toolbar_gui.cpp:605
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:52
ShowLastNewsMessage
void ShowLastNewsMessage()
Show previous news item.
Definition: news_gui.cpp:1055
PM_PAUSED_NORMAL
@ PM_PAUSED_NORMAL
A game normally paused.
Definition: openttd.h:64
GRMN_DELIVERED_CARGO_GRAPH
static const int GRMN_DELIVERED_CARGO_GRAPH
Show delivered cargo graph.
Definition: toolbar_gui.cpp:619
MenuClickNewspaper
static CallBackFunction MenuClickNewspaper(int index)
Handle click on the entry in the Newspaper menu.
Definition: toolbar_gui.cpp:1017
NWidgetToolbarContainer
Full blown container to make it behave exactly as we want :)
Definition: toolbar_gui.cpp:1332
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:226
ShowSmallMap
void ShowSmallMap()
Show the smallmap window.
Definition: smallmap_gui.cpp:1994
WID_TN_INDUSTRIES
@ WID_TN_INDUSTRIES
Industry menu.
Definition: toolbar_widget.h:29
GetString
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
Definition: strings.cpp:327
EventState
EventState
State of handling an event.
Definition: window_type.h:738
HT_RECT
@ HT_RECT
rectangle (stations, depots, ...)
Definition: tilehighlight_type.h:21
transparency_gui.h
DO_SHOW_SIGNS
@ DO_SHOW_SIGNS
Display signs.
Definition: openttd.h:48
TimerGameConst< struct Calendar >::MIN_YEAR
static constexpr TimerGame< struct Calendar >::Year MIN_YEAR
The absolute minimum year in OTTD.
Definition: timer_game_common.h:176
news_gui.h
WID_TN_FINANCES
@ WID_TN_FINANCES
Finance menu.
Definition: toolbar_widget.h:23
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:122
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:25
WID_TE_DATE_BACKWARD
@ WID_TE_DATE_BACKWARD
Reduce the date of the scenario.
Definition: toolbar_widget.h:59
FT_HEIGHTMAP
@ FT_HEIGHTMAP
heightmap file
Definition: fileio_type.h:20
SC_DEFAULTZOOM
@ SC_DEFAULTZOOM
Zoomed to default zoom level screenshot of the visible area.
Definition: screenshot.h:22
ShowStoryBook
void ShowStoryBook(CompanyID company, uint16_t page_id=INVALID_STORY_PAGE, bool centered=false)
Raise or create the story book window for company, at page page_id.
Definition: story_gui.cpp:1053
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:81
ToggleTransparency
void ToggleTransparency(TransparencyOption to)
Toggle the transparency option bit.
Definition: transparency.h:69
MenuClickSettings
static CallBackFunction MenuClickSettings(int index)
Handle click on one of the entries in the Options button menu.
Definition: toolbar_gui.cpp:289
DO_SHOW_TOWN_NAMES
@ DO_SHOW_TOWN_NAMES
Display town names.
Definition: openttd.h:46
company_func.h
MainToolbarWindow::refresh_interval
IntervalTimer< TimerWindow > refresh_interval
Refresh the state of pause / game-speed on a regular interval.
Definition: toolbar_gui.cpp:2062
NWidgetScenarioToolbarContainer::panel_widths
uint panel_widths[2]
The width of the two panels (the text panel and date panel)
Definition: toolbar_gui.cpp:1793
NWidgetContainer
Baseclass for container widgets.
Definition: widget_type.h:445
TO_SIGNS
@ TO_SIGNS
signs
Definition: transparency.h:23
WID_TE_SETTINGS
@ WID_TE_SETTINGS
Settings menu.
Definition: toolbar_widget.h:55
ShowLinkGraphLegend
void ShowLinkGraphLegend()
Open a link graph legend window.
Definition: linkgraph_gui.cpp:554
Window::SetWidgetsLoweredState
void SetWidgetsLoweredState(bool lowered_stat, Args... widgets)
Sets the lowered/raised status of a list of widgets.
Definition: window_gui.h:526
WID_TN_VEHICLE_START
@ WID_TN_VEHICLE_START
Helper for the offset of the vehicle menus.
Definition: toolbar_widget.h:30
WID_TN_HELP
@ WID_TN_HELP
Help menu.
Definition: toolbar_widget.h:46
network.h
_grfconfig
GRFConfig * _grfconfig
First item in list of current GRF set up.
Definition: newgrf_config.cpp:164
TimerGameEconomy::SetDate
static void SetDate(Date date, DateFract fract)
Set the date.
Definition: timer_game_economy.cpp:81
CommandHelper
Definition: command_func.h:93
window_func.h
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition: gfx_type.h:348
SoundSettings::click_beep
bool click_beep
Beep on a random selection of buttons.
Definition: settings_type.h:241
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition: fontcache.cpp:78
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:300
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:305
CTMN_SPECTATOR
static const int CTMN_SPECTATOR
Show a company window as spectator.
Definition: toolbar_gui.cpp:142
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition: terraform_gui.cpp:367
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1552
WDP_MANUAL
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
Definition: window_gui.h:140
SC_VIEWPORT
@ SC_VIEWPORT
Screenshot of viewport.
Definition: screenshot.h:19
WID_TE_INDUSTRY
@ WID_TE_INDUSTRY
Industry building window.
Definition: toolbar_widget.h:66
MakeScreenshotWithConfirm
void MakeScreenshotWithConfirm(ScreenshotType t)
Make a screenshot.
Definition: screenshot.cpp:876
ROADTYPE_TRAM
@ ROADTYPE_TRAM
Trams.
Definition: road_type.h:28
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:237
ShowBuildRoadToolbar
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
Definition: road_gui.cpp:910
DrawString
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:658
timer_window.h
INVALID_COMPANY
@ INVALID_COMPANY
An invalid company.
Definition: company_type.h:30
engine_base.h
WID_TN_ZOOM_OUT
@ WID_TN_ZOOM_OUT
Zoom out the main viewport.
Definition: toolbar_widget.h:36
help_gui.h
console_gui.h
MenuClickShowTrains
static CallBackFunction MenuClickShowTrains(int index)
Handle click on the entry in the Train menu.
Definition: toolbar_gui.cpp:757
gui.h
WID_TN_SMALL_MAP
@ WID_TN_SMALL_MAP
Small map menu.
Definition: toolbar_widget.h:19
MenuClickStations
static CallBackFunction MenuClickStations(int index)
Handle click on the entry in the Stations menu.
Definition: toolbar_gui.cpp:509
HandleZoomMessage
void HandleZoomMessage(Window *w, const Viewport *vp, WidgetID widget_zoom_in, WidgetID widget_zoom_out)
Update the status of the zoom-buttons according to the zoom-level of the viewport.
Definition: viewport.cpp:491
ScenarioEditorToolbarWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: toolbar_gui.cpp:2445
Window
Data structure for an opened window.
Definition: window_gui.h:267
NWidgetToolbarContainer::spacers
uint spacers
Number of spacer widgets in this toolbar.
Definition: toolbar_gui.cpp:1334
GetRoadTypes
RoadTypes GetRoadTypes(bool introduces)
Get list of road types, regardless of company availability.
Definition: road.cpp:227
SizingType
SizingType
Different forms of sizing nested widgets, using NWidgetBase::AssignSizePosition()
Definition: widget_type.h:117
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:324
ToggleWidgetOutlines
void ToggleWidgetOutlines()
Toggle drawing of widget outlihes.
Definition: toolbar_gui.cpp:1094
NWidgetMainToolbarContainer::GetButtonArrangement
const WidgetID * 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:1471
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:3435
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:731
Clamp
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:79
WID_TN_STORY
@ WID_TN_STORY
Story menu.
Definition: toolbar_widget.h:25
WID_TN_LANDSCAPE
@ WID_TN_LANDSCAPE
Landscaping toolbar.
Definition: toolbar_widget.h:43
IConsoleSwitch
void IConsoleSwitch()
Toggle in-game console between opened and closed.
Definition: console_gui.cpp:377
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1162
Window::RaiseWidgetWhenLowered
void RaiseWidgetWhenLowered(byte widget_index)
Marks a widget as raised and dirty (redraw), when it is marked as lowered.
Definition: window_gui.h:478
NWidgetCore
Base class for a 'real' widget.
Definition: widget_type.h:356
story_base.h
WKC_MINUS
@ WKC_MINUS
Definition: gfx_type.h:104
ShowAIConfigWindow
void ShowAIConfigWindow()
Open the AI config window.
Definition: ai_gui.cpp:324
ShowCompany
void ShowCompany(CompanyID company)
Show the window with the overview of the company.
Definition: company_gui.cpp:2640
GUISettings::UserIsAllowedToChangeNewGRFs
bool UserIsAllowedToChangeNewGRFs() const
Returns true when the user has sufficient privileges to edit newgrfs on a running game.
Definition: settings_type.h:229
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition: vehicle_type.h:26
ToolbarMode
ToolbarMode
Toobar modes.
Definition: toolbar_gui.cpp:77
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:75
Window::ToggleWidgetLoweredState
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
Definition: window_gui.h:450
ScenarioEditorToolbarWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: toolbar_gui.cpp:2420
Company
Definition: company_base.h:116
WID_TE_ROADS
@ WID_TE_ROADS
Road building menu.
Definition: toolbar_widget.h:67
NWidgetBase::resize_x
uint resize_x
Horizontal resize step (0 means not resizable).
Definition: widget_type.h:225
WC_MAIN_TOOLBAR
@ WC_MAIN_TOOLBAR
Main toolbar (the long bar at the top); Window numbers:
Definition: window_type.h:58
Window::SetWidgetsDisabledState
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
Definition: window_gui.h:515
ScenarioEditorToolbarWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: toolbar_gui.cpp:2304
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:51
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:233
WID_TN_LEAGUE
@ WID_TN_LEAGUE
Company league menu.
Definition: toolbar_widget.h:28
CLIENT_ID_SERVER
@ CLIENT_ID_SERVER
Servers always have this ID.
Definition: network_type.h:51
WID_TN_WATER
@ WID_TN_WATER
Water building toolbar.
Definition: toolbar_widget.h:41
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3483
WID_TE_SMALL_MAP
@ WID_TE_SMALL_MAP
Small map menu.
Definition: toolbar_widget.h:61
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition: gfx.cpp:41
network_func.h
WID_TN_GRAPHS
@ WID_TN_GRAPHS
Graph menu.
Definition: toolbar_widget.h:27
SetTextStyle
constexpr NWidgetPart SetTextStyle(TextColour colour, FontSize size=FS_NORMAL)
Widget part function for setting the text style.
Definition: widget_type.h:1120
CS_NUMERAL
@ CS_NUMERAL
Only numeric ones.
Definition: string_type.h:26
ToggleBit
constexpr T ToggleBit(T &x, const uint8_t y)
Toggles a bit in a variable.
Definition: bitmath_func.hpp:181
GetStringBoundingBox
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:852
NWidgetToolbarContainer::GetButtonArrangement
virtual const WidgetID * 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_AIRCRAFT
@ WID_TN_AIRCRAFT
Aircraft menu.
Definition: toolbar_widget.h:34
MenuClickForest
static CallBackFunction MenuClickForest(int index)
Handle click on the entry in the landscaping menu.
Definition: toolbar_gui.cpp:974
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:636
MenuClickBuildRoad
static CallBackFunction MenuClickBuildRoad(int index)
Handle click on the entry in the Build Road menu.
Definition: toolbar_gui.cpp:882
LTMN_HIGHSCORE
static const int LTMN_HIGHSCORE
Show highscrore table.
Definition: toolbar_gui.cpp:625
MainToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: toolbar_gui.cpp:2056
WID_TE_TRAMS
@ WID_TE_TRAMS
Tram building menu.
Definition: toolbar_widget.h:68
LTMN_PERFORMANCE_LEAGUE
static const int LTMN_PERFORMANCE_LEAGUE
Show default league table.
Definition: toolbar_gui.cpp:623
ShowEditorTerraformToolbar
Window * ShowEditorTerraformToolbar()
Show the toolbar for terraforming in the scenario editor.
Definition: terraform_gui.cpp:750
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:21
ShowBuildDocksToolbar
Window * ShowBuildDocksToolbar()
Open the build water toolbar window.
Definition: dock_gui.cpp:362
Window::FindWindowPlacementAndResize
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
Resize window towards the default size.
Definition: window.cpp:1421
hotkeys.h
cheat_func.h
WID_TN_TOWNS
@ WID_TN_TOWNS
Town menu.
Definition: toolbar_widget.h:20
ShowBuildRoadScenToolbar
Window * ShowBuildRoadScenToolbar(RoadType roadtype)
Show the road building toolbar in the scenario editor.
Definition: road_gui.cpp:997
TimerGameEconomy::date
static Date date
Current date in days (day counter).
Definition: timer_game_economy.h:37
HasBit
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103