OpenTTD Source 20241224-master-gf74b0cf984
toolbar_gui.cpp File Reference

Code related to the (main) toolbar. More...

#include "stdafx.h"
#include "gui.h"
#include "window_gui.h"
#include "window_func.h"
#include "viewport_func.h"
#include "command_func.h"
#include "dropdown_type.h"
#include "dropdown_func.h"
#include "dropdown_common_type.h"
#include "house.h"
#include "vehicle_gui.h"
#include "rail_gui.h"
#include "road.h"
#include "road_gui.h"
#include "vehicle_func.h"
#include "sound_func.h"
#include "terraform_gui.h"
#include "strings_func.h"
#include "company_func.h"
#include "company_gui.h"
#include "vehicle_base.h"
#include "cheat_func.h"
#include "transparency_gui.h"
#include "screenshot.h"
#include "signs_func.h"
#include "fios.h"
#include "console_gui.h"
#include "news_gui.h"
#include "ai/ai_gui.hpp"
#include "game/game_gui.hpp"
#include "script/script_gui.h"
#include "tilehighlight_func.h"
#include "smallmap_gui.h"
#include "graph_gui.h"
#include "textbuf_gui.h"
#include "linkgraph/linkgraph_gui.h"
#include "newgrf_debug.h"
#include "hotkeys.h"
#include "engine_base.h"
#include "highscore.h"
#include "game/game.hpp"
#include "goal_base.h"
#include "story_base.h"
#include "toolbar_gui.h"
#include "framerate_type.h"
#include "screenshot_gui.h"
#include "misc_cmd.h"
#include "league_gui.h"
#include "league_base.h"
#include "timer/timer.h"
#include "timer/timer_window.h"
#include "timer/timer_game_calendar.h"
#include "help_gui.h"
#include "widgets/toolbar_widget.h"
#include "network/network.h"
#include "network/network_gui.h"
#include "network/network_func.h"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

class  DropDownListCompanyItem
 Company name list item, with company-colour icon, name, and lock components. More...
 
class  NWidgetToolbarContainer
 Full blown container to make it behave exactly as we want :) More...
 
class  NWidgetMainToolbarContainer
 Container for the 'normal' main toolbar. More...
 
class  NWidgetScenarioToolbarContainer
 Container for the scenario editor's toolbar. More...
 
struct  MainToolbarWindow
 Main toolbar. More...
 
struct  ScenarioEditorToolbarWindow
 

Typedefs

typedef CallBackFunction MenuClickedProc(int index)
 
typedef CallBackFunction ToolbarButtonProc(Window *w)
 

Enumerations

enum  ToolbarMode { TB_NORMAL , TB_UPPER , TB_LOWER }
 Toobar modes. More...
 
enum  CallBackFunction { CBF_NONE , CBF_PLACE_SIGN , CBF_PLACE_LANDINFO }
 Callback functions. More...
 
enum  OptionMenuEntries {
  OME_GAMEOPTIONS , OME_SETTINGS , OME_AI_SETTINGS , OME_GAMESCRIPT_SETTINGS ,
  OME_NEWGRFSETTINGS , OME_SANDBOX , OME_TRANSPARENCIES , OME_SHOW_TOWNNAMES ,
  OME_SHOW_STATIONNAMES , OME_SHOW_WAYPOINTNAMES , OME_SHOW_SIGNS , OME_SHOW_COMPETITOR_SIGNS ,
  OME_FULL_ANIMATION , OME_FULL_DETAILS , OME_TRANSPARENTBUILDINGS , OME_SHOW_STATIONSIGNS
}
 Game Option button menu entries. More...
 
enum  SaveLoadEditorMenuEntries {
  SLEME_SAVE_SCENARIO = 0 , SLEME_LOAD_SCENARIO , SLEME_SAVE_HEIGHTMAP , SLEME_LOAD_HEIGHTMAP ,
  SLEME_EXIT_TOINTRO , SLEME_EXIT_GAME
}
 SaveLoad entries in scenario editor mode. More...
 
enum  SaveLoadNormalMenuEntries { SLNME_SAVE_GAME = 0 , SLNME_LOAD_GAME , SLNME_EXIT_TOINTRO , SLNME_EXIT_GAME }
 SaveLoad entries in normal game mode. More...
 
enum  MapMenuEntries {
  MME_SHOW_SMALLMAP = 0 , MME_SHOW_EXTRAVIEWPORTS , MME_SHOW_LINKGRAPH , MME_SHOW_SIGNLISTS ,
  MME_SHOW_TOWNDIRECTORY , MME_SHOW_INDUSTRYDIRECTORY
}
 
enum  MainToolbarEditorHotkeys {
  MTEHK_PAUSE , MTEHK_FASTFORWARD , MTEHK_SETTINGS , MTEHK_SAVEGAME ,
  MTEHK_GENLAND , MTEHK_GENTOWN , MTEHK_GENINDUSTRY , MTEHK_BUILD_ROAD ,
  MTEHK_BUILD_TRAM , MTEHK_BUILD_DOCKS , MTEHK_BUILD_TREES , MTEHK_SIGN ,
  MTEHK_MUSIC , MTEHK_LANDINFO , MTEHK_SMALL_SCREENSHOT , MTEHK_ZOOMEDIN_SCREENSHOT ,
  MTEHK_DEFAULTZOOM_SCREENSHOT , MTEHK_GIANT_SCREENSHOT , MTEHK_ZOOM_IN , MTEHK_ZOOM_OUT ,
  MTEHK_TERRAFORM , MTEHK_SMALLMAP , MTEHK_EXTRA_VIEWPORT
}
 

Functions

static void PopupMainToolbarMenu (Window *w, WidgetID widget, DropDownList &&list, int def)
 Pop up a generic text only menu.
 
static void PopupMainToolbarMenu (Window *w, WidgetID widget, const std::initializer_list< StringID > &strings)
 Pop up a generic text only menu.
 
