232 uint box_left = rtl ? r.right - this->box_width - 5 : r.left + 5;
233 uint button_left = rtl ? r.right - this->box_width - 10 -
SETTING_BUTTON_WIDTH : r.left + this->box_width + 10;
240 for (
int i = 0; i !=
lengthof(_cheats_ui); i++) {
243 DrawSprite((*ce->
been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, box_left, y + icon_y_offset + 2);
250 SetDParam(0, on ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
259 DrawArrowButtons(button_left, y + icon_y_offset, COLOUR_YELLOW, clicked - (i * 2),
true,
true);
266 case STR_CHEAT_CHANGE_COMPANY: {
268 GetString(buf, STR_CHEAT_CHANGE_COMPANY,
lastof(buf));
280 DrawString(text_left, text_right, y + text_y_offset, ce->
str);
282 y += this->line_height;
291 for (
int i = 0; i !=
lengthof(_cheats_ui); i++) {
304 case STR_CHEAT_CHANGE_DATE:
310 case STR_CHEAT_CHANGE_COMPANY:
337 int x = pt.x - wid->
pos_x;
341 if (btn >=
lengthof(_cheats_ui))
return;
345 int oldvalue = value;
368 if (ce->
proc != NULL) ce->
proc(value, 0);
376 if (value != oldvalue || btn ==
CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= 10 + this->box_width +
SETTING_BUTTON_WIDTH / 2) != rtl ? 1 : 0);
396 if (str == NULL ||
StrEmpty(str))
return;
398 const CheatEntry *ce = &_cheats_ui[clicked_widget];
400 int value = atoi(str);
402 value = ce->
proc(value, value - oldvalue);
414 _nested_cheat_widgets,
lengthof(_nested_cheat_widgets)
Functions related to OTTD's strings.
uint8 max_heightlevel
maximum allowed heightlevel
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition of stuff that is very close to a company, like the company struct itself.
Cheat switch_company
change to another company
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
static int32 ClickChangeCompanyCheat(int32 p1, int32 p2)
Handle changing of company.
High level window description.
static const uint MAX_MAX_HEIGHTLEVEL
Upper bound of maximum allowed heightlevel (in the construction settings)
void ShowCheatWindow()
Open cheat window.
Functions related to dates.
static bool IsInsideMM(const T x, const uint min, const uint max)
Checks if a value is in an interval.
Offset at top to draw the frame rectangular area.
Allow manually editing of industry production.
Normal amount of vertical space between two paragraphs of text.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
Edit maximum allowed heightlevel.
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
CheatNumbers
Available cheats.
int64 ReadValue(const void *ptr, VarType conv)
Return a signed-long version of the value of a setting.
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
#define lastof(x)
Get the last element of an fixed size array.
return success even when the text didn't change
bool been_used
has this cheat been used before?
Stuff related to the text buffer GUI.
bool * been_used
has this cheat been used before?
static T max(const T a, const T b)
Returns the maximum of two values.
Year _cur_year
Current year, starting at 0.
Cheat money
get rich or poor
Allow tunnels to cross each other.
Functions related to maps.
Large amount of vertical space between two paragraphs of text.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
Functions, definitions and such used only by the GUI.
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Cheat no_jetcrash
no jet will crash on small airports anymore
void ShiftDates(int interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
Data structure for an opened window.
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...
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=NULL, uint textref_stack_size=0, const uint32 *textref_stack=NULL)
Display an error message in a window.
void SetDate(Date date, DateFract fract)
Set the date.
Functions related to low-level strings.
Functions/types related to saving and loading games.
Types related to cheating.
Functions related to errors.
Disable jet-airplane crashes.
Cheat edit_max_hl
edit the maximum heightlevel; this is a cheat because of the fact that it needs to reset NewGRF game ...
DateFract _date_fract
Fractional part of the day.
static size_t GetPoolSize()
Returns first unused index.
static const CheatEntry _cheats_ui[]
The available cheats.
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
Small map; Window numbers:
Cheat change_date
changes date ingame
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition of base types and functions in a cross-platform compatible way.
static int32 ClickMoneyCheat(int32 p1, int32 p2)
Handle cheating of money.
Center both horizontally and vertically.
CheckButtonClick * proc
procedure
Data structure to convert between Date and triplet (year, month, and day).
A number of safeguards to prevent using unsafe methods.
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...
bool value
tells if the bool cheat is active or not
Declaration of link graph schedule used for cargo distribution.
bool ResetSignalVariant(int32 p)
Updates the current signal variant used in the signal GUI to the one adequate to current year...
Cheat setup_prod
setup raw-material production in game
static int32 _money_cheat_amount
The 'amount' to cheat with.
GUI Functions related to companies.
Offset at bottom to draw the frame rectangular area.
static int32 ClickSetProdCheat(int32 p1, int32 p2)
Allow (or disallow) changing production of all industries.
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.
Build station; Window numbers:
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Industry view; Window numbers:
#define lengthof(x)
Return the length of an fixed size array.
void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
Draw [<][>] boxes.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
Build object; Window numbers:
static const NWidgetPart _nested_cheat_widgets[]
Widget definitions of the cheat GUI.
Maximum number of companies.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
void * variable
pointer to the variable
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2)
Allow (or disallow) a change of the maximum allowed heightlevel.
No window, redirects to WC_MAIN_WINDOW.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
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.
virtual void OnTimeout()
Called when this window's timeout has been reached.
Functions related to companies.
static uint MapSize()
Get the size of the map.
static const uint MIN_MAX_HEIGHTLEVEL
Lower bound of maximum allowed heightlevel (in the construction settings)
Cheat window; Window numbers:
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
uint32 TileIndex
The index/ID of a Tile.
Cheat crossing_tunnels
allow tunnels that cross each other
TextDirection _current_text_dir
Text direction of the currently selected language.
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.
int32 CheckButtonClick(int32 p1, int32 p2)
Signature of handler function when user clicks at a cheat.
StringID str
string with descriptive text
Cheat magic_bulldozer
dynamite industries, objects
Functions for setting GUIs.
Statusbar (at the bottom of your screen); Window numbers:
Functions related to commands.
Coordinates of a point in 2D.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
ConstructionSettings construction
construction of things in-game
static const Year MIN_YEAR
The absolute minimum & maximum years in OTTD.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
int32 Date
The type to store our dates in.
Offset at right to draw the frame rectangular area.
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
Specification of a rectangle with absolute coordinates of all edges.
void EnginesMonthlyLoop()
Monthly update of the availability, reliability, and preview offers of the engines.
Text is written right-to-left by default.
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Map writing/reading functions for tiles.
Owner
Enum for all companies/owners.
Window functions not directly related to making/drawing windows.
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
Find a place automatically.
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
Errors (eg. saving/loading failed)
Date _date
Current date in days (day counter)
void ConvertDateToYMD(Date date, YearMonthDay *ymd)
Converts a Date to a Year, Month & Day.
static int32 ClickChangeDateCheat(int32 p1, int32 p2)
Handle changing of the current year.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
void WriteValue(void *ptr, VarType conv, int64 val)
Write the value of a setting.
Dimensions (a width and height) of a rectangle in 2D.
Offset at left to draw the frame rectangular area.
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...
This file contains all sprite-related enums and defines.
VarType type
type of selector
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Cheats _cheats
All the cheats.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Base for the NewGRF implementation.