OpenTTD
cheat_gui.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "stdafx.h"
11 #include "command_func.h"
12 #include "cheat_type.h"
13 #include "company_base.h"
14 #include "company_func.h"
15 #include "date_func.h"
16 #include "saveload/saveload.h"
17 #include "textbuf_gui.h"
18 #include "window_gui.h"
19 #include "string_func.h"
20 #include "strings_func.h"
21 #include "window_func.h"
22 #include "rail_gui.h"
23 #include "settings_gui.h"
24 #include "company_gui.h"
26 #include "map_func.h"
27 #include "tile_map.h"
28 #include "newgrf.h"
29 #include "error.h"
30 
31 #include "widgets/cheat_widget.h"
32 
33 #include "table/sprites.h"
34 
35 #include "safeguards.h"
36 
37 
43 static int32 _money_cheat_amount = 10000000;
44 
54 static int32 ClickMoneyCheat(int32 p1, int32 p2)
55 {
56  DoCommandP(0, (uint32)(p2 * _money_cheat_amount), 0, CMD_MONEY_CHEAT);
57  return _money_cheat_amount;
58 }
59 
66 static int32 ClickChangeCompanyCheat(int32 p1, int32 p2)
67 {
68  while ((uint)p1 < Company::GetPoolSize()) {
69  if (Company::IsValidID((CompanyID)p1)) {
71  return _local_company;
72  }
73  p1 += p2;
74  }
75 
76  return _local_company;
77 }
78 
85 static int32 ClickSetProdCheat(int32 p1, int32 p2)
86 {
87  _cheats.setup_prod.value = (p1 != 0);
89  return _cheats.setup_prod.value;
90 }
91 
92 extern void EnginesMonthlyLoop();
93 
100 static int32 ClickChangeDateCheat(int32 p1, int32 p2)
101 {
102  YearMonthDay ymd;
103  ConvertDateToYMD(_date, &ymd);
104 
105  p1 = Clamp(p1, MIN_YEAR, MAX_YEAR);
106  if (p1 == _cur_year) return _cur_year;
107 
108  Date new_date = ConvertYMDToDate(p1, ymd.month, ymd.day);
110  SetDate(new_date, _date_fract);
116  return _cur_year;
117 }
118 
126 static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2)
127 {
129 
130  /* Check if at least one mountain on the map is higher than the new value.
131  * If yes, disallow the change. */
132  for (TileIndex t = 0; t < MapSize(); t++) {
133  if ((int32)TileHeight(t) > p1) {
134  ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR);
135  /* Return old, unchanged value */
137  }
138  }
139 
140  /* Execute the change and reload GRF Data */
143 
144  /* The smallmap uses an index from heightlevels to colours. Trigger rebuilding it. */
146 
148 }
149 
160 
162 };
163 
169 typedef int32 CheckButtonClick(int32 p1, int32 p2);
170 
172 struct CheatEntry {
173  VarType type;
175  void *variable;
176  bool *been_used;
178 };
179 
184 static const CheatEntry _cheats_ui[] = {
185  {SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
186  {SLE_UINT8, STR_CHEAT_CHANGE_COMPANY, &_local_company, &_cheats.switch_company.been_used, &ClickChangeCompanyCheat },
187  {SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, nullptr },
188  {SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, nullptr },
189  {SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, nullptr },
190  {SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, &ClickSetProdCheat },
192  {SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
193 };
194 
195 assert_compile(CHT_NUM_CHEATS == lengthof(_cheats_ui));
196 
200  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
201  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CHEATS, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
202  NWidget(WWT_SHADEBOX, COLOUR_GREY),
203  NWidget(WWT_STICKYBOX, COLOUR_GREY),
204  EndContainer(),
205  NWidget(WWT_PANEL, COLOUR_GREY, WID_C_PANEL), SetDataTip(0x0, STR_CHEATS_TOOLTIP), EndContainer(),
206 };
207 
209 struct CheatWindow : Window {
210  int clicked;
211  int header_height;
212  int clicked_widget;
213  uint line_height;
214  int box_width;
215 
216  CheatWindow(WindowDesc *desc) : Window(desc)
217  {
218  this->box_width = GetSpriteSize(SPR_BOX_EMPTY).width;
219  this->InitNested();
220  }
221 
222  void DrawWidget(const Rect &r, int widget) const override
223  {
224  if (widget != WID_C_PANEL) return;
225 
226  int y = r.top + WD_FRAMERECT_TOP + this->header_height;
227  DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, r.top + WD_FRAMERECT_TOP, y, STR_CHEATS_WARNING, TC_FROMSTRING, SA_CENTER);
228 
229  bool rtl = _current_text_dir == TD_RTL;
230  uint box_left = rtl ? r.right - this->box_width - 5 : r.left + 5;
231  uint button_left = rtl ? r.right - this->box_width - 10 - SETTING_BUTTON_WIDTH : r.left + this->box_width + 10;
232  uint text_left = r.left + (rtl ? WD_FRAMERECT_LEFT : 20 + this->box_width + SETTING_BUTTON_WIDTH);
233  uint text_right = r.right - (rtl ? 20 + this->box_width + SETTING_BUTTON_WIDTH : WD_FRAMERECT_RIGHT);
234 
235  int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
236  int icon_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
237 
238  for (int i = 0; i != lengthof(_cheats_ui); i++) {
239  const CheatEntry *ce = &_cheats_ui[i];
240 
241  DrawSprite((*ce->been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, box_left, y + icon_y_offset + 2);
242 
243  switch (ce->type) {
244  case SLE_BOOL: {
245  bool on = (*(bool*)ce->variable);
246 
247  DrawBoolButton(button_left, y + icon_y_offset, on, true);
248  SetDParam(0, on ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
249  break;
250  }
251 
252  default: {
253  int32 val = (int32)ReadValue(ce->variable, ce->type);
254  char buf[512];
255 
256  /* Draw [<][>] boxes for settings of an integer-type */
257  DrawArrowButtons(button_left, y + icon_y_offset, COLOUR_YELLOW, clicked - (i * 2), true, true);
258 
259  switch (ce->str) {
260  /* Display date for change date cheat */
261  case STR_CHEAT_CHANGE_DATE: SetDParam(0, _date); break;
262 
263  /* Draw coloured flag for change company cheat */
264  case STR_CHEAT_CHANGE_COMPANY: {
265  SetDParam(0, val + 1);
266  GetString(buf, STR_CHEAT_CHANGE_COMPANY, lastof(buf));
267  uint offset = 10 + GetStringBoundingBox(buf).width;
268  DrawCompanyIcon(_local_company, rtl ? text_right - offset - 10 : text_left + offset, y + icon_y_offset + 2);
269  break;
270  }
271 
272  default: SetDParam(0, val);
273  }
274  break;
275  }
276  }
277 
278  DrawString(text_left, text_right, y + text_y_offset, ce->str);
279 
280  y += this->line_height;
281  }
282  }
283 
284  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
285  {
286  if (widget != WID_C_PANEL) return;
287 
288  uint width = 0;
289  for (int i = 0; i != lengthof(_cheats_ui); i++) {
290  const CheatEntry *ce = &_cheats_ui[i];
291  switch (ce->type) {
292  case SLE_BOOL:
293  SetDParam(0, STR_CONFIG_SETTING_ON);
294  width = max(width, GetStringBoundingBox(ce->str).width);
295  SetDParam(0, STR_CONFIG_SETTING_OFF);
296  width = max(width, GetStringBoundingBox(ce->str).width);
297  break;
298 
299  default:
300  switch (ce->str) {
301  /* Display date for change date cheat */
302  case STR_CHEAT_CHANGE_DATE:
303  SetDParam(0, ConvertYMDToDate(MAX_YEAR, 11, 31));
304  width = max(width, GetStringBoundingBox(ce->str).width);
305  break;
306 
307  /* Draw coloured flag for change company cheat */
308  case STR_CHEAT_CHANGE_COMPANY:
310  width = max(width, GetStringBoundingBox(ce->str).width + 10 + 10);
311  break;
312 
313  default:
314  SetDParam(0, INT64_MAX);
315  width = max(width, GetStringBoundingBox(ce->str).width);
316  break;
317  }
318  break;
319  }
320  }
321 
322  this->line_height = max(GetSpriteSize(SPR_BOX_CHECKED).height, GetSpriteSize(SPR_BOX_EMPTY).height);
323  this->line_height = max<uint>(this->line_height, SETTING_BUTTON_HEIGHT);
324  this->line_height = max<uint>(this->line_height, FONT_HEIGHT_NORMAL) + WD_PAR_VSEP_NORMAL;
325 
326  size->width = width + 20 + this->box_width + SETTING_BUTTON_WIDTH /* stuff on the left */ + 10 /* extra spacing on right */;
327  this->header_height = GetStringHeight(STR_CHEATS_WARNING, size->width - WD_FRAMERECT_LEFT - WD_FRAMERECT_RIGHT) + WD_PAR_VSEP_WIDE;
328  size->height = this->header_height + WD_FRAMERECT_TOP + WD_PAR_VSEP_NORMAL + WD_FRAMERECT_BOTTOM + this->line_height * lengthof(_cheats_ui);
329  }
330 
331  void OnClick(Point pt, int widget, int click_count) override
332  {
333  const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_C_PANEL);
334  uint btn = (pt.y - wid->pos_y - WD_FRAMERECT_TOP - this->header_height) / this->line_height;
335  int x = pt.x - wid->pos_x;
336  bool rtl = _current_text_dir == TD_RTL;
337  if (rtl) x = wid->current_x - x;
338 
339  if (btn >= lengthof(_cheats_ui)) return;
340 
341  const CheatEntry *ce = &_cheats_ui[btn];
342  int value = (int32)ReadValue(ce->variable, ce->type);
343  int oldvalue = value;
344 
345  if (btn == CHT_CHANGE_DATE && x >= 20 + this->box_width + SETTING_BUTTON_WIDTH) {
346  /* Click at the date text directly. */
347  clicked_widget = CHT_CHANGE_DATE;
348  SetDParam(0, value);
349  ShowQueryString(STR_JUST_INT, STR_CHEAT_CHANGE_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
350  return;
351  } else if (btn == CHT_EDIT_MAX_HL && x >= 20 + this->box_width + SETTING_BUTTON_WIDTH) {
352  clicked_widget = CHT_EDIT_MAX_HL;
353  SetDParam(0, value);
354  ShowQueryString(STR_JUST_INT, STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
355  return;
356  }
357 
358  /* Not clicking a button? */
359  if (!IsInsideMM(x, 10 + this->box_width, 10 + this->box_width + SETTING_BUTTON_WIDTH)) return;
360 
361  *ce->been_used = true;
362 
363  switch (ce->type) {
364  case SLE_BOOL:
365  value ^= 1;
366  if (ce->proc != nullptr) ce->proc(value, 0);
367  break;
368 
369  default:
370  /* Take whatever the function returns */
371  value = ce->proc(value + ((x >= 10 + this->box_width + SETTING_BUTTON_WIDTH / 2) ? 1 : -1), (x >= 10 + this->box_width + SETTING_BUTTON_WIDTH / 2) ? 1 : -1);
372 
373  /* The first cheat (money), doesn't return a different value. */
374  if (value != oldvalue || btn == CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= 10 + this->box_width + SETTING_BUTTON_WIDTH / 2) != rtl ? 1 : 0);
375  break;
376  }
377 
378  if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
379 
380  this->SetTimeout();
381 
382  this->SetDirty();
383  }
384 
385  void OnTimeout() override
386  {
387  this->clicked = 0;
388  this->SetDirty();
389  }
390 
391  void OnQueryTextFinished(char *str) override
392  {
393  /* Was 'cancel' pressed or nothing entered? */
394  if (str == nullptr || StrEmpty(str)) return;
395 
396  const CheatEntry *ce = &_cheats_ui[clicked_widget];
397  int oldvalue = (int32)ReadValue(ce->variable, ce->type);
398  int value = atoi(str);
399  *ce->been_used = true;
400  value = ce->proc(value, value - oldvalue);
401 
402  if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
403  this->SetDirty();
404  }
405 };
406 
408 static WindowDesc _cheats_desc(
409  WDP_AUTO, "cheats", 0, 0,
411  0,
412  _nested_cheat_widgets, lengthof(_nested_cheat_widgets)
413 );
414 
417 {
419  new CheatWindow(&_cheats_desc);
420 }
Functions related to OTTD&#39;s strings.
Owner
Enum for all companies/owners.
Definition: company_type.h:18
uint8 max_heightlevel
maximum allowed heightlevel
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:79
Definition of stuff that is very close to a company, like the company struct itself.
Cheat switch_company
change to another company
Definition: cheat_type.h:28
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3215
static int32 ClickChangeCompanyCheat(int32 p1, int32 p2)
Handle changing of company.
Definition: cheat_gui.cpp:66
High level window description.
Definition: window_gui.h:166
static const uint MAX_MAX_HEIGHTLEVEL
Upper bound of maximum allowed heightlevel (in the construction settings)
Definition: tile_type.h:26
void ShowCheatWindow()
Open cheat window.
Definition: cheat_gui.cpp:416
Functions related to dates.
Day day
Day (1..31)
Definition: date_type.h:104
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:62
Allow manually editing of industry production.
Definition: cheat_gui.cpp:157
Normal amount of vertical space between two paragraphs of text.
Definition: window_gui.h:137
Horizontal container.
Definition: widget_type.h:73
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
Definition: misc_gui.cpp:1119
Edit maximum allowed heightlevel.
Definition: cheat_gui.cpp:158
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
CheatNumbers
Available cheats.
Definition: cheat_gui.cpp:151
int64 ReadValue(const void *ptr, VarType conv)
Return a signed-long version of the value of a setting.
Definition: saveload.cpp:755
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.
Definition: error_gui.cpp:380
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition: gfx.cpp:547
Close box (at top-left of a window)
Definition: widget_type.h:67
#define lastof(x)
Get the last element of an fixed size array.
Definition: depend.cpp:48
return success even when the text didn&#39;t change
Definition: textbuf_gui.h:20
bool been_used
has this cheat been used before?
Definition: cheat_type.h:17
Stuff related to the text buffer GUI.
bool * been_used
has this cheat been used before?
Definition: cheat_gui.cpp:176
static T max(const T a, const T b)
Returns the maximum of two values.
Definition: math_func.hpp:24
Year _cur_year
Current year, starting at 0.
Definition: date.cpp:24
Cheat money
get rich or poor
Definition: cheat_type.h:29
GUI for the cheats.
Definition: cheat_gui.cpp:209
Allow tunnels to cross each other.
Definition: cheat_gui.cpp:155
Functions related to maps.
Large amount of vertical space between two paragraphs of text.
Definition: window_gui.h:138
Functions/types etc.
Functions, definitions and such used only by the GUI.
Information of a cheat.
Definition: cheat_gui.cpp:172
Cheat no_jetcrash
no jet will crash on small airports anymore
Definition: cheat_type.h:32
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:908
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.
Definition: window_gui.h:276
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
Definition: math_func.hpp:264
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...
Definition: window.cpp:3334
void SetDate(Date date, DateFract fract)
Set the date.
Definition: date.cpp:35
Functions related to low-level strings.
Only numeric ones.
Definition: string_type.h:28
Functions/types related to saving and loading games.
Types related to cheating.
Functions related to errors.
Disable jet-airplane crashes.
Definition: cheat_gui.cpp:156
Cheat edit_max_hl
edit the maximum heightlevel; this is a cheat because of the fact that it needs to reset NewGRF game ...
Definition: cheat_type.h:37
DateFract _date_fract
Fractional part of the day.
Definition: date.cpp:27
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: cheat_gui.cpp:331
static size_t GetPoolSize()
Returns first unused index.
Definition: pool_type.hpp:312
static const CheatEntry _cheats_ui[]
The available cheats.
Definition: cheat_gui.cpp:184
Number of cheats.
Definition: cheat_gui.cpp:161
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
Small map; Window numbers:
Definition: window_type.h:97
Cheat change_date
changes date ingame
Definition: cheat_type.h:34
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:176
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1012
Definition of base types and functions in a cross-platform compatible way.
static int32 ClickMoneyCheat(int32 p1, int32 p2)
Handle cheating of money.
Definition: cheat_gui.cpp:54
Center both horizontally and vertically.
Definition: gfx_func.h:104
CheckButtonClick * proc
procedure
Definition: cheat_gui.cpp:177
Data structure to convert between Date and triplet (year, month, and day).
Definition: date_type.h:101
Switch company.
Definition: cheat_gui.cpp:153
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
Definition: cheat_type.h:18
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...
Definition: rail_gui.cpp:1959
Simple depressed panel.
Definition: widget_type.h:48
Cheat setup_prod
setup raw-material production in game
Definition: cheat_type.h:35
Types related to the cheat widgets.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: cheat_gui.cpp:391
static int32 _money_cheat_amount
The &#39;amount&#39; to cheat with.
Definition: cheat_gui.cpp:43
GUI Functions related to companies.
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:175
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1112
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:63
Baseclass for nested widgets.
Definition: widget_type.h:124
static int32 ClickSetProdCheat(int32 p1, int32 p2)
Allow (or disallow) changing production of all industries.
Definition: cheat_gui.cpp:85
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.
Definition: gfx.cpp:498
Build station; Window numbers:
Definition: window_type.h:390
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Definition: command.cpp:532
Industry view; Window numbers:
Definition: window_type.h:356
#define lengthof(x)
Return the length of an fixed size array.
Definition: depend.cpp:40
do the money cheat
Definition: command_type.h:273
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.
Definition: strings_type.h:16
Month month
Month (0..11)
Definition: date_type.h:103
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
Definition: settings_gui.h:17
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.
Definition: cheat_gui.cpp:284
Build object; Window numbers:
Definition: window_type.h:369
static const NWidgetPart _nested_cheat_widgets[]
Widget definitions of the cheat GUI.
Definition: cheat_gui.cpp:198
Panel where all cheats are shown in.
Definition: cheat_widget.h:15
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: cheat_gui.cpp:222
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:137
Do time traveling.
Definition: cheat_gui.cpp:159
void * variable
pointer to the variable
Definition: cheat_gui.cpp:175
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:700
static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2)
Allow (or disallow) a change of the maximum allowed heightlevel.
Definition: cheat_gui.cpp:126
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1162
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.
Functions related to companies.
static uint MapSize()
Get the size of the map.
Definition: map_func.h:92
static const uint MIN_MAX_HEIGHTLEVEL
Lower bound of maximum allowed heightlevel (in the construction settings)
Definition: tile_type.h:24
Cheat window; Window numbers:
Definition: window_type.h:618
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:57
Dynamite anything.
Definition: cheat_gui.cpp:154
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
void OnTimeout() override
Called when this window&#39;s timeout has been reached.
Definition: cheat_gui.cpp:385
Cheat crossing_tunnels
allow tunnels that cross each other
Definition: cheat_type.h:30
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:48
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.
Definition: strings.cpp:104
int32 CheckButtonClick(int32 p1, int32 p2)
Signature of handler function when user clicks at a cheat.
Definition: cheat_gui.cpp:169
StringID str
string with descriptive text
Definition: cheat_gui.cpp:174
Cheat magic_bulldozer
dynamite industries, objects
Definition: cheat_type.h:27
Functions for setting GUIs.
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:997
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:172
Maximum number of companies.
Definition: company_type.h:23
Statusbar (at the bottom of your screen); Window numbers:
Definition: window_type.h:57
Functions related to commands.
Coordinates of a point in 2D.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:770
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:280
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
Definition: tile_map.h:29
ConstructionSettings construction
construction of things in-game
static const Year MIN_YEAR
The absolute minimum & maximum years in OTTD.
Definition: date_type.h:83
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17
int32 Date
The type to store our dates in.
Definition: date_type.h:14
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:61
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:64
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.
Definition: engine.cpp:966
Text is written right-to-left by default.
Definition: strings_type.h:24
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: date.cpp:147
Map writing/reading functions for tiles.
Window functions not directly related to making/drawing windows.
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
Definition: afterload.cpp:3131
Find a place automatically.
Definition: window_gui.h:154
Change amount of money.
Definition: cheat_gui.cpp:152
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
Definition: settings_gui.h:19
Errors (eg. saving/loading failed)
Definition: error.h:23
Date _date
Current date in days (day counter)
Definition: date.cpp:26
void ConvertDateToYMD(Date date, YearMonthDay *ymd)
Converts a Date to a Year, Month & Day.
Definition: date.cpp:92
static int32 ClickChangeDateCheat(int32 p1, int32 p2)
Handle changing of the current year.
Definition: cheat_gui.cpp:100
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:44
void WriteValue(void *ptr, VarType conv, int64 val)
Write the value of a setting.
Definition: saveload.cpp:779
Dimensions (a width and height) of a rectangle in 2D.
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:60
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...
Definition: date_type.h:92
This file contains all sprite-related enums and defines.
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:62
VarType type
type of selector
Definition: cheat_gui.cpp:173
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:835
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:176
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.
Definition: gfx.cpp:621
Cheats _cheats
All the cheats.
Definition: cheat.cpp:16
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:199
Base for the NewGRF implementation.