static void PopupMainCompanyToolbMenu (Window *w, WidgetID widget, CompanyMask grey=0)
 Pop up a generic company list menu.
 
static CallBackFunction SelectSignTool ()
 
static CallBackFunction ToolbarPauseClick (Window *)
 
static CallBackFunction ToolbarFastForwardClick (Window *)
 Toggle fast forward mode.
 
static CallBackFunction ToolbarOptionsClick (Window *w)
 Handle click on Options button in toolbar.
 
static CallBackFunction MenuClickSettings (int index)
 Handle click on one of the entries in the Options button menu.
 
static CallBackFunction ToolbarSaveClick (Window *w)
 Handle click on Save button in toolbar in normal game mode.
 
static CallBackFunction ToolbarScenSaveOrLoad (Window *w)
 Handle click on SaveLoad button in toolbar in the scenario editor.
 
static CallBackFunction MenuClickSaveLoad (int index=0)
 Handle click on one of the entries in the SaveLoad menu.
 
static CallBackFunction ToolbarMapClick (Window *w)
 
static CallBackFunction ToolbarScenMapTownDir (Window *w)
 
static CallBackFunction MenuClickMap (int index)
 Handle click on one of the entries in the Map menu.
 
static CallBackFunction ToolbarTownClick (Window *w)
 
static CallBackFunction MenuClickTown (int index)
 Handle click on one of the entries in the Town menu.
 
static CallBackFunction ToolbarSubsidiesClick (Window *w)
 
static CallBackFunction MenuClickSubsidies (int)
 Handle click on the entry in the Subsidies menu.
 
static CallBackFunction ToolbarStationsClick (Window *w)
 
static CallBackFunction MenuClickStations (int index)
 Handle click on the entry in the Stations menu.
 
static CallBackFunction ToolbarFinancesClick (Window *w)
 
static CallBackFunction MenuClickFinances (int index)
 Handle click on the entry in the finances overview menu.
 
static CallBackFunction ToolbarCompaniesClick (Window *w)
 
static CallBackFunction MenuClickCompany (int index)
 Handle click on the entry in the Company menu.
 
static CallBackFunction ToolbarStoryClick (Window *w)
 
static CallBackFunction MenuClickStory (int index)
 Handle click on the entry in the Story menu.
 
static CallBackFunction ToolbarGoalClick (Window *w)
 
static CallBackFunction MenuClickGoal (int index)
 Handle click on the entry in the Goal menu.
 
static void AddDropDownLeagueTableOptions (DropDownList &list)
 
static CallBackFunction ToolbarGraphsClick (Window *w)
 
static CallBackFunction ToolbarLeagueClick (Window *w)
 
static CallBackFunction MenuClickGraphsOrLeague (int index)
 Handle click on the entry in the Graphs or CompanyLeague.
 
static CallBackFunction ToolbarIndustryClick (Window *w)
 
static CallBackFunction MenuClickIndustry (int index)
 Handle click on the entry in the Industry menu.
 
static void ToolbarVehicleClick (Window *w, VehicleType veh)
 
static CallBackFunction ToolbarTrainClick (Window *w)
 
static CallBackFunction MenuClickShowTrains (int index)
 Handle click on the entry in the Train menu.
 
static CallBackFunction ToolbarRoadClick (Window *w)
 
static CallBackFunction MenuClickShowRoad (int index)
 Handle click on the entry in the Road Vehicles menu.
 
static CallBackFunction ToolbarShipClick (Window *w)
 
static CallBackFunction MenuClickShowShips (int index)
 Handle click on the entry in the Ships menu.
 
static CallBackFunction ToolbarAirClick (Window *w)
 
static CallBackFunction MenuClickShowAir (int index)
 Handle click on the entry in the Aircraft menu.
 
static CallBackFunction ToolbarZoomInClick (Window *w)
 
static CallBackFunction ToolbarZoomOutClick (Window *w)
 
static CallBackFunction ToolbarBuildRailClick (Window *w)
 
static CallBackFunction MenuClickBuildRail (int index)
 Handle click on the entry in the Build Rail menu.
 
static CallBackFunction ToolbarBuildRoadClick (Window *w)
 
static CallBackFunction MenuClickBuildRoad (int index)
 Handle click on the entry in the Build Road menu.
 
static CallBackFunction ToolbarBuildTramClick (Window *w)
 
static CallBackFunction MenuClickBuildTram (int index)
 Handle click on the entry in the Build Tram menu.
 
static CallBackFunction ToolbarBuildWaterClick (Window *w)
 
static CallBackFunction MenuClickBuildWater (int)
 Handle click on the entry in the Build Waterways menu.
 
static CallBackFunction ToolbarBuildAirClick (Window *w)
 
static CallBackFunction MenuClickBuildAir (int)
 Handle click on the entry in the Build Air menu.
 
static CallBackFunction ToolbarForestClick (Window *w)
 
static CallBackFunction MenuClickForest (int index)
 Handle click on the entry in the landscaping menu.
 
static CallBackFunction ToolbarMusicClick (Window *w)
 
static CallBackFunction MenuClickMusicWindow (int)
 Handle click on the entry in the Music menu.
 
static CallBackFunction ToolbarNewspaperClick (Window *w)
 
static CallBackFunction MenuClickNewspaper (int index)
 Handle click on the entry in the Newspaper menu.
 
static CallBackFunction PlaceLandBlockInfo ()
 
static CallBackFunction ToolbarHelpClick (Window *w)
 
void ToggleBoundingBoxes ()
 Toggle drawing of sprites' bounding boxes.
 
void ToggleDirtyBlocks ()
 Toggle drawing of the dirty blocks.
 
void ToggleWidgetOutlines ()
 Toggle drawing of widget outlihes.
 
void SetStartingYear (TimerGameCalendar::Year year)
 Set the starting year for a scenario.
 
static CallBackFunction MenuClickHelp (int index)
 Choose the proper callback function for the main toolbar's help menu.
 
