OpenTTD Source  13.2.1
toolbar_gui.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "stdafx.h"
11 #include "gui.h"
12 #include "window_gui.h"
13 #include "window_func.h"
14 #include "viewport_func.h"
15 #include "command_func.h"
16 #include "vehicle_gui.h"
17 #include "rail_gui.h"
18 #include "road.h"
19 #include "road_gui.h"
20 #include "date_func.h"
21 #include "vehicle_func.h"
22 #include "sound_func.h"
23 #include "terraform_gui.h"
24 #include "strings_func.h"
25 #include "company_func.h"
26 #include "company_gui.h"
27 #include "vehicle_base.h"
28 #include "cheat_func.h"
29 #include "transparency_gui.h"
30 #include "screenshot.h"
31 #include "signs_func.h"
32 #include "fios.h"
33 #include "console_gui.h"
34 #include "news_gui.h"
35 #include "ai/ai_gui.hpp"
36 #include "game/game_gui.hpp"
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 "guitimer_func.h"
52 #include "screenshot_gui.h"
53 #include "misc_cmd.h"
54 #include "league_gui.h"
55 #include "league_base.h"
56 
57 #include "widgets/toolbar_widget.h"
58 
59 #include "network/network.h"
60 #include "network/network_gui.h"
61 #include "network/network_func.h"
62 
63 #include "safeguards.h"
64 
65 
67 uint _toolbar_width = 0;
68 
69 RailType _last_built_railtype;
70 RoadType _last_built_roadtype;
71 RoadType _last_built_tramtype;
72 
75  TB_NORMAL,
76  TB_UPPER,
77  TB_LOWER
78 };
79 
82  CBF_NONE,
83  CBF_PLACE_SIGN,
84  CBF_PLACE_LANDINFO,
85 };
86 
88 
89 
94  uint checkmark_width;
95 public:
96  bool checked;
97 
98  DropDownListCheckedItem(StringID string, int result, bool masked, bool checked) : DropDownListStringItem(string, result, masked), checked(checked)
99  {
100  this->checkmark_width = GetStringBoundingBox(STR_JUST_CHECKMARK).width + WidgetDimensions::scaled.hsep_wide;
101  }
102 
103  uint Width() const override
104  {
105  return DropDownListStringItem::Width() + this->checkmark_width;
106  }
107 
108  void Draw(const Rect &r, bool sel, Colours bg_colour) const override
109  {
110  bool rtl = _current_text_dir == TD_RTL;
111  Rect tr = r.Shrink(WidgetDimensions::scaled.dropdowntext, RectPadding::zero);
112  if (this->checked) {
113  DrawString(tr, STR_JUST_CHECKMARK, sel ? TC_WHITE : TC_BLACK);
114  }
115  DrawString(tr.Indent(this->checkmark_width, rtl), this->String(), sel ? TC_WHITE : TC_BLACK);
116  }
117 };
118 
123  Dimension icon_size;
124  Dimension lock_size;
125 public:
126  bool greyed;
127 
128  DropDownListCompanyItem(int result, bool masked, bool greyed) : DropDownListItem(result, masked), greyed(greyed)
129  {
130  this->icon_size = GetSpriteSize(SPR_COMPANY_ICON);
131  this->lock_size = GetSpriteSize(SPR_LOCK);
132  }
133 
134  bool Selectable() const override
135  {
136  return true;
137  }
138 
139  uint Width() const override
140  {
141  CompanyID company = (CompanyID)this->result;
142  SetDParam(0, company);
143  SetDParam(1, company);
144  return GetStringBoundingBox(STR_COMPANY_NAME_COMPANY_NUM).width + this->icon_size.width + this->lock_size.width + WidgetDimensions::scaled.dropdowntext.Horizontal() + WidgetDimensions::scaled.hsep_wide;
145  }
146 
147  uint Height(uint width) const override
148  {
149  return std::max(std::max(this->icon_size.height, this->lock_size.height) + WidgetDimensions::scaled.imgbtn.Vertical(), (uint)FONT_HEIGHT_NORMAL);
150  }
151 
152  void Draw(const Rect &r, bool sel, Colours bg_colour) const override
153  {
154  CompanyID company = (CompanyID)this->result;
155  bool rtl = _current_text_dir == TD_RTL;
156 
157  /* It's possible the company is deleted while the dropdown is open */
158  if (!Company::IsValidID(company)) return;
159 
160  Rect tr = r.Shrink(WidgetDimensions::scaled.dropdowntext, RectPadding::zero);
161  int icon_y = CenterBounds(r.top, r.bottom, icon_size.height);
162  int text_y = CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL);
163  int lock_y = CenterBounds(r.top, r.bottom, lock_size.height);
164 
165  DrawCompanyIcon(company, tr.WithWidth(this->icon_size.width, rtl).left, icon_y);
166  if (NetworkCompanyIsPassworded(company)) {
167  DrawSprite(SPR_LOCK, PAL_NONE, tr.WithWidth(this->lock_size.width, !rtl).left, lock_y);
168  }
169 
170  SetDParam(0, company);
171  SetDParam(1, company);
172  TextColour col;
173  if (this->greyed) {
174  col = (sel ? TC_SILVER : TC_GREY) | TC_NO_SHADE;
175  } else {
176  col = sel ? TC_WHITE : TC_BLACK;
177  }
178  tr = tr.Indent(this->icon_size.width + WidgetDimensions::scaled.hsep_normal, rtl).Indent(this->lock_size.width + WidgetDimensions::scaled.hsep_normal, !rtl);
179  DrawString(tr.left, tr.right, text_y, STR_COMPANY_NAME_COMPANY_NUM, col);
180  }
181 };
182 
190 static void PopupMainToolbMenu(Window *w, int widget, DropDownList &&list, int def)
191 {
192  ShowDropDownList(w, std::move(list), def, widget, 0, true, true);
194 }
195 
203 static void PopupMainToolbMenu(Window *w, int widget, StringID string, int count)
204 {
205  DropDownList list;
206  for (int i = 0; i < count; i++) {
207  list.emplace_back(new DropDownListStringItem(string + i, i, false));
208  }
209  PopupMainToolbMenu(w, widget, std::move(list), 0);
210 }
211 
213 static const int CTMN_CLIENT_LIST = -1;
214 static const int CTMN_SPECTATE = -2;
215 static const int CTMN_SPECTATOR = -3;
216 
223 static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0)
224 {
225  DropDownList list;
226 
227  switch (widget) {
228  case WID_TN_COMPANIES:
229  if (!_networking) break;
230 
231  /* Add the client list button for the companies menu */
232  list.emplace_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, CTMN_CLIENT_LIST, false));
233 
235  list.emplace_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, false));
236  }
237  break;
238  case WID_TN_STORY:
239  list.emplace_back(new DropDownListStringItem(STR_STORY_BOOK_SPECTATOR, CTMN_SPECTATOR, false));
240  break;
241 
242  case WID_TN_GOAL:
243  list.emplace_back(new DropDownListStringItem(STR_GOALS_SPECTATOR, CTMN_SPECTATOR, false));
244  break;
245  }
246 
247  for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
248  if (!Company::IsValidID(c)) continue;
249  list.emplace_back(new DropDownListCompanyItem(c, false, HasBit(grey, c)));
250  }
251 
253 }
254 
255 static ToolbarMode _toolbar_mode;
256 
257 static CallBackFunction SelectSignTool()
258 {
259  if (_last_started_action == CBF_PLACE_SIGN) {
261  return CBF_NONE;
262  } else {
263  SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, HT_RECT, WC_MAIN_TOOLBAR, 0);
264  return CBF_PLACE_SIGN;
265  }
266 }
267 
268 /* --- Pausing --- */
269 
270 static CallBackFunction ToolbarPauseClick(Window *w)
271 {
272  if (_networking && !_network_server) return CBF_NONE; // only server can pause the game
273 
275  if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP);
276  }
277  return CBF_NONE;
278 }
279 
287 {
288  ChangeGameSpeed(_game_speed == 100);
289 
291  return CBF_NONE;
292 }
293 
298  OME_GAMEOPTIONS,
299  OME_SETTINGS,
300  OME_AI_SETTINGS,
301  OME_GAMESCRIPT_SETTINGS,
302  OME_NEWGRFSETTINGS,
303  OME_TRANSPARENCIES,
304  OME_SHOW_TOWNNAMES,
305  OME_SHOW_STATIONNAMES,
306  OME_SHOW_WAYPOINTNAMES,
307  OME_SHOW_SIGNS,
308  OME_SHOW_COMPETITOR_SIGNS,
309  OME_FULL_ANIMATION,
310  OME_FULL_DETAILS,
311  OME_TRANSPARENTBUILDINGS,
312  OME_SHOW_STATIONSIGNS,
313 };
314 
322 {
323  DropDownList list;
324  list.emplace_back(new DropDownListStringItem(STR_SETTINGS_MENU_GAME_OPTIONS, OME_GAMEOPTIONS, false));
325  list.emplace_back(new DropDownListStringItem(STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE, OME_SETTINGS, false));
326  /* Changes to the per-AI settings don't get send from the server to the clients. Clients get
327  * the settings once they join but never update it. As such don't show the window at all
328  * to network clients. */
329  if (!_networking || _network_server) {
330  list.emplace_back(new DropDownListStringItem(STR_SETTINGS_MENU_AI_SETTINGS, OME_AI_SETTINGS, false));
331  list.emplace_back(new DropDownListStringItem(STR_SETTINGS_MENU_GAMESCRIPT_SETTINGS, OME_GAMESCRIPT_SETTINGS, false));
332  }
333  list.emplace_back(new DropDownListStringItem(STR_SETTINGS_MENU_NEWGRF_SETTINGS, OME_NEWGRFSETTINGS, false));
334  list.emplace_back(new DropDownListStringItem(STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS, OME_TRANSPARENCIES, false));
335  list.emplace_back(new DropDownListItem(-1, false));
336  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED, OME_SHOW_TOWNNAMES, false, HasBit(_display_opt, DO_SHOW_TOWN_NAMES)));
337  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_STATION_NAMES_DISPLAYED, OME_SHOW_STATIONNAMES, false, HasBit(_display_opt, DO_SHOW_STATION_NAMES)));
338  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_WAYPOINTS_DISPLAYED, OME_SHOW_WAYPOINTNAMES, false, HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES)));
339  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_SIGNS_DISPLAYED, OME_SHOW_SIGNS, false, HasBit(_display_opt, DO_SHOW_SIGNS)));
340  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_SHOW_COMPETITOR_SIGNS, OME_SHOW_COMPETITOR_SIGNS, false, HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS)));
341  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_ANIMATION, OME_FULL_ANIMATION, false, HasBit(_display_opt, DO_FULL_ANIMATION)));
342  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_DETAIL, OME_FULL_DETAILS, false, HasBit(_display_opt, DO_FULL_DETAIL)));
343  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS, false, IsTransparencySet(TO_HOUSES)));
344  list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS, false, IsTransparencySet(TO_SIGNS)));
345 
346  ShowDropDownList(w, std::move(list), 0, WID_TN_SETTINGS, 140, true, true);
348  return CBF_NONE;
349 }
350 
358 {
359  switch (index) {
360  case OME_GAMEOPTIONS: ShowGameOptions(); return CBF_NONE;
361  case OME_SETTINGS: ShowGameSettings(); return CBF_NONE;
362  case OME_AI_SETTINGS: ShowAIConfigWindow(); return CBF_NONE;
363  case OME_GAMESCRIPT_SETTINGS: ShowGSConfigWindow(); return CBF_NONE;
364  case OME_NEWGRFSETTINGS: ShowNewGRFSettings(!_networking && _settings_client.gui.UserIsAllowedToChangeNewGRFs(), true, true, &_grfconfig); return CBF_NONE;
365  case OME_TRANSPARENCIES: ShowTransparencyToolbar(); break;
366 
367  case OME_SHOW_TOWNNAMES: ToggleBit(_display_opt, DO_SHOW_TOWN_NAMES); break;
368  case OME_SHOW_STATIONNAMES: ToggleBit(_display_opt, DO_SHOW_STATION_NAMES); break;
369  case OME_SHOW_WAYPOINTNAMES: ToggleBit(_display_opt, DO_SHOW_WAYPOINT_NAMES); break;
370  case OME_SHOW_SIGNS: ToggleBit(_display_opt, DO_SHOW_SIGNS); break;
371  case OME_SHOW_COMPETITOR_SIGNS:
374  break;
375  case OME_FULL_ANIMATION: ToggleBit(_display_opt, DO_FULL_ANIMATION); CheckBlitter(); break;
376  case OME_FULL_DETAILS: ToggleBit(_display_opt, DO_FULL_DETAIL); break;
377  case OME_TRANSPARENTBUILDINGS: ToggleTransparency(TO_HOUSES); break;
378  case OME_SHOW_STATIONSIGNS: ToggleTransparency(TO_SIGNS); break;
379  }
381  return CBF_NONE;
382 }
383 
388  SLEME_SAVE_SCENARIO = 0,
389  SLEME_LOAD_SCENARIO,
390  SLEME_SAVE_HEIGHTMAP,
391  SLEME_LOAD_HEIGHTMAP,
392  SLEME_EXIT_TOINTRO,
393  SLEME_EXIT_GAME = 6,
394  SLEME_MENUCOUNT,
395 };
396 
401  SLNME_SAVE_GAME = 0,
402  SLNME_LOAD_GAME,
403  SLNME_EXIT_TOINTRO,
404  SLNME_EXIT_GAME = 4,
405  SLNME_MENUCOUNT,
406 };
407 
415 {
416  PopupMainToolbMenu(w, WID_TN_SAVE, STR_FILE_MENU_SAVE_GAME, SLNME_MENUCOUNT);
417  return CBF_NONE;
418 }
419 
427 {
428  PopupMainToolbMenu(w, WID_TE_SAVE, STR_SCENEDIT_FILE_MENU_SAVE_SCENARIO, SLEME_MENUCOUNT);
429  return CBF_NONE;
430 }
431 
438 static CallBackFunction MenuClickSaveLoad(int index = 0)
439 {
440  if (_game_mode == GM_EDITOR) {
441  switch (index) {
442  case SLEME_SAVE_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_SAVE); break;
443  case SLEME_LOAD_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_LOAD); break;
444  case SLEME_SAVE_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,SLO_SAVE); break;
445  case SLEME_LOAD_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,SLO_LOAD); break;
446  case SLEME_EXIT_TOINTRO: AskExitToGameMenu(); break;
447  case SLEME_EXIT_GAME: HandleExitGameRequest(); break;
448  }
449  } else {
450  switch (index) {
451  case SLNME_SAVE_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_SAVE); break;
452  case SLNME_LOAD_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break;
453  case SLNME_EXIT_TOINTRO: AskExitToGameMenu(); break;
454  case SLNME_EXIT_GAME: HandleExitGameRequest(); break;
455  }
456  }
457  return CBF_NONE;
458 }
459 
460 /* --- Map button menu --- */
461 
462 enum MapMenuEntries {
463  MME_SHOW_SMALLMAP = 0,
464  MME_SHOW_EXTRAVIEWPORTS,
465  MME_SHOW_LINKGRAPH,
466  MME_SHOW_SIGNLISTS,
467  MME_SHOW_TOWNDIRECTORY,
468  MME_SHOW_INDUSTRYDIRECTORY,
469 };
470 
471 static CallBackFunction ToolbarMapClick(Window *w)
472 {
473  DropDownList list;
474  list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP, false));
475  list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS, false));
476  list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_LINGRAPH_LEGEND, MME_SHOW_LINKGRAPH, false));
477  list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false));
478  PopupMainToolbMenu(w, WID_TN_SMALL_MAP, std::move(list), 0);
479  return CBF_NONE;
480 }
481 
482 static CallBackFunction ToolbarScenMapTownDir(Window *w)
483 {
484  DropDownList list;
485  list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP, false));
486  list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS, false));
487  list.emplace_back(new DropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false));
488  list.emplace_back(new DropDownListStringItem(STR_TOWN_MENU_TOWN_DIRECTORY, MME_SHOW_TOWNDIRECTORY, false));
489  list.emplace_back(new DropDownListStringItem(STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, MME_SHOW_INDUSTRYDIRECTORY, false));
490  PopupMainToolbMenu(w, WID_TE_SMALL_MAP, std::move(list), 0);
491  return CBF_NONE;
492 }
493 
501 {
502  switch (index) {
503  case MME_SHOW_SMALLMAP: ShowSmallMap(); break;
504  case MME_SHOW_EXTRAVIEWPORTS: ShowExtraViewportWindow(); break;
505  case MME_SHOW_LINKGRAPH: ShowLinkGraphLegend(); break;
506  case MME_SHOW_SIGNLISTS: ShowSignList(); break;
507  case MME_SHOW_TOWNDIRECTORY: ShowTownDirectory(); break;
508  case MME_SHOW_INDUSTRYDIRECTORY: ShowIndustryDirectory(); break;
509  }
510  return CBF_NONE;
511 }
512 
513 /* --- Town button menu --- */
514 
515 static CallBackFunction ToolbarTownClick(Window *w)
516 {
517  PopupMainToolbMenu(w, WID_TN_TOWNS, STR_TOWN_MENU_TOWN_DIRECTORY, (_settings_game.economy.found_town == TF_FORBIDDEN) ? 1 : 2);
518  return CBF_NONE;
519 }
520 
528 {
529  switch (index) {
530  case 0: ShowTownDirectory(); break;
531  case 1: // setting could be changed when the dropdown was open
532  if (_settings_game.economy.found_town != TF_FORBIDDEN) ShowFoundTownWindow();
533  break;
534  }
535  return CBF_NONE;
536 }
537 
538 /* --- Subidies button menu --- */
539 
540 static CallBackFunction ToolbarSubsidiesClick(Window *w)
541 {
542  PopupMainToolbMenu(w, WID_TN_SUBSIDIES, STR_SUBSIDIES_MENU_SUBSIDIES, 1);
543  return CBF_NONE;
544 }
545 
553 {
554  switch (index) {
555  case 0: ShowSubsidiesList(); break;
556  }
557  return CBF_NONE;
558 }
559 
560 /* --- Stations button menu --- */
561 
562 static CallBackFunction ToolbarStationsClick(Window *w)
563 {
565  return CBF_NONE;
566 }
567 
575 {
577  return CBF_NONE;
578 }
579 
580 /* --- Finances button menu --- */
581 
582 static CallBackFunction ToolbarFinancesClick(Window *w)
583 {
585  return CBF_NONE;
586 }
587 
595 {
597  return CBF_NONE;
598 }
599 
600 /* --- Company's button menu --- */
601 
602 static CallBackFunction ToolbarCompaniesClick(Window *w)
603 {
605  return CBF_NONE;
606 }
607 
615 {
616  if (_networking) {
617  switch (index) {
618  case CTMN_CLIENT_LIST:
619  ShowClientList();
620  return CBF_NONE;
621 
622  case CTMN_SPECTATE:
623  if (_network_server) {
626  } else {
628  }
629  return CBF_NONE;
630  }
631  }
632  ShowCompany((CompanyID)index);
633  return CBF_NONE;
634 }
635 
636 /* --- Story button menu --- */
637 
638 static CallBackFunction ToolbarStoryClick(Window *w)
639 {
641  return CBF_NONE;
642 }
643 
651 {
653  return CBF_NONE;
654 }
655 
656 /* --- Goal button menu --- */
657 
658 static CallBackFunction ToolbarGoalClick(Window *w)
659 {
661  return CBF_NONE;
662 }
663 
671 {
673  return CBF_NONE;
674 }
675 
676 /* --- Graphs and League Table button menu --- */
677 
682 static const int GRMN_OPERATING_PROFIT_GRAPH = -1;
683 static const int GRMN_INCOME_GRAPH = -2;
684 static const int GRMN_DELIVERED_CARGO_GRAPH = -3;
685 static const int GRMN_PERFORMANCE_HISTORY_GRAPH = -4;
686 static const int GRMN_COMPANY_VALUE_GRAPH = -5;
687 static const int GRMN_CARGO_PAYMENT_RATES = -6;
688 static const int LTMN_PERFORMANCE_LEAGUE = -7;
689 static const int LTMN_PERFORMANCE_RATING = -8;
690 static const int LTMN_HIGHSCORE = -9;
691 
692 static void AddDropDownLeagueTableOptions(DropDownList &list) {
693  if (LeagueTable::GetNumItems() > 0) {
694  for (LeagueTable *lt : LeagueTable::Iterate()) {
695  list.emplace_back(new DropDownListCharStringItem(lt->title, lt->index, false));
696  }
697  } else {
698  list.emplace_back(new DropDownListStringItem(STR_GRAPH_MENU_COMPANY_LEAGUE_TABLE, LTMN_PERFORMANCE_LEAGUE, false));
699  list.emplace_back(new DropDownListStringItem(STR_GRAPH_MENU_DETAILED_PERFORMANCE_RATING, LTMN_PERFORMANCE_RATING, false));
700  if (!_networking) {
701  list.emplace_back(new DropDownListStringItem(STR_GRAPH_MENU_HIGHSCORE, LTMN_HIGHSCORE, false));
702  }
703  }
704 }
705 
706 static CallBackFunction ToolbarGraphsClick(Window *w)
707 {
708  DropDownList list;
709 
710  list.emplace_back(new DropDownListStringItem(STR_GRAPH_MENU_OPERATING_PROFIT_GRAPH, GRMN_OPERATING_PROFIT_GRAPH, false));
711  list.emplace_back(new DropDownListStringItem(STR_GRAPH_MENU_INCOME_GRAPH, GRMN_INCOME_GRAPH, false));
712  list.emplace_back(new DropDownListStringItem(STR_GRAPH_MENU_DELIVERED_CARGO_GRAPH, GRMN_DELIVERED_CARGO_GRAPH, false));
713  list.emplace_back(new DropDownListStringItem(STR_GRAPH_MENU_PERFORMANCE_HISTORY_GRAPH, GRMN_PERFORMANCE_HISTORY_GRAPH, false));
714  list.emplace_back(new DropDownListStringItem(STR_GRAPH_MENU_COMPANY_VALUE_GRAPH, GRMN_COMPANY_VALUE_GRAPH, false));
715  list.emplace_back(new DropDownListStringItem(STR_GRAPH_MENU_CARGO_PAYMENT_RATES, GRMN_CARGO_PAYMENT_RATES, false));
716 
717  if (_toolbar_mode != TB_NORMAL) AddDropDownLeagueTableOptions(list);
718 
719  ShowDropDownList(w, std::move(list), GRMN_OPERATING_PROFIT_GRAPH, WID_TN_GRAPHS, 140, true, true);
721 
722  return CBF_NONE;
723 }
724 
725 static CallBackFunction ToolbarLeagueClick(Window *w)
726 {
727  DropDownList list;
728 
729  AddDropDownLeagueTableOptions(list);
730 
731  int selected = list[0]->result;
732  ShowDropDownList(w, std::move(list), selected, WID_TN_LEAGUE, 140, true, true);
734 
735  return CBF_NONE;
736 }
737 
745 {
746  switch (index) {
747  case GRMN_OPERATING_PROFIT_GRAPH: ShowOperatingProfitGraph(); break;
748  case GRMN_INCOME_GRAPH: ShowIncomeGraph(); break;
749  case GRMN_DELIVERED_CARGO_GRAPH: ShowDeliveredCargoGraph(); break;
750  case GRMN_PERFORMANCE_HISTORY_GRAPH: ShowPerformanceHistoryGraph(); break;
751  case GRMN_COMPANY_VALUE_GRAPH: ShowCompanyValueGraph(); break;
752  case GRMN_CARGO_PAYMENT_RATES: ShowCargoPaymentRates(); break;
753  case LTMN_PERFORMANCE_LEAGUE: ShowPerformanceLeagueTable(); break;
754  case LTMN_PERFORMANCE_RATING: ShowPerformanceRatingDetail(); break;
755  case LTMN_HIGHSCORE: ShowHighscoreTable(); break;
756  default: {
757  if (LeagueTable::IsValidID(index)) {
758  ShowScriptLeagueTable((LeagueTableID)index);
759  }
760  }
761  }
762  return CBF_NONE;
763 }
764 
765 
766 
767 /* --- Industries button menu --- */
768 
769 static CallBackFunction ToolbarIndustryClick(Window *w)
770 {
771  /* Disable build-industry menu if we are a spectator */
772  PopupMainToolbMenu(w, WID_TN_INDUSTRIES, STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, (_local_company == COMPANY_SPECTATOR) ? 2 : 3);
773  return CBF_NONE;
774 }
775 
783 {
784  switch (index) {
785  case 0: ShowIndustryDirectory(); break;
786  case 1: ShowIndustryCargoesWindow(); break;
787  case 2: ShowBuildIndustryWindow(); break;
788  }
789  return CBF_NONE;
790 }
791 
792 /* --- Trains button menu + 1 helper function for all vehicles. --- */
793 
794 static void ToolbarVehicleClick(Window *w, VehicleType veh)
795 {
796  int dis = ~0;
797 
798  for (const Vehicle *v : Vehicle::Iterate()) {
799  if (v->type == veh && v->IsPrimaryVehicle()) ClrBit(dis, v->owner);
800  }
802 }
803 
804 
805 static CallBackFunction ToolbarTrainClick(Window *w)
806 {
807  ToolbarVehicleClick(w, VEH_TRAIN);
808  return CBF_NONE;
809 }
810 
818 {
819  ShowVehicleListWindow((CompanyID)index, VEH_TRAIN);
820  return CBF_NONE;
821 }
822 
823 /* --- Road vehicle button menu --- */
824 
825 static CallBackFunction ToolbarRoadClick(Window *w)
826 {
827  ToolbarVehicleClick(w, VEH_ROAD);
828  return CBF_NONE;
829 }
830 
838 {
839  ShowVehicleListWindow((CompanyID)index, VEH_ROAD);
840  return CBF_NONE;
841 }
842 
843 /* --- Ship button menu --- */
844 
845 static CallBackFunction ToolbarShipClick(Window *w)
846 {
847  ToolbarVehicleClick(w, VEH_SHIP);
848  return CBF_NONE;
849 }
850 
858 {
859  ShowVehicleListWindow((CompanyID)index, VEH_SHIP);
860  return CBF_NONE;
861 }
862 
863 /* --- Aircraft button menu --- */
864 
865 static CallBackFunction ToolbarAirClick(Window *w)
866 {
867  ToolbarVehicleClick(w, VEH_AIRCRAFT);
868  return CBF_NONE;
869 }
870 
878 {
879  ShowVehicleListWindow((CompanyID)index, VEH_AIRCRAFT);
880  return CBF_NONE;
881 }
882 
883 /* --- Zoom in button --- */
884 
885 static CallBackFunction ToolbarZoomInClick(Window *w)
886 {
888  w->HandleButtonClick((_game_mode == GM_EDITOR) ? (byte)WID_TE_ZOOM_IN : (byte)WID_TN_ZOOM_IN);
890  }
891  return CBF_NONE;
892 }
893 
894 /* --- Zoom out button --- */
895 
896 static CallBackFunction ToolbarZoomOutClick(Window *w)
897 {
899  w->HandleButtonClick((_game_mode == GM_EDITOR) ? (byte)WID_TE_ZOOM_OUT : (byte)WID_TN_ZOOM_OUT);
901  }
902  return CBF_NONE;
903 }
904 
905 /* --- Rail button menu --- */
906 
907 static CallBackFunction ToolbarBuildRailClick(Window *w)
908 {
909  ShowDropDownList(w, GetRailTypeDropDownList(), _last_built_railtype, WID_TN_RAILS, 140, true, true);
911  return CBF_NONE;
912 }
913 
921 {
922  _last_built_railtype = (RailType)index;
923  ShowBuildRailToolbar(_last_built_railtype);
924  return CBF_NONE;
925 }
926 
927 /* --- Road button menu --- */
928 
929 static CallBackFunction ToolbarBuildRoadClick(Window *w)
930 {
931  ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TN_ROADS, 140, true, true);
933  return CBF_NONE;
934 }
935 
943 {
944  _last_built_roadtype = (RoadType)index;
945  ShowBuildRoadToolbar(_last_built_roadtype);
946  return CBF_NONE;
947 }
948 
949 /* --- Tram button menu --- */
950 
951 static CallBackFunction ToolbarBuildTramClick(Window *w)
952 {
953  ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TN_TRAMS, 140, true, true);
955  return CBF_NONE;
956 }
957 
965 {
966  _last_built_tramtype = (RoadType)index;
967  ShowBuildRoadToolbar(_last_built_tramtype);
968  return CBF_NONE;
969 }
970 
971 /* --- Water button menu --- */
972 
973 static CallBackFunction ToolbarBuildWaterClick(Window *w)
974 {
975  DropDownList list;
976  list.emplace_back(new DropDownListIconItem(SPR_IMG_BUILD_CANAL, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 0, false));
977  ShowDropDownList(w, std::move(list), 0, WID_TN_WATER, 140, true, true);
979  return CBF_NONE;
980 }
981 
989 {
991  return CBF_NONE;
992 }
993 
994 /* --- Airport button menu --- */
995 
996 static CallBackFunction ToolbarBuildAirClick(Window *w)
997 {
998  DropDownList list;
999  list.emplace_back(new DropDownListIconItem(SPR_IMG_AIRPORT, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 0, false));
1000  ShowDropDownList(w, std::move(list), 0, WID_TN_AIR, 140, true, true);
1001  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1002  return CBF_NONE;
1003 }
1004 
1012 {
1014  return CBF_NONE;
1015 }
1016 
1017 /* --- Forest button menu --- */
1018 
1019 static CallBackFunction ToolbarForestClick(Window *w)
1020 {
1021  DropDownList list;
1022  list.emplace_back(new DropDownListIconItem(SPR_IMG_LANDSCAPING, PAL_NONE, STR_LANDSCAPING_MENU_LANDSCAPING, 0, false));
1023  list.emplace_back(new DropDownListIconItem(SPR_IMG_PLANTTREES, PAL_NONE, STR_LANDSCAPING_MENU_PLANT_TREES, 1, false));
1024  list.emplace_back(new DropDownListIconItem(SPR_IMG_SIGN, PAL_NONE, STR_LANDSCAPING_MENU_PLACE_SIGN, 2, false));
1025  ShowDropDownList(w, std::move(list), 0, WID_TN_LANDSCAPE, 100, true, true);
1026  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1027  return CBF_NONE;
1028 }
1029 
1037 {
1038  switch (index) {
1039  case 0: ShowTerraformToolbar(); break;
1040  case 1: ShowBuildTreesToolbar(); break;
1041  case 2: return SelectSignTool();
1042  }
1043  return CBF_NONE;
1044 }
1045 
1046 /* --- Music button menu --- */
1047 
1048 static CallBackFunction ToolbarMusicClick(Window *w)
1049 {
1050  PopupMainToolbMenu(w, _game_mode == GM_EDITOR ? (int)WID_TE_MUSIC_SOUND : (int)WID_TN_MUSIC_SOUND, STR_TOOLBAR_SOUND_MUSIC, 1);
1051  return CBF_NONE;
1052 }
1053 
1061 {
1062  ShowMusicWindow();
1063  return CBF_NONE;
1064 }
1065 
1066 /* --- Newspaper button menu --- */
1067 
1068 static CallBackFunction ToolbarNewspaperClick(Window *w)
1069 {
1070  PopupMainToolbMenu(w, WID_TN_MESSAGES, STR_NEWS_MENU_LAST_MESSAGE_NEWS_REPORT, 3);
1071  return CBF_NONE;
1072 }
1073 
1081 {
1082  switch (index) {
1083  case 0: ShowLastNewsMessage(); break;
1084  case 1: ShowMessageHistory(); break;
1085  case 2: DeleteAllMessages(); break;
1086  }
1087  return CBF_NONE;
1088 }
1089 
1090 /* --- Help button menu --- */
1091 
1092 static CallBackFunction PlaceLandBlockInfo()
1093 {
1094  if (_last_started_action == CBF_PLACE_LANDINFO) {
1096  return CBF_NONE;
1097  } else {
1098  SetObjectToPlace(SPR_CURSOR_QUERY, PAL_NONE, HT_RECT, WC_MAIN_TOOLBAR, 0);
1099  return CBF_PLACE_LANDINFO;
1100  }
1101 }
1102 
1103 static CallBackFunction ToolbarHelpClick(Window *w)
1104 {
1105  PopupMainToolbMenu(w, _game_mode == GM_EDITOR ? (int)WID_TE_HELP : (int)WID_TN_HELP, STR_ABOUT_MENU_LAND_BLOCK_INFO, _settings_client.gui.newgrf_developer_tools ? 10 : 7);
1106  return CBF_NONE;
1107 }
1108 
1117 {
1118  extern bool _draw_bounding_boxes;
1119  /* Always allow to toggle them off */
1120  if (_settings_client.gui.newgrf_developer_tools || _draw_bounding_boxes) {
1121  _draw_bounding_boxes = !_draw_bounding_boxes;
1123  }
1124 }
1125 
1134 {
1135  extern bool _draw_dirty_blocks;
1136  /* Always allow to toggle them off */
1137  if (_settings_client.gui.newgrf_developer_tools || _draw_dirty_blocks) {
1138  _draw_dirty_blocks = !_draw_dirty_blocks;
1140  }
1141 }
1142 
1148 {
1151  /* If you open a savegame as scenario there may already be link graphs.*/
1153  SetDate(new_date, 0);
1154 }
1155 
1162 {
1163  switch (index) {
1164  case 0: return PlaceLandBlockInfo();
1165  case 2: IConsoleSwitch(); break;
1166  case 3: ShowAIDebugWindow(); break;
1167  case 4: ShowScreenshotWindow(); break;
1168  case 5: ShowFramerateWindow(); break;
1169  case 6: ShowAboutWindow(); break;
1170  case 7: ShowSpriteAlignerWindow(); break;
1171  case 8: ToggleBoundingBoxes(); break;
1172  case 9: ToggleDirtyBlocks(); break;
1173  }
1174  return CBF_NONE;
1175 }
1176 
1177 /* --- Switch toolbar button --- */
1178 
1179 static CallBackFunction ToolbarSwitchClick(Window *w)
1180 {
1181  if (_toolbar_mode != TB_LOWER) {
1182  _toolbar_mode = TB_LOWER;
1183  } else {
1184  _toolbar_mode = TB_UPPER;
1185  }
1186 
1187  w->ReInit();
1188  w->SetWidgetLoweredState(_game_mode == GM_EDITOR ? (uint)WID_TE_SWITCH_BAR : (uint)WID_TN_SWITCH_BAR, _toolbar_mode == TB_LOWER);
1189  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1190  return CBF_NONE;
1191 }
1192 
1193 /* --- Scenario editor specific handlers. */
1194 
1199 {
1201  ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, w, CS_NUMERAL, QSF_ENABLE_DEFAULT);
1202  return CBF_NONE;
1203 }
1204 
1205 static CallBackFunction ToolbarScenDateBackward(Window *w)
1206 {
1207  /* don't allow too fast scrolling */
1208  if (!(w->flags & WF_TIMEOUT) || w->timeout_timer <= 1) {
1210  w->SetDirty();
1211 
1213  }
1214  _left_button_clicked = false;
1215  return CBF_NONE;
1216 }
1217 
1218 static CallBackFunction ToolbarScenDateForward(Window *w)
1219 {
1220  /* don't allow too fast scrolling */
1221  if (!(w->flags & WF_TIMEOUT) || w->timeout_timer <= 1) {
1223  w->SetDirty();
1224 
1226  }
1227  _left_button_clicked = false;
1228  return CBF_NONE;
1229 }
1230 
1231 static CallBackFunction ToolbarScenGenLand(Window *w)
1232 {
1234  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1235 
1237  return CBF_NONE;
1238 }
1239 
1240 
1241 static CallBackFunction ToolbarScenGenTown(Window *w)
1242 {
1244  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1245  ShowFoundTownWindow();
1246  return CBF_NONE;
1247 }
1248 
1249 static CallBackFunction ToolbarScenGenIndustry(Window *w)
1250 {
1252  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1253  ShowBuildIndustryWindow();
1254  return CBF_NONE;
1255 }
1256 
1257 static CallBackFunction ToolbarScenBuildRoadClick(Window *w)
1258 {
1259  ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TE_ROADS, 140, true, true);
1260  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1261  return CBF_NONE;
1262 }
1263 
1271 {
1272  _last_built_roadtype = (RoadType)index;
1273  ShowBuildRoadScenToolbar(_last_built_roadtype);
1274  return CBF_NONE;
1275 }
1276 
1277 static CallBackFunction ToolbarScenBuildTramClick(Window *w)
1278 {
1279  ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TE_TRAMS, 140, true, true);
1280  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1281  return CBF_NONE;
1282 }
1283 
1291 {
1292  _last_built_tramtype = (RoadType)index;
1293  ShowBuildRoadScenToolbar(_last_built_tramtype);
1294  return CBF_NONE;
1295 }
1296 
1297 static CallBackFunction ToolbarScenBuildDocks(Window *w)
1298 {
1300  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1302  return CBF_NONE;
1303 }
1304 
1305 static CallBackFunction ToolbarScenPlantTrees(Window *w)
1306 {
1308  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1309  ShowBuildTreesToolbar();
1310  return CBF_NONE;
1311 }
1312 
1313 static CallBackFunction ToolbarScenPlaceSign(Window *w)
1314 {
1316  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1317  return SelectSignTool();
1318 }
1319 
1320 static CallBackFunction ToolbarBtn_NULL(Window *w)
1321 {
1322  return CBF_NONE;
1323 }
1324 
1325 typedef CallBackFunction MenuClickedProc(int index);
1326 
1327 static MenuClickedProc * const _menu_clicked_procs[] = {
1328  nullptr, // 0
1329  nullptr, // 1
1330  MenuClickSettings, // 2
1331  MenuClickSaveLoad, // 3
1332  MenuClickMap, // 4
1333  MenuClickTown, // 5
1334  MenuClickSubsidies, // 6
1335  MenuClickStations, // 7
1336  MenuClickFinances, // 8
1337  MenuClickCompany, // 9
1338  MenuClickStory, // 10
1339  MenuClickGoal, // 11
1342  MenuClickIndustry, // 14
1343  MenuClickShowTrains, // 15
1344  MenuClickShowRoad, // 16
1345  MenuClickShowShips, // 17
1346  MenuClickShowAir, // 18
1347  MenuClickMap, // 19
1348  nullptr, // 20
1349  MenuClickBuildRail, // 21
1350  MenuClickBuildRoad, // 22
1351  MenuClickBuildTram, // 23
1352  MenuClickBuildWater, // 24
1353  MenuClickBuildAir, // 25
1354  MenuClickForest, // 26
1355  MenuClickMusicWindow, // 27
1356  MenuClickNewspaper, // 28
1357  MenuClickHelp, // 29
1358 };
1359 
1363 protected:
1364  uint spacers;
1365 
1366 public:
1368  {
1369  }
1370 
1377  {
1378  return type == WWT_IMGBTN || type == WWT_IMGBTN_2 || type == WWT_PUSHIMGBTN;
1379  }
1380 
1381  void SetupSmallestSize(Window *w, bool init_array) override
1382  {
1383  this->smallest_x = 0; // Biggest child
1384  this->smallest_y = 0; // Biggest child
1385  this->fill_x = 1;
1386  this->fill_y = 0;
1387  this->resize_x = 1; // We only resize in this direction
1388  this->resize_y = 0; // We never resize in this direction
1389  this->spacers = 0;
1390 
1391  uint nbuttons = 0;
1392  /* First initialise some variables... */
1393  for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
1394  child_wid->SetupSmallestSize(w, init_array);
1395  this->smallest_y = std::max(this->smallest_y, child_wid->smallest_y + child_wid->padding.Vertical());
1396  if (this->IsButton(child_wid->type)) {
1397  nbuttons++;
1398  this->smallest_x = std::max(this->smallest_x, child_wid->smallest_x + child_wid->padding.Horizontal());
1399  } else if (child_wid->type == NWID_SPACER) {
1400  this->spacers++;
1401  }
1402  }
1403 
1404  /* ... then in a second pass make sure the 'current' heights are set. Won't change ever. */
1405  for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
1406  child_wid->current_y = this->smallest_y;
1407  if (!this->IsButton(child_wid->type)) {
1408  child_wid->current_x = child_wid->smallest_x;
1409  }
1410  }
1411  _toolbar_width = nbuttons * this->smallest_x;
1412  }
1413 
1414  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
1415  {
1416  assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
1417 
1418  this->pos_x = x;
1419  this->pos_y = y;
1420  this->current_x = given_width;
1421  this->current_y = given_height;
1422 
1423  /* Figure out what are the visible buttons */
1424  memset(this->visible, 0, sizeof(this->visible));
1425  uint arrangable_count, button_count, spacer_count;
1426  const byte *arrangement = GetButtonArrangement(given_width, arrangable_count, button_count, spacer_count);
1427  for (uint i = 0; i < arrangable_count; i++) {
1428  this->visible[arrangement[i]] = true;
1429  }
1430 
1431  /* Create us ourselves a quick lookup table */
1432  NWidgetBase *widgets[WID_TN_END];
1433  for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
1434  if (child_wid->type == NWID_SPACER) continue;
1435  widgets[((NWidgetCore*)child_wid)->index] = child_wid;
1436  }
1437 
1438  /* Now assign the widgets to their rightful place */
1439  uint position = 0; // Place to put next child relative to origin of the container.
1440  uint spacer_space = std::max(0, (int)given_width - (int)(button_count * this->smallest_x)); // Remaining spacing for 'spacer' widgets
1441  uint button_space = given_width - spacer_space; // Remaining spacing for the buttons
1442  uint spacer_i = 0;
1443  uint button_i = 0;
1444 
1445  /* Index into the arrangement indices. The macro lastof cannot be used here! */
1446  const byte *cur_wid = rtl ? &arrangement[arrangable_count - 1] : arrangement;
1447  for (uint i = 0; i < arrangable_count; i++) {
1448  NWidgetBase *child_wid = widgets[*cur_wid];
1449  /* If we have to give space to the spacers, do that */
1450  if (spacer_space != 0) {
1451  NWidgetBase *possible_spacer = rtl ? child_wid->next : child_wid->prev;
1452  if (possible_spacer != nullptr && possible_spacer->type == NWID_SPACER) {
1453  uint add = spacer_space / (spacer_count - spacer_i);
1454  position += add;
1455  spacer_space -= add;
1456  spacer_i++;
1457  }
1458  }
1459 
1460  /* Buttons can be scaled, the others not. */
1461  if (this->IsButton(child_wid->type)) {
1462  child_wid->current_x = button_space / (button_count - button_i);
1463  button_space -= child_wid->current_x;
1464  button_i++;
1465  }
1466  child_wid->AssignSizePosition(sizing, x + position, y, child_wid->current_x, this->current_y, rtl);
1467  position += child_wid->current_x;
1468 
1469  if (rtl) {
1470  cur_wid--;
1471  } else {
1472  cur_wid++;
1473  }
1474  }
1475  }
1476 
1477  void Draw(const Window *w) override
1478  {
1479  /* Draw brown-red toolbar bg. */
1480  GfxFillRect(this->pos_x, this->pos_y, this->pos_x + this->current_x - 1, this->pos_y + this->current_y - 1, PC_VERY_DARK_RED);
1481  GfxFillRect(this->pos_x, this->pos_y, this->pos_x + this->current_x - 1, this->pos_y + this->current_y - 1, PC_DARK_RED, FILLRECT_CHECKER);
1482 
1483  bool rtl = _current_text_dir == TD_RTL;
1484  for (NWidgetBase *child_wid = rtl ? this->tail : this->head; child_wid != nullptr; child_wid = rtl ? child_wid->prev : child_wid->next) {
1485  if (child_wid->type == NWID_SPACER) continue;
1486  if (!this->visible[((NWidgetCore*)child_wid)->index]) continue;
1487 
1488  child_wid->Draw(w);
1489  }
1490  }
1491 
1492  NWidgetCore *GetWidgetFromPos(int x, int y) override
1493  {
1494  if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return nullptr;
1495 
1496  for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
1497  if (child_wid->type == NWID_SPACER) continue;
1498  if (!this->visible[((NWidgetCore*)child_wid)->index]) continue;
1499 
1500  NWidgetCore *nwid = child_wid->GetWidgetFromPos(x, y);
1501  if (nwid != nullptr) return nwid;
1502  }
1503  return nullptr;
1504  }
1505 
1514  virtual const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const = 0;
1515 };
1516 
1519  const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override
1520  {
1521  static const uint SMALLEST_ARRANGEMENT = 14;
1522  static const uint BIGGEST_ARRANGEMENT = 20;
1523 
1524  /* The number of buttons of each row of the toolbar should match the number of items which we want to be visible.
1525  * The total number of buttons should be equal to arrangable_count * 2.
1526  * No bad things happen, but we could see strange behaviours if we have buttons < (arrangable_count * 2) like a
1527  * pause button appearing on the right of the lower toolbar and weird resizing of the widgets even if there is
1528  * enough space.
1529  */
1530  static const byte arrange14[] = {
1531  WID_TN_PAUSE,
1533  WID_TN_TRAINS,
1535  WID_TN_SHIPS,
1539  WID_TN_RAILS,
1540  WID_TN_ROADS,
1541  WID_TN_WATER,
1542  WID_TN_AIR,
1545  // lower toolbar
1547  WID_TN_SAVE,
1549  WID_TN_TOWNS,
1554  WID_TN_GRAPHS,
1558  WID_TN_HELP,
1560  };
1561  static const byte arrange15[] = {
1562  WID_TN_PAUSE,
1565  WID_TN_TRAINS,
1567  WID_TN_SHIPS,
1569  WID_TN_RAILS,
1570  WID_TN_ROADS,
1571  WID_TN_WATER,
1572  WID_TN_AIR,
1577  // lower toolbar
1578  WID_TN_PAUSE,
1581  WID_TN_SAVE,
1582  WID_TN_TOWNS,
1587  WID_TN_GRAPHS,
1591  WID_TN_HELP,
1593  };
1594  static const byte arrange16[] = {
1595  WID_TN_PAUSE,
1599  WID_TN_TRAINS,
1601  WID_TN_SHIPS,
1603  WID_TN_RAILS,
1604  WID_TN_ROADS,
1605  WID_TN_WATER,
1606  WID_TN_AIR,
1611  // lower toolbar
1612  WID_TN_PAUSE,
1614  WID_TN_SAVE,
1615  WID_TN_TOWNS,
1620  WID_TN_GRAPHS,
1624  WID_TN_HELP,
1628  };
1629  static const byte arrange17[] = {
1630  WID_TN_PAUSE,
1635  WID_TN_TRAINS,
1637  WID_TN_SHIPS,
1639  WID_TN_RAILS,
1640  WID_TN_ROADS,
1641  WID_TN_WATER,
1642  WID_TN_AIR,
1647  // lower toolbar
1648  WID_TN_PAUSE,
1650  WID_TN_SAVE,
1653  WID_TN_TOWNS,
1657  WID_TN_GRAPHS,
1661  WID_TN_HELP,
1665  };
1666  static const byte arrange18[] = {
1667  WID_TN_PAUSE,
1671  WID_TN_TOWNS,
1677  WID_TN_RAILS,
1678  WID_TN_ROADS,
1679  WID_TN_WATER,
1680  WID_TN_AIR,
1685  // lower toolbar
1686  WID_TN_PAUSE,
1688  WID_TN_SAVE,
1690  WID_TN_TOWNS,
1693  WID_TN_GRAPHS,
1694  WID_TN_TRAINS,
1696  WID_TN_SHIPS,
1700  WID_TN_HELP,
1704  };
1705  static const byte arrange19[] = {
1706  WID_TN_PAUSE,
1710  WID_TN_TOWNS,
1712  WID_TN_TRAINS,
1714  WID_TN_SHIPS,
1716  WID_TN_RAILS,
1717  WID_TN_ROADS,
1718  WID_TN_WATER,
1719  WID_TN_AIR,
1725  // lower toolbar
1726  WID_TN_PAUSE,
1728  WID_TN_SAVE,
1733  WID_TN_GRAPHS,
1736  WID_TN_RAILS,
1737  WID_TN_ROADS,
1738  WID_TN_WATER,
1739  WID_TN_AIR,
1741  WID_TN_HELP,
1745  };
1746  static const byte arrange20[] = {
1747  WID_TN_PAUSE,
1751  WID_TN_TOWNS,
1753  WID_TN_TRAINS,
1755  WID_TN_SHIPS,
1757  WID_TN_RAILS,
1758  WID_TN_ROADS,
1759  WID_TN_WATER,
1760  WID_TN_AIR,
1763  WID_TN_GOAL,
1767  // lower toolbar
1768  WID_TN_PAUSE,
1770  WID_TN_SAVE,
1775  WID_TN_GRAPHS,
1778  WID_TN_RAILS,
1779  WID_TN_ROADS,
1780  WID_TN_WATER,
1781  WID_TN_AIR,
1783  WID_TN_STORY,
1784  WID_TN_HELP,
1788  };
1789  static const byte arrange_all[] = {
1790  WID_TN_PAUSE,
1793  WID_TN_SAVE,
1795  WID_TN_TOWNS,
1800  WID_TN_STORY,
1801  WID_TN_GOAL,
1802  WID_TN_GRAPHS,
1803  WID_TN_LEAGUE,
1805  WID_TN_TRAINS,
1807  WID_TN_SHIPS,
1811  WID_TN_RAILS,
1812  WID_TN_ROADS,
1813  WID_TN_TRAMS,
1814  WID_TN_WATER,
1815  WID_TN_AIR,
1819  WID_TN_HELP
1820  };
1821 
1822  /* If at least BIGGEST_ARRANGEMENT fit, just spread all the buttons nicely */
1823  uint full_buttons = std::max(CeilDiv(width, this->smallest_x), SMALLEST_ARRANGEMENT);
1824  if (full_buttons > BIGGEST_ARRANGEMENT) {
1825  button_count = arrangable_count = lengthof(arrange_all);
1826  spacer_count = this->spacers;
1827  return arrange_all;
1828  }
1829 
1830  /* Introduce the split toolbar */
1831  static const byte * const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20 };
1832 
1833  button_count = arrangable_count = full_buttons;
1834  spacer_count = this->spacers;
1835  return arrangements[full_buttons - SMALLEST_ARRANGEMENT] + ((_toolbar_mode == TB_LOWER) ? full_buttons : 0);
1836  }
1837 };
1838 
1841  uint panel_widths[2];
1842 
1843  void SetupSmallestSize(Window *w, bool init_array) override
1844  {
1845  this->NWidgetToolbarContainer::SetupSmallestSize(w, init_array);
1846 
1847  /* Find the size of panel_widths */
1848  uint i = 0;
1849  for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
1850  if (child_wid->type == NWID_SPACER || this->IsButton(child_wid->type)) continue;
1851 
1852  assert(i < lengthof(this->panel_widths));
1853  this->panel_widths[i++] = child_wid->current_x;
1854  _toolbar_width += child_wid->current_x;
1855  }
1856  }
1857 
1858  const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override
1859  {
1860  static const byte arrange_all[] = {
1861  WID_TE_PAUSE,
1864  WID_TE_SAVE,
1865  WID_TE_SPACER,
1873  WID_TE_ROADS,
1874  WID_TE_TRAMS,
1875  WID_TE_WATER,
1876  WID_TE_TREES,
1877  WID_TE_SIGNS,
1879  WID_TE_HELP,
1880  };
1881  static const byte arrange_nopanel[] = {
1882  WID_TE_PAUSE,
1885  WID_TE_SAVE,
1893  WID_TE_ROADS,
1894  WID_TE_TRAMS,
1895  WID_TE_WATER,
1896  WID_TE_TREES,
1897  WID_TE_SIGNS,
1899  WID_TE_HELP,
1900  };
1901  static const byte arrange_switch[] = {
1907  WID_TE_ROADS,
1908  WID_TE_TRAMS,
1909  WID_TE_WATER,
1910  WID_TE_TREES,
1911  WID_TE_SIGNS,
1913  // lower toolbar
1914  WID_TE_PAUSE,
1917  WID_TE_SAVE,
1923  WID_TE_HELP,
1925  };
1926 
1927  /* If we can place all buttons *and* the panels, show them. */
1928  uint min_full_width = (lengthof(arrange_all) - lengthof(this->panel_widths)) * this->smallest_x + this->panel_widths[0] + this->panel_widths[1];
1929  if (width >= min_full_width) {
1930  width -= this->panel_widths[0] + this->panel_widths[1];
1931  arrangable_count = lengthof(arrange_all);
1932  button_count = arrangable_count - 2;
1933  spacer_count = this->spacers;
1934  return arrange_all;
1935  }
1936 
1937  /* 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 */
1938  uint min_small_width = (lengthof(arrange_switch) - lengthof(this->panel_widths)) * this->smallest_x / 2 + this->panel_widths[1];
1939  if (width > min_small_width) {
1940  width -= this->panel_widths[1];
1941  arrangable_count = lengthof(arrange_nopanel);
1942  button_count = arrangable_count - 1;
1943  spacer_count = this->spacers - 1;
1944  return arrange_nopanel;
1945  }
1946 
1947  /* Split toolbar */
1948  width -= this->panel_widths[1];
1949  arrangable_count = lengthof(arrange_switch) / 2;
1950  button_count = arrangable_count - 1;
1951  spacer_count = 0;
1952  return arrange_switch + ((_toolbar_mode == TB_LOWER) ? arrangable_count : 0);
1953  }
1954 };
1955 
1956 /* --- Toolbar handling for the 'normal' case */
1957 
1958 typedef CallBackFunction ToolbarButtonProc(Window *w);
1959 
1960 static ToolbarButtonProc * const _toolbar_button_procs[] = {
1961  ToolbarPauseClick,
1965  ToolbarMapClick,
1966  ToolbarTownClick,
1967  ToolbarSubsidiesClick,
1968  ToolbarStationsClick,
1969  ToolbarFinancesClick,
1970  ToolbarCompaniesClick,
1971  ToolbarStoryClick,
1972  ToolbarGoalClick,
1973  ToolbarGraphsClick,
1974  ToolbarLeagueClick,
1975  ToolbarIndustryClick,
1976  ToolbarTrainClick,
1977  ToolbarRoadClick,
1978  ToolbarShipClick,
1979  ToolbarAirClick,
1980  ToolbarZoomInClick,
1981  ToolbarZoomOutClick,
1982  ToolbarBuildRailClick,
1983  ToolbarBuildRoadClick,
1984  ToolbarBuildTramClick,
1985  ToolbarBuildWaterClick,
1986  ToolbarBuildAirClick,
1987  ToolbarForestClick,
1988  ToolbarMusicClick,
1989  ToolbarNewspaperClick,
1990  ToolbarHelpClick,
1991  ToolbarSwitchClick,
1992 };
1993 
1996  GUITimer timer;
1997 
1998  MainToolbarWindow(WindowDesc *desc) : Window(desc)
1999  {
2000  this->InitNested(0);
2001 
2002  _last_started_action = CBF_NONE;
2003  CLRBITS(this->flags, WF_WHITE_BORDER);
2004  this->SetWidgetDisabledState(WID_TN_PAUSE, _networking && !_network_server); // if not server, disable pause button
2005  this->SetWidgetDisabledState(WID_TN_FAST_FORWARD, _networking); // if networking, disable fast-forward button
2006  PositionMainToolbar(this);
2008 
2009  this->timer.SetInterval(MILLISECONDS_PER_TICK);
2010  }
2011 
2012  void FindWindowPlacementAndResize(int def_width, int def_height) override
2013  {
2015  }
2016 
2017  void OnPaint() override
2018  {
2019  /* If spectator, disable all construction buttons
2020  * ie : Build road, rail, ships, airports and landscaping
2021  * Since enabled state is the default, just disable when needed */
2023  /* disable company list drop downs, if there are no companies */
2025 
2028 
2029  this->DrawWidgets();
2030  }
2031 
2032  void OnClick(Point pt, int widget, int click_count) override
2033  {
2034  if (_game_mode != GM_MENU && !this->IsWidgetDisabled(widget)) _toolbar_button_procs[widget](this);
2035  }
2036 
2037  void OnDropdownSelect(int widget, int index) override
2038  {
2039  CallBackFunction cbf = _menu_clicked_procs[widget](index);
2040  if (cbf != CBF_NONE) _last_started_action = cbf;
2041  }
2042 
2043  EventState OnHotkey(int hotkey) override
2044  {
2045  CallBackFunction cbf = CBF_NONE;
2046  switch (hotkey) {
2047  case MTHK_PAUSE: ToolbarPauseClick(this); break;
2048  case MTHK_FASTFORWARD: ToolbarFastForwardClick(this); break;
2049  case MTHK_SETTINGS: ShowGameOptions(); break;
2050  case MTHK_SAVEGAME: MenuClickSaveLoad(); break;
2051  case MTHK_LOADGAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break;
2052  case MTHK_SMALLMAP: ShowSmallMap(); break;
2053  case MTHK_TOWNDIRECTORY: ShowTownDirectory(); break;
2054  case MTHK_SUBSIDIES: ShowSubsidiesList(); break;
2055  case MTHK_STATIONS: ShowCompanyStations(_local_company); break;
2056  case MTHK_FINANCES: ShowCompanyFinances(_local_company); break;
2057  case MTHK_COMPANIES: ShowCompany(_local_company); break;
2058  case MTHK_STORY: ShowStoryBook(_local_company); break;
2059  case MTHK_GOAL: ShowGoalsList(_local_company); break;
2060  case MTHK_GRAPHS: ShowOperatingProfitGraph(); break;
2061  case MTHK_LEAGUE: ShowFirstLeagueTable(); break;
2062  case MTHK_INDUSTRIES: ShowBuildIndustryWindow(); break;
2063  case MTHK_TRAIN_LIST: ShowVehicleListWindow(_local_company, VEH_TRAIN); break;
2064  case MTHK_ROADVEH_LIST: ShowVehicleListWindow(_local_company, VEH_ROAD); break;
2065  case MTHK_SHIP_LIST: ShowVehicleListWindow(_local_company, VEH_SHIP); break;
2066  case MTHK_AIRCRAFT_LIST: ShowVehicleListWindow(_local_company, VEH_AIRCRAFT); break;
2067  case MTHK_ZOOM_IN: ToolbarZoomInClick(this); break;
2068  case MTHK_ZOOM_OUT: ToolbarZoomOutClick(this); break;
2069  case MTHK_BUILD_RAIL: ShowBuildRailToolbar(_last_built_railtype); break;
2070  case MTHK_BUILD_ROAD: ShowBuildRoadToolbar(_last_built_roadtype); break;
2071  case MTHK_BUILD_TRAM: ShowBuildRoadToolbar(_last_built_tramtype); break;
2072  case MTHK_BUILD_DOCKS: ShowBuildDocksToolbar(); break;
2073  case MTHK_BUILD_AIRPORT: ShowBuildAirToolbar(); break;
2074  case MTHK_BUILD_TREES: ShowBuildTreesToolbar(); break;
2075  case MTHK_MUSIC: ShowMusicWindow(); break;
2076  case MTHK_AI_DEBUG: ShowAIDebugWindow(); break;
2077  case MTHK_SMALL_SCREENSHOT: MakeScreenshotWithConfirm(SC_VIEWPORT); break;
2078  case MTHK_ZOOMEDIN_SCREENSHOT: MakeScreenshotWithConfirm(SC_ZOOMEDIN); break;
2079  case MTHK_DEFAULTZOOM_SCREENSHOT: MakeScreenshotWithConfirm(SC_DEFAULTZOOM); break;
2080  case MTHK_GIANT_SCREENSHOT: MakeScreenshotWithConfirm(SC_WORLD); break;
2081  case MTHK_CHEATS: if (!_networking) ShowCheatWindow(); break;
2082  case MTHK_TERRAFORM: ShowTerraformToolbar(); break;
2083  case MTHK_EXTRA_VIEWPORT: ShowExtraViewportWindowForTileUnderCursor(); break;
2084  case MTHK_CLIENT_LIST: if (_networking) ShowClientList(); break;
2085  case MTHK_SIGN_LIST: ShowSignList(); break;
2086  case MTHK_LANDINFO: cbf = PlaceLandBlockInfo(); break;
2087  default: return ES_NOT_HANDLED;
2088  }
2089  if (cbf != CBF_NONE) _last_started_action = cbf;
2090  return ES_HANDLED;
2091  }
2092 
2093  void OnPlaceObject(Point pt, TileIndex tile) override
2094  {
2095  switch (_last_started_action) {
2096  case CBF_PLACE_SIGN:
2097  PlaceProc_Sign(tile);
2098  break;
2099 
2100  case CBF_PLACE_LANDINFO:
2101  ShowLandInfo(tile);
2102  break;
2103 
2104  default: NOT_REACHED();
2105  }
2106  }
2107 
2108  void OnPlaceObjectAbort() override
2109  {
2110  _last_started_action = CBF_NONE;
2111  }
2112 
2113  void OnRealtimeTick(uint delta_ms) override
2114  {
2115  if (!this->timer.Elapsed(delta_ms)) return;
2116  this->timer.SetInterval(MILLISECONDS_PER_TICK);
2117 
2118  if (this->IsWidgetLowered(WID_TN_PAUSE) != !!_pause_mode) {
2121  }
2122 
2123  if (this->IsWidgetLowered(WID_TN_FAST_FORWARD) != (_game_speed != 100)) {
2126  }
2127  }
2128 
2129  void OnTimeout() override
2130  {
2131  /* We do not want to automatically raise the pause, fast forward and
2132  * switchbar buttons; they have to stay down when pressed etc. */
2133  for (uint i = WID_TN_SETTINGS; i < WID_TN_SWITCH_BAR; i++) {
2134  if (this->IsWidgetLowered(i)) {
2135  this->RaiseWidget(i);
2136  this->SetWidgetDirty(i);
2137  }
2138  }
2139  }
2140 
2146  void OnInvalidateData(int data = 0, bool gui_scope = true) override
2147  {
2148  if (!gui_scope) return;
2150  }
2151 
2152  static HotkeyList hotkeys;
2153 };
2154 
2155 const uint16 _maintoolbar_pause_keys[] = {WKC_F1, WKC_PAUSE, 0};
2156 const uint16 _maintoolbar_zoomin_keys[] = {WKC_NUM_PLUS, WKC_EQUALS, WKC_SHIFT | WKC_EQUALS, WKC_SHIFT | WKC_F5, 0};
2157 const uint16 _maintoolbar_zoomout_keys[] = {WKC_NUM_MINUS, WKC_MINUS, WKC_SHIFT | WKC_MINUS, WKC_SHIFT | WKC_F6, 0};
2158 const uint16 _maintoolbar_smallmap_keys[] = {WKC_F4, 'M', 0};
2159 
2160 static Hotkey maintoolbar_hotkeys[] = {
2161  Hotkey(_maintoolbar_pause_keys, "pause", MTHK_PAUSE),
2162  Hotkey((uint16)0, "fastforward", MTHK_FASTFORWARD),
2163  Hotkey(WKC_F2, "settings", MTHK_SETTINGS),
2164  Hotkey(WKC_F3, "saveload", MTHK_SAVEGAME),
2165  Hotkey((uint16)0, "load_game", MTHK_LOADGAME),
2166  Hotkey(_maintoolbar_smallmap_keys, "smallmap", MTHK_SMALLMAP),
2167  Hotkey(WKC_F5, "town_list", MTHK_TOWNDIRECTORY),
2168  Hotkey(WKC_F6, "subsidies", MTHK_SUBSIDIES),
2169  Hotkey(WKC_F7, "station_list", MTHK_STATIONS),
2170  Hotkey(WKC_F8, "finances", MTHK_FINANCES),
2171  Hotkey(WKC_F9, "companies", MTHK_COMPANIES),
2172  Hotkey((uint16)0, "story_book", MTHK_STORY),
2173  Hotkey((uint16)0, "goal_list", MTHK_GOAL),
2174  Hotkey(WKC_F10, "graphs", MTHK_GRAPHS),
2175  Hotkey(WKC_F11, "league", MTHK_LEAGUE),
2176  Hotkey(WKC_F12, "industry_list", MTHK_INDUSTRIES),
2177  Hotkey(WKC_SHIFT | WKC_F1, "train_list", MTHK_TRAIN_LIST),
2178  Hotkey(WKC_SHIFT | WKC_F2, "roadveh_list", MTHK_ROADVEH_LIST),
2179  Hotkey(WKC_SHIFT | WKC_F3, "ship_list", MTHK_SHIP_LIST),
2180  Hotkey(WKC_SHIFT | WKC_F4, "aircraft_list", MTHK_AIRCRAFT_LIST),
2181  Hotkey(_maintoolbar_zoomin_keys, "zoomin", MTHK_ZOOM_IN),
2182  Hotkey(_maintoolbar_zoomout_keys, "zoomout", MTHK_ZOOM_OUT),
2183  Hotkey(WKC_SHIFT | WKC_F7, "build_rail", MTHK_BUILD_RAIL),
2184  Hotkey(WKC_SHIFT | WKC_F8, "build_road", MTHK_BUILD_ROAD),
2185  Hotkey((uint16)0, "build_tram", MTHK_BUILD_TRAM),
2186  Hotkey(WKC_SHIFT | WKC_F9, "build_docks", MTHK_BUILD_DOCKS),
2187  Hotkey(WKC_SHIFT | WKC_F10, "build_airport", MTHK_BUILD_AIRPORT),
2188  Hotkey(WKC_SHIFT | WKC_F11, "build_trees", MTHK_BUILD_TREES),
2189  Hotkey(WKC_SHIFT | WKC_F12, "music", MTHK_MUSIC),
2190  Hotkey((uint16)0, "ai_debug", MTHK_AI_DEBUG),
2191  Hotkey(WKC_CTRL | 'S', "small_screenshot", MTHK_SMALL_SCREENSHOT),
2192  Hotkey(WKC_CTRL | 'P', "zoomedin_screenshot", MTHK_ZOOMEDIN_SCREENSHOT),
2193  Hotkey(WKC_CTRL | 'D', "defaultzoom_screenshot", MTHK_DEFAULTZOOM_SCREENSHOT),
2194  Hotkey((uint16)0, "giant_screenshot", MTHK_GIANT_SCREENSHOT),
2195  Hotkey(WKC_CTRL | WKC_ALT | 'C', "cheats", MTHK_CHEATS),
2196  Hotkey('L', "terraform", MTHK_TERRAFORM),
2197  Hotkey('V', "extra_viewport", MTHK_EXTRA_VIEWPORT),
2198  Hotkey((uint16)0, "client_list", MTHK_CLIENT_LIST),
2199  Hotkey((uint16)0, "sign_list", MTHK_SIGN_LIST),
2200  Hotkey((uint16)0, "land_info", MTHK_LANDINFO),
2201  HOTKEY_LIST_END
2202 };
2203 HotkeyList MainToolbarWindow::hotkeys("maintoolbar", maintoolbar_hotkeys);
2204 
2205 static NWidgetBase *MakeMainToolbar(int *biggest_index)
2206 {
2208  static const SpriteID toolbar_button_sprites[] = {
2209  SPR_IMG_PAUSE, // WID_TN_PAUSE
2210  SPR_IMG_FASTFORWARD, // WID_TN_FAST_FORWARD
2211  SPR_IMG_SETTINGS, // WID_TN_SETTINGS
2212  SPR_IMG_SAVE, // WID_TN_SAVE
2213  SPR_IMG_SMALLMAP, // WID_TN_SMALL_MAP
2214  SPR_IMG_TOWN, // WID_TN_TOWNS
2215  SPR_IMG_SUBSIDIES, // WID_TN_SUBSIDIES
2216  SPR_IMG_COMPANY_LIST, // WID_TN_STATIONS
2217  SPR_IMG_COMPANY_FINANCE, // WID_TN_FINANCES
2218  SPR_IMG_COMPANY_GENERAL, // WID_TN_COMPANIES
2219  SPR_IMG_STORY_BOOK, // WID_TN_STORY
2220  SPR_IMG_GOAL, // WID_TN_GOAL
2221  SPR_IMG_GRAPHS, // WID_TN_GRAPHS
2222  SPR_IMG_COMPANY_LEAGUE, // WID_TN_LEAGUE
2223  SPR_IMG_INDUSTRY, // WID_TN_INDUSTRIES
2224  SPR_IMG_TRAINLIST, // WID_TN_TRAINS
2225  SPR_IMG_TRUCKLIST, // WID_TN_ROADVEHS
2226  SPR_IMG_SHIPLIST, // WID_TN_SHIPS
2227  SPR_IMG_AIRPLANESLIST, // WID_TN_AIRCRAFT
2228  SPR_IMG_ZOOMIN, // WID_TN_ZOOMIN
2229  SPR_IMG_ZOOMOUT, // WID_TN_ZOOMOUT
2230  SPR_IMG_BUILDRAIL, // WID_TN_RAILS
2231  SPR_IMG_BUILDROAD, // WID_TN_ROADS
2232  SPR_IMG_BUILDTRAMS, // WID_TN_TRAMS
2233  SPR_IMG_BUILDWATER, // WID_TN_WATER
2234  SPR_IMG_BUILDAIR, // WID_TN_AIR
2235  SPR_IMG_LANDSCAPING, // WID_TN_LANDSCAPE
2236  SPR_IMG_MUSIC, // WID_TN_MUSIC_SOUND
2237  SPR_IMG_MESSAGES, // WID_TN_MESSAGES
2238  SPR_IMG_QUERY, // WID_TN_HELP
2239  SPR_IMG_SWITCH_TOOLBAR, // WID_TN_SWITCH_BAR
2240  };
2241 
2243  for (uint i = 0; i < WID_TN_END; i++) {
2244  switch (i) {
2245  case WID_TN_SMALL_MAP:
2246  case WID_TN_FINANCES:
2247  case WID_TN_VEHICLE_START:
2248  case WID_TN_ZOOM_IN:
2250  case WID_TN_MUSIC_SOUND:
2251  hor->Add(new NWidgetSpacer(0, 0));
2252  break;
2253  }
2254  NWidgetLeaf *leaf = new NWidgetLeaf(i == WID_TN_SAVE ? WWT_IMGBTN_2 : WWT_IMGBTN, COLOUR_GREY, i, toolbar_button_sprites[i], STR_TOOLBAR_TOOLTIP_PAUSE_GAME + i);
2255  leaf->SetMinimalSize(20, 20);
2256  hor->Add(leaf);
2257  }
2258 
2259  *biggest_index = std::max<int>(*biggest_index, WID_TN_SWITCH_BAR);
2260  return hor;
2261 }
2262 
2263 static const NWidgetPart _nested_toolbar_normal_widgets[] = {
2265 };
2266 
2267 static WindowDesc _toolb_normal_desc(
2268  WDP_MANUAL, nullptr, 0, 0,
2270  WDF_NO_FOCUS,
2271  _nested_toolbar_normal_widgets, lengthof(_nested_toolbar_normal_widgets),
2272  &MainToolbarWindow::hotkeys
2273 );
2274 
2275 
2276 /* --- Toolbar handling for the scenario editor */
2277 
2278 static MenuClickedProc * const _scen_toolbar_dropdown_procs[] = {
2279  nullptr, // 0
2280  nullptr, // 1
2281  MenuClickSettings, // 2
2282  MenuClickSaveLoad, // 3
2283  nullptr, // 4
2284  nullptr, // 5
2285  nullptr, // 6
2286  nullptr, // 7
2287  MenuClickMap, // 8
2288  nullptr, // 9
2289  nullptr, // 10
2290  nullptr, // 11
2291  nullptr, // 12
2292  nullptr, // 13
2293  ToolbarScenBuildRoad, // 14
2294  ToolbarScenBuildTram, // 15
2295  nullptr, // 16
2296  nullptr, // 17
2297  nullptr, // 18
2298  nullptr, // 19
2299  MenuClickMusicWindow, // 20
2300  MenuClickHelp, // 21
2301  nullptr, // 22
2302 };
2303 
2304 static ToolbarButtonProc * const _scen_toolbar_button_procs[] = {
2305  ToolbarPauseClick,
2309  ToolbarBtn_NULL,
2311  ToolbarScenDateBackward,
2312  ToolbarScenDateForward,
2313  ToolbarScenMapTownDir,
2314  ToolbarZoomInClick,
2315  ToolbarZoomOutClick,
2316  ToolbarScenGenLand,
2317  ToolbarScenGenTown,
2318  ToolbarScenGenIndustry,
2319  ToolbarScenBuildRoadClick,
2320  ToolbarScenBuildTramClick,
2321  ToolbarScenBuildDocks,
2322  ToolbarScenPlantTrees,
2323  ToolbarScenPlaceSign,
2324  ToolbarBtn_NULL,
2325  ToolbarMusicClick,
2326  ToolbarHelpClick,
2327  ToolbarSwitchClick,
2328 };
2329 
2330 enum MainToolbarEditorHotkeys {
2331  MTEHK_PAUSE,
2332  MTEHK_FASTFORWARD,
2333  MTEHK_SETTINGS,
2334  MTEHK_SAVEGAME,
2335  MTEHK_GENLAND,
2336  MTEHK_GENTOWN,
2337  MTEHK_GENINDUSTRY,
2338  MTEHK_BUILD_ROAD,
2339  MTEHK_BUILD_TRAM,
2340  MTEHK_BUILD_DOCKS,
2341  MTEHK_BUILD_TREES,
2342  MTEHK_SIGN,
2343  MTEHK_MUSIC,
2344  MTEHK_LANDINFO,
2345  MTEHK_SMALL_SCREENSHOT,
2346  MTEHK_ZOOMEDIN_SCREENSHOT,
2347  MTEHK_DEFAULTZOOM_SCREENSHOT,
2348  MTEHK_GIANT_SCREENSHOT,
2349  MTEHK_ZOOM_IN,
2350  MTEHK_ZOOM_OUT,
2351  MTEHK_TERRAFORM,
2352  MTEHK_SMALLMAP,
2353  MTEHK_EXTRA_VIEWPORT,
2354 };
2355 
2357  GUITimer timer;
2358 
2360  {
2361  this->InitNested(0);
2362 
2363  _last_started_action = CBF_NONE;
2364  CLRBITS(this->flags, WF_WHITE_BORDER);
2365  PositionMainToolbar(this);
2367 
2368  this->timer.SetInterval(MILLISECONDS_PER_TICK);
2369  }
2370 
2371  void FindWindowPlacementAndResize(int def_width, int def_height) override
2372  {
2374  }
2375 
2376  void OnPaint() override
2377  {
2382 
2383  this->DrawWidgets();
2384  }
2385 
2386  void SetStringParameters(int widget) const override
2387  {
2388  switch (widget) {
2389  case WID_TE_DATE:
2391  break;
2392  }
2393  }
2394 
2395  void DrawWidget(const Rect &r, int widget) const override
2396  {
2397  switch (widget) {
2398  case WID_TE_SPACER: {
2399  int height = r.Height();
2400  if (height > 2 * FONT_HEIGHT_NORMAL) {
2401  DrawString(r.left, r.right, height / 2 - FONT_HEIGHT_NORMAL, STR_SCENEDIT_TOOLBAR_OPENTTD, TC_FROMSTRING, SA_HOR_CENTER);
2402  DrawString(r.left, r.right, height / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER);
2403  } else {
2404  DrawString(r.left, r.right, (height - FONT_HEIGHT_NORMAL) / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER);
2405  }
2406  break;
2407  }
2408  }
2409  }
2410 
2411  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
2412  {
2413  switch (widget) {
2414  case WID_TE_SPACER:
2415  size->width = std::max(GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_OPENTTD).width, GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR).width) + padding.width;
2416  break;
2417 
2418  case WID_TE_DATE:
2419  SetDParam(0, ConvertYMDToDate(MAX_YEAR, 0, 1));
2420  *size = GetStringBoundingBox(STR_WHITE_DATE_LONG);
2421  break;
2422  }
2423  }
2424 
2425  void OnClick(Point pt, int widget, int click_count) override
2426  {
2427  if (_game_mode == GM_MENU) return;
2428  CallBackFunction cbf = _scen_toolbar_button_procs[widget](this);
2429  if (cbf != CBF_NONE) _last_started_action = cbf;
2430  }
2431 
2432  void OnDropdownSelect(int widget, int index) override
2433  {
2434  CallBackFunction cbf = _scen_toolbar_dropdown_procs[widget](index);
2435  if (cbf != CBF_NONE) _last_started_action = cbf;
2436  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
2437  }
2438 
2439  EventState OnHotkey(int hotkey) override
2440  {
2441  CallBackFunction cbf = CBF_NONE;
2442  switch (hotkey) {
2443  case MTEHK_PAUSE: ToolbarPauseClick(this); break;
2444  case MTEHK_FASTFORWARD: ToolbarFastForwardClick(this); break;
2445  case MTEHK_SETTINGS: ShowGameOptions(); break;
2446  case MTEHK_SAVEGAME: MenuClickSaveLoad(); break;
2447  case MTEHK_GENLAND: ToolbarScenGenLand(this); break;
2448  case MTEHK_GENTOWN: ToolbarScenGenTown(this); break;
2449  case MTEHK_GENINDUSTRY: ToolbarScenGenIndustry(this); break;
2450  case MTEHK_BUILD_ROAD: ToolbarScenBuildRoadClick(this); break;
2451  case MTEHK_BUILD_TRAM: ToolbarScenBuildTramClick(this); break;
2452  case MTEHK_BUILD_DOCKS: ToolbarScenBuildDocks(this); break;
2453  case MTEHK_BUILD_TREES: ToolbarScenPlantTrees(this); break;
2454  case MTEHK_SIGN: cbf = ToolbarScenPlaceSign(this); break;
2455  case MTEHK_MUSIC: ShowMusicWindow(); break;
2456  case MTEHK_LANDINFO: cbf = PlaceLandBlockInfo(); break;
2457  case MTEHK_SMALL_SCREENSHOT: MakeScreenshotWithConfirm(SC_VIEWPORT); break;
2458  case MTEHK_ZOOMEDIN_SCREENSHOT: MakeScreenshotWithConfirm(SC_ZOOMEDIN); break;
2459  case MTEHK_DEFAULTZOOM_SCREENSHOT: MakeScreenshotWithConfirm(SC_DEFAULTZOOM); break;
2460  case MTEHK_GIANT_SCREENSHOT: MakeScreenshotWithConfirm(SC_WORLD); break;
2461  case MTEHK_ZOOM_IN: ToolbarZoomInClick(this); break;
2462  case MTEHK_ZOOM_OUT: ToolbarZoomOutClick(this); break;
2463  case MTEHK_TERRAFORM: ShowEditorTerraformToolbar(); break;
2464  case MTEHK_SMALLMAP: ShowSmallMap(); break;
2465  case MTEHK_EXTRA_VIEWPORT: ShowExtraViewportWindowForTileUnderCursor(); break;
2466  default: return ES_NOT_HANDLED;
2467  }
2468  if (cbf != CBF_NONE) _last_started_action = cbf;
2469  return ES_HANDLED;
2470  }
2471 
2472  void OnPlaceObject(Point pt, TileIndex tile) override
2473  {
2474  switch (_last_started_action) {
2475  case CBF_PLACE_SIGN:
2476  PlaceProc_Sign(tile);
2477  break;
2478 
2479  case CBF_PLACE_LANDINFO:
2480  ShowLandInfo(tile);
2481  break;
2482 
2483  default: NOT_REACHED();
2484  }
2485  }
2486 
2487  void OnPlaceObjectAbort() override
2488  {
2489  _last_started_action = CBF_NONE;
2490  }
2491 
2492  void OnTimeout() override
2493  {
2497  }
2498 
2499  void OnRealtimeTick(uint delta_ms) override
2500  {
2501  if (!this->timer.Elapsed(delta_ms)) return;
2502  this->timer.SetInterval(MILLISECONDS_PER_TICK);
2503 
2504  if (this->IsWidgetLowered(WID_TE_PAUSE) != !!_pause_mode) {
2506  this->SetDirty();
2507  }
2508 
2509  if (this->IsWidgetLowered(WID_TE_FAST_FORWARD) != (_game_speed != 100)) {
2511  this->SetDirty();
2512  }
2513  }
2514 
2520  void OnInvalidateData(int data = 0, bool gui_scope = true) override
2521  {
2522  if (!gui_scope) return;
2524  }
2525 
2526  void OnQueryTextFinished(char *str) override
2527  {
2528  /* Was 'cancel' pressed? */
2529  if (str == nullptr) return;
2530 
2531  int32 value;
2532  if (!StrEmpty(str)) {
2533  value = atoi(str);
2534  } else {
2535  /* An empty string means revert to the default */
2536  value = DEF_START_YEAR;
2537  }
2538  SetStartingYear(value);
2539 
2540  this->SetDirty();
2541  }
2542 
2543  static HotkeyList hotkeys;
2544 };
2545 
2546 static Hotkey scenedit_maintoolbar_hotkeys[] = {
2547  Hotkey(_maintoolbar_pause_keys, "pause", MTEHK_PAUSE),
2548  Hotkey((uint16)0, "fastforward", MTEHK_FASTFORWARD),
2549  Hotkey(WKC_F2, "settings", MTEHK_SETTINGS),
2550  Hotkey(WKC_F3, "saveload", MTEHK_SAVEGAME),
2551  Hotkey(WKC_F4, "gen_land", MTEHK_GENLAND),
2552  Hotkey(WKC_F5, "gen_town", MTEHK_GENTOWN),
2553  Hotkey(WKC_F6, "gen_industry", MTEHK_GENINDUSTRY),
2554  Hotkey(WKC_F7, "build_road", MTEHK_BUILD_ROAD),
2555  Hotkey((uint16)0, "build_tram", MTEHK_BUILD_TRAM),
2556  Hotkey(WKC_F8, "build_docks", MTEHK_BUILD_DOCKS),
2557  Hotkey(WKC_F9, "build_trees", MTEHK_BUILD_TREES),
2558  Hotkey(WKC_F10, "build_sign", MTEHK_SIGN),
2559  Hotkey(WKC_F11, "music", MTEHK_MUSIC),
2560  Hotkey(WKC_F12, "land_info", MTEHK_LANDINFO),
2561  Hotkey(WKC_CTRL | 'S', "small_screenshot", MTEHK_SMALL_SCREENSHOT),
2562  Hotkey(WKC_CTRL | 'P', "zoomedin_screenshot", MTEHK_ZOOMEDIN_SCREENSHOT),
2563  Hotkey(WKC_CTRL | 'D', "defaultzoom_screenshot", MTEHK_DEFAULTZOOM_SCREENSHOT),
2564  Hotkey((uint16)0, "giant_screenshot", MTEHK_GIANT_SCREENSHOT),
2565  Hotkey(_maintoolbar_zoomin_keys, "zoomin", MTEHK_ZOOM_IN),
2566  Hotkey(_maintoolbar_zoomout_keys, "zoomout", MTEHK_ZOOM_OUT),
2567  Hotkey('L', "terraform", MTEHK_TERRAFORM),
2568  Hotkey('M', "smallmap", MTEHK_SMALLMAP),
2569  Hotkey('V', "extra_viewport", MTEHK_EXTRA_VIEWPORT),
2570  HOTKEY_LIST_END
2571 };
2572 HotkeyList ScenarioEditorToolbarWindow::hotkeys("scenedit_maintoolbar", scenedit_maintoolbar_hotkeys);
2573 
2574 static const NWidgetPart _nested_toolb_scen_inner_widgets[] = {
2575  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_PAUSE), SetDataTip(SPR_IMG_PAUSE, STR_TOOLBAR_TOOLTIP_PAUSE_GAME),
2576  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_FAST_FORWARD), SetDataTip(SPR_IMG_FASTFORWARD, STR_TOOLBAR_TOOLTIP_FORWARD),
2577  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SETTINGS), SetDataTip(SPR_IMG_SETTINGS, STR_TOOLBAR_TOOLTIP_OPTIONS),
2578  NWidget(WWT_IMGBTN_2, COLOUR_GREY, WID_TE_SAVE), SetDataTip(SPR_IMG_SAVE, STR_SCENEDIT_TOOLBAR_TOOLTIP_SAVE_SCENARIO_LOAD_SCENARIO),
2580  NWidget(WWT_PANEL, COLOUR_GREY, WID_TE_SPACER), EndContainer(),
2582  NWidget(WWT_PANEL, COLOUR_GREY, WID_TE_DATE_PANEL),
2583  NWidget(NWID_HORIZONTAL), SetPIP(2, 2, 2), SetPadding(1),
2584  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),
2585  NWidget(WWT_TEXT, COLOUR_GREY, WID_TE_DATE), SetDataTip(STR_WHITE_DATE_LONG, STR_SCENEDIT_TOOLBAR_TOOLTIP_SET_DATE), SetAlignment(SA_CENTER), SetFill(0, 1),
2586  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),
2587  EndContainer(),
2588  EndContainer(),
2590  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SMALL_MAP), SetDataTip(SPR_IMG_SMALLMAP, STR_SCENEDIT_TOOLBAR_TOOLTIP_DISPLAY_MAP_TOWN_DIRECTORY),
2592  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_ZOOM_IN), SetDataTip(SPR_IMG_ZOOMIN, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_IN),
2593  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_ZOOM_OUT), SetDataTip(SPR_IMG_ZOOMOUT, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_OUT),
2595  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_LAND_GENERATE), SetDataTip(SPR_IMG_LANDSCAPING, STR_SCENEDIT_TOOLBAR_LANDSCAPE_GENERATION),
2596  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_TOWN_GENERATE), SetDataTip(SPR_IMG_TOWN, STR_SCENEDIT_TOOLBAR_TOWN_GENERATION),
2597  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_INDUSTRY), SetDataTip(SPR_IMG_INDUSTRY, STR_SCENEDIT_TOOLBAR_INDUSTRY_GENERATION),
2598  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_ROADS), SetDataTip(SPR_IMG_BUILDROAD, STR_SCENEDIT_TOOLBAR_ROAD_CONSTRUCTION),
2599  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_TRAMS), SetDataTip(SPR_IMG_BUILDTRAMS, STR_SCENEDIT_TOOLBAR_TRAM_CONSTRUCTION),
2600  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_WATER), SetDataTip(SPR_IMG_BUILDWATER, STR_TOOLBAR_TOOLTIP_BUILD_SHIP_DOCKS),
2601  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_TREES), SetDataTip(SPR_IMG_PLANTTREES, STR_SCENEDIT_TOOLBAR_PLANT_TREES),
2602  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_SIGNS), SetDataTip(SPR_IMG_SIGN, STR_SCENEDIT_TOOLBAR_PLACE_SIGN),
2604  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_MUSIC_SOUND), SetDataTip(SPR_IMG_MUSIC, STR_TOOLBAR_TOOLTIP_SHOW_SOUND_MUSIC_WINDOW),
2605  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_HELP), SetDataTip(SPR_IMG_QUERY, STR_TOOLBAR_TOOLTIP_LAND_BLOCK_INFORMATION),
2606  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SWITCH_BAR), SetDataTip(SPR_IMG_SWITCH_TOOLBAR, STR_TOOLBAR_TOOLTIP_SWITCH_TOOLBAR),
2607 };
2608 
2609 static NWidgetBase *MakeScenarioToolbar(int *biggest_index)
2610 {
2611  return MakeNWidgets(_nested_toolb_scen_inner_widgets, lengthof(_nested_toolb_scen_inner_widgets), biggest_index, new NWidgetScenarioToolbarContainer());
2612 }
2613 
2614 static const NWidgetPart _nested_toolb_scen_widgets[] = {
2615  NWidgetFunction(MakeScenarioToolbar),
2616 };
2617 
2618 static WindowDesc _toolb_scen_desc(
2619  WDP_MANUAL, nullptr, 0, 0,
2621  WDF_NO_FOCUS,
2622  _nested_toolb_scen_widgets, lengthof(_nested_toolb_scen_widgets),
2623  &ScenarioEditorToolbarWindow::hotkeys
2624 );
2625 
2628 {
2629  /* Clean old GUI values; railtype is (re)set by rail_gui.cpp */
2630  _last_built_roadtype = ROADTYPE_ROAD;
2631  _last_built_tramtype = ROADTYPE_TRAM;
2632 
2633  if (_game_mode == GM_EDITOR) {
2634  new ScenarioEditorToolbarWindow(&_toolb_scen_desc);
2635  } else {
2636  new MainToolbarWindow(&_toolb_normal_desc);
2637  }
2638 }
VEH_AIRCRAFT
@ VEH_AIRCRAFT
Aircraft vehicle type.
Definition: vehicle_type.h:27
SaveLoadEditorMenuEntries
SaveLoadEditorMenuEntries
SaveLoad entries in scenario editor mode.
Definition: toolbar_gui.cpp:387
WID_TE_LAND_GENERATE
@ WID_TE_LAND_GENERATE
Land generation.
Definition: toolbar_widget.h:64
DO_SHOW_COMPETITOR_SIGNS
@ DO_SHOW_COMPETITOR_SIGNS
Display signs, station names and waypoint names of opponent companies. Buoys and oilrig-stations are ...
Definition: openttd.h:51
ShowNewGRFSettings
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
Definition: newgrf_gui.cpp:1999
game.hpp
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:720
MenuClickFinances
static CallBackFunction MenuClickFinances(int index)
Handle click on the entry in the finances overview menu.
Definition: toolbar_gui.cpp:594
ShowSpriteAlignerWindow
void ShowSpriteAlignerWindow()
Show the window for aligning sprites.
Definition: newgrf_debug_gui.cpp:1130
ShowIndustryCargoesWindow
void ShowIndustryCargoesWindow()
Open the industry and cargoes window with an industry.
Definition: industry_gui.cpp:3166
ScenarioEditorToolbarWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: toolbar_gui.cpp:2432
PopupMainToolbMenu
static void PopupMainToolbMenu(Window *w, int widget, DropDownList &&list, int def)
Pop up a generic text only menu.
Definition: toolbar_gui.cpp:190
WID_TN_BUILDING_TOOLS_START
@ WID_TN_BUILDING_TOOLS_START
Helper for the offset of the building tools.
Definition: toolbar_widget.h:37
WID_TN_SAVE
@ WID_TN_SAVE
Save menu.
Definition: toolbar_widget.h:18
sound_func.h
_last_started_action
static CallBackFunction _last_started_action
Last started user action.
Definition: toolbar_gui.cpp:87
WID_TN_COMPANIES
@ WID_TN_COMPANIES
Company menu.
Definition: toolbar_widget.h:24
WID_TN_FINANCES
@ WID_TN_FINANCES
Finance menu.
Definition: toolbar_widget.h:23
WWT_IMGBTN_2
@ WWT_IMGBTN_2
(Toggle) Button with diff image when clicked
Definition: widget_type.h:51
NWidgetFunction
static NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition: widget_type.h:1261
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:527
Rect::Height
int Height() const
Get height of Rect.
Definition: geometry_type.hpp:85
DropDownListItem::result
int result
Result code to return to window on selection.
Definition: dropdown_type.h:24
vehicle_gui.h
WID_TN_ROADS
@ WID_TN_ROADS
Road building menu.
Definition: toolbar_widget.h:39
TO_HOUSES
@ TO_HOUSES
town buildings
Definition: transparency.h:25
Window::timeout_timer
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
Definition: window_gui.h:243
WID_TN_WATER
@ WID_TN_WATER
Water building toolbar.
Definition: toolbar_widget.h:41
ShowGoalsList
void ShowGoalsList(CompanyID company)
Open a goal list window.
Definition: goal_gui.cpp:317
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:2240
ShowExtraViewportWindow
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
Definition: viewport_gui.cpp:168
HotkeyList
List of hotkeys for a window.
Definition: hotkeys.h:40
GUISettings::newgrf_developer_tools
bool newgrf_developer_tools
activate NewGRF developer tools and allow modifying NewGRFs in an existing game
Definition: settings_type.h:192
MenuClickIndustry
static CallBackFunction MenuClickIndustry(int index)
Handle click on the entry in the Industry menu.
Definition: toolbar_gui.cpp:782
LinkGraphSchedule::ShiftDates
void ShiftDates(int interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
Definition: linkgraphschedule.cpp:135
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
ZOOM_OUT
@ ZOOM_OUT
Zoom out (get helicopter view).
Definition: viewport_type.h:74
command_func.h
SetPadding
static NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1143
PositionMainToolbar
int PositionMainToolbar(Window *w)
(Re)position main toolbar window at the screen.
Definition: window.cpp:3433
ShowBuildAirToolbar
Window * ShowBuildAirToolbar()
Open the build airport toolbar window.
Definition: airport_gui.cpp:229
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:92
WID_TE_ROADS
@ WID_TE_ROADS
Road building menu.
Definition: toolbar_widget.h:67
PC_DARK_RED
static const uint8 PC_DARK_RED
Dark red palette colour.
Definition: gfx_func.h:248
toolbar_gui.h
smallmap_gui.h
ShowStoryBook
void ShowStoryBook(CompanyID company, uint16 page_id=INVALID_STORY_PAGE)
Raise or create the story book window for company, at page page_id.
Definition: story_gui.cpp:1057
guitimer_func.h
Window::ReInit
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:1019
IsTransparencySet
static bool IsTransparencySet(TransparencyOption to)
Check if the transparency option bit is set and if we aren't in the game menu (there's never transpar...
Definition: transparency.h:48
NWidgetContainer::Add
void Add(NWidgetBase *wid)
Append widget wid to container.
Definition: widget.cpp:1261
WID_TE_SAVE
@ WID_TE_SAVE
Save menu.
Definition: toolbar_widget.h:56
ToolbarFastForwardClick
static CallBackFunction ToolbarFastForwardClick(Window *w)
Toggle fast forward mode.
Definition: toolbar_gui.cpp:286
NWidgetToolbarContainer::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: toolbar_gui.cpp:1492
signs_func.h
WID_TN_AIR
@ WID_TN_AIR
Airport building toolbar.
Definition: toolbar_widget.h:42
company_gui.h
TF_FORBIDDEN
@ TF_FORBIDDEN
Forbidden.
Definition: town_type.h:96
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:1185
WID_TN_STORY
@ WID_TN_STORY
Story menu.
Definition: toolbar_widget.h:25
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:50
Window::viewport
ViewportData * viewport
Pointer to viewport data, if present.
Definition: window_gui.h:255
_network_server
bool _network_server
network-server is active
Definition: network.cpp:59
league_gui.h
NWidgetToolbarContainer::Draw
void Draw(const Window *w) override
Definition: toolbar_gui.cpp:1477
DropDownList
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
Definition: dropdown_type.h:99
WID_TE_ZOOM_IN
@ WID_TE_ZOOM_IN
Zoom in the main viewport.
Definition: toolbar_widget.h:62
LinkGraphSchedule::instance
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
Definition: linkgraphschedule.h:52
ToolbarSaveClick
static CallBackFunction ToolbarSaveClick(Window *w)
Handle click on Save button in toolbar in normal game mode.
Definition: toolbar_gui.cpp:414
MainToolbarWindow::OnRealtimeTick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition: toolbar_gui.cpp:2113
WID_TE_WATER
@ WID_TE_WATER
Water building toolbar.
Definition: toolbar_widget.h:69
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
WID_TE_PAUSE
@ WID_TE_PAUSE
Pause the game.
Definition: toolbar_widget.h:53
WID_TE_DATE
@ WID_TE_DATE
The date of the scenario.
Definition: toolbar_widget.h:58
DropDownListCharStringItem
List item containing a C char string.
Definition: dropdown_type.h:70
ZOOM_NONE
@ ZOOM_NONE
Hack, used to update the button status.
Definition: viewport_type.h:75
WID_TN_STATIONS
@ WID_TN_STATIONS
Station menu.
Definition: toolbar_widget.h:22
SetDate
void SetDate(Date date, DateFract fract)
Set the date.
Definition: date.cpp:37
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1161
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:682
misc_cmd.h
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
ai_gui.hpp
NWidgetSpacer
Spacer widget.
Definition: widget_type.h:575
LeagueTable
Struct about custom league tables.
Definition: league_base.h:52
WC_SIGN_LIST
@ WC_SIGN_LIST
Sign list; Window numbers:
Definition: window_type.h:271
ClrBit
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
Definition: bitmath_func.hpp:151
NetworkServerDoMove
void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
Handle the tid-bits of moving a client from one company to another.
Definition: network_server.cpp:1915
WID_TN_GOAL
@ WID_TN_GOAL
Goal menu.
Definition: toolbar_widget.h:26
TileIndex
The index/ID of a Tile.
Definition: tile_type.h:85
WDF_NO_FOCUS
@ WDF_NO_FOCUS
This window won't get focus/make any other window lose focus when click.
Definition: window_gui.h:146
ToolbarScenSaveOrLoad
static CallBackFunction ToolbarScenSaveOrLoad(Window *w)
Handle click on SaveLoad button in toolbar in the scenario editor.
Definition: toolbar_gui.cpp:426
NWidgetScenarioToolbarContainer::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: toolbar_gui.cpp:1843
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
WID_TE_ZOOM_OUT
@ WID_TE_ZOOM_OUT
Zoom out the main viewport.
Definition: toolbar_widget.h:63
Year
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
Definition: date_type.h:18
ShowMessageHistory
void ShowMessageHistory()
Display window with news messages history.
Definition: news_gui.cpp:1262
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:253
vehicle_base.h
DoZoomInOutWindow
bool DoZoomInOutWindow(ZoomStateChange how, Window *w)
Zooms a viewport in a window in or out.
Definition: main_gui.cpp:92
screenshot_gui.h
ShowGameOptions
void ShowGameOptions()
Open the game options window.
Definition: settings_gui.cpp:790
NWidgetLeaf
Leaf widget.
Definition: widget_type.h:820
WID_TN_PAUSE
@ WID_TN_PAUSE
Pause the game.
Definition: toolbar_widget.h:15
ShowLandInfo
void ShowLandInfo(TileIndex tile)
Show land information window.
Definition: misc_gui.cpp:376
goal_base.h
DropDownListItem
Base list item class from which others are derived.
Definition: dropdown_type.h:22
ShowGameSettings
void ShowGameSettings()
Open advanced settings window.
Definition: settings_gui.cpp:2523
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:53
DrawString
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:644
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:857
CallBackFunction
CallBackFunction
Callback functions.
Definition: toolbar_gui.cpp:81
newgrf_debug.h
network_gui.h
MainToolbarWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: toolbar_gui.cpp:2043
NWidgetScenarioToolbarContainer
Container for the scenario editor's toolbar.
Definition: toolbar_gui.cpp:1840
_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:2439
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:224
MenuClickGraphsOrLeague
static CallBackFunction MenuClickGraphsOrLeague(int index)
Handle click on the entry in the Graphs or CompanyLeague.
Definition: toolbar_gui.cpp:744
WID_TE_DATE_FORWARD
@ WID_TE_DATE_FORWARD
Increase the date of the scenario.
Definition: toolbar_widget.h:60
WID_TN_END
@ WID_TN_END
Helper for knowing the amount of widgets.
Definition: toolbar_widget.h:48
Window::HandleButtonClick
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
Definition: window.cpp:659
MenuClickMap
static CallBackFunction MenuClickMap(int index)
Handle click on one of the entries in the Map menu.
Definition: toolbar_gui.cpp:500
fios.h
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
NWidgetBase::smallest_y
uint smallest_y
Smallest vertical size of the widget in a filled window.
Definition: widget_type.h:194
MakeNWidgets
NWidgetContainer * MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index, NWidgetContainer *container)
Construct a nested widget tree from an array of parts.
Definition: widget.cpp:3250
MenuClickBuildTram
static CallBackFunction MenuClickBuildTram(int index)
Handle click on the entry in the Build Tram menu.
Definition: toolbar_gui.cpp:964
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1814
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:196
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:975
ShowExtraViewportWindowForTileUnderCursor
void ShowExtraViewportWindowForTileUnderCursor()
Show a new Extra Viewport window.
Definition: viewport_gui.cpp:183
WID_TE_TOWN_GENERATE
@ WID_TE_TOWN_GENERATE
Town building window.
Definition: toolbar_widget.h:65
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1111
WID_TE_DATE_PANEL
@ WID_TE_DATE_PANEL
Container for the date widgets.
Definition: toolbar_widget.h:72
toolbar_widget.h
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:890
DropDownListCompanyItem
Drop down list entry for showing a company entry, with companies 'blob'.
Definition: toolbar_gui.cpp:122
WID_TN_ZOOM_OUT
@ WID_TN_ZOOM_OUT
Zoom out the main viewport.
Definition: toolbar_widget.h:36
textbuf_gui.h
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:587
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:297
MainToolbarWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: toolbar_gui.cpp:2129
screenshot.h
PM_UNPAUSED
@ PM_UNPAUSED
A normal unpaused game.
Definition: openttd.h:61
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
NWidgetBase::Draw
virtual void Draw(const Window *w)=0
NWidgetBase::prev
NWidgetBase * prev
Pointer to previous widget in container. Managed by parent container widget.
Definition: widget_type.h:203
WindowDesc
High level window description.
Definition: window_gui.h:102
WID_TN_LEAGUE
@ WID_TN_LEAGUE
Company league menu.
Definition: toolbar_widget.h:28
ScenarioEditorToolbarWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: toolbar_gui.cpp:2386
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:214
MainToolbarWindow::OnPlaceObject
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
Definition: toolbar_gui.cpp:2093
window_gui.h
DO_FULL_ANIMATION
@ DO_FULL_ANIMATION
Perform palette animation.
Definition: openttd.h:48
ShowCompanyFinances
void ShowCompanyFinances(CompanyID company)
Open the finances window of a company.
Definition: company_gui.cpp:548
ZOOM_IN
@ ZOOM_IN
Zoom in (get more detailed view).
Definition: viewport_type.h:73
WID_TE_SPACER
@ WID_TE_SPACER
Spacer with "scenario editor" text.
Definition: toolbar_widget.h:57
ScenarioEditorToolbarWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: toolbar_gui.cpp:2411
ScenarioEditorToolbarWindow::FindWindowPlacementAndResize
void FindWindowPlacementAndResize(int def_width, int def_height) override
Resize window towards the default size.
Definition: toolbar_gui.cpp:2371
WID_TN_MUSIC_SOUND
@ WID_TN_MUSIC_SOUND
Music/sound configuration menu.
Definition: toolbar_widget.h:44
ScenarioEditorToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: toolbar_gui.cpp:2487
WID_TN_HELP
@ WID_TN_HELP
Help menu.
Definition: toolbar_widget.h:46
GUITimer
Definition: guitimer_func.h:13
_roadtypes_type
RoadTypes _roadtypes_type
Bitmap of road/tram types.
Definition: road_cmd.cpp:60
NWidgetToolbarContainer::GetButtonArrangement
virtual const byte * GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const =0
Get the arrangement of the buttons for the toolbar.
WID_TN_SHIPS
@ WID_TN_SHIPS
Ship menu.
Definition: toolbar_widget.h:33
SLO_LOAD
@ SLO_LOAD
File is being loaded.
Definition: fileio_type.h:49
GRMN_COMPANY_VALUE_GRAPH
static const int GRMN_COMPANY_VALUE_GRAPH
Show company value graph.
Definition: toolbar_gui.cpp:686
ShowSignList
Window * ShowSignList()
Open the sign list window.
Definition: signs_gui.cpp:403
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
NWidgetScenarioToolbarContainer::GetButtonArrangement
const byte * GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override
Get the arrangement of the buttons for the toolbar.
Definition: toolbar_gui.cpp:1858
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:251
WKC_EQUALS
@ WKC_EQUALS
= Equals
Definition: gfx_type.h:97
_date
Date _date
Current date in days (day counter)
Definition: date.cpp:28
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:213
tilehighlight_func.h
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:607
ToolbarScenBuildTram
static CallBackFunction ToolbarScenBuildTram(int index)
Handle click on the entry in the Build Tram menu.
Definition: toolbar_gui.cpp:1290
NWidgetContainer::tail
NWidgetBase * tail
Pointer to last widget in container.
Definition: widget_type.h:421
WidgetDimensions::hsep_normal
int hsep_normal
Normal horizontal spacing.
Definition: window_gui.h:63
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1804
NWidgetBase::type
WidgetType type
Type of the widget / nested widget.
Definition: widget_type.h:185
WID_TE_DATE_BACKWARD
@ WID_TE_DATE_BACKWARD
Reduce the date of the scenario.
Definition: toolbar_widget.h:59
MIN_YEAR
static const Year MIN_YEAR
The absolute minimum & maximum years in OTTD.
Definition: date_type.h:84
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:249
_toolbar_width
uint _toolbar_width
Width of the toolbar, shared by statusbar.
Definition: toolbar_gui.cpp:67
WF_WHITE_BORDER
@ WF_WHITE_BORDER
Window white border counter bit mask.
Definition: window_gui.h:176
game_gui.hpp
ShowCompanyStations
void ShowCompanyStations(CompanyID company)
Opens window with list of company's stations.
Definition: station_gui.cpp:759
SaveLoadNormalMenuEntries
SaveLoadNormalMenuEntries
SaveLoad entries in normal game mode.
Definition: toolbar_gui.cpp:400
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:1008
highscore.h
NWidgetBase::smallest_x
uint smallest_x
Smallest horizontal size of the widget in a filled window.
Definition: widget_type.h:193
WID_TN_SETTINGS
@ WID_TN_SETTINGS
Settings menu.
Definition: toolbar_widget.h:17
NWidgetBase::AssignSizePosition
virtual void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)=0
ConvertYMDToDate
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: date.cpp:149
IsInsideBS
static bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
Definition: math_func.hpp:214
RectPadding::Horizontal
uint Horizontal() const
Get total horizontal padding of RectPadding.
Definition: geometry_type.hpp:59
GRMN_CARGO_PAYMENT_RATES
static const int GRMN_CARGO_PAYMENT_RATES
Show cargo payment rates graph.
Definition: toolbar_gui.cpp:687
WID_TN_LANDSCAPE
@ WID_TN_LANDSCAPE
Landscaping toolbar.
Definition: toolbar_widget.h:43
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:721
MenuClickShowShips
static CallBackFunction MenuClickShowShips(int index)
Handle click on the entry in the Ships menu.
Definition: toolbar_gui.cpp:857
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:126
AllocateToolbar
void AllocateToolbar()
Allocate the toolbar.
Definition: toolbar_gui.cpp:2627
ShowFramerateWindow
void ShowFramerateWindow()
Open the general framerate window.
Definition: framerate_gui.cpp:1028
MenuClickBuildAir
static CallBackFunction MenuClickBuildAir(int index)
Handle click on the entry in the Build Air menu.
Definition: toolbar_gui.cpp:1011
ToolbarOptionsClick
static CallBackFunction ToolbarOptionsClick(Window *w)
Handle click on Options button in toolbar.
Definition: toolbar_gui.cpp:321
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:14
WidgetDimensions::hsep_wide
int hsep_wide
Wide horizontal spacing.
Definition: window_gui.h:64
ShowDropDownList
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
Definition: dropdown.cpp:444
_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:837
MenuClickBuildRail
static CallBackFunction MenuClickBuildRail(int index)
Handle click on the entry in the Build Rail menu.
Definition: toolbar_gui.cpp:920
road_gui.h
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:54
linkgraph_gui.h
LTMN_PERFORMANCE_RATING
static const int LTMN_PERFORMANCE_RATING
Show detailed performance rating.
Definition: toolbar_gui.cpp:689
NWidgetToolbarContainer::IsButton
bool IsButton(WidgetType type) const
Check whether the given widget type is a button for us.
Definition: toolbar_gui.cpp:1376
GameSettings::economy
EconomySettings economy
settings to change the economy
Definition: settings_type.h:596
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:321
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:46
DropDownListStringItem
Common string list item.
Definition: dropdown_type.h:39
DO_SHOW_STATION_NAMES
@ DO_SHOW_STATION_NAMES
Display station names.
Definition: openttd.h:46
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:1115
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:239
Rect::Indent
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
Definition: geometry_type.hpp:192
WF_TIMEOUT
@ WF_TIMEOUT
Window timeout counter.
Definition: window_gui.h:168
CLIENT_ID_SERVER
@ CLIENT_ID_SERVER
Servers always have this ID.
Definition: network_type.h:49
MenuClickSubsidies
static CallBackFunction MenuClickSubsidies(int index)
Handle click on the entry in the Subsidies menu.
Definition: toolbar_gui.cpp:552
MenuClickShowAir
static CallBackFunction MenuClickShowAir(int index)
Handle click on the entry in the Aircraft menu.
Definition: toolbar_gui.cpp:877
MenuClickSaveLoad
static CallBackFunction MenuClickSaveLoad(int index=0)
Handle click on one of the entries in the SaveLoad menu.
Definition: toolbar_gui.cpp:438
ToggleDirtyBlocks
void ToggleDirtyBlocks()
Toggle drawing of the dirty blocks.
Definition: toolbar_gui.cpp:1133
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:67
WidgetDimensions::dropdowntext
RectPadding dropdowntext
Offsets of text within a dropdown widget.
Definition: window_gui.h:57
TC_NO_SHADE
@ TC_NO_SHADE
Do not add shading to this text colour.
Definition: gfx_type.h:277
Rect::WithWidth
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
Definition: geometry_type.hpp:179
_networking
bool _networking
are we in networking mode?
Definition: network.cpp:58
ROADTYPE_ROAD
@ ROADTYPE_ROAD
Basic road type.
Definition: road_type.h:24
DrawSprite
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:1058
ToolbarScenDatePanel
static CallBackFunction ToolbarScenDatePanel(Window *w)
Called when clicking at the date panel of the scenario editor toolbar.
Definition: toolbar_gui.cpp:1198
LeagueTableID
uint8 LeagueTableID
ID of a league table.
Definition: league_type.h:32
road.h
MainToolbarWindow::FindWindowPlacementAndResize
void FindWindowPlacementAndResize(int def_width, int def_height) override
Resize window towards the default size.
Definition: toolbar_gui.cpp:2012
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
EconomySettings::found_town
TownFounding found_town
town founding.
Definition: settings_type.h:529
WID_TN_SUBSIDIES
@ WID_TN_SUBSIDIES
Subsidy menu.
Definition: toolbar_widget.h:21
CheckBlitter
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
Definition: gfxinit.cpp:334
league_base.h
NWidgetContainer::head
NWidgetBase * head
Pointer to first widget in container.
Definition: widget_type.h:420
NWidgetToolbarContainer::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: toolbar_gui.cpp:1381
date_func.h
ShowCheatWindow
void ShowCheatWindow()
Open cheat window.
Definition: cheat_gui.cpp:429
stdafx.h
ShowSaveLoadDialog
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
Definition: fios_gui.cpp:940
FT_SAVEGAME
@ FT_SAVEGAME
old or new savegame
Definition: fileio_type.h:18
MainToolbarWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: toolbar_gui.cpp:2146
DO_FULL_DETAIL
@ DO_FULL_DETAIL
Also draw details of track and roads.
Definition: openttd.h:49
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:116
RectPadding::Vertical
uint Vertical() const
Get total vertical padding of RectPadding.
Definition: geometry_type.hpp:65
ToggleBoundingBoxes
void ToggleBoundingBoxes()
Toggle drawing of sprites' bounding boxes.
Definition: toolbar_gui.cpp:1116
ScenarioEditorToolbarWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: toolbar_gui.cpp:2425
MenuClickCompany
static CallBackFunction MenuClickCompany(int index)
Handle click on the entry in the Company menu.
Definition: toolbar_gui.cpp:614
ShowGSConfigWindow
void ShowGSConfigWindow()
Open the GS config window.
Definition: game_gui.cpp:461
MainToolbarWindow
Main toolbar.
Definition: toolbar_gui.cpp:1995
WID_TN_ROADVEHS
@ WID_TN_ROADVEHS
Road vehicle menu.
Definition: toolbar_widget.h:32
viewport_func.h
NetworkCompanyIsPassworded
bool NetworkCompanyIsPassworded(CompanyID company_id)
Check if the company we want to join requires a password.
Definition: network.cpp:213
NWidgetBase::current_y
uint current_y
Current vertical size (after resizing).
Definition: widget_type.h:197
ToolbarScenBuildRoad
static CallBackFunction ToolbarScenBuildRoad(int index)
Handle click on the entry in the Build Road menu.
Definition: toolbar_gui.cpp:1270
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_type.h:335
WID_TE_SETTINGS
@ WID_TE_SETTINGS
Settings menu.
Definition: toolbar_widget.h:55
NWidgetBase::next
NWidgetBase * next
Pointer to next widget in container. Managed by parent container widget.
Definition: widget_type.h:202
WID_TN_AIRCRAFT
@ WID_TN_AIRCRAFT
Aircraft menu.
Definition: toolbar_widget.h:34
WidgetType
WidgetType
Window widget types, nested widget types, and nested widget part types.
Definition: widget_type.h:44
DrawCompanyIcon
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
Definition: company_cmd.cpp:147
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:993
ShowHighscoreTable
void ShowHighscoreTable(int difficulty=SP_CUSTOM, int8 rank=-1)
Show the highscore table for a given difficulty.
Definition: highscore_gui.cpp:234
WID_TE_SIGNS
@ WID_TE_SIGNS
Sign building.
Definition: toolbar_widget.h:71
MenuClickStory
static CallBackFunction MenuClickStory(int index)
Handle click on the entry in the Story menu.
Definition: toolbar_gui.cpp:650
ScenarioEditorToolbarWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: toolbar_gui.cpp:2526
NWidgetMainToolbarContainer
Container for the 'normal' main toolbar.
Definition: toolbar_gui.cpp:1518
rail_gui.h
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
WWT_PUSHIMGBTN
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:105
NWidgetBase::fill_y
uint fill_y
Vertical fill stepsize (from initial size, 0 means not resizable).
Definition: widget_type.h:187
MakeMainToolbar
static NWidgetBase * MakeMainToolbar(int *biggest_index)
Definition: toolbar_gui.cpp:2205
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:216
vehicle_func.h
WID_TE_HELP
@ WID_TE_HELP
Help menu.
Definition: toolbar_widget.h:74
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1096
GRMN_INCOME_GRAPH
static const int GRMN_INCOME_GRAPH
Show income graph.
Definition: toolbar_gui.cpp:683
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:77
Pool::PoolItem<&_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:386
strings_func.h
WID_TE_TREES
@ WID_TE_TREES
Tree building toolbar.
Definition: toolbar_widget.h:70
terraform_gui.h
ScenarioEditorToolbarWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: toolbar_gui.cpp:2520
MainToolbarWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: toolbar_gui.cpp:2017
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:408
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:1161
PC_VERY_DARK_RED
static const uint8 PC_VERY_DARK_RED
Almost-black red palette colour.
Definition: gfx_func.h:247
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:199
Pool::PoolItem<&_league_table_pool >::GetNumItems
static size_t GetNumItems()
Returns number of valid items in the pool.
Definition: pool_type.hpp:367
DeleteAllMessages
void DeleteAllMessages()
Delete all messages and close their corresponding window (if any).
Definition: window.cpp:3335
WIDGET_LIST_END
static const int WIDGET_LIST_END
indicate the end of widgets' list for vararg functions
Definition: widget_type.h:20
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:56
Window::SetWidgetsLoweredState
void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets,...)
Sets the lowered/raised status of a list of widgets.
Definition: window.cpp:579
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:206
ScenarioEditorToolbarWindow
Definition: toolbar_gui.cpp:2356
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1229
ShowTransparencyToolbar
void ShowTransparencyToolbar()
Show the transparency toolbar.
Definition: transparency_gui.cpp:161
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:186
GRMN_PERFORMANCE_HISTORY_GRAPH
static const int GRMN_PERFORMANCE_HISTORY_GRAPH
Show performance history graph.
Definition: toolbar_gui.cpp:685
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:3271
SetStartingYear
void SetStartingYear(Year year)
Set the starting year for a scenario.
Definition: toolbar_gui.cpp:1147
MenuClickGoal
static CallBackFunction MenuClickGoal(int index)
Handle click on the entry in the Goal menu.
Definition: toolbar_gui.cpp:670
WID_TN_SMALL_MAP
@ WID_TN_SMALL_MAP
Small map menu.
Definition: toolbar_widget.h:19
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
MenuClickBuildWater
static CallBackFunction MenuClickBuildWater(int index)
Handle click on the entry in the Build Waterways menu.
Definition: toolbar_gui.cpp:988
ShowLastNewsMessage
void ShowLastNewsMessage()
Show previous news item.
Definition: news_gui.cpp:1054
PM_PAUSED_NORMAL
@ PM_PAUSED_NORMAL
A game normally paused.
Definition: openttd.h:62
GRMN_DELIVERED_CARGO_GRAPH
static const int GRMN_DELIVERED_CARGO_GRAPH
Show delivered cargo graph.
Definition: toolbar_gui.cpp:684
Window::SetWidgetsDisabledState
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
Definition: window.cpp:560
WID_TN_TOWNS
@ WID_TN_TOWNS
Town menu.
Definition: toolbar_widget.h:20
MenuClickNewspaper
static CallBackFunction MenuClickNewspaper(int index)
Handle click on the entry in the Newspaper menu.
Definition: toolbar_gui.cpp:1080
NWidgetToolbarContainer
Full blown container to make it behave exactly as we want :)
Definition: toolbar_gui.cpp:1361
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:189
Window::IsWidgetLowered
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:422
ShowSmallMap
void ShowSmallMap()
Show the smallmap window.
Definition: smallmap_gui.cpp:1870
ShowAIDebugWindow
Window * ShowAIDebugWindow(CompanyID show_company)
Open the AI debug window and select the given company.
Definition: ai_gui.cpp:1469
MainToolbarWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: toolbar_gui.cpp:2032
EventState
EventState
State of handling an event.
Definition: window_type.h:719
HT_RECT
@ HT_RECT
rectangle (stations, depots, ...)
Definition: tilehighlight_type.h:21
transparency_gui.h
WID_TE_SMALL_MAP
@ WID_TE_SMALL_MAP
Small map menu.
Definition: toolbar_widget.h:61
DO_SHOW_SIGNS
@ DO_SHOW_SIGNS
Display signs.
Definition: openttd.h:47
news_gui.h
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:123
ScenarioEditorToolbarWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: toolbar_gui.cpp:2395
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:22
FT_HEIGHTMAP
@ FT_HEIGHTMAP
heightmap file
Definition: fileio_type.h:20
WID_TN_MESSAGES
@ WID_TN_MESSAGES
Messages menu.
Definition: toolbar_widget.h:45
SC_DEFAULTZOOM
@ SC_DEFAULTZOOM
Zoomed to default zoom level screenshot of the visible area.
Definition: screenshot.h:22
WC_MAIN_WINDOW
@ WC_MAIN_WINDOW
Main window; Window numbers:
Definition: window_type.h:44
GameCreationSettings::starting_year
Year starting_year
starting date
Definition: settings_type.h:313
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
MenuClickSettings
static CallBackFunction MenuClickSettings(int index)
Handle click on one of the entries in the Options button menu.
Definition: toolbar_gui.cpp:357
DO_SHOW_TOWN_NAMES
@ DO_SHOW_TOWN_NAMES
Display town names.
Definition: openttd.h:45
company_func.h
NWidgetScenarioToolbarContainer::panel_widths
uint panel_widths[2]
The width of the two panels (the text panel and date panel)
Definition: toolbar_gui.cpp:1841
WID_TN_INDUSTRIES
@ WID_TN_INDUSTRIES
Industry menu.
Definition: toolbar_widget.h:29
SetAlignment
static NWidgetPart SetAlignment(StringAlignment align)
Widget part function for setting the alignment of text/images.
Definition: widget_type.h:1064
NWidgetContainer
Baseclass for container widgets.
Definition: widget_type.h:405
TO_SIGNS
@ TO_SIGNS
signs
Definition: transparency.h:23
ShowLinkGraphLegend
void ShowLinkGraphLegend()
Open a link graph legend window.
Definition: linkgraph_gui.cpp:547
DEF_START_YEAR
static const Year DEF_START_YEAR
The default starting year.
Definition: date_type.h:87
GUITimer::Elapsed
bool Elapsed(uint delta)
Test if a timer has elapsed.
Definition: guitimer_func.h:55
network.h
_grfconfig
GRFConfig * _grfconfig
First item in list of current GRF set up.
Definition: newgrf_config.cpp:171
CommandHelper
Definition: command_func.h:94
MILLISECONDS_PER_TICK
static const uint MILLISECONDS_PER_TICK
The number of milliseconds per game tick.
Definition: gfx_type.h:316
window_func.h
WID_TE_FAST_FORWARD
@ WID_TE_FAST_FORWARD
Fast forward the game.
Definition: toolbar_widget.h:54
CenterBounds
static int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
Definition: gfx_func.h:178
MenuClickMusicWindow
static CallBackFunction MenuClickMusicWindow(int index)
Handle click on the entry in the Music menu.
Definition: toolbar_gui.cpp:1060
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition: gfx_type.h:344
ToggleBit
static T ToggleBit(T &x, const uint8 y)
Toggles a bit in a variable.
Definition: bitmath_func.hpp:181
Window::ToggleWidgetLoweredState
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
Definition: window_gui.h:392
SoundSettings::click_beep
bool click_beep
Beep on a random selection of buttons.
Definition: settings_type.h:217
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:386
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:248
CTMN_SPECTATOR
static const int CTMN_SPECTATOR
Show a company window as spectator.
Definition: toolbar_gui.cpp:215
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition: terraform_gui.cpp:371
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1767
WDP_MANUAL
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
Definition: window_gui.h:89
ToggleTransparency
static void ToggleTransparency(TransparencyOption to)
Toggle the transparency option bit.
Definition: transparency.h:69
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1191
SC_VIEWPORT
@ SC_VIEWPORT
Screenshot of viewport.
Definition: screenshot.h:19
MakeScreenshotWithConfirm
void MakeScreenshotWithConfirm(ScreenshotType t)
Make a screenshot.
Definition: screenshot.cpp:886
WID_TN_ZOOM_IN
@ WID_TN_ZOOM_IN
Zoom in the main viewport.
Definition: toolbar_widget.h:35
ROADTYPE_TRAM
@ ROADTYPE_TRAM
Trams.
Definition: road_type.h:25
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:200
ShowBuildRoadToolbar
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
Definition: road_gui.cpp:864
INVALID_COMPANY
@ INVALID_COMPANY
An invalid company.
Definition: company_type.h:30
engine_base.h
NWidgetMainToolbarContainer::GetButtonArrangement
const byte * GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override
Get the arrangement of the buttons for the toolbar.
Definition: toolbar_gui.cpp:1519
console_gui.h
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1080
MenuClickShowTrains
static CallBackFunction MenuClickShowTrains(int index)
Handle click on the entry in the Train menu.
Definition: toolbar_gui.cpp:817
WID_TE_SWITCH_BAR
@ WID_TE_SWITCH_BAR
Only available when toolbar has been split to switch between different subsets.
Definition: toolbar_widget.h:75
WID_TE_INDUSTRY
@ WID_TE_INDUSTRY
Industry building window.
Definition: toolbar_widget.h:66
gui.h
CeilDiv
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Definition: math_func.hpp:280
MenuClickStations
static CallBackFunction MenuClickStations(int index)
Handle click on the entry in the Stations menu.
Definition: toolbar_gui.cpp:574
Window
Data structure for an opened window.
Definition: window_gui.h:213
NWidgetToolbarContainer::spacers
uint spacers
Number of spacer widgets in this toolbar.
Definition: toolbar_gui.cpp:1364
GetRoadTypes
RoadTypes GetRoadTypes(bool introduces)
Get list of road types, regardless of company availability.
Definition: road.cpp:216
SizingType
SizingType
Different forms of sizing nested widgets, using NWidgetBase::AssignSizePosition()
Definition: widget_type.h:111
NWidgetToolbarContainer::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: toolbar_gui.cpp:1414
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:326
Window::RaiseWidget
void RaiseWidget(byte widget_index)
Marks a widget as raised.
Definition: window_gui.h:412
WID_TN_FAST_FORWARD
@ WID_TN_FAST_FORWARD
Fast forward the game.
Definition: toolbar_widget.h:16
SetObjectToPlace
void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowClass window_class, WindowNumber window_num)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
Definition: viewport.cpp:3386
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:858
WID_TN_SWITCH_BAR
@ WID_TN_SWITCH_BAR
Only available when toolbar has been split to switch between different subsets.
Definition: toolbar_widget.h:47
IConsoleSwitch
void IConsoleSwitch()
Toggle in-game console between opened and closed.
Definition: console_gui.cpp:396
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
WID_TE_TRAMS
@ WID_TE_TRAMS
Tram building menu.
Definition: toolbar_widget.h:68
Window::IsWidgetDisabled
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
Definition: window_gui.h:350
ScenarioEditorToolbarWindow::OnPlaceObject
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
Definition: toolbar_gui.cpp:2472
NWidgetCore
Base class for a 'real' widget.
Definition: widget_type.h:316
story_base.h
WKC_MINUS
@ WKC_MINUS
Definition: gfx_type.h:104
Window::SetWidgetDirty
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:621
ShowAIConfigWindow
void ShowAIConfigWindow()
Open the AI config window.
Definition: ai_gui.cpp:911
ShowCompany
void ShowCompany(CompanyID company)
Show the window with the overview of the company.
Definition: company_gui.cpp:2763
GUISettings::UserIsAllowedToChangeNewGRFs
bool UserIsAllowedToChangeNewGRFs() const
Returns true when the user has sufficient privileges to edit newgrfs on a running game.
Definition: settings_type.h:205
HandleZoomMessage
void HandleZoomMessage(Window *w, const Viewport *vp, byte widget_zoom_in, byte widget_zoom_out)
Update the status of the zoom-buttons according to the zoom-level of the viewport.
Definition: viewport.cpp:485
ScenarioEditorToolbarWindow::OnRealtimeTick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition: toolbar_gui.cpp:2499
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition: vehicle_type.h:26
ToolbarMode
ToolbarMode
Toobar modes.
Definition: toolbar_gui.cpp:74
ROADTYPES_NONE
@ ROADTYPES_NONE
No roadtypes.
Definition: road_type.h:37
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:69
ScenarioEditorToolbarWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: toolbar_gui.cpp:2492
WID_TE_MUSIC_SOUND
@ WID_TE_MUSIC_SOUND
Music/sound configuration menu.
Definition: toolbar_widget.h:73
WID_TN_VEHICLE_START
@ WID_TN_VEHICLE_START
Helper for the offset of the vehicle menus.
Definition: toolbar_widget.h:30
NWidgetBase::resize_x
uint resize_x
Horizontal resize step (0 means not resizable).
Definition: widget_type.h:188
WC_MAIN_TOOLBAR
@ WC_MAIN_TOOLBAR
Main toolbar (the long bar at the top); Window numbers:
Definition: window_type.h:51
ScenarioEditorToolbarWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: toolbar_gui.cpp:2376
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:50
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:196
DropDownListItem::masked
bool masked
Masked and unselectable item.
Definition: dropdown_type.h:25
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3434
NWidgetResizeBase::SetMinimalSize
void SetMinimalSize(uint min_x, uint min_y)
Set minimal size of the widget.
Definition: widget.cpp:1080
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:382
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition: gfx.cpp:42
NWidgetCore::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:1214
TD_RTL
@ TD_RTL
Text is written right-to-left by default.
Definition: strings_type.h:24
network_func.h
_current_text_dir
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:49
CS_NUMERAL
@ CS_NUMERAL
Only numeric ones.
Definition: string_type.h:28
WID_TN_TRAINS
@ WID_TN_TRAINS
Train menu.
Definition: toolbar_widget.h:31
_game_speed
uint16 _game_speed
Current game-speed; 100 is 1x, 0 is infinite.
Definition: gfx.cpp:40
DropDownListIconItem
List item with icon and string.
Definition: dropdown_type.h:82
MenuClickForest
static CallBackFunction MenuClickForest(int index)
Handle click on the entry in the landscaping menu.
Definition: toolbar_gui.cpp:1036
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:604
MenuClickBuildRoad
static CallBackFunction MenuClickBuildRoad(int index)
Handle click on the entry in the Build Road menu.
Definition: toolbar_gui.cpp:942
LTMN_HIGHSCORE
static const int LTMN_HIGHSCORE
Show highscrore table.
Definition: toolbar_gui.cpp:690
DropDownListCheckedItem
Drop down list entry for showing a checked/unchecked toggle item.
Definition: toolbar_gui.cpp:93
MainToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: toolbar_gui.cpp:2108
LTMN_PERFORMANCE_LEAGUE
static const int LTMN_PERFORMANCE_LEAGUE
Show default league table.
Definition: toolbar_gui.cpp:688
ShowEditorTerraformToolbar
Window * ShowEditorTerraformToolbar()
Show the toolbar for terraforming in the scenario editor.
Definition: terraform_gui.cpp:763
PopupMainCompanyToolbMenu
static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey=0)
Pop up a generic company list menu.
Definition: toolbar_gui.cpp:223
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:22
MainToolbarWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: toolbar_gui.cpp:2037
ShowBuildDocksToolbar
Window * ShowBuildDocksToolbar()
Open the build water toolbar window.
Definition: dock_gui.cpp:367
Window::FindWindowPlacementAndResize
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
Resize window towards the default size.
Definition: window.cpp:1472
hotkeys.h
cheat_func.h
ShowBuildRoadScenToolbar
Window * ShowBuildRoadScenToolbar(RoadType roadtype)
Show the road building toolbar in the scenario editor.
Definition: road_gui.cpp:951
MAX_YEAR
static const Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date,...
Definition: date_type.h:95
WID_TN_GRAPHS
@ WID_TN_GRAPHS
Graph menu.
Definition: toolbar_widget.h:27
NWidgetToolbarContainer::visible
bool visible[WID_TN_END]
The visible headers.
Definition: toolbar_gui.cpp:1362
WID_TN_RAILS
@ WID_TN_RAILS
Rail building menu.
Definition: toolbar_widget.h:38