76#include "table/strings.h"
109class DropDownListCompanyItem :
public DropDownIcon<DropDownIcon<DropDownString<DropDownListItem>, true>> {
111 DropDownListCompanyItem(CompanyID company,
bool shaded) : DropDownIcon<DropDownIcon<DropDownString<DropDownListItem>,
true>>(
SPR_COMPANY_ICON,
GetCompanyPalette(company),
NetworkCanJoinCompany(company) ?
SPR_EMPTY :
SPR_LOCK, PAL_NONE,
GetString(STR_COMPANY_NAME_COMPANY_NUM, company, company), company.base(),
false, shaded)
150 if (
string == STR_NULL) {
196 for (CompanyID c = CompanyID::Begin(); c < MAX_COMPANIES; ++c) {
198 list.push_back(std::make_unique<DropDownListCompanyItem>(c, grey.Test(c)));
384 STR_NULL, STR_FILE_MENU_EXIT});
397 STR_SCENEDIT_FILE_MENU_SAVE_HEIGHTMAP, STR_SCENEDIT_FILE_MENU_LOAD_HEIGHTMAP,
398 STR_SCENEDIT_FILE_MENU_QUIT_EDITOR, STR_NULL, STR_SCENEDIT_FILE_MENU_QUIT});
439 ShowIndustryDirectory,
519 if (
_settings_game.economy.place_houses != PlaceHouses::Forbidden) ShowBuildHousePicker(
nullptr);
676static void AddDropDownLeagueTableOptions(
DropDownList &list)
712 AddDropDownLeagueTableOptions(list);
714 int selected = list[0]->result;
772 case 2: ShowBuildIndustryWindow();
break;
784 if (c->group_all[veh].num_vehicle == 0) dis.
Set(c->index);
1022 case 1: ShowBuildTreesToolbar();
break;
1023 case 2:
return SelectSignTool();
1089 STR_ABOUT_MENU_HELP, STR_NULL, STR_ABOUT_MENU_ENTER_SCREENSAVER_MODE,
1090 STR_ABOUT_MENU_TOGGLE_CONSOLE, STR_ABOUT_MENU_AI_DEBUG,
1091 STR_ABOUT_MENU_SCREENSHOT, STR_ABOUT_MENU_SHOW_FRAMERATE, STR_ABOUT_MENU_ABOUT_OPENTTD,
1092 STR_ABOUT_MENU_SPRITE_ALIGNER, STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES, STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS,
1093 STR_ABOUT_MENU_TOGGLE_WIDGET_OUTLINES});
1096 STR_ABOUT_MENU_HELP, STR_NULL, STR_ABOUT_MENU_ENTER_SCREENSAVER_MODE, STR_ABOUT_MENU_TOGGLE_CONSOLE, STR_ABOUT_MENU_AI_DEBUG,
1097 STR_ABOUT_MENU_SCREENSHOT, STR_ABOUT_MENU_SHOW_FRAMERATE, STR_ABOUT_MENU_ABOUT_OPENTTD});
1111 extern bool _draw_bounding_boxes;
1114 _draw_bounding_boxes = !_draw_bounding_boxes;
1128 extern bool _draw_dirty_blocks;
1131 _draw_dirty_blocks = !_draw_dirty_blocks;
1142 extern bool _draw_widget_outlines;
1144 if (
_settings_client.gui.newgrf_developer_tools || _draw_widget_outlines) {
1145 _draw_widget_outlines = !_draw_widget_outlines;
1179 case 0:
return PlaceLandBlockInfo();
1180 case 1: ShowHelpWindow();
break;
1184 case 5: ShowScreenshotWindow();
break;
1186 case 7: ShowAboutWindow();
break;
1266 case 0: ShowFoundTownWindow();
break;
1267 case 1: ShowBuildHousePicker(
nullptr);
break;
1275 ShowBuildIndustryWindow();
1327 ShowBuildTreesToolbar();
1334 return SelectSignTool();
1344static MenuClickedProc *
const _menu_clicked_procs[] = {
1378class NWidgetToolbarContainer :
public NWidgetContainer {
1409 for (
const auto &child_wid : this->
children) {
1410 child_wid->SetupSmallestSize(w);
1411 this->
smallest_y = std::max(this->
smallest_y, child_wid->smallest_y + child_wid->padding.Vertical());
1412 if (this->
IsButton(child_wid->type)) {
1414 this->
smallest_x = std::max(this->
smallest_x, child_wid->smallest_x + child_wid->padding.Horizontal());
1421 for (
const auto &child_wid : this->children) {
1423 if (!this->
IsButton(child_wid->type)) {
1424 child_wid->current_x = child_wid->smallest_x;
1446 uint arrangeable_count, button_count, spacer_count;
1450 std::map<WidgetID, uint> lookup;
1451 for (
auto it = std::begin(this->
children); it != std::end(this->
children); ++it) {
1452 NWidgetBase *nwid = it->get();
1456 assert(nwc !=
nullptr);
1457 lookup[nwc->GetIndex()] = std::distance(this->
children.begin(), it);
1462 uint spacer_space = std::max(0, (
int)given_width - (
int)(button_count * this->
smallest_x));
1463 uint button_space = given_width - spacer_space;
1468 const WidgetID *slotp = rtl ? &arrangement[arrangeable_count - 1] : arrangement;
1469 for (uint i = 0; i < arrangeable_count; i++) {
1470 uint slot = lookup[*slotp];
1471 auto &child_wid = this->
children[slot];
1473 if (spacer_space > 0 && slot > 0 && slot < this->
children.size() - 1) {
1474 const auto &possible_spacer = this->
children[slot + (rtl ? 1 : -1)];
1475 if (possible_spacer !=
nullptr && possible_spacer->type ==
NWID_SPACER) {
1476 uint add = spacer_space / (spacer_count - spacer_i);
1478 spacer_space -= add;
1484 if (this->
IsButton(child_wid->type)) {
1485 child_wid->current_x = button_space / (button_count - button_i);
1486 button_space -= child_wid->current_x;
1489 child_wid->current_x = child_wid->smallest_x;
1491 child_wid->AssignSizePosition(sizing, x + position, y, child_wid->current_x, this->current_y, rtl);
1492 position += child_wid->current_x;
1505 const Rect r = this->GetCurrentRect();
1527 static const uint SMALLEST_ARRANGEMENT = 14;
1528 static const uint BIGGEST_ARRANGEMENT = 20;
1536 static const WidgetID arrange14[] = {
1567 static const WidgetID arrange15[] = {
1600 static const WidgetID arrange16[] = {
1635 static const WidgetID arrange17[] = {
1672 static const WidgetID arrange18[] = {
1711 static const WidgetID arrange19[] = {
1752 static const WidgetID arrange20[] = {
1795 static const WidgetID arrange_all[] = {
1829 uint full_buttons = std::max(
CeilDiv(width, this->
smallest_x), SMALLEST_ARRANGEMENT);
1830 if (full_buttons > BIGGEST_ARRANGEMENT) {
1832 button_count = arrangeable_count =
lengthof(arrange_all);
1838 static const WidgetID *
const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20 };
1840 button_count = arrangeable_count = full_buttons;
1842 return arrangements[full_buttons - SMALLEST_ARRANGEMENT] + ((_toolbar_mode ==
ToolbarMode::Lower) ? full_buttons : 0);
1855 auto it = this->panel_widths.begin();
1856 for (
const auto &child_wid : this->
children) {
1857 if (child_wid->type ==
NWID_SPACER || this->IsButton(child_wid->type))
continue;
1859 assert(it != this->panel_widths.end());
1860 *it = child_wid->current_x;
1868 static const WidgetID arrange_all[] = {
1889 static const WidgetID arrange_nopanel[] = {
1909 static const WidgetID arrange_switch[] = {
1936 size_t min_full_width = (
lengthof(arrange_all) - std::size(this->panel_widths)) * this->
smallest_x + this->panel_widths[0] + this->panel_widths[1];
1937 if (width >= min_full_width) {
1938 width -= this->panel_widths[0] + this->panel_widths[1];
1939 arrangeable_count =
lengthof(arrange_all);
1940 button_count = arrangeable_count - 2;
1946 size_t min_small_width = (
lengthof(arrange_switch) - std::size(this->panel_widths)) * this->
smallest_x / 2 + this->panel_widths[1];
1947 if (width > min_small_width) {
1948 width -= this->panel_widths[1];
1949 arrangeable_count =
lengthof(arrange_nopanel);
1950 button_count = arrangeable_count - 1;
1951 spacer_count = this->
spacers - 1;
1952 return arrange_nopanel;
1956 width -= this->panel_widths[1];
1957 arrangeable_count =
lengthof(arrange_switch) / 2;
1958 button_count = arrangeable_count - 1;
1960 return arrange_switch + ((_toolbar_mode ==
ToolbarMode::Lower) ? arrangeable_count : 0);
1980 ToolbarSubsidiesClick,
1981 ToolbarStationsClick,
1982 ToolbarFinancesClick,
1983 ToolbarCompaniesClick,
1988 ToolbarIndustryClick,
1994 ToolbarZoomOutClick,
1995 ToolbarBuildRailClick,
1996 ToolbarBuildRoadClick,
1997 ToolbarBuildTramClick,
1998 ToolbarBuildWaterClick,
1999 ToolbarBuildAirClick,
2002 ToolbarNewspaperClick,
2056 case MTHK_PAUSE: ToolbarPauseClick(
this);
break;
2063 case MTHK_SUBSIDIES: ShowSubsidiesList();
break;
2069 case MTHK_GRAPHS: ShowOperatingProfitGraph();
break;
2070 case MTHK_LEAGUE: ShowFirstLeagueTable();
break;
2071 case MTHK_INDUSTRIES: ShowBuildIndustryWindow();
break;
2076 case MTHK_ZOOM_IN: ToolbarZoomInClick(
this);
break;
2077 case MTHK_ZOOM_OUT: ToolbarZoomOutClick(
this);
break;
2083 case MTHK_BUILD_TREES: ShowBuildTreesToolbar();
break;
2084 case MTHK_MUSIC: ShowMusicWindow();
break;
2095 case MTHK_LANDINFO: cbf = PlaceLandBlockInfo();
break;
2113 default: NOT_REACHED();
2140 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
2142 if (!gui_scope)
return;
2146 static inline HotkeyList hotkeys{
"maintoolbar", {
2147 Hotkey({WKC_F1, WKC_PAUSE},
"pause", MTHK_PAUSE),
2148 Hotkey(0,
"fastforward", MTHK_FASTFORWARD),
2149 Hotkey(WKC_F2,
"settings", MTHK_SETTINGS),
2150 Hotkey(WKC_F3,
"saveload", MTHK_SAVEGAME),
2151 Hotkey(0,
"load_game", MTHK_LOADGAME),
2152 Hotkey({WKC_F4,
'M'},
"smallmap", MTHK_SMALLMAP),
2153 Hotkey(WKC_F5,
"town_list", MTHK_TOWNDIRECTORY),
2154 Hotkey(WKC_F6,
"subsidies", MTHK_SUBSIDIES),
2155 Hotkey(WKC_F7,
"station_list", MTHK_STATIONS),
2156 Hotkey(WKC_F8,
"finances", MTHK_FINANCES),
2157 Hotkey(WKC_F9,
"companies", MTHK_COMPANIES),
2158 Hotkey(0,
"story_book", MTHK_STORY),
2159 Hotkey(0,
"goal_list", MTHK_GOAL),
2160 Hotkey(WKC_F10,
"graphs", MTHK_GRAPHS),
2161 Hotkey(WKC_F11,
"league", MTHK_LEAGUE),
2162 Hotkey(WKC_F12,
"industry_list", MTHK_INDUSTRIES),
2163 Hotkey(WKC_SHIFT | WKC_F1,
"train_list", MTHK_TRAIN_LIST),
2164 Hotkey(WKC_SHIFT | WKC_F2,
"roadveh_list", MTHK_ROADVEH_LIST),
2165 Hotkey(WKC_SHIFT | WKC_F3,
"ship_list", MTHK_SHIP_LIST),
2166 Hotkey(WKC_SHIFT | WKC_F4,
"aircraft_list", MTHK_AIRCRAFT_LIST),
2167 Hotkey({WKC_NUM_PLUS,
WKC_EQUALS, WKC_SHIFT |
WKC_EQUALS, WKC_SHIFT | WKC_F5},
"zoomin", MTHK_ZOOM_IN),
2168 Hotkey({WKC_NUM_MINUS,
WKC_MINUS, WKC_SHIFT |
WKC_MINUS, WKC_SHIFT | WKC_F6},
"zoomout", MTHK_ZOOM_OUT),
2169 Hotkey(WKC_SHIFT | WKC_F7,
"build_rail", MTHK_BUILD_RAIL),
2170 Hotkey(WKC_SHIFT | WKC_F8,
"build_road", MTHK_BUILD_ROAD),
2171 Hotkey(0,
"build_tram", MTHK_BUILD_TRAM),
2172 Hotkey(WKC_SHIFT | WKC_F9,
"build_docks", MTHK_BUILD_DOCKS),
2173 Hotkey(WKC_SHIFT | WKC_F10,
"build_airport", MTHK_BUILD_AIRPORT),
2174 Hotkey(WKC_SHIFT | WKC_F11,
"build_trees", MTHK_BUILD_TREES),
2175 Hotkey(WKC_SHIFT | WKC_F12,
"music", MTHK_MUSIC),
2176 Hotkey(0,
"ai_debug", MTHK_SCRIPT_DEBUG),
2177 Hotkey(WKC_CTRL |
'S',
"small_screenshot", MTHK_SMALL_SCREENSHOT),
2178 Hotkey(WKC_CTRL |
'P',
"zoomedin_screenshot", MTHK_ZOOMEDIN_SCREENSHOT),
2179 Hotkey(WKC_CTRL |
'D',
"defaultzoom_screenshot", MTHK_DEFAULTZOOM_SCREENSHOT),
2180 Hotkey(0,
"giant_screenshot", MTHK_GIANT_SCREENSHOT),
2181 Hotkey(WKC_CTRL | WKC_ALT |
'C',
"cheats", MTHK_CHEATS),
2182 Hotkey(
'L',
"terraform", MTHK_TERRAFORM),
2183 Hotkey(
'V',
"extra_viewport", MTHK_EXTRA_VIEWPORT),
2184 Hotkey(0,
"client_list", MTHK_CLIENT_LIST),
2185 Hotkey(0,
"sign_list", MTHK_SIGN_LIST),
2186 Hotkey(0,
"land_info", MTHK_LANDINFO),
2233 if (!SpriteExists(sprite))
continue;
2245 auto hor = std::make_unique<NWidgetMainToolbarContainer>();
2254 hor->Add(std::make_unique<NWidgetSpacer>(0, 0));
2257 auto leaf = std::make_unique<NWidgetLeaf>(tp,
Colours::Grey, widget,
WidgetData{.sprite = sprite}, STR_TOOLBAR_TOOLTIP_PAUSE_GAME + widget);
2258 leaf->SetToolbarMinimalSize(1);
2259 hor->Add(std::move(leaf));
2265static constexpr std::initializer_list<NWidgetPart> _nested_toolbar_normal_widgets = {
2272 WindowClass::MainToolbar, WindowClass::None,
2274 _nested_toolbar_normal_widgets,
2275 &MainToolbarWindow::hotkeys
2281static MenuClickedProc *
const _scen_toolbar_dropdown_procs[] = {
2314 ToolbarScenDateBackward,
2315 ToolbarScenDateForward,
2316 ToolbarScenMapTownDir,
2318 ToolbarZoomOutClick,
2320 ToolbarScenGenTownClick,
2321 ToolbarScenGenIndustry,
2322 ToolbarScenBuildRoadClick,
2323 ToolbarScenBuildTramClick,
2324 ToolbarScenBuildDocks,
2325 ToolbarScenPlantTrees,
2326 ToolbarScenPlaceSign,
2483 default: NOT_REACHED();
2517 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
2519 if (!gui_scope)
return;
2526 if (!str.has_value())
return;
2529 if (!str->empty()) {
2531 if (!val.has_value())
return;
2542 static inline HotkeyList hotkeys{
"scenedit_maintoolbar", {
2569static constexpr std::initializer_list<NWidgetPart> _nested_toolb_scen_inner_widgets = {
2604static std::unique_ptr<NWidgetBase> MakeScenarioToolbar()
2606 return MakeNWidgets(_nested_toolb_scen_inner_widgets, std::make_unique<NWidgetScenarioToolbarContainer>());
2609static constexpr std::initializer_list<NWidgetPart> _nested_toolb_scen_widgets = {
2616 WindowClass::MainToolbar, WindowClass::None,
2618 _nested_toolb_scen_widgets,
2619 &ScenarioEditorToolbarWindow::hotkeys
void ShowAIConfigWindow()
Open the AI config window.
Window for configuring the AIs.
Window * ShowBuildAirToolbar()
Open the build airport toolbar window.
Functions related to cheating.
void ShowCheatWindow()
Open cheat window.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr Timpl & Set()
Set all bits.
An interval timer will fire every interval, and will continue to fire until it is deleted.
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
Container for the 'normal' main toolbar.
const WidgetID * GetButtonArrangement(uint &width, uint &arrangeable_count, uint &button_count, uint &spacer_count) const override
Get the arrangement of the buttons for the toolbar.
static uint GetUIClassCount()
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
static void SetDate(Date date, DateFract fract)
Set the date.
static constexpr TimerGame< struct Calendar >::Year DEF_START_YEAR
static constexpr TimerGame< struct Calendar >::Year MIN_YEAR
static constexpr TimerGame< struct Calendar >::Year MAX_YEAR
static Date date
Current date in days (day counter).
static void SetDate(Date date, DateFract fract)
Set the date.
StrongType::Typedef< int32_t, struct YearTag< struct Calendar >, StrongType::Compare, StrongType::Integer > Year
StrongType::Typedef< int32_t, DateTag< struct Calendar >, StrongType::Compare, StrongType::Integer > Date
Functions related to commands.
PaletteID GetCompanyPalette(CompanyID company)
Get the palette for recolouring with a company colour.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Functions related to companies.
void ShowCompanyFinances(CompanyID company)
Open the finances window of a company.
void ShowCompany(CompanyID company)
Show the window with the overview of the company.
GUI Functions related to companies.
void ShowCompanyStations(CompanyID company)
Opens window with list of company's stations.
static constexpr CompanyID COMPANY_SPECTATOR
The client is spectating.
void ShowFramerateWindow()
Open the general framerate window.
void IConsoleSwitch()
Toggle in-game console between opened and closed.
GUI related functions in the console.
Window * ShowBuildDocksScenToolbar()
Open the build water toolbar window for the scenario editor.
Window * ShowBuildDocksToolbar()
Open the build water toolbar window.
std::unique_ptr< DropDownListItem > MakeDropDownListDividerItem()
Creates new DropDownListDividerItem.
std::unique_ptr< DropDownListItem > MakeDropDownListIconItem(SpriteID sprite, PaletteID palette, StringID str, int value, bool masked, bool shaded)
Creates new DropDownListIconItem.
std::unique_ptr< DropDownListItem > MakeDropDownListStringItem(StringID str, int value, bool masked, bool shaded)
Creates new DropDownListStringItem.
std::unique_ptr< DropDownListItem > MakeDropDownListCheckedItem(bool checked, StringID str, int value, bool masked, bool shaded, uint indent)
Creates new DropDownListCheckedItem.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, DropDownOptions options, std::string *const persistent_filter_text)
Show a drop down list.
Common drop down list components.
Functions related to the drop down widget.
Types related to the drop down widget.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
@ InstantClose
Set if releasing mouse button should close the list regardless of where the cursor is.
@ Filterable
Set if the dropdown is filterable.
EnumBitSet< DropDownOption, uint8_t > DropDownOptions
Bitset of DropDownOption elements.
@ Save
File is being saved.
@ Load
File is being loaded.
@ Savegame
old or new savegame
@ Scenario
old or new scenario
@ Heightmap
heightmap file
Declarations for savegames operations.
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Types for recording game performance data.
Base functions for all Games.
void ShowGSConfigWindow()
Open the GS config window.
Window for configuring GS.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
@ Centre
Align to the centre.
@ Middle
Align to the middle.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
bool _ctrl_pressed
Is Ctrl pressed?
bool _left_button_clicked
Is left mouse button clicked?
uint16_t _game_speed
Current game-speed; 100 is 1x, 0 is infinite.
PauseModes _pause_mode
The current pause mode.
void GfxFillRect(int left, int top, int right, int bottom, const std::variant< PixelColour, PaletteID > &colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
int DrawString(int left, int right, int top, std::string_view str, ExtendedTextColour colour, Alignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Dimension GetSquareScaledSpriteSize(SpriteID sprid)
Scale sprite size for GUI, as a square.
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
@ Normal
Index of the normal font in the font tables.
@ FromString
Marker for telling to use the colour from the string.
@ Checker
Draw only every second pixel, used for greying-out.
void ShowGoalsList(CompanyID company)
Open a goal list window.
static const CursorID SPR_CURSOR_SIGN
static const CursorID SPR_CURSOR_QUERY
void SetDirty() const
Mark entire window as dirty (in need of re-paint).
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
GUI functions that shouldn't be here.
void ShowStoryBook(CompanyID company, StoryPageID page_id=StoryPageID::Invalid(), bool centered=false)
Raise or create the story book window for company, at page page_id.
void ShowIndustryCargoesWindow()
Open the industry and cargoes window with an industry.
void ShowLandInfo(TileIndex tile)
Show land information window.
void ShowExtraViewportWindowForTileUnderCursor()
Show a new Extra Viewport window.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
void ShowGameOptions()
Open the game options window.
bool LoadHeightmap(DetailedFileType dft, std::string_view filename)
Load a heightmap from file and change the map in its current dimensions to a landscape representing t...
GUI to access manuals and related.
Declaration of functions and types defined in highscore.h and highscore_gui.h.
void ShowHighscoreTable(int difficulty=SP_CUSTOM, int8_t rank=-1)
Show the highscore table for a given difficulty.
Hotkey related functions.
static constexpr int SPECIAL_HOTKEY_BIT
Bit which denotes that hotkey isn't bound to UI button.
bool IsSpecialHotkey(const int &hotkey)
Checks if hotkey index is special or not.
Definition of HouseSpec and accessors.
League table GUI functions.
PoolID< uint8_t, struct LeagueTableIDTag, 255, 0xFF > LeagueTableID
ID of a league table.
void ShowLinkGraphLegend()
Open a link graph legend window.
Declaration of linkgraph overlay GUI.
#define Point
Macro that prevents name conflicts between included headers.
bool DoZoomInOutWindow(ZoomStateChange how, Window *w)
Zooms a viewport in a window in or out.
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Miscellaneous command definitions.
void ShowQueryString(std::string_view str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
bool _networking
are we in networking mode?
bool _network_server
network-server is active
bool NetworkCanJoinCompany(CompanyID company_id)
Returns whether the given company can be joined by this client.
Basic functions/variables used all over the place.
void NetworkClientRequestMove(CompanyID company_id)
Notify the server of this client wanting to be moved to another company.
Network functions used by other parts of OpenTTD.
void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
Handle the tid-bits of moving a client from one company to another.
void ShowClientList()
Open the client list window.
GUIs related to networking.
@ Server
Servers always have this ID.
GRFConfigList _grfconfig
First item in list of current GRF set up.
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfigList &config)
Setup the NewGRF gui.
Functions/types related to NewGRF debugging.
void ShowSpriteAlignerWindow()
Show the window for aligning sprites.
Functions related to NewGRF objects.
void ShowLastNewsMessage()
Show previous news item.
void ShowMessageHistory()
Display window with news messages history.
GUI functions related to the news.
Functions related to objects.
Window * ShowBuildObjectPicker()
Show our object picker.
@ ShowSigns
Display signs.
@ FullDetail
Also draw details of track and roads.
@ ShowWaypointNames
Display waypoint names.
@ ShowTownNames
Display town names.
@ ShowStationNames
Display station names.
@ FullAnimation
Perform palette animation.
@ ShowCompetitorSigns
Display signs, station names and waypoint names of opponent companies. Buoys and oilrig-stations are ...
@ Normal
A game normally paused.
@ Editor
In the scenario editor.
static constexpr PixelColour PC_VERY_DARK_RED
Almost-black red palette colour.
static constexpr PixelColour PC_DARK_RED
Dark red palette colour.
Window * ShowBuildRailToolbar(RailType railtype)
Open the build rail toolbar window for a specific rail type.
DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option)
Create a drop down list for all the rail types of the local company.
RailType
Enumeration for all possible railtypes.
RoadTypes GetRoadTypes(bool introduces)
Get list of road types, regardless of company availability.
RoadTypes GetMaskForRoadTramType(RoadTramType rtt)
Get the mask for road types of the given RoadTramType.
Window * ShowBuildRoadScenToolbar(RoadType roadtype)
Show the road building toolbar in the scenario editor.
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
Functions/types related to the road GUIs.
RoadType
The different roadtypes we support.
A number of safeguards to prevent using unsafe methods.
void ToggleScreensaverMode()
Enters or exits "Screensaver Mode".
Exports a function to turn on and off a screensaver mode.
void MakeScreenshotWithConfirm(ScreenshotType t)
Make a screenshot.
Functions to make screenshots.
@ SC_VIEWPORT
Screenshot of viewport.
@ SC_ZOOMEDIN
Fully zoomed in screenshot of the visible area.
@ SC_WORLD
World screenshot.
@ SC_DEFAULTZOOM
Zoomed to default zoom level screenshot of the visible area.
GUI functions related to screenshots.
Window * ShowScriptDebugWindow(CompanyID show_company, bool new_window)
Open the Script debug window and select the given company.
Window for configuring the scripts.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
ClientSettings _settings_client
The current settings for this game.
void PlaceProc_Sign(TileIndex tile)
PlaceProc function, called when someone pressed the button if the sign-tool is selected.
Functions related to signs.
Window * ShowSignList()
Open the sign list window.
void ShowSmallMap()
Show the smallmap window.
void SndConfirmBeep()
Play a beep sound for a confirm event if enabled in settings.
void SndClickBeep()
Play a beep sound for a click event if enabled in settings.
Functions related to sound.
Functions to cache sprites in memory.
static const SpriteID SPR_IMG_PLANTTREES
static const SpriteID SPR_IMG_COMPANY_GENERAL
static const SpriteID SPR_IMG_BUILDAIR
static const SpriteID SPR_IMG_AIRPORT
static const SpriteID SPR_IMG_TRAINLIST
static const SpriteID SPR_IMG_INDUSTRY
static const SpriteID SPR_IMG_BUILDWATER
static const SpriteID SPR_IMG_BUILD_CANAL
static const SpriteID SPR_IMG_SIGN
static const SpriteID SPR_IMG_TRANSMITTER
static const SpriteID SPR_IMG_COMPANY_LIST
static const SpriteID SPR_IMG_MUSIC
static const SpriteID SPR_IMG_GRAPHS
static const SpriteID SPR_IMG_PAUSE
static const SpriteID SPR_IMG_BUILDTRAMS
static const SpriteID SPR_IMG_SAVE
static const SpriteID SPR_IMG_COMPANY_FINANCE
static const SpriteID SPR_COMPANY_ICON
Icon showing company colour.
static const SpriteID SPR_IMG_ZOOMIN
static const SpriteID SPR_IMG_MESSAGES
static const SpriteID SPR_LOCK
Lock icon (for password protected servers).
static const SpriteID SPR_IMG_TRUCKLIST
static const SpriteID SPR_IMG_ZOOMOUT
static const SpriteID SPR_IMG_AIRPLANESLIST
static const SpriteID SPR_IMG_SUBSIDIES
static const SpriteID SPR_IMG_FASTFORWARD
static const SpriteID SPR_IMG_SHIPLIST
static const SpriteID SPR_IMG_TOWN
static const SpriteID SPR_IMG_SETTINGS
static const SpriteID SPR_IMG_COMPANY_LEAGUE
static const SpriteID SPR_EMPTY
Empty (transparent blue) sprite.
static const SpriteID SPR_IMG_QUERY
static const SpriteID SPR_ARROW_DOWN
static const SpriteID SPR_ARROW_UP
static const SpriteID SPR_IMG_STORY_BOOK
static const SpriteID SPR_IMG_GOAL
static const SpriteID SPR_IMG_SMALLMAP
static const SpriteID SPR_IMG_BUILDROAD
static const SpriteID SPR_IMG_LANDSCAPING
static const SpriteID SPR_IMG_BUILDRAIL
static constexpr StationFacility STATION_FACILITY_GHOST
Fake 'facility' to allow toggling display of recently-removed station signs.
@ Dock
Station with a dock.
@ TruckStop
Station with truck stops.
@ Train
Station with train station.
@ Airport
Station with an airport.
@ BusStop
Station with bus stops.
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
static std::optional< T > ParseInteger(std::string_view arg, int base=10, bool clamp=false)
Change a string into its number representation.
@ CS_NUMERAL
Only numeric ones.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Functions related to OTTD's strings.
StrongType::Typedef< uint32_t, struct StringIDTag, StrongType::Compare, StrongType::Integer > StringID
Numeric value that represents a string, independent of the selected language.
Settings related to the AI.
Dimensions (a width and height) of a rectangle in 2D.
List of hotkeys for a window.
All data for a single hotkey.
Struct about custom league tables.
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
void OnPaint() override
The window must be repainted.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void FindWindowPlacementAndResize(int, int def_height, bool allow_resize) override
Resize window towards the default size.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void OnDropdownSelect(WidgetID widget, int index, int) override
A dropdown option associated to this window has been selected.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
const IntervalTimer< TimerWindow > refresh_interval
Refresh the state of pause / game-speed on a regular interval.
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
static Pool::IterateWrapper< LeagueTable > Iterate(size_t from=0)
static size_t GetNumItems()
static bool IsValidID(auto index)
Specification of a rectangle with absolute coordinates of all edges.
int Height() const
Get height of Rect.
High level window description.
Data structure for an opened window.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
void DrawWidgets() const
Paint all widgets of a window.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
uint8_t timeout_timer
Timer value of the WindowFlag::Timeout for flags.
std::unique_ptr< ViewportData > viewport
Pointer to viewport data, if present.
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
ResizeInfo resize
Resize information.
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
void SetWidgetsLoweredState(bool lowered_stat, Args... widgets)
Sets the lowered/raised status of a list of widgets.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
virtual void FindWindowPlacementAndResize(int def_width, int def_height, bool allow_resize)
Resize window towards the default size.
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
WindowFlags flags
Window flags.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
int height
Height of the window (number of pixels down in y direction).
int width
width of the window (number of pixels to the right in x direction)
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
Stuff related to the text buffer GUI.
@ EnableDefault
enable the 'Default' button ("\0" is returned)
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
Functions related to tile highlights.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowClass window_class, WindowNumber window_num)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
@ HT_RECT
rectangle (stations, depots, ...)
Definition of Interval and OneShot timers.
Definition of the game-calendar-timer.
Definition of the Window system.
StationFacilities _facility_display_opt
What station facilities to draw.
void ToggleTransparency(TransparencyOption to)
Toggle the transparency option bit.
bool IsTransparencySet(TransparencyOption to)
Check if the transparency option bit is set and if we aren't in the game menu (there's never transpar...
DisplayOptions _display_opt
What do we want to draw/do?
void ShowTransparencyToolbar()
Show the transparency toolbar.
GUI functions related to transparency.
Base class for all vehicles.
Functions related to vehicles.
Functions related to the vehicle's GUIs.
VehicleType
Available vehicle types.
@ Aircraft
Aircraft vehicle type.
@ Train
Train vehicle type.
void HandleZoomMessage(Window *w, const Viewport &vp, WidgetID widget_zoom_in, WidgetID widget_zoom_out)
Update the status of the zoom-buttons according to the zoom-level of the viewport.
Functions related to (drawing on) viewports.
@ ZOOM_IN
Zoom in (get more detailed view).
@ ZOOM_NONE
Hack, used to update the button status.
@ ZOOM_OUT
Zoom out (get helicopter view).
Window * GetMainWindow()
Get the main window, i.e.
int PositionMainToolbar(Window *w)
(Re)position main toolbar window at the screen.
void DeleteAllMessages()
Delete all messages and close their corresponding window (if any).
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
@ NoClose
This window can't be interactively closed.
@ NoFocus
This window won't get focus/make any other window lose focus when click.
@ WhiteBorder
Window white border counter bit mask.
@ Timeout
Window timeout counter.
@ Manual
Manually align the window (so no automatic location finding).
EventState
State of handling an event.
@ Handled
The passed event is handled.
@ NotHandled
The passed event is not handled.