static CallBackFunction ToolbarSwitchClick (Window *w)
 
static CallBackFunction ToolbarScenDatePanel (Window *w)
 Called when clicking at the date panel of the scenario editor toolbar.
 
static CallBackFunction ToolbarScenDateBackward (Window *w)
 
static CallBackFunction ToolbarScenDateForward (Window *w)
 
static CallBackFunction ToolbarScenGenLand (Window *w)
 
static CallBackFunction ToolbarScenGenTownClick (Window *w)
 
static CallBackFunction ToolbarScenGenTown (int index)
 
static CallBackFunction ToolbarScenGenIndustry (Window *w)
 
static CallBackFunction ToolbarScenBuildRoadClick (Window *w)
 
static CallBackFunction ToolbarScenBuildRoad (int index)
 Handle click on the entry in the Build Road menu.
 
static CallBackFunction ToolbarScenBuildTramClick (Window *w)
 
static CallBackFunction ToolbarScenBuildTram (int index)
 Handle click on the entry in the Build Tram menu.
 
static CallBackFunction ToolbarScenBuildDocks (Window *w)
 
static CallBackFunction ToolbarScenPlantTrees (Window *w)
 
static CallBackFunction ToolbarScenPlaceSign (Window *w)
 
static CallBackFunction ToolbarBtn_NULL (Window *)
 
static std::unique_ptr< NWidgetBaseMakeMainToolbar ()
 
static std::unique_ptr< NWidgetBaseMakeScenarioToolbar ()
 
void AllocateToolbar ()
 Allocate the toolbar.
 

Variables

uint _toolbar_width = 0
 Width of the toolbar, shared by statusbar.
 
RailType _last_built_railtype
 
RoadType _last_built_roadtype
 
RoadType _last_built_tramtype
 
static CallBackFunction _last_started_action = CBF_NONE
 Last started user action.
 
static const int CTMN_CLIENT_LIST = -1
 Enum for the Company Toolbar's network related buttons.
 
static const int CTMN_SPECTATE = -2
 Become spectator.
 
static const int CTMN_SPECTATOR = -3
 Show a company window as spectator.
 
static ToolbarMode _toolbar_mode
 
static const int GRMN_OPERATING_PROFIT_GRAPH = -1
 Enum for the League Toolbar's and Graph Toolbar's related buttons.
 
static const int GRMN_INCOME_GRAPH = -2
 Show income graph.
 
static const int GRMN_DELIVERED_CARGO_GRAPH = -3
 Show delivered cargo graph.
 
static const int GRMN_PERFORMANCE_HISTORY_GRAPH = -4
 Show performance history graph.
 
static const int GRMN_COMPANY_VALUE_GRAPH = -5
 Show company value graph.
 
static const int GRMN_CARGO_PAYMENT_RATES = -6
 Show cargo payment rates graph.
 
static const int LTMN_PERFORMANCE_LEAGUE = -7
 Show default league table.
 
static const int LTMN_PERFORMANCE_RATING = -8
 Show detailed performance rating.
 
static const int LTMN_HIGHSCORE = -9
 Show highscrore table.
 
static MenuClickedProc *const _menu_clicked_procs []
 
static ToolbarButtonProc *const _toolbar_button_procs []
 
static constexpr NWidgetPart _nested_toolbar_normal_widgets []
 
static WindowDesc _toolb_normal_desc (WDP_MANUAL, nullptr, 0, 0, WC_MAIN_TOOLBAR, WC_NONE, WDF_NO_FOCUS|WDF_NO_CLOSE, _nested_toolbar_normal_widgets, &MainToolbarWindow::hotkeys)
 
static MenuClickedProc *const _scen_toolbar_dropdown_procs []
 
static ToolbarButtonProc *const _scen_toolbar_button_procs []
 
static constexpr NWidgetPart _nested_toolb_scen_inner_widgets []
 
static constexpr NWidgetPart _nested_toolb_scen_widgets []
 
static WindowDesc _toolb_scen_desc (WDP_MANUAL, nullptr, 0, 0, WC_MAIN_TOOLBAR, WC_NONE, WDF_NO_FOCUS|WDF_NO_CLOSE, _nested_toolb_scen_widgets, &ScenarioEditorToolbarWindow::hotkeys)
 

Detailed Description

Code related to the (main) toolbar.

Definition in file toolbar_gui.cpp.

Typedef Documentation

◆ MenuClickedProc

typedef CallBackFunction MenuClickedProc(int index)

Definition at line 1306 of file toolbar_gui.cpp.

◆ ToolbarButtonProc

typedef CallBackFunction ToolbarButtonProc(Window *w)

Definition at line 1920 of file toolbar_gui.cpp.

Enumeration Type Documentation

◆ CallBackFunction

Callback functions.

Definition at line 88 of file toolbar_gui.cpp.

◆ MainToolbarEditorHotkeys

enum MainToolbarEditorHotkeys

Definition at line 2272 of file toolbar_gui.cpp.

◆ MapMenuEntries

enum MapMenuEntries

Definition at line 400 of file toolbar_gui.cpp.

◆ OptionMenuEntries

Game Option button menu entries.

Definition at line 229 of file toolbar_gui.cpp.

◆ SaveLoadEditorMenuEntries

SaveLoad entries in scenario editor mode.

Definition at line 324 of file toolbar_gui.cpp.

◆ SaveLoadNormalMenuEntries

SaveLoad entries in normal game mode.

Definition at line 336 of file toolbar_gui.cpp.

◆ ToolbarMode

Toobar modes.

Definition at line 81 of file toolbar_gui.cpp.

Function Documentation

◆ AddDropDownLeagueTableOptions()

static void AddDropDownLeagueTableOptions ( DropDownList list)
static

Definition at line 631 of file toolbar_gui.cpp.

◆ AllocateToolbar()

void AllocateToolbar ( )

Allocate the toolbar.

Definition at line 2558 of file toolbar_gui.cpp.

