|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
36 #include "script/script_gui.h"
101 this->SetString(
GetString(STR_COMPANY_NAME_COMPANY_NUM));
129 if (
string == STR_NULL) {
130 list.push_back(std::make_unique<DropDownListDividerItem>(-1,
false));
132 list.push_back(std::make_unique<DropDownListStringItem>(
string, i,
false));
159 list.push_back(std::make_unique<DropDownListStringItem>(STR_NETWORK_COMPANY_LIST_CLIENT_LIST,
CTMN_CLIENT_LIST,
false));
162 list.push_back(std::make_unique<DropDownListStringItem>(STR_NETWORK_COMPANY_LIST_SPECTATE,
CTMN_SPECTATE,
false));
166 list.push_back(std::make_unique<DropDownListStringItem>(STR_STORY_BOOK_SPECTATOR,
CTMN_SPECTATOR,
false));
170 list.push_back(std::make_unique<DropDownListStringItem>(STR_GOALS_SPECTATOR,
CTMN_SPECTATOR,
false));
176 list.push_back(std::make_unique<DropDownListCompanyItem>(c,
HasBit(grey, c)));
191 return CBF_PLACE_SIGN;
229 OME_GAMESCRIPT_SETTINGS,
234 OME_SHOW_STATIONNAMES,
235 OME_SHOW_WAYPOINTNAMES,
237 OME_SHOW_COMPETITOR_SIGNS,
240 OME_TRANSPARENTBUILDINGS,
241 OME_SHOW_STATIONSIGNS,
253 list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_GAME_OPTIONS, OME_GAMEOPTIONS,
false));
254 list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE, OME_SETTINGS,
false));
259 list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_AI_SETTINGS, OME_AI_SETTINGS,
false));
260 list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_GAMESCRIPT_SETTINGS, OME_GAMESCRIPT_SETTINGS,
false));
262 list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_NEWGRF_SETTINGS, OME_NEWGRFSETTINGS,
false));
263 if (_game_mode != GM_EDITOR) {
264 list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_SANDBOX_OPTIONS, ONE_SANDBOX,
false));
266 list.push_back(std::make_unique<DropDownListStringItem>(STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS, OME_TRANSPARENCIES,
false));
267 list.push_back(std::make_unique<DropDownListDividerItem>(-1,
false));
271 list.push_back(std::make_unique<DropDownListCheckedItem>(
HasBit(
_display_opt,
DO_SHOW_SIGNS), STR_SETTINGS_MENU_SIGNS_DISPLAYED, OME_SHOW_SIGNS,
false));
275 list.push_back(std::make_unique<DropDownListCheckedItem>(
IsTransparencySet(
TO_HOUSES), STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS,
false));
276 list.push_back(std::make_unique<DropDownListCheckedItem>(
IsTransparencySet(
TO_SIGNS), STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS,
false));
304 case OME_SHOW_COMPETITOR_SIGNS:
321 SLEME_SAVE_SCENARIO = 0,
323 SLEME_SAVE_HEIGHTMAP,
324 SLEME_LOAD_HEIGHTMAP,
348 STR_NULL, STR_FILE_MENU_EXIT});
361 STR_SCENEDIT_FILE_MENU_SAVE_HEIGHTMAP, STR_SCENEDIT_FILE_MENU_LOAD_HEIGHTMAP,
362 STR_SCENEDIT_FILE_MENU_QUIT_EDITOR, STR_NULL, STR_SCENEDIT_FILE_MENU_QUIT});
374 if (_game_mode == GM_EDITOR) {
380 case SLEME_EXIT_TOINTRO: AskExitToGameMenu();
break;
381 case SLEME_EXIT_GAME: HandleExitGameRequest();
break;
387 case SLNME_EXIT_TOINTRO: AskExitToGameMenu();
break;
388 case SLNME_EXIT_GAME: HandleExitGameRequest();
break;
396 enum MapMenuEntries {
397 MME_SHOW_SMALLMAP = 0,
398 MME_SHOW_EXTRAVIEWPORTS,
401 MME_SHOW_TOWNDIRECTORY,
402 MME_SHOW_INDUSTRYDIRECTORY,
408 list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP,
false));
409 list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_EXTRA_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS,
false));
410 list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_LINGRAPH_LEGEND, MME_SHOW_LINKGRAPH,
false));
411 list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS,
false));
419 list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP,
false));
420 list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_EXTRA_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS,
false));
421 list.push_back(std::make_unique<DropDownListStringItem>(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS,
false));
422 list.push_back(std::make_unique<DropDownListStringItem>(STR_TOWN_MENU_TOWN_DIRECTORY, MME_SHOW_TOWNDIRECTORY,
false));
423 list.push_back(std::make_unique<DropDownListStringItem>(STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, MME_SHOW_INDUSTRYDIRECTORY,
false));
441 case MME_SHOW_TOWNDIRECTORY: ShowTownDirectory();
break;
442 case MME_SHOW_INDUSTRYDIRECTORY: ShowIndustryDirectory();
break;
468 case 0: ShowTownDirectory();
break;
627 static void AddDropDownLeagueTableOptions(
DropDownList &list)
631 list.push_back(std::make_unique<DropDownListStringItem>(lt->title, lt->index,
false));
634 list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_COMPANY_LEAGUE_TABLE,
LTMN_PERFORMANCE_LEAGUE,
false));
635 list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_DETAILED_PERFORMANCE_RATING,
LTMN_PERFORMANCE_RATING,
false));
637 list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_HIGHSCORE,
LTMN_HIGHSCORE,
false));
646 list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_OPERATING_PROFIT_GRAPH,
GRMN_OPERATING_PROFIT_GRAPH,
false));
647 list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_INCOME_GRAPH,
GRMN_INCOME_GRAPH,
false));
648 list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_DELIVERED_CARGO_GRAPH,
GRMN_DELIVERED_CARGO_GRAPH,
false));
650 list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_COMPANY_VALUE_GRAPH,
GRMN_COMPANY_VALUE_GRAPH,
false));
651 list.push_back(std::make_unique<DropDownListStringItem>(STR_GRAPH_MENU_CARGO_PAYMENT_RATES,
GRMN_CARGO_PAYMENT_RATES,
false));
653 if (_toolbar_mode != TB_NORMAL) AddDropDownLeagueTableOptions(list);
665 AddDropDownLeagueTableOptions(list);
667 int selected = list[0]->result;
725 case 0: ShowIndustryDirectory();
break;
727 case 2: ShowBuildIndustryWindow();
break;
739 if (c->group_all[veh].num_vehicle == 0)
SetBit(dis, c->index);
862 _last_built_railtype = (
RailType)index;
884 _last_built_roadtype = (
RoadType)index;
906 _last_built_tramtype = (
RoadType)index;
916 list.push_back(std::make_unique<DropDownListIconItem>(SPR_IMG_BUILD_CANAL, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 0,
false));
938 list.push_back(std::make_unique<DropDownListIconItem>(SPR_IMG_AIRPORT, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 0,
false));
960 list.push_back(std::make_unique<DropDownListIconItem>(SPR_IMG_LANDSCAPING, PAL_NONE, STR_LANDSCAPING_MENU_LANDSCAPING, 0,
false));
961 list.push_back(std::make_unique<DropDownListIconItem>(SPR_IMG_PLANTTREES, PAL_NONE, STR_LANDSCAPING_MENU_PLANT_TREES, 1,
false));
962 list.push_back(std::make_unique<DropDownListIconItem>(SPR_IMG_SIGN, PAL_NONE, STR_LANDSCAPING_MENU_PLACE_SIGN, 2,
false));
978 case 1: ShowBuildTreesToolbar();
break;
979 case 2:
return SelectSignTool();
1036 return CBF_PLACE_LANDINFO;
1044 STR_ABOUT_MENU_HELP, STR_NULL, STR_ABOUT_MENU_TOGGLE_CONSOLE, STR_ABOUT_MENU_AI_DEBUG,
1045 STR_ABOUT_MENU_SCREENSHOT, STR_ABOUT_MENU_SHOW_FRAMERATE, STR_ABOUT_MENU_ABOUT_OPENTTD,
1046 STR_ABOUT_MENU_SPRITE_ALIGNER, STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES, STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS,
1047 STR_ABOUT_MENU_TOGGLE_WIDGET_OUTLINES});
1050 STR_ABOUT_MENU_HELP, STR_NULL, STR_ABOUT_MENU_TOGGLE_CONSOLE, STR_ABOUT_MENU_AI_DEBUG,
1051 STR_ABOUT_MENU_SCREENSHOT, STR_ABOUT_MENU_SHOW_FRAMERATE, STR_ABOUT_MENU_ABOUT_OPENTTD});
1065 extern bool _draw_bounding_boxes;
1068 _draw_bounding_boxes = !_draw_bounding_boxes;
1082 extern bool _draw_dirty_blocks;
1085 _draw_dirty_blocks = !_draw_dirty_blocks;
1096 extern bool _draw_widget_outlines;
1099 _draw_widget_outlines = !_draw_widget_outlines;
1112 TimerGameEconomy::Date new_economy_date = new_calendar_date.base();
1133 case 0:
return PlaceLandBlockInfo();
1134 case 1: ShowHelpWindow();
break;
1137 case 4: ShowScreenshotWindow();
break;
1139 case 6: ShowAboutWindow();
break;
1152 if (_toolbar_mode != TB_LOWER) {
1153 _toolbar_mode = TB_LOWER;
1155 _toolbar_mode = TB_UPPER;
1216 ShowFoundTownWindow();
1224 ShowBuildIndustryWindow();
1243 _last_built_roadtype = (
RoadType)index;
1263 _last_built_tramtype = (
RoadType)index;
1280 ShowBuildTreesToolbar();
1288 return SelectSignTool();
1298 static MenuClickedProc *
const _menu_clicked_procs[] = {
1363 for (
const auto &child_wid : this->
children) {
1364 child_wid->SetupSmallestSize(w);
1365 this->
smallest_y = std::max(this->
smallest_y, child_wid->smallest_y + child_wid->padding.Vertical());
1366 if (this->
IsButton(child_wid->type)) {
1368 this->
smallest_x = std::max(this->
smallest_x, child_wid->smallest_x + child_wid->padding.Horizontal());
1375 for (
const auto &child_wid : this->children) {
1377 if (!this->
IsButton(child_wid->type)) {
1378 child_wid->current_x = child_wid->smallest_x;
1394 uint arrangable_count, button_count, spacer_count;
1398 std::map<WidgetID, uint> lookup;
1399 for (
auto it = std::begin(this->
children); it != std::end(this->
children); ++it) {
1403 lookup[
dynamic_cast<NWidgetCore *
>(nwid)->index] = std::distance(this->
children.begin(), it);
1408 uint spacer_space = std::max(0, (
int)given_width - (
int)(button_count * this->
smallest_x));
1409 uint button_space = given_width - spacer_space;
1414 const WidgetID *slotp = rtl ? &arrangement[arrangable_count - 1] : arrangement;
1415 for (uint i = 0; i < arrangable_count; i++) {
1416 uint slot = lookup[*slotp];
1417 auto &child_wid = this->
children[slot];
1419 if (spacer_space > 0 && slot > 0 && slot < this->
children.size() - 1) {
1420 const auto &possible_spacer = this->
children[slot + (rtl ? 1 : -1)];
1421 if (possible_spacer !=
nullptr && possible_spacer->type ==
NWID_SPACER) {
1422 uint add = spacer_space / (spacer_count - spacer_i);
1424 spacer_space -= add;
1430 if (this->
IsButton(child_wid->type)) {
1431 child_wid->current_x = button_space / (button_count - button_i);
1432 button_space -= child_wid->current_x;
1435 child_wid->current_x = child_wid->smallest_x;
1437 child_wid->AssignSizePosition(sizing, x + position, y, child_wid->current_x, this->current_y, rtl);
1438 position += child_wid->current_x;
1451 const Rect r = this->GetCurrentRect();
1473 static const uint SMALLEST_ARRANGEMENT = 14;
1474 static const uint BIGGEST_ARRANGEMENT = 20;
1482 static const WidgetID arrange14[] = {
1513 static const WidgetID arrange15[] = {
1546 static const WidgetID arrange16[] = {
1581 static const WidgetID arrange17[] = {
1618 static const WidgetID arrange18[] = {
1657 static const WidgetID arrange19[] = {
1698 static const WidgetID arrange20[] = {
1741 static const WidgetID arrange_all[] = {
1775 uint full_buttons = std::max(
CeilDiv(width, this->
smallest_x), SMALLEST_ARRANGEMENT);
1776 if (full_buttons > BIGGEST_ARRANGEMENT) {
1777 button_count = arrangable_count =
lengthof(arrange_all);
1783 static const WidgetID *
const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20 };
1785 button_count = arrangable_count = full_buttons;
1787 return arrangements[full_buttons - SMALLEST_ARRANGEMENT] + ((_toolbar_mode == TB_LOWER) ? full_buttons : 0);
1801 for (
const auto &child_wid : this->
children) {
1802 if (child_wid->type ==
NWID_SPACER || this->IsButton(child_wid->type))
continue;
1804 assert(i <
lengthof(this->panel_widths));
1805 this->panel_widths[i++] = child_wid->current_x;
1812 static const WidgetID arrange_all[] = {
1833 static const WidgetID arrange_nopanel[] = {
1853 static const WidgetID arrange_switch[] = {
1880 uint min_full_width = (
lengthof(arrange_all) -
lengthof(this->panel_widths)) * this->
smallest_x + this->panel_widths[0] + this->panel_widths[1];
1881 if (width >= min_full_width) {
1882 width -= this->panel_widths[0] + this->panel_widths[1];
1883 arrangable_count =
lengthof(arrange_all);
1884 button_count = arrangable_count - 2;
1890 uint min_small_width = (
lengthof(arrange_switch) -
lengthof(this->panel_widths)) * this->
smallest_x / 2 + this->panel_widths[1];
1891 if (width > min_small_width) {
1892 width -= this->panel_widths[1];
1893 arrangable_count =
lengthof(arrange_nopanel);
1894 button_count = arrangable_count - 1;
1895 spacer_count = this->
spacers - 1;
1896 return arrange_nopanel;
1900 width -= this->panel_widths[1];
1901 arrangable_count =
lengthof(arrange_switch) / 2;
1902 button_count = arrangable_count - 1;
1904 return arrange_switch + ((_toolbar_mode == TB_LOWER) ? arrangable_count : 0);
1912 static ToolbarButtonProc *
const _toolbar_button_procs[] = {
1919 ToolbarSubsidiesClick,
1920 ToolbarStationsClick,
1921 ToolbarFinancesClick,
1922 ToolbarCompaniesClick,
1927 ToolbarIndustryClick,
1933 ToolbarZoomOutClick,
1934 ToolbarBuildRailClick,
1935 ToolbarBuildRoadClick,
1936 ToolbarBuildTramClick,
1937 ToolbarBuildWaterClick,
1938 ToolbarBuildAirClick,
1941 ToolbarNewspaperClick,
1960 void FindWindowPlacementAndResize([[maybe_unused]]
int def_width, [[maybe_unused]]
int def_height)
override
1980 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1982 if (_game_mode != GM_MENU && !this->
IsWidgetDisabled(widget)) _toolbar_button_procs[widget](
this);
1985 void OnDropdownSelect(
WidgetID widget,
int index)
override
1995 case MTHK_PAUSE: ToolbarPauseClick(
this);
break;
2001 case MTHK_TOWNDIRECTORY: ShowTownDirectory();
break;
2002 case MTHK_SUBSIDIES: ShowSubsidiesList();
break;
2008 case MTHK_GRAPHS: ShowOperatingProfitGraph();
break;
2009 case MTHK_LEAGUE: ShowFirstLeagueTable();
break;
2010 case MTHK_INDUSTRIES: ShowBuildIndustryWindow();
break;
2015 case MTHK_ZOOM_IN: ToolbarZoomInClick(
this);
break;
2016 case MTHK_ZOOM_OUT: ToolbarZoomOutClick(
this);
break;
2022 case MTHK_BUILD_TREES: ShowBuildTreesToolbar();
break;
2023 case MTHK_MUSIC: ShowMusicWindow();
break;
2032 case MTHK_CLIENT_LIST:
if (
_networking) ShowClientList();
break;
2034 case MTHK_LANDINFO: cbf = PlaceLandBlockInfo();
break;
2041 void OnPlaceObject([[maybe_unused]]
Point pt,
TileIndex tile)
override
2044 case CBF_PLACE_SIGN:
2048 case CBF_PLACE_LANDINFO:
2052 default: NOT_REACHED();
2088 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
2090 if (!gui_scope)
return;
2094 static inline HotkeyList hotkeys{
"maintoolbar", {
2095 Hotkey({WKC_F1, WKC_PAUSE},
"pause", MTHK_PAUSE),
2096 Hotkey(0,
"fastforward", MTHK_FASTFORWARD),
2097 Hotkey(WKC_F2,
"settings", MTHK_SETTINGS),
2098 Hotkey(WKC_F3,
"saveload", MTHK_SAVEGAME),
2099 Hotkey(0,
"load_game", MTHK_LOADGAME),
2100 Hotkey({WKC_F4,
'M'},
"smallmap", MTHK_SMALLMAP),
2101 Hotkey(WKC_F5,
"town_list", MTHK_TOWNDIRECTORY),
2102 Hotkey(WKC_F6,
"subsidies", MTHK_SUBSIDIES),
2103 Hotkey(WKC_F7,
"station_list", MTHK_STATIONS),
2104 Hotkey(WKC_F8,
"finances", MTHK_FINANCES),
2105 Hotkey(WKC_F9,
"companies", MTHK_COMPANIES),
2106 Hotkey(0,
"story_book", MTHK_STORY),
2107 Hotkey(0,
"goal_list", MTHK_GOAL),
2108 Hotkey(WKC_F10,
"graphs", MTHK_GRAPHS),
2109 Hotkey(WKC_F11,
"league", MTHK_LEAGUE),
2110 Hotkey(WKC_F12,
"industry_list", MTHK_INDUSTRIES),
2111 Hotkey(WKC_SHIFT | WKC_F1,
"train_list", MTHK_TRAIN_LIST),
2112 Hotkey(WKC_SHIFT | WKC_F2,
"roadveh_list", MTHK_ROADVEH_LIST),
2113 Hotkey(WKC_SHIFT | WKC_F3,
"ship_list", MTHK_SHIP_LIST),
2114 Hotkey(WKC_SHIFT | WKC_F4,
"aircraft_list", MTHK_AIRCRAFT_LIST),
2117 Hotkey(WKC_SHIFT | WKC_F7,
"build_rail", MTHK_BUILD_RAIL),
2118 Hotkey(WKC_SHIFT | WKC_F8,
"build_road", MTHK_BUILD_ROAD),
2119 Hotkey(0,
"build_tram", MTHK_BUILD_TRAM),
2120 Hotkey(WKC_SHIFT | WKC_F9,
"build_docks", MTHK_BUILD_DOCKS),
2121 Hotkey(WKC_SHIFT | WKC_F10,
"build_airport", MTHK_BUILD_AIRPORT),
2122 Hotkey(WKC_SHIFT | WKC_F11,
"build_trees", MTHK_BUILD_TREES),
2123 Hotkey(WKC_SHIFT | WKC_F12,
"music", MTHK_MUSIC),
2124 Hotkey(0,
"ai_debug", MTHK_SCRIPT_DEBUG),
2125 Hotkey(WKC_CTRL |
'S',
"small_screenshot", MTHK_SMALL_SCREENSHOT),
2126 Hotkey(WKC_CTRL |
'P',
"zoomedin_screenshot", MTHK_ZOOMEDIN_SCREENSHOT),
2127 Hotkey(WKC_CTRL |
'D',
"defaultzoom_screenshot", MTHK_DEFAULTZOOM_SCREENSHOT),
2128 Hotkey(0,
"giant_screenshot", MTHK_GIANT_SCREENSHOT),
2129 Hotkey(WKC_CTRL | WKC_ALT |
'C',
"cheats", MTHK_CHEATS),
2130 Hotkey(
'L',
"terraform", MTHK_TERRAFORM),
2131 Hotkey(
'V',
"extra_viewport", MTHK_EXTRA_VIEWPORT),
2132 Hotkey(0,
"client_list", MTHK_CLIENT_LIST),
2133 Hotkey(0,
"sign_list", MTHK_SIGN_LIST),
2134 Hotkey(0,
"land_info", MTHK_LANDINFO),
2141 static const SpriteID toolbar_button_sprites[] = {
2143 SPR_IMG_FASTFORWARD,
2149 SPR_IMG_COMPANY_LIST,
2150 SPR_IMG_COMPANY_FINANCE,
2151 SPR_IMG_COMPANY_GENERAL,
2155 SPR_IMG_COMPANY_LEAGUE,
2160 SPR_IMG_AIRPLANESLIST,
2168 SPR_IMG_LANDSCAPING,
2172 SPR_IMG_SWITCH_TOOLBAR,
2175 auto hor = std::make_unique<NWidgetMainToolbarContainer>();
2184 hor->Add(std::make_unique<NWidgetSpacer>(0, 0));
2187 auto leaf = std::make_unique<NWidgetLeaf>(i ==
WID_TN_SAVE ?
WWT_IMGBTN_2 :
WWT_IMGBTN, COLOUR_GREY, i, toolbar_button_sprites[i], STR_TOOLBAR_TOOLTIP_PAUSE_GAME + i);
2188 leaf->SetMinimalSize(20, 20);
2189 hor->Add(std::move(leaf));
2195 static constexpr
NWidgetPart _nested_toolbar_normal_widgets[] = {
2199 static WindowDesc _toolb_normal_desc(__FILE__, __LINE__,
2203 std::begin(_nested_toolbar_normal_widgets), std::end(_nested_toolbar_normal_widgets),
2204 &MainToolbarWindow::hotkeys
2210 static MenuClickedProc *
const _scen_toolbar_dropdown_procs[] = {
2236 static ToolbarButtonProc *
const _scen_toolbar_button_procs[] = {
2243 ToolbarScenDateBackward,
2244 ToolbarScenDateForward,
2245 ToolbarScenMapTownDir,
2247 ToolbarZoomOutClick,
2250 ToolbarScenGenIndustry,
2251 ToolbarScenBuildRoadClick,
2252 ToolbarScenBuildTramClick,
2253 ToolbarScenBuildDocks,
2254 ToolbarScenPlantTrees,
2255 ToolbarScenPlaceSign,
2262 enum MainToolbarEditorHotkeys {
2277 MTEHK_SMALL_SCREENSHOT,
2278 MTEHK_ZOOMEDIN_SCREENSHOT,
2279 MTEHK_DEFAULTZOOM_SCREENSHOT,
2280 MTEHK_GIANT_SCREENSHOT,
2285 MTEHK_EXTRA_VIEWPORT,
2299 void FindWindowPlacementAndResize([[maybe_unused]]
int def_width, [[maybe_unused]]
int def_height)
override
2314 void SetStringParameters(
WidgetID widget)
const override
2323 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
2353 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
2355 if (_game_mode == GM_MENU)
return;
2360 void OnDropdownSelect(
WidgetID widget,
int index)
override
2371 case MTEHK_PAUSE: ToolbarPauseClick(
this);
break;
2375 case MTEHK_GENLAND: ToolbarScenGenLand(
this);
break;
2376 case MTEHK_GENTOWN: ToolbarScenGenTown(
this);
break;
2377 case MTEHK_GENINDUSTRY: ToolbarScenGenIndustry(
this);
break;
2378 case MTEHK_BUILD_ROAD: ToolbarScenBuildRoadClick(
this);
break;
2379 case MTEHK_BUILD_TRAM: ToolbarScenBuildTramClick(
this);
break;
2380 case MTEHK_BUILD_DOCKS: ToolbarScenBuildDocks(
this);
break;
2381 case MTEHK_BUILD_TREES: ToolbarScenPlantTrees(
this);
break;
2382 case MTEHK_SIGN: cbf = ToolbarScenPlaceSign(
this);
break;
2383 case MTEHK_MUSIC: ShowMusicWindow();
break;
2384 case MTEHK_LANDINFO: cbf = PlaceLandBlockInfo();
break;
2389 case MTEHK_ZOOM_IN: ToolbarZoomInClick(
this);
break;
2390 case MTEHK_ZOOM_OUT: ToolbarZoomOutClick(
this);
break;
2400 void OnPlaceObject([[maybe_unused]]
Point pt,
TileIndex tile)
override
2403 case CBF_PLACE_SIGN:
2407 case CBF_PLACE_LANDINFO:
2411 default: NOT_REACHED();
2445 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
2447 if (!gui_scope)
return;
2451 void OnQueryTextFinished(
char *str)
override
2454 if (str ==
nullptr)
return;
2468 static inline HotkeyList hotkeys{
"scenedit_maintoolbar", {
2469 Hotkey({WKC_F1, WKC_PAUSE},
"pause", MTEHK_PAUSE),
2470 Hotkey(0,
"fastforward", MTEHK_FASTFORWARD),
2471 Hotkey(WKC_F2,
"settings", MTEHK_SETTINGS),
2472 Hotkey(WKC_F3,
"saveload", MTEHK_SAVEGAME),
2473 Hotkey(WKC_F4,
"gen_land", MTEHK_GENLAND),
2474 Hotkey(WKC_F5,
"gen_town", MTEHK_GENTOWN),
2475 Hotkey(WKC_F6,
"gen_industry", MTEHK_GENINDUSTRY),
2476 Hotkey(WKC_F7,
"build_road", MTEHK_BUILD_ROAD),
2477 Hotkey(0,
"build_tram", MTEHK_BUILD_TRAM),
2478 Hotkey(WKC_F8,
"build_docks", MTEHK_BUILD_DOCKS),
2479 Hotkey(WKC_F9,
"build_trees", MTEHK_BUILD_TREES),
2480 Hotkey(WKC_F10,
"build_sign", MTEHK_SIGN),
2481 Hotkey(WKC_F11,
"music", MTEHK_MUSIC),
2482 Hotkey(WKC_F12,
"land_info", MTEHK_LANDINFO),
2483 Hotkey(WKC_CTRL |
'S',
"small_screenshot", MTEHK_SMALL_SCREENSHOT),
2484 Hotkey(WKC_CTRL |
'P',
"zoomedin_screenshot", MTEHK_ZOOMEDIN_SCREENSHOT),
2485 Hotkey(WKC_CTRL |
'D',
"defaultzoom_screenshot", MTEHK_DEFAULTZOOM_SCREENSHOT),
2486 Hotkey(0,
"giant_screenshot", MTEHK_GIANT_SCREENSHOT),
2489 Hotkey(
'L',
"terraform", MTEHK_TERRAFORM),
2490 Hotkey(
'M',
"smallmap", MTEHK_SMALLMAP),
2491 Hotkey(
'V',
"extra_viewport", MTEHK_EXTRA_VIEWPORT),
2495 static constexpr
NWidgetPart _nested_toolb_scen_inner_widgets[] = {
2530 static std::unique_ptr<NWidgetBase> MakeScenarioToolbar()
2532 return MakeNWidgets(std::begin(_nested_toolb_scen_inner_widgets), std::end(_nested_toolb_scen_inner_widgets), std::make_unique<NWidgetScenarioToolbarContainer>());
2535 static constexpr
NWidgetPart _nested_toolb_scen_widgets[] = {
2539 static WindowDesc _toolb_scen_desc(__FILE__, __LINE__,
2543 std::begin(_nested_toolb_scen_widgets), std::end(_nested_toolb_scen_widgets),
2544 &ScenarioEditorToolbarWindow::hotkeys
2554 if (_game_mode == GM_EDITOR) {
@ VEH_AIRCRAFT
Aircraft vehicle type.
Window * ShowScriptDebugWindow(CompanyID show_company, bool new_window)
Open the Script debug window and select the given company.
@ 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.
uint8_t timeout_timer
Timer value of the WF_TIMEOUT for flags.
void ShowSpriteAlignerWindow()
Show the window for aligning sprites.
void ShowIndustryCargoesWindow()
Open the industry and cargoes window with an industry.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
@ FT_SCENARIO
old or new scenario
int Height() const
Get height of Rect.
@ TO_HOUSES
town buildings
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
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.
Window * ShowBuildAirToolbar()
Open the build airport toolbar window.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
void NetworkClientRequestMove(CompanyID company_id, const std::string &pass)
Notify the server of this client wanting to be moved to another company.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
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.
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...
@ ZOOM_NONE
Hack, used to update the button status.
Struct about custom league tables.
@ WC_SIGN_LIST
Sign list; Window numbers:
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.
bool _ctrl_pressed
Is Ctrl pressed?
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
@ SND_15_BEEP
19 == 0x13 GUI button click
void ShowMessageHistory()
Display window with news messages history.
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.
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
void ShowGameSettings()
Open advanced settings window.
ClientSettings _settings_client
The current settings for this game.
@ 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.
Templated helper to make a type-safe 'typedef' representing a single POD value.
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.
Owner
Enum for all companies/owners.
bool StrEmpty(const char *s)
Check if a string buffer is empty.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
void ShowExtraViewportWindowForTileUnderCursor()
Show a new Extra Viewport window.
Company name list item, with company-colour icon, name, and lock components.
Drop down icon component.
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.
High level window description.
@ COMPANY_FIRST
First company, same as owner.
@ 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_NONE
No roadtypes.
static const uint8_t PC_VERY_DARK_RED
Almost-black red palette colour.
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.
void ShiftDates(TimerGameEconomy::Date interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
@ SLO_SAVE
File is being saved.
SoundSettings sound
sound effect settings
@ FS_NORMAL
Index of the normal font in the font tables.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
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)
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
@ ES_NOT_HANDLED
The passed event is not handled.
PauseMode _pause_mode
The current pause mode.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
EconomySettings economy
settings to change the economy
void ShowFramerateWindow()
Open the general framerate window.
@ 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.
TimerGameCalendar::Year starting_year
starting date
WindowFlags flags
Window flags.
@ WF_TIMEOUT
Window timeout counter.
bool _networking
are we in networking mode?
@ ROADTYPE_ROAD
Basic road type.
uint8_t LeagueTableID
ID of a league table.
static void SetDate(Date date, DateFract fract)
Set the date.
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.
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
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,...
@ WDF_NO_CLOSE
This window can't be interactively closed.
static constexpr TimerGame< struct Calendar >::Year DEF_START_YEAR
The default starting year.
void ShowCheatWindow()
Open cheat window.
uint16_t _game_speed
Current game-speed; 100 is 1x, 0 is infinite.
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
@ FT_SAVEGAME
old or new savegame
@ DO_FULL_DETAIL
Also draw details of track and roads.
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.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
void ShowGSConfigWindow()
Open the GS config window.
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.
@ SA_HOR_CENTER
Horizontally center the text.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
void ShowHighscoreTable(int difficulty=SP_CUSTOM, int8_t rank=-1)
Show the highscore table for a given difficulty.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Container for the 'normal' main toolbar.
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
bool confirm
Play sound effect on successful constructions or other actions.
static const uint8_t PC_DARK_RED
Dark red palette colour.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close)
Show a drop down list.
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 size_t GetNumItems()
Returns number of valid items in the pool.
void DeleteAllMessages()
Delete all messages and close their corresponding window (if any).
void ShowTransparencyToolbar()
Show the transparency toolbar.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
@ COMPANY_SPECTATOR
The client is spectating.
Window * GetMainWindow()
Get the main window, i.e.
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 ShowSmallMap()
Show the smallmap window.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
EventState
State of handling an event.
@ HT_RECT
rectangle (stations, depots, ...)
@ DO_SHOW_SIGNS
Display signs.
static constexpr TimerGame< struct Calendar >::Year MIN_YEAR
The absolute minimum year in OTTD.
void PlaceProc_Sign(TileIndex tile)
PlaceProc function, called when someone pressed the button if the sign-tool is selected.
RoadType
The different roadtypes we support.
@ FT_HEIGHTMAP
heightmap file
@ SC_DEFAULTZOOM
Zoomed to default zoom level screenshot of the visible area.
void ShowStoryBook(CompanyID company, uint16_t page_id=INVALID_STORY_PAGE, bool centered=false)
Raise or create the story book window for company, at page page_id.
void ToggleTransparency(TransparencyOption to)
Toggle the transparency option bit.
@ DO_SHOW_TOWN_NAMES
Display town names.
IntervalTimer< TimerWindow > refresh_interval
Refresh the state of pause / game-speed on a regular interval.
void ShowLinkGraphLegend()
Open a link graph legend window.
void SetWidgetsLoweredState(bool lowered_stat, Args... widgets)
Sets the lowered/raised status of a list of widgets.
GRFConfig * _grfconfig
First item in list of current GRF set up.
static void SetDate(Date date, DateFract fract)
Set the date.
@ SA_CENTER
Center both horizontally and vertically.
bool click_beep
Beep on a random selection of buttons.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
#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)
@ SC_VIEWPORT
Screenshot of viewport.
void MakeScreenshotWithConfirm(ScreenshotType t)
Make a screenshot.
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
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.
@ INVALID_COMPANY
An invalid company.
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.
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.
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.
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.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
void IConsoleSwitch()
Toggle in-game console between opened and closed.
void RaiseWidgetWhenLowered(byte widget_index)
Marks a widget as raised and dirty (redraw), when it is marked as lowered.
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.
@ VEH_SHIP
Ship vehicle type.
Specification of a rectangle with absolute coordinates of all edges.
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
@ WC_MAIN_TOOLBAR
Main toolbar (the long bar at the top); Window numbers:
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
@ 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.
@ CLIENT_ID_SERVER
Servers always have this ID.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
bool _left_button_clicked
Is left mouse button clicked?
@ CS_NUMERAL
Only numeric ones.
constexpr T ToggleBit(T &x, const uint8_t y)
Toggles a bit in a variable.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
GUISettings gui
settings related to the GUI
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
All data for a single hotkey.
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 Date date
Current date in days (day counter).
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.