102 return DropDownListStringItem::Width() + this->checkmark_width;
105 void Draw(
int left,
int right,
int top,
int bottom,
bool sel, Colours bg_colour)
const 130 bool Selectable()
const override 135 uint Width()
const override 140 return GetStringBoundingBox(STR_COMPANY_NAME_COMPANY_NUM).width + this->icon_size.width + this->lock_size.width + 6;
143 uint Height(uint width)
const override 148 void Draw(
int left,
int right,
int top,
int bottom,
bool sel, Colours bg_colour)
const override 156 int icon_offset = (bottom - top - icon_size.height) / 2;
158 int lock_offset = (bottom - top - lock_size.height) / 2;
171 col = sel ? TC_WHITE : TC_BLACK;
173 DrawString(left +
WD_FRAMERECT_LEFT + (rtl ? 3 + this->lock_size.width : 3 + this->icon_size.width), right -
WD_FRAMERECT_RIGHT - (rtl ? 3 + this->icon_size.width : 3 + this->lock_size.width), top + text_offset, STR_COMPANY_NAME_COMPANY_NUM, col);
200 for (
int i = 0; i < count; i++) {
263 return CBF_PLACE_SIGN;
287 _fast_forward ^=
true;
302 OME_SHOW_STATIONNAMES,
303 OME_SHOW_WAYPOINTNAMES,
305 OME_SHOW_COMPETITOR_SIGNS,
308 OME_TRANSPARENTBUILDINGS,
309 OME_SHOW_STATIONSIGNS,
322 list.emplace_back(
new DropDownListStringItem(STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE, OME_SETTINGS,
false));
327 list.emplace_back(
new DropDownListStringItem(STR_SETTINGS_MENU_NEWGRF_SETTINGS, OME_NEWGRFSETTINGS,
false));
328 list.emplace_back(
new DropDownListStringItem(STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS, OME_TRANSPARENCIES,
false));
364 case OME_SHOW_COMPETITOR_SIGNS:
381 SLEME_SAVE_SCENARIO = 0,
383 SLEME_SAVE_HEIGHTMAP,
384 SLEME_LOAD_HEIGHTMAP,
433 if (_game_mode == GM_EDITOR) {
439 case SLEME_EXIT_TOINTRO: AskExitToGameMenu();
break;
440 case SLEME_EXIT_GAME: HandleExitGameRequest();
break;
446 case SLNME_EXIT_TOINTRO: AskExitToGameMenu();
break;
447 case SLNME_EXIT_GAME: HandleExitGameRequest();
break;
455 enum MapMenuEntries {
456 MME_SHOW_SMALLMAP = 0,
457 MME_SHOW_EXTRAVIEWPORTS,
460 MME_SHOW_TOWNDIRECTORY,
461 MME_SHOW_INDUSTRYDIRECTORY,
468 list.emplace_back(
new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEW_PORT, MME_SHOW_EXTRAVIEWPORTS,
false));
479 list.emplace_back(
new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEW_PORT, MME_SHOW_EXTRAVIEWPORTS,
false));
481 list.emplace_back(
new DropDownListStringItem(STR_TOWN_MENU_TOWN_DIRECTORY, MME_SHOW_TOWNDIRECTORY,
false));
482 list.emplace_back(
new DropDownListStringItem(STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, MME_SHOW_INDUSTRYDIRECTORY,
false));
500 case MME_SHOW_TOWNDIRECTORY: ShowTownDirectory();
break;
501 case MME_SHOW_INDUSTRYDIRECTORY: ShowIndustryDirectory();
break;
523 case 0: ShowTownDirectory();
break;
548 case 0: ShowSubsidiesList();
break;
694 case 0: ShowOperatingProfitGraph();
break;
695 case 1: ShowIncomeGraph();
break;
696 case 2: ShowDeliveredCargoGraph();
break;
697 case 3: ShowPerformanceHistoryGraph();
break;
698 case 4: ShowCompanyValueGraph();
break;
699 case 5: ShowCargoPaymentRates();
break;
701 case 6: ShowCompanyLeagueTable();
break;
702 case 7: ShowPerformanceRatingDetail();
break;
724 case 0: ShowCompanyLeagueTable();
break;
725 case 1: ShowPerformanceRatingDetail();
break;
749 case 0: ShowIndustryDirectory();
break;
751 case 2: ShowBuildIndustryWindow();
break;
763 if (v->type == veh && v->IsPrimaryVehicle())
ClrBit(dis, v->owner);
886 _last_built_railtype = (
RailType)index;
908 _last_built_roadtype = (
RoadType)index;
930 _last_built_tramtype = (
RoadType)index;
940 list.emplace_back(
new DropDownListIconItem(SPR_IMG_BUILD_CANAL, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 0,
false));
962 list.emplace_back(
new DropDownListIconItem(SPR_IMG_AIRPORT, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 0,
false));
984 list.emplace_back(
new DropDownListIconItem(SPR_IMG_LANDSCAPING, PAL_NONE, STR_LANDSCAPING_MENU_LANDSCAPING, 0,
false));
985 list.emplace_back(
new DropDownListIconItem(SPR_IMG_PLANTTREES, PAL_NONE, STR_LANDSCAPING_MENU_PLANT_TREES, 1,
false));
986 list.emplace_back(
new DropDownListIconItem(SPR_IMG_SIGN, PAL_NONE, STR_LANDSCAPING_MENU_PLACE_SIGN, 2,
false));
1001 case 1: ShowBuildTreesToolbar();
break;
1002 case 2:
return SelectSignTool();
1060 return CBF_PLACE_LANDINFO;
1070 static void MenuClickSmallScreenshot()
1094 if ((uint64)vp.
width * (uint64)vp.
height > 8192 * 8192) {
1115 extern bool _draw_bounding_boxes;
1118 _draw_bounding_boxes = !_draw_bounding_boxes;
1132 extern bool _draw_dirty_blocks;
1135 _draw_dirty_blocks = !_draw_dirty_blocks;
1161 case 0:
return PlaceLandBlockInfo();
1164 case 4: MenuClickSmallScreenshot();
break;
1169 case 9: ShowAboutWindow();
break;
1181 if (_toolbar_mode != TB_LOWER) {
1182 _toolbar_mode = TB_LOWER;
1184 _toolbar_mode = TB_UPPER;
1246 ShowFoundTownWindow();
1254 ShowBuildIndustryWindow();
1273 _last_built_roadtype = (
RoadType)index;
1293 _last_built_tramtype = (
RoadType)index;
1310 ShowBuildTreesToolbar();
1318 return SelectSignTool();
1328 static MenuClickedProc *
const _menu_clicked_procs[] = {
1384 this->smallest_x = 0;
1385 this->smallest_y = 0;
1394 for (
NWidgetBase *child_wid = this->head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1395 child_wid->SetupSmallestSize(w, init_array);
1396 this->smallest_y =
max(this->smallest_y, child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom);
1397 if (this->IsButton(child_wid->type)) {
1399 this->smallest_x =
max(this->smallest_x, child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right);
1406 for (
NWidgetBase *child_wid = this->head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1407 child_wid->current_y = this->smallest_y;
1408 if (!this->IsButton(child_wid->type)) {
1409 child_wid->current_x = child_wid->smallest_x;
1417 assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
1421 this->current_x = given_width;
1422 this->current_y = given_height;
1425 memset(this->visible, 0,
sizeof(this->visible));
1426 uint arrangable_count, button_count, spacer_count;
1427 const byte *arrangement = GetButtonArrangement(given_width, arrangable_count, button_count, spacer_count);
1428 for (uint i = 0; i < arrangable_count; i++) {
1429 this->visible[arrangement[i]] =
true;
1434 for (
NWidgetBase *child_wid = this->head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1436 widgets[((
NWidgetCore*)child_wid)->index] = child_wid;
1441 uint spacer_space =
max(0, (
int)given_width - (
int)(button_count * this->smallest_x));
1442 uint button_space = given_width - spacer_space;
1447 const byte *cur_wid = rtl ? &arrangement[arrangable_count - 1] : arrangement;
1448 for (uint i = 0; i < arrangable_count; i++) {
1451 if (spacer_space != 0) {
1453 if (possible_spacer !=
nullptr && possible_spacer->
type ==
NWID_SPACER) {
1454 uint add = spacer_space / (spacer_count - spacer_i);
1456 spacer_space -= add;
1462 if (this->IsButton(child_wid->
type)) {
1463 child_wid->
current_x = button_space / (button_count - button_i);
1485 for (
NWidgetBase *child_wid = rtl ? this->tail : this->head; child_wid !=
nullptr; child_wid = rtl ? child_wid->
prev : child_wid->
next) {
1487 if (!this->visible[((
NWidgetCore*)child_wid)->index])
continue;
1495 if (!
IsInsideBS(x, this->pos_x, this->current_x) || !
IsInsideBS(y, this->pos_y, this->current_y))
return nullptr;
1497 for (
NWidgetBase *child_wid = this->head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1499 if (!this->visible[((
NWidgetCore*)child_wid)->index])
continue;
1502 if (nwid !=
nullptr)
return nwid;
1515 virtual const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count)
const = 0;
1520 const byte *
GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count)
const override 1522 static const uint SMALLEST_ARRANGEMENT = 14;
1523 static const uint BIGGEST_ARRANGEMENT = 20;
1531 static const byte arrange14[] = {
1562 static const byte arrange15[] = {
1595 static const byte arrange16[] = {
1630 static const byte arrange17[] = {
1667 static const byte arrange18[] = {
1706 static const byte arrange19[] = {
1747 static const byte arrange20[] = {
1790 static const byte arrange_all[] = {
1824 uint full_buttons =
max(
CeilDiv(width, this->smallest_x), SMALLEST_ARRANGEMENT);
1825 if (full_buttons > BIGGEST_ARRANGEMENT) {
1826 button_count = arrangable_count =
lengthof(arrange_all);
1827 spacer_count = this->spacers;
1832 static const byte *
const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20 };
1834 button_count = arrangable_count = full_buttons;
1835 spacer_count = this->spacers;
1836 return arrangements[full_buttons - SMALLEST_ARRANGEMENT] + ((_toolbar_mode == TB_LOWER) ? full_buttons : 0);
1842 uint panel_widths[2];
1850 for (
NWidgetBase *child_wid = this->head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1851 if (child_wid->type ==
NWID_SPACER || this->IsButton(child_wid->type))
continue;
1853 assert(i <
lengthof(this->panel_widths));
1854 this->panel_widths[i++] = child_wid->current_x;
1859 const byte *
GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count)
const override 1861 static const byte arrange_all[] = {
1882 static const byte arrange_nopanel[] = {
1902 static const byte arrange_switch[] = {
1929 uint min_full_width = (
lengthof(arrange_all) -
lengthof(this->panel_widths)) * this->smallest_x + this->panel_widths[0] + this->panel_widths[1];
1930 if (width >= min_full_width) {
1931 width -= this->panel_widths[0] + this->panel_widths[1];
1932 arrangable_count =
lengthof(arrange_all);
1933 button_count = arrangable_count - 2;
1934 spacer_count = this->spacers;
1939 uint min_small_width = (
lengthof(arrange_switch) -
lengthof(this->panel_widths)) * this->smallest_x / 2 + this->panel_widths[1];
1940 if (width > min_small_width) {
1941 width -= this->panel_widths[1];
1942 arrangable_count =
lengthof(arrange_nopanel);
1943 button_count = arrangable_count - 1;
1944 spacer_count = this->spacers - 1;
1945 return arrange_nopanel;
1949 width -= this->panel_widths[1];
1950 arrangable_count =
lengthof(arrange_switch) / 2;
1951 button_count = arrangable_count - 1;
1953 return arrange_switch + ((_toolbar_mode == TB_LOWER) ? arrangable_count : 0);
1961 static ToolbarButtonProc *
const _toolbar_button_procs[] = {
1968 ToolbarSubsidiesClick,
1969 ToolbarStationsClick,
1970 ToolbarFinancesClick,
1971 ToolbarCompaniesClick,
1976 ToolbarIndustryClick,
1982 ToolbarZoomOutClick,
1983 ToolbarBuildRailClick,
1984 ToolbarBuildRoadClick,
1985 ToolbarBuildTramClick,
1986 ToolbarBuildWaterClick,
1987 ToolbarBuildAirClick,
1990 ToolbarNewspaperClick,
1995 enum MainToolbarHotkeys {
2026 MTHK_SMALL_SCREENSHOT,
2027 MTHK_ZOOMEDIN_SCREENSHOT,
2028 MTHK_DEFAULTZOOM_SCREENSHOT,
2029 MTHK_GIANT_SCREENSHOT,
2032 MTHK_EXTRA_VIEWPORT,
2043 this->InitNested(0);
2077 this->DrawWidgets();
2082 if (_game_mode != GM_MENU && !this->IsWidgetDisabled(widget)) _toolbar_button_procs[widget](
this);
2094 case MTHK_PAUSE: ToolbarPauseClick(
this);
break;
2100 case MTHK_TOWNDIRECTORY: ShowTownDirectory();
break;
2101 case MTHK_SUBSIDIES: ShowSubsidiesList();
break;
2107 case MTHK_GRAPHS: ShowOperatingProfitGraph();
break;
2108 case MTHK_LEAGUE: ShowCompanyLeagueTable();
break;
2109 case MTHK_INDUSTRIES: ShowBuildIndustryWindow();
break;
2114 case MTHK_ZOOM_IN: ToolbarZoomInClick(
this);
break;
2115 case MTHK_ZOOM_OUT: ToolbarZoomOutClick(
this);
break;
2121 case MTHK_BUILD_TREES: ShowBuildTreesToolbar();
break;
2122 case MTHK_MUSIC: ShowMusicWindow();
break;
2124 case MTHK_SMALL_SCREENSHOT: MenuClickSmallScreenshot();
break;
2131 case MTHK_CLIENT_LIST:
if (
_networking) ShowClientList();
break;
2141 case CBF_PLACE_SIGN:
2145 case CBF_PLACE_LANDINFO:
2149 default: NOT_REACHED();
2160 if (!this->timer.
Elapsed(delta_ms))
return;
2179 if (this->IsWidgetLowered(i)) {
2180 this->RaiseWidget(i);
2181 this->SetWidgetDirty(i);
2193 if (!gui_scope)
return;
2200 const uint16 _maintoolbar_pause_keys[] = {WKC_F1, WKC_PAUSE, 0};
2201 const uint16 _maintoolbar_zoomin_keys[] = {WKC_NUM_PLUS,
WKC_EQUALS, WKC_SHIFT |
WKC_EQUALS, WKC_SHIFT | WKC_F5, 0};
2202 const uint16 _maintoolbar_zoomout_keys[] = {WKC_NUM_MINUS,
WKC_MINUS, WKC_SHIFT |
WKC_MINUS, WKC_SHIFT | WKC_F6, 0};
2203 const uint16 _maintoolbar_smallmap_keys[] = {WKC_F4,
'M', 0};
2205 static Hotkey maintoolbar_hotkeys[] = {
2206 Hotkey(_maintoolbar_pause_keys,
"pause", MTHK_PAUSE),
2207 Hotkey((uint16)0,
"fastforward", MTHK_FASTFORWARD),
2208 Hotkey(WKC_F2,
"settings", MTHK_SETTINGS),
2209 Hotkey(WKC_F3,
"saveload", MTHK_SAVEGAME),
2210 Hotkey((uint16)0,
"load_game", MTHK_LOADGAME),
2211 Hotkey(_maintoolbar_smallmap_keys,
"smallmap", MTHK_SMALLMAP),
2212 Hotkey(WKC_F5,
"town_list", MTHK_TOWNDIRECTORY),
2213 Hotkey(WKC_F6,
"subsidies", MTHK_SUBSIDIES),
2214 Hotkey(WKC_F7,
"station_list", MTHK_STATIONS),
2215 Hotkey(WKC_F8,
"finances", MTHK_FINANCES),
2216 Hotkey(WKC_F9,
"companies", MTHK_COMPANIES),
2217 Hotkey((uint16)0,
"story_book", MTHK_STORY),
2218 Hotkey((uint16)0,
"goal_list", MTHK_GOAL),
2219 Hotkey(WKC_F10,
"graphs", MTHK_GRAPHS),
2220 Hotkey(WKC_F11,
"league", MTHK_LEAGUE),
2221 Hotkey(WKC_F12,
"industry_list", MTHK_INDUSTRIES),
2222 Hotkey(WKC_SHIFT | WKC_F1,
"train_list", MTHK_TRAIN_LIST),
2223 Hotkey(WKC_SHIFT | WKC_F2,
"roadveh_list", MTHK_ROADVEH_LIST),
2224 Hotkey(WKC_SHIFT | WKC_F3,
"ship_list", MTHK_SHIP_LIST),
2225 Hotkey(WKC_SHIFT | WKC_F4,
"aircraft_list", MTHK_AIRCRAFT_LIST),
2226 Hotkey(_maintoolbar_zoomin_keys,
"zoomin", MTHK_ZOOM_IN),
2227 Hotkey(_maintoolbar_zoomout_keys,
"zoomout", MTHK_ZOOM_OUT),
2228 Hotkey(WKC_SHIFT | WKC_F7,
"build_rail", MTHK_BUILD_RAIL),
2229 Hotkey(WKC_SHIFT | WKC_F8,
"build_road", MTHK_BUILD_ROAD),
2230 Hotkey((uint16)0,
"build_tram", MTHK_BUILD_TRAM),
2231 Hotkey(WKC_SHIFT | WKC_F9,
"build_docks", MTHK_BUILD_DOCKS),
2232 Hotkey(WKC_SHIFT | WKC_F10,
"build_airport", MTHK_BUILD_AIRPORT),
2233 Hotkey(WKC_SHIFT | WKC_F11,
"build_trees", MTHK_BUILD_TREES),
2234 Hotkey(WKC_SHIFT | WKC_F12,
"music", MTHK_MUSIC),
2235 Hotkey((uint16)0,
"ai_debug", MTHK_AI_DEBUG),
2236 Hotkey(WKC_CTRL |
'S',
"small_screenshot", MTHK_SMALL_SCREENSHOT),
2237 Hotkey(WKC_CTRL |
'P',
"zoomedin_screenshot", MTHK_ZOOMEDIN_SCREENSHOT),
2238 Hotkey(WKC_CTRL |
'D',
"defaultzoom_screenshot", MTHK_DEFAULTZOOM_SCREENSHOT),
2239 Hotkey((uint16)0,
"giant_screenshot", MTHK_GIANT_SCREENSHOT),
2240 Hotkey(WKC_CTRL | WKC_ALT |
'C',
"cheats", MTHK_CHEATS),
2241 Hotkey(
'L',
"terraform", MTHK_TERRAFORM),
2242 Hotkey(
'V',
"extra_viewport", MTHK_EXTRA_VIEWPORT),
2243 Hotkey((uint16)0,
"client_list", MTHK_CLIENT_LIST),
2244 Hotkey((uint16)0,
"sign_list", MTHK_SIGN_LIST),
2247 HotkeyList MainToolbarWindow::hotkeys(
"maintoolbar", maintoolbar_hotkeys);
2252 static const SpriteID toolbar_button_sprites[] = {
2254 SPR_IMG_FASTFORWARD,
2260 SPR_IMG_COMPANY_LIST,
2261 SPR_IMG_COMPANY_FINANCE,
2262 SPR_IMG_COMPANY_GENERAL,
2266 SPR_IMG_COMPANY_LEAGUE,
2271 SPR_IMG_AIRPLANESLIST,
2279 SPR_IMG_LANDSCAPING,
2283 SPR_IMG_SWITCH_TOOLBAR,
2305 static const NWidgetPart _nested_toolbar_normal_widgets[] = {
2313 _nested_toolbar_normal_widgets,
lengthof(_nested_toolbar_normal_widgets),
2314 &MainToolbarWindow::hotkeys
2320 static MenuClickedProc *
const _scen_toolbar_dropdown_procs[] = {
2346 static ToolbarButtonProc *
const _scen_toolbar_button_procs[] = {
2353 ToolbarScenDateBackward,
2354 ToolbarScenDateForward,
2355 ToolbarScenMapTownDir,
2357 ToolbarZoomOutClick,
2360 ToolbarScenGenIndustry,
2361 ToolbarScenBuildRoadClick,
2362 ToolbarScenBuildTramClick,
2363 ToolbarScenBuildDocks,
2364 ToolbarScenPlantTrees,
2365 ToolbarScenPlaceSign,
2372 enum MainToolbarEditorHotkeys {
2387 MTEHK_SMALL_SCREENSHOT,
2388 MTEHK_ZOOMEDIN_SCREENSHOT,
2389 MTEHK_DEFAULTZOOM_SCREENSHOT,
2390 MTEHK_GIANT_SCREENSHOT,
2395 MTEHK_EXTRA_VIEWPORT,
2403 this->InitNested(0);
2425 this->DrawWidgets();
2437 int height = r.bottom - r.top;
2440 DrawString(r.left, r.right, (height + 1) / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING,
SA_HOR_CENTER);
2466 if (_game_mode == GM_MENU)
return;
2482 case MTEHK_PAUSE: ToolbarPauseClick(
this);
break;
2486 case MTEHK_GENLAND: ToolbarScenGenLand(
this);
break;
2487 case MTEHK_GENTOWN: ToolbarScenGenTown(
this);
break;
2488 case MTEHK_GENINDUSTRY: ToolbarScenGenIndustry(
this);
break;
2489 case MTEHK_BUILD_ROAD: ToolbarScenBuildRoadClick(
this);
break;
2490 case MTEHK_BUILD_TRAM: ToolbarScenBuildTramClick(
this);
break;
2491 case MTEHK_BUILD_DOCKS: ToolbarScenBuildDocks(
this);
break;
2492 case MTEHK_BUILD_TREES: ToolbarScenPlantTrees(
this);
break;
2493 case MTEHK_SIGN: cbf = ToolbarScenPlaceSign(
this);
break;
2494 case MTEHK_MUSIC: ShowMusicWindow();
break;
2495 case MTEHK_LANDINFO: cbf = PlaceLandBlockInfo();
break;
2496 case MTEHK_SMALL_SCREENSHOT: MenuClickSmallScreenshot();
break;
2500 case MTEHK_ZOOM_IN: ToolbarZoomInClick(
this);
break;
2501 case MTEHK_ZOOM_OUT: ToolbarZoomOutClick(
this);
break;
2514 case CBF_PLACE_SIGN:
2518 case CBF_PLACE_LANDINFO:
2522 default: NOT_REACHED();
2540 if (!this->timer.
Elapsed(delta_ms))
return;
2561 if (!gui_scope)
return;
2568 if (str ==
nullptr)
return;
2585 static Hotkey scenedit_maintoolbar_hotkeys[] = {
2586 Hotkey(_maintoolbar_pause_keys,
"pause", MTEHK_PAUSE),
2587 Hotkey((uint16)0,
"fastforward", MTEHK_FASTFORWARD),
2588 Hotkey(WKC_F2,
"settings", MTEHK_SETTINGS),
2589 Hotkey(WKC_F3,
"saveload", MTEHK_SAVEGAME),
2590 Hotkey(WKC_F4,
"gen_land", MTEHK_GENLAND),
2591 Hotkey(WKC_F5,
"gen_town", MTEHK_GENTOWN),
2592 Hotkey(WKC_F6,
"gen_industry", MTEHK_GENINDUSTRY),
2593 Hotkey(WKC_F7,
"build_road", MTEHK_BUILD_ROAD),
2594 Hotkey((uint16)0,
"build_tram", MTEHK_BUILD_TRAM),
2595 Hotkey(WKC_F8,
"build_docks", MTEHK_BUILD_DOCKS),
2596 Hotkey(WKC_F9,
"build_trees", MTEHK_BUILD_TREES),
2597 Hotkey(WKC_F10,
"build_sign", MTEHK_SIGN),
2598 Hotkey(WKC_F11,
"music", MTEHK_MUSIC),
2599 Hotkey(WKC_F12,
"land_info", MTEHK_LANDINFO),
2600 Hotkey(WKC_CTRL |
'S',
"small_screenshot", MTEHK_SMALL_SCREENSHOT),
2601 Hotkey(WKC_CTRL |
'P',
"zoomedin_screenshot", MTEHK_ZOOMEDIN_SCREENSHOT),
2602 Hotkey(WKC_CTRL |
'D',
"defaultzoom_screenshot", MTEHK_DEFAULTZOOM_SCREENSHOT),
2603 Hotkey((uint16)0,
"giant_screenshot", MTEHK_GIANT_SCREENSHOT),
2604 Hotkey(_maintoolbar_zoomin_keys,
"zoomin", MTEHK_ZOOM_IN),
2605 Hotkey(_maintoolbar_zoomout_keys,
"zoomout", MTEHK_ZOOM_OUT),
2606 Hotkey(
'L',
"terraform", MTEHK_TERRAFORM),
2607 Hotkey(
'M',
"smallmap", MTEHK_SMALLMAP),
2608 Hotkey(
'V',
"extra_viewport", MTEHK_EXTRA_VIEWPORT),
2611 HotkeyList ScenarioEditorToolbarWindow::hotkeys(
"scenedit_maintoolbar", scenedit_maintoolbar_hotkeys);
2613 static const NWidgetPart _nested_toolb_scen_inner_widgets[] = {
2648 static NWidgetBase *MakeScenarioToolbar(
int *biggest_index)
2653 static const NWidgetPart _nested_toolb_scen_widgets[] = {
2661 _nested_toolb_scen_widgets,
lengthof(_nested_toolb_scen_widgets),
2662 &ScenarioEditorToolbarWindow::hotkeys
2672 if (_game_mode == GM_EDITOR) {
EventState
State of handling an event.
bool DoZoomInOutWindow(ZoomStateChange how, Window *w)
Zooms a viewport in a window in or out.
Functions related to OTTD's strings.
Window * ShowBuildRailToolbar(RailType railtype)
Open the build rail toolbar window for a specific rail type.
const byte * GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override
Get the arrangement of the buttons for the toolbar.
Owner
Enum for all companies/owners.
Functions/types related to NewGRF debugging.
Window * ShowBuildRoadScenToolbar(RoadType roadtype)
Show the road building toolbar in the scenario editor.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
used in multiplayer to create a new companies etc.
bool _networking
are we in networking mode?
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company)
Prepare a DoCommand to be send over the network.
Horizontally center the text.
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...
GRFConfig * _grfconfig
First item in list of current GRF set up.
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
RoadTypes _roadtypes_type
Bitmap of road/tram types.
All data for a single hotkey.
High level window description.
void ShowSpriteAlignerWindow()
Show the window for aligning sprites.
byte _display_opt
What do we want to draw/do?
EconomySettings economy
settings to change the economy
WindowFlags flags
Window flags.
Zoom out (get helicopter view).
int height
Screen height of the viewport.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out)
Update the status of the zoom-buttons according to the zoom-level of the viewport.
Hotkey related functions.
Functions related to dates.
GUIs related to networking.
static T ToggleBit(T &x, const uint8 y)
Toggles a bit in a variable.
Window for configuring the AIs
void ShowSmallMap()
Show the smallmap window.
Functions/types related to the road GUIs.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
The passed event is not handled.
bool Elapsed(uint delta)
Test if a timer has elapsed.
int PositionMainToolbar(Window *w)
(Re)position main toolbar window at the screen.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
Types for recording game performance data.
VehicleType
Available vehicle types.
Window * ShowSignList()
Open the sign list window.
Sign list; Window numbers:
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
Functions related to vehicles.
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
void ShowGoalsList(CompanyID company)
Open a goal list window.
Window * ShowBuildDocksToolbar()
Open the build water toolbar window.
TownFounding found_town
town founding.
void NetworkClientRequestMove(CompanyID company_id, const char *pass)
Notify the server of this client wanting to be moved to another company.
void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
Handle the tid-bits of moving a client from one company to another.
Display signs, station names and waypoint names of opponent companies. Buoys and oilrig-stations are ...
Also draw details of track and roads.
void ShowAIConfigWindow()
Open the AI config window.
Zoom in (get more detailed view).
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
bool NetworkCompanyIsPassworded(CompanyID company_id)
Check if the company we want to join requires a password.
Stuff related to the text buffer GUI.
Functions to make screenshots.
bool NetworkMaxSpectatorsReached()
Check if max_spectatos has been reached on the server (local check only).
#define CLRBITS(x, y)
Clears several bits in a variable.
void DeleteAllMessages()
Delete all messages and their corresponding window (if any).
DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option)
Create a drop down list for all the rail types of the local company.
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
Functions related to signs.
RoadType
The different roadtypes we support.
static T max(const T a, const T b)
Returns the maximum of two values.
Fully zoomed in screenshot of the visible area.
Functions related to the vehicle's GUIs.
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Functions, definitions and such used only by the GUI.
bool _left_button_clicked
Is left mouse button clicked?
static bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
static const Year DEF_START_YEAR
The default starting year.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
void ShowLandInfo(TileIndex tile)
Show land information window.
Functions related to (drawing on) viewports.
void SetupScreenshotViewport(ScreenshotType t, ViewPort *vp)
Configure a ViewPort for rendering (a part of) the map into a screenshot.
Declaration of linkgraph overlay GUI.
void ShiftDates(int interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
Data structure for an opened window.
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...
Bottom offset of image in the button.
Main window; Window numbers:
void SetDate(Date date, DateFract fract)
Set the date.
enable the 'Default' button ("\0" is returned)
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
void FindWindowPlacementAndResize(int def_width, int def_height) override
Resize window towards the default size.
void ShowCompanyStations(CompanyID company)
Opens window with list of company's stations.
void ShowCompany(CompanyID company)
Show the window with the overview of the company.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
The client is spectating.
List item with icon and string.
SoundSettings sound
sound effect settings
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
Show a modal confirmation window with standard 'yes' and 'no' buttons The window is aligned to the ce...
GUI functions related to the news.
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
void ShowMessageHistory()
Display window with news messages history.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
ClientID _network_own_client_id
Our client identifier.
ClientSettings _settings_client
The current settings for this game.
bool masked
Masked and unselectable item.
Definition of base types and functions in a cross-platform compatible way.
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
A number of safeguards to prevent using unsafe methods.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
List of hotkeys for a window.
rectangle (stations, depots, ...)
void ShowFramerateWindow()
Open the general framerate window.
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
static const uint MILLISECONDS_PER_TICK
The number of milliseconds per game tick.
Drop down list entry for showing a checked/unchecked toggle item.
GUI functions related to transparency.
GUI Functions related to companies.
void ShowLastNewsMessage()
Show previous news item.
GUI related functions in the console.
void ShowCheatWindow()
Open cheat window.
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Functions related to cheating.
Basic functions/variables used all over the place.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
static void ToggleTransparency(TransparencyOption to)
Toggle the transparency option bit.
#define lengthof(x)
Return the length of an fixed size array.
Window * ShowBuildAirToolbar()
Open the build airport toolbar window.
PauseMode _pause_mode
The current pause mode.
Functions related to sound.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Window * ShowAIDebugWindow(CompanyID show_company)
Open the AI debug window and select the given company.
bool CanBuildVehicleInfrastructure(VehicleType type, byte subtype)
Check whether we can build infrastructure for the given vehicle type.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
void ShowExtraViewPortWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
bool MakeScreenshot(ScreenshotType t, const char *name)
Make an actual screenshot.
bool newgrf_developer_tools
activate NewGRF developer tools and allow modifying NewGRFs in an existing game
void ShowHighscoreTable(int difficulty=SP_CUSTOM, int8 rank=-1)
Show the highscore table for a given difficulty.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
static const uint8 PC_VERY_DARK_RED
Almost-black red palette colour.
Draw only every second pixel, used for greying-out.
No window, redirects to WC_MAIN_WINDOW.
static const uint8 PC_DARK_RED
Dark red palette colour.
Functions related to companies.
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
RailType
Enumeration for all possible railtypes.
Declaration of functions and types defined in highscore.h and highscore_gui.h.
GUISettings gui
settings related to the GUI
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Base class for all vehicles.
Data structure for viewport, display of a part of the world.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Declarations for savegames operations.
Zoomed to default zoom level screenshot of the visible area.
void OnPaint() override
The window must be repainted.
uint32 TileIndex
The index/ID of a Tile.
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
static size_t GetNumItems()
Returns number of valid items in the pool.
First company, same as owner.
TextDirection _current_text_dir
Text direction of the currently selected language.
int result
Result code to return to window on selection.
This window won't get focus/make any other window lose focus when click.
void ShowIndustryCargoesWindow()
Open the industry and cargoes window with an industry.
Top offset of image in the button.
void ShowLinkGraphLegend()
Open a link graph legend window.
Do not add shading to this text colour.
Container for the 'normal' main toolbar.
Maximum number of companies.
Drop down list entry for showing a company entry, with companies 'blob'.
bool confirm
Play sound effect on successful constructions or other actions.
Base functions for all Games.
Functions related to commands.
bool NetworkMaxCompaniesReached()
Check if max_companies has been reached on the server (local check only).
Network functions used by other parts of OpenTTD.
bool _network_server
network-server is active
void ShowStoryBook(CompanyID company, uint16 page_id=INVALID_STORY_PAGE)
Raise or create the story book window for company, at page page_id.
Main toolbar (the long bar at the top); Window numbers:
Coordinates of a point in 2D.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Perform palette animation.
void ShowCompanyFinances(CompanyID company)
Open the finances window of a company.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
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...
bool UserIsAllowedToChangeNewGRFs() const
Returns true when the user has sufficient privileges to edit newgrfs on a running game...
static const Year MIN_YEAR
The absolute minimum & maximum years in OTTD.
int32 Date
The type to store our dates in.
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
Resize window towards the default size.
void ShowGameSettings()
Open advanced settings window.
Offset at right to draw the frame rectangular area.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Servers always have this ID.
void ShowExtraViewPortWindowForTileUnderCursor()
Show a new Extra Viewport window.
GameCreationSettings game_creation
settings used during the creation of a game (map)
void IConsoleSwitch()
Toggle in-game console between opened and closed.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
void OnTimeout() override
Called when this window's timeout has been reached.
Specification of a rectangle with absolute coordinates of all edges.
void ShowGameOptions()
Open the game options window.
The passed event is handled.
Text is written right-to-left by default.
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Functions related to tile highlights.
Window functions not directly related to making/drawing windows.
Manually align the window (so no automatic location finding)
GUI functions that shouldn't be here.
Window * ShowBuildDocksScenToolbar()
Open the build water toolbar window for the scenario editor.
void PlaceProc_Sign(TileIndex tile)
PlaceProc function, called when someone pressed the button if the sign-tool is selected.
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
RoadTypes GetRoadTypes(bool introduces)
Get list of road types, regardless of company availability.
Date _date
Current date in days (day counter)
Window white border counter bit mask.
Hack, used to update the button status.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Base list item class from which others are derived.
Dimensions (a width and height) of a rectangle in 2D.
bool click_beep
Beep on a random selection of buttons.
Offset at left to draw the frame rectangular area.
static const Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date...
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
void ShowTransparencyToolbar()
Show the transparency toolbar.
Year starting_year
starting date
void OnRealtimeTick(uint delta_ms) override
Called periodically.
static bool IsTransparencySet(TransparencyOption to)
Check if the transparency option bit is set and if we aren't in the game menu (there's never transpar...
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
ScreenshotType
Type of requested screenshot.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
int width
Screen width of the viewport.