References ROADTYPE_ROAD, and ROADTYPE_TRAM.

Referenced by ShowVitalWindows().

◆ MakeMainToolbar()

static std::unique_ptr< NWidgetBase > MakeMainToolbar ( )
static

Sprites to use for the different toolbar buttons

Definition at line 2148 of file toolbar_gui.cpp.

References WID_TN_BUILDING_TOOLS_START, WID_TN_END, WID_TN_FINANCES, WID_TN_MUSIC_SOUND, WID_TN_SAVE, WID_TN_SMALL_MAP, WID_TN_VEHICLE_START, WID_TN_ZOOM_IN, WWT_IMGBTN, and WWT_IMGBTN_2.

◆ MakeScenarioToolbar()

static std::unique_ptr< NWidgetBase > MakeScenarioToolbar ( )
static

Definition at line 2540 of file toolbar_gui.cpp.

◆ MenuClickBuildAir()

static CallBackFunction MenuClickBuildAir ( int  )
static

Handle click on the entry in the Build Air menu.

Returns
CBF_NONE

Definition at line 953 of file toolbar_gui.cpp.

References ShowBuildAirToolbar().

◆ MenuClickBuildRail()

static CallBackFunction MenuClickBuildRail ( int  index)
static

Handle click on the entry in the Build Rail menu.

Parameters
indexRailType to show the build toolbar for.
Returns
CBF_NONE

Definition at line 864 of file toolbar_gui.cpp.

References ShowBuildRailToolbar().

◆ MenuClickBuildRoad()

static CallBackFunction MenuClickBuildRoad ( int  index)
static

Handle click on the entry in the Build Road menu.

Parameters
indexRoadType to show the build toolbar for.
Returns
CBF_NONE

Definition at line 886 of file toolbar_gui.cpp.

References ShowBuildRoadToolbar().

◆ MenuClickBuildTram()

static CallBackFunction MenuClickBuildTram ( int  index)
static

Handle click on the entry in the Build Tram menu.

Parameters
indexRoadType to show the build toolbar for.
Returns
CBF_NONE

Definition at line 908 of file toolbar_gui.cpp.

References ShowBuildRoadToolbar().

◆ MenuClickBuildWater()

static CallBackFunction MenuClickBuildWater ( int  )
static

Handle click on the entry in the Build Waterways menu.

Returns
CBF_NONE

Definition at line 931 of file toolbar_gui.cpp.

References ShowBuildDocksToolbar().

◆ MenuClickCompany()

static CallBackFunction MenuClickCompany ( int  index)
static

Handle click on the entry in the Company menu.

Parameters
indexMenu entry to handle.
Returns
CBF_NONE

Definition at line 553 of file toolbar_gui.cpp.

References _network_server, _networking, CLIENT_ID_SERVER, COMPANY_SPECTATOR, CTMN_CLIENT_LIST, CTMN_SPECTATE, MarkWholeScreenDirty(), NetworkClientRequestMove(), NetworkServerDoMove(), and ShowCompany().

◆ MenuClickFinances()

static CallBackFunction MenuClickFinances ( int  index)
static

Handle click on the entry in the finances overview menu.

Parameters
indexCompanyID to show finances for.
Returns
CBF_NONE

Definition at line 533 of file toolbar_gui.cpp.

References ShowCompanyFinances().

◆ MenuClickForest()

static CallBackFunction MenuClickForest ( int  index)
static

Handle click on the entry in the landscaping menu.

Parameters
indexMenu entry clicked.
Returns
CBF_NONE

Definition at line 978 of file toolbar_gui.cpp.

References ShowTerraformToolbar().

◆ MenuClickGoal()

static CallBackFunction MenuClickGoal ( int  index)
static

Handle click on the entry in the Goal menu.

Parameters
indexCompanyID to show story book for
Returns
CBF_NONE

Definition at line 609 of file toolbar_gui.cpp.

References CTMN_SPECTATOR, INVALID_COMPANY, and ShowGoalsList().

◆ MenuClickGraphsOrLeague()

◆ MenuClickHelp()

static CallBackFunction MenuClickHelp ( int  index)
static

Choose the proper callback function for the main toolbar's help menu.

Parameters
indexThe menu index which was selected.
Returns
CBF_NONE

Definition at line 1134 of file toolbar_gui.cpp.

References _ctrl_pressed, IConsoleSwitch(), INVALID_COMPANY, ShowFramerateWindow(), ShowScriptDebugWindow(), ShowSpriteAlignerWindow(), ToggleBoundingBoxes(), ToggleDirtyBlocks(), and ToggleWidgetOutlines().

◆ MenuClickIndustry()

static CallBackFunction MenuClickIndustry ( int  index)
static

Handle click on the entry in the Industry menu.

Parameters
indexMenu entry number.
Returns
CBF_NONE

Definition at line 726 of file toolbar_gui.cpp.

References ShowIndustryCargoesWindow().

◆ MenuClickMap()

static CallBackFunction MenuClickMap ( int  index)
static

Handle click on one of the entries in the Map menu.

Parameters
indexIndex being clicked.
Returns
CBF_NONE

Definition at line 438 of file toolbar_gui.cpp.

References ShowExtraViewportWindow(), ShowLinkGraphLegend(), ShowSignList(), and ShowSmallMap().

◆ MenuClickMusicWindow()

static CallBackFunction MenuClickMusicWindow ( int  )
static

Handle click on the entry in the Music menu.

Returns
CBF_NONE

Definition at line 1001 of file toolbar_gui.cpp.

◆ MenuClickNewspaper()

static CallBackFunction MenuClickNewspaper ( int  index)
static

Handle click on the entry in the Newspaper menu.

Parameters
indexMenu entry clicked.
Returns
CBF_NONE

Definition at line 1021 of file toolbar_gui.cpp.

References DeleteAllMessages(), ShowLastNewsMessage(), and ShowMessageHistory().

◆ MenuClickSaveLoad()

