# toolbar_gui.cpp

Go to the documentation of this file.

    00001 /* $Id: toolbar_gui.cpp 15448 2009-02-11 18:10:12Z peter1138 $ */
    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     /* Highways don't exist */
    00653     if (rt == ROADTYPE_HWAY) continue;
    00654
    00655     /* The standard road button is *always* available */
    00656     list->push_back(new DropDownListStringItem(STR_180A_ROAD_CONSTRUCTION + rt, rt, !(HasBit(c->avail_roadtypes, rt) || rt == ROADTYPE_ROAD)));
    00657   }
    00658   ShowDropDownList(w, list, _last_built_roadtype, TBN_ROADS, 140, true, true);
    00659   SndPlayFx(SND_15_BEEP);
    00660 }
    00661
    00662 static void MenuClickBuildRoad(int index)
    00663 {
    00664   _last_built_roadtype = (RoadType)index;
    00665   ShowBuildRoadToolbar(_last_built_roadtype);
    00666 }
    00667
    00668 /* --- Water button menu --- */
    00669
    00670 static void ToolbarBuildWaterClick(Window *w)
    00671 {
    00672   PopupMainToolbMenu(w, TBN_WATER, STR_9800_WATERWAYS_CONSTRUCTION, 1);
    00673 }
    00674
    00675 static void MenuClickBuildWater(int index)
    00676 {
    00677   ShowBuildDocksToolbar();
    00678 }
    00679
    00680 /* --- Airport button menu --- */
    00681
    00682 static void ToolbarBuildAirClick(Window *w)
    00683 {
    00684   PopupMainToolbMenu(w, TBN_AIR, STR_A01D_AIRPORT_CONSTRUCTION, 1);
    00685 }
    00686
    00687 static void MenuClickBuildAir(int index)
    00688 {
    00689   ShowBuildAirToolbar();
    00690 }
    00691
    00692 /* --- Forest button menu --- */
    00693
    00694 static void ToolbarForestClick(Window *w)
    00695 {
    00696   PopupMainToolbMenu(w, TBN_LANDSCAPE, STR_LANDSCAPING, 3);
    00697 }
    00698
    00699 static void MenuClickForest(int index)
    00700 {
    00701   switch (index) {
    00702     case 0: ShowTerraformToolbar();  break;
    00703     case 1: ShowBuildTreesToolbar(); break;
    00704     case 2: SelectSignTool();        break;
    00705   }
    00706 }
    00707
    00708 /* --- Music button menu --- */
    00709
    00710 static void ToolbarMusicClick(Window *w)
    00711 {
    00712   PopupMainToolbMenu(w, TBN_MUSICSOUND, STR_01D3_SOUND_MUSIC, 1);
    00713 }
    00714
    00715 static void MenuClickMusicWindow(int index)
    00716 {
    00717   ShowMusicWindow();
    00718 }
    00719
    00720 /* --- Newspaper button menu --- */
    00721
    00722 static void ToolbarNewspaperClick(Window *w)
    00723 {
    00724   PopupMainToolbMenu(w, TBN_NEWSREPORT, STR_0200_LAST_MESSAGE_NEWS_REPORT, 3);
    00725 }
    00726
    00727 static void MenuClickNewspaper(int index)
    00728 {
    00729   switch (index) {
    00730     case 0: ShowLastNewsMessage(); break;
    00731     case 1: ShowMessageOptions();  break;
    00732     case 2: ShowMessageHistory();  break;
    00733   }
    00734 }
    00735
    00736 /* --- Help button menu --- */
    00737
    00738 static void ToolbarHelpClick(Window *w)
    00739 {
    00740   PopupMainToolbMenu(w, TBN_HELP, STR_02D5_LAND_BLOCK_INFO, 7);
    00741 }
    00742
    00743 static void MenuClickSmallScreenshot()
    00744 {
    00745   SetScreenshotType(SC_VIEWPORT);
    00746 }
    00747
    00748 static void MenuClickWorldScreenshot()
    00749 {
    00750   SetScreenshotType(SC_WORLD);
    00751 }
    00752
    00753 static void MenuClickHelp(int index)
    00754 {
    00755   switch (index) {
    00756     case 0: PlaceLandBlockInfo();       break;
    00757     case 2: IConsoleSwitch();           break;
    00758     case 3: ShowAIDebugWindow();        break;
    00759     case 4: MenuClickSmallScreenshot(); break;
    00760     case 5: MenuClickWorldScreenshot(); break;
    00761     case 6: ShowAboutWindow();          break;
    00762   }
    00763 }
    00764
    00765 /* --- Switch toolbar button --- */
    00766
    00767 static void ToolbarSwitchClick(Window *w)
    00768 {
    00769   if (_toolbar_mode != TB_LOWER) {
    00770     _toolbar_mode = TB_LOWER;
    00771   } else {
    00772     _toolbar_mode = TB_UPPER;
    00773   }
    00774
    00775   SplitToolbar(w);
    00776   w->HandleButtonClick(TBN_SWITCHBAR);
    00777   SetWindowDirty(w);
    00778   SndPlayFx(SND_15_BEEP);
    00779 }
    00780
    00781 /* --- Scenario editor specific handlers. */
    00782
    00783 static void ToolbarScenDateBackward(Window *w)
    00784 {
    00785   /* don't allow too fast scrolling */
    00786   if ((w->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
    00787     w->HandleButtonClick(TBSE_DATEBACKWARD);
    00788     w->SetDirty();
    00789
    00790     _settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year - 1, MIN_YEAR, MAX_YEAR);
    00791     SetDate(ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
    00792   }
    00793   _left_button_clicked = false;
    00794 }
    00795
    00796 static void ToolbarScenDateForward(Window *w)
    00797 {
    00798   /* don't allow too fast scrolling */
    00799   if ((w->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
    00800     w->HandleButtonClick(TBSE_DATEFORWARD);
    00801     w->SetDirty();
    00802
    00803     _settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + 1, MIN_YEAR, MAX_YEAR);
    00804     SetDate(ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
    00805   }
    00806   _left_button_clicked = false;
    00807 }
    00808
    00809 static void ToolbarScenGenLand(Window *w)
    00810 {
    00811   w->HandleButtonClick(TBSE_LANDGENERATE);
    00812   SndPlayFx(SND_15_BEEP);
    00813
    00814   ShowEditorTerraformToolbar();
    00815 }
    00816
    00817
    00818 static void ToolbarScenGenTown(Window *w)
    00819 {
    00820   w->HandleButtonClick(TBSE_TOWNGENERATE);
    00821   SndPlayFx(SND_15_BEEP);
    00822   ShowBuildTownWindow();
    00823 }
    00824
    00825 static void ToolbarScenGenIndustry(Window *w)
    00826 {
    00827   w->HandleButtonClick(TBSE_INDUSTRYGENERATE);
    00828   SndPlayFx(SND_15_BEEP);
    00829   ShowBuildIndustryWindow();
    00830 }
    00831
    00832 static void ToolbarScenBuildRoad(Window *w)
    00833 {
    00834   w->HandleButtonClick(TBSE_BUILDROAD);
    00835   SndPlayFx(SND_15_BEEP);
    00836   ShowBuildRoadScenToolbar();
    00837 }
    00838
    00839 static void ToolbarScenBuildDocks(Window *w)
    00840 {
    00841   w->HandleButtonClick(TBSE_BUILDDOCKS);
    00842   SndPlayFx(SND_15_BEEP);
    00843   ShowBuildDocksScenToolbar();
    00844 }
    00845
    00846 static void ToolbarScenPlantTrees(Window *w)
    00847 {
    00848   w->HandleButtonClick(TBSE_PLANTTREES);
    00849   SndPlayFx(SND_15_BEEP);
    00850   ShowBuildTreesToolbar();
    00851 }
    00852
    00853 static void ToolbarScenPlaceSign(Window *w)
    00854 {
    00855   w->HandleButtonClick(TBSE_PLACESIGNS);
    00856   SndPlayFx(SND_15_BEEP);
    00857   SelectSignTool();
    00858 }
    00859
    00860 static void ToolbarBtn_NULL(Window *w)
    00861 {
    00862 }
    00863
    00864 /* --- Resizing the toolbar */
    00865
    00866 static void ResizeToolbar(Window *w)
    00867 {
    00868   /* There are 27 buttons plus some spacings if the space allows it */
    00869   uint button_width;
    00870   uint spacing;
    00871   uint widgetcount = w->widget_count - 1;
    00872
    00873   if (w->width >= (int)widgetcount * TBP_BUTTONWIDTH) {
    00874     button_width = TBP_BUTTONWIDTH;
    00875     spacing = w->width - (widgetcount * button_width);
    00876   } else {
    00877     button_width = w->width / widgetcount;
    00878     spacing = 0;
    00879   }
    00880
    00881   static const uint extra_spacing_at[] = { 4, 8, 13, 17, 19, 24, 0 };
    00882   uint i = 0;
    00883   for (uint x = 0, j = 0; i < widgetcount; i++) {
    00884     if (extra_spacing_at[j] == i) {
    00885       j++;
    00886       uint add = spacing / (lengthof(extra_spacing_at) - j);
    00887       spacing -= add;
    00888       x += add;
    00889     }
    00890
    00891     w->widget[i].type = WWT_IMGBTN;
    00892     w->widget[i].left = x;
    00893     x += (spacing != 0) ? button_width : (w->width - x) / (widgetcount - i);
    00894     w->widget[i].right = x - 1;
    00895   }
    00896
    00897   w->widget[i].type = WWT_EMPTY; // i now points to the last item
    00898   _toolbar_mode = TB_NORMAL;
    00899 }
    00900
    00901 /* --- Split the toolbar */
    00902
    00903 static void SplitToolbar(Window *w)
    00904 {
    00905   static const byte arrange14[] = {
    00906     0,  1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 27,
    00907     2,  3,  4,  5,  6,  7,  8,  9, 10, 12, 24, 25, 26, 27,
    00908   };
    00909   static const byte arrange15[] = {
    00910     0,  1,  4, 13, 14, 15, 16, 19, 20, 21, 22, 23, 17, 18, 27,
    00911     0,  2,  4,  3,  5,  6,  7,  8,  9, 10, 12, 24, 25, 26, 27,
    00912   };
    00913   static const byte arrange16[] = {
    00914     0,  1,  2,  4, 13, 14, 15, 16, 19, 20, 21, 22, 23, 17, 18, 27,
    00915     0,  1,  3,  5,  6,  7,  8,  9, 10, 12, 24, 25, 26, 17, 18, 27,
    00916   };
    00917   static const byte arrange17[] = {
    00918     0,  1,  2,  4,  6, 13, 14, 15, 16, 19, 20, 21, 22, 23, 17, 18, 27,
    00919     0,  1,  3,  4,  6,  5,  7,  8,  9, 10, 12, 24, 25, 26, 17, 18, 27,
    00920   };
    00921   static const byte arrange18[] = {
    00922     0,  1,  2,  4,  5,  6,  7,  8,  9, 12, 19, 20, 21, 22, 23, 17, 18, 27,
    00923     0,  1,  3,  4,  5,  6,  7, 10, 13, 14, 15, 16, 24, 25, 26, 17, 18, 27,
    00924   };
    00925   static const byte arrange19[] = {
    00926     0,  1,  2,  4,  5,  6, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 17, 18, 27,
    00927     0,  1,  3,  4,  7,  8,  9, 10, 12, 25, 19, 20, 21, 22, 23, 26, 17, 18, 27,
    00928   };
    00929
    00930   static const byte *arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19 };
    00931
    00932   uint max_icons = max(TBP_TOOLBAR_MINBUTTON, (ToolBarProperties)((w->width + TBP_BUTTONWIDTH / 2) / TBP_BUTTONWIDTH));
    00933
    00934   assert(max_icons >= TBP_TOOLBAR_MINBUTTON && max_icons <= TBP_NORMAL_MAXBUTTON);
    00935
    00936   /* first hide all icons */
    00937   for (uint i = 0; i < w->widget_count - 1; i++) {
    00938     w->widget[i].type = WWT_EMPTY;
    00939   }
    00940
    00941   /* now activate them all on their proper positions */
    00942   for (uint i = 0, x = 0, n = max_icons - TBP_TOOLBAR_MINBUTTON; i < max_icons; i++) {
    00943     uint icon = arrangements[n][i + ((_toolbar_mode == TB_LOWER) ? max_icons : 0)];
    00944     w->widget[icon].type = WWT_IMGBTN;
    00945     w->widget[icon].left = x;
    00946     x += (w->width - x) / (max_icons - i);
    00947     w->widget[icon].right = x - 1;
    00948   }
    00949 }
    00950
    00951 typedef void MenuClickedProc(int index);
    00952
    00953 static MenuClickedProc * const _menu_clicked_procs[] = {
    00954   NULL,                 /* 0 */
    00955   NULL,                 /* 1 */
    00956   MenuClickSettings,    /* 2 */
    00957   MenuClickSaveLoad,    /* 3 */
    00958   MenuClickMap,         /* 4 */
    00959   MenuClickTown,        /* 5 */
    00960   MenuClickSubsidies,   /* 6 */
    00961   MenuClickStations,    /* 7 */
    00962   MenuClickFinances,    /* 8 */
    00963   MenuClickCompany,     /* 9 */
    00964   MenuClickGraphs,      /* 10 */
    00965   MenuClickLeague,      /* 11 */
    00966   MenuClickIndustry,    /* 12 */
    00967   MenuClickShowTrains,  /* 13 */
    00968   MenuClickShowRoad,    /* 14 */
    00969   MenuClickShowShips,   /* 15 */
    00970   MenuClickShowAir,     /* 16 */
    00971   MenuClickMap,         /* 17 */
    00972   NULL,                 /* 18 */
    00973   MenuClickBuildRail,   /* 19 */
    00974   MenuClickBuildRoad,   /* 20 */
    00975   MenuClickBuildWater,  /* 21 */
    00976   MenuClickBuildAir,    /* 22 */
    00977   MenuClickForest,      /* 23 */
    00978   MenuClickMusicWindow, /* 24 */
    00979   MenuClickNewspaper,   /* 25 */
    00980   MenuClickHelp,        /* 26 */
    00981 };
    00982
    00983 /* --- Toolbar handling for the 'normal' case */
    00984
    00985 typedef void ToolbarButtonProc(Window *w);
    00986
    00987 static ToolbarButtonProc * const _toolbar_button_procs[] = {
    00988   ToolbarPauseClick,
    00989   ToolbarFastForwardClick,
    00990   ToolbarOptionsClick,
    00991   ToolbarSaveClick,
    00992   ToolbarMapClick,
    00993   ToolbarTownClick,
    00994   ToolbarSubsidiesClick,
    00995   ToolbarStationsClick,
    00996   ToolbarFinancesClick,
    00997   ToolbarCompaniesClick,
    00998   ToolbarGraphsClick,
    00999   ToolbarLeagueClick,
    01000   ToolbarIndustryClick,
    01001   ToolbarTrainClick,
    01002   ToolbarRoadClick,
    01003   ToolbarShipClick,
    01004   ToolbarAirClick,
    01005   ToolbarZoomInClick,
    01006   ToolbarZoomOutClick,
    01007   ToolbarBuildRailClick,
    01008   ToolbarBuildRoadClick,
    01009   ToolbarBuildWaterClick,
    01010   ToolbarBuildAirClick,
    01011   ToolbarForestClick,
    01012   ToolbarMusicClick,
    01013   ToolbarNewspaperClick,
    01014   ToolbarHelpClick,
    01015   ToolbarSwitchClick,
    01016 };
    01017
    01018 struct MainToolbarWindow : Window {
    01019   MainToolbarWindow(const WindowDesc *desc) : Window(desc)
    01020   {
    01021     this->SetWidgetDisabledState(TBN_PAUSE, _networking && !_network_server); // if not server, disable pause button
    01022     this->SetWidgetDisabledState(TBN_FASTFORWARD, _networking); // if networking, disable fast-forward button
    01023
    01024     CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
    01025
    01026     this->FindWindowPlacementAndResize(desc);
    01027     PositionMainToolbar(this);
    01028     DoZoomInOutWindow(ZOOM_NONE, this);
    01029   }
    01030
    01031   virtual void OnPaint()
    01032   {
    01033     /* Draw brown-red toolbar bg. */
    01034     GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB2);
    01035     GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB4, FILLRECT_CHECKER);
    01036
    01037     /* If spectator, disable all construction buttons
    01038     * ie : Build road, rail, ships, airports and landscaping
    01039     * Since enabled state is the default, just disable when needed */
    01040     this->SetWidgetsDisabledState(_local_company == COMPANY_SPECTATOR, TBN_RAILS, TBN_ROADS, TBN_WATER, TBN_AIR, TBN_LANDSCAPE, WIDGET_LIST_END);
    01041     /* disable company list drop downs, if there are no companies */
    01042     this->SetWidgetsDisabledState(ActiveCompanyCount() == TBN_PAUSE, TBN_STATIONS, TBN_FINANCES, TBN_TRAINS, TBN_ROADVEHS, TBN_SHIPS, TBN_AIRCRAFTS, WIDGET_LIST_END);
    01043
    01044     this->SetWidgetDisabledState(TBN_RAILS, !CanBuildVehicleInfrastructure(VEH_TRAIN));
    01045     this->SetWidgetDisabledState(TBN_AIR, !CanBuildVehicleInfrastructure(VEH_AIRCRAFT));
    01046
    01047     this->DrawWidgets();
    01048   }
    01049
    01050   virtual void OnClick(Point pt, int widget)
    01051   {
    01052     if (_game_mode != GM_MENU && !this->IsWidgetDisabled(widget)) _toolbar_button_procs[widget](this);
    01053   }
    01054
    01055   virtual void OnDropdownSelect(int widget, int index)
    01056   {
    01057     _menu_clicked_procs[widget](index);
    01058   }
    01059
    01060   virtual EventState OnKeyPress(uint16 key, uint16 keycode)
    01061   {
    01062     switch (keycode) {
    01063       case WKC_F1: case WKC_PAUSE: ToolbarPauseClick(this); break;
    01064       case WKC_F2: ShowGameOptions(); break;
    01065       case WKC_F3: MenuClickSaveLoad(); break;
    01066       case WKC_F4: ShowSmallMap(); break;
    01067       case WKC_F5: ShowTownDirectory(); break;
    01068       case WKC_F6: ShowSubsidiesList(); break;
    01069       case WKC_F7: ShowCompanyStations(_local_company); break;
    01070       case WKC_F8: ShowCompanyFinances(_local_company); break;
    01071       case WKC_F9: ShowCompany(_local_company); break;
    01072       case WKC_F10: ShowOperatingProfitGraph(); break;
    01073       case WKC_F11: ShowCompanyLeagueTable(); break;
    01074       case WKC_F12: ShowBuildIndustryWindow(); break;
    01075       case WKC_SHIFT | WKC_F1: ShowVehicleListWindow(_local_company, VEH_TRAIN); break;
    01076       case WKC_SHIFT | WKC_F2: ShowVehicleListWindow(_local_company, VEH_ROAD); break;
    01077       case WKC_SHIFT | WKC_F3: ShowVehicleListWindow(_local_company, VEH_SHIP); break;
    01078       case WKC_SHIFT | WKC_F4: ShowVehicleListWindow(_local_company, VEH_AIRCRAFT); break;
    01079       case WKC_NUM_PLUS: // Fall through
    01080       case WKC_EQUALS: // Fall through
    01081       case WKC_SHIFT | WKC_EQUALS: // Fall through
    01082       case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(this); break;
    01083       case WKC_NUM_MINUS: // Fall through
    01084       case WKC_MINUS: // Fall through
    01085       case WKC_SHIFT | WKC_MINUS: // Fall through
    01086       case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(this); break;
    01087       case WKC_SHIFT | WKC_F7: if (CanBuildVehicleInfrastructure(VEH_TRAIN)) ShowBuildRailToolbar(_last_built_railtype, -1); break;
    01088       case WKC_SHIFT | WKC_F8: ShowBuildRoadToolbar(_last_built_roadtype); break;
    01089       case WKC_SHIFT | WKC_F9: ShowBuildDocksToolbar(); break;
    01090       case WKC_SHIFT | WKC_F10: if (CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) ShowBuildAirToolbar(); break;
    01091       case WKC_SHIFT | WKC_F11: ShowBuildTreesToolbar(); break;
    01092       case WKC_SHIFT | WKC_F12: ShowMusicWindow(); break;
    01093       case WKC_CTRL  | 'S': MenuClickSmallScreenshot(); break;
    01094       case WKC_CTRL  | 'G': MenuClickWorldScreenshot(); break;
    01095       case WKC_CTRL | WKC_ALT | 'C': if (!_networking) ShowCheatWindow(); break;
    01096       case 'A': if (CanBuildVehicleInfrastructure(VEH_TRAIN)) ShowBuildRailToolbar(_last_built_railtype, 4); break; // Invoke Autorail
    01097       case 'L': ShowTerraformToolbar(); break;
    01098       case 'M': ShowSmallMap(); break;
    01099       case 'V': ShowExtraViewPortWindow(); break;
    01100       default: return ES_NOT_HANDLED;
    01101     }
    01102     return ES_HANDLED;
    01103   }
    01104
    01105   virtual void OnPlaceObject(Point pt, TileIndex tile)
    01106   {
    01107     _place_proc(tile);
    01108   }
    01109
    01110   virtual void OnTick()
    01111   {
    01112     if (this->IsWidgetLowered(TBN_PAUSE) != !!_pause_game) {
    01113       this->ToggleWidgetLoweredState(TBN_PAUSE);
    01114       this->InvalidateWidget(TBN_PAUSE);
    01115     }
    01116
    01117     if (this->IsWidgetLowered(TBN_FASTFORWARD) != !!_fast_forward) {
    01118       this->ToggleWidgetLoweredState(TBN_FASTFORWARD);
    01119       this->InvalidateWidget(TBN_FASTFORWARD);
    01120     }
    01121   }
    01122
    01123   virtual void OnResize(Point new_size, Point delta)
    01124   {
    01125     if (this->width <= TBP_NORMAL_MAXBUTTON * TBP_BUTTONWIDTH) {
    01126       SplitToolbar(this);
    01127     } else {
    01128       ResizeToolbar(this);
    01129     }
    01130   }
    01131
    01132   virtual void OnTimeout()
    01133   {
    01134     for (uint i = TBN_SETTINGS; i < this->widget_count - 1; i++) {
    01135       if (this->IsWidgetLowered(i)) {
    01136         this->RaiseWidget(i);
    01137         this->InvalidateWidget(i);
    01138       }
    01139     }
    01140   }
    01141
    01142   virtual void OnInvalidateData(int data)
    01143   {
    01144     if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, TBN_ZOOMIN, TBN_ZOOMOUT);
    01145   }
    01146 };
    01147
    01148 static const Widget _toolb_normal_widgets[] = {
    01149 {     WWT_IMGBTN,   RESIZE_LEFT,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_PAUSE,           STR_0171_PAUSE_GAME},               // TBN_PAUSE
    01150 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_FASTFORWARD,     STR_FAST_FORWARD},                  // TBN_FASTFORWARD
    01151 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_SETTINGS,        STR_0187_OPTIONS},                  // TBN_SETTINGS
    01152 {   WWT_IMGBTN_2,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_SAVE,            STR_0172_SAVE_GAME_ABANDON_GAME},   // TBN_SAVEGAME
    01153
    01154 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_SMALLMAP,        STR_0174_DISPLAY_MAP},              // TBN_SMALLMAP
    01155 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_TOWN,            STR_0176_DISPLAY_TOWN_DIRECTORY},   // TBN_TOWNDIRECTORY
    01156 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_SUBSIDIES,       STR_02DC_DISPLAY_SUBSIDIES},        // TBN_SUBSIDIES
    01157 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_COMPANY_LIST,    STR_0173_DISPLAY_LIST_OF_COMPANY},  // TBN_STATIONS
    01158
    01159 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_COMPANY_FINANCE, STR_0177_DISPLAY_COMPANY_FINANCES}, // TBN_FINANCES
    01160 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_COMPANY_GENERAL, STR_0178_DISPLAY_COMPANY_GENERAL},  // TBN_COMPANIES
    01161 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_GRAPHS,          STR_0179_DISPLAY_GRAPHS},           // TBN_GRAPHICS
    01162 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_COMPANY_LEAGUE,  STR_017A_DISPLAY_COMPANY_LEAGUE},   // TBN_LEAGUE
    01163 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_INDUSTRY,        STR_0312_FUND_CONSTRUCTION_OF_NEW}, // TBN_INDUSTRIES
    01164
    01165 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_TRAINLIST,       STR_017B_DISPLAY_LIST_OF_COMPANY},  // TBN_TRAINS
    01166 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_TRUCKLIST,       STR_017C_DISPLAY_LIST_OF_COMPANY},  // TBN_ROADVEHS
    01167 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_SHIPLIST,        STR_017D_DISPLAY_LIST_OF_COMPANY},  // TBN_SHIPS
    01168 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_AIRPLANESLIST,   STR_017E_DISPLAY_LIST_OF_COMPANY},  // TBN_AIRCRAFTS
    01169
    01170 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_ZOOMIN,          STR_017F_ZOOM_THE_VIEW_IN},         // TBN_ZOOMIN
    01171 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_ZOOMOUT,         STR_0180_ZOOM_THE_VIEW_OUT},        // TBN_ZOOMOUT
    01172
    01173 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_BUILDRAIL,       STR_0181_BUILD_RAILROAD_TRACK},     // TBN_RAILS
    01174 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_BUILDROAD,       STR_0182_BUILD_ROADS},              // TBN_ROADS
    01175 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_BUILDWATER,      STR_0183_BUILD_SHIP_DOCKS},         // TBN_WATER
    01176 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_BUILDAIR,        STR_0184_BUILD_AIRPORTS},           // TBN_AIR
    01177 {     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
    01178
    01179 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_MUSIC,           STR_01D4_SHOW_SOUND_MUSIC_WINDOW},  // TBN_MUSICSOUND
    01180 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_MESSAGES,        STR_0203_SHOW_LAST_MESSAGE_NEWS},   // TBN_NEWSREPORT
    01181 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_IMG_QUERY,           STR_0186_LAND_BLOCK_INFORMATION},   // TBN_HELP
    01182 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_GREY,     0,     0,     0,    21, SPR_SWITCH_TOOLBAR,      STR_EMPTY},                         // TBN_SWITCHBAR
    01183 {   WIDGETS_END},
    01184 };
    01185
    01186 static const WindowDesc _toolb_normal_desc = {
    01187   0, 0, 0, TBP_BUTTONHEIGHT, 640, TBP_BUTTONHEIGHT,
    01188   WC_MAIN_TOOLBAR, WC_NONE,
    01189   WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_NO_FOCUS,
    01190   _toolb_normal_widgets,
    01191 };
    01192
    01193
    01194 /* --- Toolbar handling for the scenario editor */
    01195
    01196 static ToolbarButtonProc * const _scen_toolbar_button_procs[] = {
    01197   ToolbarPauseClick,
    01198   ToolbarFastForwardClick,
    01199   ToolbarOptionsClick,
    01200   ToolbarScenSaveOrLoad,
    01201   ToolbarBtn_NULL,
    01202   ToolbarBtn_NULL,
    01203   ToolbarScenDateBackward,
    01204   ToolbarScenDateForward,
    01205   ToolbarScenMapTownDir,
    01206   ToolbarZoomInClick,
    01207   ToolbarZoomOutClick,
    01208   ToolbarScenGenLand,
    01209   ToolbarScenGenTown,
    01210   ToolbarScenGenIndustry,
    01211   ToolbarScenBuildRoad,
    01212   ToolbarScenBuildDocks,
    01213   ToolbarScenPlantTrees,
    01214   ToolbarScenPlaceSign,
    01215   NULL,
    01216   NULL,
    01217   NULL,
    01218   NULL,
    01219   NULL,
    01220   NULL,
    01221   ToolbarMusicClick,
    01222   NULL,
    01223   ToolbarHelpClick,
    01224 };
    01225
    01226 struct ScenarioEditorToolbarWindow : Window {
    01227 public:
    01228   ScenarioEditorToolbarWindow(const WindowDesc *desc) : Window(desc)
    01229   {
    01230     CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
    01231
    01232     this->FindWindowPlacementAndResize(desc);
    01233     PositionMainToolbar(this);
    01234     DoZoomInOutWindow(ZOOM_NONE, this);
    01235   }
    01236
    01237   virtual void OnPaint()
    01238   {
    01239     this->SetWidgetDisabledState(TBSE_DATEBACKWARD, _settings_newgame.game_creation.starting_year <= MIN_YEAR);
    01240     this->SetWidgetDisabledState(TBSE_DATEFORWARD, _settings_newgame.game_creation.starting_year >= MAX_YEAR);
    01241
    01242     /* Draw brown-red toolbar bg. */
    01243     GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB2);
    01244     GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB4, FILLRECT_CHECKER);
    01245
    01246     this->DrawWidgets();
    01247
    01248     SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
    01249     DrawStringCenteredTruncated(this->widget[TBSE_DATEBACKWARD].right, this->widget[TBSE_DATEFORWARD].left, 6, STR_00AF, TC_FROMSTRING);
    01250
    01251     /* We hide this panel when the toolbar space gets too small */
    01252     const Widget *panel = &this->widget[TBSE_SPACERPANEL];
    01253     if (panel->left != panel->right) {
    01254       DrawStringCenteredTruncated(panel->left + 1, panel->right - 1,  1, STR_0221_OPENTTD, TC_FROMSTRING);
    01255       DrawStringCenteredTruncated(panel->left + 1, panel->right - 1, 11, STR_0222_SCENARIO_EDITOR, TC_FROMSTRING);
    01256     }
    01257   }
    01258
    01259   virtual void OnClick(Point pt, int widget)
    01260   {
    01261     if (_game_mode == GM_MENU) return;
    01262     _scen_toolbar_button_procs[widget](this);
    01263   }
    01264
    01265   virtual void OnDropdownSelect(int widget, int index)
    01266   {
    01267     /* The map button is in a different location on the scenario
    01268      * editor toolbar, so we need to adjust for it. */
    01269     if (widget == TBSE_SMALLMAP) widget = TBN_SMALLMAP;
    01270     _menu_clicked_procs[widget](index);
    01271     SndPlayFx(SND_15_BEEP);
    01272   }
    01273
    01274   virtual EventState OnKeyPress(uint16 key, uint16 keycode)
    01275   {
    01276     switch (keycode) {
    01277       case WKC_F1: case WKC_PAUSE: ToolbarPauseClick(this); break;
    01278       case WKC_F2: ShowGameOptions(); break;
    01279       case WKC_F3: MenuClickSaveLoad(); break;
    01280       case WKC_F4: ToolbarScenGenLand(this); break;
    01281       case WKC_F5: ToolbarScenGenTown(this); break;
    01282       case WKC_F6: ToolbarScenGenIndustry(this); break;
    01283       case WKC_F7: ToolbarScenBuildRoad(this); break;
    01284       case WKC_F8: ToolbarScenBuildDocks(this); break;
    01285       case WKC_F9: ToolbarScenPlantTrees(this); break;
    01286       case WKC_F10: ToolbarScenPlaceSign(this); break;
    01287       case WKC_F11: ShowMusicWindow(); break;
    01288       case WKC_F12: PlaceLandBlockInfo(); break;
    01289       case WKC_CTRL | 'S': MenuClickSmallScreenshot(); break;
    01290       case WKC_CTRL | 'G': MenuClickWorldScreenshot(); break;
    01291
    01292       /* those following are all fall through */
    01293       case WKC_NUM_PLUS:
    01294       case WKC_EQUALS:
    01295       case WKC_SHIFT | WKC_EQUALS:
    01296       case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(this); break;
    01297
    01298       /* those following are all fall through */
    01299       case WKC_NUM_MINUS:
    01300       case WKC_MINUS:
    01301       case WKC_SHIFT | WKC_MINUS:
    01302       case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(this); break;
    01303
    01304       case 'L': ShowEditorTerraformToolbar(); break;
    01305       case 'M': ShowSmallMap(); break;
    01306       case 'V': ShowExtraViewPortWindow(); break;
    01307       default: return ES_NOT_HANDLED;
    01308     }
    01309     return ES_HANDLED;
    01310   }
    01311
    01312   virtual void OnPlaceObject(Point pt, TileIndex tile)
    01313   {
    01314     _place_proc(tile);
    01315   }
    01316
    01317   virtual void OnResize(Point new_size, Point delta)
    01318   {
    01319     /* There are 16 buttons plus some spacings if the space allows it.
    01320      * Furthermore there are two panels of which one is non - essential
    01321      * and that one can be removed if the space is too small. */
    01322     uint buttons_width;
    01323     uint spacing;
    01324
    01325     static const int normal_min_width = (TBP_SCENARIO_MAXBUTTON * TBP_BUTTONWIDTH) + (2 * TBP_DATEPANELWIDTH);
    01326     static const int one_less_panel_min_width = (TBP_SCENARIO_MAXBUTTON * TBP_BUTTONWIDTH) + TBP_DATEPANELWIDTH;
    01327
    01328     if (this->width >= one_less_panel_min_width) {
    01329       buttons_width = TBP_SCENARIO_MAXBUTTON * TBP_BUTTONWIDTH;
    01330       spacing = this->width - ((this->width >= normal_min_width) ? normal_min_width : one_less_panel_min_width);
    01331     } else {
    01332       buttons_width = this->width - TBP_DATEPANELWIDTH;
    01333       spacing = 0;
    01334     }
    01335     static const uint extra_spacing_at[] = { 3, 4, 7, 8, 10, 17, 0 };
    01336
    01337     for (uint i = 0, x = 0, j = 0, b = 0; i < this->widget_count; i++) {
    01338       switch (i) {
    01339         case TBSE_SPACERPANEL:
    01340           this->widget[i].left = x;
    01341           if (this->width < normal_min_width) {
    01342             this->widget[i].right = x;
    01343             j++;
    01344             continue;
    01345           }
    01346
    01347           x += TBP_DATEPANELWIDTH;
    01348           this->widget[i].right = x - 1;
    01349           break;
    01350
    01351         case TBSE_DATEPANEL: {
    01352           int offset = x - this->widget[i].left;
    01353           this->widget[i + 1].left  += offset;
    01354           this->widget[i + 1].right += offset;
    01355           this->widget[i + 2].left  += offset;
    01356           this->widget[i + 2].right += offset;
    01357           this->widget[i].left = x;
    01358           x += TBP_DATEPANELWIDTH;
    01359           this->widget[i].right = x - 1;
    01360           i += 2;
    01361         } break;
    01362
    01363         default:
    01364           if (this->widget[i].bottom == 0) continue;
    01365
    01366           this->widget[i].left = x;
    01367           x += buttons_width / (TBP_SCENARIO_MAXBUTTON - b);
    01368           this->widget[i].right = x - 1;
    01369           buttons_width -= buttons_width / (TBP_SCENARIO_MAXBUTTON - b);
    01370           b++;
    01371           break;
    01372       }
    01373
    01374       if (extra_spacing_at[j] == i) {
    01375         j++;
    01376         uint add = spacing / (lengthof(extra_spacing_at) - j);
    01377         spacing -= add;
    01378         x += add;
    01379       }
    01380     }
    01381   }
    01382
    01383   virtual void OnTick()
    01384   {
    01385     if (this->IsWidgetLowered(TBSE_PAUSE) != !!_pause_game) {
    01386       this->ToggleWidgetLoweredState(TBSE_PAUSE);
    01387       this->SetDirty();
    01388     }
    01389
    01390     if (this->IsWidgetLowered(TBSE_FASTFORWARD) != !!_fast_forward) {
    01391       this->ToggleWidgetLoweredState(TBSE_FASTFORWARD);
    01392       this->SetDirty();
    01393     }
    01394   }
    01395
    01396   virtual void OnInvalidateData(int data)
    01397   {
    01398     if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, TBSE_ZOOMIN, TBSE_ZOOMOUT);
    01399   }
    01400 };
    01401
    01402 static const Widget _toolb_scen_widgets[] = {
    01403 {  WWT_IMGBTN, RESIZE_LEFT,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_PAUSE,       STR_0171_PAUSE_GAME},                  // TBSE_PAUSE
    01404 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_FASTFORWARD, STR_FAST_FORWARD},                     // TBSE_FASTFORWARD
    01405 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_SETTINGS,    STR_0187_OPTIONS},
    01406 {WWT_IMGBTN_2, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_SAVE,        STR_0297_SAVE_SCENARIO_LOAD_SCENARIO}, // TBSE_SAVESCENARIO
    01407
    01408 {   WWT_PANEL, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, 0x0,                 STR_NULL},                             // TBSE_SPACERPANEL
    01409
    01410 {   WWT_PANEL, RESIZE_NONE,  COLOUR_GREY,   0, 129,  0, 21, 0x0,                 STR_NULL},                             // TBSE_DATEPANEL
    01411 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   3,  14,  5, 16, SPR_ARROW_DOWN,      STR_029E_MOVE_THE_STARTING_DATE},      // TBSE_DATEBACKWARD
    01412 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY, 113, 125,  5, 16, SPR_ARROW_UP,        STR_029F_MOVE_THE_STARTING_DATE},      // TBSE_DATEFORWARD
    01413
    01414 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_SMALLMAP,    STR_0175_DISPLAY_MAP_TOWN_DIRECTORY},  // TBSE_SMALLMAP
    01415
    01416 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_ZOOMIN,      STR_017F_ZOOM_THE_VIEW_IN},            // TBSE_ZOOMIN
    01417 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_ZOOMOUT,     STR_0180_ZOOM_THE_VIEW_OUT},           // TBSE_ZOOMOUT
    01418
    01419 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_LANDSCAPING, STR_022E_LANDSCAPE_GENERATION},        // TBSE_LANDGENERATE
    01420 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_TOWN,        STR_022F_TOWN_GENERATION},             // TBSE_TOWNGENERATE
    01421 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_INDUSTRY,    STR_0230_INDUSTRY_GENERATION},         // TBSE_INDUSTRYGENERATE
    01422 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_BUILDROAD,   STR_0231_ROAD_CONSTRUCTION},           // TBSE_BUILDROAD
    01423 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_BUILDWATER,  STR_0183_BUILD_SHIP_DOCKS},            // TBSE_BUILDDOCKS
    01424 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_PLANTTREES,  STR_0288_PLANT_TREES},                 // TBSE_PLANTTREES
    01425 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_SIGN,        STR_0289_PLACE_SIGN},                  // TBSE_PLACESIGNS
    01426
    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_EMPTY, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0,  0, 0x0,                 STR_NULL},
    01431 {   WWT_EMPTY, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0,  0, 0x0,                 STR_NULL},
    01432 {   WWT_EMPTY, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0,  0, 0x0,                 STR_NULL},
    01433 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_MUSIC,       STR_01D4_SHOW_SOUND_MUSIC_WINDOW},
    01434 {   WWT_EMPTY, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0,  0, 0x0,                 STR_NULL},
    01435 {  WWT_IMGBTN, RESIZE_NONE,  COLOUR_GREY,   0,   0,  0, 21, SPR_IMG_QUERY,       STR_0186_LAND_BLOCK_INFORMATION},
    01436 {WIDGETS_END},
    01437 };
    01438
    01439 static const WindowDesc _toolb_scen_desc = {
    01440   0, 0, 130, TBP_BUTTONHEIGHT, 640, TBP_BUTTONHEIGHT,
    01441   WC_MAIN_TOOLBAR, WC_NONE,
    01442   WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_NO_FOCUS,
    01443   _toolb_scen_widgets,
    01444 };
    01445
    01446 /* --- Allocating the toolbar --- */
    01447
    01448 void AllocateToolbar()
    01449 {
    01450   /* Clean old GUI values; railtype is (re)set by rail_gui.cpp */
    01451   _last_built_roadtype = ROADTYPE_ROAD;
    01452
    01453   if (_game_mode == GM_EDITOR) {
    01454     new ScenarioEditorToolbarWindow(&_toolb_scen_desc);;
    01455   } else {
    01456     new MainToolbarWindow(&_toolb_normal_desc);
    01457   }
    01458 }