src/toolbar_gui.cpp
changeset 10989 253dc7c191dd
parent 10988 6c7b90b28b6a
child 10996 c0f85c0d7284
equal deleted inserted replaced
10988:6c7b90b28b6a 10989:253dc7c191dd
    56 	TB_NORMAL,
    56 	TB_NORMAL,
    57 	TB_UPPER,
    57 	TB_UPPER,
    58 	TB_LOWER
    58 	TB_LOWER
    59 };
    59 };
    60 
    60 
       
    61 enum ToolbarNormalWidgets {
       
    62 	TBN_PAUSE         = 0,
       
    63 	TBN_FASTFORWARD,
       
    64 	TBN_SETTINGS,
       
    65 	TBN_SAVEGAME,
       
    66 	TBN_SMALLMAP,
       
    67 	TBN_TOWNDIRECTORY,
       
    68 	TBN_SUBSIDIES,
       
    69 	TBN_STATIONS,
       
    70 	TBN_FINANCES,
       
    71 	TBN_PLAYERS,
       
    72 	TBN_GRAPHICS,
       
    73 	TBN_LEAGUE,
       
    74 	TBN_INDUSTRIES,
       
    75 	TBN_VEHICLESTART,      ///< trains, actually.  So following are trucks, boats and planes
       
    76 	TBN_TRAINS        = TBN_VEHICLESTART,
       
    77 	TBN_ROADVEHS,
       
    78 	TBN_SHIPS,
       
    79 	TBN_AIRCRAFTS,
       
    80 	TBN_ZOOMIN,
       
    81 	TBN_ZOOMOUT,
       
    82 	TBN_RAILS,
       
    83 	TBN_ROADS,
       
    84 	TBN_WATER,
       
    85 	TBN_AIR,
       
    86 	TBN_LANDSCAPE,
       
    87 	TBN_MUSICSOUND,
       
    88 	TBN_NEWSREPORT,
       
    89 	TBN_HELP,
       
    90 	TBN_SWITCHBAR,         ///< only available when toolbar has been split
       
    91 };
       
    92 
    61 enum ToolbarScenEditorWidgets {
    93 enum ToolbarScenEditorWidgets {
    62 	TBSE_PAUSE        = 0,
    94 	TBSE_PAUSE        = 0,
    63 	TBSE_FASTFORWARD,
    95 	TBSE_FASTFORWARD,
    64 	TBSE_SPACERPANEL  = 4,
    96 	TBSE_SAVESCENARIO = 3,
       
    97 	TBSE_SPACERPANEL,
    65 	TBSE_DATEBACKWARD = 6,
    98 	TBSE_DATEBACKWARD = 6,
    66 	TBSE_DATEFORWARD,
    99 	TBSE_DATEFORWARD,
    67 	TBSE_ZOOMIN       = 9,
   100 	TBSE_ZOOMIN       = 9,
    68 	TBSE_ZOOMOUT,
   101 	TBSE_ZOOMOUT,
    69 	TBSE_LANDGENERATE,
   102 	TBSE_LANDGENERATE,
   154 	if (HasBit(_display_opt, DO_FULL_ANIMATION))     SetBit(x, 10);
   187 	if (HasBit(_display_opt, DO_FULL_ANIMATION))     SetBit(x, 10);
   155 	if (HasBit(_display_opt, DO_FULL_DETAIL))        SetBit(x, 11);
   188 	if (HasBit(_display_opt, DO_FULL_DETAIL))        SetBit(x, 11);
   156 	if (IsTransparencySet(TO_HOUSES))                SetBit(x, 12);
   189 	if (IsTransparencySet(TO_HOUSES))                SetBit(x, 12);
   157 	if (IsTransparencySet(TO_SIGNS))                 SetBit(x, 13);
   190 	if (IsTransparencySet(TO_SIGNS))                 SetBit(x, 13);
   158 
   191 
   159 	PopupMainToolbMenu(w, 2, STR_02C4_GAME_OPTIONS, 14, 0, 0, x);
   192 	PopupMainToolbMenu(w, TBN_SETTINGS, STR_02C4_GAME_OPTIONS, 14, 0, 0, x);
   160 }
   193 }
   161 
   194 
   162 static void MenuClickSettings(int index)
   195 static void MenuClickSettings(int index)
   163 {
   196 {
   164 	switch (index) {
   197 	switch (index) {
   182 
   215 
   183 /* --- Saving/loading button menu --- */
   216 /* --- Saving/loading button menu --- */
   184 
   217 
   185 static void ToolbarSaveClick(Window *w)
   218 static void ToolbarSaveClick(Window *w)
   186 {
   219 {
   187 	PopupMainToolbMenu(w, 3, STR_015C_SAVE_GAME, 4);
   220 	PopupMainToolbMenu(w, TBN_SAVEGAME, STR_015C_SAVE_GAME, 4);
   188 }
   221 }
   189 
   222 
   190 static void ToolbarScenSaveOrLoad(Window *w)
   223 static void ToolbarScenSaveOrLoad(Window *w)
   191 {
   224 {
   192 	PopupMainToolbMenu(w, 3, STR_0292_SAVE_SCENARIO, 6);
   225 	PopupMainToolbMenu(w, TBSE_SAVESCENARIO, STR_0292_SAVE_SCENARIO, 6);
   193 }
   226 }
   194 
   227 
   195 static void MenuClickSaveLoad(int index)
   228 static void MenuClickSaveLoad(int index)
   196 {
   229 {
   197 	if (_game_mode == GM_EDITOR) {
   230 	if (_game_mode == GM_EDITOR) {
   214 
   247 
   215 /* --- Map button menu --- */
   248 /* --- Map button menu --- */
   216 
   249 
   217 static void ToolbarMapClick(Window *w)
   250 static void ToolbarMapClick(Window *w)
   218 {
   251 {
   219 	PopupMainToolbMenu(w, 4, STR_02DE_MAP_OF_WORLD, 3);
   252 	PopupMainToolbMenu(w, TBN_SMALLMAP, STR_02DE_MAP_OF_WORLD, 3);
   220 }
   253 }
   221 
   254 
   222 static void MenuClickMap(int index)
   255 static void MenuClickMap(int index)
   223 {
   256 {
   224 	switch (index) {
   257 	switch (index) {
   240 
   273 
   241 /* --- Town button menu --- */
   274 /* --- Town button menu --- */
   242 
   275 
   243 static void ToolbarTownClick(Window *w)
   276 static void ToolbarTownClick(Window *w)
   244 {
   277 {
   245 	PopupMainToolbMenu(w, 5, STR_02BB_TOWN_DIRECTORY, 1);
   278 	PopupMainToolbMenu(w, TBN_TOWNDIRECTORY, STR_02BB_TOWN_DIRECTORY, 1);
   246 }
   279 }
   247 
   280 
   248 static void MenuClickTown(int index)
   281 static void MenuClickTown(int index)
   249 {
   282 {
   250 	ShowTownDirectory();
   283 	ShowTownDirectory();
   252 
   285 
   253 /* --- Subidies button menu --- */
   286 /* --- Subidies button menu --- */
   254 
   287 
   255 static void ToolbarSubsidiesClick(Window *w)
   288 static void ToolbarSubsidiesClick(Window *w)
   256 {
   289 {
   257 	PopupMainToolbMenu(w, 6, STR_02DD_SUBSIDIES, 1);
   290 	PopupMainToolbMenu(w, TBN_SUBSIDIES, STR_02DD_SUBSIDIES, 1);
   258 }
   291 }
   259 
   292 
   260 static void MenuClickSubsidies(int index)
   293 static void MenuClickSubsidies(int index)
   261 {
   294 {
   262 	ShowSubsidiesList();
   295 	ShowSubsidiesList();
   264 
   297 
   265 /* --- Stations button menu --- */
   298 /* --- Stations button menu --- */
   266 
   299 
   267 static void ToolbarStationsClick(Window *w)
   300 static void ToolbarStationsClick(Window *w)
   268 {
   301 {
   269 	PopupMainPlayerToolbMenu(w, 7, 0);
   302 	PopupMainPlayerToolbMenu(w, TBN_STATIONS, 0);
   270 }
   303 }
   271 
   304 
   272 static void MenuClickStations(int index)
   305 static void MenuClickStations(int index)
   273 {
   306 {
   274 	ShowPlayerStations((PlayerID)index);
   307 	ShowPlayerStations((PlayerID)index);
   276 
   309 
   277 /* --- Finances button menu --- */
   310 /* --- Finances button menu --- */
   278 
   311 
   279 static void ToolbarFinancesClick(Window *w)
   312 static void ToolbarFinancesClick(Window *w)
   280 {
   313 {
   281 	PopupMainPlayerToolbMenu(w, 8, 0);
   314 	PopupMainPlayerToolbMenu(w, TBN_FINANCES, 0);
   282 }
   315 }
   283 
   316 
   284 static void MenuClickFinances(int index)
   317 static void MenuClickFinances(int index)
   285 {
   318 {
   286 	ShowPlayerFinances((PlayerID)index);
   319 	ShowPlayerFinances((PlayerID)index);
   288 
   321 
   289 /* --- Company's button menu --- */
   322 /* --- Company's button menu --- */
   290 
   323 
   291 static void ToolbarPlayersClick(Window *w)
   324 static void ToolbarPlayersClick(Window *w)
   292 {
   325 {
   293 	PopupMainPlayerToolbMenu(w, 9, 0);
   326 	PopupMainPlayerToolbMenu(w, TBN_PLAYERS, 0);
   294 }
   327 }
   295 
   328 
   296 static void MenuClickCompany(int index)
   329 static void MenuClickCompany(int index)
   297 {
   330 {
   298 	if (_networking && index == 0) {
   331 	if (_networking && index == 0) {
   305 
   338 
   306 /* --- Graphs button menu --- */
   339 /* --- Graphs button menu --- */
   307 
   340 
   308 static void ToolbarGraphsClick(Window *w)
   341 static void ToolbarGraphsClick(Window *w)
   309 {
   342 {
   310 	PopupMainToolbMenu(w, 10, STR_0154_OPERATING_PROFIT_GRAPH, (_toolbar_mode == TB_NORMAL) ? 6 : 8);
   343 	PopupMainToolbMenu(w, TBN_GRAPHICS, STR_0154_OPERATING_PROFIT_GRAPH, (_toolbar_mode == TB_NORMAL) ? 6 : 8);
   311 }
   344 }
   312 
   345 
   313 static void MenuClickGraphs(int index)
   346 static void MenuClickGraphs(int index)
   314 {
   347 {
   315 	switch (index) {
   348 	switch (index) {
   327 
   360 
   328 /* --- League button menu --- */
   361 /* --- League button menu --- */
   329 
   362 
   330 static void ToolbarLeagueClick(Window *w)
   363 static void ToolbarLeagueClick(Window *w)
   331 {
   364 {
   332 	PopupMainToolbMenu(w, 11, STR_015A_COMPANY_LEAGUE_TABLE, 2);
   365 	PopupMainToolbMenu(w, TBN_LEAGUE, STR_015A_COMPANY_LEAGUE_TABLE, 2);
   333 }
   366 }
   334 
   367 
   335 static void MenuClickLeague(int index)
   368 static void MenuClickLeague(int index)
   336 {
   369 {
   337 	switch (index) {
   370 	switch (index) {
   343 /* --- Industries button menu --- */
   376 /* --- Industries button menu --- */
   344 
   377 
   345 static void ToolbarIndustryClick(Window *w)
   378 static void ToolbarIndustryClick(Window *w)
   346 {
   379 {
   347 	/* Disable build-industry menu if we are a spectator */
   380 	/* Disable build-industry menu if we are a spectator */
   348 	PopupMainToolbMenu(w, 12, STR_INDUSTRY_DIR, 2, (_current_player == PLAYER_SPECTATOR) ? 2 : 0);
   381 	PopupMainToolbMenu(w, TBN_INDUSTRIES, STR_INDUSTRY_DIR, 2, (_current_player == PLAYER_SPECTATOR) ? 2 : 0);
   349 }
   382 }
   350 
   383 
   351 static void MenuClickIndustry(int index)
   384 static void MenuClickIndustry(int index)
   352 {
   385 {
   353 	switch (index) {
   386 	switch (index) {
   364 	int dis = ~0;
   397 	int dis = ~0;
   365 
   398 
   366 	FOR_ALL_VEHICLES(v) {
   399 	FOR_ALL_VEHICLES(v) {
   367 		if (v->type == veh && v->IsPrimaryVehicle()) ClrBit(dis, v->owner);
   400 		if (v->type == veh && v->IsPrimaryVehicle()) ClrBit(dis, v->owner);
   368 	}
   401 	}
   369 	PopupMainPlayerToolbMenu(w, 13 + veh, dis);
   402 	PopupMainPlayerToolbMenu(w, TBN_VEHICLESTART + veh, dis);
   370 }
   403 }
   371 
   404 
   372 
   405 
   373 static void ToolbarTrainClick(Window *w)
   406 static void ToolbarTrainClick(Window *w)
   374 {
   407 {
   419 /* --- Zoom in button --- */
   452 /* --- Zoom in button --- */
   420 
   453 
   421 static void ToolbarZoomInClick(Window *w)
   454 static void ToolbarZoomInClick(Window *w)
   422 {
   455 {
   423 	if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
   456 	if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
   424 		w->HandleButtonClick(17);
   457 		w->HandleButtonClick(TBN_ZOOMIN);
   425 		SndPlayFx(SND_15_BEEP);
   458 		SndPlayFx(SND_15_BEEP);
   426 	}
   459 	}
   427 }
   460 }
   428 
   461 
   429 /* --- Zoom out button --- */
   462 /* --- Zoom out button --- */
   430 
   463 
   431 static void ToolbarZoomOutClick(Window *w)
   464 static void ToolbarZoomOutClick(Window *w)
   432 {
   465 {
   433 	if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) {
   466 	if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) {
   434 		w->HandleButtonClick(18);
   467 		w->HandleButtonClick(TBN_ZOOMOUT);
   435 		SndPlayFx(SND_15_BEEP);
   468 		SndPlayFx(SND_15_BEEP);
   436 	}
   469 	}
   437 }
   470 }
   438 
   471 
   439 /* --- Rail button menu --- */
   472 /* --- Rail button menu --- */
   440 
   473 
   441 static void ToolbarBuildRailClick(Window *w)
   474 static void ToolbarBuildRailClick(Window *w)
   442 {
   475 {
   443 	const Player *p = GetPlayer(_local_player);
   476 	const Player *p = GetPlayer(_local_player);
   444 	PopupMainToolbMenu(w, 19, STR_1015_RAILROAD_CONSTRUCTION, RAILTYPE_END, ~p->avail_railtypes, _last_built_railtype);
   477 	PopupMainToolbMenu(w, TBN_RAILS, STR_1015_RAILROAD_CONSTRUCTION, RAILTYPE_END, ~p->avail_railtypes, _last_built_railtype);
   445 }
   478 }
   446 
   479 
   447 static void MenuClickBuildRail(int index)
   480 static void MenuClickBuildRail(int index)
   448 {
   481 {
   449 	_last_built_railtype = (RailType)index;
   482 	_last_built_railtype = (RailType)index;
   454 
   487 
   455 static void ToolbarBuildRoadClick(Window *w)
   488 static void ToolbarBuildRoadClick(Window *w)
   456 {
   489 {
   457 	const Player *p = GetPlayer(_local_player);
   490 	const Player *p = GetPlayer(_local_player);
   458 	/* The standard road button is *always* available */
   491 	/* The standard road button is *always* available */
   459 	PopupMainToolbMenu(w, 20, STR_180A_ROAD_CONSTRUCTION, 2, ~(p->avail_roadtypes | ROADTYPES_ROAD), _last_built_roadtype);
   492 	PopupMainToolbMenu(w, TBN_ROADS, STR_180A_ROAD_CONSTRUCTION, 2, ~(p->avail_roadtypes | ROADTYPES_ROAD), _last_built_roadtype);
   460 }
   493 }
   461 
   494 
   462 static void MenuClickBuildRoad(int index)
   495 static void MenuClickBuildRoad(int index)
   463 {
   496 {
   464 	_last_built_roadtype = (RoadType)index;
   497 	_last_built_roadtype = (RoadType)index;
   467 
   500 
   468 /* --- Water button menu --- */
   501 /* --- Water button menu --- */
   469 
   502 
   470 static void ToolbarBuildWaterClick(Window *w)
   503 static void ToolbarBuildWaterClick(Window *w)
   471 {
   504 {
   472 	PopupMainToolbMenu(w, 21, STR_9800_DOCK_CONSTRUCTION, 1);
   505 	PopupMainToolbMenu(w, TBN_WATER, STR_9800_DOCK_CONSTRUCTION, 1);
   473 }
   506 }
   474 
   507 
   475 static void MenuClickBuildWater(int index)
   508 static void MenuClickBuildWater(int index)
   476 {
   509 {
   477 	ShowBuildDocksToolbar();
   510 	ShowBuildDocksToolbar();
   479 
   512 
   480 /* --- Airport button menu --- */
   513 /* --- Airport button menu --- */
   481 
   514 
   482 static void ToolbarBuildAirClick(Window *w)
   515 static void ToolbarBuildAirClick(Window *w)
   483 {
   516 {
   484 	PopupMainToolbMenu(w, 22, STR_A01D_AIRPORT_CONSTRUCTION, 1);
   517 	PopupMainToolbMenu(w, TBN_AIR, STR_A01D_AIRPORT_CONSTRUCTION, 1);
   485 }
   518 }
   486 
   519 
   487 static void MenuClickBuildAir(int index)
   520 static void MenuClickBuildAir(int index)
   488 {
   521 {
   489 	ShowBuildAirToolbar();
   522 	ShowBuildAirToolbar();
   491 
   524 
   492 /* --- Forest button menu --- */
   525 /* --- Forest button menu --- */
   493 
   526 
   494 static void ToolbarForestClick(Window *w)
   527 static void ToolbarForestClick(Window *w)
   495 {
   528 {
   496 	PopupMainToolbMenu(w, 23, STR_LANDSCAPING, 3);
   529 	PopupMainToolbMenu(w, TBN_LANDSCAPE, STR_LANDSCAPING, 3);
   497 }
   530 }
   498 
   531 
   499 static void MenuClickForest(int index)
   532 static void MenuClickForest(int index)
   500 {
   533 {
   501 	switch (index) {
   534 	switch (index) {
   507 
   540 
   508 /* --- Music button menu --- */
   541 /* --- Music button menu --- */
   509 
   542 
   510 static void ToolbarMusicClick(Window *w)
   543 static void ToolbarMusicClick(Window *w)
   511 {
   544 {
   512 	PopupMainToolbMenu(w, 24, STR_01D3_SOUND_MUSIC, 1);
   545 	PopupMainToolbMenu(w, TBN_MUSICSOUND, STR_01D3_SOUND_MUSIC, 1);
   513 }
   546 }
   514 
   547 
   515 static void MenuClickMusicWindow(int index)
   548 static void MenuClickMusicWindow(int index)
   516 {
   549 {
   517 	ShowMusicWindow();
   550 	ShowMusicWindow();
   519 
   552 
   520 /* --- Newspaper button menu --- */
   553 /* --- Newspaper button menu --- */
   521 
   554 
   522 static void ToolbarNewspaperClick(Window *w)
   555 static void ToolbarNewspaperClick(Window *w)
   523 {
   556 {
   524 	PopupMainToolbMenu(w, 25, STR_0200_LAST_MESSAGE_NEWS_REPORT, 3);
   557 	PopupMainToolbMenu(w, TBN_NEWSREPORT, STR_0200_LAST_MESSAGE_NEWS_REPORT, 3);
   525 }
   558 }
   526 
   559 
   527 static void MenuClickNewspaper(int index)
   560 static void MenuClickNewspaper(int index)
   528 {
   561 {
   529 	switch (index) {
   562 	switch (index) {
   535 
   568 
   536 /* --- Help button menu --- */
   569 /* --- Help button menu --- */
   537 
   570 
   538 static void ToolbarHelpClick(Window *w)
   571 static void ToolbarHelpClick(Window *w)
   539 {
   572 {
   540 	PopupMainToolbMenu(w, 26, STR_02D5_LAND_BLOCK_INFO, 6);
   573 	PopupMainToolbMenu(w, TBN_HELP, STR_02D5_LAND_BLOCK_INFO, 6);
   541 }
   574 }
   542 
   575 
   543 static void MenuClickSmallScreenshot()
   576 static void MenuClickSmallScreenshot()
   544 {
   577 {
   545 	SetScreenshotType(SC_VIEWPORT);
   578 	SetScreenshotType(SC_VIEWPORT);
   570 	} else {
   603 	} else {
   571 		_toolbar_mode = TB_UPPER;
   604 		_toolbar_mode = TB_UPPER;
   572 	}
   605 	}
   573 
   606 
   574 	SplitToolbar(w);
   607 	SplitToolbar(w);
   575 	w->HandleButtonClick(27);
   608 	w->HandleButtonClick(TBN_SWITCHBAR);
   576 	SetWindowDirty(w);
   609 	SetWindowDirty(w);
   577 	SndPlayFx(SND_15_BEEP);
   610 	SndPlayFx(SND_15_BEEP);
   578 }
   611 }
   579 
   612 
   580 /* --- Scenario editor specific handlers. */
   613 /* --- Scenario editor specific handlers. */
   797 };
   830 };
   798 
   831 
   799 struct MainToolbarWindow : Window {
   832 struct MainToolbarWindow : Window {
   800 	MainToolbarWindow(const WindowDesc *desc) : Window(desc)
   833 	MainToolbarWindow(const WindowDesc *desc) : Window(desc)
   801 	{
   834 	{
   802 		this->SetWidgetDisabledState(0, _networking && !_network_server); // if not server, disable pause button
   835 		this->SetWidgetDisabledState(TBN_PAUSE, _networking && !_network_server); // if not server, disable pause button
   803 		this->SetWidgetDisabledState(1, _networking); // if networking, disable fast-forward button
   836 		this->SetWidgetDisabledState(TBN_FASTFORWARD, _networking); // if networking, disable fast-forward button
   804 
   837 
   805 		CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
   838 		CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
   806 
   839 
   807 		this->FindWindowPlacementAndResize(desc);
   840 		this->FindWindowPlacementAndResize(desc);
   808 		PositionMainToolbar(this);
   841 		PositionMainToolbar(this);
   816 		GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT));
   849 		GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT));
   817 
   850 
   818 		/* If spectator, disable all construction buttons
   851 		/* If spectator, disable all construction buttons
   819 		* ie : Build road, rail, ships, airports and landscaping
   852 		* ie : Build road, rail, ships, airports and landscaping
   820 		* Since enabled state is the default, just disable when needed */
   853 		* Since enabled state is the default, just disable when needed */
   821 		this->SetWidgetsDisabledState(_current_player == PLAYER_SPECTATOR, 19, 20, 21, 22, 23, WIDGET_LIST_END);
   854 		this->SetWidgetsDisabledState(_current_player == PLAYER_SPECTATOR, TBN_RAILS, TBN_ROADS, TBN_WATER, TBN_AIR, TBN_LANDSCAPE, WIDGET_LIST_END);
   822 		/* disable company list drop downs, if there are no companies */
   855 		/* disable company list drop downs, if there are no companies */
   823 		this->SetWidgetsDisabledState(ActivePlayerCount() == 0, 7, 8, 13, 14, 15, 16, WIDGET_LIST_END);
   856 		this->SetWidgetsDisabledState(ActivePlayerCount() == TBN_PAUSE, TBN_STATIONS, TBN_FINANCES, TBN_TRAINS, TBN_ROADVEHS, TBN_SHIPS, TBN_AIRCRAFTS, WIDGET_LIST_END);
   824 
   857 
   825 		this->SetWidgetDisabledState(19, !CanBuildVehicleInfrastructure(VEH_TRAIN));
   858 		this->SetWidgetDisabledState(TBN_RAILS, !CanBuildVehicleInfrastructure(VEH_TRAIN));
   826 		this->SetWidgetDisabledState(22, !CanBuildVehicleInfrastructure(VEH_AIRCRAFT));
   859 		this->SetWidgetDisabledState(TBN_AIR, !CanBuildVehicleInfrastructure(VEH_AIRCRAFT));
   827 
   860 
   828 		this->DrawWidgets();
   861 		this->DrawWidgets();
   829 	}
   862 	}
   830 
   863 
   831 	virtual void OnClick(Point pt, int widget)
   864 	virtual void OnClick(Point pt, int widget)
   883 		_place_proc(tile);
   916 		_place_proc(tile);
   884 	}
   917 	}
   885 
   918 
   886 	virtual void OnTick()
   919 	virtual void OnTick()
   887 	{
   920 	{
   888 		if (this->IsWidgetLowered(0) != !!_pause_game) {
   921 		if (this->IsWidgetLowered(TBN_PAUSE) != !!_pause_game) {
   889 			this->ToggleWidgetLoweredState(0);
   922 			this->ToggleWidgetLoweredState(TBN_PAUSE);
   890 			this->InvalidateWidget(0);
   923 			this->InvalidateWidget(TBN_PAUSE);
   891 		}
   924 		}
   892 
   925 
   893 		if (this->IsWidgetLowered(1) != !!_fast_forward) {
   926 		if (this->IsWidgetLowered(TBN_FASTFORWARD) != !!_fast_forward) {
   894 			this->ToggleWidgetLoweredState(1);
   927 			this->ToggleWidgetLoweredState(TBN_FASTFORWARD);
   895 			this->InvalidateWidget(1);
   928 			this->InvalidateWidget(TBN_FASTFORWARD);
   896 		}
   929 		}
   897 	}
   930 	}
   898 
   931 
   899 	virtual void OnResize(Point new_size, Point delta)
   932 	virtual void OnResize(Point new_size, Point delta)
   900 	{
   933 	{
   905 		}
   938 		}
   906 	}
   939 	}
   907 
   940 
   908 	virtual void OnTimeout()
   941 	virtual void OnTimeout()
   909 	{
   942 	{
   910 		for (uint i = 2; i < this->widget_count; i++) {
   943 		for (uint i = TBN_SETTINGS; i < this->widget_count; i++) {
   911 			if (this->IsWidgetLowered(i)) {
   944 			if (this->IsWidgetLowered(i)) {
   912 				this->RaiseWidget(i);
   945 				this->RaiseWidget(i);
   913 				this->InvalidateWidget(i);
   946 				this->InvalidateWidget(i);
   914 			}
   947 			}
   915 		}
   948 		}
   916 	}
   949 	}
   917 
   950 
   918 	virtual void OnInvalidateData(int data)
   951 	virtual void OnInvalidateData(int data)
   919 	{
   952 	{
   920 		if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, 17, 18);
   953 		if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, TBN_ZOOMIN, TBN_ZOOMOUT);
   921 	}
   954 	}
   922 };
   955 };
   923 
   956 
   924 static const Widget _toolb_normal_widgets[] = {
   957 static const Widget _toolb_normal_widgets[] = {
   925 {     WWT_IMGBTN,   RESIZE_LEFT,    14,     0,     0,     0,    21, SPR_IMG_PAUSE,           STR_0171_PAUSE_GAME},
   958 {     WWT_IMGBTN,   RESIZE_LEFT,    14,     0,     0,     0,    21, SPR_IMG_PAUSE,           STR_0171_PAUSE_GAME},
  1413 			Window(x, y, width, height, WC_TOOLBAR_MENU, widgets),
  1446 			Window(x, y, width, height, WC_TOOLBAR_MENU, widgets),
  1414 			item_count(0), main_button(main_button), action_id(main_button), gray_items(gray)
  1447 			item_count(0), main_button(main_button), action_id(main_button), gray_items(gray)
  1415 	{
  1448 	{
  1416 		this->flags4 &= ~WF_WHITE_BORDER_MASK;
  1449 		this->flags4 &= ~WF_WHITE_BORDER_MASK;
  1417 		this->sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0);
  1450 		this->sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0);
  1418 		if (_networking && main_button == 9) {
  1451 		if (_networking && main_button == TBN_PLAYERS) {
  1419 			if (_local_player != PLAYER_SPECTATOR) {
  1452 			if (_local_player != PLAYER_SPECTATOR) {
  1420 				this->sel_index++;
  1453 				this->sel_index++;
  1421 			} else {
  1454 			} else {
  1422 				/* Select client list by default for spectators */
  1455 				/* Select client list by default for spectators */
  1423 				this->sel_index = 0;
  1456 				this->sel_index = 0;
  1437 	void UpdatePlayerMenuHeight()
  1470 	void UpdatePlayerMenuHeight()
  1438 	{
  1471 	{
  1439 		byte num = ActivePlayerCount();
  1472 		byte num = ActivePlayerCount();
  1440 
  1473 
  1441 		/* Increase one to fit in PlayerList in the menu when in network */
  1474 		/* Increase one to fit in PlayerList in the menu when in network */
  1442 		if (_networking && this->main_button == 9) num++;
  1475 		if (_networking && this->main_button == TBN_PLAYERS) num++;
  1443 
  1476 
  1444 		if (this->item_count != num) {
  1477 		if (this->item_count != num) {
  1445 			this->item_count = num;
  1478 			this->item_count = num;
  1446 			this->SetDirty();
  1479 			this->SetDirty();
  1447 			num = num * 10 + 2;
  1480 			num = num * 10 + 2;
  1461 		int y = 1;
  1494 		int y = 1;
  1462 		int sel = this->sel_index;
  1495 		int sel = this->sel_index;
  1463 		int gray = this->gray_items;
  1496 		int gray = this->gray_items;
  1464 
  1497 
  1465 		/* 9 = playerlist */
  1498 		/* 9 = playerlist */
  1466 		if (_networking && this->main_button == 9) {
  1499 		if (_networking && this->main_button == TBN_PLAYERS) {
  1467 			if (sel == 0) {
  1500 			if (sel == 0) {
  1468 				GfxFillRect(x, y, x + 238, y + 9, 0);
  1501 				GfxFillRect(x, y, x + 238, y + 9, 0);
  1469 			}
  1502 			}
  1470 			DrawString(x + 19, y, STR_NETWORK_CLIENT_LIST, TC_FROMSTRING);
  1503 			DrawString(x + 19, y, STR_NETWORK_CLIENT_LIST, TC_FROMSTRING);
  1471 			y += 10;
  1504 			y += 10;
  1500 
  1533 
  1501 		if (_left_button_down) {
  1534 		if (_left_button_down) {
  1502 			this->UpdatePlayerMenuHeight();
  1535 			this->UpdatePlayerMenuHeight();
  1503 			/* We have a new entry at the top of the list of menu 9 when networking
  1536 			/* We have a new entry at the top of the list of menu 9 when networking
  1504 				* so keep that in count */
  1537 				* so keep that in count */
  1505 			if (_networking && this->main_button == 9) {
  1538 			if (_networking && this->main_button == TBN_PLAYERS) {
  1506 				if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
  1539 				if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
  1507 			} else {
  1540 			} else {
  1508 				index = GetPlayerIndexFromMenu(index);
  1541 				index = GetPlayerIndexFromMenu(index);
  1509 			}
  1542 			}
  1510 
  1543 
  1515 		} else {
  1548 		} else {
  1516 			int action_id = this->action_id;
  1549 			int action_id = this->action_id;
  1517 
  1550 
  1518 			/* We have a new entry at the top of the list of menu 9 when networking
  1551 			/* We have a new entry at the top of the list of menu 9 when networking
  1519 				* so keep that in count */
  1552 				* so keep that in count */
  1520 			if (_networking && this->main_button == 9) {
  1553 			if (_networking && this->main_button == TBN_PLAYERS) {
  1521 				if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
  1554 				if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
  1522 			} else {
  1555 			} else {
  1523 				index = GetPlayerIndexFromMenu(index);
  1556 				index = GetPlayerIndexFromMenu(index);
  1524 			}
  1557 			}
  1525 
  1558