static CallBackFunction MenuClickSaveLoad ( int  index = 0)
static

Handle click on one of the entries in the SaveLoad menu.

Parameters
indexIndex being clicked.
Returns
CBF_NONE

Definition at line 376 of file toolbar_gui.cpp.

References FT_HEIGHTMAP, FT_SAVEGAME, FT_SCENARIO, ShowSaveLoadDialog(), SLO_LOAD, and SLO_SAVE.

Referenced by MainToolbarWindow::OnHotkey(), and ScenarioEditorToolbarWindow::OnHotkey().

◆ MenuClickSettings()

◆ MenuClickShowAir()

static CallBackFunction MenuClickShowAir ( int  index)
static

Handle click on the entry in the Aircraft menu.

Parameters
indexCompanyID to show aircraft list for.
Returns
CBF_NONE

Definition at line 821 of file toolbar_gui.cpp.

References VEH_AIRCRAFT.

◆ MenuClickShowRoad()

static CallBackFunction MenuClickShowRoad ( int  index)
static

Handle click on the entry in the Road Vehicles menu.

Parameters
indexCompanyID to show road vehicles list for.
Returns
CBF_NONE

Definition at line 781 of file toolbar_gui.cpp.

References VEH_ROAD.

◆ MenuClickShowShips()

static CallBackFunction MenuClickShowShips ( int  index)
static

Handle click on the entry in the Ships menu.

Parameters
indexCompanyID to show ship list for.
Returns
CBF_NONE

Definition at line 801 of file toolbar_gui.cpp.

References VEH_SHIP.

◆ MenuClickShowTrains()

static CallBackFunction MenuClickShowTrains ( int  index)
static

Handle click on the entry in the Train menu.

Parameters
indexCompanyID to show train list for.
Returns
CBF_NONE

Definition at line 761 of file toolbar_gui.cpp.

References VEH_TRAIN.

◆ MenuClickStations()

static CallBackFunction MenuClickStations ( int  index)
static

Handle click on the entry in the Stations menu.

Parameters
indexCompanyID to show station list for
Returns
CBF_NONE

Definition at line 513 of file toolbar_gui.cpp.

References ShowCompanyStations().

◆ MenuClickStory()

static CallBackFunction MenuClickStory ( int  index)
static

Handle click on the entry in the Story menu.

Parameters
indexCompanyID to show story book for
Returns
CBF_NONE

Definition at line 589 of file toolbar_gui.cpp.

References CTMN_SPECTATOR, INVALID_COMPANY, and ShowStoryBook().

◆ MenuClickSubsidies()

static CallBackFunction MenuClickSubsidies ( int  )
static

Handle click on the entry in the Subsidies menu.

Returns
CBF_NONE

Definition at line 493 of file toolbar_gui.cpp.

◆ MenuClickTown()

static CallBackFunction MenuClickTown ( int  index)
static

Handle click on one of the entries in the Town menu.

Parameters
indexIndex being clicked.
Returns
CBF_NONE

Definition at line 469 of file toolbar_gui.cpp.

References _settings_game, GameSettings::economy, EconomySettings::found_town, and TF_FORBIDDEN.

◆ PlaceLandBlockInfo()

static CallBackFunction PlaceLandBlockInfo ( )
static

Definition at line 1033 of file toolbar_gui.cpp.

◆ PopupMainCompanyToolbMenu()

static void PopupMainCompanyToolbMenu ( Window w,
WidgetID  widget,
CompanyMask  grey = 0 
)
static

Pop up a generic company list menu.

Parameters
wThe toolbar window.
widgetThe button widget id.
greyA bitmask of which companies to mark as disabled.

Definition at line 154 of file toolbar_gui.cpp.

References _local_company, _networking, COMPANY_FIRST, COMPANY_SPECTATOR, CTMN_CLIENT_LIST, CTMN_SPECTATE, CTMN_SPECTATOR, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), MAX_COMPANIES, PopupMainToolbarMenu(), WID_TN_COMPANIES, WID_TN_GOAL, and WID_TN_STORY.

◆ PopupMainToolbarMenu() [1/2]

static void PopupMainToolbarMenu ( Window w,
WidgetID  widget,
const std::initializer_list< StringID > &  strings 
)
static

Pop up a generic text only menu.

Parameters
wToolbar
widgetToolbar button
stringsList of strings for each item in the menu

Definition at line 128 of file toolbar_gui.cpp.

References PopupMainToolbarMenu().

◆ PopupMainToolbarMenu() [2/2]

static void PopupMainToolbarMenu ( Window w,
WidgetID  widget,
DropDownList &&  list,
int  def 
)
static

Pop up a generic text only menu.

Parameters
wToolbar
widgetToolbar button
listList of items
defDefault item

Definition at line 116 of file toolbar_gui.cpp.

References _settings_client, SoundSettings::click_beep, ShowDropDownList(), SND_15_BEEP, and ClientSettings::sound.

Referenced by PopupMainCompanyToolbMenu(), PopupMainToolbarMenu(), ToolbarSaveClick(), and ToolbarScenSaveOrLoad().

◆ SelectSignTool()

static CallBackFunction SelectSignTool ( )
static

Definition at line 188 of file toolbar_gui.cpp.

◆ SetStartingYear()

◆ ToggleBoundingBoxes()

void ToggleBoundingBoxes ( )

Toggle drawing of sprites' bounding boxes.

Note
has only an effect when newgrf_developer_tools are active.

Function is found here and not in viewport.cpp in order to avoid importing the settings structs to there.

Definition at line 1067 of file toolbar_gui.cpp.

References _settings_client, ClientSettings::gui, MarkWholeScreenDirty(), and GUISettings::newgrf_developer_tools.

Referenced by MenuClickHelp(), and MainWindow::OnHotkey().

◆ ToggleDirtyBlocks()

void ToggleDirtyBlocks ( )

Toggle drawing of the dirty blocks.

Note
has only an effect when newgrf_developer_tools are active.

