OpenTTD Source  20240917-master-g9ab0a47812
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 
428 static WindowDesc _cheats_desc(
429  WDP_AUTO, "cheats", 0, 0,
431  0,
433 );
434 
437 {
440 }
CheatEntry::type
VarType type
type of selector
Definition: cheat_gui.cpp:190
_nested_cheat_widgets
static constexpr NWidgetPart _nested_cheat_widgets[]
Widget definitions of the cheat GUI.
Definition: cheat_gui.cpp:216
DrawArrowButtons
void DrawArrowButtons(int x, int y, Colours button_colour, uint8_t state, bool clickable_left, bool clickable_right)
Draw [<][>] boxes.
Definition: settings_gui.cpp:2926
Window::SetTimeout
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Definition: window_gui.h:364
Cheats::no_jetcrash
Cheat no_jetcrash
no jet will crash on small airports anymore
Definition: cheat_type.h:31
Cheats::crossing_tunnels
Cheat crossing_tunnels
allow tunnels that cross each other
Definition: cheat_type.h:30
Cheats::magic_bulldozer
Cheat magic_bulldozer
dynamite industries, objects
Definition: cheat_type.h:27
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3090
ReloadNewGRFData
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
Definition: afterload.cpp:3337
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:30
command_func.h
IsInsideMM
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
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:68
ShowErrorMessage
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
Definition: error_gui.cpp:367
Cheats::edit_max_hl
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
QSF_ACCEPT_UNCHANGED
@ QSF_ACCEPT_UNCHANGED
return success even when the text didn't change
Definition: textbuf_gui.h:20
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:98
TimerGameCalendar::date_fract
static DateFract date_fract
Fractional part of the day.
Definition: timer_game_calendar.h:35
company_base.h
timer_game_calendar.h
CheatWindow
GUI for the cheats.
Definition: cheat_gui.cpp:227
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:63
company_gui.h
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
CheatEntry
Information of a cheat.
Definition: cheat_gui.cpp:189
CloseWindowById
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
WC_INDUSTRY_VIEW
@ WC_INDUSTRY_VIEW
Industry view; Window numbers:
Definition: window_type.h:363
IntervalTimer< TimerGameCalendar >
CheatWindow::icon
Dimension icon
Dimension of company icon sprite.
Definition: cheat_gui.cpp:231
LinkGraphSchedule::instance
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
Definition: linkgraphschedule.h:52
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
map_func.h
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:77
CalendarEnginesMonthlyLoop
void CalendarEnginesMonthlyLoop()
Monthly update of the availability, reliability, and preview offers of the engines.
Definition: engine.cpp:1111
misc_cmd.h
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1193
Cheats::setup_prod
Cheat setup_prod
setup raw-material production in game
Definition: cheat_type.h:33
SetLocalCompany
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...
Definition: company_cmd.cpp:117
vehicle_base.h
CHT_CHANGE_COMPANY
@ CHT_CHANGE_COMPANY
Switch company.
Definition: cheat_gui.cpp:169
saveload.h
TimerGameEconomy::date_fract
static DateFract date_fract
Fractional part of the day.
Definition: timer_game_economy.h:38
WidgetDimensions::hsep_wide
int hsep_wide
Wide horizontal spacing.
Definition: window_gui.h:64
TimerGameEconomy::UsingWallclockUnits
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
Definition: timer_game_economy.cpp:97
RectPadding::Vertical
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Definition: geometry_type.hpp:69
StrongType::Typedef
Templated helper to make a type-safe 'typedef' representing a single POD value.
Definition: strong_typedef_type.hpp:150
WC_BUILD_STATION
@ WC_BUILD_STATION
Build station; Window numbers:
Definition: window_type.h:403
ClickChangeDateCheat
static int32_t ClickChangeDateCheat(int32_t new_value, int32_t)
Handle changing of the current year.
Definition: cheat_gui.cpp:102
ClickSetProdCheat
static int32_t ClickSetProdCheat(int32_t new_value, int32_t)
Allow (or disallow) changing production of all industries.
Definition: cheat_gui.cpp:88
WC_CHEATS
@ WC_CHEATS
Cheat window; Window numbers:
Definition: window_type.h:630
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:1077
CheatEntry::been_used
bool * been_used
has this cheat been used before?
Definition: cheat_gui.cpp:193
textbuf_gui.h
CHT_MONEY
@ CHT_MONEY
Change amount of money.
Definition: cheat_gui.cpp:168
ReadValue
int64_t ReadValue(const void *ptr, VarType conv)
Return a signed-long version of the value of a setting.
Definition: saveload.cpp:793
CheatNumbers
CheatNumbers
Available cheats.
Definition: cheat_gui.cpp:167
WindowDesc
High level window description.
Definition: window_gui.h:162
WidgetID
int WidgetID
Widget ID.
Definition: window_type.h:18
ClickChangeMaxHlCheat
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
_cheats_desc
static WindowDesc _cheats_desc(WDP_AUTO, "cheats", 0, 0, WC_CHEATS, WC_NONE, 0, _nested_cheat_widgets)
Window description of the cheats GUI.
window_gui.h
Pool::PoolItem<&_company_pool >::GetPoolSize
static size_t GetPoolSize()
Returns first unused index.
Definition: pool_type.hpp:360
CHT_EDIT_MAX_HL
@ CHT_EDIT_MAX_HL
Edit maximum allowed heightlevel.
Definition: cheat_gui.cpp:175
tile_map.h
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:150
CheatWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: cheat_gui.cpp:401
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:317
LinkGraphSchedule::ShiftDates
void ShiftDates(TimerGameEconomy::Date interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
Definition: linkgraphschedule.cpp:135
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:209
Cheats::money
Cheat money
get rich or poor
Definition: cheat_type.h:29
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1746
CheatEntry::proc
CheckButtonClick * proc
procedure
Definition: cheat_gui.cpp:194
MAX_MAP_HEIGHT_LIMIT
static const uint MAX_MAP_HEIGHT_LIMIT
Upper bound of maximum allowed heightlevel (in the construction settings)
Definition: tile_type.h:30
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:940
WID_C_PANEL
@ WID_C_PANEL
Panel where all cheats are shown in.
Definition: cheat_widget.h:16
ConstructionSettings::map_height_limit
uint8_t map_height_limit
the maximum allowed heightlevel
Definition: settings_type.h:382
_cheats
Cheats _cheats
All the cheats.
Definition: cheat.cpp:16
CHT_NUM_CHEATS
@ CHT_NUM_CHEATS
Number of cheats.
Definition: cheat_gui.cpp:178
TimerGameCalendar::ConvertYMDToDate
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: timer_game_calendar.cpp:55
WC_TRUCK_STATION
@ WC_TRUCK_STATION
Build truck station; Window numbers:
Definition: window_type.h:415
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:57
WC_BUS_STATION
@ WC_BUS_STATION
Build bus station; Window numbers:
Definition: window_type.h:409
CheckButtonClick
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
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1311
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:52
TimerGameCalendar::ConvertDateToYMD
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
Definition: timer_game_calendar.cpp:42
safeguards.h
ShowQueryString
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
timer.h
lengthof
#define lengthof(array)
Return the length of an fixed size array.
Definition: stdafx.h:280
CheatEntry::variable
void * variable
pointer to the variable
Definition: cheat_gui.cpp:192
TimerGameCalendar::SetDate
static void SetDate(Date date, DateFract fract)
Set the date.
Definition: timer_game_calendar.cpp:66
sprites.h
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
error.h
TimerGameConst< struct Calendar >::MAX_YEAR
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,...
Definition: timer_game_common.h:173
SETTING_BUTTON_WIDTH
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
Definition: settings_gui.h:17
linkgraphschedule.h
stdafx.h
CheatWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition: cheat_gui.cpp:238
_cheats_ui
static const CheatEntry _cheats_ui[]
The available cheats.
Definition: cheat_gui.cpp:201
Cheat::value
bool value
tells if the bool cheat is active or not
Definition: cheat_type.h:18
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:45
DrawCompanyIcon
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
Definition: company_cmd.cpp:161
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:922
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:71
_money_cheat_amount
static int32_t _money_cheat_amount
The 'amount' to cheat with.
Definition: cheat_gui.cpp:48
string_func.h
rail_gui.h
Pool::PoolItem<&_vehicle_pool >::Iterate
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:388
strings_func.h
CHT_STATION_RATING
@ CHT_STATION_RATING
Fix station ratings at 100%.
Definition: cheat_gui.cpp:174
MIN_MAP_HEIGHT_LIMIT
static const uint MIN_MAP_HEIGHT_LIMIT
Lower bound of maximum allowed heightlevel (in the construction settings)
Definition: tile_type.h:29
WidgetDimensions::hsep_indent
int hsep_indent
Width of identation for tree layouts.
Definition: window_gui.h:65
SetDParamMaxValue
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
CheatEntry::str
StringID str
string with descriptive text
Definition: cheat_gui.cpp:191
Map::Size
static debug_inline uint Size()
Get the size of the map.
Definition: map_func.h:288
SetDParam
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
geometry_func.hpp
InvalidateWindowClassesData
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:3225
cheat_type.h
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:52
CHT_SETUP_PROD
@ CHT_SETUP_PROD
Allow manually editing of industry production.
Definition: cheat_gui.cpp:173
newgrf.h
Cheats::change_date
Cheat change_date
changes date ingame
Definition: cheat_type.h:32
ResetSignalVariant
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
TimerGameConst< struct Calendar >::MIN_YEAR
static constexpr TimerGame< struct Calendar >::Year MIN_YEAR
The absolute minimum year in OTTD.
Definition: timer_game_common.h:176
CHT_NO_JETCRASH
@ CHT_NO_JETCRASH
Disable jet-airplane crashes.
Definition: cheat_gui.cpp:172
company_func.h
WL_ERROR
@ WL_ERROR
Errors (eg. saving/loading failed)
Definition: error.h:26
TimerGameEconomy::SetDate
static void SetDate(Date date, DateFract fract)
Set the date.
Definition: timer_game_economy.cpp:81
CommandHelper
Definition: command_func.h:93
window_func.h
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition: fontcache.cpp:77
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:314
WC_BUILD_OBJECT
@ WC_BUILD_OBJECT
Build object; Window numbers:
Definition: window_type.h:376
TileHeight
static debug_inline uint TileHeight(Tile tile)
Returns the height of a tile.
Definition: tile_map.h:29
OverflowSafeInt< int64_t >
DrawString
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
CHT_CROSSINGTUNNELS
@ CHT_CROSSINGTUNNELS
Allow tunnels to cross each other.
Definition: cheat_gui.cpp:171
TimerGameCalendar::date
static Date date
Current date in days (day counter).
Definition: timer_game_calendar.h:34
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition: settings_type.h:595
Cheats::station_rating
Cheat station_rating
Fix station ratings at 100%.
Definition: cheat_type.h:35
Window
Data structure for an opened window.
Definition: window_gui.h:276
MAX_COMPANIES
@ MAX_COMPANIES
Maximum number of companies.
Definition: company_type.h:23
cheat_widget.h
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:328
WC_STATUS_BAR
@ WC_STATUS_BAR
Statusbar (at the bottom of your screen); Window numbers:
Definition: window_type.h:64
Clamp
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:79
Cheat::been_used
bool been_used
has this cheat been used before?
Definition: cheat_type.h:17
DrawBoolButton
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
Definition: settings_gui.cpp:2978
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1204
settings_gui.h
Rect::Width
int Width() const
Get width of Rect.
Definition: geometry_type.hpp:85
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:75
WidgetDimensions::framerect
RectPadding framerect
Standard padding inside many panels.
Definition: window_gui.h:42
ClickMoneyCheat
static int32_t ClickMoneyCheat(int32_t, int32_t change_direction)
Handle cheating of money.
Definition: cheat_gui.cpp:58
Cheats::switch_company
Cheat switch_company
change to another company
Definition: cheat_type.h:28
WC_SMALLMAP
@ WC_SMALLMAP
Small map; Window numbers:
Definition: window_type.h:104
SETTING_BUTTON_HEIGHT
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
Definition: settings_gui.h:19
TD_RTL
@ TD_RTL
Text is written right-to-left by default.
Definition: strings_type.h:24
CHT_CHANGE_DATE
@ CHT_CHANGE_DATE
Do time traveling.
Definition: cheat_gui.cpp:176
_current_text_dir
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:56
CS_NUMERAL
@ CS_NUMERAL
Only numeric ones.
Definition: string_type.h:26
GetStringBoundingBox
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:851
WriteValue
void WriteValue(void *ptr, VarType conv, int64_t val)
Write the value of a setting.
Definition: saveload.cpp:817
timer_game_economy.h
INVALID_STRING_ID
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17
CHT_EXTRA_DYNAMITE
@ CHT_EXTRA_DYNAMITE
Dynamite anything.
Definition: cheat_gui.cpp:170
ShowCheatWindow
void ShowCheatWindow()
Open cheat window.
Definition: cheat_gui.cpp:436
TimerGameCalendar::year
static Year year
Current year, starting at 0.
Definition: timer_game_calendar.h:32
ClickChangeCompanyCheat
static int32_t ClickChangeCompanyCheat(int32_t new_value, int32_t change_direction)
Handle changing of company.
Definition: cheat_gui.cpp:70
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:66
TimerGameEconomy::date
static Date date
Current date in days (day counter).
Definition: timer_game_economy.h:37