OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
207 NWidget(
WWT_LABEL, COLOUR_GREY,
WID_C_NOTE),
SetFill(1, 1),
SetDataTip(STR_CHEATS_NOTE, STR_NULL),
SetPadding(
WD_PAR_VSEP_NORMAL, 4,
WD_PAR_VSEP_NORMAL, 4),
231 uint box_left = rtl ? r.right - this->box_width - 5 : r.left + 5;
232 uint button_left = rtl ? r.right - this->box_width - 10 -
SETTING_BUTTON_WIDTH : r.left + this->box_width + 10;
242 DrawSprite((*ce->
been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, box_left, y + icon_y_offset + 2);
249 SetDParam(0, on ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
258 DrawArrowButtons(button_left, y + icon_y_offset, COLOUR_YELLOW, clicked - (i * 2),
true,
true);
265 case STR_CHEAT_CHANGE_COMPANY: {
267 GetString(buf, STR_CHEAT_CHANGE_COMPANY,
lastof(buf));
279 DrawString(text_left, text_right, y + text_y_offset, ce->
str);
281 y += this->line_height;
303 case STR_CHEAT_CHANGE_DATE:
309 case STR_CHEAT_CHANGE_COMPANY:
335 int x = pt.x - wid->
pos_x;
343 int oldvalue = value;
366 if (ce->
proc !=
nullptr) ce->
proc(value, 0);
374 if (value != oldvalue || btn ==
CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= 10 + this->box_width +
SETTING_BUTTON_WIDTH / 2) != rtl ? 1 : 0);
394 if (str ==
nullptr ||
StrEmpty(str))
return;
398 int value = atoi(str);
400 value = ce->
proc(value, value - oldvalue);
VarType type
type of selector
static const uint MIN_MAX_HEIGHTLEVEL
Lower bound of maximum allowed heightlevel (in the construction settings)
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Cheat no_jetcrash
no jet will crash on small airports anymore
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
uint32 TileIndex
The index/ID of a Tile.
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.
uint8 max_heightlevel
maximum allowed heightlevel
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
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.
@ WC_INDUSTRY_VIEW
Industry view; Window numbers:
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
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 const uint MAX_MAX_HEIGHTLEVEL
Upper bound of maximum allowed heightlevel (in the construction settings)
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:
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
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.
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
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.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
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.
int height
Height of the window (number of pixels down in y direction)
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
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.
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
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.
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.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
static int32 ClickSetProdCheat(int32 p1, int32 p2)
Allow (or disallow) changing production of all industries.
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...
bool ResetSignalVariant(int32 p)
Updates the current signal variant used in the signal GUI to the one adequate to current year.
@ 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:
@ CMD_MONEY_CHEAT
do the money cheat
@ CHT_CROSSINGTUNNELS
Allow tunnels to cross each other.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
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.
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
@ 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,...