Function is found here and not in viewport.cpp in order to avoid importing the settings structs to there.

Definition at line 1084 of file toolbar_gui.cpp.

References _settings_client, ClientSettings::gui, MarkWholeScreenDirty(), and GUISettings::newgrf_developer_tools.

Referenced by MenuClickHelp(), and MainWindow::OnHotkey().

◆ ToggleWidgetOutlines()

void ToggleWidgetOutlines ( )

Toggle drawing of widget outlihes.

Note
has only an effect when newgrf_developer_tools are active.

Definition at line 1098 of file toolbar_gui.cpp.

References _settings_client, ClientSettings::gui, MarkWholeScreenDirty(), and GUISettings::newgrf_developer_tools.

Referenced by MenuClickHelp(), and MainWindow::OnHotkey().

◆ ToolbarAirClick()

static CallBackFunction ToolbarAirClick ( Window w)
static

Definition at line 809 of file toolbar_gui.cpp.

◆ ToolbarBtn_NULL()

static CallBackFunction ToolbarBtn_NULL ( Window )
static

Definition at line 1301 of file toolbar_gui.cpp.

◆ ToolbarBuildAirClick()

static CallBackFunction ToolbarBuildAirClick ( Window w)
static

Definition at line 939 of file toolbar_gui.cpp.

◆ ToolbarBuildRailClick()

static CallBackFunction ToolbarBuildRailClick ( Window w)
static

Definition at line 851 of file toolbar_gui.cpp.

◆ ToolbarBuildRoadClick()

static CallBackFunction ToolbarBuildRoadClick ( Window w)
static

Definition at line 873 of file toolbar_gui.cpp.

◆ ToolbarBuildTramClick()

static CallBackFunction ToolbarBuildTramClick ( Window w)
static

Definition at line 895 of file toolbar_gui.cpp.

◆ ToolbarBuildWaterClick()

static CallBackFunction ToolbarBuildWaterClick ( Window w)
static

Definition at line 917 of file toolbar_gui.cpp.

◆ ToolbarCompaniesClick()

static CallBackFunction ToolbarCompaniesClick ( Window w)
static

Definition at line 541 of file toolbar_gui.cpp.

◆ ToolbarFastForwardClick()

static CallBackFunction ToolbarFastForwardClick ( Window )
static

Toggle fast forward mode.

Returns
CBF_NONE

Definition at line 216 of file toolbar_gui.cpp.

References _game_speed, _networking, _settings_client, SoundSettings::click_beep, SND_15_BEEP, and ClientSettings::sound.

Referenced by MainToolbarWindow::OnHotkey(), and ScenarioEditorToolbarWindow::OnHotkey().

◆ ToolbarFinancesClick()

static CallBackFunction ToolbarFinancesClick ( Window w)
static

Definition at line 521 of file toolbar_gui.cpp.

◆ ToolbarForestClick()

static CallBackFunction ToolbarForestClick ( Window w)
static

Definition at line 961 of file toolbar_gui.cpp.

◆ ToolbarGoalClick()

static CallBackFunction ToolbarGoalClick ( Window w)
static

Definition at line 597 of file toolbar_gui.cpp.

◆ ToolbarGraphsClick()

static CallBackFunction ToolbarGraphsClick ( Window w)
static

Definition at line 646 of file toolbar_gui.cpp.

◆ ToolbarHelpClick()

static CallBackFunction ToolbarHelpClick ( Window w)
static

Definition at line 1044 of file toolbar_gui.cpp.

◆ ToolbarIndustryClick()

static CallBackFunction ToolbarIndustryClick ( Window w)
static

Definition at line 709 of file toolbar_gui.cpp.

◆ ToolbarLeagueClick()

static CallBackFunction ToolbarLeagueClick ( Window w)
static

Definition at line 665 of file toolbar_gui.cpp.

◆ ToolbarMapClick()

static CallBackFunction ToolbarMapClick ( Window w)
static

Definition at line 409 of file toolbar_gui.cpp.

◆ ToolbarMusicClick()

static CallBackFunction ToolbarMusicClick ( Window w)
static

Definition at line 990 of file toolbar_gui.cpp.

◆ ToolbarNewspaperClick()

static CallBackFunction ToolbarNewspaperClick ( Window w)
static

Definition at line 1009 of file toolbar_gui.cpp.

◆ ToolbarOptionsClick()

static CallBackFunction ToolbarOptionsClick ( Window w)
static

◆ ToolbarPauseClick()

static CallBackFunction ToolbarPauseClick ( Window )
static

Definition at line 201 of file toolbar_gui.cpp.

◆ ToolbarRoadClick()

static CallBackFunction ToolbarRoadClick ( Window w)
static

Definition at line 769 of file toolbar_gui.cpp.

◆ ToolbarSaveClick()

static CallBackFunction ToolbarSaveClick ( Window w)
static

Handle click on Save button in toolbar in normal game mode.

Parameters
wparent window the shown save dialogue is attached to.
Returns
CBF_NONE

Definition at line 349 of file toolbar_gui.cpp.

References PopupMainToolbarMenu(), and WID_TN_SAVE.

◆ ToolbarScenBuildDocks()

static CallBackFunction ToolbarScenBuildDocks ( Window w)
static

Definition at line 1278 of file toolbar_gui.cpp.

◆ ToolbarScenBuildRoad()

static CallBackFunction ToolbarScenBuildRoad ( int  index)
static

Handle click on the entry in the Build Road menu.

Parameters
indexRoadType to show the build toolbar for.
Returns
CBF_NONE

Definition at line 1251 of file toolbar_gui.cpp.

References ShowBuildRoadScenToolbar().

◆ ToolbarScenBuildRoadClick()

static CallBackFunction ToolbarScenBuildRoadClick ( Window w)
static

Definition at line 1238 of file toolbar_gui.cpp.

◆ ToolbarScenBuildTram()

static CallBackFunction ToolbarScenBuildTram ( int  index)
static

