77 new_value += change_direction;
116 TimerGameEconomy::Date new_economy_date = new_calendar_date.base();
258 int icon_y_offset = (this->line_height - this->icon.height) / 2;
265 bool on = (*(
bool*)
ce->variable);
298 y += this->line_height;
351 uint
btn = (
pt.y - r.top) / this->line_height;
352 int x =
pt.x - r.left;
378 *
ce->been_used =
true;
383 if (
ce->proc !=
nullptr)
ce->proc(value, 0);
411 if (!str.has_value() || str->empty())
return;
415 int value =
atoi(str->c_str());
416 *
ce->been_used =
true;
Cheats _cheats
All the cheats.
static int32_t _money_cheat_amount
The 'amount' to cheat with.
static int32_t ClickChangeMaxHlCheat(int32_t new_value, int32_t)
Allow (or disallow) a change of the maximum allowed heightlevel.
CheatNumbers
Available cheats.
@ CHT_NO_JETCRASH
Disable jet-airplane crashes.
@ CHT_CHANGE_DATE
Do time traveling.
@ CHT_CROSSINGTUNNELS
Allow tunnels to cross each other.
@ CHT_SETUP_PROD
Allow manually editing of industry production.
@ CHT_CHANGE_COMPANY
Switch company.
@ CHT_NUM_CHEATS
Number of cheats.
@ CHT_EXTRA_DYNAMITE
Dynamite anything.
@ CHT_MONEY
Change amount of money.
@ CHT_STATION_RATING
Fix station ratings at 100%.
@ CHT_EDIT_MAX_HL
Edit maximum allowed heightlevel.
void CalendarEnginesMonthlyLoop()
Monthly update of the availability, reliability, and preview offers of the engines.
static int32_t ClickMoneyCheat(int32_t, int32_t change_direction)
Handle cheating of money.
static int32_t ClickSetProdCheat(int32_t new_value, int32_t)
Allow (or disallow) changing production of all industries.
static int32_t ClickChangeDateCheat(int32_t new_value, int32_t)
Handle changing of the current year.
static constexpr NWidgetPart _nested_cheat_widgets[]
Widget definitions of the cheat GUI.
static int32_t ClickChangeCompanyCheat(int32_t new_value, int32_t change_direction)
Handle changing of company.
int32_t CheckButtonClick(int32_t new_value, int32_t change_direction)
Signature of handler function when user clicks at a cheat.
static WindowDesc _cheats_desc(WDP_AUTO, "cheats", 0, 0, WC_CHEATS, WC_NONE, 0, _nested_cheat_widgets)
Window description of the cheats GUI.
void ShowCheatWindow()
Open cheat window.
static const CheatEntry _cheats_ui[]
The available cheats.
Types related to cheating.
An interval timer will fire every interval, and will continue to fire until it is deleted.
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
void ShiftDates(TimerGameEconomy::Date interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
static void SetDate(Date date, DateFract fract)
Set the date.
static Date date
Current date in days (day counter).
static Year year
Current year, starting at 0.
static DateFract date_fract
Fractional part of the day.
static constexpr TimerGame< struct Calendar >::Year MIN_YEAR
The absolute minimum year in OTTD.
static constexpr TimerGame< struct Calendar >::Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date,...
static Date date
Current date in days (day counter).
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
static DateFract date_fract
Fractional part of the day.
static void SetDate(Date date, DateFract fract)
Set the date.
Functions related to commands.
Definition of stuff that is very close to a company, like the company struct itself.
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
void SetLocalCompany(CompanyID new_company)
Sets the local company and updates the settings that are set on a per-company basis to reflect the co...
Functions related to companies.
GUI Functions related to companies.
Owner
Enum for all companies/owners.
@ MAX_COMPANIES
Maximum number of companies.
Functions related to errors.
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
@ WL_ERROR
Errors (eg. saving/loading failed)
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
@ FS_NORMAL
Index of the normal font in the font tables.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Declaration of link graph schedule used for cargo distribution.
Functions related to maps.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
Miscellaneous command definitions.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
Base for the NewGRF implementation.
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
void ResetSignalVariant(int32_t)
Updates the current signal variant used in the signal GUI to the one adequate to current year.
A number of safeguards to prevent using unsafe methods.
void WriteValue(void *ptr, VarType conv, int64_t val)
Write the value of a setting.
int64_t ReadValue(const void *ptr, VarType conv)
Return a signed-long version of the value of a setting.
Functions/types related to saving and loading games.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
void DrawArrowButtons(int x, int y, Colours button_colour, uint8_t state, bool clickable_left, bool clickable_right)
Draw [<][>] boxes.
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
Functions for setting GUIs.
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
This file contains all sprite-related enums and defines.
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
Functions related to low-level strings.
@ CS_NUMERAL
Only numeric ones.
void SetDParamMaxValue(size_t n, uint64_t max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
TextDirection _current_text_dir
Text direction of the currently selected language.
Functions related to OTTD's strings.
@ TD_RTL
Text is written right-to-left by default.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
VarType type
type of selector
void * variable
pointer to the variable
StringID str
string with descriptive text
CheckButtonClick * proc
procedure
bool * been_used
has this cheat been used before?
void OnTimeout() override
Called when this window's timeout has been reached.
Dimension icon
Dimension of company icon sprite.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void OnInit() override
Notification that the nested widget tree gets initialized.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
void OnQueryTextFinished(std::optional< std::string > str) override
The query window opened from this window has closed.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
bool value
tells if the bool cheat is active or not
bool been_used
has this cheat been used before?
Cheat crossing_tunnels
allow tunnels that cross each other
Cheat no_jetcrash
no jet will crash on small airports anymore
Cheat change_date
changes date ingame
Cheat station_rating
Fix station ratings at 100%.
Cheat money
get rich or poor
Cheat setup_prod
setup raw-material production in game
Cheat switch_company
change to another company
Cheat magic_bulldozer
dynamite industries, objects
Cheat edit_max_hl
edit the maximum heightlevel; this is a cheat because of the fact that it needs to reset NewGRF game ...
uint8_t map_height_limit
the maximum allowed heightlevel
Dimensions (a width and height) of a rectangle in 2D.
ConstructionSettings construction
construction of things in-game
static IterateWrapper Iterate()
Returns an iterable ensemble of all Tiles.
Coordinates of a point in 2D.
static size_t GetPoolSize()
Returns first unused index.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Specification of a rectangle with absolute coordinates of all edges.
int Width() const
Get width of Rect.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Templated helper to make a type-safe 'typedef' representing a single POD value.
High level window description.
Data structure for an opened window.
ResizeInfo resize
Resize information.
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
int width
width of the window (number of pixels to the right in x direction)
Stuff related to the text buffer GUI.
@ QSF_ACCEPT_UNCHANGED
return success even when the text didn't change
Map writing/reading functions for tiles.
static debug_inline uint TileHeight(Tile tile)
Returns the height of a tile.
static const uint MIN_MAP_HEIGHT_LIMIT
Lower bound of maximum allowed heightlevel (in the construction settings)
static const uint MAX_MAP_HEIGHT_LIMIT
Upper bound of maximum allowed heightlevel (in the construction settings)
Definition of Interval and OneShot timers.
Definition of the game-calendar-timer.
Definition of the game-economy-timer.
Base class for all vehicles.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
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.
@ WDP_AUTO
Find a place automatically.
@ WC_BUILD_STATION
Build station; Window numbers:
@ WC_BUILD_OBJECT
Build object; Window numbers:
@ WC_STATUS_BAR
Statusbar (at the bottom of your screen); Window numbers:
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ WC_CHEATS
Cheat window; Window numbers:
@ WC_TRUCK_STATION
Build truck station; Window numbers:
@ WC_INDUSTRY_VIEW
Industry view; Window numbers:
@ WC_FINANCES
Finances of a company; Window numbers:
@ WC_BUS_STATION
Build bus station; Window numbers:
@ WC_SMALLMAP
Small map; Window numbers: