OpenTTD Source: src/toolbar_gui.cpp Source File

OpenTTD Source 15.3

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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#include "stdafx.h"
11#include "core/geometry_func.hpp"
12#include "gui.h"
13#include "spritecache.h"
14#include "window_gui.h"
15#include "window_func.h"
16#include "viewport_func.h"
17#include "command_func.h"
18#include "dropdown_type.h"
19#include "dropdown_func.h"
20#include "house.h"
21#include "vehicle_gui.h"
22#include "rail_gui.h"
23#include "road.h"
24#include "road_gui.h"
25#include "vehicle_func.h"
26#include "sound_func.h"
27#include "terraform_gui.h"
28#include "strings_func.h"
29#include "company_func.h"
30#include "company_gui.h"
31#include "vehicle_base.h"
32#include "cheat_func.h"
33#include "transparency_gui.h"
34#include "screenshot.h"
35#include "signs_func.h"
36#include "fios.h"
37#include "console_gui.h"
38#include "news_gui.h"
39#include "ai/ai_gui.hpp"
40#include "game/game_gui.hpp"
41#include "script/script_gui.h"
42#include "tilehighlight_func.h"
43#include "smallmap_gui.h"
44#include "graph_gui.h"
45#include "textbuf_gui.h"
46#include "linkgraph/linkgraph_gui.h"
47#include "newgrf_debug.h"
48#include "hotkeys.h"
49#include "engine_base.h"
50#include "highscore.h"
51#include "game/game.hpp"
52#include "goal_base.h"
53#include "story_base.h"
54#include "toolbar_gui.h"
55#include "framerate_type.h"
56#include "screenshot_gui.h"
57#include "misc_cmd.h"
58#include "league_gui.h"
59#include "league_base.h"
60#include "timer/timer.h"
61#include "timer/timer_window.h"
62#include "timer/timer_game_calendar.h"
63#include "help_gui.h"
64#include "core/string_consumer.hpp"
65
66#include "widgets/toolbar_widget.h"
67
68#include "network/network.h"
69#include "network/network_gui.h"
70#include "network/network_func.h"
71
72#include "table/strings.h"
73
74#include "dropdown_common_type.h"
75
76#include "safeguards.h"
77
78
80uint _toolbar_width = 0;
81
82 RailType _last_built_railtype;
83 RoadType _last_built_roadtype;
84 RoadType _last_built_tramtype;
85
87 enum ToolbarMode : uint8_t {
88 TB_NORMAL,
89 TB_UPPER,
90 TB_LOWER
91};
92
94 enum CallBackFunction : uint8_t {
95 CBF_NONE,
96 CBF_PLACE_SIGN,
97 CBF_PLACE_LANDINFO,
98};
99
100 static CallBackFunction _last_started_action = CBF_NONE;
101
105 class DropDownListCompanyItem : public DropDownIcon<DropDownIcon<DropDownString<DropDownListItem>, true>> {
106public:
107 DropDownListCompanyItem(CompanyID company, bool shaded) : DropDownIcon<DropDownIcon<DropDownString<DropDownListItem>, true>>(SPR_COMPANY_ICON, GetCompanyPalette(company), NetworkCanJoinCompany(company) ? SPR_EMPTY : SPR_LOCK, PAL_NONE, GetString(STR_COMPANY_NAME_COMPANY_NUM, company, company), company.base(), false, shaded)
108 {
109 }
110};
111
112static DropDownOptions GetToolbarDropDownOptions()
113{
114 if (_settings_client.gui.toolbar_dropdown_autoselect) return DropDownOption::InstantClose;
115 return {};
116}
117
125 static void PopupMainToolbarMenu(Window *w, WidgetID widget, DropDownList &&list, int def)
126{
127 ShowDropDownList(w, std::move(list), def, widget, 0, GetToolbarDropDownOptions());
128}
129
136 static void PopupMainToolbarMenu(Window *w, WidgetID widget, const std::initializer_list<StringID> &strings)
137{
138 DropDownList list;
139 int i = 0;
140 for (StringID string : strings) {
141 if (string == STR_NULL) {
142 list.push_back(MakeDropDownListDividerItem());
143 } else {
144 list.push_back(MakeDropDownListStringItem(string, i));
145 i++;
146 }
147 }
148 PopupMainToolbarMenu(w, widget, std::move(list), 0);
149}
150
152 static const int CTMN_CLIENT_LIST = -1;
153 static const int CTMN_SPECTATE = -2;
154 static const int CTMN_SPECTATOR = -3;
155
162 static void PopupMainCompanyToolbMenu(Window *w, WidgetID widget, CompanyMask grey = {})
163{
164 DropDownList list;
165
166 switch (widget) {
167 case WID_TN_COMPANIES:
168 if (!_networking) break;
169
170 /* Add the client list button for the companies menu */
171 list.push_back(MakeDropDownListStringItem(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, CTMN_CLIENT_LIST));
172
173 if (_local_company != COMPANY_SPECTATOR) {
174 list.push_back(MakeDropDownListStringItem(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE));
175 }
176 break;
177 case WID_TN_STORY:
178 list.push_back(MakeDropDownListStringItem(STR_STORY_BOOK_SPECTATOR, CTMN_SPECTATOR));
179 break;
180
181 case WID_TN_GOAL:
182 list.push_back(MakeDropDownListStringItem(STR_GOALS_SPECTATOR, CTMN_SPECTATOR));
183 break;
184 }
185
186 for (CompanyID c = CompanyID::Begin(); c < MAX_COMPANIES; ++c) {
187 if (!Company::IsValidID(c)) continue;
188 list.push_back(std::make_unique<DropDownListCompanyItem>(c, grey.Test(c)));
189 }
190
191 PopupMainToolbarMenu(w, widget, std::move(list), _local_company == COMPANY_SPECTATOR ? (widget == WID_TN_COMPANIES ? CTMN_CLIENT_LIST : CTMN_SPECTATOR) : _local_company.base());
192}
193
194static ToolbarMode _toolbar_mode;
195
196static CallBackFunction SelectSignTool()
197{
198 if (_last_started_action == CBF_PLACE_SIGN) {
199 ResetObjectToPlace();
200 return CBF_NONE;
201 } else {
202 SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, HT_RECT, WC_MAIN_TOOLBAR, 0);
203 return CBF_PLACE_SIGN;
204 }
205}
206
207/* --- Pausing --- */
208
209static CallBackFunction ToolbarPauseClick(Window *)
210{
211 if (_networking && !_network_server) return CBF_NONE; // only server can pause the game
212
213 if (Command<CMD_PAUSE>::Post(PauseMode::Normal, _pause_mode.None())) {
214 SndConfirmBeep();
215 }
216 return CBF_NONE;
217}
218
224 static CallBackFunction ToolbarFastForwardClick(Window *)
225{
226 if (_networking) return CBF_NONE; // no fast forward in network game
227
228 ChangeGameSpeed(_game_speed == 100);
229
230 SndClickBeep();
231 return CBF_NONE;
232}
233
237 enum OptionMenuEntries : uint8_t {
238 OME_GAMEOPTIONS,
239 OME_AI_SETTINGS,
240 OME_GAMESCRIPT_SETTINGS,
241 OME_NEWGRFSETTINGS,
242 OME_SANDBOX,
243 OME_TRANSPARENCIES,
244 OME_SHOW_TOWNNAMES,
245 OME_SHOW_STATIONNAMES,
246 OME_SHOW_STATIONNAMES_TRAIN,
247 OME_SHOW_STATIONNAMES_LORRY,
248 OME_SHOW_STATIONNAMES_BUS,
249 OME_SHOW_STATIONNAMES_SHIP,
250 OME_SHOW_STATIONNAMES_PLANE,
251 OME_SHOW_STATIONNAMES_GHOST,
252 OME_SHOW_WAYPOINTNAMES,
253 OME_SHOW_SIGNS,
254 OME_SHOW_COMPETITOR_SIGNS,
255 OME_FULL_ANIMATION,
256 OME_FULL_DETAILS,
257 OME_TRANSPARENTBUILDINGS,
258 OME_SHOW_STATIONSIGNS,
259};
260
267 static CallBackFunction ToolbarOptionsClick(Window *w)
268{
269 DropDownList list;
270 list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_GAME_OPTIONS, OME_GAMEOPTIONS));
271 /* Changes to the per-AI settings don't get send from the server to the clients. Clients get
272 * the settings once they join but never update it. As such don't show the window at all
273 * to network clients. */
274 if (!_networking || _network_server) {
275 list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_AI_SETTINGS, OME_AI_SETTINGS));
276 list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_GAMESCRIPT_SETTINGS, OME_GAMESCRIPT_SETTINGS));
277 }
278 list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_NEWGRF_SETTINGS, OME_NEWGRFSETTINGS));
279 if (_game_mode != GM_EDITOR && !_networking) {
280 list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_SANDBOX_OPTIONS, OME_SANDBOX));
281 }
282 list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS, OME_TRANSPARENCIES));
283 list.push_back(MakeDropDownListDividerItem());
284 list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_SHOW_TOWN_NAMES), STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED, OME_SHOW_TOWNNAMES));
285 list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_SHOW_STATION_NAMES), STR_SETTINGS_MENU_STATION_NAMES_DISPLAYED, OME_SHOW_STATIONNAMES));
286 list.push_back(MakeDropDownListCheckedItem(_facility_display_opt.Test(StationFacility::Train), STR_SETTINGS_MENU_STATION_NAMES_TRAIN, OME_SHOW_STATIONNAMES_TRAIN, false, false, 1));
287 list.push_back(MakeDropDownListCheckedItem(_facility_display_opt.Test(StationFacility::TruckStop), STR_SETTINGS_MENU_STATION_NAMES_LORRY, OME_SHOW_STATIONNAMES_LORRY, false, false, 1));
288 list.push_back(MakeDropDownListCheckedItem(_facility_display_opt.Test(StationFacility::BusStop), STR_SETTINGS_MENU_STATION_NAMES_BUS, OME_SHOW_STATIONNAMES_BUS, false, false, 1));
289 list.push_back(MakeDropDownListCheckedItem(_facility_display_opt.Test(StationFacility::Dock), STR_SETTINGS_MENU_STATION_NAMES_SHIP, OME_SHOW_STATIONNAMES_SHIP, false, false, 1));
290 list.push_back(MakeDropDownListCheckedItem(_facility_display_opt.Test(StationFacility::Airport), STR_SETTINGS_MENU_STATION_NAMES_PLANE, OME_SHOW_STATIONNAMES_PLANE, false, false, 1));
291 list.push_back(MakeDropDownListCheckedItem(_facility_display_opt.Test(STATION_FACILITY_GHOST), STR_SETTINGS_MENU_STATION_NAMES_GHOST, OME_SHOW_STATIONNAMES_GHOST, false, false, 1));
292 list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES), STR_SETTINGS_MENU_WAYPOINTS_DISPLAYED, OME_SHOW_WAYPOINTNAMES));
293 list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_SHOW_SIGNS), STR_SETTINGS_MENU_SIGNS_DISPLAYED, OME_SHOW_SIGNS));
294 list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS), STR_SETTINGS_MENU_SHOW_COMPETITOR_SIGNS, OME_SHOW_COMPETITOR_SIGNS));
295 list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_FULL_ANIMATION), STR_SETTINGS_MENU_FULL_ANIMATION, OME_FULL_ANIMATION));
296 list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_FULL_DETAIL), STR_SETTINGS_MENU_FULL_DETAIL, OME_FULL_DETAILS));
297 list.push_back(MakeDropDownListCheckedItem(IsTransparencySet(TO_HOUSES), STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS));
298 list.push_back(MakeDropDownListCheckedItem(IsTransparencySet(TO_SIGNS), STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS));
299
300 ShowDropDownList(w, std::move(list), 0, WID_TN_SETTINGS, 140, GetToolbarDropDownOptions());
301 return CBF_NONE;
302}
303
310 static CallBackFunction MenuClickSettings(int index)
311{
312 switch (index) {
313 case OME_GAMEOPTIONS: ShowGameOptions(); return CBF_NONE;
314 case OME_AI_SETTINGS: ShowAIConfigWindow(); return CBF_NONE;
315 case OME_GAMESCRIPT_SETTINGS: ShowGSConfigWindow(); return CBF_NONE;
316 case OME_NEWGRFSETTINGS: ShowNewGRFSettings(!_networking && _settings_client.gui.UserIsAllowedToChangeNewGRFs(), true, true, _grfconfig); return CBF_NONE;
317 case OME_SANDBOX: ShowCheatWindow(); break;
318 case OME_TRANSPARENCIES: ShowTransparencyToolbar(); break;
319
320 case OME_SHOW_TOWNNAMES: ToggleBit(_display_opt, DO_SHOW_TOWN_NAMES); break;
321 case OME_SHOW_STATIONNAMES: ToggleBit(_display_opt, DO_SHOW_STATION_NAMES); break;
322 case OME_SHOW_STATIONNAMES_TRAIN: _facility_display_opt.Flip(StationFacility::Train); break;
323 case OME_SHOW_STATIONNAMES_LORRY: _facility_display_opt.Flip(StationFacility::TruckStop); break;
324 case OME_SHOW_STATIONNAMES_BUS: _facility_display_opt.Flip(StationFacility::BusStop); break;
325 case OME_SHOW_STATIONNAMES_SHIP: _facility_display_opt.Flip(StationFacility::Dock); break;
326 case OME_SHOW_STATIONNAMES_PLANE: _facility_display_opt.Flip(StationFacility::Airport); break;
327 case OME_SHOW_STATIONNAMES_GHOST: _facility_display_opt.Flip(STATION_FACILITY_GHOST); break;
328 case OME_SHOW_WAYPOINTNAMES: ToggleBit(_display_opt, DO_SHOW_WAYPOINT_NAMES); break;
329 case OME_SHOW_SIGNS: ToggleBit(_display_opt, DO_SHOW_SIGNS); break;
330 case OME_SHOW_COMPETITOR_SIGNS:
331 ToggleBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS);
332 InvalidateWindowClassesData(WC_SIGN_LIST, -1);
333 break;
334 case OME_FULL_ANIMATION: ToggleBit(_display_opt, DO_FULL_ANIMATION); CheckBlitter(); break;
335 case OME_FULL_DETAILS: ToggleBit(_display_opt, DO_FULL_DETAIL); break;
336 case OME_TRANSPARENTBUILDINGS: ToggleTransparency(TO_HOUSES); break;
337 case OME_SHOW_STATIONSIGNS: ToggleTransparency(TO_SIGNS); break;
338 }
339 MarkWholeScreenDirty();
340 return CBF_NONE;
341}
342
346 enum SaveLoadEditorMenuEntries : uint8_t {
347 SLEME_SAVE_SCENARIO = 0,
348 SLEME_LOAD_SCENARIO,
349 SLEME_SAVE_HEIGHTMAP,
350 SLEME_LOAD_HEIGHTMAP,
351 SLEME_EXIT_TOINTRO,
352 SLEME_EXIT_GAME,
353};
354
358 enum SaveLoadNormalMenuEntries : uint8_t {
359 SLNME_SAVE_GAME = 0,
360 SLNME_LOAD_GAME,
361 SLNME_EXIT_TOINTRO,
362 SLNME_EXIT_GAME,
363};
364
371 static CallBackFunction ToolbarSaveClick(Window *w)
372{
373 PopupMainToolbarMenu(w, WID_TN_SAVE, {STR_FILE_MENU_SAVE_GAME, STR_FILE_MENU_LOAD_GAME, STR_FILE_MENU_QUIT_GAME,
374 STR_NULL, STR_FILE_MENU_EXIT});
375 return CBF_NONE;
376}
377
384 static CallBackFunction ToolbarScenSaveOrLoad(Window *w)
385{
386 PopupMainToolbarMenu(w, WID_TE_SAVE, {STR_SCENEDIT_FILE_MENU_SAVE_SCENARIO, STR_SCENEDIT_FILE_MENU_LOAD_SCENARIO,
387 STR_SCENEDIT_FILE_MENU_SAVE_HEIGHTMAP, STR_SCENEDIT_FILE_MENU_LOAD_HEIGHTMAP,
388 STR_SCENEDIT_FILE_MENU_QUIT_EDITOR, STR_NULL, STR_SCENEDIT_FILE_MENU_QUIT});
389 return CBF_NONE;
390}
391
398 static CallBackFunction MenuClickSaveLoad(int index = 0)
399{
400 if (_game_mode == GM_EDITOR) {
401 switch (index) {
402 case SLEME_SAVE_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_SAVE); break;
403 case SLEME_LOAD_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_LOAD); break;
404 case SLEME_SAVE_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP, SLO_SAVE); break;
405 case SLEME_LOAD_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP, SLO_LOAD); break;
406 case SLEME_EXIT_TOINTRO: AskExitToGameMenu(); break;
407 case SLEME_EXIT_GAME: HandleExitGameRequest(); break;
408 }
409 } else {
410 switch (index) {
411 case SLNME_SAVE_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_SAVE); break;
412 case SLNME_LOAD_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break;
413 case SLNME_EXIT_TOINTRO: AskExitToGameMenu(); break;
414 case SLNME_EXIT_GAME: HandleExitGameRequest(); break;
415 }
416 }
417 return CBF_NONE;
418}
419
420/* --- Map button menu --- */
421
422enum MapMenuEntries : uint8_t {
423 MME_SHOW_SMALLMAP = 0,
424 MME_SHOW_EXTRAVIEWPORTS,
425 MME_SHOW_LINKGRAPH,
426 MME_SHOW_SIGNLISTS,
427 MME_SHOW_TOWNDIRECTORY,
428 MME_SHOW_INDUSTRYDIRECTORY,
429};
430
431static CallBackFunction ToolbarMapClick(Window *w)
432{
433 DropDownList list;
434 list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP));
435 list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_EXTRA_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS));
436 list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_LINGRAPH_LEGEND, MME_SHOW_LINKGRAPH));
437 list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS));
438 PopupMainToolbarMenu(w, WID_TN_SMALL_MAP, std::move(list), 0);
439 return CBF_NONE;
440}
441
442static CallBackFunction ToolbarScenMapTownDir(Window *w)
443{
444 DropDownList list;
445 list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP));
446 list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_EXTRA_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS));
447 list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS));
448 list.push_back(MakeDropDownListStringItem(STR_TOWN_MENU_TOWN_DIRECTORY, MME_SHOW_TOWNDIRECTORY));
449 list.push_back(MakeDropDownListStringItem(STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, MME_SHOW_INDUSTRYDIRECTORY));
450 PopupMainToolbarMenu(w, WID_TE_SMALL_MAP, std::move(list), 0);
451 return CBF_NONE;
452}
453
460 static CallBackFunction MenuClickMap(int index)
461{
462 switch (index) {
463 case MME_SHOW_SMALLMAP: ShowSmallMap(); break;
464 case MME_SHOW_EXTRAVIEWPORTS: ShowExtraViewportWindow(); break;
465 case MME_SHOW_LINKGRAPH: ShowLinkGraphLegend(); break;
466 case MME_SHOW_SIGNLISTS: ShowSignList(); break;
467 case MME_SHOW_TOWNDIRECTORY: ShowTownDirectory(); break;
468 case MME_SHOW_INDUSTRYDIRECTORY: ShowIndustryDirectory(); break;
469 }
470 return CBF_NONE;
471}
472
473/* --- Town button menu --- */
474
475enum TownMenuEntries {
476 TME_SHOW_DIRECTORY = 0,
477 TME_SHOW_FOUND_TOWN,
478 TME_SHOW_PLACE_HOUSES,
479};
480
481static CallBackFunction ToolbarTownClick(Window *w)
482{
483 DropDownList list;
484 list.push_back(MakeDropDownListStringItem(STR_TOWN_MENU_TOWN_DIRECTORY, TME_SHOW_DIRECTORY));
485 if (_settings_game.economy.found_town != TF_FORBIDDEN) list.push_back(MakeDropDownListStringItem(STR_TOWN_MENU_FOUND_TOWN, TME_SHOW_FOUND_TOWN));
486 if (_settings_game.economy.place_houses != PH_FORBIDDEN) list.push_back(MakeDropDownListStringItem(STR_SCENEDIT_TOWN_MENU_PACE_HOUSE, TME_SHOW_PLACE_HOUSES));
487
488 PopupMainToolbarMenu(w, WID_TN_TOWNS, std::move(list), 0);
489
490 return CBF_NONE;
491}
492
499 static CallBackFunction MenuClickTown(int index)
500{
501 switch (index) {
502 case TME_SHOW_DIRECTORY: ShowTownDirectory(); break;
503 case TME_SHOW_FOUND_TOWN: // Setting could be changed when the dropdown was open
504 if (_settings_game.economy.found_town != TF_FORBIDDEN) ShowFoundTownWindow();
505 break;
506 case TME_SHOW_PLACE_HOUSES: // Setting could be changed when the dropdown was open
507 if (_settings_game.economy.place_houses != PH_FORBIDDEN) ShowBuildHousePicker(nullptr);
508 break;
509 }
510 return CBF_NONE;
511}
512
513/* --- Subidies button menu --- */
514
515static CallBackFunction ToolbarSubsidiesClick(Window *w)
516{
517 PopupMainToolbarMenu(w, WID_TN_SUBSIDIES, {STR_SUBSIDIES_MENU_SUBSIDIES});
518 return CBF_NONE;
519}
520
526 static CallBackFunction MenuClickSubsidies(int)
527{
528 ShowSubsidiesList();
529 return CBF_NONE;
530}
531
532/* --- Stations button menu --- */
533
534static CallBackFunction ToolbarStationsClick(Window *w)
535{
536 PopupMainCompanyToolbMenu(w, WID_TN_STATIONS);
537 return CBF_NONE;
538}
539
546 static CallBackFunction MenuClickStations(int index)
547{
548 ShowCompanyStations((CompanyID)index);
549 return CBF_NONE;
550}
551
552/* --- Finances button menu --- */
553
554static CallBackFunction ToolbarFinancesClick(Window *w)
555{
556 PopupMainCompanyToolbMenu(w, WID_TN_FINANCES);
557 return CBF_NONE;
558}
559
566 static CallBackFunction MenuClickFinances(int index)
567{
568 ShowCompanyFinances((CompanyID)index);
569 return CBF_NONE;
570}
571
572/* --- Company's button menu --- */
573
574static CallBackFunction ToolbarCompaniesClick(Window *w)
575{
576 PopupMainCompanyToolbMenu(w, WID_TN_COMPANIES);
577 return CBF_NONE;
578}
579
586 static CallBackFunction MenuClickCompany(int index)
587{
588 if (_networking) {
589 switch (index) {
590 case CTMN_CLIENT_LIST:
591 ShowClientList();
592 return CBF_NONE;
593
594 case CTMN_SPECTATE:
595 if (_network_server) {
596 NetworkServerDoMove(CLIENT_ID_SERVER, COMPANY_SPECTATOR);
597 MarkWholeScreenDirty();
598 } else {
599 NetworkClientRequestMove(COMPANY_SPECTATOR);
600 }
601 return CBF_NONE;
602 }
603 }
604 ShowCompany((CompanyID)index);
605 return CBF_NONE;
606}
607
608/* --- Story button menu --- */
609
610static CallBackFunction ToolbarStoryClick(Window *w)
611{
612 PopupMainCompanyToolbMenu(w, WID_TN_STORY);
613 return CBF_NONE;
614}
615
622 static CallBackFunction MenuClickStory(int index)
623{
624 ShowStoryBook(index == CTMN_SPECTATOR ? CompanyID::Invalid() : (CompanyID)index);
625 return CBF_NONE;
626}
627
628/* --- Goal button menu --- */
629
630static CallBackFunction ToolbarGoalClick(Window *w)
631{
632 PopupMainCompanyToolbMenu(w, WID_TN_GOAL);
633 return CBF_NONE;
634}
635
642 static CallBackFunction MenuClickGoal(int index)
643{
644 ShowGoalsList(index == CTMN_SPECTATOR ? CompanyID::Invalid() : (CompanyID)index);
645 return CBF_NONE;
646}
647
648/* --- Graphs and League Table button menu --- */
649
654 static const int GRMN_OPERATING_PROFIT_GRAPH = -1;
655 static const int GRMN_INCOME_GRAPH = -2;
656 static const int GRMN_DELIVERED_CARGO_GRAPH = -3;
657 static const int GRMN_PERFORMANCE_HISTORY_GRAPH = -4;
658 static const int GRMN_COMPANY_VALUE_GRAPH = -5;
659 static const int GRMN_CARGO_PAYMENT_RATES = -6;
660 static const int LTMN_PERFORMANCE_LEAGUE = -7;
661 static const int LTMN_PERFORMANCE_RATING = -8;
662 static const int LTMN_HIGHSCORE = -9;
663
664static void AddDropDownLeagueTableOptions(DropDownList &list)
665{
666 if (LeagueTable::GetNumItems() > 0) {
667 for (LeagueTable *lt : LeagueTable::Iterate()) {
668 list.push_back(MakeDropDownListStringItem(lt->title.GetDecodedString(), lt->index.base()));
669 }
670 } else {
671 list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_COMPANY_LEAGUE_TABLE, LTMN_PERFORMANCE_LEAGUE));
672 list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_DETAILED_PERFORMANCE_RATING, LTMN_PERFORMANCE_RATING));
673 if (!_networking) {
674 list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_HIGHSCORE, LTMN_HIGHSCORE));
675 }
676 }
677}
678
679static CallBackFunction ToolbarGraphsClick(Window *w)
680{
681 DropDownList list;
682
683 list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_OPERATING_PROFIT_GRAPH, GRMN_OPERATING_PROFIT_GRAPH));
684 list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_INCOME_GRAPH, GRMN_INCOME_GRAPH));
685 list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_DELIVERED_CARGO_GRAPH, GRMN_DELIVERED_CARGO_GRAPH));
686 list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_PERFORMANCE_HISTORY_GRAPH, GRMN_PERFORMANCE_HISTORY_GRAPH));
687 list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_COMPANY_VALUE_GRAPH, GRMN_COMPANY_VALUE_GRAPH));
688 list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_CARGO_PAYMENT_RATES, GRMN_CARGO_PAYMENT_RATES));
689
690 if (_toolbar_mode != TB_NORMAL) AddDropDownLeagueTableOptions(list);
691
692 ShowDropDownList(w, std::move(list), GRMN_OPERATING_PROFIT_GRAPH, WID_TN_GRAPHS, 140, GetToolbarDropDownOptions());
693 return CBF_NONE;
694}
695
696static CallBackFunction ToolbarLeagueClick(Window *w)
697{
698 DropDownList list;
699
700 AddDropDownLeagueTableOptions(list);
701
702 int selected = list[0]->result;
703 ShowDropDownList(w, std::move(list), selected, WID_TN_LEAGUE, 140, GetToolbarDropDownOptions());
704 return CBF_NONE;
705}
706
713 static CallBackFunction MenuClickGraphsOrLeague(int index)
714{
715 switch (index) {
716 case GRMN_OPERATING_PROFIT_GRAPH: ShowOperatingProfitGraph(); break;
717 case GRMN_INCOME_GRAPH: ShowIncomeGraph(); break;
718 case GRMN_DELIVERED_CARGO_GRAPH: ShowDeliveredCargoGraph(); break;
719 case GRMN_PERFORMANCE_HISTORY_GRAPH: ShowPerformanceHistoryGraph(); break;
720 case GRMN_COMPANY_VALUE_GRAPH: ShowCompanyValueGraph(); break;
721 case GRMN_CARGO_PAYMENT_RATES: ShowCargoPaymentRates(); break;
722 case LTMN_PERFORMANCE_LEAGUE: ShowPerformanceLeagueTable(); break;
723 case LTMN_PERFORMANCE_RATING: ShowPerformanceRatingDetail(); break;
724 case LTMN_HIGHSCORE: ShowHighscoreTable(); break;
725 default: {
726 if (LeagueTable::IsValidID(index)) {
727 ShowScriptLeagueTable((LeagueTableID)index);
728 }
729 }
730 }
731 return CBF_NONE;
732}
733
734
735
736/* --- Industries button menu --- */
737
738static CallBackFunction ToolbarIndustryClick(Window *w)
739{
740 /* Disable build-industry menu if we are a spectator */
741 if (_local_company == COMPANY_SPECTATOR) {
742 PopupMainToolbarMenu(w, WID_TN_INDUSTRIES, {STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, STR_INDUSTRY_MENU_INDUSTRY_CHAIN});
743 } else {
744 PopupMainToolbarMenu(w, WID_TN_INDUSTRIES, {STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, STR_INDUSTRY_MENU_INDUSTRY_CHAIN, STR_INDUSTRY_MENU_FUND_NEW_INDUSTRY});
745 }
746 return CBF_NONE;
747}
748
755 static CallBackFunction MenuClickIndustry(int index)
756{
757 switch (index) {
758 case 0: ShowIndustryDirectory(); break;
759 case 1: ShowIndustryCargoesWindow(); break;
760 case 2: ShowBuildIndustryWindow(); break;
761 }
762 return CBF_NONE;
763}
764
765/* --- Trains button menu + 1 helper function for all vehicles. --- */
766
767static void ToolbarVehicleClick(Window *w, VehicleType veh)
768{
769 CompanyMask dis{};
770
771 for (const Company *c : Company::Iterate()) {
772 if (c->group_all[veh].num_vehicle == 0) dis.Set(c->index);
773 }
774 PopupMainCompanyToolbMenu(w, WID_TN_VEHICLE_START + veh, dis);
775}
776
777
778static CallBackFunction ToolbarTrainClick(Window *w)
779{
780 ToolbarVehicleClick(w, VEH_TRAIN);
781 return CBF_NONE;
782}
783
790 static CallBackFunction MenuClickShowTrains(int index)
791{
792 ShowVehicleListWindow((CompanyID)index, VEH_TRAIN);
793 return CBF_NONE;
794}
795
796/* --- Road vehicle button menu --- */
797
798static CallBackFunction ToolbarRoadClick(Window *w)
799{
800 ToolbarVehicleClick(w, VEH_ROAD);
801 return CBF_NONE;
802}
803
810 static CallBackFunction MenuClickShowRoad(int index)
811{
812 ShowVehicleListWindow((CompanyID)index, VEH_ROAD);
813 return CBF_NONE;
814}
815
816/* --- Ship button menu --- */
817
818static CallBackFunction ToolbarShipClick(Window *w)
819{
820 ToolbarVehicleClick(w, VEH_SHIP);
821 return CBF_NONE;
822}
823
830 static CallBackFunction MenuClickShowShips(int index)
831{
832 ShowVehicleListWindow((CompanyID)index, VEH_SHIP);
833 return CBF_NONE;
834}
835
836/* --- Aircraft button menu --- */
837
838static CallBackFunction ToolbarAirClick(Window *w)
839{
840 ToolbarVehicleClick(w, VEH_AIRCRAFT);
841 return CBF_NONE;
842}
843
850 static CallBackFunction MenuClickShowAir(int index)
851{
852 ShowVehicleListWindow((CompanyID)index, VEH_AIRCRAFT);
853 return CBF_NONE;
854}
855
856/* --- Zoom in button --- */
857
858static CallBackFunction ToolbarZoomInClick(Window *w)
859{
860 if (DoZoomInOutWindow(ZOOM_IN, GetMainWindow())) {
861 w->HandleButtonClick((_game_mode == GM_EDITOR) ? (WidgetID)WID_TE_ZOOM_IN : (WidgetID)WID_TN_ZOOM_IN);
862 }
863 return CBF_NONE;
864}
865
866/* --- Zoom out button --- */
867
868static CallBackFunction ToolbarZoomOutClick(Window *w)
869{
870 if (DoZoomInOutWindow(ZOOM_OUT, GetMainWindow())) {
871 w->HandleButtonClick((_game_mode == GM_EDITOR) ? (WidgetID)WID_TE_ZOOM_OUT : (WidgetID)WID_TN_ZOOM_OUT);
872 }
873 return CBF_NONE;
874}
875
876/* --- Rail button menu --- */
877
878static CallBackFunction ToolbarBuildRailClick(Window *w)
879{
880 ShowDropDownList(w, GetRailTypeDropDownList(), _last_built_railtype, WID_TN_RAILS, 140, GetToolbarDropDownOptions());
881 return CBF_NONE;
882}
883
890 static CallBackFunction MenuClickBuildRail(int index)
891{
892 _last_built_railtype = (RailType)index;
893 ShowBuildRailToolbar(_last_built_railtype);
894 return CBF_NONE;
895}
896
897/* --- Road button menu --- */
898
899static CallBackFunction ToolbarBuildRoadClick(Window *w)
900{
901 ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TN_ROADS, 140, GetToolbarDropDownOptions());
902 return CBF_NONE;
903}
904
911 static CallBackFunction MenuClickBuildRoad(int index)
912{
913 _last_built_roadtype = (RoadType)index;
914 ShowBuildRoadToolbar(_last_built_roadtype);
915 return CBF_NONE;
916}
917
918/* --- Tram button menu --- */
919
920static CallBackFunction ToolbarBuildTramClick(Window *w)
921{
922 ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TN_TRAMS, 140, GetToolbarDropDownOptions());
923 return CBF_NONE;
924}
925
932 static CallBackFunction MenuClickBuildTram(int index)
933{
934 _last_built_tramtype = (RoadType)index;
935 ShowBuildRoadToolbar(_last_built_tramtype);
936 return CBF_NONE;
937}
938
939/* --- Water button menu --- */
940
941static CallBackFunction ToolbarBuildWaterClick(Window *w)
942{
943 DropDownList list;
944 list.push_back(MakeDropDownListIconItem(SPR_IMG_BUILD_CANAL, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 0));
945 ShowDropDownList(w, std::move(list), 0, WID_TN_WATER, 140, GetToolbarDropDownOptions());
946 return CBF_NONE;
947}
948
954 static CallBackFunction MenuClickBuildWater(int)
955{
956 ShowBuildDocksToolbar();
957 return CBF_NONE;
958}
959
960/* --- Airport button menu --- */
961
962static CallBackFunction ToolbarBuildAirClick(Window *w)
963{
964 DropDownList list;
965 list.push_back(MakeDropDownListIconItem(SPR_IMG_AIRPORT, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 0));
966 ShowDropDownList(w, std::move(list), 0, WID_TN_AIR, 140, GetToolbarDropDownOptions());
967 return CBF_NONE;
968}
969
975 static CallBackFunction MenuClickBuildAir(int)
976{
977 ShowBuildAirToolbar();
978 return CBF_NONE;
979}
980
981/* --- Forest button menu --- */
982
983static CallBackFunction ToolbarForestClick(Window *w)
984{
985 DropDownList list;
986 list.push_back(MakeDropDownListIconItem(SPR_IMG_LANDSCAPING, PAL_NONE, STR_LANDSCAPING_MENU_LANDSCAPING, 0));
987 list.push_back(MakeDropDownListIconItem(SPR_IMG_PLANTTREES, PAL_NONE, STR_LANDSCAPING_MENU_PLANT_TREES, 1));
988 list.push_back(MakeDropDownListIconItem(SPR_IMG_SIGN, PAL_NONE, STR_LANDSCAPING_MENU_PLACE_SIGN, 2));
989 ShowDropDownList(w, std::move(list), 0, WID_TN_LANDSCAPE, 100, GetToolbarDropDownOptions());
990 return CBF_NONE;
991}
992
999 static CallBackFunction MenuClickForest(int index)
1000{
1001 switch (index) {
1002 case 0: ShowTerraformToolbar(); break;
1003 case 1: ShowBuildTreesToolbar(); break;
1004 case 2: return SelectSignTool();
1005 }
1006 return CBF_NONE;
1007}
1008
1009/* --- Music button menu --- */
1010
1011static CallBackFunction ToolbarMusicClick(Window *w)
1012{
1013 PopupMainToolbarMenu(w, _game_mode == GM_EDITOR ? (WidgetID)WID_TE_MUSIC_SOUND : (WidgetID)WID_TN_MUSIC_SOUND, {STR_TOOLBAR_SOUND_MUSIC});
1014 return CBF_NONE;
1015}
1016
1022 static CallBackFunction MenuClickMusicWindow(int)
1023{
1024 ShowMusicWindow();
1025 return CBF_NONE;
1026}
1027
1028/* --- Newspaper button menu --- */
1029
1030static CallBackFunction ToolbarNewspaperClick(Window *w)
1031{
1032 PopupMainToolbarMenu(w, WID_TN_MESSAGES, {STR_NEWS_MENU_LAST_MESSAGE_NEWS_REPORT, STR_NEWS_MENU_MESSAGE_HISTORY_MENU, STR_NEWS_MENU_DELETE_ALL_MESSAGES});
1033 return CBF_NONE;
1034}
1035
1042 static CallBackFunction MenuClickNewspaper(int index)
1043{
1044 switch (index) {
1045 case 0: ShowLastNewsMessage(); break;
1046 case 1: ShowMessageHistory(); break;
1047 case 2: DeleteAllMessages(); break;
1048 }
1049 return CBF_NONE;
1050}
1051
1052/* --- Help button menu --- */
1053
1054static CallBackFunction PlaceLandBlockInfo()
1055{
1056 if (_last_started_action == CBF_PLACE_LANDINFO) {
1057 ResetObjectToPlace();
1058 return CBF_NONE;
1059 } else {
1060 SetObjectToPlace(SPR_CURSOR_QUERY, PAL_NONE, HT_RECT, WC_MAIN_TOOLBAR, 0);
1061 return CBF_PLACE_LANDINFO;
1062 }
1063}
1064
1065static CallBackFunction ToolbarHelpClick(Window *w)
1066{
1067 if (_settings_client.gui.newgrf_developer_tools) {
1068 PopupMainToolbarMenu(w, _game_mode == GM_EDITOR ? (WidgetID)WID_TE_HELP : (WidgetID)WID_TN_HELP, {STR_ABOUT_MENU_LAND_BLOCK_INFO,
1069 STR_ABOUT_MENU_HELP, STR_NULL, STR_ABOUT_MENU_TOGGLE_CONSOLE, STR_ABOUT_MENU_AI_DEBUG,
1070 STR_ABOUT_MENU_SCREENSHOT, STR_ABOUT_MENU_SHOW_FRAMERATE, STR_ABOUT_MENU_ABOUT_OPENTTD,
1071 STR_ABOUT_MENU_SPRITE_ALIGNER, STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES, STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS,
1072 STR_ABOUT_MENU_TOGGLE_WIDGET_OUTLINES});
1073 } else {
1074 PopupMainToolbarMenu(w, _game_mode == GM_EDITOR ? (WidgetID)WID_TE_HELP : (WidgetID)WID_TN_HELP, {STR_ABOUT_MENU_LAND_BLOCK_INFO,
1075 STR_ABOUT_MENU_HELP, STR_NULL, STR_ABOUT_MENU_TOGGLE_CONSOLE, STR_ABOUT_MENU_AI_DEBUG,
1076 STR_ABOUT_MENU_SCREENSHOT, STR_ABOUT_MENU_SHOW_FRAMERATE, STR_ABOUT_MENU_ABOUT_OPENTTD});
1077 }
1078 return CBF_NONE;
1079}
1080
1088 void ToggleBoundingBoxes()
1089{
1090 extern bool _draw_bounding_boxes;
1091 /* Always allow to toggle them off */
1092 if (_settings_client.gui.newgrf_developer_tools || _draw_bounding_boxes) {
1093 _draw_bounding_boxes = !_draw_bounding_boxes;
1094 MarkWholeScreenDirty();
1095 }
1096}
1097
1105 void ToggleDirtyBlocks()
1106{
1107 extern bool _draw_dirty_blocks;
1108 /* Always allow to toggle them off */
1109 if (_settings_client.gui.newgrf_developer_tools || _draw_dirty_blocks) {
1110 _draw_dirty_blocks = !_draw_dirty_blocks;
1111 MarkWholeScreenDirty();
1112 }
1113}
1114
1119 void ToggleWidgetOutlines()
1120{
1121 extern bool _draw_widget_outlines;
1122 /* Always allow to toggle them off */
1123 if (_settings_client.gui.newgrf_developer_tools || _draw_widget_outlines) {
1124 _draw_widget_outlines = !_draw_widget_outlines;
1125 MarkWholeScreenDirty();
1126 }
1127}
1128
1133 void SetStartingYear(TimerGameCalendar::Year year)
1134{
1135 _settings_game.game_creation.starting_year = Clamp(year, CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
1136 TimerGameCalendar::Date new_calendar_date = TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1);
1137 TimerGameEconomy::Date new_economy_date{new_calendar_date.base()};
1138
1139 /* We must set both Calendar and Economy dates to keep them in sync. Calendar first. */
1140 TimerGameCalendar::SetDate(new_calendar_date, 0);
1141
1142 /* If you open a savegame as a scenario, there may already be link graphs and/or vehicles. These use economy date. */
1143 LinkGraphSchedule::instance.ShiftDates(new_economy_date - TimerGameEconomy::date);
1144 for (auto v : Vehicle::Iterate()) v->ShiftDates(new_economy_date - TimerGameEconomy::date);
1145
1146 /* Only change the date after changing cached values above. */
1147 TimerGameEconomy::SetDate(new_economy_date, 0);
1148}
1149
1155 static CallBackFunction MenuClickHelp(int index)
1156{
1157 switch (index) {
1158 case 0: return PlaceLandBlockInfo();
1159 case 1: ShowHelpWindow(); break;
1160 case 2: IConsoleSwitch(); break;
1161 case 3: ShowScriptDebugWindow(CompanyID::Invalid(), _ctrl_pressed); break;
1162 case 4: ShowScreenshotWindow(); break;
1163 case 5: ShowFramerateWindow(); break;
1164 case 6: ShowAboutWindow(); break;
1165 case 7: ShowSpriteAlignerWindow(); break;
1166 case 8: ToggleBoundingBoxes(); break;
1167 case 9: ToggleDirtyBlocks(); break;
1168 case 10: ToggleWidgetOutlines(); break;
1169 }
1170 return CBF_NONE;
1171}
1172
1173/* --- Switch toolbar button --- */
1174
1175static CallBackFunction ToolbarSwitchClick(Window *w)
1176{
1177 if (_toolbar_mode != TB_LOWER) {
1178 _toolbar_mode = TB_LOWER;
1179 } else {
1180 _toolbar_mode = TB_UPPER;
1181 }
1182
1183 w->ReInit();
1184 w->SetWidgetLoweredState(_game_mode == GM_EDITOR ? (WidgetID)WID_TE_SWITCH_BAR : (WidgetID)WID_TN_SWITCH_BAR, _toolbar_mode == TB_LOWER);
1185 SndClickBeep();
1186 return CBF_NONE;
1187}
1188
1189/* --- Scenario editor specific handlers. */
1190
1194 static CallBackFunction ToolbarScenDatePanel(Window *w)
1195{
1196 ShowQueryString(GetString(STR_JUST_INT, _settings_game.game_creation.starting_year), STR_MAPGEN_START_DATE_QUERY_CAPT, 8, w, CS_NUMERAL, QueryStringFlag::EnableDefault);
1197 return CBF_NONE;
1198}
1199
1200static CallBackFunction ToolbarScenDateBackward(Window *w)
1201{
1202 /* don't allow too fast scrolling */
1203 if (!w->flags.Test(WindowFlag::Timeout) || w->timeout_timer <= 1) {
1204 w->HandleButtonClick(WID_TE_DATE_BACKWARD);
1205 w->SetDirty();
1206
1207 SetStartingYear(_settings_game.game_creation.starting_year - 1);
1208 }
1209 _left_button_clicked = false;
1210 return CBF_NONE;
1211}
1212
1213static CallBackFunction ToolbarScenDateForward(Window *w)
1214{
1215 /* don't allow too fast scrolling */
1216 if (!w->flags.Test(WindowFlag::Timeout) || w->timeout_timer <= 1) {
1217 w->HandleButtonClick(WID_TE_DATE_FORWARD);
1218 w->SetDirty();
1219
1220 SetStartingYear(_settings_game.game_creation.starting_year + 1);
1221 }
1222 _left_button_clicked = false;
1223 return CBF_NONE;
1224}
1225
1226static CallBackFunction ToolbarScenGenLand(Window *w)
1227{
1228 w->HandleButtonClick(WID_TE_LAND_GENERATE);
1229
1230 ShowEditorTerraformToolbar();
1231 return CBF_NONE;
1232}
1233
1234static CallBackFunction ToolbarScenGenTownClick(Window *w)
1235{
1236 PopupMainToolbarMenu(w, WID_TE_TOWN_GENERATE, {STR_SCENEDIT_TOWN_MENU_BUILD_TOWN, STR_SCENEDIT_TOWN_MENU_PACE_HOUSE});
1237 return CBF_NONE;
1238}
1239
1240static CallBackFunction ToolbarScenGenTown(int index)
1241{
1242 switch (index) {
1243 case 0: ShowFoundTownWindow(); break;
1244 case 1: ShowBuildHousePicker(nullptr); break;
1245 }
1246 return CBF_NONE;
1247}
1248
1249static CallBackFunction ToolbarScenGenIndustry(Window *w)
1250{
1251 w->HandleButtonClick(WID_TE_INDUSTRY);
1252 ShowBuildIndustryWindow();
1253 return CBF_NONE;
1254}
1255
1256static CallBackFunction ToolbarScenBuildRoadClick(Window *w)
1257{
1258 ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TE_ROADS, 140, GetToolbarDropDownOptions());
1259 return CBF_NONE;
1260}
1261
1268 static CallBackFunction ToolbarScenBuildRoad(int index)
1269{
1270 _last_built_roadtype = (RoadType)index;
1271 ShowBuildRoadScenToolbar(_last_built_roadtype);
1272 return CBF_NONE;
1273}
1274
1275static CallBackFunction ToolbarScenBuildTramClick(Window *w)
1276{
1277 ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TE_TRAMS, 140, GetToolbarDropDownOptions());
1278 return CBF_NONE;
1279}
1280
1287 static CallBackFunction ToolbarScenBuildTram(int index)
1288{
1289 _last_built_tramtype = (RoadType)index;
1290 ShowBuildRoadScenToolbar(_last_built_tramtype);
1291 return CBF_NONE;
1292}
1293
1294static CallBackFunction ToolbarScenBuildDocks(Window *w)
1295{
1296 w->HandleButtonClick(WID_TE_WATER);
1297 ShowBuildDocksScenToolbar();
1298 return CBF_NONE;
1299}
1300
1301static CallBackFunction ToolbarScenPlantTrees(Window *w)
1302{
1303 w->HandleButtonClick(WID_TE_TREES);
1304 ShowBuildTreesToolbar();
1305 return CBF_NONE;
1306}
1307
1308static CallBackFunction ToolbarScenPlaceSign(Window *w)
1309{
1310 w->HandleButtonClick(WID_TE_SIGNS);
1311 return SelectSignTool();
1312}
1313
1314static CallBackFunction ToolbarBtn_NULL(Window *)
1315{
1316 return CBF_NONE;
1317}
1318
1319typedef CallBackFunction MenuClickedProc(int index);
1320
1321static MenuClickedProc * const _menu_clicked_procs[] = {
1322 nullptr, // 0
1323 nullptr, // 1
1324 MenuClickSettings, // 2
1325 MenuClickSaveLoad, // 3
1326 MenuClickMap, // 4
1327 MenuClickTown, // 5
1328 MenuClickSubsidies, // 6
1329 MenuClickStations, // 7
1330 MenuClickFinances, // 8
1331 MenuClickCompany, // 9
1332 MenuClickStory, // 10
1333 MenuClickGoal, // 11
1334 MenuClickGraphsOrLeague, // 12
1335 MenuClickGraphsOrLeague, // 13
1336 MenuClickIndustry, // 14
1337 MenuClickShowTrains, // 15
1338 MenuClickShowRoad, // 16
1339 MenuClickShowShips, // 17
1340 MenuClickShowAir, // 18
1341 MenuClickMap, // 19
1342 nullptr, // 20
1343 MenuClickBuildRail, // 21
1344 MenuClickBuildRoad, // 22
1345 MenuClickBuildTram, // 23
1346 MenuClickBuildWater, // 24
1347 MenuClickBuildAir, // 25
1348 MenuClickForest, // 26
1349 MenuClickMusicWindow, // 27
1350 MenuClickNewspaper, // 28
1351 MenuClickHelp, // 29
1352};
1353
1355 class NWidgetToolbarContainer : public NWidgetContainer {
1356protected:
1357 uint spacers = 0;
1358
1359public:
1360 NWidgetToolbarContainer() : NWidgetContainer(NWID_HORIZONTAL)
1361 {
1362 }
1363
1369 bool IsButton(WidgetType type) const
1370 {
1371 return type == WWT_IMGBTN || type == WWT_IMGBTN_2 || type == WWT_PUSHIMGBTN;
1372 }
1373
1374 void SetupSmallestSize(Window *w) override
1375 {
1376 this->smallest_x = 0; // Biggest child
1377 this->smallest_y = 0; // Biggest child
1378 this->fill_x = 1;
1379 this->fill_y = 0;
1380 this->resize_x = 1; // We only resize in this direction
1381 this->resize_y = 0; // We never resize in this direction
1382 this->spacers = 0;
1383
1384 uint nbuttons = 0;
1385 /* First initialise some variables... */
1386 for (const auto &child_wid : this->children) {
1387 child_wid->SetupSmallestSize(w);
1388 this->smallest_y = std::max(this->smallest_y, child_wid->smallest_y + child_wid->padding.Vertical());
1389 if (this->IsButton(child_wid->type)) {
1390 nbuttons++;
1391 this->smallest_x = std::max(this->smallest_x, child_wid->smallest_x + child_wid->padding.Horizontal());
1392 } else if (child_wid->type == NWID_SPACER) {
1393 this->spacers++;
1394 }
1395 }
1396
1397 /* ... then in a second pass make sure the 'current' heights are set. Won't change ever. */
1398 for (const auto &child_wid : this->children) {
1399 child_wid->current_y = this->smallest_y;
1400 if (!this->IsButton(child_wid->type)) {
1401 child_wid->current_x = child_wid->smallest_x;
1402 }
1403 }
1404
1405 /* Exclude the switcher button which is not displayed when the toolbar fits the screen. When the switch is
1406 * displayed there will be no spacers anyway. */
1407 --nbuttons;
1408
1409 /* Allow space for all buttons, and include spacers at quarter the width of buttons. */
1410 _toolbar_width = nbuttons * this->smallest_x + this->spacers * this->smallest_x / 4;
1411 }
1412
1413 void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override
1414 {
1415 assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
1416
1417 this->pos_x = x;
1418 this->pos_y = y;
1419 this->current_x = given_width;
1420 this->current_y = given_height;
1421
1422 /* Figure out what are the visible buttons */
1423 uint arrangeable_count, button_count, spacer_count;
1424 const WidgetID *arrangement = GetButtonArrangement(given_width, arrangeable_count, button_count, spacer_count);
1425
1426 /* Create us ourselves a quick lookup table from WidgetID to slot. */
1427 std::map<WidgetID, uint> lookup;
1428 for (auto it = std::begin(this->children); it != std::end(this->children); ++it) {
1429 NWidgetBase *nwid = it->get();
1430 nwid->current_x = 0; /* Hide widget, it will be revealed in the next step. */
1431 if (nwid->type == NWID_SPACER) continue;
1432 NWidgetCore *nwc = dynamic_cast<NWidgetCore *>(nwid);
1433 assert(nwc != nullptr);
1434 lookup[nwc->GetIndex()] = std::distance(this->children.begin(), it);
1435 }
1436
1437 /* Now assign the widgets to their rightful place */
1438 uint position = 0; // Place to put next child relative to origin of the container.
1439 uint spacer_space = std::max(0, (int)given_width - (int)(button_count * this->smallest_x)); // Remaining spacing for 'spacer' widgets
1440 uint button_space = given_width - spacer_space; // Remaining spacing for the buttons
1441 uint spacer_i = 0;
1442 uint button_i = 0;
1443
1444 /* Index into the arrangement indices. */
1445 const WidgetID *slotp = rtl ? &arrangement[arrangeable_count - 1] : arrangement;
1446 for (uint i = 0; i < arrangeable_count; i++) {
1447 uint slot = lookup[*slotp];
1448 auto &child_wid = this->children[slot];
1449 /* If we have space to give to the spacers, do that. */
1450 if (spacer_space > 0 && slot > 0 && slot < this->children.size() - 1) {
1451 const auto &possible_spacer = this->children[slot + (rtl ? 1 : -1)];
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 } else {
1466 child_wid->current_x = child_wid->smallest_x;
1467 }
1468 child_wid->AssignSizePosition(sizing, x + position, y, child_wid->current_x, this->current_y, rtl);
1469 position += child_wid->current_x;
1470
1471 if (rtl) {
1472 slotp--;
1473 } else {
1474 slotp++;
1475 }
1476 }
1477 }
1478
1479 void Draw(const Window *w) override
1480 {
1481 /* Draw brown-red toolbar bg. */
1482 const Rect r = this->GetCurrentRect();
1483 GfxFillRect(r, PC_VERY_DARK_RED);
1484 GfxFillRect(r, PC_DARK_RED, FILLRECT_CHECKER);
1485
1486 this->NWidgetContainer::Draw(w);
1487 }
1488
1497 virtual const WidgetID *GetButtonArrangement(uint &width, uint &arrangeable_count, uint &button_count, uint &spacer_count) const = 0;
1498};
1499
1501 class NWidgetMainToolbarContainer : public NWidgetToolbarContainer {
1502 const WidgetID *GetButtonArrangement(uint &width, uint &arrangeable_count, uint &button_count, uint &spacer_count) const override
1503 {
1504 static const uint SMALLEST_ARRANGEMENT = 14;
1505 static const uint BIGGEST_ARRANGEMENT = 20;
1506
1507 /* The number of buttons of each row of the toolbar should match the number of items which we want to be visible.
1508 * The total number of buttons should be equal to arrangeable_count * 2.
1509 * No bad things happen, but we could see strange behaviours if we have buttons < (arrangeable_count * 2) like a
1510 * pause button appearing on the right of the lower toolbar and weird resizing of the widgets even if there is
1511 * enough space.
1512 */
1513 static const WidgetID arrange14[] = {
1514 WID_TN_PAUSE,
1515 WID_TN_FAST_FORWARD,
1516 WID_TN_TRAINS,
1517 WID_TN_ROADVEHS,
1518 WID_TN_SHIPS,
1519 WID_TN_AIRCRAFT,
1520 WID_TN_ZOOM_IN,
1521 WID_TN_ZOOM_OUT,
1522 WID_TN_RAILS,
1523 WID_TN_ROADS,
1524 WID_TN_WATER,
1525 WID_TN_AIR,
1526 WID_TN_LANDSCAPE,
1527 WID_TN_SWITCH_BAR,
1528 /* lower toolbar */
1529 WID_TN_SETTINGS,
1530 WID_TN_SAVE,
1531 WID_TN_SMALL_MAP,
1532 WID_TN_TOWNS,
1533 WID_TN_SUBSIDIES,
1534 WID_TN_STATIONS,
1535 WID_TN_FINANCES,
1536 WID_TN_COMPANIES,
1537 WID_TN_GRAPHS,
1538 WID_TN_INDUSTRIES,
1539 WID_TN_MUSIC_SOUND,
1540 WID_TN_MESSAGES,
1541 WID_TN_HELP,
1542 WID_TN_SWITCH_BAR,
1543 };
1544 static const WidgetID arrange15[] = {
1545 WID_TN_PAUSE,
1546 WID_TN_FAST_FORWARD,
1547 WID_TN_SMALL_MAP,
1548 WID_TN_TRAINS,
1549 WID_TN_ROADVEHS,
1550 WID_TN_SHIPS,
1551 WID_TN_AIRCRAFT,
1552 WID_TN_RAILS,
1553 WID_TN_ROADS,
1554 WID_TN_WATER,
1555 WID_TN_AIR,
1556 WID_TN_LANDSCAPE,
1557 WID_TN_ZOOM_IN,
1558 WID_TN_ZOOM_OUT,
1559 WID_TN_SWITCH_BAR,
1560 /* lower toolbar */
1561 WID_TN_PAUSE,
1562 WID_TN_SETTINGS,
1563 WID_TN_SMALL_MAP,
1564 WID_TN_SAVE,
1565 WID_TN_TOWNS,
1566 WID_TN_SUBSIDIES,
1567 WID_TN_STATIONS,
1568 WID_TN_FINANCES,
1569 WID_TN_COMPANIES,
1570 WID_TN_GRAPHS,
1571 WID_TN_INDUSTRIES,
1572 WID_TN_MUSIC_SOUND,
1573 WID_TN_MESSAGES,
1574 WID_TN_HELP,
1575 WID_TN_SWITCH_BAR,
1576 };
1577 static const WidgetID arrange16[] = {
1578 WID_TN_PAUSE,
1579 WID_TN_FAST_FORWARD,
1580 WID_TN_SETTINGS,
1581 WID_TN_SMALL_MAP,
1582 WID_TN_TRAINS,
1583 WID_TN_ROADVEHS,
1584 WID_TN_SHIPS,
1585 WID_TN_AIRCRAFT,
1586 WID_TN_RAILS,
1587 WID_TN_ROADS,
1588 WID_TN_WATER,
1589 WID_TN_AIR,
1590 WID_TN_LANDSCAPE,
1591 WID_TN_ZOOM_IN,
1592 WID_TN_ZOOM_OUT,
1593 WID_TN_SWITCH_BAR,
1594 /* lower toolbar */
1595 WID_TN_PAUSE,
1596 WID_TN_FAST_FORWARD,
1597 WID_TN_SAVE,
1598 WID_TN_TOWNS,
1599 WID_TN_SUBSIDIES,
1600 WID_TN_STATIONS,
1601 WID_TN_FINANCES,
1602 WID_TN_COMPANIES,
1603 WID_TN_GRAPHS,
1604 WID_TN_INDUSTRIES,
1605 WID_TN_MUSIC_SOUND,
1606 WID_TN_MESSAGES,
1607 WID_TN_HELP,
1608 WID_TN_ZOOM_IN,
1609 WID_TN_ZOOM_OUT,
1610 WID_TN_SWITCH_BAR,
1611 };
1612 static const WidgetID arrange17[] = {
1613 WID_TN_PAUSE,
1614 WID_TN_FAST_FORWARD,
1615 WID_TN_SETTINGS,
1616 WID_TN_SMALL_MAP,
1617 WID_TN_SUBSIDIES,
1618 WID_TN_TRAINS,
1619 WID_TN_ROADVEHS,
1620 WID_TN_SHIPS,
1621 WID_TN_AIRCRAFT,
1622 WID_TN_RAILS,
1623 WID_TN_ROADS,
1624 WID_TN_WATER,
1625 WID_TN_AIR,
1626 WID_TN_LANDSCAPE,
1627 WID_TN_ZOOM_IN,
1628 WID_TN_ZOOM_OUT,
1629 WID_TN_SWITCH_BAR,
1630 /* lower toolbar */
1631 WID_TN_PAUSE,
1632 WID_TN_FAST_FORWARD,
1633 WID_TN_SAVE,
1634 WID_TN_SMALL_MAP,
1635 WID_TN_SUBSIDIES,
1636 WID_TN_TOWNS,
1637 WID_TN_STATIONS,
1638 WID_TN_FINANCES,
1639 WID_TN_COMPANIES,
1640 WID_TN_GRAPHS,
1641 WID_TN_INDUSTRIES,
1642 WID_TN_MUSIC_SOUND,
1643 WID_TN_MESSAGES,
1644 WID_TN_HELP,
1645 WID_TN_ZOOM_IN,
1646 WID_TN_ZOOM_OUT,
1647 WID_TN_SWITCH_BAR,
1648 };
1649 static const WidgetID arrange18[] = {
1650 WID_TN_PAUSE,
1651 WID_TN_FAST_FORWARD,
1652 WID_TN_SETTINGS,
1653 WID_TN_SMALL_MAP,
1654 WID_TN_TOWNS,
1655 WID_TN_SUBSIDIES,
1656 WID_TN_STATIONS,
1657 WID_TN_FINANCES,
1658 WID_TN_COMPANIES,
1659 WID_TN_INDUSTRIES,
1660 WID_TN_RAILS,
1661 WID_TN_ROADS,
1662 WID_TN_WATER,
1663 WID_TN_AIR,
1664 WID_TN_LANDSCAPE,
1665 WID_TN_ZOOM_IN,
1666 WID_TN_ZOOM_OUT,
1667 WID_TN_SWITCH_BAR,
1668 /* lower toolbar */
1669 WID_TN_PAUSE,
1670 WID_TN_FAST_FORWARD,
1671 WID_TN_SAVE,
1672 WID_TN_SMALL_MAP,
1673 WID_TN_TOWNS,
1674 WID_TN_SUBSIDIES,
1675 WID_TN_STATIONS,
1676 WID_TN_GRAPHS,
1677 WID_TN_TRAINS,
1678 WID_TN_ROADVEHS,
1679 WID_TN_SHIPS,
1680 WID_TN_AIRCRAFT,
1681 WID_TN_MUSIC_SOUND,
1682 WID_TN_MESSAGES,
1683 WID_TN_HELP,
1684 WID_TN_ZOOM_IN,
1685 WID_TN_ZOOM_OUT,
1686 WID_TN_SWITCH_BAR,
1687 };
1688 static const WidgetID arrange19[] = {
1689 WID_TN_PAUSE,
1690 WID_TN_FAST_FORWARD,
1691 WID_TN_SETTINGS,
1692 WID_TN_SMALL_MAP,
1693 WID_TN_TOWNS,
1694 WID_TN_SUBSIDIES,
1695 WID_TN_TRAINS,
1696 WID_TN_ROADVEHS,
1697 WID_TN_SHIPS,
1698 WID_TN_AIRCRAFT,
1699 WID_TN_RAILS,
1700 WID_TN_ROADS,
1701 WID_TN_WATER,
1702 WID_TN_AIR,
1703 WID_TN_LANDSCAPE,
1704 WID_TN_MUSIC_SOUND,
1705 WID_TN_ZOOM_IN,
1706 WID_TN_ZOOM_OUT,
1707 WID_TN_SWITCH_BAR,
1708 /* lower toolbar */
1709 WID_TN_PAUSE,
1710 WID_TN_FAST_FORWARD,
1711 WID_TN_SAVE,
1712 WID_TN_SMALL_MAP,
1713 WID_TN_STATIONS,
1714 WID_TN_FINANCES,
1715 WID_TN_COMPANIES,
1716 WID_TN_GRAPHS,
1717 WID_TN_INDUSTRIES,
1718 WID_TN_MESSAGES,
1719 WID_TN_RAILS,
1720 WID_TN_ROADS,
1721 WID_TN_WATER,
1722 WID_TN_AIR,
1723 WID_TN_LANDSCAPE,
1724 WID_TN_HELP,
1725 WID_TN_ZOOM_IN,
1726 WID_TN_ZOOM_OUT,
1727 WID_TN_SWITCH_BAR,
1728 };
1729 static const WidgetID arrange20[] = {
1730 WID_TN_PAUSE,
1731 WID_TN_FAST_FORWARD,
1732 WID_TN_SETTINGS,
1733 WID_TN_SMALL_MAP,
1734 WID_TN_TOWNS,
1735 WID_TN_SUBSIDIES,
1736 WID_TN_TRAINS,
1737 WID_TN_ROADVEHS,
1738 WID_TN_SHIPS,
1739 WID_TN_AIRCRAFT,
1740 WID_TN_RAILS,
1741 WID_TN_ROADS,
1742 WID_TN_WATER,
1743 WID_TN_AIR,
1744 WID_TN_LANDSCAPE,
1745 WID_TN_MUSIC_SOUND,
1746 WID_TN_GOAL,
1747 WID_TN_ZOOM_IN,
1748 WID_TN_ZOOM_OUT,
1749 WID_TN_SWITCH_BAR,
1750 /* lower toolbar */
1751 WID_TN_PAUSE,
1752 WID_TN_FAST_FORWARD,
1753 WID_TN_SAVE,
1754 WID_TN_SMALL_MAP,
1755 WID_TN_STATIONS,
1756 WID_TN_FINANCES,
1757 WID_TN_COMPANIES,
1758 WID_TN_GRAPHS,
1759 WID_TN_INDUSTRIES,
1760 WID_TN_MESSAGES,
1761 WID_TN_RAILS,
1762 WID_TN_ROADS,
1763 WID_TN_WATER,
1764 WID_TN_AIR,
1765 WID_TN_LANDSCAPE,
1766 WID_TN_STORY,
1767 WID_TN_HELP,
1768 WID_TN_ZOOM_IN,
1769 WID_TN_ZOOM_OUT,
1770 WID_TN_SWITCH_BAR,
1771 };
1772 static const WidgetID arrange_all[] = {
1773 WID_TN_PAUSE,
1774 WID_TN_FAST_FORWARD,
1775 WID_TN_SETTINGS,
1776 WID_TN_SAVE,
1777 WID_TN_SMALL_MAP,
1778 WID_TN_TOWNS,
1779 WID_TN_SUBSIDIES,
1780 WID_TN_STATIONS,
1781 WID_TN_FINANCES,
1782 WID_TN_COMPANIES,
1783 WID_TN_STORY,
1784 WID_TN_GOAL,
1785 WID_TN_GRAPHS,
1786 WID_TN_LEAGUE,
1787 WID_TN_INDUSTRIES,
1788 WID_TN_TRAINS,
1789 WID_TN_ROADVEHS,
1790 WID_TN_SHIPS,
1791 WID_TN_AIRCRAFT,
1792 WID_TN_ZOOM_IN,
1793 WID_TN_ZOOM_OUT,
1794 WID_TN_RAILS,
1795 WID_TN_ROADS,
1796 WID_TN_TRAMS,
1797 WID_TN_WATER,
1798 WID_TN_AIR,
1799 WID_TN_LANDSCAPE,
1800 WID_TN_MUSIC_SOUND,
1801 WID_TN_MESSAGES,
1802 WID_TN_HELP
1803 };
1804
1805 /* If at least BIGGEST_ARRANGEMENT fit, just spread all the buttons nicely */
1806 uint full_buttons = std::max(CeilDiv(width, this->smallest_x), SMALLEST_ARRANGEMENT);
1807 if (full_buttons > BIGGEST_ARRANGEMENT) {
1808 button_count = arrangeable_count = lengthof(arrange_all);
1809 spacer_count = this->spacers;
1810 return arrange_all;
1811 }
1812
1813 /* Introduce the split toolbar */
1814 static const WidgetID * const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20 };
1815
1816 button_count = arrangeable_count = full_buttons;
1817 spacer_count = this->spacers;
1818 return arrangements[full_buttons - SMALLEST_ARRANGEMENT] + ((_toolbar_mode == TB_LOWER) ? full_buttons : 0);
1819 }
1820};
1821
1823 class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer {
1824 std::array<uint, 2> panel_widths{};
1825
1826 void SetupSmallestSize(Window *w) override
1827 {
1828 this->NWidgetToolbarContainer::SetupSmallestSize(w);
1829
1830 /* Find the size of panel_widths */
1831 auto it = this->panel_widths.begin();
1832 for (const auto &child_wid : this->children) {
1833 if (child_wid->type == NWID_SPACER || this->IsButton(child_wid->type)) continue;
1834
1835 assert(it != this->panel_widths.end());
1836 *it = child_wid->current_x;
1837 _toolbar_width += child_wid->current_x;
1838 ++it;
1839 }
1840 }
1841
1842 const WidgetID *GetButtonArrangement(uint &width, uint &arrangeable_count, uint &button_count, uint &spacer_count) const override
1843 {
1844 static const WidgetID arrange_all[] = {
1845 WID_TE_PAUSE,
1846 WID_TE_FAST_FORWARD,
1847 WID_TE_SETTINGS,
1848 WID_TE_SAVE,
1849 WID_TE_SPACER,
1850 WID_TE_DATE_PANEL,
1851 WID_TE_SMALL_MAP,
1852 WID_TE_ZOOM_IN,
1853 WID_TE_ZOOM_OUT,
1854 WID_TE_LAND_GENERATE,
1855 WID_TE_TOWN_GENERATE,
1856 WID_TE_INDUSTRY,
1857 WID_TE_ROADS,
1858 WID_TE_TRAMS,
1859 WID_TE_WATER,
1860 WID_TE_TREES,
1861 WID_TE_SIGNS,
1862 WID_TE_MUSIC_SOUND,
1863 WID_TE_HELP,
1864 };
1865 static const WidgetID arrange_nopanel[] = {
1866 WID_TE_PAUSE,
1867 WID_TE_FAST_FORWARD,
1868 WID_TE_SETTINGS,
1869 WID_TE_SAVE,
1870 WID_TE_DATE_PANEL,
1871 WID_TE_SMALL_MAP,
1872 WID_TE_ZOOM_IN,
1873 WID_TE_ZOOM_OUT,
1874 WID_TE_LAND_GENERATE,
1875 WID_TE_TOWN_GENERATE,
1876 WID_TE_INDUSTRY,
1877 WID_TE_ROADS,
1878 WID_TE_TRAMS,
1879 WID_TE_WATER,
1880 WID_TE_TREES,
1881 WID_TE_SIGNS,
1882 WID_TE_MUSIC_SOUND,
1883 WID_TE_HELP,
1884 };
1885 static const WidgetID arrange_switch[] = {
1886 WID_TE_DATE_PANEL,
1887 WID_TE_SMALL_MAP,
1888 WID_TE_LAND_GENERATE,
1889 WID_TE_TOWN_GENERATE,
1890 WID_TE_INDUSTRY,
1891 WID_TE_ROADS,
1892 WID_TE_TRAMS,
1893 WID_TE_WATER,
1894 WID_TE_TREES,
1895 WID_TE_SIGNS,
1896 WID_TE_SWITCH_BAR,
1897 /* lower toolbar */
1898 WID_TE_PAUSE,
1899 WID_TE_FAST_FORWARD,
1900 WID_TE_SETTINGS,
1901 WID_TE_SAVE,
1902 WID_TE_DATE_PANEL,
1903 WID_TE_SMALL_MAP,
1904 WID_TE_ZOOM_IN,
1905 WID_TE_ZOOM_OUT,
1906 WID_TE_MUSIC_SOUND,
1907 WID_TE_HELP,
1908 WID_TE_SWITCH_BAR,
1909 };
1910
1911 /* If we can place all buttons *and* the panels, show them. */
1912 size_t min_full_width = (lengthof(arrange_all) - std::size(this->panel_widths)) * this->smallest_x + this->panel_widths[0] + this->panel_widths[1];
1913 if (width >= min_full_width) {
1914 width -= this->panel_widths[0] + this->panel_widths[1];
1915 arrangeable_count = lengthof(arrange_all);
1916 button_count = arrangeable_count - 2;
1917 spacer_count = this->spacers;
1918 return arrange_all;
1919 }
1920
1921 /* 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 */
1922 size_t min_small_width = (lengthof(arrange_switch) - std::size(this->panel_widths)) * this->smallest_x / 2 + this->panel_widths[1];
1923 if (width > min_small_width) {
1924 width -= this->panel_widths[1];
1925 arrangeable_count = lengthof(arrange_nopanel);
1926 button_count = arrangeable_count - 1;
1927 spacer_count = this->spacers - 1;
1928 return arrange_nopanel;
1929 }
1930
1931 /* Split toolbar */
1932 width -= this->panel_widths[1];
1933 arrangeable_count = lengthof(arrange_switch) / 2;
1934 button_count = arrangeable_count - 1;
1935 spacer_count = 0;
1936 return arrange_switch + ((_toolbar_mode == TB_LOWER) ? arrangeable_count : 0);
1937 }
1938};
1939
1940/* --- Toolbar handling for the 'normal' case */
1941
1942typedef CallBackFunction ToolbarButtonProc(Window *w);
1943
1944static ToolbarButtonProc * const _toolbar_button_procs[] = {
1945 ToolbarPauseClick,
1946 ToolbarFastForwardClick,
1947 ToolbarOptionsClick,
1948 ToolbarSaveClick,
1949 ToolbarMapClick,
1950 ToolbarTownClick,
1951 ToolbarSubsidiesClick,
1952 ToolbarStationsClick,
1953 ToolbarFinancesClick,
1954 ToolbarCompaniesClick,
1955 ToolbarStoryClick,
1956 ToolbarGoalClick,
1957 ToolbarGraphsClick,
1958 ToolbarLeagueClick,
1959 ToolbarIndustryClick,
1960 ToolbarTrainClick,
1961 ToolbarRoadClick,
1962 ToolbarShipClick,
1963 ToolbarAirClick,
1964 ToolbarZoomInClick,
1965 ToolbarZoomOutClick,
1966 ToolbarBuildRailClick,
1967 ToolbarBuildRoadClick,
1968 ToolbarBuildTramClick,
1969 ToolbarBuildWaterClick,
1970 ToolbarBuildAirClick,
1971 ToolbarForestClick,
1972 ToolbarMusicClick,
1973 ToolbarNewspaperClick,
1974 ToolbarHelpClick,
1975 ToolbarSwitchClick,
1976};
1977
1979 struct MainToolbarWindow : Window {
1980 MainToolbarWindow(WindowDesc &desc) : Window(desc)
1981 {
1982 this->InitNested(0);
1983
1984 _last_started_action = CBF_NONE;
1985 this->flags.Reset(WindowFlag::WhiteBorder);
1986 this->SetWidgetDisabledState(WID_TN_PAUSE, _networking && !_network_server); // if not server, disable pause button
1987 this->SetWidgetDisabledState(WID_TN_FAST_FORWARD, _networking); // if networking, disable fast-forward button
1988 PositionMainToolbar(this);
1989 DoZoomInOutWindow(ZOOM_NONE, this);
1990 }
1991
1992 void FindWindowPlacementAndResize(int, int def_height, bool allow_resize) override
1993 {
1994 Window::FindWindowPlacementAndResize(_toolbar_width, def_height, allow_resize);
1995 }
1996
1997 void OnPaint() override
1998 {
1999 /* If spectator, disable all construction buttons
2000 * ie : Build road, rail, ships, airports and landscaping
2001 * Since enabled state is the default, just disable when needed */
2002 this->SetWidgetsDisabledState(_local_company == COMPANY_SPECTATOR, WID_TN_RAILS, WID_TN_ROADS, WID_TN_TRAMS, WID_TN_WATER, WID_TN_AIR, WID_TN_LANDSCAPE);
2003 /* disable company list drop downs, if there are no companies */
2004 this->SetWidgetsDisabledState(Company::GetNumItems() == 0, WID_TN_STATIONS, WID_TN_FINANCES, WID_TN_TRAINS, WID_TN_ROADVEHS, WID_TN_SHIPS, WID_TN_AIRCRAFT);
2005
2006 this->SetWidgetDisabledState(WID_TN_GOAL, Goal::GetNumItems() == 0);
2007 this->SetWidgetDisabledState(WID_TN_STORY, StoryPage::GetNumItems() == 0);
2008
2009 this->DrawWidgets();
2010 }
2011
2012 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
2013 {
2014 if (_game_mode != GM_MENU && !this->IsWidgetDisabled(widget)) _toolbar_button_procs[widget](this);
2015 }
2016
2017 void OnDropdownSelect(WidgetID widget, int index, int) override
2018 {
2019 CallBackFunction cbf = _menu_clicked_procs[widget](index);
2020 if (cbf != CBF_NONE) _last_started_action = cbf;
2021 }
2022
2023 EventState OnHotkey(int hotkey) override
2024 {
2025 CallBackFunction cbf = CBF_NONE;
2026 switch (hotkey) {
2027 case MTHK_PAUSE: ToolbarPauseClick(this); break;
2028 case MTHK_FASTFORWARD: ToolbarFastForwardClick(this); break;
2029 case MTHK_SETTINGS: ShowGameOptions(); break;
2030 case MTHK_SAVEGAME: MenuClickSaveLoad(); break;
2031 case MTHK_LOADGAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break;
2032 case MTHK_SMALLMAP: ShowSmallMap(); break;
2033 case MTHK_TOWNDIRECTORY: ShowTownDirectory(); break;
2034 case MTHK_SUBSIDIES: ShowSubsidiesList(); break;
2035 case MTHK_STATIONS: ShowCompanyStations(_local_company); break;
2036 case MTHK_FINANCES: ShowCompanyFinances(_local_company); break;
2037 case MTHK_COMPANIES: ShowCompany(_local_company); break;
2038 case MTHK_STORY: ShowStoryBook(_local_company); break;
2039 case MTHK_GOAL: ShowGoalsList(_local_company); break;
2040 case MTHK_GRAPHS: ShowOperatingProfitGraph(); break;
2041 case MTHK_LEAGUE: ShowFirstLeagueTable(); break;
2042 case MTHK_INDUSTRIES: ShowBuildIndustryWindow(); break;
2043 case MTHK_TRAIN_LIST: ShowVehicleListWindow(_local_company, VEH_TRAIN); break;
2044 case MTHK_ROADVEH_LIST: ShowVehicleListWindow(_local_company, VEH_ROAD); break;
2045 case MTHK_SHIP_LIST: ShowVehicleListWindow(_local_company, VEH_SHIP); break;
2046 case MTHK_AIRCRAFT_LIST: ShowVehicleListWindow(_local_company, VEH_AIRCRAFT); break;
2047 case MTHK_ZOOM_IN: ToolbarZoomInClick(this); break;
2048 case MTHK_ZOOM_OUT: ToolbarZoomOutClick(this); break;
2049 case MTHK_BUILD_RAIL: ShowBuildRailToolbar(_last_built_railtype); break;
2050 case MTHK_BUILD_ROAD: ShowBuildRoadToolbar(_last_built_roadtype); break;
2051 case MTHK_BUILD_TRAM: ShowBuildRoadToolbar(_last_built_tramtype); break;
2052 case MTHK_BUILD_DOCKS: ShowBuildDocksToolbar(); break;
2053 case MTHK_BUILD_AIRPORT: ShowBuildAirToolbar(); break;
2054 case MTHK_BUILD_TREES: ShowBuildTreesToolbar(); break;
2055 case MTHK_MUSIC: ShowMusicWindow(); break;
2056 case MTHK_SCRIPT_DEBUG: ShowScriptDebugWindow(); break;
2057 case MTHK_SMALL_SCREENSHOT: MakeScreenshotWithConfirm(SC_VIEWPORT); break;
2058 case MTHK_ZOOMEDIN_SCREENSHOT: MakeScreenshotWithConfirm(SC_ZOOMEDIN); break;
2059 case MTHK_DEFAULTZOOM_SCREENSHOT: MakeScreenshotWithConfirm(SC_DEFAULTZOOM); break;
2060 case MTHK_GIANT_SCREENSHOT: MakeScreenshotWithConfirm(SC_WORLD); break;
2061 case MTHK_CHEATS: if (!_networking) ShowCheatWindow(); break;
2062 case MTHK_TERRAFORM: ShowTerraformToolbar(); break;
2063 case MTHK_EXTRA_VIEWPORT: ShowExtraViewportWindowForTileUnderCursor(); break;
2064 case MTHK_CLIENT_LIST: if (_networking) ShowClientList(); break;
2065 case MTHK_SIGN_LIST: ShowSignList(); break;
2066 case MTHK_LANDINFO: cbf = PlaceLandBlockInfo(); break;
2067 default: return ES_NOT_HANDLED;
2068 }
2069 if (cbf != CBF_NONE) _last_started_action = cbf;
2070 return ES_HANDLED;
2071 }
2072
2073 void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
2074 {
2075 switch (_last_started_action) {
2076 case CBF_PLACE_SIGN:
2077 PlaceProc_Sign(tile);
2078 break;
2079
2080 case CBF_PLACE_LANDINFO:
2081 ShowLandInfo(tile);
2082 break;
2083
2084 default: NOT_REACHED();
2085 }
2086 }
2087
2088 void OnPlaceObjectAbort() override
2089 {
2090 _last_started_action = CBF_NONE;
2091 }
2092
2094 const IntervalTimer<TimerWindow> refresh_interval = {std::chrono::milliseconds(30), [this](auto) {
2095 if (this->IsWidgetLowered(WID_TN_PAUSE) != _pause_mode.Any()) {
2096 this->ToggleWidgetLoweredState(WID_TN_PAUSE);
2097 this->SetWidgetDirty(WID_TN_PAUSE);
2098 }
2099
2100 if (this->IsWidgetLowered(WID_TN_FAST_FORWARD) != (_game_speed != 100)) {
2101 this->ToggleWidgetLoweredState(WID_TN_FAST_FORWARD);
2102 this->SetWidgetDirty(WID_TN_FAST_FORWARD);
2103 }
2104 }};
2105
2111 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
2112 {
2113 if (!gui_scope) return;
2114 HandleZoomMessage(this, *GetMainWindow()->viewport, WID_TN_ZOOM_IN, WID_TN_ZOOM_OUT);
2115 }
2116
2117 static inline HotkeyList hotkeys{"maintoolbar", {
2118 Hotkey({WKC_F1, WKC_PAUSE}, "pause", MTHK_PAUSE),
2119 Hotkey(0, "fastforward", MTHK_FASTFORWARD),
2120 Hotkey(WKC_F2, "settings", MTHK_SETTINGS),
2121 Hotkey(WKC_F3, "saveload", MTHK_SAVEGAME),
2122 Hotkey(0, "load_game", MTHK_LOADGAME),
2123 Hotkey({WKC_F4, 'M'}, "smallmap", MTHK_SMALLMAP),
2124 Hotkey(WKC_F5, "town_list", MTHK_TOWNDIRECTORY),
2125 Hotkey(WKC_F6, "subsidies", MTHK_SUBSIDIES),
2126 Hotkey(WKC_F7, "station_list", MTHK_STATIONS),
2127 Hotkey(WKC_F8, "finances", MTHK_FINANCES),
2128 Hotkey(WKC_F9, "companies", MTHK_COMPANIES),
2129 Hotkey(0, "story_book", MTHK_STORY),
2130 Hotkey(0, "goal_list", MTHK_GOAL),
2131 Hotkey(WKC_F10, "graphs", MTHK_GRAPHS),
2132 Hotkey(WKC_F11, "league", MTHK_LEAGUE),
2133 Hotkey(WKC_F12, "industry_list", MTHK_INDUSTRIES),
2134 Hotkey(WKC_SHIFT | WKC_F1, "train_list", MTHK_TRAIN_LIST),
2135 Hotkey(WKC_SHIFT | WKC_F2, "roadveh_list", MTHK_ROADVEH_LIST),
2136 Hotkey(WKC_SHIFT | WKC_F3, "ship_list", MTHK_SHIP_LIST),
2137 Hotkey(WKC_SHIFT | WKC_F4, "aircraft_list", MTHK_AIRCRAFT_LIST),
2138 Hotkey({WKC_NUM_PLUS, WKC_EQUALS, WKC_SHIFT | WKC_EQUALS, WKC_SHIFT | WKC_F5}, "zoomin", MTHK_ZOOM_IN),
2139 Hotkey({WKC_NUM_MINUS, WKC_MINUS, WKC_SHIFT | WKC_MINUS, WKC_SHIFT | WKC_F6}, "zoomout", MTHK_ZOOM_OUT),
2140 Hotkey(WKC_SHIFT | WKC_F7, "build_rail", MTHK_BUILD_RAIL),
2141 Hotkey(WKC_SHIFT | WKC_F8, "build_road", MTHK_BUILD_ROAD),
2142 Hotkey(0, "build_tram", MTHK_BUILD_TRAM),
2143 Hotkey(WKC_SHIFT | WKC_F9, "build_docks", MTHK_BUILD_DOCKS),
2144 Hotkey(WKC_SHIFT | WKC_F10, "build_airport", MTHK_BUILD_AIRPORT),
2145 Hotkey(WKC_SHIFT | WKC_F11, "build_trees", MTHK_BUILD_TREES),
2146 Hotkey(WKC_SHIFT | WKC_F12, "music", MTHK_MUSIC),
2147 Hotkey(0, "ai_debug", MTHK_SCRIPT_DEBUG),
2148 Hotkey(WKC_CTRL | 'S', "small_screenshot", MTHK_SMALL_SCREENSHOT),
2149 Hotkey(WKC_CTRL | 'P', "zoomedin_screenshot", MTHK_ZOOMEDIN_SCREENSHOT),
2150 Hotkey(WKC_CTRL | 'D', "defaultzoom_screenshot", MTHK_DEFAULTZOOM_SCREENSHOT),
2151 Hotkey(0, "giant_screenshot", MTHK_GIANT_SCREENSHOT),
2152 Hotkey(WKC_CTRL | WKC_ALT | 'C', "cheats", MTHK_CHEATS),
2153 Hotkey('L', "terraform", MTHK_TERRAFORM),
2154 Hotkey('V', "extra_viewport", MTHK_EXTRA_VIEWPORT),
2155 Hotkey(0, "client_list", MTHK_CLIENT_LIST),
2156 Hotkey(0, "sign_list", MTHK_SIGN_LIST),
2157 Hotkey(0, "land_info", MTHK_LANDINFO),
2158 }};
2159};
2160
2162 static constexpr std::tuple<WidgetID, WidgetType, SpriteID> _toolbar_button_sprites[] = {
2163 {WID_TN_PAUSE, WWT_IMGBTN, SPR_IMG_PAUSE},
2164 {WID_TN_FAST_FORWARD, WWT_IMGBTN, SPR_IMG_FASTFORWARD},
2165 {WID_TN_SETTINGS, WWT_IMGBTN, SPR_IMG_SETTINGS},
2166 {WID_TN_SAVE, WWT_IMGBTN_2, SPR_IMG_SAVE},
2167 {WID_TN_SMALL_MAP, WWT_IMGBTN, SPR_IMG_SMALLMAP},
2168 {WID_TN_TOWNS, WWT_IMGBTN, SPR_IMG_TOWN},
2169 {WID_TN_SUBSIDIES, WWT_IMGBTN, SPR_IMG_SUBSIDIES},
2170 {WID_TN_STATIONS, WWT_IMGBTN, SPR_IMG_COMPANY_LIST},
2171 {WID_TN_FINANCES, WWT_IMGBTN, SPR_IMG_COMPANY_FINANCE},
2172 {WID_TN_COMPANIES, WWT_IMGBTN, SPR_IMG_COMPANY_GENERAL},
2173 {WID_TN_STORY, WWT_IMGBTN, SPR_IMG_STORY_BOOK},
2174 {WID_TN_GOAL, WWT_IMGBTN, SPR_IMG_GOAL},
2175 {WID_TN_GRAPHS, WWT_IMGBTN, SPR_IMG_GRAPHS},
2176 {WID_TN_LEAGUE, WWT_IMGBTN, SPR_IMG_COMPANY_LEAGUE},
2177 {WID_TN_INDUSTRIES, WWT_IMGBTN, SPR_IMG_INDUSTRY},
2178 {WID_TN_TRAINS, WWT_IMGBTN, SPR_IMG_TRAINLIST},
2179 {WID_TN_ROADVEHS, WWT_IMGBTN, SPR_IMG_TRUCKLIST},
2180 {WID_TN_SHIPS, WWT_IMGBTN, SPR_IMG_SHIPLIST},
2181 {WID_TN_AIRCRAFT, WWT_IMGBTN, SPR_IMG_AIRPLANESLIST},
2182 {WID_TN_ZOOM_IN, WWT_PUSHIMGBTN, SPR_IMG_ZOOMIN},
2183 {WID_TN_ZOOM_OUT, WWT_PUSHIMGBTN, SPR_IMG_ZOOMOUT},
2184 {WID_TN_RAILS, WWT_IMGBTN, SPR_IMG_BUILDRAIL},
2185 {WID_TN_ROADS, WWT_IMGBTN, SPR_IMG_BUILDROAD},
2186 {WID_TN_TRAMS, WWT_IMGBTN, SPR_IMG_BUILDTRAMS},
2187 {WID_TN_WATER, WWT_IMGBTN, SPR_IMG_BUILDWATER},
2188 {WID_TN_AIR, WWT_IMGBTN, SPR_IMG_BUILDAIR},
2189 {WID_TN_LANDSCAPE, WWT_IMGBTN, SPR_IMG_LANDSCAPING},
2190 {WID_TN_MUSIC_SOUND, WWT_IMGBTN, SPR_IMG_MUSIC},
2191 {WID_TN_MESSAGES, WWT_IMGBTN, SPR_IMG_MESSAGES},
2192 {WID_TN_HELP, WWT_IMGBTN, SPR_IMG_QUERY},
2193 {WID_TN_SWITCH_BAR, WWT_IMGBTN, SPR_IMG_SWITCH_TOOLBAR},
2194};
2195
2200 Dimension GetToolbarMaximalImageSize()
2201{
2202 Dimension d{};
2203 for (const auto &[widget, tp, sprite] : _toolbar_button_sprites) {
2204 if (!SpriteExists(sprite)) continue;
2205 d = maxdim(d, GetSquareScaledSpriteSize(sprite));
2206 }
2207 return d;
2208}
2209
2214 static std::unique_ptr<NWidgetBase> MakeMainToolbar()
2215{
2216 auto hor = std::make_unique<NWidgetMainToolbarContainer>();
2217 for (const auto &[widget, tp, sprite] : _toolbar_button_sprites) {
2218 switch (widget) {
2219 case WID_TN_SMALL_MAP:
2220 case WID_TN_FINANCES:
2221 case WID_TN_VEHICLE_START:
2222 case WID_TN_ZOOM_IN:
2223 case WID_TN_BUILDING_TOOLS_START:
2224 case WID_TN_MUSIC_SOUND:
2225 hor->Add(std::make_unique<NWidgetSpacer>(0, 0));
2226 break;
2227 }
2228 auto leaf = std::make_unique<NWidgetLeaf>(tp, COLOUR_GREY, widget, WidgetData{.sprite = sprite}, STR_TOOLBAR_TOOLTIP_PAUSE_GAME + widget);
2229 leaf->SetToolbarMinimalSize(1);
2230 hor->Add(std::move(leaf));
2231 }
2232
2233 return hor;
2234}
2235
2236static constexpr std::initializer_list<NWidgetPart> _nested_toolbar_normal_widgets = {
2237 NWidgetFunction(MakeMainToolbar),
2238};
2239
2240static WindowDesc _toolb_normal_desc(
2241 WDP_MANUAL, {}, 0, 0,
2242 WC_MAIN_TOOLBAR, WC_NONE,
2243 {WindowDefaultFlag::NoFocus, WindowDefaultFlag::NoClose},
2244 _nested_toolbar_normal_widgets,
2245 &MainToolbarWindow::hotkeys
2246);
2247
2248
2249/* --- Toolbar handling for the scenario editor */
2250
2251static MenuClickedProc * const _scen_toolbar_dropdown_procs[] = {
2252 nullptr, // 0
2253 nullptr, // 1
2254 MenuClickSettings, // 2
2255 MenuClickSaveLoad, // 3
2256 nullptr, // 4
2257 nullptr, // 5
2258 nullptr, // 6
2259 nullptr, // 7
2260 MenuClickMap, // 8
2261 nullptr, // 9
2262 nullptr, // 10
2263 nullptr, // 11
2264 ToolbarScenGenTown, // 12
2265 nullptr, // 13
2266 ToolbarScenBuildRoad, // 14
2267 ToolbarScenBuildTram, // 15
2268 nullptr, // 16
2269 nullptr, // 17
2270 nullptr, // 18
2271 nullptr, // 19
2272 MenuClickMusicWindow, // 20
2273 MenuClickHelp, // 21
2274 nullptr, // 22
2275};
2276
2277static ToolbarButtonProc * const _scen_toolbar_button_procs[] = {
2278 ToolbarPauseClick,
2279 ToolbarFastForwardClick,
2280 ToolbarOptionsClick,
2281 ToolbarScenSaveOrLoad,
2282 ToolbarBtn_NULL,
2283 ToolbarScenDatePanel,
2284 ToolbarScenDateBackward,
2285 ToolbarScenDateForward,
2286 ToolbarScenMapTownDir,
2287 ToolbarZoomInClick,
2288 ToolbarZoomOutClick,
2289 ToolbarScenGenLand,
2290 ToolbarScenGenTownClick,
2291 ToolbarScenGenIndustry,
2292 ToolbarScenBuildRoadClick,
2293 ToolbarScenBuildTramClick,
2294 ToolbarScenBuildDocks,
2295 ToolbarScenPlantTrees,
2296 ToolbarScenPlaceSign,
2297 ToolbarBtn_NULL,
2298 ToolbarMusicClick,
2299 ToolbarHelpClick,
2300 ToolbarSwitchClick,
2301};
2302
2303enum MainToolbarEditorHotkeys : int32_t {
2304 MTEHK_PAUSE,
2305 MTEHK_FASTFORWARD,
2306 MTEHK_SETTINGS,
2307 MTEHK_SAVEGAME,
2308 MTEHK_GENLAND,
2309 MTEHK_GENTOWN,
2310 MTEHK_GENINDUSTRY,
2311 MTEHK_BUILD_ROAD,
2312 MTEHK_BUILD_TRAM,
2313 MTEHK_BUILD_DOCKS,
2314 MTEHK_BUILD_TREES,
2315 MTEHK_SIGN,
2316 MTEHK_MUSIC,
2317 MTEHK_LANDINFO,
2318 MTEHK_SMALL_SCREENSHOT,
2319 MTEHK_ZOOMEDIN_SCREENSHOT,
2320 MTEHK_DEFAULTZOOM_SCREENSHOT,
2321 MTEHK_GIANT_SCREENSHOT,
2322 MTEHK_ZOOM_IN,
2323 MTEHK_ZOOM_OUT,
2324 MTEHK_TERRAFORM,
2325 MTEHK_SMALLMAP,
2326 MTEHK_EXTRA_VIEWPORT,
2327};
2328
2329 struct ScenarioEditorToolbarWindow : Window {
2330 ScenarioEditorToolbarWindow(WindowDesc &desc) : Window(desc)
2331 {
2332 this->InitNested(0);
2333
2334 _last_started_action = CBF_NONE;
2335 this->flags.Reset(WindowFlag::WhiteBorder);
2336 PositionMainToolbar(this);
2337 DoZoomInOutWindow(ZOOM_NONE, this);
2338 }
2339
2340 void FindWindowPlacementAndResize(int, int def_height, bool allow_resize) override
2341 {
2342 Window::FindWindowPlacementAndResize(_toolbar_width, def_height, allow_resize);
2343 }
2344
2345 void OnPaint() override
2346 {
2347 this->SetWidgetDisabledState(WID_TE_DATE_BACKWARD, _settings_game.game_creation.starting_year <= CalendarTime::MIN_YEAR);
2348 this->SetWidgetDisabledState(WID_TE_DATE_FORWARD, _settings_game.game_creation.starting_year >= CalendarTime::MAX_YEAR);
2349 this->SetWidgetDisabledState(WID_TE_ROADS, !GetRoadTypes(true).Any(GetMaskForRoadTramType(RTT_ROAD)));
2350 this->SetWidgetDisabledState(WID_TE_TRAMS, !GetRoadTypes(true).Any(GetMaskForRoadTramType(RTT_TRAM)));
2351
2352 this->DrawWidgets();
2353 }
2354
2355 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
2356 {
2357 switch (widget) {
2358 case WID_TE_DATE:
2359 return GetString(STR_JUST_DATE_LONG, TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1));
2360
2361 default:
2362 return this->Window::GetWidgetString(widget, stringid);
2363 }
2364 }
2365
2366 void DrawWidget(const Rect &r, WidgetID widget) const override
2367 {
2368 switch (widget) {
2369 case WID_TE_SPACER: {
2370 int height = r.Height();
2371 if (height > 2 * GetCharacterHeight(FS_NORMAL)) {
2372 DrawString(r.left, r.right, height / 2 - GetCharacterHeight(FS_NORMAL), STR_SCENEDIT_TOOLBAR_OPENTTD, TC_FROMSTRING, SA_HOR_CENTER);
2373 DrawString(r.left, r.right, height / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER);
2374 } else {
2375 DrawString(r.left, r.right, (height - GetCharacterHeight(FS_NORMAL)) / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING, SA_HOR_CENTER);
2376 }
2377 break;
2378 }
2379 }
2380 }
2381
2382 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
2383 {
2384 switch (widget) {
2385 case WID_TE_SPACER:
2386 size.width = std::max(GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_OPENTTD).width, GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR).width) + padding.width;
2387 break;
2388
2389 case WID_TE_DATE:
2390 size = GetStringBoundingBox(GetString(STR_JUST_DATE_LONG, TimerGameCalendar::ConvertYMDToDate(CalendarTime::MAX_YEAR, 0, 1)));
2391 break;
2392 }
2393 }
2394
2395 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
2396 {
2397 if (_game_mode == GM_MENU) return;
2398 CallBackFunction cbf = _scen_toolbar_button_procs[widget](this);
2399 if (cbf != CBF_NONE) _last_started_action = cbf;
2400 }
2401
2402 void OnDropdownSelect(WidgetID widget, int index, int) override
2403 {
2404 CallBackFunction cbf = _scen_toolbar_dropdown_procs[widget](index);
2405 if (cbf != CBF_NONE) _last_started_action = cbf;
2406 SndClickBeep();
2407 }
2408
2409 EventState OnHotkey(int hotkey) override
2410 {
2411 CallBackFunction cbf = CBF_NONE;
2412 switch (hotkey) {
2413 case MTEHK_PAUSE: ToolbarPauseClick(this); break;
2414 case MTEHK_FASTFORWARD: ToolbarFastForwardClick(this); break;
2415 case MTEHK_SETTINGS: ShowGameOptions(); break;
2416 case MTEHK_SAVEGAME: MenuClickSaveLoad(); break;
2417 case MTEHK_GENLAND: ToolbarScenGenLand(this); break;
2418 case MTEHK_GENTOWN: ToolbarScenGenTownClick(this); break;
2419 case MTEHK_GENINDUSTRY: ToolbarScenGenIndustry(this); break;
2420 case MTEHK_BUILD_ROAD: ToolbarScenBuildRoadClick(this); break;
2421 case MTEHK_BUILD_TRAM: ToolbarScenBuildTramClick(this); break;
2422 case MTEHK_BUILD_DOCKS: ToolbarScenBuildDocks(this); break;
2423 case MTEHK_BUILD_TREES: ToolbarScenPlantTrees(this); break;
2424 case MTEHK_SIGN: cbf = ToolbarScenPlaceSign(this); break;
2425 case MTEHK_MUSIC: ShowMusicWindow(); break;
2426 case MTEHK_LANDINFO: cbf = PlaceLandBlockInfo(); break;
2427 case MTEHK_SMALL_SCREENSHOT: MakeScreenshotWithConfirm(SC_VIEWPORT); break;
2428 case MTEHK_ZOOMEDIN_SCREENSHOT: MakeScreenshotWithConfirm(SC_ZOOMEDIN); break;
2429 case MTEHK_DEFAULTZOOM_SCREENSHOT: MakeScreenshotWithConfirm(SC_DEFAULTZOOM); break;
2430 case MTEHK_GIANT_SCREENSHOT: MakeScreenshotWithConfirm(SC_WORLD); break;
2431 case MTEHK_ZOOM_IN: ToolbarZoomInClick(this); break;
2432 case MTEHK_ZOOM_OUT: ToolbarZoomOutClick(this); break;
2433 case MTEHK_TERRAFORM: ShowEditorTerraformToolbar(); break;
2434 case MTEHK_SMALLMAP: ShowSmallMap(); break;
2435 case MTEHK_EXTRA_VIEWPORT: ShowExtraViewportWindowForTileUnderCursor(); break;
2436 default: return ES_NOT_HANDLED;
2437 }
2438 if (cbf != CBF_NONE) _last_started_action = cbf;
2439 return ES_HANDLED;
2440 }
2441
2442 void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
2443 {
2444 switch (_last_started_action) {
2445 case CBF_PLACE_SIGN:
2446 PlaceProc_Sign(tile);
2447 break;
2448
2449 case CBF_PLACE_LANDINFO:
2450 ShowLandInfo(tile);
2451 break;
2452
2453 default: NOT_REACHED();
2454 }
2455 }
2456
2457 void OnPlaceObjectAbort() override
2458 {
2459 _last_started_action = CBF_NONE;
2460 }
2461
2462 void OnTimeout() override
2463 {
2464 this->SetWidgetsLoweredState(false, WID_TE_DATE_BACKWARD, WID_TE_DATE_FORWARD);
2465 this->SetWidgetDirty(WID_TE_DATE_BACKWARD);
2466 this->SetWidgetDirty(WID_TE_DATE_FORWARD);
2467 }
2468
2470 const IntervalTimer<TimerWindow> refresh_interval = {std::chrono::milliseconds(30), [this](auto) {
2471 if (this->IsWidgetLowered(WID_TE_PAUSE) != _pause_mode.Any()) {
2472 this->ToggleWidgetLoweredState(WID_TE_PAUSE);
2473 this->SetDirty();
2474 }
2475
2476 if (this->IsWidgetLowered(WID_TE_FAST_FORWARD) != (_game_speed != 100)) {
2477 this->ToggleWidgetLoweredState(WID_TE_FAST_FORWARD);
2478 this->SetDirty();
2479 }
2480 }};
2481
2487 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
2488 {
2489 if (!gui_scope) return;
2490 HandleZoomMessage(this, *GetMainWindow()->viewport, WID_TE_ZOOM_IN, WID_TE_ZOOM_OUT);
2491 }
2492
2493 void OnQueryTextFinished(std::optional<std::string> str) override
2494 {
2495 /* Was 'cancel' pressed? */
2496 if (!str.has_value()) return;
2497
2498 TimerGameCalendar::Year value;
2499 if (!str->empty()) {
2500 auto val = ParseInteger(*str, 10, true);
2501 if (!val.has_value()) return;
2502 value = static_cast<TimerGameCalendar::Year>(*val);
2503 } else {
2504 /* An empty string means revert to the default */
2505 value = TimerGameCalendar::Year{CalendarTime::DEF_START_YEAR.base()};
2506 }
2507 SetStartingYear(value);
2508
2509 this->SetDirty();
2510 }
2511
2512 static inline HotkeyList hotkeys{"scenedit_maintoolbar", {
2513 Hotkey({WKC_F1, WKC_PAUSE}, "pause", MTEHK_PAUSE),
2514 Hotkey(0, "fastforward", MTEHK_FASTFORWARD),
2515 Hotkey(WKC_F2, "settings", MTEHK_SETTINGS),
2516 Hotkey(WKC_F3, "saveload", MTEHK_SAVEGAME),
2517 Hotkey(WKC_F4, "gen_land", MTEHK_GENLAND),
2518 Hotkey(WKC_F5, "gen_town", MTEHK_GENTOWN),
2519 Hotkey(WKC_F6, "gen_industry", MTEHK_GENINDUSTRY),
2520 Hotkey(WKC_F7, "build_road", MTEHK_BUILD_ROAD),
2521 Hotkey(0, "build_tram", MTEHK_BUILD_TRAM),
2522 Hotkey(WKC_F8, "build_docks", MTEHK_BUILD_DOCKS),
2523 Hotkey(WKC_F9, "build_trees", MTEHK_BUILD_TREES),
2524 Hotkey(WKC_F10, "build_sign", MTEHK_SIGN),
2525 Hotkey(WKC_F11, "music", MTEHK_MUSIC),
2526 Hotkey(WKC_F12, "land_info", MTEHK_LANDINFO),
2527 Hotkey(WKC_CTRL | 'S', "small_screenshot", MTEHK_SMALL_SCREENSHOT),
2528 Hotkey(WKC_CTRL | 'P', "zoomedin_screenshot", MTEHK_ZOOMEDIN_SCREENSHOT),
2529 Hotkey(WKC_CTRL | 'D', "defaultzoom_screenshot", MTEHK_DEFAULTZOOM_SCREENSHOT),
2530 Hotkey(0, "giant_screenshot", MTEHK_GIANT_SCREENSHOT),
2531 Hotkey({WKC_NUM_PLUS, WKC_EQUALS, WKC_SHIFT | WKC_EQUALS, WKC_SHIFT | WKC_F5}, "zoomin", MTEHK_ZOOM_IN),
2532 Hotkey({WKC_NUM_MINUS, WKC_MINUS, WKC_SHIFT | WKC_MINUS, WKC_SHIFT | WKC_F6}, "zoomout", MTEHK_ZOOM_OUT),
2533 Hotkey('L', "terraform", MTEHK_TERRAFORM),
2534 Hotkey('M', "smallmap", MTEHK_SMALLMAP),
2535 Hotkey('V', "extra_viewport", MTEHK_EXTRA_VIEWPORT),
2536 }};
2537};
2538
2539static constexpr std::initializer_list<NWidgetPart> _nested_toolb_scen_inner_widgets = {
2540 NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_PAUSE), SetSpriteTip(SPR_IMG_PAUSE, STR_TOOLBAR_TOOLTIP_PAUSE_GAME),
2541 NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_FAST_FORWARD), SetSpriteTip(SPR_IMG_FASTFORWARD, STR_TOOLBAR_TOOLTIP_FORWARD),
2542 NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SETTINGS), SetSpriteTip(SPR_IMG_SETTINGS, STR_TOOLBAR_TOOLTIP_OPTIONS),
2543 NWidget(WWT_IMGBTN_2, COLOUR_GREY, WID_TE_SAVE), SetSpriteTip(SPR_IMG_SAVE, STR_SCENEDIT_TOOLBAR_SAVE_SCENARIO_LOAD_SCENARIO_TOOLTIP),
2544 NWidget(NWID_SPACER),
2545 NWidget(WWT_PANEL, COLOUR_GREY, WID_TE_SPACER), EndContainer(),
2546 NWidget(NWID_SPACER),
2547 NWidget(WWT_PANEL, COLOUR_GREY, WID_TE_DATE_PANEL),
2548 NWidget(NWID_HORIZONTAL), SetPIP(2, 2, 2), SetPadding(1),
2549 NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_DATE_BACKWARD), SetSpriteTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_MOVE_THE_STARTING_DATE_BACKWARD_TOOLTIP), SetFill(0, 1),
2550 NWidget(WWT_TEXT, INVALID_COLOUR, WID_TE_DATE), SetToolTip(STR_SCENEDIT_TOOLBAR_SET_DATE_TOOLTIP), SetTextStyle(TC_WHITE), SetAlignment(SA_CENTER), SetFill(0, 1),
2551 NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_DATE_FORWARD), SetSpriteTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_MOVE_THE_STARTING_DATE_FORWARD_TOOLTIP), SetFill(0, 1),
2552 EndContainer(),
2553 EndContainer(),
2554 NWidget(NWID_SPACER),
2555 NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SMALL_MAP), SetSpriteTip(SPR_IMG_SMALLMAP, STR_SCENEDIT_TOOLBAR_DISPLAY_MAP_TOWN_DIRECTORY_TOOLTIP),
2556 NWidget(NWID_SPACER),
2557 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_ZOOM_IN), SetSpriteTip(SPR_IMG_ZOOMIN, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_IN),
2558 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_ZOOM_OUT), SetSpriteTip(SPR_IMG_ZOOMOUT, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_OUT),
2559 NWidget(NWID_SPACER),
2560 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_LAND_GENERATE), SetSpriteTip(SPR_IMG_LANDSCAPING, STR_SCENEDIT_TOOLBAR_LANDSCAPE_GENERATION_TOOLTIP),
2561 NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_TOWN_GENERATE), SetSpriteTip(SPR_IMG_TOWN, STR_SCENEDIT_TOOLBAR_TOWN_GENERATION_TOOLTIP),
2562 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_INDUSTRY), SetSpriteTip(SPR_IMG_INDUSTRY, STR_SCENEDIT_TOOLBAR_INDUSTRY_GENERATION_TOOLTIP),
2563 NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_ROADS), SetSpriteTip(SPR_IMG_BUILDROAD, STR_SCENEDIT_TOOLBAR_ROAD_CONSTRUCTION_TOOLTIP),
2564 NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_TRAMS), SetSpriteTip(SPR_IMG_BUILDTRAMS, STR_SCENEDIT_TOOLBAR_TRAM_CONSTRUCTION_TOOLTIP),
2565 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_WATER), SetSpriteTip(SPR_IMG_BUILDWATER, STR_TOOLBAR_TOOLTIP_BUILD_SHIP_DOCKS),
2566 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_TREES), SetSpriteTip(SPR_IMG_PLANTTREES, STR_SCENEDIT_TOOLBAR_PLANT_TREES_TOOLTIP),
2567 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TE_SIGNS), SetSpriteTip(SPR_IMG_SIGN, STR_SCENEDIT_TOOLBAR_PLACE_SIGN_TOOLTIP),
2568 NWidget(NWID_SPACER),
2569 NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_MUSIC_SOUND), SetSpriteTip(SPR_IMG_MUSIC, STR_TOOLBAR_TOOLTIP_SHOW_SOUND_MUSIC_WINDOW),
2570 NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_HELP), SetSpriteTip(SPR_IMG_QUERY, STR_TOOLBAR_TOOLTIP_LAND_BLOCK_INFORMATION),
2571 NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SWITCH_BAR), SetSpriteTip(SPR_IMG_SWITCH_TOOLBAR, STR_TOOLBAR_TOOLTIP_SWITCH_TOOLBAR),
2572};
2573
2574static std::unique_ptr<NWidgetBase> MakeScenarioToolbar()
2575{
2576 return MakeNWidgets(_nested_toolb_scen_inner_widgets, std::make_unique<NWidgetScenarioToolbarContainer>());
2577}
2578
2579static constexpr std::initializer_list<NWidgetPart> _nested_toolb_scen_widgets = {
2580 NWidgetFunction(MakeScenarioToolbar),
2581};
2582
2583static WindowDesc _toolb_scen_desc(
2584 WDP_MANUAL, {}, 0, 0,
2585 WC_MAIN_TOOLBAR, WC_NONE,
2586 {WindowDefaultFlag::NoFocus, WindowDefaultFlag::NoClose},
2587 _nested_toolb_scen_widgets,
2588 &ScenarioEditorToolbarWindow::hotkeys
2589);
2590
2592 void AllocateToolbar()
2593{
2594 /* Clean old GUI values; railtype is (re)set by rail_gui.cpp */
2595 _last_built_roadtype = ROADTYPE_ROAD;
2596 _last_built_tramtype = ROADTYPE_TRAM;
2597
2598 if (_game_mode == GM_EDITOR) {
2599 new ScenarioEditorToolbarWindow(_toolb_scen_desc);
2600 } else {
2601 new MainToolbarWindow(_toolb_normal_desc);
2602 }
2603}
ShowAIConfigWindow
void ShowAIConfigWindow()
Open the AI config window.
Definition ai_gui.cpp:334
ai_gui.hpp
Window for configuring the AIs
ShowBuildAirToolbar
Window * ShowBuildAirToolbar()
Open the build airport toolbar window.
Definition airport_gui.cpp:233
HasBit
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition bitmath_func.hpp:103
ToggleBit
constexpr T ToggleBit(T &x, const uint8_t y)
Toggles a bit in a variable.
Definition bitmath_func.hpp:157
cheat_func.h
Functions related to cheating.
ShowCheatWindow
void ShowCheatWindow()
Open cheat window.
Definition cheat_gui.cpp:651
BaseBitSet::Test
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Definition base_bitset_type.hpp:141
BaseBitSet::None
constexpr bool None() const
Test if none of the values are set.
Definition base_bitset_type.hpp:188
BaseBitSet::Reset
constexpr Timpl & Reset()
Reset all bits.
Definition base_bitset_type.hpp:83
BaseBitSet::Flip
constexpr Timpl & Flip(Tvalue_type value)
Flip the value-th bit.
Definition base_bitset_type.hpp:116
BaseBitSet::Set
constexpr Timpl & Set()
Set all bits.
Definition base_bitset_type.hpp:40
BaseBitSet::Any
constexpr bool Any(const Timpl &other) const
Test if any of the given values are set.
Definition base_bitset_type.hpp:170
CompanyMask
Definition company_type.h:43
DropDownIcon
Drop down icon component.
Definition dropdown_common_type.h:113
DropDownListCompanyItem
Company name list item, with company-colour icon, name, and lock components.
Definition toolbar_gui.cpp:105
EnumBitSet< DropDownOption, uint8_t >
IntervalTimer
An interval timer will fire every interval, and will continue to fire until it is deleted.
Definition timer.h:76
LinkGraphSchedule::instance
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
Definition linkgraphschedule.h:52
LinkGraphSchedule::ShiftDates
void ShiftDates(TimerGameEconomy::Date interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
Definition linkgraphschedule.cpp:135
NWidgetBase
Baseclass for nested widgets.
Definition widget_type.h:137
NWidgetBase::type
WidgetType type
Type of the widget / nested widget.
Definition widget_type.h:227
NWidgetBase::resize_x
uint resize_x
Horizontal resize step (0 means not resizable).
Definition widget_type.h:230
NWidgetBase::fill_x
uint fill_x
Horizontal fill stepsize (from initial size, 0 means not resizable).
Definition widget_type.h:228
NWidgetBase::smallest_x
uint smallest_x
Smallest horizontal size of the widget in a filled window.
Definition widget_type.h:235
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition widget_type.h:238
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition widget_type.h:244
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition widget_type.h:243
NWidgetBase::smallest_y
uint smallest_y
Smallest vertical size of the widget in a filled window.
Definition widget_type.h:236
NWidgetBase::fill_y
uint fill_y
Vertical fill stepsize (from initial size, 0 means not resizable).
Definition widget_type.h:229
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition widget_type.h:231
NWidgetBase::current_y
uint current_y
Current vertical size (after resizing).
Definition widget_type.h:239
NWidgetContainer
Baseclass for container widgets.
Definition widget_type.h:474
NWidgetContainer::Draw
void Draw(const Window *w) override
Draw the widgets of the tree.
Definition widget.cpp:1335
NWidgetContainer::children
std::vector< std::unique_ptr< NWidgetBase > > children
Child widgets in container.
Definition widget_type.h:502
NWidgetCore
Base class for a 'real' widget.
Definition widget_type.h:371
NWidgetMainToolbarContainer
Container for the 'normal' main toolbar.
Definition toolbar_gui.cpp:1501
NWidgetMainToolbarContainer::GetButtonArrangement
const WidgetID * GetButtonArrangement(uint &width, uint &arrangeable_count, uint &button_count, uint &spacer_count) const override
Get the arrangement of the buttons for the toolbar.
Definition toolbar_gui.cpp:1502
NWidgetScenarioToolbarContainer
Container for the scenario editor's toolbar.
Definition toolbar_gui.cpp:1823
NWidgetScenarioToolbarContainer::panel_widths
std::array< uint, 2 > panel_widths
The width of the two panels (the text panel and date panel)
Definition toolbar_gui.cpp:1824
NWidgetScenarioToolbarContainer::GetButtonArrangement
const WidgetID * GetButtonArrangement(uint &width, uint &arrangeable_count, uint &button_count, uint &spacer_count) const override
Get the arrangement of the buttons for the toolbar.
Definition toolbar_gui.cpp:1842
NWidgetScenarioToolbarContainer::SetupSmallestSize
void SetupSmallestSize(Window *w) override
Compute smallest size needed by the widget.
Definition toolbar_gui.cpp:1826
NWidgetToolbarContainer
Full blown container to make it behave exactly as we want :)
Definition toolbar_gui.cpp:1355
NWidgetToolbarContainer::spacers
uint spacers
Number of spacer widgets in this toolbar.
Definition toolbar_gui.cpp:1357
NWidgetToolbarContainer::AssignSizePosition
void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override
Assign size and position to the widget.
Definition toolbar_gui.cpp:1413
NWidgetToolbarContainer::SetupSmallestSize
void SetupSmallestSize(Window *w) override
Compute smallest size needed by the widget.
Definition toolbar_gui.cpp:1374
NWidgetToolbarContainer::IsButton
bool IsButton(WidgetType type) const
Check whether the given widget type is a button for us.
Definition toolbar_gui.cpp:1369
NWidgetToolbarContainer::Draw
void Draw(const Window *w) override
Draw the widgets of the tree.
Definition toolbar_gui.cpp:1479
NWidgetToolbarContainer::GetButtonArrangement
virtual const WidgetID * GetButtonArrangement(uint &width, uint &arrangeable_count, uint &button_count, uint &spacer_count) const =0
Get the arrangement of the buttons for the toolbar.
TimerGameCalendar::ConvertYMDToDate
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition timer_game_calendar.cpp:55
TimerGameCalendar::SetDate
static void SetDate(Date date, DateFract fract)
Set the date.
Definition timer_game_calendar.cpp:66
TimerGameConst< struct Calendar >::DEF_START_YEAR
static constexpr TimerGame< struct Calendar >::Year DEF_START_YEAR
The default starting year.
Definition timer_game_common.h:179
TimerGameConst< struct Calendar >::MIN_YEAR
static constexpr TimerGame< struct Calendar >::Year MIN_YEAR
The absolute minimum year in OTTD.
Definition timer_game_common.h:176
TimerGameConst< struct Calendar >::MAX_YEAR
static constexpr TimerGame< struct Calendar >::Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date,...
Definition timer_game_common.h:173
TimerGameEconomy::date
static Date date
Current date in days (day counter).
Definition timer_game_economy.h:38
TimerGameEconomy::SetDate
static void SetDate(Date date, DateFract fract)
Set the date.
Definition timer_game_economy.cpp:82
command_func.h
Functions related to commands.
GetCompanyPalette
PaletteID GetCompanyPalette(CompanyID company)
Get the palette for recolouring with a company colour.
Definition company_cmd.cpp:164
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition company_cmd.cpp:55
company_func.h
Functions related to companies.
ShowCompanyFinances
void ShowCompanyFinances(CompanyID company)
Open the finances window of a company.
Definition company_gui.cpp:569
ShowCompany
void ShowCompany(CompanyID company)
Show the window with the overview of the company.
Definition company_gui.cpp:2307
company_gui.h
GUI Functions related to companies.
ShowCompanyStations
void ShowCompanyStations(CompanyID company)
Opens window with list of company's stations.
Definition station_gui.cpp:808
COMPANY_SPECTATOR
static constexpr CompanyID COMPANY_SPECTATOR
The client is spectating.
Definition company_type.h:21
ShowFramerateWindow
void ShowFramerateWindow()
Open the general framerate window.
Definition framerate_gui.cpp:986
IConsoleSwitch
void IConsoleSwitch()
Toggle in-game console between opened and closed.
Definition console_gui.cpp:426
console_gui.h
GUI related functions in the console.
ShowBuildDocksScenToolbar
Window * ShowBuildDocksScenToolbar()
Open the build water toolbar window for the scenario editor.
Definition dock_gui.cpp:415
ShowBuildDocksToolbar
Window * ShowBuildDocksToolbar()
Open the build water toolbar window.
Definition dock_gui.cpp:374
ShowDropDownList
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, DropDownOptions options)
Show a drop down list.
Definition dropdown.cpp:418
dropdown_common_type.h
Common drop down list components.
dropdown_func.h
Functions related to the drop down widget.
dropdown_type.h
Types related to the drop down widget.
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:56
DropDownOption::InstantClose
@ InstantClose
Set if releasing mouse button should close the list regardless of where the cursor is.
engine_base.h
Base class for engines.
SLO_SAVE
@ SLO_SAVE
File is being saved.
Definition fileio_type.h:55
SLO_LOAD
@ SLO_LOAD
File is being loaded.
Definition fileio_type.h:54
FT_SCENARIO
@ FT_SCENARIO
old or new scenario
Definition fileio_type.h:20
FT_HEIGHTMAP
@ FT_HEIGHTMAP
heightmap file
Definition fileio_type.h:21
FT_SAVEGAME
@ FT_SAVEGAME
old or new savegame
Definition fileio_type.h:19
fios.h
Declarations for savegames operations.
ShowSaveLoadDialog
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
Definition fios_gui.cpp:1000
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition fontcache.cpp:87
framerate_type.h
Types for recording game performance data.
game.hpp
Base functions for all Games.
ShowGSConfigWindow
void ShowGSConfigWindow()
Open the GS config window.
Definition game_gui.cpp:425
game_gui.hpp
Window for configuring the Games
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition geometry_func.cpp:22
geometry_func.hpp
Geometry functions.
GetStringBoundingBox
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition gfx.cpp:897
DrawString
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition gfx.cpp:668
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition gfx.cpp:38
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition gfx.cpp:42
_game_speed
uint16_t _game_speed
Current game-speed; 100 is 1x, 0 is infinite.
Definition gfx.cpp:40
_pause_mode
PauseModes _pause_mode
The current pause mode.
Definition gfx.cpp:50
GfxFillRect
void GfxFillRect(int left, int top, int right, int bottom, const std::variant< PixelColour, PaletteID > &colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
Definition gfx.cpp:115
GetSquareScaledSpriteSize
Dimension GetSquareScaledSpriteSize(SpriteID sprid)
Scale sprite size for GUI, as a square.
Definition widget.cpp:83
CheckBlitter
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
Definition gfxinit.cpp:325
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition gfx_type.h:249
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition gfx_type.h:389
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition gfx_type.h:398
FILLRECT_CHECKER
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
Definition gfx_type.h:346
WKC_MINUS
@ WKC_MINUS
Definition gfx_type.h:106
WKC_EQUALS
@ WKC_EQUALS
= Equals
Definition gfx_type.h:99
goal_base.h
Goal base class.
ShowGoalsList
void ShowGoalsList(CompanyID company)
Open a goal list window.
Definition goal_gui.cpp:311
graph_gui.h
Graph GUI functions.
NWidgetFunction
constexpr NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition widget_type.h:1448
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition widget_type.h:1222
SetSpriteTip
constexpr NWidgetPart SetSpriteTip(SpriteID sprite, StringID tip={})
Widget part function for setting the sprite and tooltip.
Definition widget_type.h:1254
SetPIP
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
Definition widget_type.h:1378
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition widget_type.h:1335
SetTextStyle
constexpr NWidgetPart SetTextStyle(TextColour colour, FontSize size=FS_NORMAL)
Widget part function for setting the text style.
Definition widget_type.h:1201
MakeNWidgets
std::unique_ptr< NWidgetBase > MakeNWidgets(std::span< const NWidgetPart > nwid_parts, std::unique_ptr< NWidgetBase > &&container)
Construct a nested widget tree from an array of parts.
Definition widget.cpp:3410
SetToolTip
constexpr NWidgetPart SetToolTip(StringID tip)
Widget part function for setting tooltip and clearing the widget data.
Definition widget_type.h:1321
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition widget_type.h:1232
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=INVALID_WIDGET)
Widget part function for starting a new 'real' widget.
Definition widget_type.h:1427
SetAlignment
constexpr NWidgetPart SetAlignment(StringAlignment align)
Widget part function for setting the alignment of text/images.
Definition widget_type.h:1211
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition window.cpp:968
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition gfx.cpp:1549
gui.h
GUI functions that shouldn't be here.
ShowStoryBook
void ShowStoryBook(CompanyID company, StoryPageID page_id=StoryPageID::Invalid(), bool centered=false)
Raise or create the story book window for company, at page page_id.
Definition story_gui.cpp:1043
ShowIndustryCargoesWindow
void ShowIndustryCargoesWindow()
Open the industry and cargoes window with an industry.
Definition industry_gui.cpp:3194
ShowLandInfo
void ShowLandInfo(TileIndex tile)
Show land information window.
Definition misc_gui.cpp:321
ShowExtraViewportWindowForTileUnderCursor
void ShowExtraViewportWindowForTileUnderCursor()
Show a new Extra Viewport window.
Definition viewport_gui.cpp:174
ShowExtraViewportWindow
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
Definition viewport_gui.cpp:159
ShowGameOptions
void ShowGameOptions()
Open the game options window.
Definition settings_gui.cpp:1851
help_gui.h
GUI to access manuals and related.
highscore.h
Declaration of functions and types defined in highscore.h and highscore_gui.h.
ShowHighscoreTable
void ShowHighscoreTable(int difficulty=SP_CUSTOM, int8_t rank=-1)
Show the highscore table for a given difficulty.
Definition highscore_gui.cpp:243
hotkeys.h
Hotkey related functions.
house.h
definition of HouseSpec and accessors
league_base.h
LeagueTable base class.
league_gui.h
League table GUI functions.
ShowLinkGraphLegend
void ShowLinkGraphLegend()
Open a link graph legend window.
Definition linkgraph_gui.cpp:542
linkgraph_gui.h
Declaration of linkgraph overlay GUI.
DoZoomInOutWindow
bool DoZoomInOutWindow(ZoomStateChange how, Window *w)
Zooms a viewport in a window in or out.
Definition main_gui.cpp:93
CeilDiv
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Definition math_func.hpp:310
Clamp
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition math_func.hpp:79
misc_cmd.h
Miscellaneous command definitions.
ShowQueryString
void ShowQueryString(std::string_view 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:1064
_networking
bool _networking
are we in networking mode?
Definition network.cpp:67
_network_server
bool _network_server
network-server is active
Definition network.cpp:68
NetworkCanJoinCompany
bool NetworkCanJoinCompany(CompanyID company_id)
Returns whether the given company can be joined by this client.
Definition network.cpp:143
network.h
Basic functions/variables used all over the place.
NetworkClientRequestMove
void NetworkClientRequestMove(CompanyID company_id)
Notify the server of this client wanting to be moved to another company.
Definition network_client.cpp:1214
network_func.h
Network functions used by other parts of OpenTTD.
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:1976
network_gui.h
GUIs related to networking.
CLIENT_ID_SERVER
@ CLIENT_ID_SERVER
Servers always have this ID.
Definition network_type.h:45
_grfconfig
GRFConfigList _grfconfig
First item in list of current GRF set up.
Definition newgrf_config.cpp:154
ShowNewGRFSettings
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfigList &config)
Setup the NewGRF gui.
Definition newgrf_gui.cpp:1968
newgrf_debug.h
Functions/types related to NewGRF debugging.
ShowSpriteAlignerWindow
void ShowSpriteAlignerWindow()
Show the window for aligning sprites.
Definition newgrf_debug_gui.cpp:1202
ShowLastNewsMessage
void ShowLastNewsMessage()
Show previous news item.
Definition news_gui.cpp:1138
ShowMessageHistory
void ShowMessageHistory()
Display window with news messages history.
Definition news_gui.cpp:1303
news_gui.h
GUI functions related to the news.
DO_SHOW_TOWN_NAMES
@ DO_SHOW_TOWN_NAMES
Display town names.
Definition openttd.h:46
DO_SHOW_COMPETITOR_SIGNS
@ DO_SHOW_COMPETITOR_SIGNS
Display signs, station names and waypoint names of opponent companies. Buoys and oilrig-stations are ...
Definition openttd.h:52
DO_FULL_DETAIL
@ DO_FULL_DETAIL
Also draw details of track and roads.
Definition openttd.h:50
DO_SHOW_SIGNS
@ DO_SHOW_SIGNS
Display signs.
Definition openttd.h:48
DO_SHOW_WAYPOINT_NAMES
@ DO_SHOW_WAYPOINT_NAMES
Display waypoint names.
Definition openttd.h:51
DO_SHOW_STATION_NAMES
@ DO_SHOW_STATION_NAMES
Display station names.
Definition openttd.h:47
DO_FULL_ANIMATION
@ DO_FULL_ANIMATION
Perform palette animation.
Definition openttd.h:49
PauseMode::Normal
@ Normal
A game normally paused.
PC_VERY_DARK_RED
static constexpr PixelColour PC_VERY_DARK_RED
Almost-black red palette colour.
Definition palette_func.h:101
PC_DARK_RED
static constexpr PixelColour PC_DARK_RED
Dark red palette colour.
Definition palette_func.h:102
ShowBuildRailToolbar
Window * ShowBuildRailToolbar(RailType railtype)
Open the build rail toolbar window for a specific rail type.
Definition rail_gui.cpp:923
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:2030
rail_gui.h
Functions/types etc.
RailType
RailType
Enumeration for all possible railtypes.
Definition rail_type.h:25
GetRoadTypes
RoadTypes GetRoadTypes(bool introduces)
Get list of road types, regardless of company availability.
Definition road.cpp:238
road.h
Road specific functions.
GetMaskForRoadTramType
RoadTypes GetMaskForRoadTramType(RoadTramType rtt)
Get the mask for road types of the given RoadTramType.
Definition road.h:183
ShowBuildRoadScenToolbar
Window * ShowBuildRoadScenToolbar(RoadType roadtype)
Show the road building toolbar in the scenario editor.
Definition road_gui.cpp:1097
ShowBuildRoadToolbar
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
Definition road_gui.cpp:1006
road_gui.h
Functions/types related to the road GUIs.
RTT_ROAD
@ RTT_ROAD
Road road type.
Definition road_type.h:38
RTT_TRAM
@ RTT_TRAM
Tram road type.
Definition road_type.h:39
RTTB_ROAD
@ RTTB_ROAD
Road road type bit.
Definition road_type.h:43
RTTB_TRAM
@ RTTB_TRAM
Tram road type bit.
Definition road_type.h:44
RoadType
RoadType
The different roadtypes we support.
Definition road_type.h:23
ROADTYPE_TRAM
@ ROADTYPE_TRAM
Trams.
Definition road_type.h:26
ROADTYPE_ROAD
@ ROADTYPE_ROAD
Basic road type.
Definition road_type.h:25
safeguards.h
A number of safeguards to prevent using unsafe methods.
MakeScreenshotWithConfirm
void MakeScreenshotWithConfirm(ScreenshotType t)
Make a screenshot.
Definition screenshot.cpp:353
screenshot.h
Functions to make screenshots.
SC_VIEWPORT
@ SC_VIEWPORT
Screenshot of viewport.
Definition screenshot.h:17
SC_ZOOMEDIN
@ SC_ZOOMEDIN
Fully zoomed in screenshot of the visible area.
Definition screenshot.h:19
SC_WORLD
@ SC_WORLD
World screenshot.
Definition screenshot.h:21
SC_DEFAULTZOOM
@ SC_DEFAULTZOOM
Zoomed to default zoom level screenshot of the visible area.
Definition screenshot.h:20
screenshot_gui.h
GUI functions related to screenshots.
ShowScriptDebugWindow
Window * ShowScriptDebugWindow(CompanyID show_company, bool new_window)
Open the Script debug window and select the given company.
Definition script_gui.cpp:1264
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:61
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
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:147
signs_func.h
Functions related to signs.
ShowSignList
Window * ShowSignList()
Open the sign list window.
Definition signs_gui.cpp:373
ShowSmallMap
void ShowSmallMap()
Show the smallmap window.
Definition smallmap_gui.cpp:2065
smallmap_gui.h
Smallmap GUI functions.
SndConfirmBeep
void SndConfirmBeep()
Play a beep sound for a confirm event if enabled in settings.
Definition sound.cpp:261
SndClickBeep
void SndClickBeep()
Play a beep sound for a click event if enabled in settings.
Definition sound.cpp:253
sound_func.h
Functions related to sound.
spritecache.h
Functions to cache sprites in memory.
STATION_FACILITY_GHOST
static constexpr StationFacility STATION_FACILITY_GHOST
Fake 'facility' to allow toggling display of recently-removed station signs.
Definition station_type.h:61
StationFacility::Dock
@ Dock
Station with a dock.
StationFacility::TruckStop
@ TruckStop
Station with truck stops.
StationFacility::Train
@ Train
Station with train station.
StationFacility::Airport
@ Airport
Station with an airport.
StationFacility::BusStop
@ BusStop
Station with bus stops.
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
lengthof
#define lengthof(array)
Return the length of an fixed size array.
Definition stdafx.h:271
story_base.h
StoryPage base class.
string_consumer.hpp
Parse strings.
ParseInteger
static std::optional< T > ParseInteger(std::string_view arg, int base=10, bool clamp=false)
Change a string into its number representation.
Definition string_consumer.hpp:917
CS_NUMERAL
@ CS_NUMERAL
Only numeric ones.
Definition string_type.h:26
GetString
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:424
strings_func.h
Functions related to OTTD's strings.
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition strings_type.h:19
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition settings_type.h:650
CommandHelper
Definition command_func.h:84
Company
Definition company_base.h:127
Coord2D< int >
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition geometry_type.hpp:56
EconomySettings::found_town
TownFounding found_town
town founding.
Definition settings_type.h:558
EconomySettings::place_houses
PlaceHouses place_houses
players are allowed to place town houses.
Definition settings_type.h:559
GUISettings::UserIsAllowedToChangeNewGRFs
bool UserIsAllowedToChangeNewGRFs() const
Returns true when the user has sufficient privileges to edit newgrfs on a running game.
Definition settings_type.h:264
GUISettings::toolbar_dropdown_autoselect
bool toolbar_dropdown_autoselect
should toolbar dropdown buttons autoselect when releasing the mouse button
Definition settings_type.h:207
GUISettings::newgrf_developer_tools
bool newgrf_developer_tools
activate NewGRF developer tools and allow modifying NewGRFs in an existing game
Definition settings_type.h:251
GameCreationSettings::starting_year
TimerGameCalendar::Year starting_year
starting date
Definition settings_type.h:380
GameSettings::economy
EconomySettings economy
settings to change the economy
Definition settings_type.h:642
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition settings_type.h:634
HotkeyList
List of hotkeys for a window.
Definition hotkeys.h:37
Hotkey
All data for a single hotkey.
Definition hotkeys.h:21
LeagueTable
Struct about custom league tables.
Definition league_base.h:55
MainToolbarWindow
Main toolbar.
Definition toolbar_gui.cpp:1979
MainToolbarWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition toolbar_gui.cpp:2023
MainToolbarWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition toolbar_gui.cpp:1997
MainToolbarWindow::OnClick
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition toolbar_gui.cpp:2012
MainToolbarWindow::FindWindowPlacementAndResize
void FindWindowPlacementAndResize(int, int def_height, bool allow_resize) override
Resize window towards the default size.
Definition toolbar_gui.cpp:1992
MainToolbarWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition toolbar_gui.cpp:2111
MainToolbarWindow::OnDropdownSelect
void OnDropdownSelect(WidgetID widget, int index, int) override
A dropdown option associated to this window has been selected.
Definition toolbar_gui.cpp:2017
MainToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition toolbar_gui.cpp:2088
MainToolbarWindow::refresh_interval
const IntervalTimer< TimerWindow > refresh_interval
Refresh the state of pause / game-speed on a regular interval.
Definition toolbar_gui.cpp:2094
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:2073
PoolID< uint8_t, struct CompanyIDTag, 0xF, 0xFF >
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:436
Pool::PoolItem<&_league_table_pool >::GetNumItems
static size_t GetNumItems()
Returns number of valid items in the pool.
Definition pool_type.hpp:417
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(auto index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition pool_type.hpp:376
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition geometry_type.hpp:101
Rect::Height
int Height() const
Get height of Rect.
Definition geometry_type.hpp:117
ScenarioEditorToolbarWindow
Definition toolbar_gui.cpp:2329
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:2442
ScenarioEditorToolbarWindow::OnClick
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition toolbar_gui.cpp:2395
ScenarioEditorToolbarWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition toolbar_gui.cpp:2345
ScenarioEditorToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition toolbar_gui.cpp:2457
ScenarioEditorToolbarWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition toolbar_gui.cpp:2462
ScenarioEditorToolbarWindow::OnDropdownSelect
void OnDropdownSelect(WidgetID widget, int index, int) override
A dropdown option associated to this window has been selected.
Definition toolbar_gui.cpp:2402
ScenarioEditorToolbarWindow::GetWidgetString
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
Definition toolbar_gui.cpp:2355
ScenarioEditorToolbarWindow::refresh_interval
const IntervalTimer< TimerWindow > refresh_interval
Refresh the state of pause / game-speed on a regular interval.
Definition toolbar_gui.cpp:2470
ScenarioEditorToolbarWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition toolbar_gui.cpp:2409
ScenarioEditorToolbarWindow::DrawWidget
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
Definition toolbar_gui.cpp:2366
ScenarioEditorToolbarWindow::FindWindowPlacementAndResize
void FindWindowPlacementAndResize(int, int def_height, bool allow_resize) override
Resize window towards the default size.
Definition toolbar_gui.cpp:2340
ScenarioEditorToolbarWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition toolbar_gui.cpp:2487
ScenarioEditorToolbarWindow::OnQueryTextFinished
void OnQueryTextFinished(std::optional< std::string > str) override
The query window opened from this window has closed.
Definition toolbar_gui.cpp:2493
ScenarioEditorToolbarWindow::UpdateWidgetSize
void UpdateWidgetSize(WidgetID 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:2382
StrongType::Typedef
Templated helper to make a type-safe 'typedef' representing a single POD value.
Definition strong_typedef_type.hpp:130
WidgetData
Container with the data associated to a single widget.
Definition widget_type.h:358
WindowDesc
High level window description.
Definition window_gui.h:168
Window
Data structure for an opened window.
Definition window_gui.h:274
Window::ReInit
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
Definition window.cpp:980
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition widget.cpp:784
Window::SetWidgetDirty
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition window.cpp:558
Window::timeout_timer
uint8_t timeout_timer
Timer value of the WindowFlag::Timeout for flags.
Definition window_gui.h:307
Window::viewport
std::unique_ptr< ViewportData > viewport
Pointer to viewport data, if present.
Definition window_gui.h:319
Window::GetWidgetString
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
Definition window.cpp:506
Window::resize
ResizeInfo resize
Resize information.
Definition window_gui.h:315
Window::SetWidgetsDisabledState
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
Definition window_gui.h:516
Window::IsWidgetLowered
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
Definition window_gui.h:492
Window::IsWidgetDisabled
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
Definition window_gui.h:411
Window::SetWidgetsLoweredState
void SetWidgetsLoweredState(bool lowered_stat, Args... widgets)
Sets the lowered/raised status of a list of widgets.
Definition window_gui.h:527
Window::SetWidgetLoweredState
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition window_gui.h:442
Window::FindWindowPlacementAndResize
virtual void FindWindowPlacementAndResize(int def_width, int def_height, bool allow_resize)
Resize window towards the default size.
Definition window.cpp:1476
Window::HandleButtonClick
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
Definition window.cpp:597
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition window.cpp:1823
Window::flags
WindowFlags flags
Window flags.
Definition window_gui.h:301
Window::SetWidgetDisabledState
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition window_gui.h:382
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition window_gui.h:313
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition window_gui.h:312
Window::ToggleWidgetLoweredState
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
Definition window_gui.h:451
ShowEditorTerraformToolbar
Window * ShowEditorTerraformToolbar()
Show the toolbar for terraforming in the scenario editor.
Definition terraform_gui.cpp:742
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition terraform_gui.cpp:364
terraform_gui.h
GUI stuff related to terraforming.
textbuf_gui.h
Stuff related to the text buffer GUI.
QueryStringFlag::EnableDefault
@ EnableDefault
enable the 'Default' button ("\0" is returned)
tilehighlight_func.h
Functions related to tile highlights.
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition viewport.cpp:3573
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:3525
HT_RECT
@ HT_RECT
rectangle (stations, depots, ...)
Definition tilehighlight_type.h:21
timer.h
Definition of Interval and OneShot timers.
timer_game_calendar.h
Definition of the game-calendar-timer.
timer_window.h
Definition of the Window system.
MenuClickForest
static CallBackFunction MenuClickForest(int index)
Handle click on the entry in the landscaping menu.
Definition toolbar_gui.cpp:999
SaveLoadEditorMenuEntries
SaveLoadEditorMenuEntries
SaveLoad entries in scenario editor mode.
Definition toolbar_gui.cpp:346
PopupMainToolbarMenu
static void PopupMainToolbarMenu(Window *w, WidgetID widget, DropDownList &&list, int def)
Pop up a generic text only menu.
Definition toolbar_gui.cpp:125
MenuClickCompany
static CallBackFunction MenuClickCompany(int index)
Handle click on the entry in the Company menu.
Definition toolbar_gui.cpp:586
MenuClickStations
static CallBackFunction MenuClickStations(int index)
Handle click on the entry in the Stations menu.
Definition toolbar_gui.cpp:546
MenuClickTown
static CallBackFunction MenuClickTown(int index)
Handle click on one of the entries in the Town menu.
Definition toolbar_gui.cpp:499
LTMN_PERFORMANCE_LEAGUE
static const int LTMN_PERFORMANCE_LEAGUE
Show default league table.
Definition toolbar_gui.cpp:660
ToolbarMode
ToolbarMode
Toolbar modes.
Definition toolbar_gui.cpp:87
MenuClickNewspaper
static CallBackFunction MenuClickNewspaper(int index)
Handle click on the entry in the Newspaper menu.
Definition toolbar_gui.cpp:1042
LTMN_PERFORMANCE_RATING
static const int LTMN_PERFORMANCE_RATING
Show detailed performance rating.
Definition toolbar_gui.cpp:661
CallBackFunction
CallBackFunction
Callback functions.
Definition toolbar_gui.cpp:94
ToolbarSaveClick
static CallBackFunction ToolbarSaveClick(Window *w)
Handle click on Save button in toolbar in normal game mode.
Definition toolbar_gui.cpp:371
SaveLoadNormalMenuEntries
SaveLoadNormalMenuEntries
SaveLoad entries in normal game mode.
Definition toolbar_gui.cpp:358
MenuClickShowRoad
static CallBackFunction MenuClickShowRoad(int index)
Handle click on the entry in the Road Vehicles menu.
Definition toolbar_gui.cpp:810
GRMN_DELIVERED_CARGO_GRAPH
static const int GRMN_DELIVERED_CARGO_GRAPH
Show delivered cargo graph.
Definition toolbar_gui.cpp:656
MenuClickGraphsOrLeague
static CallBackFunction MenuClickGraphsOrLeague(int index)
Handle click on the entry in the Graphs or CompanyLeague.
Definition toolbar_gui.cpp:713
MenuClickHelp
static CallBackFunction MenuClickHelp(int index)
Choose the proper callback function for the main toolbar's help menu.
Definition toolbar_gui.cpp:1155
_toolbar_width
uint _toolbar_width
Width of the toolbar, shared by statusbar.
Definition toolbar_gui.cpp:80
GRMN_PERFORMANCE_HISTORY_GRAPH
static const int GRMN_PERFORMANCE_HISTORY_GRAPH
Show performance history graph.
Definition toolbar_gui.cpp:657
ToolbarOptionsClick
static CallBackFunction ToolbarOptionsClick(Window *w)
Handle click on Options button in toolbar.
Definition toolbar_gui.cpp:267
MenuClickShowShips
static CallBackFunction MenuClickShowShips(int index)
Handle click on the entry in the Ships menu.
Definition toolbar_gui.cpp:830
MakeMainToolbar
static std::unique_ptr< NWidgetBase > MakeMainToolbar()
Make widgets for the main toolbar.
Definition toolbar_gui.cpp:2214
MenuClickSaveLoad
static CallBackFunction MenuClickSaveLoad(int index=0)
Handle click on one of the entries in the SaveLoad menu.
Definition toolbar_gui.cpp:398
CTMN_CLIENT_LIST
static const int CTMN_CLIENT_LIST
Enum for the Company Toolbar's network related buttons.
Definition toolbar_gui.cpp:152
GRMN_INCOME_GRAPH
static const int GRMN_INCOME_GRAPH
Show income graph.
Definition toolbar_gui.cpp:655
MenuClickMusicWindow
static CallBackFunction MenuClickMusicWindow(int)
Handle click on the entry in the Music menu.
Definition toolbar_gui.cpp:1022
ToolbarScenBuildTram
static CallBackFunction ToolbarScenBuildTram(int index)
Handle click on the entry in the Build Tram menu.
Definition toolbar_gui.cpp:1287
GRMN_COMPANY_VALUE_GRAPH
static const int GRMN_COMPANY_VALUE_GRAPH
Show company value graph.
Definition toolbar_gui.cpp:658
ToggleDirtyBlocks
void ToggleDirtyBlocks()
Toggle drawing of the dirty blocks.
Definition toolbar_gui.cpp:1105
MenuClickGoal
static CallBackFunction MenuClickGoal(int index)
Handle click on the entry in the Goal menu.
Definition toolbar_gui.cpp:642
ToolbarScenBuildRoad
static CallBackFunction ToolbarScenBuildRoad(int index)
Handle click on the entry in the Build Road menu.
Definition toolbar_gui.cpp:1268
MenuClickBuildRoad
static CallBackFunction MenuClickBuildRoad(int index)
Handle click on the entry in the Build Road menu.
Definition toolbar_gui.cpp:911
_last_started_action
static CallBackFunction _last_started_action
Last started user action.
Definition toolbar_gui.cpp:100
GetToolbarMaximalImageSize
Dimension GetToolbarMaximalImageSize()
Get maximal square size of a toolbar image.
Definition toolbar_gui.cpp:2200
MenuClickShowTrains
static CallBackFunction MenuClickShowTrains(int index)
Handle click on the entry in the Train menu.
Definition toolbar_gui.cpp:790
MenuClickMap
static CallBackFunction MenuClickMap(int index)
Handle click on one of the entries in the Map menu.
Definition toolbar_gui.cpp:460
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:654
MenuClickBuildRail
static CallBackFunction MenuClickBuildRail(int index)
Handle click on the entry in the Build Rail menu.
Definition toolbar_gui.cpp:890
MenuClickShowAir
static CallBackFunction MenuClickShowAir(int index)
Handle click on the entry in the Aircraft menu.
Definition toolbar_gui.cpp:850
AllocateToolbar
void AllocateToolbar()
Allocate the toolbar.
Definition toolbar_gui.cpp:2592
GRMN_CARGO_PAYMENT_RATES
static const int GRMN_CARGO_PAYMENT_RATES
Show cargo payment rates graph.
Definition toolbar_gui.cpp:659
ToolbarScenSaveOrLoad
static CallBackFunction ToolbarScenSaveOrLoad(Window *w)
Handle click on SaveLoad button in toolbar in the scenario editor.
Definition toolbar_gui.cpp:384
MenuClickBuildTram
static CallBackFunction MenuClickBuildTram(int index)
Handle click on the entry in the Build Tram menu.
Definition toolbar_gui.cpp:932
ToolbarFastForwardClick
static CallBackFunction ToolbarFastForwardClick(Window *)
Toggle fast forward mode.
Definition toolbar_gui.cpp:224
OptionMenuEntries
OptionMenuEntries
Game Option button menu entries.
Definition toolbar_gui.cpp:237
ToolbarScenDatePanel
static CallBackFunction ToolbarScenDatePanel(Window *w)
Called when clicking at the date panel of the scenario editor toolbar.
Definition toolbar_gui.cpp:1194
PopupMainCompanyToolbMenu
static void PopupMainCompanyToolbMenu(Window *w, WidgetID widget, CompanyMask grey={})
Pop up a generic company list menu.
Definition toolbar_gui.cpp:162
MenuClickBuildWater
static CallBackFunction MenuClickBuildWater(int)
Handle click on the entry in the Build Waterways menu.
Definition toolbar_gui.cpp:954
CTMN_SPECTATE
static const int CTMN_SPECTATE
Become spectator.
Definition toolbar_gui.cpp:153
MenuClickSubsidies
static CallBackFunction MenuClickSubsidies(int)
Handle click on the entry in the Subsidies menu.
Definition toolbar_gui.cpp:526
SetStartingYear
void SetStartingYear(TimerGameCalendar::Year year)
Set the starting year for a scenario.
Definition toolbar_gui.cpp:1133
LTMN_HIGHSCORE
static const int LTMN_HIGHSCORE
Show highscrore table.
Definition toolbar_gui.cpp:662
MenuClickStory
static CallBackFunction MenuClickStory(int index)
Handle click on the entry in the Story menu.
Definition toolbar_gui.cpp:622
ToggleBoundingBoxes
void ToggleBoundingBoxes()
Toggle drawing of sprites' bounding boxes.
Definition toolbar_gui.cpp:1088
MenuClickBuildAir
static CallBackFunction MenuClickBuildAir(int)
Handle click on the entry in the Build Air menu.
Definition toolbar_gui.cpp:975
ToggleWidgetOutlines
void ToggleWidgetOutlines()
Toggle drawing of widget outlines.
Definition toolbar_gui.cpp:1119
MenuClickSettings
static CallBackFunction MenuClickSettings(int index)
Handle click on one of the entries in the Options button menu.
Definition toolbar_gui.cpp:310
MenuClickFinances
static CallBackFunction MenuClickFinances(int index)
Handle click on the entry in the finances overview menu.
Definition toolbar_gui.cpp:566
_toolbar_button_sprites
static constexpr std::tuple< WidgetID, WidgetType, SpriteID > _toolbar_button_sprites[]
Sprites to use for the different toolbar buttons.
Definition toolbar_gui.cpp:2162
MenuClickIndustry
static CallBackFunction MenuClickIndustry(int index)
Handle click on the entry in the Industry menu.
Definition toolbar_gui.cpp:755
CTMN_SPECTATOR
static const int CTMN_SPECTATOR
Show a company window as spectator.
Definition toolbar_gui.cpp:154
toolbar_gui.h
Stuff related to the (main) toolbar.
toolbar_widget.h
Types related to the toolbar widgets.
WID_TE_SMALL_MAP
@ WID_TE_SMALL_MAP
Small map menu.
Definition toolbar_widget.h:61
WID_TE_TREES
@ WID_TE_TREES
Tree building toolbar.
Definition toolbar_widget.h:70
WID_TE_TRAMS
@ WID_TE_TRAMS
Tram building menu.
Definition toolbar_widget.h:68
WID_TE_DATE
@ WID_TE_DATE
The date of the scenario.
Definition toolbar_widget.h:58
WID_TE_ZOOM_IN
@ WID_TE_ZOOM_IN
Zoom in the main viewport.
Definition toolbar_widget.h:62
WID_TE_DATE_PANEL
@ WID_TE_DATE_PANEL
Container for the date widgets.
Definition toolbar_widget.h:72
WID_TE_HELP
@ WID_TE_HELP
Help menu.
Definition toolbar_widget.h:74
WID_TE_ZOOM_OUT
@ WID_TE_ZOOM_OUT
Zoom out the main viewport.
Definition toolbar_widget.h:63
WID_TE_INDUSTRY
@ WID_TE_INDUSTRY
Industry building window.
Definition toolbar_widget.h:66
WID_TE_PAUSE
@ WID_TE_PAUSE
Pause the game.
Definition toolbar_widget.h:53
WID_TE_DATE_FORWARD
@ WID_TE_DATE_FORWARD
Increase the date of the scenario.
Definition toolbar_widget.h:60
WID_TE_SPACER
@ WID_TE_SPACER
Spacer with "scenario editor" text.
Definition toolbar_widget.h:57
WID_TE_WATER
@ WID_TE_WATER
Water building toolbar.
Definition toolbar_widget.h:69
WID_TE_MUSIC_SOUND
@ WID_TE_MUSIC_SOUND
Music/sound configuration menu.
Definition toolbar_widget.h:73
WID_TE_SAVE
@ WID_TE_SAVE
Save menu.
Definition toolbar_widget.h:56
WID_TE_LAND_GENERATE
@ WID_TE_LAND_GENERATE
Land generation.
Definition toolbar_widget.h:64
WID_TE_TOWN_GENERATE
@ WID_TE_TOWN_GENERATE
Town building window.
Definition toolbar_widget.h:65
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_ROADS
@ WID_TE_ROADS
Road building menu.
Definition toolbar_widget.h:67
WID_TE_FAST_FORWARD
@ WID_TE_FAST_FORWARD
Fast forward the game.
Definition toolbar_widget.h:54
WID_TE_SIGNS
@ WID_TE_SIGNS
Sign building.
Definition toolbar_widget.h:71
WID_TE_SETTINGS
@ WID_TE_SETTINGS
Settings menu.
Definition toolbar_widget.h:55
WID_TE_DATE_BACKWARD
@ WID_TE_DATE_BACKWARD
Reduce the date of the scenario.
Definition toolbar_widget.h:59
WID_TN_LANDSCAPE
@ WID_TN_LANDSCAPE
Landscaping toolbar.
Definition toolbar_widget.h:43
WID_TN_AIR
@ WID_TN_AIR
Airport building toolbar.
Definition toolbar_widget.h:42
WID_TN_SHIPS
@ WID_TN_SHIPS
Ship menu.
Definition toolbar_widget.h:33
WID_TN_SETTINGS
@ WID_TN_SETTINGS
Settings menu.
Definition toolbar_widget.h:17
WID_TN_GOAL
@ WID_TN_GOAL
Goal menu.
Definition toolbar_widget.h:26
WID_TN_MUSIC_SOUND
@ WID_TN_MUSIC_SOUND
Music/sound configuration menu.
Definition toolbar_widget.h:44
WID_TN_RAILS
@ WID_TN_RAILS
Rail building menu.
Definition toolbar_widget.h:38
WID_TN_SUBSIDIES
@ WID_TN_SUBSIDIES
Subsidy menu.
Definition toolbar_widget.h:21
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_TRAMS
@ WID_TN_TRAMS
Tram building menu.
Definition toolbar_widget.h:40
WID_TN_HELP
@ WID_TN_HELP
Help menu.
Definition toolbar_widget.h:46
WID_TN_SAVE
@ WID_TN_SAVE
Save menu.
Definition toolbar_widget.h:18
WID_TN_STORY
@ WID_TN_STORY
Story menu.
Definition toolbar_widget.h:25
WID_TN_MESSAGES
@ WID_TN_MESSAGES
Messages menu.
Definition toolbar_widget.h:45
WID_TN_ROADVEHS
@ WID_TN_ROADVEHS
Road vehicle menu.
Definition toolbar_widget.h:32
WID_TN_VEHICLE_START
@ WID_TN_VEHICLE_START
Helper for the offset of the vehicle menus.
Definition toolbar_widget.h:30
WID_TN_FINANCES
@ WID_TN_FINANCES
Finance menu.
Definition toolbar_widget.h:23
WID_TN_GRAPHS
@ WID_TN_GRAPHS
Graph menu.
Definition toolbar_widget.h:27
WID_TN_LEAGUE
@ WID_TN_LEAGUE
Company league menu.
Definition toolbar_widget.h:28
WID_TN_STATIONS
@ WID_TN_STATIONS
Station menu.
Definition toolbar_widget.h:22
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
WID_TN_COMPANIES
@ WID_TN_COMPANIES
Company menu.
Definition toolbar_widget.h:24
WID_TN_INDUSTRIES
@ WID_TN_INDUSTRIES
Industry menu.
Definition toolbar_widget.h:29
WID_TN_AIRCRAFT
@ WID_TN_AIRCRAFT
Aircraft menu.
Definition toolbar_widget.h:34
WID_TN_ZOOM_OUT
@ WID_TN_ZOOM_OUT
Zoom out the main viewport.
Definition toolbar_widget.h:36
WID_TN_FAST_FORWARD
@ WID_TN_FAST_FORWARD
Fast forward the game.
Definition toolbar_widget.h:16
WID_TN_ZOOM_IN
@ WID_TN_ZOOM_IN
Zoom in the main viewport.
Definition toolbar_widget.h:35
WID_TN_PAUSE
@ WID_TN_PAUSE
Pause the game.
Definition toolbar_widget.h:15
WID_TN_WATER
@ WID_TN_WATER
Water building toolbar.
Definition toolbar_widget.h:41
WID_TN_ROADS
@ WID_TN_ROADS
Road building menu.
Definition toolbar_widget.h:39
WID_TN_TRAINS
@ WID_TN_TRAINS
Train menu.
Definition toolbar_widget.h:31
WID_TN_TOWNS
@ WID_TN_TOWNS
Town menu.
Definition toolbar_widget.h:20
WID_TN_SMALL_MAP
@ WID_TN_SMALL_MAP
Small map menu.
Definition toolbar_widget.h:19
TF_FORBIDDEN
@ TF_FORBIDDEN
Forbidden.
Definition town_type.h:105
_facility_display_opt
StationFacilities _facility_display_opt
What station facilities to draw.
Definition transparency_gui.cpp:27
ToggleTransparency
void ToggleTransparency(TransparencyOption to)
Toggle the transparency option bit.
Definition transparency.h:71
IsTransparencySet
bool IsTransparencySet(TransparencyOption to)
Check if the transparency option bit is set and if we aren't in the game menu (there's never transpar...
Definition transparency.h:50
_display_opt
uint8_t _display_opt
What do we want to draw/do?
Definition transparency_gui.cpp:26
TO_HOUSES
@ TO_HOUSES
town buildings
Definition transparency.h:26
TO_SIGNS
@ TO_SIGNS
signs
Definition transparency.h:24
ShowTransparencyToolbar
void ShowTransparencyToolbar()
Show the transparency toolbar.
Definition transparency_gui.cpp:162
transparency_gui.h
GUI functions related to transparency.
vehicle_base.h
Base class for all vehicles.
vehicle_func.h
Functions related to vehicles.
vehicle_gui.h
Functions related to the vehicle's GUIs.
VehicleType
VehicleType
Available vehicle types.
Definition vehicle_type.h:22
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition vehicle_type.h:26
VEH_AIRCRAFT
@ VEH_AIRCRAFT
Aircraft vehicle type.
Definition vehicle_type.h:28
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition vehicle_type.h:27
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition vehicle_type.h:25
HandleZoomMessage
void HandleZoomMessage(Window *w, const Viewport &vp, WidgetID widget_zoom_in, WidgetID widget_zoom_out)
Update the status of the zoom-buttons according to the zoom-level of the viewport.
Definition viewport.cpp:486
viewport_func.h
Functions related to (drawing on) viewports.
ZOOM_IN
@ ZOOM_IN
Zoom in (get more detailed view).
Definition viewport_type.h:81
ZOOM_NONE
@ ZOOM_NONE
Hack, used to update the button status.
Definition viewport_type.h:83
ZOOM_OUT
@ ZOOM_OUT
Zoom out (get helicopter view).
Definition viewport_type.h:82
WidgetType
WidgetType
Window widget types, nested widget types, and nested widget part types.
Definition widget_type.h:35
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition widget_type.h:41
WWT_IMGBTN_2
@ WWT_IMGBTN_2
(Toggle) Button with diff image when clicked
Definition widget_type.h:42
WWT_PUSHIMGBTN
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
Definition widget_type.h:106
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition widget_type.h:70
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:66
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:39
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition widget_type.h:49
SizingType
SizingType
Different forms of sizing nested widgets, using NWidgetBase::AssignSizePosition()
Definition widget_type.h:113
GetMainWindow
Window * GetMainWindow()
Get the main window, i.e.
Definition window.cpp:1182
PositionMainToolbar
int PositionMainToolbar(Window *w)
(Re)position main toolbar window at the screen.
Definition window.cpp:3468
DeleteAllMessages
void DeleteAllMessages()
Delete all messages and close their corresponding window (if any).
Definition window.cpp:3371
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:3314
window_func.h
Window functions not directly related to making/drawing windows.
window_gui.h
Functions, definitions and such used only by the GUI.
WindowDefaultFlag::NoClose
@ NoClose
This window can't be interactively closed.
WindowDefaultFlag::NoFocus
@ NoFocus
This window won't get focus/make any other window lose focus when click.
WindowFlag::WhiteBorder
@ WhiteBorder
Window white border counter bit mask.
WindowFlag::Timeout
@ Timeout
Window timeout counter.
WDP_MANUAL
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
Definition window_gui.h:143
WidgetID
int WidgetID
Widget ID.
Definition window_type.h:20
EventState
EventState
State of handling an event.
Definition window_type.h:780
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition window_type.h:781
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition window_type.h:782
WC_SIGN_LIST
@ WC_SIGN_LIST
Sign list; Window numbers:
Definition window_type.h:283
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition window_type.h:50
WC_MAIN_TOOLBAR
@ WC_MAIN_TOOLBAR
Main toolbar (the long bar at the top); Window numbers:
Definition window_type.h:63