Go to the documentation of this file.
248 int box_y_offset = (this->line_height - this->box.height) / 2;
250 int icon_y_offset = (this->line_height - this->icon.height) / 2;
255 DrawSprite((*ce->
been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, box_left, y + box_y_offset);
262 SetDParam(0, on ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
271 DrawArrowButtons(button_left, y + button_y_offset, COLOUR_YELLOW, clicked - (i * 2),
true,
true);
278 case STR_CHEAT_CHANGE_COMPANY: {
280 GetString(buf, STR_CHEAT_CHANGE_COMPANY,
lastof(buf));
292 DrawString(text_left, text_right, y + text_y_offset, ce->
str);
294 y += this->line_height;
316 case STR_CHEAT_CHANGE_DATE:
322 case STR_CHEAT_CHANGE_COMPANY:
336 this->line_height = std::max(this->box.height, this->icon.height);
347 uint btn = (pt.y - r.top) / this->line_height;
348 uint x = pt.x - r.left;
350 if (rtl) x = r.
Width() - 1 - x;
356 int oldvalue = value;
379 if (ce->
proc !=
nullptr) ce->
proc(value, 0);
407 if (str ==
nullptr ||
StrEmpty(str))
return;
411 int value = atoi(str);
413 value = ce->
proc(value, value - oldvalue);
VarType type
type of selector
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Cheat no_jetcrash
no jet will crash on small airports anymore
static constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
Cheat crossing_tunnels
allow tunnels that cross each other
Cheat magic_bulldozer
dynamite industries, objects
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
void ShiftDates(int interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
Dimensions (a width and height) of a rectangle in 2D.
static int32 _money_cheat_amount
The 'amount' to cheat with.
Cheat edit_max_hl
edit the maximum heightlevel; this is a cheat because of the fact that it needs to reset NewGRF game ...
@ QSF_ACCEPT_UNCHANGED
return success even when the text didn't change
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Year _cur_year
Current year, starting at 0.
DateFract _date_fract
Fractional part of the day.
static WindowDesc _cheats_desc(WDP_AUTO, "cheats", 0, 0, WC_CHEATS, WC_NONE, 0, _nested_cheat_widgets, lengthof(_nested_cheat_widgets))
Window description of the cheats GUI.
uint8 map_height_limit
the maximum allowed heightlevel
@ WC_INDUSTRY_VIEW
Industry view; Window numbers:
Dimension icon
Dimension of company icon sprite.
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
void SetDate(Date date, DateFract fract)
Set the date.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Cheat setup_prod
setup raw-material production in game
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...
@ CHT_CHANGE_COMPANY
Switch company.
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
@ WC_BUILD_STATION
Build station; Window numbers:
static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2)
Allow (or disallow) a change of the maximum allowed heightlevel.
Owner
Enum for all companies/owners.
@ WC_CHEATS
Cheat window; Window numbers:
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
bool * been_used
has this cheat been used before?
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
@ CHT_MONEY
Change amount of money.
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=nullptr, uint textref_stack_size=0, const uint32 *textref_stack=nullptr)
Display an error message in a window.
CheatNumbers
Available cheats.
High level window description.
static int32 ClickChangeDateCheat(int32 p1, int32 p2)
Handle changing of the current year.
static size_t GetPoolSize()
Returns first unused index.
@ CHT_EDIT_MAX_HL
Edit maximum allowed heightlevel.
@ WDP_AUTO
Find a place automatically.
void OnTimeout() override
Called when this window's timeout has been reached.
static uint MapSize()
Get the size of the map.
ResizeInfo resize
Resize information.
Date _date
Current date in days (day counter)
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
Cheat money
get rich or poor
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
CheckButtonClick * proc
procedure
static const Year MIN_YEAR
The absolute minimum & maximum years in OTTD.
static const uint MAX_MAP_HEIGHT_LIMIT
Upper bound of maximum allowed heightlevel (in the construction settings)
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Cheats _cheats
All the cheats.
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
@ CHT_NUM_CHEATS
Number of cheats.
int32 Date
The type to store our dates in.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
void ConvertDateToYMD(Date date, YearMonthDay *ymd)
Converts a Date to a Year, Month & Day.
@ MAX_COMPANIES
Maximum number of companies.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
void * variable
pointer to the variable
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
static int32 ClickMoneyCheat(int32 p1, int32 p2)
Handle cheating of money.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Coordinates of a point in 2D.
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
Draw [<][>] boxes.
void OnInit() override
Notification that the nested widget tree gets initialized.
uint Vertical() const
Get total vertical padding of RectPadding.
static const CheatEntry _cheats_ui[]
The available cheats.
bool value
tells if the bool cheat is active or not
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
void WriteValue(void *ptr, VarType conv, int64 val)
Write the value of a setting.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static int32 ClickSetProdCheat(int32 p1, int32 p2)
Allow (or disallow) changing production of all industries.
static const uint MIN_MAP_HEIGHT_LIMIT
Lower bound of maximum allowed heightlevel (in the construction settings)
StringID str
string with descriptive text
static const NWidgetPart _nested_cheat_widgets[]
Widget definitions of the cheat GUI.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
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...
@ CHT_SETUP_PROD
Allow manually editing of industry production.
Cheat change_date
changes date ingame
@ CHT_NO_JETCRASH
Disable jet-airplane crashes.
int32 CheckButtonClick(int32 p1, int32 p2)
Signature of handler function when user clicks at a cheat.
@ WL_ERROR
Errors (eg. saving/loading failed)
static int32 ClickChangeCompanyCheat(int32 p1, int32 p2)
Handle changing of company.
#define lengthof(x)
Return the length of an fixed size array.
int width
width of the window (number of pixels to the right in x direction)
Data structure to convert between Date and triplet (year, month, and day).
@ WC_BUILD_OBJECT
Build object; Window numbers:
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
@ CHT_CROSSINGTUNNELS
Allow tunnels to cross each other.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
void ResetSignalVariant(int32 new_value)
Updates the current signal variant used in the signal GUI to the one adequate to current year.
int64 ReadValue(const void *ptr, VarType conv)
Return a signed-long version of the value of a setting.
ConstructionSettings construction
construction of things in-game
Data structure for an opened window.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
@ WC_STATUS_BAR
Statusbar (at the bottom of your screen); Window numbers:
bool been_used
has this cheat been used before?
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
int Width() const
Get width of Rect.
Specification of a rectangle with absolute coordinates of all edges.
#define lastof(x)
Get the last element of an fixed size array.
Cheat switch_company
change to another company
Dimension box
Dimension of box sprite.
@ WC_SMALLMAP
Small map; Window numbers:
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
@ TD_RTL
Text is written right-to-left by default.
@ CHT_CHANGE_DATE
Do time traveling.
TextDirection _current_text_dir
Text direction of the currently selected language.
@ CS_NUMERAL
Only numeric ones.
void EnginesMonthlyLoop()
Monthly update of the availability, reliability, and preview offers of the engines.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
@ CHT_EXTRA_DYNAMITE
Dynamite anything.
void ShowCheatWindow()
Open cheat window.
static const Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date,...