OpenTTD Source  20241108-master-g80f628063a
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 "saveload/saveload.h"
16 #include "vehicle_base.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 #include "misc_cmd.h"
31 #include "core/geometry_func.hpp"
32 #include "timer/timer.h"
35 
36 #include "widgets/cheat_widget.h"
37 
38 #include "table/sprites.h"
39 
40 #include "safeguards.h"
41 
42 
48 static int32_t _money_cheat_amount = 10000000;
49 
58 static int32_t ClickMoneyCheat(int32_t, int32_t change_direction)
59 {
61  return _money_cheat_amount;
62 }
63 
70 static int32_t ClickChangeCompanyCheat(int32_t new_value, int32_t change_direction)
71 {
72  while ((uint)new_value < Company::GetPoolSize()) {
73  if (Company::IsValidID((CompanyID)new_value)) {
74  SetLocalCompany((CompanyID)new_value);
75  return _local_company;
76  }
77  new_value += change_direction;
78  }
79 
80  return _local_company;
81 }
82 
88 static int32_t ClickSetProdCheat(int32_t new_value, int32_t)
89 {
90  _cheats.setup_prod.value = (new_value != 0);
92  return _cheats.setup_prod.value;
93 }
94 
95 extern void CalendarEnginesMonthlyLoop();
96 
102 static int32_t ClickChangeDateCheat(int32_t new_value, int32_t)
103 {
104  /* Don't allow changing to an invalid year, or the current year. */
106  if (new_year == TimerGameCalendar::year) return TimerGameCalendar::year.base();
107 
108  TimerGameCalendar::YearMonthDay ymd = TimerGameCalendar::ConvertDateToYMD(TimerGameCalendar::date);
109  TimerGameCalendar::Date new_calendar_date = TimerGameCalendar::ConvertYMDToDate(new_year, ymd.month, ymd.day);
110 
112 
113  /* If not using wallclock units, we keep economy date in sync with calendar date and must change it also. */
115  /* Keep economy and calendar dates synced. */
116  TimerGameEconomy::Date new_economy_date = new_calendar_date.base();
117 
118  /* Shift cached dates before we change the date. */
119  for (auto v : Vehicle::Iterate()) v->ShiftDates(new_economy_date - TimerGameEconomy::date);
121 
122  /* Now it's safe to actually change the date. */
124  }
125 
133  return TimerGameCalendar::year.base();
134 }
135 
142 static int32_t ClickChangeMaxHlCheat(int32_t new_value, int32_t)
143 {
144  new_value = Clamp(new_value, MIN_MAP_HEIGHT_LIMIT, MAX_MAP_HEIGHT_LIMIT);
145 
146  /* Check if at least one mountain on the map is higher than the new value.
147  * If yes, disallow the change. */
148  for (TileIndex t = 0; t < Map::Size(); t++) {
149  if ((int32_t)TileHeight(t) > new_value) {
150  ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR);
151  /* Return old, unchanged value */
153  }
154  }
155 
156  /* Execute the change and reload GRF Data */
159 
160  /* The smallmap uses an index from heightlevels to colours. Trigger rebuilding it. */
162 
164 }
165 
177 
179 };
180 
186 typedef int32_t CheckButtonClick(int32_t new_value, int32_t change_direction);
187 
189 struct CheatEntry {
190  VarType type;
192  void *variable;
193  bool *been_used;
195 };
196 
201 static const CheatEntry _cheats_ui[] = {
202  {SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
203  {SLE_UINT8, STR_CHEAT_CHANGE_COMPANY, &_local_company, &_cheats.switch_company.been_used, &ClickChangeCompanyCheat },
204  {SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, nullptr },
205  {SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, nullptr },
206  {SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, nullptr },
207  {SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, &ClickSetProdCheat },
208  {SLE_BOOL, STR_CHEAT_STATION_RATING, &_cheats.station_rating.value, &_cheats.station_rating.been_used, nullptr },
210  {SLE_INT32, STR_CHEAT_CHANGE_DATE, &TimerGameCalendar::year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
211 };
212 
213 static_assert(CHT_NUM_CHEATS == lengthof(_cheats_ui));
214 
216 static constexpr NWidgetPart _nested_cheat_widgets[] = {
218  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
219  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CHEATS, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
220  NWidget(WWT_SHADEBOX, COLOUR_GREY),
221  NWidget(WWT_STICKYBOX, COLOUR_GREY),
222  EndContainer(),
223  NWidget(WWT_PANEL, COLOUR_GREY, WID_C_PANEL), EndContainer(),
224 };
225 
227 struct CheatWindow : Window {
228  int clicked;
229  int clicked_widget;
230  uint line_height;
232 
233  CheatWindow(WindowDesc &desc) : Window(desc)
234  {
235  this->InitNested();
236  }
237 
238  void OnInit() override
239  {
240  this->icon = GetSpriteSize(SPR_COMPANY_ICON);
241  }
242 
243  void DrawWidget(const Rect &r, WidgetID widget) const override
244  {
245  if (widget != WID_C_PANEL) return;
246 
247  const Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
248  int y = ir.top;
249 
250  bool rtl = _current_text_dir == TD_RTL;
251  uint button_left = rtl ? ir.right - SETTING_BUTTON_WIDTH : ir.left;
252  uint text_left = ir.left + (rtl ? 0 : WidgetDimensions::scaled.hsep_wide + SETTING_BUTTON_WIDTH);
253  uint text_right = ir.right - (rtl ? WidgetDimensions::scaled.hsep_wide + SETTING_BUTTON_WIDTH : 0);
254 
255  int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2;
256  int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
257  int icon_y_offset = (this->line_height - this->icon.height) / 2;
258 
259  for (int i = 0; i != lengthof(_cheats_ui); i++) {
260  const CheatEntry *ce = &_cheats_ui[i];
261 
262  switch (ce->type) {
263  case SLE_BOOL: {
264  bool on = (*(bool*)ce->variable);
265 
266  DrawBoolButton(button_left, y + button_y_offset, on, true);
267  SetDParam(0, on ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
268  break;
269  }
270 
271  default: {
272  int32_t val = (int32_t)ReadValue(ce->variable, ce->type);
273 
274  /* Draw [<][>] boxes for settings of an integer-type */
275  DrawArrowButtons(button_left, y + button_y_offset, COLOUR_YELLOW, clicked - (i * 2), true, true);
276 
277  switch (ce->str) {
278  /* Display date for change date cheat */
279  case STR_CHEAT_CHANGE_DATE: SetDParam(0, TimerGameCalendar::date); break;
280 
281  /* Draw coloured flag for change company cheat */
282  case STR_CHEAT_CHANGE_COMPANY: {
283  SetDParam(0, val + 1);
285  DrawCompanyIcon(_local_company, rtl ? text_right - offset - WidgetDimensions::scaled.hsep_indent : text_left + offset, y + icon_y_offset);
286  break;
287  }
288 
289  default: SetDParam(0, val);
290  }
291  break;
292  }
293  }
294 
295  DrawString(text_left, text_right, y + text_y_offset, ce->str);
296 
297  y += this->line_height;
298  }
299  }
300 
301  void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
302  {
303  if (widget != WID_C_PANEL) return;
304 
305  uint width = 0;
306  for (const auto &ce : _cheats_ui) {
307  switch (ce.type) {
308  case SLE_BOOL:
309  SetDParam(0, STR_CONFIG_SETTING_ON);
310  width = std::max(width, GetStringBoundingBox(ce.str).width);
311  SetDParam(0, STR_CONFIG_SETTING_OFF);
312  width = std::max(width, GetStringBoundingBox(ce.str).width);
313  break;
314 
315  default:
316  switch (ce.str) {
317  /* Display date for change date cheat */
318  case STR_CHEAT_CHANGE_DATE:
320  width = std::max(width, GetStringBoundingBox(ce.str).width);
321  break;
322 
323  /* Draw coloured flag for change company cheat */
324  case STR_CHEAT_CHANGE_COMPANY:
327  break;
328 
329  default:
330  SetDParam(0, INT64_MAX);
331  width = std::max(width, GetStringBoundingBox(ce.str).width);
332  break;
333  }
334  break;
335  }
336  }
337 
338  this->line_height = std::max<uint>(this->icon.height, SETTING_BUTTON_HEIGHT);
339  this->line_height = std::max<uint>(this->line_height, GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.framerect.Vertical();
340 
342  size.height = WidgetDimensions::scaled.framerect.Vertical() + this->line_height * lengthof(_cheats_ui);
343  }
344 
345  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
346  {
347  if (widget != WID_C_PANEL) return;
348 
349  Rect r = this->GetWidget<NWidgetBase>(WID_C_PANEL)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
350  uint btn = (pt.y - r.top) / this->line_height;
351  int x = pt.x - r.left;
352  bool rtl = _current_text_dir == TD_RTL;
353  if (rtl) x = r.Width() - 1 - x;
354 
355  if (btn >= lengthof(_cheats_ui)) return;
356 
357  const CheatEntry *ce = &_cheats_ui[btn];
358  int value = (int32_t)ReadValue(ce->variable, ce->type);
359  int oldvalue = value;
360 
361  if (btn == CHT_CHANGE_DATE && x >= SETTING_BUTTON_WIDTH) {
362  /* Click at the date text directly. */
363  clicked_widget = CHT_CHANGE_DATE;
364  SetDParam(0, value);
365  ShowQueryString(STR_JUST_INT, STR_CHEAT_CHANGE_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
366  return;
367  } else if (btn == CHT_EDIT_MAX_HL && x >= SETTING_BUTTON_WIDTH) {
368  clicked_widget = CHT_EDIT_MAX_HL;
369  SetDParam(0, value);
370  ShowQueryString(STR_JUST_INT, STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
371  return;
372  }
373 
374  /* Not clicking a button? */
375  if (!IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) return;
376 
377  *ce->been_used = true;
378 
379  switch (ce->type) {
380  case SLE_BOOL:
381  value ^= 1;
382  if (ce->proc != nullptr) ce->proc(value, 0);
383  break;
384 
385  default:
386  /* Take whatever the function returns */
387  value = ce->proc(value + ((x >= SETTING_BUTTON_WIDTH / 2) ? 1 : -1), (x >= SETTING_BUTTON_WIDTH / 2) ? 1 : -1);
388 
389  /* The first cheat (money), doesn't return a different value. */
390  if (value != oldvalue || btn == CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= SETTING_BUTTON_WIDTH / 2) != rtl ? 1 : 0);
391  break;
392  }
393 
394  if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64_t)value);
395 
396  this->SetTimeout();
397 
398  this->SetDirty();
399  }
400 
401  void OnTimeout() override
402  {
403  this->clicked = 0;
404  this->SetDirty();
405  }
406 
407  void OnQueryTextFinished(std::optional<std::string> str) override
408  {
409  /* Was 'cancel' pressed or nothing entered? */
410  if (!str.has_value() || str->empty()) return;
411 
412  const CheatEntry *ce = &_cheats_ui[clicked_widget];
413  int oldvalue = (int32_t)ReadValue(ce->variable, ce->type);
414  int value = atoi(str->c_str());
415  *ce->been_used = true;
416  value = ce->proc(value, value - oldvalue);
417 
418  if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64_t)value);
419  this->SetDirty();
420  }
421 
422  IntervalTimer<TimerGameCalendar> daily_interval = {{TimerGameCalendar::MONTH, TimerGameCalendar::Priority::NONE}, [this](auto) {
423  this->SetDirty();
424  }};
425 };
426 
429  WDP_AUTO, "cheats", 0, 0,
431  0,
433 );
434 
437 {
440 }
Cheats _cheats
All the cheats.
Definition: cheat.cpp:16
static int32_t _money_cheat_amount
The 'amount' to cheat with.
Definition: cheat_gui.cpp:48
static int32_t ClickChangeMaxHlCheat(int32_t new_value, int32_t)
Allow (or disallow) a change of the maximum allowed heightlevel.
Definition: cheat_gui.cpp:142
CheatNumbers
Available cheats.
Definition: cheat_gui.cpp:167
@ CHT_NO_JETCRASH
Disable jet-airplane crashes.
Definition: cheat_gui.cpp:172
@ CHT_CHANGE_DATE
Do time traveling.
Definition: cheat_gui.cpp:176
@ CHT_CROSSINGTUNNELS
Allow tunnels to cross each other.
Definition: cheat_gui.cpp:171
@ CHT_SETUP_PROD
Allow manually editing of industry production.
Definition: cheat_gui.cpp:173
@ CHT_CHANGE_COMPANY
Switch company.
Definition: cheat_gui.cpp:169
@ CHT_NUM_CHEATS
Number of cheats.
Definition: cheat_gui.cpp:178
@ CHT_EXTRA_DYNAMITE
Dynamite anything.
Definition: cheat_gui.cpp:170
@ CHT_MONEY
Change amount of money.
Definition: cheat_gui.cpp:168
@ CHT_STATION_RATING
Fix station ratings at 100%.
Definition: cheat_gui.cpp:174
@ CHT_EDIT_MAX_HL
Edit maximum allowed heightlevel.
Definition: cheat_gui.cpp:175
void CalendarEnginesMonthlyLoop()
Monthly update of the availability, reliability, and preview offers of the engines.
Definition: engine.cpp:1111
static int32_t ClickMoneyCheat(int32_t, int32_t change_direction)
Handle cheating of money.
Definition: cheat_gui.cpp:58
static int32_t ClickSetProdCheat(int32_t new_value, int32_t)
Allow (or disallow) changing production of all industries.
Definition: cheat_gui.cpp:88
static int32_t ClickChangeDateCheat(int32_t new_value, int32_t)
Handle changing of the current year.
Definition: cheat_gui.cpp:102
static constexpr NWidgetPart _nested_cheat_widgets[]
Widget definitions of the cheat GUI.
Definition: cheat_gui.cpp:216
static int32_t ClickChangeCompanyCheat(int32_t new_value, int32_t change_direction)
Handle changing of company.
Definition: cheat_gui.cpp:70
int32_t CheckButtonClick(int32_t new_value, int32_t change_direction)
Signature of handler function when user clicks at a cheat.
Definition: cheat_gui.cpp:186
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.
Definition: cheat_gui.cpp:436
static const CheatEntry _cheats_ui[]
The available cheats.
Definition: cheat_gui.cpp:201
Types related to cheating.
Types related to the cheat widgets.
@ WID_C_PANEL
Panel where all cheats are shown in.
Definition: cheat_widget.h:16
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.
RectPadding framerect
Standard padding inside many panels.
Definition: window_gui.h:42
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
int hsep_wide
Wide horizontal spacing.
Definition: window_gui.h:64
int hsep_indent
Width of identation for tree layouts.
Definition: window_gui.h:65
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.
Definition: company_cmd.cpp:52
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.
Definition: company_type.h:18
@ MAX_COMPANIES
Maximum number of companies.
Definition: company_type.h:23
Functions related to errors.
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
Definition: error_gui.cpp:367
@ WL_ERROR
Errors (eg. saving/loading failed)
Definition: error.h:26
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition: fontcache.cpp:77
Geometry functions.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:922
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:851
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.
Definition: gfx.cpp:657
@ FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:209
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1202
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1309
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1191
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:940
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.
Definition: math_func.hpp:79
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
Definition: math_func.hpp:268
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.
Definition: misc_gui.cpp:1079
Base for the NewGRF implementation.
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
Definition: afterload.cpp:3364
void ResetSignalVariant(int32_t)
Updates the current signal variant used in the signal GUI to the one adequate to current year.
Definition: rail_gui.cpp:1971
Functions/types etc.
A number of safeguards to prevent using unsafe methods.
void WriteValue(void *ptr, VarType conv, int64_t val)
Write the value of a setting.
Definition: saveload.cpp:817
int64_t ReadValue(const void *ptr, VarType conv)
Return a signed-long version of the value of a setting.
Definition: saveload.cpp:793
Functions/types related to saving and loading games.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:57
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.
Definition: settings_gui.h:17
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
Definition: settings_gui.h:19
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.
Definition: stdafx.h:280
Functions related to low-level strings.
@ CS_NUMERAL
Only numeric ones.
Definition: string_type.h:26
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.
Definition: strings.cpp:127
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings.cpp:104
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:56
Functions related to OTTD's strings.
@ TD_RTL
Text is written right-to-left by default.
Definition: strings_type.h:24
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17
Information of a cheat.
Definition: cheat_gui.cpp:189
VarType type
type of selector
Definition: cheat_gui.cpp:190
void * variable
pointer to the variable
Definition: cheat_gui.cpp:192
StringID str
string with descriptive text
Definition: cheat_gui.cpp:191
CheckButtonClick * proc
procedure
Definition: cheat_gui.cpp:194
bool * been_used
has this cheat been used before?
Definition: cheat_gui.cpp:193
GUI for the cheats.
Definition: cheat_gui.cpp:227
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: cheat_gui.cpp:401
Dimension icon
Dimension of company icon sprite.
Definition: cheat_gui.cpp:231
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition: cheat_gui.cpp:238
bool value
tells if the bool cheat is active or not
Definition: cheat_type.h:18
bool been_used
has this cheat been used before?
Definition: cheat_type.h:17
Cheat crossing_tunnels
allow tunnels that cross each other
Definition: cheat_type.h:30
Cheat no_jetcrash
no jet will crash on small airports anymore
Definition: cheat_type.h:31
Cheat change_date
changes date ingame
Definition: cheat_type.h:32
Cheat station_rating
Fix station ratings at 100%.
Definition: cheat_type.h:35
Cheat money
get rich or poor
Definition: cheat_type.h:29
Cheat setup_prod
setup raw-material production in game
Definition: cheat_type.h:33
Cheat switch_company
change to another company
Definition: cheat_type.h:28
Cheat magic_bulldozer
dynamite industries, objects
Definition: cheat_type.h:27
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:34
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 debug_inline uint Size()
Get the size of the map.
Definition: map_func.h:288
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:1075
Coordinates of a point in 2D.
static size_t GetPoolSize()
Returns first unused index.
Definition: pool_type.hpp:360
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:328
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:388
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.
Definition: window_gui.h:159
Data structure for an opened window.
Definition: window_gui.h:273
ResizeInfo resize
Resize information.
Definition: window_gui.h:314
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Definition: window_gui.h:361
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1746
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:311
Stuff related to the text buffer GUI.
@ QSF_ACCEPT_UNCHANGED
return success even when the text didn't change
Definition: textbuf_gui.h:20
Map writing/reading functions for tiles.
static debug_inline uint TileHeight(Tile tile)
Returns the height of a tile.
Definition: tile_map.h:29
static const uint MIN_MAP_HEIGHT_LIMIT
Lower bound of maximum allowed heightlevel (in the construction settings)
Definition: tile_type.h:29
static const uint MAX_MAP_HEIGHT_LIMIT
Upper bound of maximum allowed heightlevel (in the construction settings)
Definition: tile_type.h:30
Definition of Interval and OneShot timers.
Definition of the game-calendar-timer.
Definition of the game-economy-timer.
Base class for all vehicles.
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:75
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:50
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:66
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:64
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:69
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1140
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3093
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:3228
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:147
int WidgetID
Widget ID.
Definition: window_type.h:18
@ WC_BUILD_STATION
Build station; Window numbers:
Definition: window_type.h:403
@ WC_BUILD_OBJECT
Build object; Window numbers:
Definition: window_type.h:376
@ WC_STATUS_BAR
Statusbar (at the bottom of your screen); Window numbers:
Definition: window_type.h:64
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:45
@ WC_CHEATS
Cheat window; Window numbers:
Definition: window_type.h:636
@ WC_TRUCK_STATION
Build truck station; Window numbers:
Definition: window_type.h:415
@ WC_INDUSTRY_VIEW
Industry view; Window numbers:
Definition: window_type.h:363
@ WC_BUS_STATION
Build bus station; Window numbers:
Definition: window_type.h:409
@ WC_SMALLMAP
Small map; Window numbers:
Definition: window_type.h:104