40#include "script/script_gui.h"
103 this->SetString(
GetString(STR_COMPANY_NAME_COMPANY_NUM, company, company));
131 if (
string == STR_NULL) {
132 list.push_back(MakeDropDownListDividerItem());
134 list.push_back(MakeDropDownListStringItem(
string, i));
161 list.push_back(MakeDropDownListStringItem(STR_NETWORK_COMPANY_LIST_CLIENT_LIST,
CTMN_CLIENT_LIST));
164 list.push_back(MakeDropDownListStringItem(STR_NETWORK_COMPANY_LIST_SPECTATE,
CTMN_SPECTATE));
168 list.push_back(MakeDropDownListStringItem(STR_STORY_BOOK_SPECTATOR,
CTMN_SPECTATOR));
172 list.push_back(MakeDropDownListStringItem(STR_GOALS_SPECTATOR,
CTMN_SPECTATOR));
176 for (
CompanyID c = CompanyID::Begin(); c < MAX_COMPANIES; ++c) {
178 list.push_back(std::make_unique<DropDownListCompanyItem>(c, grey.Test(c)));
193 return CBF_PLACE_SIGN;
231 OME_GAMESCRIPT_SETTINGS,
236 OME_SHOW_STATIONNAMES,
237 OME_SHOW_STATIONNAMES_TRAIN,
238 OME_SHOW_STATIONNAMES_LORRY,
239 OME_SHOW_STATIONNAMES_BUS,
240 OME_SHOW_STATIONNAMES_SHIP,
241 OME_SHOW_STATIONNAMES_PLANE,
242 OME_SHOW_STATIONNAMES_GHOST,
243 OME_SHOW_WAYPOINTNAMES,
245 OME_SHOW_COMPETITOR_SIGNS,
248 OME_TRANSPARENTBUILDINGS,
249 OME_SHOW_STATIONSIGNS,
261 list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_GAME_OPTIONS, OME_GAMEOPTIONS));
262 list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE, OME_SETTINGS));
267 list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_AI_SETTINGS, OME_AI_SETTINGS));
268 list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_GAMESCRIPT_SETTINGS, OME_GAMESCRIPT_SETTINGS));
270 list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_NEWGRF_SETTINGS, OME_NEWGRFSETTINGS));
272 list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_SANDBOX_OPTIONS, OME_SANDBOX));
274 list.push_back(MakeDropDownListStringItem(STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS, OME_TRANSPARENCIES));
275 list.push_back(MakeDropDownListDividerItem());
289 list.push_back(MakeDropDownListCheckedItem(
IsTransparencySet(
TO_HOUSES), STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS));
290 list.push_back(MakeDropDownListCheckedItem(
IsTransparencySet(
TO_SIGNS), STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS));
324 case OME_SHOW_COMPETITOR_SIGNS:
341 SLEME_SAVE_SCENARIO = 0,
343 SLEME_SAVE_HEIGHTMAP,
344 SLEME_LOAD_HEIGHTMAP,
368 STR_NULL, STR_FILE_MENU_EXIT});
381 STR_SCENEDIT_FILE_MENU_SAVE_HEIGHTMAP, STR_SCENEDIT_FILE_MENU_LOAD_HEIGHTMAP,
382 STR_SCENEDIT_FILE_MENU_QUIT_EDITOR, STR_NULL, STR_SCENEDIT_FILE_MENU_QUIT});
394 if (_game_mode == GM_EDITOR) {
400 case SLEME_EXIT_TOINTRO: AskExitToGameMenu();
break;
401 case SLEME_EXIT_GAME: HandleExitGameRequest();
break;
407 case SLNME_EXIT_TOINTRO: AskExitToGameMenu();
break;
408 case SLNME_EXIT_GAME: HandleExitGameRequest();
break;
416enum MapMenuEntries : uint8_t {
417 MME_SHOW_SMALLMAP = 0,
418 MME_SHOW_EXTRAVIEWPORTS,
421 MME_SHOW_TOWNDIRECTORY,
422 MME_SHOW_INDUSTRYDIRECTORY,
428 list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP));
429 list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_EXTRA_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS));
430 list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_LINGRAPH_LEGEND, MME_SHOW_LINKGRAPH));
431 list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS));
439 list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP));
440 list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_EXTRA_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS));
441 list.push_back(MakeDropDownListStringItem(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS));
442 list.push_back(MakeDropDownListStringItem(STR_TOWN_MENU_TOWN_DIRECTORY, MME_SHOW_TOWNDIRECTORY));
443 list.push_back(MakeDropDownListStringItem(STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, MME_SHOW_INDUSTRYDIRECTORY));
461 case MME_SHOW_TOWNDIRECTORY: ShowTownDirectory();
break;
462 case MME_SHOW_INDUSTRYDIRECTORY: ShowIndustryDirectory();
break;
469enum TownMenuEntries {
470 TME_SHOW_DIRECTORY = 0,
472 TME_SHOW_PLACE_HOUSES,
478 list.push_back(MakeDropDownListStringItem(STR_TOWN_MENU_TOWN_DIRECTORY, TME_SHOW_DIRECTORY));
496 case TME_SHOW_DIRECTORY: ShowTownDirectory();
break;
497 case TME_SHOW_FOUND_TOWN:
500 case TME_SHOW_PLACE_HOUSES:
658static void AddDropDownLeagueTableOptions(
DropDownList &list)
662 list.push_back(MakeDropDownListStringItem(lt->title, lt->index.base()));
666 list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_DETAILED_PERFORMANCE_RATING,
LTMN_PERFORMANCE_RATING));
668 list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_HIGHSCORE,
LTMN_HIGHSCORE));
678 list.push_back(MakeDropDownListStringItem(STR_GRAPH_MENU_INCOME_GRAPH,
GRMN_INCOME_GRAPH));
684 if (_toolbar_mode != TB_NORMAL) AddDropDownLeagueTableOptions(list);
696 AddDropDownLeagueTableOptions(list);
698 int selected = list[0]->result;
756 case 0: ShowIndustryDirectory();
break;
758 case 2: ShowBuildIndustryWindow();
break;
770 if (c->group_all[veh].num_vehicle == 0) dis.
Set(c->index);
893 _last_built_railtype = (
RailType)index;
915 _last_built_roadtype = (
RoadType)index;
937 _last_built_tramtype = (
RoadType)index;
947 list.push_back(MakeDropDownListIconItem(SPR_IMG_BUILD_CANAL, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 0));
969 list.push_back(MakeDropDownListIconItem(SPR_IMG_AIRPORT, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 0));
991 list.push_back(MakeDropDownListIconItem(SPR_IMG_LANDSCAPING, PAL_NONE, STR_LANDSCAPING_MENU_LANDSCAPING, 0));
992 list.push_back(MakeDropDownListIconItem(SPR_IMG_PLANTTREES, PAL_NONE, STR_LANDSCAPING_MENU_PLANT_TREES, 1));
993 list.push_back(MakeDropDownListIconItem(SPR_IMG_SIGN, PAL_NONE, STR_LANDSCAPING_MENU_PLACE_SIGN, 2));
1009 case 1: ShowBuildTreesToolbar();
break;
1010 case 2:
return SelectSignTool();
1067 return CBF_PLACE_LANDINFO;
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 STR_ABOUT_MENU_SPRITE_ALIGNER, STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES, STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS,
1078 STR_ABOUT_MENU_TOGGLE_WIDGET_OUTLINES});
1081 STR_ABOUT_MENU_HELP, STR_NULL, STR_ABOUT_MENU_TOGGLE_CONSOLE, STR_ABOUT_MENU_AI_DEBUG,
1082 STR_ABOUT_MENU_SCREENSHOT, STR_ABOUT_MENU_SHOW_FRAMERATE, STR_ABOUT_MENU_ABOUT_OPENTTD});
1096 extern bool _draw_bounding_boxes;
1099 _draw_bounding_boxes = !_draw_bounding_boxes;
1113 extern bool _draw_dirty_blocks;
1116 _draw_dirty_blocks = !_draw_dirty_blocks;
1127 extern bool _draw_widget_outlines;
1130 _draw_widget_outlines = !_draw_widget_outlines;
1143 TimerGameEconomy::Date new_economy_date{new_calendar_date.base()};
1164 case 0:
return PlaceLandBlockInfo();
1165 case 1: ShowHelpWindow();
break;
1168 case 4: ShowScreenshotWindow();
break;
1170 case 6: ShowAboutWindow();
break;
1183 if (_toolbar_mode != TB_LOWER) {
1184 _toolbar_mode = TB_LOWER;
1186 _toolbar_mode = TB_UPPER;
1250 case 0: ShowFoundTownWindow();
break;
1251 case 1: ShowBuildHousePicker(
nullptr);
break;
1260 ShowBuildIndustryWindow();
1279 _last_built_roadtype = (
RoadType)index;
1299 _last_built_tramtype = (
RoadType)index;
1316 ShowBuildTreesToolbar();
1324 return SelectSignTool();
1334static MenuClickedProc *
const _menu_clicked_procs[] = {
1399 for (
const auto &child_wid : this->
children) {
1400 child_wid->SetupSmallestSize(w);
1401 this->
smallest_y = std::max(this->
smallest_y, child_wid->smallest_y + child_wid->padding.Vertical());
1402 if (this->
IsButton(child_wid->type)) {
1404 this->
smallest_x = std::max(this->
smallest_x, child_wid->smallest_x + child_wid->padding.Horizontal());
1411 for (
const auto &child_wid : this->
children) {
1413 if (!this->
IsButton(child_wid->type)) {
1414 child_wid->current_x = child_wid->smallest_x;
1436 uint arrangable_count, button_count, spacer_count;
1440 std::map<WidgetID, uint> lookup;
1441 for (
auto it = std::begin(this->
children); it != std::end(this->
children); ++it) {
1445 lookup[
dynamic_cast<NWidgetCore *
>(nwid)->GetIndex()] = std::distance(this->
children.begin(), it);
1450 uint spacer_space = std::max(0, (
int)given_width - (
int)(button_count * this->
smallest_x));
1451 uint button_space = given_width - spacer_space;
1456 const WidgetID *slotp = rtl ? &arrangement[arrangable_count - 1] : arrangement;
1457 for (uint i = 0; i < arrangable_count; i++) {
1458 uint slot = lookup[*slotp];
1459 auto &child_wid = this->
children[slot];
1461 if (spacer_space > 0 && slot > 0 && slot < this->
children.size() - 1) {
1462 const auto &possible_spacer = this->
children[slot + (rtl ? 1 : -1)];
1463 if (possible_spacer !=
nullptr && possible_spacer->type ==
NWID_SPACER) {
1464 uint add = spacer_space / (spacer_count - spacer_i);
1466 spacer_space -= add;
1472 if (this->
IsButton(child_wid->type)) {
1473 child_wid->current_x = button_space / (button_count - button_i);
1474 button_space -= child_wid->current_x;
1477 child_wid->current_x = child_wid->smallest_x;
1479 child_wid->AssignSizePosition(sizing, x + position, y, child_wid->current_x, this->current_y, rtl);
1480 position += child_wid->current_x;
1493 const Rect r = this->GetCurrentRect();
1515 static const uint SMALLEST_ARRANGEMENT = 14;
1516 static const uint BIGGEST_ARRANGEMENT = 20;
1524 static const WidgetID arrange14[] = {
1555 static const WidgetID arrange15[] = {
1588 static const WidgetID arrange16[] = {
1623 static const WidgetID arrange17[] = {
1660 static const WidgetID arrange18[] = {
1699 static const WidgetID arrange19[] = {
1740 static const WidgetID arrange20[] = {
1783 static const WidgetID arrange_all[] = {
1817 uint full_buttons = std::max(
CeilDiv(width, this->
smallest_x), SMALLEST_ARRANGEMENT);
1818 if (full_buttons > BIGGEST_ARRANGEMENT) {
1819 button_count = arrangable_count =
lengthof(arrange_all);
1825 static const WidgetID *
const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20 };
1827 button_count = arrangable_count = full_buttons;
1829 return arrangements[full_buttons - SMALLEST_ARRANGEMENT] + ((_toolbar_mode == TB_LOWER) ? full_buttons : 0);
1843 for (
const auto &child_wid : this->
children) {
1844 if (child_wid->type ==
NWID_SPACER || this->IsButton(child_wid->type))
continue;
1846 assert(i <
lengthof(this->panel_widths));
1847 this->panel_widths[i++] = child_wid->current_x;
1854 static const WidgetID arrange_all[] = {
1875 static const WidgetID arrange_nopanel[] = {
1895 static const WidgetID arrange_switch[] = {
1922 uint min_full_width = (
lengthof(arrange_all) -
lengthof(this->panel_widths)) * this->
smallest_x + this->panel_widths[0] + this->panel_widths[1];
1923 if (width >= min_full_width) {
1924 width -= this->panel_widths[0] + this->panel_widths[1];
1925 arrangable_count =
lengthof(arrange_all);
1926 button_count = arrangable_count - 2;
1932 uint min_small_width = (
lengthof(arrange_switch) -
lengthof(this->panel_widths)) * this->
smallest_x / 2 + this->panel_widths[1];
1933 if (width > min_small_width) {
1934 width -= this->panel_widths[1];
1935 arrangable_count =
lengthof(arrange_nopanel);
1936 button_count = arrangable_count - 1;
1937 spacer_count = this->
spacers - 1;
1938 return arrange_nopanel;
1942 width -= this->panel_widths[1];
1943 arrangable_count =
lengthof(arrange_switch) / 2;
1944 button_count = arrangable_count - 1;
1946 return arrange_switch + ((_toolbar_mode == TB_LOWER) ? arrangable_count : 0);
1954static ToolbarButtonProc *
const _toolbar_button_procs[] = {
1961 ToolbarSubsidiesClick,
1962 ToolbarStationsClick,
1963 ToolbarFinancesClick,
1964 ToolbarCompaniesClick,
1969 ToolbarIndustryClick,
1975 ToolbarZoomOutClick,
1976 ToolbarBuildRailClick,
1977 ToolbarBuildRoadClick,
1978 ToolbarBuildTramClick,
1979 ToolbarBuildWaterClick,
1980 ToolbarBuildAirClick,
1983 ToolbarNewspaperClick,
2024 if (_game_mode != GM_MENU && !this->
IsWidgetDisabled(widget)) _toolbar_button_procs[widget](
this);
2037 case MTHK_PAUSE: ToolbarPauseClick(
this);
break;
2043 case MTHK_TOWNDIRECTORY: ShowTownDirectory();
break;
2044 case MTHK_SUBSIDIES: ShowSubsidiesList();
break;
2050 case MTHK_GRAPHS: ShowOperatingProfitGraph();
break;
2051 case MTHK_LEAGUE: ShowFirstLeagueTable();
break;
2052 case MTHK_INDUSTRIES: ShowBuildIndustryWindow();
break;
2057 case MTHK_ZOOM_IN: ToolbarZoomInClick(
this);
break;
2058 case MTHK_ZOOM_OUT: ToolbarZoomOutClick(
this);
break;
2064 case MTHK_BUILD_TREES: ShowBuildTreesToolbar();
break;
2065 case MTHK_MUSIC: ShowMusicWindow();
break;
2074 case MTHK_CLIENT_LIST:
if (
_networking) ShowClientList();
break;
2076 case MTHK_LANDINFO:
cbf = PlaceLandBlockInfo();
break;
2086 case CBF_PLACE_SIGN:
2090 case CBF_PLACE_LANDINFO:
2094 default: NOT_REACHED();
2136 static inline HotkeyList hotkeys{
"maintoolbar", {
2137 Hotkey({WKC_F1, WKC_PAUSE},
"pause", MTHK_PAUSE),
2138 Hotkey(0,
"fastforward", MTHK_FASTFORWARD),
2139 Hotkey(WKC_F2,
"settings", MTHK_SETTINGS),
2140 Hotkey(WKC_F3,
"saveload", MTHK_SAVEGAME),
2141 Hotkey(0,
"load_game", MTHK_LOADGAME),
2142 Hotkey({WKC_F4,
'M'},
"smallmap", MTHK_SMALLMAP),
2143 Hotkey(WKC_F5,
"town_list", MTHK_TOWNDIRECTORY),
2144 Hotkey(WKC_F6,
"subsidies", MTHK_SUBSIDIES),
2145 Hotkey(WKC_F7,
"station_list", MTHK_STATIONS),
2146 Hotkey(WKC_F8,
"finances", MTHK_FINANCES),
2147 Hotkey(WKC_F9,
"companies", MTHK_COMPANIES),
2148 Hotkey(0,
"story_book", MTHK_STORY),
2149 Hotkey(0,
"goal_list", MTHK_GOAL),
2150 Hotkey(WKC_F10,
"graphs", MTHK_GRAPHS),
2151 Hotkey(WKC_F11,
"league", MTHK_LEAGUE),
2152 Hotkey(WKC_F12,
"industry_list", MTHK_INDUSTRIES),
2153 Hotkey(WKC_SHIFT | WKC_F1,
"train_list", MTHK_TRAIN_LIST),
2154 Hotkey(WKC_SHIFT | WKC_F2,
"roadveh_list", MTHK_ROADVEH_LIST),
2155 Hotkey(WKC_SHIFT | WKC_F3,
"ship_list", MTHK_SHIP_LIST),
2156 Hotkey(WKC_SHIFT | WKC_F4,
"aircraft_list", MTHK_AIRCRAFT_LIST),
2159 Hotkey(WKC_SHIFT | WKC_F7,
"build_rail", MTHK_BUILD_RAIL),
2160 Hotkey(WKC_SHIFT | WKC_F8,
"build_road", MTHK_BUILD_ROAD),
2161 Hotkey(0,
"build_tram", MTHK_BUILD_TRAM),
2162 Hotkey(WKC_SHIFT | WKC_F9,
"build_docks", MTHK_BUILD_DOCKS),
2163 Hotkey(WKC_SHIFT | WKC_F10,
"build_airport", MTHK_BUILD_AIRPORT),
2164 Hotkey(WKC_SHIFT | WKC_F11,
"build_trees", MTHK_BUILD_TREES),
2165 Hotkey(WKC_SHIFT | WKC_F12,
"music", MTHK_MUSIC),
2166 Hotkey(0,
"ai_debug", MTHK_SCRIPT_DEBUG),
2167 Hotkey(WKC_CTRL |
'S',
"small_screenshot", MTHK_SMALL_SCREENSHOT),
2168 Hotkey(WKC_CTRL |
'P',
"zoomedin_screenshot", MTHK_ZOOMEDIN_SCREENSHOT),
2169 Hotkey(WKC_CTRL |
'D',
"defaultzoom_screenshot", MTHK_DEFAULTZOOM_SCREENSHOT),
2170 Hotkey(0,
"giant_screenshot", MTHK_GIANT_SCREENSHOT),
2171 Hotkey(WKC_CTRL | WKC_ALT |
'C',
"cheats", MTHK_CHEATS),
2172 Hotkey(
'L',
"terraform", MTHK_TERRAFORM),
2173 Hotkey(
'V',
"extra_viewport", MTHK_EXTRA_VIEWPORT),
2174 Hotkey(0,
"client_list", MTHK_CLIENT_LIST),
2175 Hotkey(0,
"sign_list", MTHK_SIGN_LIST),
2176 Hotkey(0,
"land_info", MTHK_LANDINFO),
2183 static const SpriteID toolbar_button_sprites[] = {
2185 SPR_IMG_FASTFORWARD,
2191 SPR_IMG_COMPANY_LIST,
2192 SPR_IMG_COMPANY_FINANCE,
2193 SPR_IMG_COMPANY_GENERAL,
2197 SPR_IMG_COMPANY_LEAGUE,
2202 SPR_IMG_AIRPLANESLIST,
2210 SPR_IMG_LANDSCAPING,
2214 SPR_IMG_SWITCH_TOOLBAR,
2217 auto hor = std::make_unique<NWidgetMainToolbarContainer>();
2226 hor->Add(std::make_unique<NWidgetSpacer>(0, 0));
2230 leaf->SetMinimalSize(20, 20);
2231 hor->Add(std::move(leaf));
2237static constexpr NWidgetPart _nested_toolbar_normal_widgets[] = {
2245 _nested_toolbar_normal_widgets,
2246 &MainToolbarWindow::hotkeys
2252static MenuClickedProc *
const _scen_toolbar_dropdown_procs[] = {
2278static ToolbarButtonProc *
const _scen_toolbar_button_procs[] = {
2285 ToolbarScenDateBackward,
2286 ToolbarScenDateForward,
2287 ToolbarScenMapTownDir,
2289 ToolbarZoomOutClick,
2291 ToolbarScenGenTownClick,
2292 ToolbarScenGenIndustry,
2293 ToolbarScenBuildRoadClick,
2294 ToolbarScenBuildTramClick,
2295 ToolbarScenBuildDocks,
2296 ToolbarScenPlantTrees,
2297 ToolbarScenPlaceSign,
2304enum MainToolbarEditorHotkeys : int32_t {
2319 MTEHK_SMALL_SCREENSHOT,
2320 MTEHK_ZOOMEDIN_SCREENSHOT,
2321 MTEHK_DEFAULTZOOM_SCREENSHOT,
2322 MTEHK_GIANT_SCREENSHOT,
2327 MTEHK_EXTRA_VIEWPORT,
2397 if (_game_mode == GM_MENU)
return;
2413 case MTEHK_PAUSE: ToolbarPauseClick(
this);
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;
2431 case MTEHK_ZOOM_IN: ToolbarZoomInClick(
this);
break;
2432 case MTEHK_ZOOM_OUT: ToolbarZoomOutClick(
this);
break;
2445 case CBF_PLACE_SIGN:
2449 case CBF_PLACE_LANDINFO:
2453 default: NOT_REACHED();
2496 if (!str.has_value())
return;
2499 if (!str->empty()) {
2510 static inline HotkeyList hotkeys{
"scenedit_maintoolbar", {
2511 Hotkey({WKC_F1, WKC_PAUSE},
"pause", MTEHK_PAUSE),
2512 Hotkey(0,
"fastforward", MTEHK_FASTFORWARD),
2513 Hotkey(WKC_F2,
"settings", MTEHK_SETTINGS),
2514 Hotkey(WKC_F3,
"saveload", MTEHK_SAVEGAME),
2515 Hotkey(WKC_F4,
"gen_land", MTEHK_GENLAND),
2516 Hotkey(WKC_F5,
"gen_town", MTEHK_GENTOWN),
2517 Hotkey(WKC_F6,
"gen_industry", MTEHK_GENINDUSTRY),
2518 Hotkey(WKC_F7,
"build_road", MTEHK_BUILD_ROAD),
2519 Hotkey(0,
"build_tram", MTEHK_BUILD_TRAM),
2520 Hotkey(WKC_F8,
"build_docks", MTEHK_BUILD_DOCKS),
2521 Hotkey(WKC_F9,
"build_trees", MTEHK_BUILD_TREES),
2522 Hotkey(WKC_F10,
"build_sign", MTEHK_SIGN),
2523 Hotkey(WKC_F11,
"music", MTEHK_MUSIC),
2524 Hotkey(WKC_F12,
"land_info", MTEHK_LANDINFO),
2525 Hotkey(WKC_CTRL |
'S',
"small_screenshot", MTEHK_SMALL_SCREENSHOT),
2526 Hotkey(WKC_CTRL |
'P',
"zoomedin_screenshot", MTEHK_ZOOMEDIN_SCREENSHOT),
2527 Hotkey(WKC_CTRL |
'D',
"defaultzoom_screenshot", MTEHK_DEFAULTZOOM_SCREENSHOT),
2528 Hotkey(0,
"giant_screenshot", MTEHK_GIANT_SCREENSHOT),
2531 Hotkey(
'L',
"terraform", MTEHK_TERRAFORM),
2532 Hotkey(
'M',
"smallmap", MTEHK_SMALLMAP),
2533 Hotkey(
'V',
"extra_viewport", MTEHK_EXTRA_VIEWPORT),
2537static constexpr NWidgetPart _nested_toolb_scen_inner_widgets[] = {
2572static std::unique_ptr<NWidgetBase> MakeScenarioToolbar()
2574 return MakeNWidgets(_nested_toolb_scen_inner_widgets, std::make_unique<NWidgetScenarioToolbarContainer>());
2577static constexpr NWidgetPart _nested_toolb_scen_widgets[] = {
2585 _nested_toolb_scen_widgets,
2586 &ScenarioEditorToolbarWindow::hotkeys
2596 if (_game_mode == GM_EDITOR) {
void ShowAIConfigWindow()
Open the AI config window.
Window for configuring the AIs
Window * ShowBuildAirToolbar()
Open the build airport toolbar window.
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T ToggleBit(T &x, const uint8_t y)
Toggles a bit in a variable.
Functions related to cheating.
void ShowCheatWindow()
Open cheat window.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr bool None() const
Test if none of the values are set.
constexpr Timpl & Flip(Tvalue_type value)
Flip the value-th bit.
constexpr Timpl & Set()
Set all bits.
constexpr bool Any(const Timpl &other) const
Test if any of the given values are set.
constexpr Timpl & Reset(Tvalue_type value)
Reset the value-th bit.
Drop down icon component.
Company name list item, with company-colour icon, name, and lock components.
An interval timer will fire every interval, and will continue to fire until it is deleted.
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
void ShiftDates(TimerGameEconomy::Date interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
Container for the 'normal' main toolbar.
const WidgetID * GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override
Get the arrangement of the buttons for the toolbar.
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
static void SetDate(Date date, DateFract fract)
Set the date.
static constexpr TimerGame< struct Calendar >::Year DEF_START_YEAR
The default starting year.
static constexpr TimerGame< struct Calendar >::Year MIN_YEAR
The absolute minimum year in OTTD.
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,...
static Date date
Current date in days (day counter).
static void SetDate(Date date, DateFract fract)
Set the date.
Functions related to commands.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Functions related to companies.
void ShowCompanyFinances(CompanyID company)
Open the finances window of a company.
void ShowCompany(CompanyID company)
Show the window with the overview of the company.
GUI Functions related to companies.
void ShowCompanyStations(CompanyID company)
Opens window with list of company's stations.
static constexpr CompanyID COMPANY_SPECTATOR
The client is spectating.
void ShowFramerateWindow()
Open the general framerate window.
void IConsoleSwitch()
Toggle in-game console between opened and closed.
GUI related functions in the console.
Window * ShowBuildDocksScenToolbar()
Open the build water toolbar window for the scenario editor.
Window * ShowBuildDocksToolbar()
Open the build water toolbar window.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close, bool persist)
Show a drop down list.
Common drop down list components.
Functions related to the drop down widget.
Types related to the drop down widget.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
@ SLO_SAVE
File is being saved.
@ SLO_LOAD
File is being loaded.
@ FT_SCENARIO
old or new scenario
@ FT_HEIGHTMAP
heightmap file
@ FT_SAVEGAME
old or new savegame
Declarations for savegames operations.
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Types for recording game performance data.
Base functions for all Games.
void ShowGSConfigWindow()
Open the GS config window.
Window for configuring the Games
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
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.
bool _ctrl_pressed
Is Ctrl pressed?
bool _left_button_clicked
Is left mouse button clicked?
uint16_t _game_speed
Current game-speed; 100 is 1x, 0 is infinite.
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
PauseModes _pause_mode
The current pause mode.
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
@ FS_NORMAL
Index of the normal font in the font tables.
@ SA_HOR_CENTER
Horizontally center the text.
@ SA_CENTER
Center both horizontally and vertically.
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
void ShowGoalsList(CompanyID company)
Open a goal list window.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
GUI functions that shouldn't be here.
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.
void ShowIndustryCargoesWindow()
Open the industry and cargoes window with an industry.
void ShowLandInfo(TileIndex tile)
Show land information window.
void ShowExtraViewportWindowForTileUnderCursor()
Show a new Extra Viewport window.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
void ShowGameSettings()
Open advanced settings window.
void ShowGameOptions()
Open the game options window.
GUI to access manuals and related.
Declaration of functions and types defined in highscore.h and highscore_gui.h.
void ShowHighscoreTable(int difficulty=SP_CUSTOM, int8_t rank=-1)
Show the highscore table for a given difficulty.
Hotkey related functions.
definition of HouseSpec and accessors
League table GUI functions.
void ShowLinkGraphLegend()
Open a link graph legend window.
Declaration of linkgraph overlay GUI.
bool DoZoomInOutWindow(ZoomStateChange how, Window *w)
Zooms a viewport in a window in or out.
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Miscellaneous command definitions.
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.
bool _networking
are we in networking mode?
bool _network_server
network-server is active
bool NetworkCanJoinCompany(CompanyID company_id)
Returns whether the given company can be joined by this client.
Basic functions/variables used all over the place.
void NetworkClientRequestMove(CompanyID company_id)
Notify the server of this client wanting to be moved to another company.
Network functions used by other parts of OpenTTD.
void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
Handle the tid-bits of moving a client from one company to another.
GUIs related to networking.
@ CLIENT_ID_SERVER
Servers always have this ID.
GRFConfigList _grfconfig
First item in list of current GRF set up.
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfigList &config)
Setup the NewGRF gui.
Functions/types related to NewGRF debugging.
void ShowSpriteAlignerWindow()
Show the window for aligning sprites.
void ShowLastNewsMessage()
Show previous news item.
void ShowMessageHistory()
Display window with news messages history.
GUI functions related to the news.
@ DO_SHOW_TOWN_NAMES
Display town names.
@ DO_SHOW_COMPETITOR_SIGNS
Display signs, station names and waypoint names of opponent companies. Buoys and oilrig-stations are ...
@ DO_FULL_DETAIL
Also draw details of track and roads.
@ DO_SHOW_SIGNS
Display signs.
@ DO_SHOW_WAYPOINT_NAMES
Display waypoint names.
@ DO_SHOW_STATION_NAMES
Display station names.
@ DO_FULL_ANIMATION
Perform palette animation.
@ Normal
A game normally paused.
static const uint8_t PC_VERY_DARK_RED
Almost-black red palette colour.
static const uint8_t PC_DARK_RED
Dark red palette colour.
Window * ShowBuildRailToolbar(RailType railtype)
Open the build rail toolbar window for a specific rail type.
DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option)
Create a drop down list for all the rail types of the local company.
RailType
Enumeration for all possible railtypes.
RoadTypes GetRoadTypes(bool introduces)
Get list of road types, regardless of company availability.
RoadTypes _roadtypes_type
Bitmap of road/tram types.
Window * ShowBuildRoadScenToolbar(RoadType roadtype)
Show the road building toolbar in the scenario editor.
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
Functions/types related to the road GUIs.
@ ROADTYPES_NONE
No roadtypes.
RoadType
The different roadtypes we support.
@ ROADTYPE_ROAD
Basic road type.
A number of safeguards to prevent using unsafe methods.
void MakeScreenshotWithConfirm(ScreenshotType t)
Make a screenshot.
Functions to make screenshots.
@ SC_VIEWPORT
Screenshot of viewport.
@ SC_ZOOMEDIN
Fully zoomed in screenshot of the visible area.
@ SC_WORLD
World screenshot.
@ SC_DEFAULTZOOM
Zoomed to default zoom level screenshot of the visible area.
GUI functions related to screenshots.
Window * ShowScriptDebugWindow(CompanyID show_company, bool new_window)
Open the Script debug window and select the given company.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
ClientSettings _settings_client
The current settings for this game.
void PlaceProc_Sign(TileIndex tile)
PlaceProc function, called when someone pressed the button if the sign-tool is selected.
Functions related to signs.
Window * ShowSignList()
Open the sign list window.
void ShowSmallMap()
Show the smallmap window.
Functions related to sound.
@ SND_15_BEEP
19 == 0x13 GUI button click
static constexpr StationFacility STATION_FACILITY_GHOST
Fake 'facility' to allow toggling display of recently-removed station signs.
@ Dock
Station with a dock.
@ TruckStop
Station with truck stops.
@ Train
Station with train station.
@ Airport
Station with an airport.
@ BusStop
Station with bus stops.
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
@ CS_NUMERAL
Only numeric ones.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
Functions related to OTTD's strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
SoundSettings sound
sound effect settings
GUISettings gui
settings related to the GUI
Dimensions (a width and height) of a rectangle in 2D.
TownFounding found_town
town founding.
PlaceHouses place_houses
players are allowed to place town houses.
bool UserIsAllowedToChangeNewGRFs() const
Returns true when the user has sufficient privileges to edit newgrfs on a running game.
bool newgrf_developer_tools
activate NewGRF developer tools and allow modifying NewGRFs in an existing game
TimerGameCalendar::Year starting_year
starting date
EconomySettings economy
settings to change the economy
GameCreationSettings game_creation
settings used during the creation of a game (map)
List of hotkeys for a window.
All data for a single hotkey.
Struct about custom league tables.
void OnTimeout() override
Called when this window's timeout has been reached.
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
void OnDropdownSelect(WidgetID widget, int index) override
A dropdown option associated to this window has been selected.
void OnPaint() override
The window must be repainted.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void FindWindowPlacementAndResize(int def_width, int def_height) override
Resize window towards the default size.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
IntervalTimer< TimerWindow > refresh_interval
Refresh the state of pause / game-speed on a regular interval.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
Coordinates of a point in 2D.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static size_t GetNumItems()
Returns number of valid items in the pool.
static bool IsValidID(auto index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Specification of a rectangle with absolute coordinates of all edges.
int Height() const
Get height of Rect.
bool click_beep
Beep on a random selection of buttons.
bool confirm
Play sound effect on successful constructions or other actions.
Templated helper to make a type-safe 'typedef' representing a single POD value.
High level window description.
Data structure for an opened window.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
void DrawWidgets() const
Paint all widgets of a window.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
uint8_t timeout_timer
Timer value of the WindowFlag::Timeout for flags.
void RaiseWidgetWhenLowered(WidgetID widget_index)
Marks a widget as raised and dirty (redraw), when it is marked as lowered.
ResizeInfo resize
Resize information.
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
ViewportData * viewport
Pointer to viewport data, if present.
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
void SetWidgetsLoweredState(bool lowered_stat, Args... widgets)
Sets the lowered/raised status of a list of widgets.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
WindowFlags flags
Window flags.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
int height
Height of the window (number of pixels down in y direction)
int width
width of the window (number of pixels to the right in x direction)
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
Resize window towards the default size.
Stuff related to the text buffer GUI.
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
Functions related to tile highlights.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
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...
@ HT_RECT
rectangle (stations, depots, ...)
Definition of Interval and OneShot timers.
Definition of the game-calendar-timer.
Definition of the Window system.
StationFacilities _facility_display_opt
What station facilities to draw.
void ToggleTransparency(TransparencyOption to)
Toggle the transparency option bit.
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...
uint8_t _display_opt
What do we want to draw/do?
@ TO_HOUSES
town buildings
void ShowTransparencyToolbar()
Show the transparency toolbar.
GUI functions related to transparency.
Base class for all vehicles.
Functions related to vehicles.
Functions related to the vehicle's GUIs.
VehicleType
Available vehicle types.
@ VEH_ROAD
Road vehicle type.
@ VEH_AIRCRAFT
Aircraft vehicle type.
@ VEH_SHIP
Ship vehicle type.
@ VEH_TRAIN
Train vehicle type.
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.
Functions related to (drawing on) viewports.
@ ZOOM_IN
Zoom in (get more detailed view).
@ ZOOM_NONE
Hack, used to update the button status.
@ ZOOM_OUT
Zoom out (get helicopter view).
Window * GetMainWindow()
Get the main window, i.e.
int PositionMainToolbar(Window *w)
(Re)position main toolbar window at the screen.
void DeleteAllMessages()
Delete all messages and close their corresponding window (if any).
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...
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
@ NoClose
This window can't be interactively closed.
@ NoFocus
This window won't get focus/make any other window lose focus when click.
@ WhiteBorder
Window white border counter bit mask.
@ Timeout
Window timeout counter.
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
EventState
State of handling an event.
@ ES_HANDLED
The passed event is handled.
@ ES_NOT_HANDLED
The passed event is not handled.
@ WC_SIGN_LIST
Sign list; Window numbers:
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ WC_MAIN_TOOLBAR
Main toolbar (the long bar at the top); Window numbers: