95 return DropDownListStringItem::Width() + this->checkmark_width;
98 void Draw(
int left,
int right,
int top,
int bottom,
bool sel,
int bg_colour)
const
123 bool Selectable()
const
136 uint Height(uint width)
const
141 void Draw(
int left,
int right,
int top,
int bottom,
bool sel,
int bg_colour)
const
149 int icon_offset = (bottom - top - icon_size.height) / 2;
160 col = sel ? TC_WHITE : TC_BLACK;
189 for (
int i = 0; i < count; i++) {
212 #ifdef ENABLE_NETWORK
219 if (include_spectator) {
246 if (_cursor.
sprite == SPR_CURSOR_SIGN) {
247 ResetObjectToPlace();
251 return CBF_PLACE_SIGN;
275 _fast_forward ^=
true;
290 OME_SHOW_STATIONNAMES,
291 OME_SHOW_WAYPOINTNAMES,
293 OME_SHOW_COMPETITOR_SIGNS,
296 OME_TRANSPARENTBUILDINGS,
297 OME_SHOW_STATIONSIGNS,
352 case OME_SHOW_COMPETITOR_SIGNS:
369 SLEME_SAVE_SCENARIO = 0,
371 SLEME_SAVE_HEIGHTMAP,
372 SLEME_LOAD_HEIGHTMAP,
421 if (_game_mode == GM_EDITOR) {
427 case SLEME_EXIT_TOINTRO: AskExitToGameMenu();
break;
428 case SLEME_EXIT_GAME: HandleExitGameRequest();
break;
434 case SLNME_EXIT_TOINTRO: AskExitToGameMenu();
break;
435 case SLNME_EXIT_GAME: HandleExitGameRequest();
break;
443 enum MapMenuEntries {
444 MME_SHOW_SMALLMAP = 0,
445 MME_SHOW_EXTRAVIEWPORTS,
448 MME_SHOW_TOWNDIRECTORY,
449 MME_SHOW_INDUSTRYDIRECTORY,
488 case MME_SHOW_TOWNDIRECTORY: ShowTownDirectory();
break;
489 case MME_SHOW_INDUSTRYDIRECTORY: ShowIndustryDirectory();
break;
511 case 0: ShowTownDirectory();
break;
536 case 0: ShowSubsidiesList();
break;
597 #ifdef ENABLE_NETWORK
684 case 0: ShowOperatingProfitGraph();
break;
685 case 1: ShowIncomeGraph();
break;
686 case 2: ShowDeliveredCargoGraph();
break;
687 case 3: ShowPerformanceHistoryGraph();
break;
688 case 4: ShowCompanyValueGraph();
break;
689 case 5: ShowCargoPaymentRates();
break;
691 case 6: ShowCompanyLeagueTable();
break;
692 case 7: ShowPerformanceRatingDetail();
break;
714 case 0: ShowCompanyLeagueTable();
break;
715 case 1: ShowPerformanceRatingDetail();
break;
739 case 0: ShowIndustryDirectory();
break;
741 case 2: ShowBuildIndustryWindow();
break;
877 _last_built_railtype = (
RailType)index;
894 FOR_ALL_ENGINES_OF_TYPE(e,
VEH_ROAD) {
914 _last_built_roadtype = (
RoadType)index;
977 case 1: ShowBuildTreesToolbar();
break;
978 case 2:
return SelectSignTool();
1030 if (_cursor.
sprite == SPR_CURSOR_QUERY) {
1031 ResetObjectToPlace();
1035 return CBF_PLACE_LANDINFO;
1045 static void MenuClickSmallScreenshot()
1069 if ((uint64)vp.
width * (uint64)vp.
height > 8192 * 8192) {
1090 extern bool _draw_bounding_boxes;
1093 _draw_bounding_boxes = !_draw_bounding_boxes;
1107 extern bool _draw_dirty_blocks;
1110 _draw_dirty_blocks = !_draw_dirty_blocks;
1136 case 0:
return PlaceLandBlockInfo();
1139 case 4: MenuClickSmallScreenshot();
break;
1143 case 8: ShowAboutWindow();
break;
1155 if (_toolbar_mode != TB_LOWER) {
1156 _toolbar_mode = TB_LOWER;
1158 _toolbar_mode = TB_UPPER;
1220 ShowFoundTownWindow();
1228 ShowBuildIndustryWindow();
1252 ShowBuildTreesToolbar();
1260 return SelectSignTool();
1270 static MenuClickedProc *
const _menu_clicked_procs[] = {
1335 for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
1336 child_wid->SetupSmallestSize(w, init_array);
1337 this->
smallest_y =
max(this->
smallest_y, child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom);
1338 if (this->
IsButton(child_wid->type)) {
1340 this->
smallest_x =
max(this->
smallest_x, child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right);
1347 for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
1349 if (!this->
IsButton(child_wid->type)) {
1350 child_wid->current_x = child_wid->smallest_x;
1367 uint arrangable_count, button_count, spacer_count;
1368 const byte *arrangement =
GetButtonArrangement(given_width, arrangable_count, button_count, spacer_count);
1369 for (uint i = 0; i < arrangable_count; i++) {
1370 this->
visible[arrangement[i]] =
true;
1375 for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
1377 widgets[((
NWidgetCore*)child_wid)->index] = child_wid;
1382 uint spacer_space =
max(0, (
int)given_width - (
int)(button_count * this->
smallest_x));
1383 uint button_space = given_width - spacer_space;
1388 const byte *cur_wid = rtl ? &arrangement[arrangable_count - 1] : arrangement;
1389 for (uint i = 0; i < arrangable_count; i++) {
1392 if (spacer_space != 0) {
1394 if (possible_spacer != NULL && possible_spacer->
type ==
NWID_SPACER) {
1395 uint add = spacer_space / (spacer_count - spacer_i);
1397 spacer_space -= add;
1404 child_wid->
current_x = button_space / (button_count - button_i);
1426 for (
NWidgetBase *child_wid = rtl ? this->
tail : this->
head; child_wid != NULL; child_wid = rtl ? child_wid->
prev : child_wid->
next) {
1438 for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
1443 if (nwid != NULL)
return nwid;
1456 virtual const byte *
GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count)
const = 0;
1461 const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count)
const
1463 static const uint SMALLEST_ARRANGEMENT = 14;
1464 static const uint BIGGEST_ARRANGEMENT = 20;
1465 static const byte arrange14[] = {
1466 0, 1, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 29,
1467 2, 3, 4, 5, 6, 7, 8, 9, 12, 14, 26, 27, 28, 29,
1469 static const byte arrange15[] = {
1470 0, 1, 4, 15, 16, 17, 18, 21, 22, 23, 24, 25, 19, 20, 29,
1471 0, 2, 4, 3, 5, 6, 7, 8, 9, 12, 14, 26, 27, 28, 29,
1473 static const byte arrange16[] = {
1474 0, 1, 2, 4, 15, 16, 17, 18, 21, 22, 23, 24, 25, 19, 20, 29,
1475 0, 1, 3, 5, 6, 7, 8, 9, 12, 14, 26, 27, 28, 19, 20, 29,
1477 static const byte arrange17[] = {
1478 0, 1, 2, 4, 6, 15, 16, 17, 18, 21, 22, 23, 24, 25, 19, 20, 29,
1479 0, 1, 3, 4, 6, 5, 7, 8, 9, 12, 14, 26, 27, 28, 19, 20, 29,
1481 static const byte arrange18[] = {
1482 0, 1, 2, 4, 5, 6, 7, 8, 9, 14, 21, 22, 23, 24, 25, 19, 20, 29,
1483 0, 1, 3, 4, 5, 6, 7, 12, 15, 16, 17, 18, 26, 27, 28, 19, 20, 29,
1485 static const byte arrange19[] = {
1486 0, 1, 2, 4, 5, 6, 15, 16, 17, 18, 21, 22, 23, 24, 25, 26, 19, 20, 29,
1487 0, 1, 3, 4, 7, 8, 9, 12, 14, 27, 21, 22, 23, 24, 25, 28, 19, 20, 29,
1489 static const byte arrange20[] = {
1490 0, 1, 2, 4, 5, 6, 15, 16, 17, 18, 21, 22, 23, 24, 25, 26, 11, 19, 20, 29,
1491 0, 1, 3, 4, 7, 8, 9, 12, 14, 27, 21, 22, 23, 24, 25, 10, 28, 19, 20, 29,
1493 static const byte arrange_all[] = {
1494 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28
1499 if (full_buttons > BIGGEST_ARRANGEMENT) {
1500 button_count = arrangable_count =
lengthof(arrange_all);
1506 static const byte *
const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20 };
1508 button_count = arrangable_count = full_buttons;
1510 return arrangements[full_buttons - SMALLEST_ARRANGEMENT] + ((_toolbar_mode == TB_LOWER) ? full_buttons : 0);
1518 void SetupSmallestSize(
Window *w,
bool init_array)
1524 for (
NWidgetBase *child_wid = this->
head; child_wid != NULL; child_wid = child_wid->
next) {
1525 if (child_wid->type ==
NWID_SPACER || this->IsButton(child_wid->type))
continue;
1533 const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count)
const
1535 static const byte arrange_all[] = {
1536 0, 1, 2, 3, 4, 18, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 26, 28,
1538 static const byte arrange_nopanel[] = {
1539 0, 1, 2, 3, 18, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 26, 28,
1541 static const byte arrange_switch[] = {
1542 18, 8, 11, 12, 13, 14, 15, 16, 17, 29,
1543 0, 1, 2, 3, 18, 9, 10, 26, 28, 29,
1548 if (width >= min_full_width) {
1550 arrangable_count =
lengthof(arrange_all);
1551 button_count = arrangable_count - 2;
1558 if (width > min_small_width) {
1560 arrangable_count =
lengthof(arrange_nopanel);
1561 button_count = arrangable_count - 1;
1562 spacer_count = this->
spacers - 1;
1563 return arrange_nopanel;
1568 arrangable_count =
lengthof(arrange_switch) / 2;
1569 button_count = arrangable_count - 1;
1571 return arrange_switch + ((_toolbar_mode == TB_LOWER) ? arrangable_count : 0);
1579 static ToolbarButtonProc *
const _toolbar_button_procs[] = {
1586 ToolbarSubsidiesClick,
1587 ToolbarStationsClick,
1588 ToolbarFinancesClick,
1589 ToolbarCompaniesClick,
1594 ToolbarIndustryClick,
1600 ToolbarZoomOutClick,
1601 ToolbarBuildRailClick,
1602 ToolbarBuildRoadClick,
1603 ToolbarBuildWaterClick,
1604 ToolbarBuildAirClick,
1607 ToolbarNewspaperClick,
1612 enum MainToolbarHotkeys {
1642 MTHK_SMALL_SCREENSHOT,
1643 MTHK_ZOOMEDIN_SCREENSHOT,
1644 MTHK_DEFAULTZOOM_SCREENSHOT,
1645 MTHK_GIANT_SCREENSHOT,
1648 MTHK_EXTRA_VIEWPORT,
1689 if (_game_mode != GM_MENU && !this->
IsWidgetDisabled(widget)) _toolbar_button_procs[widget](
this);
1701 case MTHK_PAUSE: ToolbarPauseClick(
this);
break;
1707 case MTHK_TOWNDIRECTORY: ShowTownDirectory();
break;
1708 case MTHK_SUBSIDIES: ShowSubsidiesList();
break;
1714 case MTHK_GRAPHS: ShowOperatingProfitGraph();
break;
1715 case MTHK_LEAGUE: ShowCompanyLeagueTable();
break;
1716 case MTHK_INDUSTRIES: ShowBuildIndustryWindow();
break;
1721 case MTHK_ZOOM_IN: ToolbarZoomInClick(
this);
break;
1722 case MTHK_ZOOM_OUT: ToolbarZoomOutClick(
this);
break;
1727 case MTHK_BUILD_TREES: ShowBuildTreesToolbar();
break;
1728 case MTHK_MUSIC: ShowMusicWindow();
break;
1730 case MTHK_SMALL_SCREENSHOT: MenuClickSmallScreenshot();
break;
1737 #ifdef ENABLE_NETWORK
1738 case MTHK_CLIENT_LIST:
if (
_networking) ShowClientList();
break;
1749 case CBF_PLACE_SIGN:
1753 case CBF_PLACE_LANDINFO:
1757 default: NOT_REACHED();
1793 if (!gui_scope)
return;
1800 const uint16 _maintoolbar_pause_keys[] = {WKC_F1, WKC_PAUSE, 0};
1801 const uint16 _maintoolbar_zoomin_keys[] = {WKC_NUM_PLUS,
WKC_EQUALS, WKC_SHIFT |
WKC_EQUALS, WKC_SHIFT | WKC_F5, 0};
1802 const uint16 _maintoolbar_zoomout_keys[] = {WKC_NUM_MINUS,
WKC_MINUS, WKC_SHIFT |
WKC_MINUS, WKC_SHIFT | WKC_F6, 0};
1803 const uint16 _maintoolbar_smallmap_keys[] = {WKC_F4,
'M', 0};
1805 static Hotkey maintoolbar_hotkeys[] = {
1806 Hotkey(_maintoolbar_pause_keys,
"pause", MTHK_PAUSE),
1807 Hotkey((uint16)0,
"fastforward", MTHK_FASTFORWARD),
1808 Hotkey(WKC_F2,
"settings", MTHK_SETTINGS),
1809 Hotkey(WKC_F3,
"saveload", MTHK_SAVEGAME),
1810 Hotkey((uint16)0,
"load_game", MTHK_LOADGAME),
1811 Hotkey(_maintoolbar_smallmap_keys,
"smallmap", MTHK_SMALLMAP),
1812 Hotkey(WKC_F5,
"town_list", MTHK_TOWNDIRECTORY),
1813 Hotkey(WKC_F6,
"subsidies", MTHK_SUBSIDIES),
1814 Hotkey(WKC_F7,
"station_list", MTHK_STATIONS),
1815 Hotkey(WKC_F8,
"finances", MTHK_FINANCES),
1816 Hotkey(WKC_F9,
"companies", MTHK_COMPANIES),
1817 Hotkey((uint16)0,
"story_book", MTHK_STORY),
1818 Hotkey((uint16)0,
"goal_list", MTHK_GOAL),
1819 Hotkey(WKC_F10,
"graphs", MTHK_GRAPHS),
1820 Hotkey(WKC_F11,
"league", MTHK_LEAGUE),
1821 Hotkey(WKC_F12,
"industry_list", MTHK_INDUSTRIES),
1822 Hotkey(WKC_SHIFT | WKC_F1,
"train_list", MTHK_TRAIN_LIST),
1823 Hotkey(WKC_SHIFT | WKC_F2,
"roadveh_list", MTHK_ROADVEH_LIST),
1824 Hotkey(WKC_SHIFT | WKC_F3,
"ship_list", MTHK_SHIP_LIST),
1825 Hotkey(WKC_SHIFT | WKC_F4,
"aircraft_list", MTHK_AIRCRAFT_LIST),
1826 Hotkey(_maintoolbar_zoomin_keys,
"zoomin", MTHK_ZOOM_IN),
1827 Hotkey(_maintoolbar_zoomout_keys,
"zoomout", MTHK_ZOOM_OUT),
1828 Hotkey(WKC_SHIFT | WKC_F7,
"build_rail", MTHK_BUILD_RAIL),
1829 Hotkey(WKC_SHIFT | WKC_F8,
"build_road", MTHK_BUILD_ROAD),
1830 Hotkey(WKC_SHIFT | WKC_F9,
"build_docks", MTHK_BUILD_DOCKS),
1831 Hotkey(WKC_SHIFT | WKC_F10,
"build_airport", MTHK_BUILD_AIRPORT),
1832 Hotkey(WKC_SHIFT | WKC_F11,
"build_trees", MTHK_BUILD_TREES),
1833 Hotkey(WKC_SHIFT | WKC_F12,
"music", MTHK_MUSIC),
1834 Hotkey((uint16)0,
"ai_debug", MTHK_AI_DEBUG),
1835 Hotkey(WKC_CTRL |
'S',
"small_screenshot", MTHK_SMALL_SCREENSHOT),
1836 Hotkey(WKC_CTRL |
'P',
"zoomedin_screenshot", MTHK_ZOOMEDIN_SCREENSHOT),
1837 Hotkey(WKC_CTRL |
'D',
"defaultzoom_screenshot", MTHK_DEFAULTZOOM_SCREENSHOT),
1838 Hotkey((uint16)0,
"giant_screenshot", MTHK_GIANT_SCREENSHOT),
1839 Hotkey(WKC_CTRL | WKC_ALT |
'C',
"cheats", MTHK_CHEATS),
1840 Hotkey(
'L',
"terraform", MTHK_TERRAFORM),
1841 Hotkey(
'V',
"extra_viewport", MTHK_EXTRA_VIEWPORT),
1842 #ifdef ENABLE_NETWORK
1843 Hotkey((uint16)0,
"client_list", MTHK_CLIENT_LIST),
1845 Hotkey((uint16)0,
"sign_list", MTHK_SIGN_LIST),
1848 HotkeyList MainToolbarWindow::hotkeys(
"maintoolbar", maintoolbar_hotkeys);
1853 static const SpriteID toolbar_button_sprites[] = {
1855 SPR_IMG_FASTFORWARD,
1861 SPR_IMG_COMPANY_LIST,
1862 SPR_IMG_COMPANY_FINANCE,
1863 SPR_IMG_COMPANY_GENERAL,
1867 SPR_IMG_COMPANY_LEAGUE,
1872 SPR_IMG_AIRPLANESLIST,
1879 SPR_IMG_LANDSCAPING,
1883 SPR_IMG_SWITCH_TOOLBAR,
1889 case 4:
case 8:
case 15:
case 19:
case 21:
case 26: hor->
Add(
new NWidgetSpacer(0, 0));
break;
1898 static const NWidgetPart _nested_toolbar_normal_widgets[] = {
1906 _nested_toolbar_normal_widgets,
lengthof(_nested_toolbar_normal_widgets),
1907 &MainToolbarWindow::hotkeys
1913 static ToolbarButtonProc *
const _scen_toolbar_button_procs[] = {
1920 ToolbarScenDateBackward,
1921 ToolbarScenDateForward,
1922 ToolbarScenMapTownDir,
1924 ToolbarZoomOutClick,
1927 ToolbarScenGenIndustry,
1928 ToolbarScenBuildRoad,
1929 ToolbarScenBuildDocks,
1930 ToolbarScenPlantTrees,
1931 ToolbarScenPlaceSign,
1946 enum MainToolbarEditorHotkeys {
1960 MTEHK_SMALL_SCREENSHOT,
1961 MTEHK_ZOOMEDIN_SCREENSHOT,
1962 MTEHK_DEFAULTZOOM_SCREENSHOT,
1963 MTEHK_GIANT_SCREENSHOT,
1968 MTEHK_EXTRA_VIEWPORT,
2001 int height = r.bottom - r.top;
2004 DrawString(r.left, r.right, (height + 1) / 2, STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR, TC_FROMSTRING,
SA_HOR_CENTER);
2030 if (_game_mode == GM_MENU)
return;
2049 case MTEHK_PAUSE: ToolbarPauseClick(
this);
break;
2053 case MTEHK_GENLAND: ToolbarScenGenLand(
this);
break;
2054 case MTEHK_GENTOWN: ToolbarScenGenTown(
this);
break;
2055 case MTEHK_GENINDUSTRY: ToolbarScenGenIndustry(
this);
break;
2056 case MTEHK_BUILD_ROAD: ToolbarScenBuildRoad(
this);
break;
2057 case MTEHK_BUILD_DOCKS: ToolbarScenBuildDocks(
this);
break;
2058 case MTEHK_BUILD_TREES: ToolbarScenPlantTrees(
this);
break;
2059 case MTEHK_SIGN: cbf = ToolbarScenPlaceSign(
this);
break;
2060 case MTEHK_MUSIC: ShowMusicWindow();
break;
2061 case MTEHK_LANDINFO: cbf = PlaceLandBlockInfo();
break;
2062 case MTEHK_SMALL_SCREENSHOT: MenuClickSmallScreenshot();
break;
2066 case MTEHK_ZOOM_IN: ToolbarZoomInClick(
this);
break;
2067 case MTEHK_ZOOM_OUT: ToolbarZoomOutClick(
this);
break;
2080 case CBF_PLACE_SIGN:
2084 case CBF_PLACE_LANDINFO:
2088 default: NOT_REACHED();
2119 if (!gui_scope)
return;
2126 if (str == NULL)
return;
2143 static Hotkey scenedit_maintoolbar_hotkeys[] = {
2144 Hotkey(_maintoolbar_pause_keys,
"pause", MTEHK_PAUSE),
2145 Hotkey((uint16)0,
"fastforward", MTEHK_FASTFORWARD),
2146 Hotkey(WKC_F2,
"settings", MTEHK_SETTINGS),
2147 Hotkey(WKC_F3,
"saveload", MTEHK_SAVEGAME),
2148 Hotkey(WKC_F4,
"gen_land", MTEHK_GENLAND),
2149 Hotkey(WKC_F5,
"gen_town", MTEHK_GENTOWN),
2150 Hotkey(WKC_F6,
"gen_industry", MTEHK_GENINDUSTRY),
2151 Hotkey(WKC_F7,
"build_road", MTEHK_BUILD_ROAD),
2152 Hotkey(WKC_F8,
"build_docks", MTEHK_BUILD_DOCKS),
2153 Hotkey(WKC_F9,
"build_trees", MTEHK_BUILD_TREES),
2154 Hotkey(WKC_F10,
"build_sign", MTEHK_SIGN),
2155 Hotkey(WKC_F11,
"music", MTEHK_MUSIC),
2156 Hotkey(WKC_F12,
"land_info", MTEHK_LANDINFO),
2157 Hotkey(WKC_CTRL |
'S',
"small_screenshot", MTEHK_SMALL_SCREENSHOT),
2158 Hotkey(WKC_CTRL |
'P',
"zoomedin_screenshot", MTEHK_ZOOMEDIN_SCREENSHOT),
2159 Hotkey(WKC_CTRL |
'D',
"defaultzoom_screenshot", MTEHK_DEFAULTZOOM_SCREENSHOT),
2160 Hotkey((uint16)0,
"giant_screenshot", MTEHK_GIANT_SCREENSHOT),
2161 Hotkey(_maintoolbar_zoomin_keys,
"zoomin", MTEHK_ZOOM_IN),
2162 Hotkey(_maintoolbar_zoomout_keys,
"zoomout", MTEHK_ZOOM_OUT),
2163 Hotkey(
'L',
"terraform", MTEHK_TERRAFORM),
2164 Hotkey(
'M',
"smallmap", MTEHK_SMALLMAP),
2165 Hotkey(
'V',
"extra_viewport", MTEHK_EXTRA_VIEWPORT),
2168 HotkeyList ScenarioEditorToolbarWindow::hotkeys(
"scenedit_maintoolbar", scenedit_maintoolbar_hotkeys);
2170 static const NWidgetPart _nested_toolb_scen_inner_widgets[] = {
2204 static NWidgetBase *MakeScenarioToolbar(
int *biggest_index)
2209 static const NWidgetPart _nested_toolb_scen_widgets[] = {
2217 _nested_toolb_scen_widgets,
lengthof(_nested_toolb_scen_widgets),
2218 &ScenarioEditorToolbarWindow::hotkeys
2227 if (_game_mode == GM_EDITOR) {