Handle click on the entry in the Build Tram menu.

Parameters
indexRoadType to show the build toolbar for.
Returns
CBF_NONE

Definition at line 1271 of file toolbar_gui.cpp.

References ShowBuildRoadScenToolbar().

◆ ToolbarScenBuildTramClick()

static CallBackFunction ToolbarScenBuildTramClick ( Window w)
static

Definition at line 1258 of file toolbar_gui.cpp.

◆ ToolbarScenDateBackward()

static CallBackFunction ToolbarScenDateBackward ( Window w)
static

Definition at line 1180 of file toolbar_gui.cpp.

◆ ToolbarScenDateForward()

static CallBackFunction ToolbarScenDateForward ( Window w)
static

Definition at line 1193 of file toolbar_gui.cpp.

◆ ToolbarScenDatePanel()

static CallBackFunction ToolbarScenDatePanel ( Window w)
static

Called when clicking at the date panel of the scenario editor toolbar.

Definition at line 1173 of file toolbar_gui.cpp.

References _settings_game, CS_NUMERAL, GameSettings::game_creation, QSF_ENABLE_DEFAULT, SetDParam(), ShowQueryString(), and GameCreationSettings::starting_year.

◆ ToolbarScenGenIndustry()

static CallBackFunction ToolbarScenGenIndustry ( Window w)
static

Definition at line 1230 of file toolbar_gui.cpp.

◆ ToolbarScenGenLand()

static CallBackFunction ToolbarScenGenLand ( Window w)
static

Definition at line 1206 of file toolbar_gui.cpp.

◆ ToolbarScenGenTown()

static CallBackFunction ToolbarScenGenTown ( int  index)
static

Definition at line 1221 of file toolbar_gui.cpp.

◆ ToolbarScenGenTownClick()

static CallBackFunction ToolbarScenGenTownClick ( Window w)
static

Definition at line 1215 of file toolbar_gui.cpp.

◆ ToolbarScenMapTownDir()

static CallBackFunction ToolbarScenMapTownDir ( Window w)
static

Definition at line 420 of file toolbar_gui.cpp.

◆ ToolbarScenPlaceSign()

static CallBackFunction ToolbarScenPlaceSign ( Window w)
static

Definition at line 1294 of file toolbar_gui.cpp.

◆ ToolbarScenPlantTrees()

static CallBackFunction ToolbarScenPlantTrees ( Window w)
static

Definition at line 1286 of file toolbar_gui.cpp.

◆ ToolbarScenSaveOrLoad()

static CallBackFunction ToolbarScenSaveOrLoad ( Window w)
static

Handle click on SaveLoad button in toolbar in the scenario editor.

Parameters
wparent window the shown save dialogue is attached to.
Returns
CBF_NONE

Definition at line 362 of file toolbar_gui.cpp.

References PopupMainToolbarMenu(), and WID_TE_SAVE.

◆ ToolbarShipClick()

static CallBackFunction ToolbarShipClick ( Window w)
static

Definition at line 789 of file toolbar_gui.cpp.

◆ ToolbarStationsClick()

static CallBackFunction ToolbarStationsClick ( Window w)
static

Definition at line 501 of file toolbar_gui.cpp.

◆ ToolbarStoryClick()

static CallBackFunction ToolbarStoryClick ( Window w)
static

Definition at line 577 of file toolbar_gui.cpp.

◆ ToolbarSubsidiesClick()

static CallBackFunction ToolbarSubsidiesClick ( Window w)
static

Definition at line 482 of file toolbar_gui.cpp.

◆ ToolbarSwitchClick()

static CallBackFunction ToolbarSwitchClick ( Window w)
static

Definition at line 1154 of file toolbar_gui.cpp.

◆ ToolbarTownClick()

static CallBackFunction ToolbarTownClick ( Window w)
static

Definition at line 453 of file toolbar_gui.cpp.

◆ ToolbarTrainClick()

static CallBackFunction ToolbarTrainClick ( Window w)
static

Definition at line 749 of file toolbar_gui.cpp.

◆ ToolbarVehicleClick()

static void ToolbarVehicleClick ( Window w,
VehicleType  veh 
)
static

Definition at line 738 of file toolbar_gui.cpp.

◆ ToolbarZoomInClick()

static CallBackFunction ToolbarZoomInClick ( Window w)
static

Definition at line 829 of file toolbar_gui.cpp.

◆ ToolbarZoomOutClick()

static CallBackFunction ToolbarZoomOutClick ( Window w)
static

Definition at line 840 of file toolbar_gui.cpp.

Variable Documentation

◆ _last_built_railtype

RailType _last_built_railtype

Definition at line 76 of file toolbar_gui.cpp.

◆ _last_built_roadtype

RoadType _last_built_roadtype

Definition at line 77 of file toolbar_gui.cpp.

◆ _last_built_tramtype

RoadType _last_built_tramtype

Definition at line 78 of file toolbar_gui.cpp.

◆ _last_started_action

◆ _menu_clicked_procs

MenuClickedProc* const _menu_clicked_procs[]
static

Definition at line 1308 of file toolbar_gui.cpp.

◆ _nested_toolb_scen_inner_widgets

constexpr NWidgetPart _nested_toolb_scen_inner_widgets[]
staticconstexpr

Definition at line 2505 of file toolbar_gui.cpp.

◆ _nested_toolb_scen_widgets

constexpr NWidgetPart _nested_toolb_scen_widgets[]
staticconstexpr
Initial value:
= {
NWidgetFunction(MakeScenarioToolbar),
}
constexpr NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.

Definition at line 2545 of file toolbar_gui.cpp.

◆ _nested_toolbar_normal_widgets

constexpr NWidgetPart _nested_toolbar_normal_widgets[]
staticconstexpr
Initial value:
= {
}
static std::unique_ptr< NWidgetBase > MakeMainToolbar()

Definition at line 2205 of file toolbar_gui.cpp.

◆ _scen_toolbar_button_procs

