Go to the documentation of this file.
101 return DropDownListStringItem::Width() + this->checkmark_width;
104 void Draw(
int left,
int right,
int top,
int bottom,
bool sel, Colours bg_colour)
const
129 bool Selectable()
const override
134 uint Width()
const override
139 return GetStringBoundingBox(STR_COMPANY_NAME_COMPANY_NUM).width + this->icon_size.width + this->lock_size.width + 6;
142 uint Height(uint width)
const override
144 return std::max(std::max(this->icon_size.height, this->lock_size.height) + 2U, (uint)
FONT_HEIGHT_NORMAL);
147 void Draw(
int left,
int right,
int top,
int bottom,
bool sel, Colours bg_colour)
const override
155 int icon_offset = (bottom - top - icon_size.height) / 2;
157 int lock_offset = (bottom - top - lock_size.height) / 2;
170 col = sel ? TC_WHITE : TC_BLACK;
172 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);
199 for (
int i = 0; i < count; i++) {
262 return CBF_PLACE_SIGN;
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_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS,
false));
479 list.emplace_back(
new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEWPORT, 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));
963 list.emplace_back(
new DropDownListIconItem(SPR_IMG_AIRPORT, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 0,
false));
986 list.emplace_back(
new DropDownListIconItem(SPR_IMG_LANDSCAPING, PAL_NONE, STR_LANDSCAPING_MENU_LANDSCAPING, 0,
false));
987 list.emplace_back(
new DropDownListIconItem(SPR_IMG_PLANTTREES, PAL_NONE, STR_LANDSCAPING_MENU_PLANT_TREES, 1,
false));
988 list.emplace_back(
new DropDownListIconItem(SPR_IMG_SIGN, PAL_NONE, STR_LANDSCAPING_MENU_PLACE_SIGN, 2,
false));
1004 case 1: ShowBuildTreesToolbar();
break;
1005 case 2:
return SelectSignTool();
1063 return CBF_PLACE_LANDINFO;
1082 extern bool _draw_bounding_boxes;
1085 _draw_bounding_boxes = !_draw_bounding_boxes;
1099 extern bool _draw_dirty_blocks;
1102 _draw_dirty_blocks = !_draw_dirty_blocks;
1128 case 0:
return PlaceLandBlockInfo();
1131 case 4: ShowScreenshotWindow();
break;
1133 case 6: ShowAboutWindow();
break;
1145 if (_toolbar_mode != TB_LOWER) {
1146 _toolbar_mode = TB_LOWER;
1148 _toolbar_mode = TB_UPPER;
1210 ShowFoundTownWindow();
1218 ShowBuildIndustryWindow();
1237 _last_built_roadtype = (
RoadType)index;
1257 _last_built_tramtype = (
RoadType)index;
1274 ShowBuildTreesToolbar();
1282 return SelectSignTool();
1292 static MenuClickedProc *
const _menu_clicked_procs[] = {
1358 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1359 child_wid->SetupSmallestSize(w, init_array);
1360 this->
smallest_y = std::max(this->
smallest_y, child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom);
1361 if (this->
IsButton(child_wid->type)) {
1363 this->
smallest_x = std::max(this->
smallest_x, child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right);
1370 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1372 if (!this->
IsButton(child_wid->type)) {
1373 child_wid->current_x = child_wid->smallest_x;
1389 memset(this->visible, 0,
sizeof(this->visible));
1390 uint arrangable_count, button_count, spacer_count;
1391 const byte *arrangement =
GetButtonArrangement(given_width, arrangable_count, button_count, spacer_count);
1392 for (uint i = 0; i < arrangable_count; i++) {
1393 this->visible[arrangement[i]] =
true;
1398 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1400 widgets[((
NWidgetCore*)child_wid)->index] = child_wid;
1405 uint spacer_space = std::max(0, (
int)given_width - (
int)(button_count * this->
smallest_x));
1406 uint button_space = given_width - spacer_space;
1411 const byte *cur_wid = rtl ? &arrangement[arrangable_count - 1] : arrangement;
1412 for (uint i = 0; i < arrangable_count; i++) {
1415 if (spacer_space != 0) {
1417 if (possible_spacer !=
nullptr && possible_spacer->
type ==
NWID_SPACER) {
1418 uint add = spacer_space / (spacer_count - spacer_i);
1420 spacer_space -= add;
1427 child_wid->
current_x = button_space / (button_count - button_i);
1449 for (
NWidgetBase *child_wid = rtl ? this->
tail : this->
head; child_wid !=
nullptr; child_wid = rtl ? child_wid->
prev : child_wid->
next) {
1451 if (!this->visible[((
NWidgetCore*)child_wid)->index])
continue;
1461 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1463 if (!this->visible[((
NWidgetCore*)child_wid)->index])
continue;
1466 if (nwid !=
nullptr)
return nwid;
1479 virtual const byte *
GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count)
const = 0;
1484 const byte *
GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count)
const override
1486 static const uint SMALLEST_ARRANGEMENT = 14;
1487 static const uint BIGGEST_ARRANGEMENT = 20;
1495 static const byte arrange14[] = {
1526 static const byte arrange15[] = {
1559 static const byte arrange16[] = {
1594 static const byte arrange17[] = {
1631 static const byte arrange18[] = {
1670 static const byte arrange19[] = {
1711 static const byte arrange20[] = {
1754 static const byte arrange_all[] = {
1788 uint full_buttons = std::max(
CeilDiv(width, this->
smallest_x), SMALLEST_ARRANGEMENT);
1789 if (full_buttons > BIGGEST_ARRANGEMENT) {
1790 button_count = arrangable_count =
lengthof(arrange_all);
1796 static const byte *
const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20 };
1798 button_count = arrangable_count = full_buttons;
1800 return arrangements[full_buttons - SMALLEST_ARRANGEMENT] + ((_toolbar_mode == TB_LOWER) ? full_buttons : 0);
1814 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1815 if (child_wid->type ==
NWID_SPACER || this->IsButton(child_wid->type))
continue;
1817 assert(i <
lengthof(this->panel_widths));
1818 this->panel_widths[i++] = child_wid->current_x;
1823 const byte *
GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count)
const override
1825 static const byte arrange_all[] = {
1846 static const byte arrange_nopanel[] = {
1866 static const byte arrange_switch[] = {
1893 uint min_full_width = (
lengthof(arrange_all) -
lengthof(this->panel_widths)) * this->
smallest_x + this->panel_widths[0] + this->panel_widths[1];
1894 if (width >= min_full_width) {
1895 width -= this->panel_widths[0] + this->panel_widths[1];
1896 arrangable_count =
lengthof(arrange_all);
1897 button_count = arrangable_count - 2;
1903 uint min_small_width = (
lengthof(arrange_switch) -
lengthof(this->panel_widths)) * this->
smallest_x / 2 + this->panel_widths[1];
1904 if (width > min_small_width) {
1905 width -= this->panel_widths[1];
1906 arrangable_count =
lengthof(arrange_nopanel);
1907 button_count = arrangable_count - 1;
1908 spacer_count = this->
spacers - 1;
1909 return arrange_nopanel;
1913 width -= this->panel_widths[1];
1914 arrangable_count =
lengthof(arrange_switch) / 2;
1915 button_count = arrangable_count - 1;
1917 return arrange_switch + ((_toolbar_mode == TB_LOWER) ? arrangable_count : 0);
1925 static ToolbarButtonProc *
const _toolbar_button_procs[] = {
1932 ToolbarSubsidiesClick,
1933 ToolbarStationsClick,
1934 ToolbarFinancesClick,
1935 ToolbarCompaniesClick,
1940 ToolbarIndustryClick,
1946 ToolbarZoomOutClick,
1947 ToolbarBuildRailClick,
1948 ToolbarBuildRoadClick,
1949 ToolbarBuildTramClick,
1950 ToolbarBuildWaterClick,
1951 ToolbarBuildAirClick,
1954 ToolbarNewspaperClick,
1959 enum MainToolbarHotkeys {
1991 MTHK_SMALL_SCREENSHOT,
1992 MTHK_ZOOMEDIN_SCREENSHOT,
1993 MTHK_DEFAULTZOOM_SCREENSHOT,
1994 MTHK_GIANT_SCREENSHOT,
1997 MTHK_EXTRA_VIEWPORT,
2042 if (_game_mode != GM_MENU && !this->
IsWidgetDisabled(widget)) _toolbar_button_procs[widget](
this);
2055 case MTHK_PAUSE: ToolbarPauseClick(
this);
break;
2061 case MTHK_TOWNDIRECTORY: ShowTownDirectory();
break;
2062 case MTHK_SUBSIDIES: ShowSubsidiesList();
break;
2068 case MTHK_GRAPHS: ShowOperatingProfitGraph();
break;
2069 case MTHK_LEAGUE: ShowCompanyLeagueTable();
break;
2070 case MTHK_INDUSTRIES: ShowBuildIndustryWindow();
break;
2075 case MTHK_ZOOM_IN: ToolbarZoomInClick(
this);
break;
2076 case MTHK_ZOOM_OUT: ToolbarZoomOutClick(
this);
break;
2082 case MTHK_BUILD_TREES: ShowBuildTreesToolbar();
break;
2083 case MTHK_MUSIC: ShowMusicWindow();
break;
2092 case MTHK_CLIENT_LIST:
if (
_networking) ShowClientList();
break;
2094 case MTHK_LANDINFO: cbf = PlaceLandBlockInfo();
break;
2104 case CBF_PLACE_SIGN:
2108 case CBF_PLACE_LANDINFO:
2112 default: NOT_REACHED();
2123 if (!this->timer.
Elapsed(delta_ms))
return;
2156 if (!gui_scope)
return;
2163 const uint16 _maintoolbar_pause_keys[] = {WKC_F1, WKC_PAUSE, 0};
2164 const uint16 _maintoolbar_zoomin_keys[] = {WKC_NUM_PLUS,
WKC_EQUALS, WKC_SHIFT |
WKC_EQUALS, WKC_SHIFT | WKC_F5, 0};
2165 const uint16 _maintoolbar_zoomout_keys[] = {WKC_NUM_MINUS,
WKC_MINUS, WKC_SHIFT |
WKC_MINUS, WKC_SHIFT | WKC_F6, 0};
2166 const uint16 _maintoolbar_smallmap_keys[] = {WKC_F4,
'M', 0};
2168 static Hotkey maintoolbar_hotkeys[] = {
2169 Hotkey(_maintoolbar_pause_keys,
"pause", MTHK_PAUSE),
2170 Hotkey((uint16)0,
"fastforward", MTHK_FASTFORWARD),
2171 Hotkey(WKC_F2,
"settings", MTHK_SETTINGS),
2172 Hotkey(WKC_F3,
"saveload", MTHK_SAVEGAME),
2173 Hotkey((uint16)0,
"load_game", MTHK_LOADGAME),
2174 Hotkey(_maintoolbar_smallmap_keys,
"smallmap", MTHK_SMALLMAP),
2175 Hotkey(WKC_F5,
"town_list", MTHK_TOWNDIRECTORY),
2176 Hotkey(WKC_F6,
"subsidies", MTHK_SUBSIDIES),
2177 Hotkey(WKC_F7,
"station_list", MTHK_STATIONS),
2178 Hotkey(WKC_F8,
"finances", MTHK_FINANCES),
2179 Hotkey(WKC_F9,
"companies", MTHK_COMPANIES),
2180 Hotkey((uint16)0,
"story_book", MTHK_STORY),
2181 Hotkey((uint16)0,
"goal_list", MTHK_GOAL),
2182 Hotkey(WKC_F10,
"graphs", MTHK_GRAPHS),
2183 Hotkey(WKC_F11,
"league", MTHK_LEAGUE),
2184 Hotkey(WKC_F12,
"industry_list", MTHK_INDUSTRIES),
2185 Hotkey(WKC_SHIFT | WKC_F1,
"train_list", MTHK_TRAIN_LIST),
2186 Hotkey(WKC_SHIFT | WKC_F2,
"roadveh_list", MTHK_ROADVEH_LIST),
2187 Hotkey(WKC_SHIFT | WKC_F3,
"ship_list", MTHK_SHIP_LIST),
2188 Hotkey(WKC_SHIFT | WKC_F4,
"aircraft_list", MTHK_AIRCRAFT_LIST),
2189 Hotkey(_maintoolbar_zoomin_keys,
"zoomin", MTHK_ZOOM_IN),
2190 Hotkey(_maintoolbar_zoomout_keys,
"zoomout", MTHK_ZOOM_OUT),
2191 Hotkey(WKC_SHIFT | WKC_F7,
"build_rail", MTHK_BUILD_RAIL),
2192 Hotkey(WKC_SHIFT | WKC_F8,
"build_road", MTHK_BUILD_ROAD),
2193 Hotkey((uint16)0,
"build_tram", MTHK_BUILD_TRAM),
2194 Hotkey(WKC_SHIFT | WKC_F9,
"build_docks", MTHK_BUILD_DOCKS),
2195 Hotkey(WKC_SHIFT | WKC_F10,
"build_airport", MTHK_BUILD_AIRPORT),
2196 Hotkey(WKC_SHIFT | WKC_F11,
"build_trees", MTHK_BUILD_TREES),
2197 Hotkey(WKC_SHIFT | WKC_F12,
"music", MTHK_MUSIC),
2198 Hotkey((uint16)0,
"ai_debug", MTHK_AI_DEBUG),
2199 Hotkey(WKC_CTRL |
'S',
"small_screenshot", MTHK_SMALL_SCREENSHOT),
2200 Hotkey(WKC_CTRL |
'P',
"zoomedin_screenshot", MTHK_ZOOMEDIN_SCREENSHOT),
2201 Hotkey(WKC_CTRL |
'D',
"defaultzoom_screenshot", MTHK_DEFAULTZOOM_SCREENSHOT),
2202 Hotkey((uint16)0,
"giant_screenshot", MTHK_GIANT_SCREENSHOT),
2203 Hotkey(WKC_CTRL | WKC_ALT |
'C',
"cheats", MTHK_CHEATS),
2204 Hotkey(
'L',
"terraform", MTHK_TERRAFORM),
2205 Hotkey(
'V',
"extra_viewport", MTHK_EXTRA_VIEWPORT),
2206 Hotkey((uint16)0,
"client_list", MTHK_CLIENT_LIST),
2207 Hotkey((uint16)0,
"sign_list", MTHK_SIGN_LIST),
2208 Hotkey((uint16)0,
"land_info", MTHK_LANDINFO),
2211 HotkeyList MainToolbarWindow::hotkeys(
"maintoolbar", maintoolbar_hotkeys);
2216 static const SpriteID toolbar_button_sprites[] = {
2218 SPR_IMG_FASTFORWARD,
2224 SPR_IMG_COMPANY_LIST,
2225 SPR_IMG_COMPANY_FINANCE,
2226 SPR_IMG_COMPANY_GENERAL,
2230 SPR_IMG_COMPANY_LEAGUE,
2235 SPR_IMG_AIRPLANESLIST,
2243 SPR_IMG_LANDSCAPING,
2247 SPR_IMG_SWITCH_TOOLBAR,
2269 static const NWidgetPart _nested_toolbar_normal_widgets[] = {
2277 _nested_toolbar_normal_widgets,
lengthof(_nested_toolbar_normal_widgets),
2278 &MainToolbarWindow::hotkeys
2284 static MenuClickedProc *
const _scen_toolbar_dropdown_procs[] = {
2310 static ToolbarButtonProc *
const _scen_toolbar_button_procs[] = {
2317 ToolbarScenDateBackward,
2318 ToolbarScenDateForward,
2319 ToolbarScenMapTownDir,
2321 ToolbarZoomOutClick,
2324 ToolbarScenGenIndustry,
2325 ToolbarScenBuildRoadClick,
2326 ToolbarScenBuildTramClick,
2327 ToolbarScenBuildDocks,
2328 ToolbarScenPlantTrees,
2329 ToolbarScenPlaceSign,
2336 enum MainToolbarEditorHotkeys {
2351 MTEHK_SMALL_SCREENSHOT,
2352 MTEHK_ZOOMEDIN_SCREENSHOT,
2353 MTEHK_DEFAULTZOOM_SCREENSHOT,
2354 MTEHK_GIANT_SCREENSHOT,
2359 MTEHK_EXTRA_VIEWPORT,
2401 int height = r.bottom - r.top;
2430 if (_game_mode == GM_MENU)
return;
2446 case MTEHK_PAUSE: ToolbarPauseClick(
this);
break;
2450 case MTEHK_GENLAND: ToolbarScenGenLand(
this);
break;
2451 case MTEHK_GENTOWN: ToolbarScenGenTown(
this);
break;
2452 case MTEHK_GENINDUSTRY: ToolbarScenGenIndustry(
this);
break;
2453 case MTEHK_BUILD_ROAD: ToolbarScenBuildRoadClick(
this);
break;
2454 case MTEHK_BUILD_TRAM: ToolbarScenBuildTramClick(
this);
break;
2455 case MTEHK_BUILD_DOCKS: ToolbarScenBuildDocks(
this);
break;
2456 case MTEHK_BUILD_TREES: ToolbarScenPlantTrees(
this);
break;
2457 case MTEHK_SIGN: cbf = ToolbarScenPlaceSign(
this);
break;
2458 case MTEHK_MUSIC: ShowMusicWindow();
break;
2459 case MTEHK_LANDINFO: cbf = PlaceLandBlockInfo();
break;
2464 case MTEHK_ZOOM_IN: ToolbarZoomInClick(
this);
break;
2465 case MTEHK_ZOOM_OUT: ToolbarZoomOutClick(
this);
break;
2478 case CBF_PLACE_SIGN:
2482 case CBF_PLACE_LANDINFO:
2486 default: NOT_REACHED();
2504 if (!this->timer.
Elapsed(delta_ms))
return;
2525 if (!gui_scope)
return;
2532 if (str ==
nullptr)
return;
2549 static Hotkey scenedit_maintoolbar_hotkeys[] = {
2550 Hotkey(_maintoolbar_pause_keys,
"pause", MTEHK_PAUSE),
2551 Hotkey((uint16)0,
"fastforward", MTEHK_FASTFORWARD),
2552 Hotkey(WKC_F2,
"settings", MTEHK_SETTINGS),
2553 Hotkey(WKC_F3,
"saveload", MTEHK_SAVEGAME),
2554 Hotkey(WKC_F4,
"gen_land", MTEHK_GENLAND),
2555 Hotkey(WKC_F5,
"gen_town", MTEHK_GENTOWN),
2556 Hotkey(WKC_F6,
"gen_industry", MTEHK_GENINDUSTRY),
2557 Hotkey(WKC_F7,
"build_road", MTEHK_BUILD_ROAD),
2558 Hotkey((uint16)0,
"build_tram", MTEHK_BUILD_TRAM),
2559 Hotkey(WKC_F8,
"build_docks", MTEHK_BUILD_DOCKS),
2560 Hotkey(WKC_F9,
"build_trees", MTEHK_BUILD_TREES),
2561 Hotkey(WKC_F10,
"build_sign", MTEHK_SIGN),
2562 Hotkey(WKC_F11,
"music", MTEHK_MUSIC),
2563 Hotkey(WKC_F12,
"land_info", MTEHK_LANDINFO),
2564 Hotkey(WKC_CTRL |
'S',
"small_screenshot", MTEHK_SMALL_SCREENSHOT),
2565 Hotkey(WKC_CTRL |
'P',
"zoomedin_screenshot", MTEHK_ZOOMEDIN_SCREENSHOT),
2566 Hotkey(WKC_CTRL |
'D',
"defaultzoom_screenshot", MTEHK_DEFAULTZOOM_SCREENSHOT),
2567 Hotkey((uint16)0,
"giant_screenshot", MTEHK_GIANT_SCREENSHOT),
2568 Hotkey(_maintoolbar_zoomin_keys,
"zoomin", MTEHK_ZOOM_IN),
2569 Hotkey(_maintoolbar_zoomout_keys,
"zoomout", MTEHK_ZOOM_OUT),
2570 Hotkey(
'L',
"terraform", MTEHK_TERRAFORM),
2571 Hotkey(
'M',
"smallmap", MTEHK_SMALLMAP),
2572 Hotkey(
'V',
"extra_viewport", MTEHK_EXTRA_VIEWPORT),
2575 HotkeyList ScenarioEditorToolbarWindow::hotkeys(
"scenedit_maintoolbar", scenedit_maintoolbar_hotkeys);
2577 static const NWidgetPart _nested_toolb_scen_inner_widgets[] = {
2612 static NWidgetBase *MakeScenarioToolbar(
int *biggest_index)
2617 static const NWidgetPart _nested_toolb_scen_widgets[] = {
2625 _nested_toolb_scen_widgets,
lengthof(_nested_toolb_scen_widgets),
2626 &ScenarioEditorToolbarWindow::hotkeys
2636 if (_game_mode == GM_EDITOR) {
@ VEH_AIRCRAFT
Aircraft vehicle type.
@ DO_SHOW_COMPETITOR_SIGNS
Display signs, station names and waypoint names of opponent companies. Buoys and oilrig-stations are ...
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
@ ES_HANDLED
The passed event is handled.
void ShowSpriteAlignerWindow()
Show the window for aligning sprites.
void ShowIndustryCargoesWindow()
Open the industry and cargoes window with an industry.
uint32 TileIndex
The index/ID of a Tile.
@ FT_SCENARIO
old or new scenario
int result
Result code to return to window on selection.
@ TO_HOUSES
town buildings
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
void ShowGoalsList(CompanyID company)
Open a goal list window.
DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option)
Create a drop down list for all the rail types of the local company.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
List of hotkeys for a window.
bool newgrf_developer_tools
activate NewGRF developer tools and allow modifying NewGRFs in an existing game
void ShiftDates(int interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
Dimensions (a width and height) of a rectangle in 2D.
@ ZOOM_OUT
Zoom out (get helicopter view).
int PositionMainToolbar(Window *w)
(Re)position main toolbar window at the screen.
bool NetworkMaxSpectatorsReached()
Check if max_spectatos has been reached on the server (local check only).
Window * ShowBuildAirToolbar()
Open the build airport toolbar window.
static const uint8 PC_DARK_RED
Dark red palette colour.
void ShowStoryBook(CompanyID company, uint16 page_id=INVALID_STORY_PAGE)
Raise or create the story book window for company, at page page_id.
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
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...
ViewportData * viewport
Pointer to viewport data, if present.
bool _network_server
network-server is active
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
void OnRealtimeTick(uint delta_ms) override
Called periodically.
@ ZOOM_NONE
Hack, used to update the button status.
void SetDate(Date date, DateFract fract)
Set the date.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
@ WC_SIGN_LIST
Sign list; Window numbers:
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
Handle the tid-bits of moving a client from one company to another.
@ WDF_NO_FOCUS
This window won't get focus/make any other window lose focus when click.
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
@ SND_15_BEEP
19 == 0x13 GUI button click
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
void ShowMessageHistory()
Display window with news messages history.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
bool DoZoomInOutWindow(ZoomStateChange how, Window *w)
Zooms a viewport in a window in or out.
void ShowGameOptions()
Open the game options window.
void ShowLandInfo(TileIndex tile)
Show land information window.
Base list item class from which others are derived.
void ShowGameSettings()
Open advanced settings window.
ClientSettings _settings_client
The current settings for this game.
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.
@ SC_ZOOMEDIN
Fully zoomed in screenshot of the visible area.
Window * ShowBuildRailToolbar(RailType railtype)
Open the build rail toolbar window for a specific rail type.
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
byte _display_opt
What do we want to draw/do?
@ VEH_ROAD
Road vehicle type.
@ SA_HOR_CENTER
Horizontally center the text.
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
@ ROADTYPE_ROAD
Basic road type.
Owner
Enum for all companies/owners.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
void ShowExtraViewportWindowForTileUnderCursor()
Show a new Extra Viewport window.
@ WD_IMGBTN_BOTTOM
Bottom offset of image in the button.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Drop down list entry for showing a company entry, with companies 'blob'.
GameCreationSettings game_creation
settings used during the creation of a game (map)
void OnTimeout() override
Called when this window's timeout has been reached.
@ PM_UNPAUSED
A normal unpaused game.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
High level window description.
@ COMPANY_FIRST
First company, same as owner.
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
@ DO_FULL_ANIMATION
Perform palette animation.
void ShowCompanyFinances(CompanyID company)
Open the finances window of a company.
@ ZOOM_IN
Zoom in (get more detailed view).
RoadTypes _roadtypes_type
Bitmap of road/tram types.
@ SLO_LOAD
File is being loaded.
Window * ShowSignList()
Open the sign list window.
RailType
Enumeration for all possible railtypes.
ResizeInfo resize
Resize information.
Date _date
Current date in days (day counter)
@ SLO_SAVE
File is being saved.
SoundSettings sound
sound effect settings
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
@ CMD_PAUSE
pause the game
bool NetworkMaxCompaniesReached()
Check if max_companies has been reached on the server (local check only).
static const Year MIN_YEAR
The absolute minimum & maximum years in OTTD.
int height
Height of the window (number of pixels down in y direction)
@ WF_WHITE_BORDER
Window white border counter bit mask.
void ShowCompanyStations(CompanyID company)
Opens window with list of company's stations.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
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.
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
@ ES_NOT_HANDLED
The passed event is not handled.
void ShowFramerateWindow()
Open the general framerate window.
int32 Date
The type to store our dates in.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
PauseMode _pause_mode
The current pause mode.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
@ CCA_NEW
Create a new company.
EconomySettings economy
settings to change the economy
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
@ MAX_COMPANIES
Maximum number of companies.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
@ DO_SHOW_STATION_NAMES
Display station names.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
WindowFlags flags
Window flags.
@ WF_TIMEOUT
Window timeout counter.
@ CLIENT_ID_SERVER
Servers always have this ID.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
@ TC_NO_SHADE
Do not add shading to this text colour.
bool _networking
are we in networking mode?
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
void FindWindowPlacementAndResize(int def_width, int def_height) override
Resize window towards the default size.
Coordinates of a point in 2D.
TownFounding found_town
town founding.
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
void ShowCheatWindow()
Open cheat window.
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
@ FT_SAVEGAME
old or new savegame
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
@ DO_FULL_DETAIL
Also draw details of track and roads.
RoadType
The different roadtypes we support.
VehicleType
Available vehicle types.
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.
bool NetworkCompanyIsPassworded(CompanyID company_id)
Check if the company we want to join requires a password.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
ClientID _network_own_client_id
Our client identifier.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
void ShowHighscoreTable(int difficulty=SP_CUSTOM, int8 rank=-1)
Show the highscore table for a given difficulty.
Container for the 'normal' main toolbar.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
bool confirm
Play sound effect on successful constructions or other actions.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
void OnPaint() override
The window must be repainted.
@ SC_WORLD
World screenshot.
Window * ShowBuildDocksScenToolbar()
Open the build water toolbar window for the scenario editor.
static const uint8 PC_VERY_DARK_RED
Almost-black red palette colour.
static size_t GetNumItems()
Returns number of valid items in the pool.
void DeleteAllMessages()
Delete all messages and their corresponding window (if any).
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.
void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets,...)
Sets the lowered/raised status of a list of widgets.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
void ShowTransparencyToolbar()
Show the transparency toolbar.
@ COMPANY_SPECTATOR
The client is spectating.
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...
void ShowLastNewsMessage()
Show previous news item.
@ PM_PAUSED_NORMAL
A game normally paused.
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
void ShowSmallMap()
Show the smallmap window.
Window * ShowAIDebugWindow(CompanyID show_company)
Open the AI debug window and select the given company.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
EventState
State of handling an event.
@ HT_RECT
rectangle (stations, depots, ...)
@ DO_SHOW_SIGNS
Display signs.
@ WD_IMGBTN_TOP
Top offset of image in the button.
void PlaceProc_Sign(TileIndex tile)
PlaceProc function, called when someone pressed the button if the sign-tool is selected.
@ FT_HEIGHTMAP
heightmap file
@ SC_DEFAULTZOOM
Zoomed to default zoom level screenshot of the visible area.
@ WC_MAIN_WINDOW
Main window; Window numbers:
Year starting_year
starting date
@ DO_SHOW_TOWN_NAMES
Display town names.
@ CMD_COMPANY_CTRL
used in multiplayer to create a new companies etc.
void ShowLinkGraphLegend()
Open a link graph legend window.
static const Year DEF_START_YEAR
The default starting year.
bool Elapsed(uint delta)
Test if a timer has elapsed.
GRFConfig * _grfconfig
First item in list of current GRF set up.
static const uint MILLISECONDS_PER_TICK
The number of milliseconds per game tick.
static T ToggleBit(T &x, const uint8 y)
Toggles a bit in a variable.
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
bool click_beep
Beep on a random selection of buttons.
#define lengthof(x)
Return the length of an fixed size array.
int width
width of the window (number of pixels to the right in x direction)
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
static void ToggleTransparency(TransparencyOption to)
Toggle the transparency option bit.
@ SC_VIEWPORT
Screenshot of viewport.
void MakeScreenshotWithConfirm(ScreenshotType t)
Make a screenshot.
void NetworkClientRequestMove(CompanyID company_id, const char *pass)
Notify the server of this client wanting to be moved to another company.
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
@ INVALID_COMPANY
An invalid company.
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.
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Data structure for an opened window.
RoadTypes GetRoadTypes(bool introduces)
Get list of road types, regardless of company availability.
@ VEH_TRAIN
Train vehicle type.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
void RaiseWidget(byte widget_index)
Marks a widget as raised.
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...
void DrawWidgets() const
Paint all widgets of a window.
void IConsoleSwitch()
Toggle in-game console between opened and closed.
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
void ShowAIConfigWindow()
Open the AI config window.
void ShowCompany(CompanyID company)
Show the window with the overview of the company.
bool UserIsAllowedToChangeNewGRFs() const
Returns true when the user has sufficient privileges to edit newgrfs on a running game.
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.
@ VEH_SHIP
Ship vehicle type.
@ ROADTYPES_NONE
No roadtypes.
Specification of a rectangle with absolute coordinates of all edges.
@ WC_MAIN_TOOLBAR
Main toolbar (the long bar at the top); Window numbers:
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
@ DO_SHOW_WAYPOINT_NAMES
Display waypoint names.
#define CLRBITS(x, y)
Clears several bits in a variable.
bool masked
Masked and unselectable item.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
bool _left_button_clicked
Is left mouse button clicked?
@ TD_RTL
Text is written right-to-left by default.
TextDirection _current_text_dir
Text direction of the currently selected language.
@ CS_NUMERAL
Only numeric ones.
uint16 _game_speed
Current game-speed; 100 is 1x, 0 is infinite.
List item with icon and string.
GUISettings gui
settings related to the GUI
Drop down list entry for showing a checked/unchecked toggle item.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
All data for a single hotkey.
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Window * ShowBuildDocksToolbar()
Open the build water toolbar window.
virtual void FindWindowPlacementAndResize(int def_width, int def_height)
Resize window towards the default size.
Window * ShowBuildRoadScenToolbar(RoadType roadtype)
Show the road building toolbar in the scenario editor.
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,...