Go to the documentation of this file.
27 #if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
28 #define HAS_TRUETYPE_FONT
54 #include "table/strings.h"
55 #include "table/settings.h"
59 SettingTable _company_settings{ _company_settings_table };
60 SettingTable _currency_settings{ _currency_settings_table };
61 SettingTable _difficulty_settings{ _difficulty_settings_table };
62 SettingTable _multimedia_settings{ _multimedia_settings_table };
63 SettingTable _economy_settings{ _economy_settings_table };
64 SettingTable _game_settings{ _game_settings_table };
65 SettingTable _gui_settings{ _gui_settings_table };
66 SettingTable _linkgraph_settings{ _linkgraph_settings_table };
67 SettingTable _locale_settings{ _locale_settings_table };
68 SettingTable _misc_settings{ _misc_settings_table };
69 SettingTable _network_private_settings{ _network_private_settings_table };
70 SettingTable _network_secrets_settings{ _network_secrets_settings_table };
71 SettingTable _network_settings{ _network_settings_table };
72 SettingTable _news_display_settings{ _news_display_settings_table };
73 SettingTable _old_gameopt_settings{ _old_gameopt_settings_table };
74 SettingTable _pathfinding_settings{ _pathfinding_settings_table };
75 SettingTable _script_settings{ _script_settings_table };
76 SettingTable _window_settings{ _window_settings_table };
77 SettingTable _world_settings{ _world_settings_table };
78 #if defined(_WIN32) && !defined(DEDICATED)
79 SettingTable _win32_settings{ _win32_settings_table };
102 case 0: val = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_IMPERIAL;
break;
103 case 1: val = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_METRIC;
break;
104 case 2: val = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_SI;
break;
105 case 3: val =
TimerGameEconomy::UsingWallclockUnits(_game_mode == GM_MENU) ? STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_GAMEUNITS_SECS : STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_GAMEUNITS_DAYS;
break;
106 case 4: val = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_KNOTS;
break;
107 default: NOT_REACHED();
128 if (_game_mode != GM_MENU) {
152 static void StationSpreadChanged(int32_t)
158 static void UpdateConsists(int32_t)
162 if (t->IsFrontEngine() || t->IsFreeWagon()) t->ConsistChanged(
CCF_TRACK);
173 bool update_vehicles;
177 update_vehicles =
false;
180 update_vehicles =
true;
183 if (new_value != 0) {
203 if (update_vehicles) {
206 if (v->owner ==
_current_company && v->IsPrimaryVehicle() && !v->ServiceIntervalIsCustom()) {
208 v->SetServiceIntervalIsPercent(new_value != 0);
216 static bool CanUpdateServiceInterval(
VehicleType, int32_t &new_value)
227 return interval == new_value;
230 static void UpdateServiceInterval(
VehicleType type, int32_t new_value)
234 if (v->owner ==
_current_company && v->type == type && v->IsPrimaryVehicle() && !v->ServiceIntervalIsCustom()) {
235 v->SetServiceInterval(new_value);
243 static void TrainAccelerationModelChanged(int32_t)
246 if (t->IsFrontEngine()) {
247 t->tcache.cached_max_curve_speed = t->GetCurveSpeedLimit();
248 t->UpdateAcceleration();
264 if (t->IsFrontEngine()) t->CargoChanged();
275 if (rv->IsFrontEngine()) {
293 if (rv->IsFrontEngine()) rv->CargoChanged();
297 static void TownFoundingChanged(int32_t)
306 static void ZoomMinMaxChanged(int32_t)
308 ConstrainAllViewportsZoom();
316 static void SpriteZoomMinChanged(int32_t)
335 static void InvalidateCompanyLiveryWindow(int32_t)
338 ResetVehicleColourMap();
341 static void DifficultyNoiseChange(int32_t)
343 if (_game_mode == GM_NORMAL) {
351 static void MaxNoAIsChange(int32_t)
381 static std::vector<std::string> _old_landscape_values{
"normal",
"hilly",
"desert",
"candy"};
385 static bool CheckFreeformEdges(int32_t &new_value)
387 if (_game_mode == GM_MENU)
return true;
388 if (new_value != 0) {
391 if (
TileX(s->tile) == 0 ||
TileY(s->tile) == 0) {
398 if (st->IsInUse() && (
TileX(st->xy) == 0 ||
TileY(st->xy) == 0)) {
432 static void UpdateFreeformEdges(int32_t new_value)
434 if (_game_mode == GM_MENU)
return;
436 if (new_value != 0) {
459 if (_game_mode == GM_MENU)
return true;
469 static bool CheckMaxHeightLevel(int32_t &new_value)
471 if (_game_mode == GM_NORMAL)
return false;
472 if (_game_mode != GM_EDITOR)
return true;
487 static void StationCatchmentChanged(int32_t)
493 static void MaxVehiclesChanged(int32_t)
499 static void InvalidateShipPathCache(int32_t)
513 if (newval.compare(
"*") == 0) newval.clear();
547 if (_game_mode == GM_EDITOR) {
548 TimerGameEconomy::Date new_economy_date;
554 new_economy_date_fract = 0;
577 if (new_value < CalendarTime::DEF_MINUTES_PER_YEAR) {
581 if (new_value == 1) {
582 clamped = CalendarTime::DEF_MINUTES_PER_YEAR;
584 clamped = CalendarTime::FROZEN_MINUTES_PER_YEAR;
588 if (_game_mode == GM_MENU) {
Buses, trucks and trams belong to this class.
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
@ WC_SAVELOAD
Saveload window; Window numbers:
void BuildOwnerLegend()
Completes the array for the owned property legend.
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
static bool ResetToCurrentNewGRFConfig()
Tries to reset the engine mapping to match the current NewGRF configuration.
static Titem * Get(size_t index)
Returns Titem with given index.
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
int PositionMainToolbar(Window *w)
(Re)position main toolbar window at the screen.
static DateFract date_fract
Fractional part of the day.
static bool CheckDynamicEngines(int32_t &)
Changing the setting "allow multiple NewGRF sets" is not allowed if there are vehicles.
static debug_inline uint MaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
@ WC_COMPANY_COLOUR
Company colour selection; Window numbers:
@ WC_FOUND_TOWN
Found a town; Window numbers:
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
bool _network_server
network-server is active
@ WC_ENGINE_PREVIEW
Engine preview window; Window numbers:
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
@ WC_CLIENT_LIST
Client list; Window numbers:
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
static bool CanChangeTimetableMode(int32_t &)
Pre-callback check when trying to change the timetable mode.
void SetTileHeight(Tile tile, uint height)
Sets the height of a tile.
static void UpdateAllServiceInterval(int32_t new_value)
Check and update if needed all vehicle service intervals.
static void SettingsValueVelocityUnit(const IntSettingDesc &, uint first_param, int32_t value)
Setting values for velocity unit localisation.
VehicleDefaultSettings vehicle
default settings for vehicles
static void UpdateLinkgraphColours(int32_t)
Redraw linkgraph links after a colour scheme change.
TimekeepingUnits timekeeping_units
time units to use for the game economy, either calendar or wallclock
ClientSettings _settings_client
The current settings for this game.
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
static size_t ConvertLandscape(const char *value)
Conversion callback for _gameopt_settings_game.landscape It converts (or try) between old values and ...
@ WC_BUILD_STATION
Build station; Window numbers:
static void ChangeTimekeepingUnits(int32_t)
Callback for when the player changes the timekeeping units.
static void UpdateClientConfigValues()
Update the game info, and send it to the clients when we are running as a server.
static void RedrawSmallmap(int32_t)
Redraw the smallmap after a colour scheme change.
uint16_t minutes_per_calendar_year
minutes per calendar year. Special value 0 means that calendar time is frozen.
static void ChangeMinutesPerYear(int32_t new_value)
Callback after the player changes the minutes per year.
bool AdjustGUIZoom(bool automatic)
Resolve GUI zoom level and adjust GUI to new zoom, if auto-suggestion is requested.
uint16_t GetServiceIntervalClamped(int interval, bool ispercent)
Clamp the service interval to the correct min/max.
int PositionStatusbar(Window *w)
(Re)position statusbar window at the screen.
bool RoadVehiclesAreBuilt()
Verify whether a road vehicle is available.
int PositionNewsMessage(Window *w)
(Re)position news message window at the screen.
bool station_noise_level
build new airports when the town noise level is still within accepted limits
StringID str_val
(Translated) first string describing the value.
void ShiftDates(TimerGameEconomy::Date interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
void ReInitAllWindows(bool zoom_changed)
Re-initialize all windows.
void GfxClearSpriteCache()
Remove all encoded sprites from the sprite cache without discarding sprite location information.
static void RecomputeCatchmentForAll()
Recomputes catchment of all stations.
Base integer type, including boolean, settings.
void UpdateAirportsNoise()
Recalculate the noise generated by the airports of each town.
void MakeVoid(Tile t)
Make a nice void tile ;)
GameSettings _settings_game
Game settings of a running game or the scenario editor.
@ WC_VEHICLE_DETAILS
Vehicle details; Window numbers:
EconomySettings economy
settings to change the economy
static const ScriptInfoList * GetInfoList()
Wrapper function for AIScanner::GetAIInfoList.
'Train' is either a loco or a wagon.
uint16_t servint_aircraft
service interval for aircraft
bool _networking
are we in networking mode?
static void v_PositionMainToolbar(int32_t)
Reposition the main toolbar as the setting changed.
Default settings for vehicles.
TownFounding found_town
town founding.
VehicleType
Available vehicle types.
uint8_t roadveh_acceleration_model
realistic acceleration for road vehicles
static debug_inline uint SizeX()
Get the size of the map along the X.
static void InvalidateNewGRFChangeWindows(int32_t)
Update any possible saveload window and delete any newgrf dialogue as its widget parts might change.
StringID str_help
(Translated) string with help text; gui only.
All ships have this type.
CompanyID _current_company
Company currently doing an action.
@ WC_GAME_OPTIONS
Game options window; Window numbers:
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
static bool CheckRoadSide(int32_t &)
Check whether the road side may be changed.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static uint MaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
static StringID SettingTitleWallclock(const IntSettingDesc &sd)
Switch setting title depending on wallclock setting.
void NetworkServerSendConfigUpdate()
Send Config Update.
@ WC_BUILD_VEHICLE
Build vehicle; Window numbers:
constexpr T abs(const T a)
Returns the absolute value of (scalar) variable.
static debug_inline uint Size()
Get the size of the map.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
int CompanyServiceInterval(const Company *c, VehicleType type)
Get the service interval for the given company and vehicle type.
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...
StringID str
(translated) string with descriptive text; gui and console
void SetTileType(Tile tile, TileType type)
Set the type of a tile.
Base class for all station-ish types.
uint16_t servint_trains
service interval for trains
@ WL_ERROR
Errors (eg. saving/loading failed)
static Pool::IterateWrapper< Train > Iterate(size_t from=0)
Returns an iterable ensemble of all valid vehicles of type T.
static StringID SettingHelpWallclock(const IntSettingDesc &sd)
Switch setting help depending on wallclock setting.
static void SettingsValueAbsolute(const IntSettingDesc &sd, uint first_param, int32_t value)
A negative value has another string (the one after "strval").
static void SetDate(Date date, DateFract fract)
Set the date.
uint16_t servint_ships
service interval for ships
bool servint_ispercent
service intervals are in percents
uint16_t DateFract
The fraction of a date we're in, i.e.
static void v_PositionStatusbar(int32_t)
Reposition the statusbar as the setting changed.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
static debug_inline TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
static debug_inline uint TileHeight(Tile tile)
Returns the height of a tile.
static bool ReplaceAsteriskWithEmptyPassword(std::string &newval)
Replace a passwords that are a literal asterisk with an empty string.
@ WC_TOWN_VIEW
Town view; Window numbers:
GameSettings & GetGameSettings()
Get the settings-object applicable for the current situation: the newgame settings when we're in the ...
static Date date
Current date in days (day counter).
CompanySettings company
default values for per-company settings
int PositionNetworkChatWindow(Window *w)
(Re)position network chat window at the screen.
@ CCF_TRACK
Valid changes while vehicle is driving, and possibly changing tracks.
VehicleSettings vehicle
options for vehicles
static void RoadVehAccelerationModelChanged(int32_t)
This function updates realistic acceleration caches when the setting "Road vehicle acceleration model...
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static void RoadVehSlopeSteepnessChanged(int32_t)
This function updates the road vehicle acceleration cache after a steepness change.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
static void TrainSlopeSteepnessChanged(int32_t)
This function updates the train acceleration cache after a steepness change.
@ WC_SPRITE_ALIGNER
Sprite aligner (debug); Window numbers:
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
void NetworkServerUpdateGameInfo()
Update the server's NetworkServerGameInfo due to changes in settings.
void BuildLinkStatsLegend()
Populate legend table for the link stat view.
uint16_t servint_roadveh
service interval for road vehicles
@ WC_SMALLMAP
Small map; Window numbers:
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
static uint SizeY()
Get the size of the map along the Y.
static size_t ParseSingleValue(const char *str, size_t len, const std::vector< std::string > &many)
Find the index value of a ONEofMANY type in a string separated by |.
@ WL_CRITICAL
Critical errors, the MessageBox is shown in all cases.
void BuildLandLegend()
(Re)build the colour tables for the legends.
static Date date
Current date in days (day counter).