# toolbar_gui.cpp

Go to the documentation of this file.

    00001 /* $Id: toolbar_gui.cpp 15723 2009-03-15 15:12:06Z rubidium $ */
    00002
    00005 #include "stdafx.h"
    00006 #include "openttd.h"
    00007 #include "gui.h"
    00008 #include "window_gui.h"
    00009 #include "window_func.h"
    00010 #include "viewport_func.h"
    00011 #include "command_func.h"
    00012 #include "variables.h"
    00013 #include "vehicle_gui.h"
    00014 #include "rail_gui.h"
    00015 #include "road_gui.h"
    00016 #include "date_func.h"
    00017 #include "vehicle_func.h"
    00018 #include "sound_func.h"
    00019 #include "terraform_gui.h"
    00020 #include "transparency.h"
    00021 #include "strings_func.h"
    00022 #include "company_func.h"
    00023 #include "company_gui.h"
    00024 #include "vehicle_base.h"
    00025 #include "cheat_func.h"
    00026 #include "transparency_gui.h"
    00027 #include "screenshot.h"
    00028 #include "signs_func.h"
    00029 #include "fios.h"
    00030 #include "functions.h"
    00031 #include "console_gui.h"
    00032 #include "news_gui.h"
    00033 #include "ai/ai_gui.hpp"
    00034 #include "tilehighlight_func.h"
    00035 #include "rail.h"
    00036 #include "widgets/dropdown_type.h"
    00037 #include "settings_type.h"
    00038 #include "newgrf_config.h"
    00039
    00040 #include "network/network.h"
    00041 #include "network/network_gui.h"
    00042 #include "network/network_func.h"
    00043
    00044 #include "table/strings.h"
    00045 #include "table/sprites.h"
    00046
    00047 static void SplitToolbar(Window *w);
    00048
    00049 RailType _last_built_railtype;
    00050 RoadType _last_built_roadtype;
    00051
    00053 enum ToolBarProperties {
    00054   TBP_BUTTONWIDTH        =  22,
    00055   TBP_BUTTONHEIGHT       =  22,
    00056   TBP_DATEPANELWIDTH     = 130,
    00057
    00058   TBP_TOOLBAR_MINBUTTON  =  14,
    00059   TBP_NORMAL_MAXBUTTON   =  19,
    00060   TBP_SCENARIO_MAXBUTTON =  16,
    00061 };
    00062
    00063 enum ToolbarMode {
    00064   TB_NORMAL,
    00065   TB_UPPER,
    00066   TB_LOWER
    00067 };
    00068
    00069 enum ToolbarNormalWidgets {
    00070   TBN_PAUSE         = 0,
    00071   TBN_FASTFORWARD,
    00072   TBN_SETTINGS,
    00073   TBN_SAVEGAME,
    00074   TBN_SMALLMAP,
    00075   TBN_TOWNDIRECTORY,
    00076   TBN_SUBSIDIES,
    00077   TBN_STATIONS,
    00078   TBN_FINANCES,
    00079   TBN_COMPANIES,
    00080   TBN_GRAPHICS,
    00081   TBN_LEAGUE,
    00082   TBN_INDUSTRIES,
    00083   TBN_VEHICLESTART,
    00084   TBN_TRAINS        = TBN_VEHICLESTART,
    00085   TBN_ROADVEHS,
    00086   TBN_SHIPS,
    00087   TBN_AIRCRAFTS,
    00088   TBN_ZOOMIN,
    00089   TBN_ZOOMOUT,
    00090   TBN_RAILS,
    00091   TBN_ROADS,
    00092   TBN_WATER,
    00093   TBN_AIR,
    00094   TBN_LANDSCAPE,
    00095   TBN_MUSICSOUND,
    00096   TBN_NEWSREPORT,
    00097   TBN_HELP,
    00098   TBN_SWITCHBAR,
    00099 };
    00100
    00101 enum ToolbarScenEditorWidgets {
    00102   TBSE_PAUSE        = 0,
    00103   TBSE_FASTFORWARD,
    00104   TBSE_SAVESCENARIO = 3,
    00105   TBSE_SPACERPANEL,
    00106   TBSE_DATEPANEL,
    00107   TBSE_DATEBACKWARD,
    00108   TBSE_DATEFORWARD,
    00109   TBSE_SMALLMAP,
    00110   TBSE_ZOOMIN,
    00111   TBSE_ZOOMOUT,
    00112   TBSE_LANDGENERATE,
    00113   TBSE_TOWNGENERATE,
    00114   TBSE_INDUSTRYGENERATE,
    00115   TBSE_BUILDROAD,
    00116   TBSE_BUILDDOCKS,
    00117   TBSE_PLANTTREES,
    00118   TBSE_PLACESIGNS,
    00119 };
    00120
    00124 class DropDownListCheckedItem : public DropDownListStringItem {
    00125 public:
    00126   bool checked;
    00127
    00128   DropDownListCheckedItem(StringID string, int result, bool masked, bool checked) : DropDownListStringItem(string, result, masked), checked(checked) {}
    00129
    00130   virtual ~DropDownListCheckedItem() {}
    00131
    00132   void Draw(int x, int y, uint width, uint height, bool sel, int bg_colour) const
    00133   {
    00134     if (checked) {
    00135       DrawString(x + 2, y, STR_CHECKMARK, sel ? TC_WHITE : TC_BLACK);
    00136     }
    00137     DrawStringTruncated(x + 2, y, this->String(), sel ? TC_WHITE : TC_BLACK, width);
    00138   }
    00139 };
    00140
    00144 class DropDownListCompanyItem : public DropDownListItem {
    00145 public:
    00146   bool greyed;
    00147
    00148   DropDownListCompanyItem(int result, bool masked, bool greyed) : DropDownListItem(result, masked), greyed(greyed) {}
    00149
    00150   virtual ~DropDownListCompanyItem() {}
    00151
    00152   bool Selectable() const
    00153   {
    00154     return true;
    00155   }
    00156
    00157   uint Width() const
    00158   {
    00159     char buffer[512];
    00160     CompanyID company = (CompanyID)result;
    00161     SetDParam(0, company);
    00162     SetDParam(1, company);
    00163     GetString(buffer, STR_7021, lastof(buffer));
    00164     return GetStringBoundingBox(buffer).width + 19;
    00165   }
    00166
    00167   void Draw(int x, int y, uint width, uint height, bool sel, int bg_colour) const
    00168   {
    00169     CompanyID company = (CompanyID)result;
    00170     DrawCompanyIcon(company, x + 2, y + 1);
    00171
    00172     SetDParam(0, company);
    00173     SetDParam(1, company);
    00174     TextColour col;
    00175     if (this->greyed) {
    00176       col = TC_GREY;
    00177     } else {
    00178       col = sel ? TC_WHITE : TC_BLACK;
    00179     }
    00180     DrawStringTruncated(x + 19, y, STR_7021, col, width - 17);
    00181   }
    00182 };
    00183
    00187 static void PopupMainToolbMenu(Window *w, int widget, StringID string, int count)
    00188 {
    00189   DropDownList *list = new DropDownList();
    00190   for (int i = 0; i < count; i++) {
    00191     list->push_back(new DropDownListStringItem(string + i, i, false));
    00192   }
    00193   ShowDropDownList(w, list, 0, widget, 140, true, true);
    00194   SndPlayFx(SND_15_BEEP);
    00195 }
    00196
    00198 enum {
    00199   CTMN_CLIENT_LIST = -1,
    00200   CTMN_NEW_COMPANY = -2,
    00201   CTMN_SPECTATE    = -3,
    00202 };
    00203
    00207 static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0)
    00208 {
    00209   DropDownList *list = new DropDownList();
    00210
    00211 #ifdef ENABLE_NETWORK
    00212   if (widget == TBN_COMPANIES && _networking) {
    00213     /* Add the client list button for the companies menu */
    00214     list->push_back(new DropDownListStringItem(STR_NETWORK_CLIENT_LIST, CTMN_CLIENT_LIST, false));
    00215
    00216     if (_local_company == COMPANY_SPECTATOR) {
    00217       list->push_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_NEW_COMPANY, CTMN_NEW_COMPANY, NetworkMaxCompaniesReached()));
    00218     } else {
    00219       list->push_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, NetworkMaxSpectatorsReached()));
    00220     }
    00221   }
    00222 #endif /* ENABLE_NETWORK */
    00223
    00224   for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
    00225     if (!IsValidCompanyID(c)) continue;
    00226     list->push_back(new DropDownListCompanyItem(c, false, HasBit(grey, c)));
    00227   }
    00228
    00229   ShowDropDownList(w, list, _local_company == COMPANY_SPECTATOR ? CTMN_CLIENT_LIST : (int)_local_company, widget, 240, true, true);
    00230   SndPlayFx(SND_15_BEEP);
    00231 }
    00232
    00233
    00234 static ToolbarMode _toolbar_mode;
    00235
    00236 static void SelectSignTool()
    00237 {
    00238   if (_cursor.sprite == SPR_CURSOR_SIGN) {
    00239     ResetObjectToPlace();
    00240   } else {
    00241     SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, VHM_RECT, WC_MAIN_TOOLBAR, 0);
    00242     _place_proc = PlaceProc_Sign;
    00243   }
    00244 }
    00245
    00246 /* --- Pausing --- */
    00247
    00248 static void ToolbarPauseClick(Window *w)
    00249 {
    00250   if (_networking && !_network_server) return; // only server can pause the game
    00251
    00252   if (DoCommandP(0, _pause_game ? 0 : 1, 0, CMD_PAUSE)) SndPlayFx(SND_15_BEEP);
    00253 }
    00254
    00255 /* --- Fast forwarding --- */
    00256
    00257 static void ToolbarFastForwardClick(Window *w)
    00258 {
    00259   _fast_forward ^= true;
    00260   SndPlayFx(SND_15_BEEP);
    00261 }
    00262
    00263 /* --- Options button menu --- */
    00264
    00265 enum OptionMenuEntries {
    00266   OME_GAMEOPTIONS,
    00267   OME_DIFFICULTIES,
    00268   OME_SETTINGS,
    00269   OME_NEWGRFSETTINGS,
    00270   OME_TRANSPARENCIES,
    00271   OME_SHOW_TOWNNAMES,
    00272   OME_SHOW_STATIONNAMES,
    00273   OME_SHOW_SIGNS,
    00274   OME_SHOW_WAYPOINTNAMES,
    00275   OME_FULL_ANIMATION,
    00276   OME_FULL_DETAILS,
    00277   OME_TRANSPARENTBUILDINGS,
    00278   OME_SHOW_STATIONSIGNS,
    00279 };
    00280
    00281 static void ToolbarOptionsClick(Window *w)
    00282 {
    00283   DropDownList *list = new DropDownList();
    00284   list->push_back(new DropDownListStringItem(STR_02C4_GAME_OPTIONS,        OME_GAMEOPTIONS, false));
    00285   list->push_back(new DropDownListStringItem(STR_02C6_DIFFICULTY_SETTINGS, OME_DIFFICULTIES, false));
    00286   list->push_back(new DropDownListStringItem(STR_MENU_CONFIG_SETTINGS,      OME_SETTINGS, false));
    00287   list->push_back(new DropDownListStringItem(STR_NEWGRF_SETTINGS,          OME_NEWGRFSETTINGS, false));
    00288   list->push_back(new DropDownListStringItem(STR_TRANSPARENCY_OPTIONS,     OME_TRANSPARENCIES, false));
    00289   list->push_back(new DropDownListItem(-1, false));
    00290   list->push_back(new DropDownListCheckedItem(STR_02CA_TOWN_NAMES_DISPLAYED,    OME_SHOW_TOWNNAMES, false, HasBit(_display_opt, DO_SHOW_TOWN_NAMES)));
    00291   list->push_back(new DropDownListCheckedItem(STR_02CC_STATION_NAMES_DISPLAYED, OME_SHOW_STATIONNAMES, false, HasBit(_display_opt, DO_SHOW_STATION_NAMES)));
    00292   list->push_back(new DropDownListCheckedItem(STR_02CE_SIGNS_DISPLAYED,         OME_SHOW_SIGNS, false, HasBit(_display_opt, DO_SHOW_SIGNS)));
    00293   list->push_back(new DropDownListCheckedItem(STR_WAYPOINTS_DISPLAYED2,         OME_SHOW_WAYPOINTNAMES, false, HasBit(_display_opt, DO_WAYPOINTS)));
    00294   list->push_back(new DropDownListCheckedItem(STR_02D0_FULL_ANIMATION,          OME_FULL_ANIMATION, false, HasBit(_display_opt, DO_FULL_ANIMATION)));
    00295   list->push_back(new DropDownListCheckedItem(STR_02D2_FULL_DETAIL,             OME_FULL_DETAILS, false, HasBit(_display_opt, DO_FULL_DETAIL)));
    00296   list->push_back(new DropDownListCheckedItem(STR_02D4_TRANSPARENT_BUILDINGS,   OME_TRANSPARENTBUILDINGS, false, IsTransparencySet(TO_HOUSES)));
    00297   list->push_back(new DropDownListCheckedItem(STR_TRANSPARENT_SIGNS,            OME_SHOW_STATIONSIGNS, false, IsTransparencySet(TO_SIGNS)));
    00298
    00299   ShowDropDownList(w, list, 0, TBN_SETTINGS, 140, true, true);
    00300   SndPlayFx(SND_15_BEEP);
    00301 }
    00302
    00303 static void MenuClickSettings(int index)
    00304 {
    00305   switch (index) {
    00306     case OME_GAMEOPTIONS:          ShowGameOptions();                              return;
    00307     case OME_DIFFICULTIES:         ShowGameDifficulty();                           return;
    00308     case OME_SETTINGS:             ShowGameSettings();                             return;
    00309     case OME_NEWGRFSETTINGS:       ShowNewGRFSettings(!_networking, true, true, &_grfconfig);   return;
    00310     case OME_TRANSPARENCIES:       ShowTransparencyToolbar();                      break;
    00311
    00312     case OME_SHOW_TOWNNAMES:       ToggleBit(_display_opt, DO_SHOW_TOWN_NAMES);    break;
    00313     case OME_SHOW_STATIONNAMES:    ToggleBit(_display_opt, DO_SHOW_STATION_NAMES); break;
    00314     case OME_SHOW_SIGNS:           ToggleBit(_display_opt, DO_SHOW_SIGNS);         break;
    00315     case OME_SHOW_WAYPOINTNAMES:   ToggleBit(_display_opt, DO_WAYPOINTS);          break;
    00316     case OME_FULL_ANIMATION:       ToggleBit(_display_opt, DO_FULL_ANIMATION);     break;
    00317     case OME_FULL_DETAILS:         ToggleBit(_display_opt, DO_FULL_DETAIL);        break;
    00318     case OME_TRANSPARENTBUILDINGS: ToggleTransparency(TO_HOUSES);                  break;
    00319     case OME_SHOW_STATIONSIGNS:    ToggleTransparency(TO_SIGNS);                   break;
    00320   }
    00321   MarkWholeScreenDirty();
    00322 }
    00323
    00324 /* --- Saving/loading button menu --- */
    00325
    00326 enum SaveLoadEditorMenuEntries {
    00327   SLEME_SAVE_SCENARIO   = 0,
    00328   SLEME_LOAD_SCENARIO,
    00329   SLEME_LOAD_HEIGHTMAP,
    00330   SLEME_EXIT_TOINTRO,
    00331   SLEME_EXIT_GAME       = 5,
    00332   SLEME_MENUCOUNT,
    00333 };
    00334
    00335 enum SaveLoadNormalMenuEntries {
    00336   SLNME_SAVE_GAME   = 0,
    00337   SLNME_LOAD_GAME,
    00338   SLNME_EXIT_TOINTRO,
    00339   SLNME_EXIT_GAME,
    00340   SLNME_MENUCOUNT,
    00341 };
    00342
    00343 static void ToolbarSaveClick(Window *w)
    00344 {
    00345   PopupMainToolbMenu(w, TBN_SAVEGAME, STR_015C_SAVE_GAME, SLNME_MENUCOUNT);
    00346 }
    00347
    00348 static void ToolbarScenSaveOrLoad(Window *w)
    00349 {
    00350   PopupMainToolbMenu(w, TBSE_SAVESCENARIO, STR_0292_SAVE_SCENARIO, SLEME_MENUCOUNT);
    00351 }
    00352
    00353 static void MenuClickSaveLoad(int index = 0)
    00354 {
    00355   if (_game_mode == GM_EDITOR) {
    00356     switch (index) {
    00357       case SLEME_SAVE_SCENARIO:  ShowSaveLoadDialog(SLD_SAVE_SCENARIO);  break;
    00358       case SLEME_LOAD_SCENARIO:  ShowSaveLoadDialog(SLD_LOAD_SCENARIO);  break;
    00359       case SLEME_LOAD_HEIGHTMAP: ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP); break;
    00360       case SLEME_EXIT_TOINTRO:   AskExitToGameMenu();                    break;
    00361       case SLEME_EXIT_GAME:      HandleExitGameRequest();                break;
    00362     }
    00363   } else {
    00364     switch (index) {
    00365       case SLNME_SAVE_GAME:      ShowSaveLoadDialog(SLD_SAVE_GAME); break;
    00366       case SLNME_LOAD_GAME:      ShowSaveLoadDialog(SLD_LOAD_GAME); break;
    00367       case SLNME_EXIT_TOINTRO:   AskExitToGameMenu();               break;
    00368       case SLNME_EXIT_GAME:      HandleExitGameRequest();           break;
    00369     }
    00370   }
    00371 }
    00372
    00373 /* --- Map button menu --- */
    00374
    00375 enum MapMenuEntries {
    00376   MME_SHOW_SMALLMAP        = 0,
    00377   MME_SHOW_EXTRAVIEWPORTS,
    00378   MME_SHOW_SIGNLISTS,
    00379   MME_SHOW_TOWNDIRECTORY,
    00380   MME_MENUCOUNT_NORMAL     = 3,
    00381   MME_MENUCOUNT_EDITOR     = 4,
    00382 };
    00383
    00384 static void ToolbarMapClick(Window *w)
    00385 {
    00386   PopupMainToolbMenu(w, TBN_SMALLMAP, STR_02DE_MAP_OF_WORLD, MME_MENUCOUNT_NORMAL);
    00387 }
    00388
    00389 static void ToolbarScenMapTownDir(Window *w)
    00390 {
    00391   PopupMainToolbMenu(w, TBSE_SMALLMAP, STR_02DE_MAP_OF_WORLD, MME_MENUCOUNT_EDITOR);
    00392 }
    00393
    00394 static void MenuClickMap(int index)
    00395 {
    00396   switch (index) {
    00397     case MME_SHOW_SMALLMAP:       ShowSmallMap();            break;
    00398     case MME_SHOW_EXTRAVIEWPORTS: ShowExtraViewPortWindow(); break;
    00399     case MME_SHOW_SIGNLISTS:      ShowSignList();            break;
    00400     case MME_SHOW_TOWNDIRECTORY:  if (_game_mode == GM_EDITOR) ShowTownDirectory(); break;
    00401   }
    00402 }
    00403
    00404 /* --- Town button menu --- */
    00405
    00406 static void ToolbarTownClick(Window *w)
    00407 {
    00408   PopupMainToolbMenu(w, TBN_TOWNDIRECTORY, STR_02BB_TOWN_DIRECTORY, 1);
    00409 }
    00410
    00411 static void MenuClickTown(int index)
    00412 {
    00413   ShowTownDirectory();
    00414 }
    00415
    00416 /* --- Subidies button menu --- */
    00417
    00418 static void ToolbarSubsidiesClick(Window *w)
    00419 {
    00420   PopupMainToolbMenu(w, TBN_SUBSIDIES, STR_02DD_SUBSIDIES, 1);
    00421 }
    00422
    00423 static void MenuClickSubsidies(int index)
    00424 {
    00425   ShowSubsidiesList();
    00426 }
    00427
    00428 /* --- Stations button menu --- */
    00429
    00430 static void ToolbarStationsClick(Window *w)
    00431 {
    00432   PopupMainCompanyToolbMenu(w, TBN_STATIONS);
    00433 }
    00434
    00435 static void MenuClickStations(int index)
    00436 {
    00437   ShowCompanyStations((CompanyID)index);
    00438 }
    00439
    00440 /* --- Finances button menu --- */
    00441
    00442 static void ToolbarFinancesClick(Window *w)
    00443 {
    00444   PopupMainCompanyToolbMenu(w, TBN_FINANCES);
    00445 }
    00446
    00447 static void MenuClickFinances(int index)
    00448 {
    00449   ShowCompanyFinances((CompanyID)index);
    00450 }
    00451
    00452 /* --- Company's button menu --- */
    00453
    00454 static void ToolbarCompaniesClick(Window *w)
    00455 {
    00456   PopupMainCompanyToolbMenu(w, TBN_COMPANIES);
    00457 }
    00458
    00459 static void MenuClickCompany(int index)
    00460 {
    00461 #ifdef ENABLE_NETWORK
    00462   if (_networking) {
    00463     switch (index) {
    00464       case CTMN_CLIENT_LIST:
    00465         ShowClientList();
    00466         return;
    00467
    00468       case CTMN_NEW_COMPANY:
    00469         if (_network_server) {
    00470           DoCommandP(0, 0, _network_own_client_id, CMD_COMPANY_CTRL);
    00471         } else {
    00472           NetworkSend_Command(0, 0, 0, CMD_COMPANY_CTRL, NULL, NULL);
    00473         }
    00474         return;
    00475
    00476       case CTMN_SPECTATE:
    00477         if (_network_server) {
    00478           NetworkServerDoMove(CLIENT_ID_SERVER, COMPANY_SPECTATOR);
    00479           MarkWholeScreenDirty();
    00480         } else {
    00481           NetworkClientRequestMove(COMPANY_SPECTATOR);
    00482         }
    00483         return;
    00484     }
    00485   }
    00486 #endif /* ENABLE_NETWORK */
    00487   ShowCompany((CompanyID)index);
    00488 }
    00489
    00490 /* --- Graphs button menu --- */
    00491
    00492 static void ToolbarGraphsClick(Window *w)
    00493 {
    00494   PopupMainToolbMenu(w, TBN_GRAPHICS, STR_0154_OPERATING_PROFIT_GRAPH, (_toolbar_mode == TB_NORMAL) ? 6 : 8);
    00495 }
    00496
    00497 static void MenuClickGraphs(int index)
    00498 {
    00499   switch (index) {
    00500     case 0: ShowOperatingProfitGraph();    break;
    00501     case 1: ShowIncomeGraph();             break;
    00502     case 2: ShowDeliveredCargoGraph();     break;
    00503     case 3: ShowPerformanceHistoryGraph(); break;
    00504     case 4: ShowCompanyValueGraph();       break;
    00505     case 5: ShowCargoPaymentRates();       break;
    00506     /* functions for combined graphs/league button */
    00507     case 6: ShowCompanyLeagueTable();      break;
    00508     case 7: ShowPerformanceRatingDetail(); break;
    00509   }
    00510 }
    00511
    00512 /* --- League button menu --- */
    00513
    00514 static void ToolbarLeagueClick(Window *w)
    00515 {
    00516   PopupMainToolbMenu(w, TBN_LEAGUE, STR_015A_COMPANY_LEAGUE_TABLE, 2);
    00517 }
    00518
    00519 static void MenuClickLeague(int index)
    00520 {
    00521   switch (index) {
    00522     case 0: ShowCompanyLeagueTable();      break;
    00523     case 1: ShowPerformanceRatingDetail(); break;
    00524   }
    00525 }
    00526
    00527 /* --- Industries button menu --- */
    00528
    00529 static void ToolbarIndustryClick(Window *w)
    00530 {
    00531   /* Disable build-industry menu if we are a spectator */
    00532   PopupMainToolbMenu(w, TBN_INDUSTRIES, STR_INDUSTRY_DIR, (_local_company == COMPANY_SPECTATOR) ? 1 : 2);
    00533 }
    00534
    00535 static void MenuClickIndustry(int index)
    00536 {
    00537   switch (index) {
    00538     case 0: ShowIndustryDirectory();   break;
    00539     case 1: ShowBuildIndustryWindow(); break;
    00540   }
    00541 }
    00542
    00543 /* --- Trains button menu + 1 helper function for all vehicles. --- */
    00544
    00545 static void ToolbarVehicleClick(Window *w, VehicleType veh)
    00546 {
    00547   const Vehicle *v;
    00548   int dis = ~0;
    00549
    00550   FOR_ALL_VEHICLES(v) {
    00551     if (v->type == veh && v->IsPrimaryVehicle()) ClrBit(dis, v->owner);
    00552   }
    00553   PopupMainCompanyToolbMenu(w, TBN_VEHICLESTART + veh, dis);
    00554 }
    00555
    00556
    00557 static void ToolbarTrainClick(Window *w)
    00558 {
    00559   ToolbarVehicleClick(w, VEH_TRAIN);
    00560 }
    00561
    00562 static void MenuClickShowTrains(int index)
    00563 {
    00564   ShowVehicleListWindow((CompanyID)index, VEH_TRAIN);
    00565 }
    00566
    00567 /* --- Road vehicle button menu --- */
    00568
    00569 static void ToolbarRoadClick(Window *w)
    00570 {
    00571   ToolbarVehicleClick(w, VEH_ROAD);
    00572 }
    00573
    00574 static void MenuClickShowRoad(int index)
    00575 {
    00576   ShowVehicleListWindow((CompanyID)index, VEH_ROAD);
    00577 }
    00578
    00579 /* --- Ship button menu --- */
    00580
    00581 static void ToolbarShipClick(Window *w)
    00582 {
    00583   ToolbarVehicleClick(w, VEH_SHIP);
    00584 }
    00585
    00586 static void MenuClickShowShips(int index)
    00587 {
    00588   ShowVehicleListWindow((CompanyID)index, VEH_SHIP);
    00589 }
    00590
    00591 /* --- Aircraft button menu --- */
    00592
    00593 static void ToolbarAirClick(Window *w)
    00594 {
    00595   ToolbarVehicleClick(w, VEH_AIRCRAFT);
    00596 }
    00597
    00598 static void MenuClickShowAir(int index)
    00599 {
    00600   ShowVehicleListWindow((CompanyID)index, VEH_AIRCRAFT);
    00601 }
    00602
    00603 /* --- Zoom in button --- */
    00604
    00605 static void ToolbarZoomInClick(Window *w)
    00606 {
    00607   if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
    00608     w->HandleButtonClick((_game_mode == GM_EDITOR) ? (byte)TBSE_ZOOMIN : (byte)TBN_ZOOMIN);
    00609     SndPlayFx(SND_15_BEEP);
    00610   }
    00611 }
    00612
    00613 /* --- Zoom out button --- */
    00614
    00615 static void ToolbarZoomOutClick(Window *w)
    00616 {
    00617   if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) {
    00618     w->HandleButtonClick((_game_mode == GM_EDITOR) ? (byte)TBSE_ZOOMOUT : (byte)TBN_ZOOMOUT);
    00619     SndPlayFx(SND_15_BEEP);
    00620   }
    00621 }
    00622
    00623 /* --- Rail button menu --- */
    00624
    00625 static void ToolbarBuildRailClick(Window *w)
    00626 {
    00627   const Company *c = GetCompany(_local_company);
    00628   DropDownList *list = new DropDownList();
    00629   for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
    00630     const RailtypeInfo *rti = GetRailTypeInfo(rt);
    00631     /* Skip rail type if it has no label */
    00632     if (rti->label == 0) continue;
    00633     list->push_back(new DropDownListStringItem(rti->strings.menu_text, rt, !HasBit(c->avail_railtypes, rt)));
    00634   }
    00635   ShowDropDownList(w, list, _last_built_railtype, TBN_RAILS, 140, true, true);
    00636   SndPlayFx(SND_15_BEEP);
    00637 }
    00638
    00639 static void MenuClickBuildRail(int index)
    00640 {
    00641   _last_built_railtype = (RailType)index;
    00642   ShowBuildRailToolbar(_last_built_railtype, -1);
    00643 }
    00644
    00645 /* --- Road button menu --- */
    00646
    00647 static void ToolbarBuildRoadClick(Window *w)
    00648 {
    00649   const Company *c = GetCompany(_local_company);
    00650   DropDownList *list = new DropDownList();
    00651   for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
    00652     /* The standard road button is *always* available */
    00653     list->push_back(new DropDownListStringItem(STR_180A_ROAD_CONSTRUCTION + rt, rt, !(HasBit(c->avail_roadtypes, rt) || rt == ROADTYPE_ROAD)));
    00654   }
    00655   ShowDropDownList(w, list, _last_built_roadtype, TBN_ROADS, 140, true, true);
    00656   SndPlayFx(SND_15_BEEP);
    00657 }
    00658
    00659 static void MenuClickBuildRoad(int index)
    00660 {
    00661   _last_built_roadtype = (RoadType)index;
    00662   ShowBuildRoadToolbar(_last_built_roadtype);
    00663 }
    00664
    00665 /* --- Water button menu --- */
    00666
    00667 static void ToolbarBuildWaterClick(Window *w)
    00668 {
    00669   PopupMainToolbMenu(w, TBN_WATER, STR_9800_WATERWAYS_CONSTRUCTION, 1);
    00670 }
    00671
    00672 static void MenuClickBuildWater(int index)
    00673 {
    00674   ShowBuildDocksToolbar();
    00675 }
    00676
    00677 /* --- Airport button menu --- */
    00678
    00679 static void ToolbarBuildAirClick(Window *w)
    00680 {
    00681   PopupMainToolbMenu(w, TBN_AIR, STR_A01D_AIRPORT_CONSTRUCTION, 1);
    00682 }
    00683
    00684 static void MenuClickBuildAir(int index)
    00685 {
    00686   ShowBuildAirToolbar();
    00687 }
    00688
    00689 /* --- Forest button menu --- */
    00690
    00691 static void ToolbarForestClick(Window *w)
    00692 {
    00693   PopupMainToolbMenu(w, TBN_LANDSCAPE, STR_LANDSCAPING, 3);
    00694 }
    00695
    00696 static void MenuClickForest(int index)
    00697 {
    00698   switch (index) {
    00699     case 0: ShowTerraformToolbar();  break;
    00700     case 1: ShowBuildTreesToolbar(); break;
    00701     case 2: SelectSignTool();        break;
    00702   }
    00703 }
    00704
    00705 /* --- Music button menu --- */
    00706
    00707 static void ToolbarMusicClick(Window *w)
    00708 {
    00709   PopupMainToolbMenu(w, TBN_MUSICSOUND, STR_01D3_SOUND_MUSIC, 1);
    00710 }
    00711
    00712 static void MenuClickMusicWindow(int index)
    00713 {
    00714   ShowMusicWindow();
    00715 }
    00716
    00717 /* --- Newspaper button menu --- */
    00718
    00719 static void ToolbarNewspaperClick(Window *w)
    00720 {
    00721   PopupMainToolbMenu(w, TBN_NEWSREPORT, STR_0200_LAST_MESSAGE_NEWS_REPORT, 3);
    00722 }
    00723
    00724 static void MenuClickNewspaper(int index)
    00725 {
    00726   switch (index) {
    00727     case 0: ShowLastNewsMessage(); break;
    00728     case 1: ShowMessageOptions();  break;
    00729     case 2: ShowMessageHistory();  break;
    00730   }
    00731 }
    00732
    00733 /* --- Help button menu --- */
    00734
    00735 static void ToolbarHelpClick(Window *w)
    00736 {
    00737   PopupMainToolbMenu(w, TBN_HELP, STR_02D5_LAND_BLOCK_INFO, 7);
    00738 }
    00739
    00740 static void MenuClickSmallScreenshot()
    00741 {
    00742   SetScreenshotType(SC_VIEWPORT);
    00743 }
    00744
    00745 static void MenuClickWorldScreenshot()
    00746 {
    00747   SetScreenshotType(SC_WORLD);
    00748 }
    00749
    00750 static void MenuClickHelp(int index)
    00751 {
    00752   switch (index) {
    00753     case 0: PlaceLandBlockInfo();       break;
    00754     case 2: IConsoleSwitch();           break;
    00755     case 3: ShowAIDebugWindow();        break;
    00756     case 4: MenuClickSmallScreenshot(); break;
    00757     case 5: MenuClickWorldScreenshot(); break;
    00758     case 6: ShowAboutWindow();          break;
    00759   }
    00760 }
    00761
    00762 /* --- Switch toolbar button --- */
    00763
    00764 static void ToolbarSwitchClick(Window *w)
    00765 {
    00766   if (_toolbar_mode != TB_LOWER) {
    00767     _toolbar_mode = TB_LOWER;
    00768   } else {
    00769     _toolbar_mode = TB_UPPER;
    00770   }
    00771
    00772   SplitToolbar(w);
    00773   w->HandleButtonClick(TBN_SWITCHBAR);
    00774   SetWindowDirty(w);
    00775   SndPlayFx(SND_15_BEEP);
    00776 }
    00777
    00778 /* --- Scenario editor specific handlers. */
    00779
    00780 static void ToolbarScenDateBackward(Window *w)
    00781 {
    00782   /* don't allow too fast scrolling */
    00783   if ((w->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
    00784     w->HandleButtonClick(TBSE_DATEBACKWARD);
    00785     w->SetDirty();
    00786
    00787     _settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year - 1, MIN_YEAR, MAX_YEAR);
    00788     SetDate(ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
    00789   }
    00790   _left_button_clicked = false;
    00791 }
    00792
    00793 static void ToolbarScenDateForward(Window *w)
    00794 {
    00795   /* don't allow too fast scrolling */
    00796   if ((w->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
    00797     w->HandleButtonClick(TBSE_DATEFORWARD);
    00798     w->SetDirty();
    00799
    00800     _settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + 1, MIN_YEAR, MAX_YEAR);
    00801     SetDate(ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
    00802   }
    00803   _left_button_clicked = false;
    00804 }
    00805
    00806 static void ToolbarScenGenLand(Window *w)
    00807 {
    00808   w->HandleButtonClick(TBSE_LANDGENERATE);
    00809   SndPlayFx(SND_15_BEEP);
    00810
    00811   ShowEditorTerraformToolbar();
    00812 }
    00813
    00814
    00815 static void ToolbarScenGenTown(Window *w)
    00816 {
    00817   w->HandleButtonClick(TBSE_TOWNGENERATE);
    00818   SndPlayFx(SND_15_BEEP);
    00819   ShowBuildTownWindow();
    00820 }
    00821
    00822 static void ToolbarScenGenIndustry(Window *w)
    00823 {
    00824   w->HandleButtonClick(TBSE_INDUSTRYGENERATE);
    00825   SndPlayFx(SND_15_BEEP);
    00826   ShowBuildIndustryWindow();
    00827 }
    00828
    00829 static void ToolbarScenBuildRoad(Window *w)
    00830 {
    00831   w->HandleButtonClick(TBSE_BUILDROAD);
    00832   SndPlayFx(SND_15_BEEP);
    00833   ShowBuildRoadScenToolbar();
    00834 }
    00835
    00836 static void ToolbarScenBuildDocks(Window *w)
    00837 {
    00838   w->HandleButtonClick(TBSE_BUILDDOCKS);
    00839   SndPlayFx(SND_15_BEEP);
    00840   ShowBuildDocksScenToolbar();
    00841 }
    00842
    00843 static void ToolbarScenPlantTrees(Window *w)
    00844 {
    00845   w->HandleButtonClick(TBSE_PLANTTREES);
    00846   SndPlayFx(SND_15_BEEP);
    00847   ShowBuildTreesToolbar();
    00848 }
    00849
    00850 static void ToolbarScenPlaceSign(Window *w)
    00851 {
    00852   w->HandleButtonClick(TBSE_PLACESIGNS);
    00853   SndPlayFx(SND_15_BEEP);
    00854   SelectSignTool();
    00855 }
    00856
    00857 static void ToolbarBtn_NULL(Window *w)
    00858 {
    00859 }
    00860
    00861 /* --- Resizing the toolbar */
    00862
    00863 static void ResizeToolbar(Window *w)
    00864 {
    00865   /* There are 27 buttons plus some spacings if the space allows it */
    00866   uint button_width;
    00867   uint spacing;
    00868   uint widgetcount = w->widget_count - 1;
    00869
    00870   if (w->width >= (int)widgetcount * TBP_BUTTONWIDTH) {
    00871     button_width = TBP_BUTTONWIDTH;
    00872     spacing = w->width - (widgetcount * button_width);
    00873   } else {
    00874     button_width = w->width / widgetcount;
    00875     spacing = 0;
    00876   }
    00877
    00878   static const uint extra_spacing_at[] = { 4, 8, 13, 17, 19, 24, 0 };
    00879   uint i = 0;
    00880   for (uint x = 0, j = 0; i < widgetcount; i++) {
    00881     if (extra_spacing_at[j] == i) {
    00882       j++;
    00883       uint add = spacing / (lengthof(extra_spacing_at) - j);
    00884       spacing -= add;
    00885       x += add;
    00886     }
    00887
    00888     w->widget[i].type = WWT_IMGBTN;
    00889     w->widget[i].left = x;
    00890     x += (spacing != 0) ? button_width : (w->width - x) / (widgetcount - i);
    00891     w->widget[i].right = x - 1;
    00892   }
    00893
    00894   w->widget[i].type = WWT_EMPTY; // i now points to the last item
    00895   _toolbar_mode = TB_NORMAL;
    00896 }
    00897
    00898 /* --- Split the toolbar */
    00899
    00900 static void SplitToolbar(Window *w)
    00901 {
    00902   static const byte arrange14[] = {
    00903     0,  1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 27,
    00904     2,  3,  4,  5,  6,  7,  8,  9, 10, 12, 24, 25, 26, 27,
    00905   };
    00906   static const byte arrange15[] = {
    00907     0,  1,  4, 13, 14, 15, 16, 19, 20, 21, 22, 23, 17, 18, 27,
    00908     0,  2,  4,  3,  5,  6,  7,  8,  9, 10, 12, 24, 25, 26, 27,
    00909   };
    00910   static const byte arrange16[] = {
    00911     0,  1,  2,  4, 13, 14, 15, 16, 19, 20, 21, 22, 23, 17, 18, 27,
    00912     0,  1,  3,  5,  6,  7,  8,  9, 10, 12, 24, 25, 26, 17, 18, 27,
    00913   };
    00914   static const byte arrange17[] = {
    00915     0,  1,  2,  4,  6, 13, 14, 15, 16, 19, 20, 21, 22, 23, 17, 18, 27,
    00916     0,  1,  3,  4,  6,  5,  7,  8,  9, 10, 12, 24, 25, 26, 17, 18, 27,
    00917   };
    00918   static const byte arrange18[] = {
    00919     0,  1,  2,  4,  5,  6,  7,  8,  9, 12, 19, 20, 21, 22, 23, 17, 18, 27,
    00920     0,  1,  3,  4,  5,  6,  7, 10, 13, 14, 15, 16, 24, 25, 26, 17, 18, 27,
    00921   };
    00922   static const byte arrange19[] = {
    00923     0,  1,  2,  4,  5,  6, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 17, 18, 27,
    00924     0,  1,  3,  4,  7,  8,  9, 10, 12, 25, 19, 20, 21, 22, 23, 26, 17, 18, 27,
    00925   };
    00926
    00927   static const byte *arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19 };
    00928
    00929   uint max_icons = max(TBP_TOOLBAR_MINBUTTON, (ToolBarProperties)((w->width + TBP_BUTTONWIDTH / 2) / TBP_BUTTONWIDTH));
    00930
    00931   assert(max_icons >= TBP_TOOLBAR_MINBUTTON && max_icons <= TBP_NORMAL_MAXBUTTON);
    00932
    00933   /* first hide all icons */
    00934   for (uint i = 0; i < w->widget_count - 1; i++) {
    00935     w->widget[i].type = WWT_EMPTY;
    00936   }
    00937
    00938   /* now activate them all on their proper positions */
    00939   for (uint i = 0, x = 0, n = max_icons - TBP_TOOLBAR_MINBUTTON; i < max_icons; i++) {
    00940     uint icon = arrangements[n][i + ((_toolbar_mode == TB_LOWER) ? max_icons : 0)];
    00941     w->widget[icon].type = WWT_IMGBTN;
    00942     w->widget[icon].left = x;
    00943     x += (w->width - x) / (max_icons - i);
    00944     w->widget[icon].right = x - 1;
    00945   }
    00946 }
    00947
    00948 typedef void MenuClickedProc(int index);
    00949
    00950 static MenuClickedProc * const _menu_clicked_procs[] = {
    00951   NULL,                 // 0
    00952   NULL,                 // 1
    00953   MenuClickSettings,    // 2
    00954   MenuClickSaveLoad,    // 3
    00955   MenuClickMap,         // 4
    00956   MenuClickTown,        // 5
    00957   MenuClickSubsidies,   // 6
    00958   MenuClickStations,    // 7
    00959   MenuClickFinances,    // 8
    00960   MenuClickCompany,     // 9
    00961   MenuClickGraphs,      // 10
    00962   MenuClickLeague,      // 11
    00963   MenuClickIndustry,    // 12
    00964   MenuClickShowTrains,  // 13
    00965   MenuClickShowRoad,    // 14
    00966   MenuClickShowShips,   // 15
    00967   MenuClickShowAir,     // 16
    00968   MenuClickMap,         // 17
    00969   NULL,                 // 18
    00970   MenuClickBuildRail,   // 19
    00971   MenuClickBuildRoad,   // 20
    00972   MenuClickBuildWater,  // 21
    00973   MenuClickBuildAir,    // 22
    00974   MenuClickForest,      // 23
    00975   MenuClickMusicWindow, // 24
    00976   MenuClickNewspaper,   // 25
    00977   MenuClickHelp,        // 26
    00978 };
    00979
    00980 /* --- Toolbar handling for the 'normal' case */
    00981
    00982 typedef void ToolbarButtonProc(Window *w);
    00983
    00984 static ToolbarButtonProc * const _toolbar_button_procs[] = {
    00985   ToolbarPauseClick,
    00986   ToolbarFastForwardClick,
    00987   ToolbarOptionsClick,
    00988   ToolbarSaveClick,
    00989   ToolbarMapClick,
    00990   ToolbarTownClick,
    00991   ToolbarSubsidiesClick,
    00992   ToolbarStationsClick,
    00993   ToolbarFinancesClick,
    00994   ToolbarCompaniesClick,
    00995   ToolbarGraphsClick,
    00996   ToolbarLeagueClick,
    00997   ToolbarIndustryClick,
    00998   ToolbarTrainClick,
    00999   ToolbarRoadClick,
    01000   ToolbarShipClick,
    01001   ToolbarAirClick,
    01002   ToolbarZoomInClick,
    01003   ToolbarZoomOutClick,
    01004   ToolbarBuildRailClick,
    01005   ToolbarBuildRoadClick,
    01006   ToolbarBuildWaterClick,
    01007   ToolbarBuildAirClick,
    01008   ToolbarForestClick,
    01009   ToolbarMusicClick,
    01010   ToolbarNewspaperClick,
    01011   ToolbarHelpClick,
    01012   ToolbarSwitchClick,
    01013 };
    01014
    01015 struct MainToolbarWindow : Window {
    01016   MainToolbarWindow(const WindowDesc *desc) : Window(desc)
    01017   {
    01018     this->SetWidgetDisabledState(TBN_PAUSE, _networking && !_network_server); // if not server, disable pause button
    01019     this->SetWidgetDisabledState(TBN_FASTFORWARD, _networking); // if networking, disable fast-forward button
    01020
    01021     CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
    01022
    01023     this->FindWindowPlacementAndResize(desc);
    01024     PositionMainToolbar(this);
    01025     DoZoomInOutWindow(ZOOM_NONE, this);
    01026   }
    01027
    01028   virtual void OnPaint()
    01029   {
    01030     /* Draw brown-red toolbar bg. */
    01031     GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB2);
    01032     GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB4, FILLRECT_CHECKER);
    01033
    01034     /* If spectator, disable all construction buttons
    01035      * ie : Build road, rail, ships, airports and landscaping
    01036      * Since enabled state is the default, just disable when needed */
    01037     this->SetWidgetsDisabledState(_local_company == COMPANY_SPECTATOR, TBN_RAILS, TBN_ROADS, TBN_WATER, TBN_AIR, TBN_LANDSCAPE, WIDGET_LIST_END);
    01038     /* disable company list drop downs, if there are no companies */
    01039     this->SetWidgetsDisabledState(ActiveCompanyCount() == TBN_PAUSE, TBN_STATIONS, TBN_FINANCES, TBN_TRAINS, TBN_ROADVEHS, TBN_SHIPS, TBN_AIRCRAFTS, WIDGET_LIST_END);
    01040
    01041     this->SetWidgetDisabledState(TBN_RAILS, !CanBuildVehicleInfrastructure(VEH_TRAIN));
    01042     this->SetWidgetDisabledState(TBN_AIR, !CanBuildVehicleInfrastructure(VEH_AIRCRAFT));
    01043
    01044     this->DrawWidgets();
    01045   }
    01046
    01047   virtual void OnClick(Point pt, int widget)
    01048   {
    01049     if (_game_mode != GM_MENU && !this->IsWidgetDisabled(widget)) _toolbar_button_procs[widget](this);
    01050   }
    01051
    01052   virtual void OnDropdownSelect(int widget, int index)
    01053   {
    01054     _menu_clicked_procs[widget](index);
    01055   }
    01056
    01057   virtual EventState OnKeyPress(uint16 key, uint16 keycode)
    01058   {
    01059     switch (keycode) {
    01060       case WKC_F1: case WKC_PAUSE: ToolbarPauseClick(this); break;
    01061       case WKC_F2: ShowGameOptions(); break;
    01062       case WKC_F3: MenuClickSaveLoad(); break;
    01063       case WKC_F4: ShowSmallMap(); break;
    01064       case WKC_F5: ShowTownDirectory(); break;
    01065       case WKC_F6: ShowSubsidiesList(); break;
    01066       case WKC_F7: ShowCompanyStations(_local_company); break;
    01067       case WKC_F8: ShowCompanyFinances(_local_company); break;
    01068       case WKC_F9: ShowCompany(_local_company); break;
    01069       case WKC_F10: ShowOperatingProfitGraph(); break;
    01070       case WKC_F11: ShowCompanyLeagueTable(); break;
    01071       case WKC_F12: ShowBuildIndustryWindow(); break;
    01072       case WKC_SHIFT | WKC_F1: ShowVehicleListWindow(_local_company, VEH_TRAIN); break;
    01073       case WKC_SHIFT | WKC_F2: ShowVehicleListWindow(_local_company, VEH_ROAD); break;
    01074       case WKC_SHIFT | WKC_F3: ShowVehicleListWindow(_local_company, VEH_SHIP); break;
    01075       case WKC_SHIFT | WKC_F4: ShowVehicleListWindow(_local_company, VEH_AIRCRAFT); break;
    01076       case WKC_NUM_PLUS: // Fall through
    01077       case WKC_EQUALS: // Fall through
    01078       case WKC_SHIFT | WKC_EQUALS: // Fall through
    01079       case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(this); break;
    01080       case WKC_NUM_MINUS: // Fall through
    01081       case WKC_MINUS: // Fall through
    01082       case WKC_SHIFT | WKC_MINUS: // Fall through
    01083       case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(this); break;
    01084       case WKC_SHIFT | WKC_F7: if (CanBuildVehicleInfrastructure(VEH_TRAIN)) ShowBuildRailToolbar(_last_built_railtype, -1); break;
    01085       case WKC_SHIFT | WKC_F8: ShowBuildRoadToolbar(_last_built_roadtype); break;
    01086       case WKC_SHIFT | WKC_F9: ShowBuildDocksToolbar(); break;
    01087       case WKC_SHIFT | WKC_F10: if (CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) ShowBuildAirToolbar(); break;
    01088       case WKC_SHIFT | WKC_F11: ShowBuildTreesToolbar(); break;
    01089       case WKC_SHIFT | WKC_F12: ShowMusicWindow(); break;
    01090       case WKC_CTRL  | 'S': MenuClickSmallScreenshot(); break;
    01091       case WKC_CTRL  | 'G': MenuClickWorldScreenshot(); break;
    01092       case WKC_CTRL | WKC_ALT | 'C': if (!_networking) ShowCheatWindow(); break;
    01093       case 'A': if (CanBuildVehicleInfrastructure(VEH_TRAIN)) ShowBuildRailToolbar(_last_built_railtype, 4); break; // Invoke Autorail
    01094       case 'L': ShowTerraformToolbar(); break;
    01095       case 'M': ShowSmallMap(); break;
    01096       case 'V': ShowExtraViewPortWindow(); break;
    01097       default: return ES_NOT_HANDLED;
    01098     }
    01099     return ES_HANDLED;
    01100   }
    01101
    01102   virtual void OnPlaceObject(Point pt, TileIndex tile)
    01103   {
    01104     _place_proc(tile);
    01105   }
    01106
    01107   virtual void OnTick()
    01108   {
    01109     if (this->IsWidgetLowered(TBN_PAUSE) != !!_pause_game) {
    01110       this->ToggleWidgetLoweredState(TBN_PAUSE);
    01111       this->InvalidateWidget(TBN_PAUSE);
    01112     }
    01113
    01114     if (this->IsWidgetLowered(TBN_FASTFORWARD) != !!_fast_forward) {
    01115       this->ToggleWidgetLoweredState(TBN_FASTFORWARD);
    01116       this->InvalidateWidget(TBN_FASTFORWARD);
    01117     }
    01118   }
    01119
    01120   virtual void OnResize(Point new_size, Point delta)
    01121   {
    01122     if (this->width <= TBP_NORMAL_MAXBUTTON * TBP_BUTTONWIDTH) {
    01123       SplitToolbar(this);
    01124     } else {
    01125       ResizeToolbar(this);
    01126     }
    01127   }
    01128
    01129   virtual void OnTimeout()
    01130   {
    01131     for (uint i = TBN_SETTINGS; i < this->widget_count - 1; i++) {
    01132       if (this->IsWidgetLowered(i)) {
    01133         this->RaiseWidget(i);
    01134         this->InvalidateWidget(i);
    01135       }
    01136     }
    01137   }
    01138
    01139   virtual void OnInvalidateData(int data)
    01140   {
    01141     if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, TBN_ZOOMIN, TBN_ZOOMOUT);
    01142   }
    01143 };
    01144
    01145 static const Widget _toolb_normal_widgets[] = {
    01146 {     WWT_IMGBTN,   RESIZE_LEFT,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_PAUSE,           STR_0171_PAUSE_GAME},               // TBN_PAUSE
    01147 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_FASTFORWARD,     STR_FAST_FORWARD},                  // TBN_FASTFORWARD
    01148 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_SETTINGS,        STR_0187_OPTIONS},                  // TBN_SETTINGS
    01149 {   WWT_IMGBTN_2,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_SAVE,            STR_0172_SAVE_GAME_ABANDON_GAME},   // TBN_SAVEGAME
    01150
    01151 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_SMALLMAP,        STR_0174_DISPLAY_MAP},              // TBN_SMALLMAP
    01152 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_TOWN,            STR_0176_DISPLAY_TOWN_DIRECTORY},   // TBN_TOWNDIRECTORY
    01153 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_SUBSIDIES,       STR_02DC_DISPLAY_SUBSIDIES},        // TBN_SUBSIDIES
    01154 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_COMPANY_LIST,    STR_0173_DISPLAY_LIST_OF_COMPANY},  // TBN_STATIONS
    01155
    01156 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_COMPANY_FINANCE, STR_0177_DISPLAY_COMPANY_FINANCES}, // TBN_FINANCES
    01157 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_COMPANY_GENERAL, STR_0178_DISPLAY_COMPANY_GENERAL},  // TBN_COMPANIES
    01158 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_GRAPHS,          STR_0179_DISPLAY_GRAPHS},           // TBN_GRAPHICS
    01159 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_COMPANY_LEAGUE,  STR_017A_DISPLAY_COMPANY_LEAGUE},   // TBN_LEAGUE
    01160 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_INDUSTRY,        STR_0312_FUND_CONSTRUCTION_OF_NEW}, // TBN_INDUSTRIES
    01161
    01162 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_TRAINLIST,       STR_017B_DISPLAY_LIST_OF_COMPANY},  // TBN_TRAINS
    01163 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_TRUCKLIST,       STR_017C_DISPLAY_LIST_OF_COMPANY},  // TBN_ROADVEHS
    01164 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_SHIPLIST,        STR_017D_DISPLAY_LIST_OF_COMPANY},  // TBN_SHIPS
    01165 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_AIRPLANESLIST,   STR_017E_DISPLAY_LIST_OF_COMPANY},  // TBN_AIRCRAFTS
    01166
    01167 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_ZOOMIN,          STR_017F_ZOOM_THE_VIEW_IN},         // TBN_ZOOMIN
    01168 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_ZOOMOUT,         STR_0180_ZOOM_THE_VIEW_OUT},        // TBN_ZOOMOUT
    01169
    01170 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_BUILDRAIL,       STR_0181_BUILD_RAILROAD_TRACK},     // TBN_RAILS
    01171 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_BUILDROAD,       STR_0182_BUILD_ROADS},              // TBN_ROADS
    01172 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_BUILDWATER,      STR_0183_BUILD_SHIP_DOCKS},         // TBN_WATER
    01173 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_BUILDAIR,        STR_0184_BUILD_AIRPORTS},           // TBN_AIR
    01174 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_LANDSCAPING,     STR_LANDSCAPING_TOOLBAR_TIP},       // TBN_LANDSCAPE tree icon is SPR_IMG_PLANTTREES
    01175
    01176 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_MUSIC,           STR_01D4_SHOW_SOUND_MUSIC_WINDOW},  // TBN_MUSICSOUND
    01177 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_MESSAGES,        STR_0203_SHOW_LAST_MESSAGE_NEWS},   // TBN_NEWSREPORT
    01178 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_QUERY,           STR_0186_LAND_BLOCK_INFORMATION},   // TBN_HELP
    01179 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_SWITCH_TOOLBAR,      STR_EMPTY},                         // TBN_SWITCHBAR
    01180 {   WIDGETS_END},
    01181 };
    01182
    01183 static const WindowDesc _toolb_normal_desc(
    01184   0, 0, 0, TBP_BUTTONHEIGHT, 640, TBP_BUTTONHEIGHT,
    01185   WC_MAIN_TOOLBAR, WC_NONE,
    01186   WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_NO_FOCUS,
    01187   _toolb_normal_widgets
    01188 );
    01189
    01190
    01191 /* --- Toolbar handling for the scenario editor */
    01192
    01193 static ToolbarButtonProc * const _scen_toolbar_button_procs[] = {
    01194   ToolbarPauseClick,
    01195   ToolbarFastForwardClick,
    01196   ToolbarOptionsClick,
    01197   ToolbarScenSaveOrLoad,
    01198   ToolbarBtn_NULL,
    01199   ToolbarBtn_NULL,
    01200   ToolbarScenDateBackward,
    01201   ToolbarScenDateForward,
    01202   ToolbarScenMapTownDir,
    01203   ToolbarZoomInClick,
    01204   ToolbarZoomOutClick,
    01205   ToolbarScenGenLand,
    01206   ToolbarScenGenTown,
    01207   ToolbarScenGenIndustry,
    01208   ToolbarScenBuildRoad,
    01209   ToolbarScenBuildDocks,
    01210   ToolbarScenPlantTrees,
    01211   ToolbarScenPlaceSign,
    01212   NULL,
    01213   NULL,
    01214   NULL,
    01215   NULL,
    01216   NULL,
    01217   NULL,
    01218   ToolbarMusicClick,
    01219   NULL,
    01220   ToolbarHelpClick,
    01221 };
    01222
    01223 struct ScenarioEditorToolbarWindow : Window {
    01224 public:
    01225   ScenarioEditorToolbarWindow(const WindowDesc *desc) : Window(desc)
    01226   {
    01227     CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
    01228
    01229     this->FindWindowPlacementAndResize(desc);
    01230     PositionMainToolbar(this);
    01231     DoZoomInOutWindow(ZOOM_NONE, this);
    01232   }
    01233
    01234   virtual void OnPaint()
    01235   {
    01236     this->SetWidgetDisabledState(TBSE_DATEBACKWARD, _settings_newgame.game_creation.starting_year <= MIN_YEAR);
    01237     this->SetWidgetDisabledState(TBSE_DATEFORWARD, _settings_newgame.game_creation.starting_year >= MAX_YEAR);
    01238
    01239     /* Draw brown-red toolbar bg. */
    01240     GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB2);
    01241     GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB4, FILLRECT_CHECKER);
    01242
    01243     this->DrawWidgets();
    01244
    01245     SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
    01246     DrawStringCenteredTruncated(this->widget[TBSE_DATEBACKWARD].right, this->widget[TBSE_DATEFORWARD].left, 6, STR_00AF, TC_FROMSTRING);
    01247
    01248     /* We hide this panel when the toolbar space gets too small */
    01249     const Widget *panel = &this->widget[TBSE_SPACERPANEL];
    01250     if (panel->left != panel->right) {
    01251       DrawStringCenteredTruncated(panel->left + 1, panel->right - 1,  1, STR_0221_OPENTTD, TC_FROMSTRING);
    01252       DrawStringCenteredTruncated(panel->left + 1, panel->right - 1, 11, STR_0222_SCENARIO_EDITOR, TC_FROMSTRING);
    01253     }
    01254   }
    01255
    01256   virtual void OnClick(Point pt, int widget)
    01257   {
    01258     if (_game_mode == GM_MENU) return;
    01259     _scen_toolbar_button_procs[widget](this);
    01260   }
    01261
    01262   virtual void OnDropdownSelect(int widget, int index)
    01263   {
    01264     /* The map button is in a different location on the scenario
    01265      * editor toolbar, so we need to adjust for it. */
    01266     if (widget == TBSE_SMALLMAP) widget = TBN_SMALLMAP;
    01267     _menu_clicked_procs[widget](index);
    01268     SndPlayFx(SND_15_BEEP);
    01269   }
    01270
    01271   virtual EventState OnKeyPress(uint16 key, uint16 keycode)
    01272   {
    01273     switch (keycode) {
    01274       case WKC_F1: case WKC_PAUSE: ToolbarPauseClick(this); break;
    01275       case WKC_F2: ShowGameOptions(); break;
    01276       case WKC_F3: MenuClickSaveLoad(); break;
    01277       case WKC_F4: ToolbarScenGenLand(this); break;
    01278       case WKC_F5: ToolbarScenGenTown(this); break;
    01279       case WKC_F6: ToolbarScenGenIndustry(this); break;
    01280       case WKC_F7: ToolbarScenBuildRoad(this); break;
    01281       case WKC_F8: ToolbarScenBuildDocks(this); break;
    01282       case WKC_F9: ToolbarScenPlantTrees(this); break;
    01283       case WKC_F10: ToolbarScenPlaceSign(this); break;
    01284       case WKC_F11: ShowMusicWindow(); break;
    01285       case WKC_F12: PlaceLandBlockInfo(); break;
    01286       case WKC_CTRL | 'S': MenuClickSmallScreenshot(); break;
    01287       case WKC_CTRL | 'G': MenuClickWorldScreenshot(); break;
    01288
    01289       /* those following are all fall through */
    01290       case WKC_NUM_PLUS:
    01291       case WKC_EQUALS:
    01292       case WKC_SHIFT | WKC_EQUALS:
    01293       case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(this); break;
    01294
    01295       /* those following are all fall through */
    01296       case WKC_NUM_MINUS:
    01297       case WKC_MINUS:
    01298       case WKC_SHIFT | WKC_MINUS:
    01299       case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(this); break;
    01300
    01301       case 'L': ShowEditorTerraformToolbar(); break;
    01302       case 'M': ShowSmallMap(); break;
    01303       case 'V': ShowExtraViewPortWindow(); break;
    01304       default: return ES_NOT_HANDLED;
    01305     }
    01306     return ES_HANDLED;
    01307   }
    01308
    01309   virtual void OnPlaceObject(Point pt, TileIndex tile)
    01310   {
    01311     _place_proc(tile);
    01312   }
    01313
    01314   virtual void OnResize(Point new_size, Point delta)
    01315   {
    01316     /* There are 16 buttons plus some spacings if the space allows it.
    01317      * Furthermore there are two panels of which one is non - essential
    01318      * and that one can be removed if the space is too small. */
    01319     uint buttons_width;
    01320     uint spacing;
    01321
    01322     static const int normal_min_width = (TBP_SCENARIO_MAXBUTTON * TBP_BUTTONWIDTH) + (2 * TBP_DATEPANELWIDTH);
    01323     static const int one_less_panel_min_width = (TBP_SCENARIO_MAXBUTTON * TBP_BUTTONWIDTH) + TBP_DATEPANELWIDTH;
    01324
    01325     if (this->width >= one_less_panel_min_width) {
    01326       buttons_width = TBP_SCENARIO_MAXBUTTON * TBP_BUTTONWIDTH;
    01327       spacing = this->width - ((this->width >= normal_min_width) ? normal_min_width : one_less_panel_min_width);
    01328     } else {
    01329       buttons_width = this->width - TBP_DATEPANELWIDTH;
    01330       spacing = 0;
    01331     }
    01332     static const uint extra_spacing_at[] = { 3, 4, 7, 8, 10, 17, 0 };
    01333
    01334     for (uint i = 0, x = 0, j = 0, b = 0; i < this->widget_count; i++) {
    01335       switch (i) {
    01336         case TBSE_SPACERPANEL:
    01337           this->widget[i].left = x;
    01338           if (this->width < normal_min_width) {
    01339             this->widget[i].right = x;
    01340             j++;
    01341             continue;
    01342           }
    01343
    01344           x += TBP_DATEPANELWIDTH;
    01345           this->widget[i].right = x - 1;
    01346           break;
    01347
    01348         case TBSE_DATEPANEL: {
    01349           int offset = x - this->widget[i].left;
    01350           this->widget[i + 1].left  += offset;
    01351           this->widget[i + 1].right += offset;
    01352           this->widget[i + 2].left  += offset;
    01353           this->widget[i + 2].right += offset;
    01354           this->widget[i].left = x;
    01355           x += TBP_DATEPANELWIDTH;
    01356           this->widget[i].right = x - 1;
    01357           i += 2;
    01358         } break;
    01359
    01360         default:
    01361           if (this->widget[i].bottom == 0) continue;
    01362
    01363           this->widget[i].left = x;
    01364           x += buttons_width / (TBP_SCENARIO_MAXBUTTON - b);
    01365           this->widget[i].right = x - 1;
    01366           buttons_width -= buttons_width / (TBP_SCENARIO_MAXBUTTON - b);
    01367           b++;
    01368           break;
    01369       }
    01370
    01371       if (extra_spacing_at[j] == i) {
    01372         j++;
    01373         uint add = spacing / (lengthof(extra_spacing_at) - j);
    01374         spacing -= add;
    01375         x += add;
    01376       }
    01377     }
    01378   }
    01379
    01380   virtual void OnTick()
    01381   {
    01382     if (this->IsWidgetLowered(TBSE_PAUSE) != !!_pause_game) {
    01383       this->ToggleWidgetLoweredState(TBSE_PAUSE);
    01384       this->SetDirty();
    01385     }
    01386
    01387     if (this->IsWidgetLowered(TBSE_FASTFORWARD) != !!_fast_forward) {
    01388       this->ToggleWidgetLoweredState(TBSE_FASTFORWARD);
    01389       this->SetDirty();
    01390     }
    01391   }
    01392
    01393   virtual void OnInvalidateData(int data)
    01394   {
    01395     if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, TBSE_ZOOMIN, TBSE_ZOOMOUT);
    01396   }
    01397 };
    01398
    01399 static const Widget _toolb_scen_widgets[] = {
    01400 {  WWT_IMGBTN, RESIZE_LEFT,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_PAUSE,       STR_0171_PAUSE_GAME},                  // TBSE_PAUSE
    01401 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_FASTFORWARD, STR_FAST_FORWARD},                     // TBSE_FASTFORWARD
    01402 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_SETTINGS,    STR_0187_OPTIONS},
    01403 {WWT_IMGBTN_2, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_SAVE,        STR_0297_SAVE_SCENARIO_LOAD_SCENARIO}, // TBSE_SAVESCENARIO
    01404
    01405 {   WWT_PANEL, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, 0x0,                 STR_NULL},                             // TBSE_SPACERPANEL
    01406
    01407 {   WWT_PANEL, RESIZE_NONE,  COLOUR_GREY,   0, 129,  0, 21, 0x0,                 STR_NULL},                             // TBSE_DATEPANEL
    01408 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   3,  14,  5, 16, SPR_ARROW_DOWN,      STR_029E_MOVE_THE_STARTING_DATE},      // TBSE_DATEBACKWARD
    01409 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY, 113, 125,  5, 16, SPR_ARROW_UP,        STR_029F_MOVE_THE_STARTING_DATE},      // TBSE_DATEFORWARD
    01410
    01411 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_SMALLMAP,    STR_0175_DISPLAY_MAP_TOWN_DIRECTORY},  // TBSE_SMALLMAP
    01412
    01413 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_ZOOMIN,      STR_017F_ZOOM_THE_VIEW_IN},            // TBSE_ZOOMIN
    01414 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_ZOOMOUT,     STR_0180_ZOOM_THE_VIEW_OUT},           // TBSE_ZOOMOUT
    01415
    01416 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_LANDSCAPING, STR_022E_LANDSCAPE_GENERATION},        // TBSE_LANDGENERATE
    01417 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_TOWN,        STR_022F_TOWN_GENERATION},             // TBSE_TOWNGENERATE
    01418 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_INDUSTRY,    STR_0230_INDUSTRY_GENERATION},         // TBSE_INDUSTRYGENERATE
    01419 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_BUILDROAD,   STR_0231_ROAD_CONSTRUCTION},           // TBSE_BUILDROAD
    01420 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_BUILDWATER,  STR_0183_BUILD_SHIP_DOCKS},            // TBSE_BUILDDOCKS
    01421 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_PLANTTREES,  STR_0288_PLANT_TREES},                 // TBSE_PLANTTREES
    01422 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_SIGN,        STR_0289_PLACE_SIGN},                  // TBSE_PLACESIGNS
    01423
    01424 {   WWT_EMPTY, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0,  0, 0x0,                 STR_NULL},
    01425 {   WWT_EMPTY, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0,  0, 0x0,                 STR_NULL},
    01426 {   WWT_EMPTY, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0,  0, 0x0,                 STR_NULL},
    01427 {   WWT_EMPTY, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0,  0, 0x0,                 STR_NULL},
    01428 {   WWT_EMPTY, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0,  0, 0x0,                 STR_NULL},
    01429 {   WWT_EMPTY, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0,  0, 0x0,                 STR_NULL},
    01430 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_MUSIC,       STR_01D4_SHOW_SOUND_MUSIC_WINDOW},
    01431 {   WWT_EMPTY, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0,  0, 0x0,                 STR_NULL},
    01432 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_QUERY,       STR_0186_LAND_BLOCK_INFORMATION},
    01433 {WIDGETS_END},
    01434 };
    01435
    01436 static const WindowDesc _toolb_scen_desc(
    01437   0, 0, 130, TBP_BUTTONHEIGHT, 640, TBP_BUTTONHEIGHT,
    01438   WC_MAIN_TOOLBAR, WC_NONE,
    01439   WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_NO_FOCUS,
    01440   _toolb_scen_widgets
    01441 );
    01442
    01443 /* --- Allocating the toolbar --- */
    01444
    01445 void AllocateToolbar()
    01446 {
    01447   /* Clean old GUI values; railtype is (re)set by rail_gui.cpp */
    01448   _last_built_roadtype = ROADTYPE_ROAD;
    01449
    01450   if (_game_mode == GM_EDITOR) {
    01451     new ScenarioEditorToolbarWindow(&_toolb_scen_desc);;
    01452   } else {
    01453     new MainToolbarWindow(&_toolb_normal_desc);
    01454   }
    01455 }