ToolbarButtonProc* const _scen_toolbar_button_procs[]
static
Initial value:
= {
ToolbarPauseClick,
ToolbarBtn_NULL,
ToolbarScenDateBackward,
ToolbarScenDateForward,
ToolbarScenMapTownDir,
ToolbarZoomInClick,
ToolbarZoomOutClick,
ToolbarScenGenLand,
ToolbarScenGenTownClick,
ToolbarScenGenIndustry,
ToolbarScenBuildRoadClick,
ToolbarScenBuildTramClick,
ToolbarScenBuildDocks,
ToolbarScenPlantTrees,
ToolbarScenPlaceSign,
ToolbarBtn_NULL,
ToolbarMusicClick,
ToolbarHelpClick,
ToolbarSwitchClick,
}
static CallBackFunction ToolbarOptionsClick(Window *w)
Handle click on Options button in toolbar.
static CallBackFunction ToolbarScenSaveOrLoad(Window *w)
Handle click on SaveLoad button in toolbar in the scenario editor.
static CallBackFunction ToolbarFastForwardClick(Window *)
Toggle fast forward mode.
static CallBackFunction ToolbarScenDatePanel(Window *w)
Called when clicking at the date panel of the scenario editor toolbar.

Definition at line 2246 of file toolbar_gui.cpp.

◆ _scen_toolbar_dropdown_procs

MenuClickedProc* const _scen_toolbar_dropdown_procs[]
static
Initial value:
= {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
ToolbarScenGenTown,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
}
static CallBackFunction MenuClickHelp(int index)
Choose the proper callback function for the main toolbar's help menu.
static CallBackFunction MenuClickSaveLoad(int index=0)
Handle click on one of the entries in the SaveLoad menu.
static CallBackFunction MenuClickMusicWindow(int)
Handle click on the entry in the Music menu.
static CallBackFunction ToolbarScenBuildTram(int index)
Handle click on the entry in the Build Tram menu.
static CallBackFunction ToolbarScenBuildRoad(int index)
Handle click on the entry in the Build Road menu.
static CallBackFunction MenuClickMap(int index)
Handle click on one of the entries in the Map menu.
static CallBackFunction MenuClickSettings(int index)
Handle click on one of the entries in the Options button menu.

Definition at line 2220 of file toolbar_gui.cpp.

◆ _toolbar_button_procs

ToolbarButtonProc* const _toolbar_button_procs[]
static

Definition at line 1922 of file toolbar_gui.cpp.

◆ _toolbar_mode

ToolbarMode _toolbar_mode
static

Definition at line 186 of file toolbar_gui.cpp.

◆ _toolbar_width

◆ CTMN_CLIENT_LIST

const int CTMN_CLIENT_LIST = -1
static

Enum for the Company Toolbar's network related buttons.

Show the client list

Definition at line 144 of file toolbar_gui.cpp.

Referenced by MenuClickCompany(), and PopupMainCompanyToolbMenu().

◆ CTMN_SPECTATE

const int CTMN_SPECTATE = -2
static

Become spectator.

Definition at line 145 of file toolbar_gui.cpp.

Referenced by MenuClickCompany(), and PopupMainCompanyToolbMenu().

◆ CTMN_SPECTATOR

const int CTMN_SPECTATOR = -3
static

Show a company window as spectator.

Definition at line 146 of file toolbar_gui.cpp.

Referenced by MenuClickGoal(), MenuClickStory(), and PopupMainCompanyToolbMenu().

◆ GRMN_CARGO_PAYMENT_RATES

const int GRMN_CARGO_PAYMENT_RATES = -6
static

Show cargo payment rates graph.

Definition at line 626 of file toolbar_gui.cpp.

Referenced by MenuClickGraphsOrLeague().

◆ GRMN_COMPANY_VALUE_GRAPH

const int GRMN_COMPANY_VALUE_GRAPH = -5
static

Show company value graph.

Definition at line 625 of file toolbar_gui.cpp.

Referenced by MenuClickGraphsOrLeague().

◆ GRMN_DELIVERED_CARGO_GRAPH

const int GRMN_DELIVERED_CARGO_GRAPH = -3
static

Show delivered cargo graph.

Definition at line 623 of file toolbar_gui.cpp.

Referenced by MenuClickGraphsOrLeague().

◆ GRMN_INCOME_GRAPH

const int GRMN_INCOME_GRAPH = -2
static

Show income graph.

Definition at line 622 of file toolbar_gui.cpp.

Referenced by MenuClickGraphsOrLeague().

◆ GRMN_OPERATING_PROFIT_GRAPH

const int GRMN_OPERATING_PROFIT_GRAPH = -1
static

Enum for the League Toolbar's and Graph Toolbar's related buttons.

Use continuous numbering as League Toolbar can be combined into the Graph Toolbar. Show operating profit graph

Definition at line 621 of file toolbar_gui.cpp.

Referenced by MenuClickGraphsOrLeague().

◆ GRMN_PERFORMANCE_HISTORY_GRAPH

const int GRMN_PERFORMANCE_HISTORY_GRAPH = -4
static

Show performance history graph.

Definition at line 624 of file toolbar_gui.cpp.

Referenced by MenuClickGraphsOrLeague().

◆ LTMN_HIGHSCORE

const int LTMN_HIGHSCORE = -9
static

Show highscrore table.

Definition at line 629 of file toolbar_gui.cpp.

Referenced by MenuClickGraphsOrLeague().

◆ LTMN_PERFORMANCE_LEAGUE

const int LTMN_PERFORMANCE_LEAGUE = -7
static

Show default league table.

Definition at line 627 of file toolbar_gui.cpp.

Referenced by MenuClickGraphsOrLeague().

◆ LTMN_PERFORMANCE_RATING

const int LTMN_PERFORMANCE_RATING = -8
static

Show detailed performance rating.

Definition at line 628 of file toolbar_gui.cpp.

Referenced by MenuClickGraphsOrLeague().