OpenTTD Source: src/cheat_gui.cpp Source File

OpenTTD Source 14.0-beta3

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"
25 #include "linkgraph/linkgraphschedule.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"
33 #include "timer/timer_game_calendar.h"
34 #include "timer/timer_game_economy.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 {
60 Command<CMD_MONEY_CHEAT>::Post(Money(_money_cheat_amount) * change_direction);
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);
91 InvalidateWindowClassesData(WC_INDUSTRY_VIEW);
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. */
105 auto new_year = Clamp(TimerGameCalendar::Year(new_value), CalendarTime::MIN_YEAR, CalendarTime::MAX_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 /* Keep economy and calendar dates synced. */
111 TimerGameEconomy::Date new_economy_date = new_calendar_date.base();
112
113 /* Shift cached dates before we change the date. */
114 for (auto v : Vehicle::Iterate()) v->ShiftDates(new_economy_date - TimerGameEconomy::date);
115 LinkGraphSchedule::instance.ShiftDates(new_economy_date - TimerGameEconomy::date);
116
117 /* Now it's safe to actually change the date. */
118 TimerGameCalendar::SetDate(new_calendar_date, TimerGameCalendar::date_fract);
119
120 /* If not using wallclock units, we keep economy date in sync with calendar date and must change it also. */
121 if (!TimerGameEconomy::UsingWallclockUnits()) TimerGameEconomy::SetDate(new_economy_date, TimerGameEconomy::date_fract);
122
123 CalendarEnginesMonthlyLoop();
124 SetWindowDirty(WC_STATUS_BAR, 0);
125 InvalidateWindowClassesData(WC_BUILD_STATION, 0);
126 InvalidateWindowClassesData(WC_BUS_STATION, 0);
127 InvalidateWindowClassesData(WC_TRUCK_STATION, 0);
128 InvalidateWindowClassesData(WC_BUILD_OBJECT, 0);
129 ResetSignalVariant();
130 return TimerGameCalendar::year.base();
131 }
132
139 static int32_t ClickChangeMaxHlCheat(int32_t new_value, int32_t)
140 {
141 new_value = Clamp(new_value, MIN_MAP_HEIGHT_LIMIT, MAX_MAP_HEIGHT_LIMIT);
142
143 /* Check if at least one mountain on the map is higher than the new value.
144 * If yes, disallow the change. */
145 for (TileIndex t = 0; t < Map::Size(); t++) {
146 if ((int32_t)TileHeight(t) > new_value) {
147 ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR);
148 /* Return old, unchanged value */
149 return _settings_game.construction.map_height_limit;
150 }
151 }
152
153 /* Execute the change and reload GRF Data */
154 _settings_game.construction.map_height_limit = new_value;
155 ReloadNewGRFData();
156
157 /* The smallmap uses an index from heightlevels to colours. Trigger rebuilding it. */
158 InvalidateWindowClassesData(WC_SMALLMAP, 2);
159
160 return _settings_game.construction.map_height_limit;
161 }
162
164 enum CheatNumbers {
165 CHT_MONEY,
166 CHT_CHANGE_COMPANY,
167 CHT_EXTRA_DYNAMITE,
168 CHT_CROSSINGTUNNELS,
169 CHT_NO_JETCRASH,
170 CHT_SETUP_PROD,
171 CHT_STATION_RATING,
172 CHT_EDIT_MAX_HL,
173 CHT_CHANGE_DATE,
174
175 CHT_NUM_CHEATS,
176 };
177
183 typedef int32_t CheckButtonClick(int32_t new_value, int32_t change_direction);
184
186 struct CheatEntry {
187 VarType type;
188 StringID str;
189 void *variable;
190 bool *been_used;
191 CheckButtonClick *proc;
192 };
193
198 static const CheatEntry _cheats_ui[] = {
199 {SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
200 {SLE_UINT8, STR_CHEAT_CHANGE_COMPANY, &_local_company, &_cheats.switch_company.been_used, &ClickChangeCompanyCheat },
201 {SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, nullptr },
202 {SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, nullptr },
203 {SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, nullptr },
204 {SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, &ClickSetProdCheat },
205 {SLE_BOOL, STR_CHEAT_STATION_RATING, &_cheats.station_rating.value, &_cheats.station_rating.been_used, nullptr },
206 {SLE_UINT8, STR_CHEAT_EDIT_MAX_HL, &_settings_game.construction.map_height_limit, &_cheats.edit_max_hl.been_used, &ClickChangeMaxHlCheat },
207 {SLE_INT32, STR_CHEAT_CHANGE_DATE, &TimerGameCalendar::year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
208 };
209
210 static_assert(CHT_NUM_CHEATS == lengthof(_cheats_ui));
211
213 static constexpr NWidgetPart _nested_cheat_widgets[] = {
214 NWidget(NWID_HORIZONTAL),
215 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
216 NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CHEATS, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
217 NWidget(WWT_SHADEBOX, COLOUR_GREY),
218 NWidget(WWT_STICKYBOX, COLOUR_GREY),
219 EndContainer(),
220 NWidget(WWT_PANEL, COLOUR_GREY, WID_C_PANEL), EndContainer(),
221 };
222
224 struct CheatWindow : Window {
225 int clicked;
226 int clicked_widget;
227 uint line_height;
228 Dimension icon;
229
230 CheatWindow(WindowDesc *desc) : Window(desc)
231 {
232 this->InitNested();
233 }
234
235 void OnInit() override
236 {
237 this->icon = GetSpriteSize(SPR_COMPANY_ICON);
238 }
239
240 void DrawWidget(const Rect &r, WidgetID widget) const override
241 {
242 if (widget != WID_C_PANEL) return;
243
244 const Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
245 int y = ir.top;
246
247 bool rtl = _current_text_dir == TD_RTL;
248 uint button_left = rtl ? ir.right - SETTING_BUTTON_WIDTH : ir.left;
249 uint text_left = ir.left + (rtl ? 0 : WidgetDimensions::scaled.hsep_wide + SETTING_BUTTON_WIDTH);
250 uint text_right = ir.right - (rtl ? WidgetDimensions::scaled.hsep_wide + SETTING_BUTTON_WIDTH : 0);
251
252 int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2;
253 int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
254 int icon_y_offset = (this->line_height - this->icon.height) / 2;
255
256 for (int i = 0; i != lengthof(_cheats_ui); i++) {
257 const CheatEntry *ce = &_cheats_ui[i];
258
259 switch (ce->type) {
260 case SLE_BOOL: {
261 bool on = (*(bool*)ce->variable);
262
263 DrawBoolButton(button_left, y + button_y_offset, on, true);
264 SetDParam(0, on ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
265 break;
266 }
267
268 default: {
269 int32_t val = (int32_t)ReadValue(ce->variable, ce->type);
270
271 /* Draw [<][>] boxes for settings of an integer-type */
272 DrawArrowButtons(button_left, y + button_y_offset, COLOUR_YELLOW, clicked - (i * 2), true, true);
273
274 switch (ce->str) {
275 /* Display date for change date cheat */
276 case STR_CHEAT_CHANGE_DATE: SetDParam(0, TimerGameCalendar::date); break;
277
278 /* Draw coloured flag for change company cheat */
279 case STR_CHEAT_CHANGE_COMPANY: {
280 SetDParam(0, val + 1);
281 uint offset = WidgetDimensions::scaled.hsep_indent + GetStringBoundingBox(ce->str).width;
282 DrawCompanyIcon(_local_company, rtl ? text_right - offset - WidgetDimensions::scaled.hsep_indent : text_left + offset, y + icon_y_offset);
283 break;
284 }
285
286 default: SetDParam(0, val);
287 }
288 break;
289 }
290 }
291
292 DrawString(text_left, text_right, y + text_y_offset, ce->str);
293
294 y += this->line_height;
295 }
296 }
297
298 void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
299 {
300 if (widget != WID_C_PANEL) return;
301
302 uint width = 0;
303 for (int i = 0; i != lengthof(_cheats_ui); i++) {
304 const CheatEntry *ce = &_cheats_ui[i];
305 switch (ce->type) {
306 case SLE_BOOL:
307 SetDParam(0, STR_CONFIG_SETTING_ON);
308 width = std::max(width, GetStringBoundingBox(ce->str).width);
309 SetDParam(0, STR_CONFIG_SETTING_OFF);
310 width = std::max(width, GetStringBoundingBox(ce->str).width);
311 break;
312
313 default:
314 switch (ce->str) {
315 /* Display date for change date cheat */
316 case STR_CHEAT_CHANGE_DATE:
317 SetDParam(0, TimerGameCalendar::ConvertYMDToDate(CalendarTime::MAX_YEAR, 11, 31));
318 width = std::max(width, GetStringBoundingBox(ce->str).width);
319 break;
320
321 /* Draw coloured flag for change company cheat */
322 case STR_CHEAT_CHANGE_COMPANY:
323 SetDParamMaxValue(0, MAX_COMPANIES);
324 width = std::max(width, GetStringBoundingBox(ce->str).width + WidgetDimensions::scaled.hsep_wide);
325 break;
326
327 default:
328 SetDParam(0, INT64_MAX);
329 width = std::max(width, GetStringBoundingBox(ce->str).width);
330 break;
331 }
332 break;
333 }
334 }
335
336 this->line_height = std::max<uint>(this->icon.height, SETTING_BUTTON_HEIGHT);
337 this->line_height = std::max<uint>(this->line_height, GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.framerect.Vertical();
338
339 size->width = width + WidgetDimensions::scaled.hsep_wide * 2 + SETTING_BUTTON_WIDTH;
340 size->height = WidgetDimensions::scaled.framerect.Vertical() + this->line_height * lengthof(_cheats_ui);
341 }
342
343 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
344 {
345 if (widget != WID_C_PANEL) return;
346
347 Rect r = this->GetWidget<NWidgetBase>(WID_C_PANEL)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
348 uint btn = (pt.y - r.top) / this->line_height;
349 int x = pt.x - r.left;
350 bool rtl = _current_text_dir == TD_RTL;
351 if (rtl) x = r.Width() - 1 - x;
352
353 if (btn >= lengthof(_cheats_ui)) return;
354
355 const CheatEntry *ce = &_cheats_ui[btn];
356 int value = (int32_t)ReadValue(ce->variable, ce->type);
357 int oldvalue = value;
358
359 if (btn == CHT_CHANGE_DATE && x >= SETTING_BUTTON_WIDTH) {
360 /* Click at the date text directly. */
361 clicked_widget = CHT_CHANGE_DATE;
362 SetDParam(0, value);
363 ShowQueryString(STR_JUST_INT, STR_CHEAT_CHANGE_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
364 return;
365 } else if (btn == CHT_EDIT_MAX_HL && x >= SETTING_BUTTON_WIDTH) {
366 clicked_widget = CHT_EDIT_MAX_HL;
367 SetDParam(0, value);
368 ShowQueryString(STR_JUST_INT, STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
369 return;
370 }
371
372 /* Not clicking a button? */
373 if (!IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) return;
374
375 *ce->been_used = true;
376
377 switch (ce->type) {
378 case SLE_BOOL:
379 value ^= 1;
380 if (ce->proc != nullptr) ce->proc(value, 0);
381 break;
382
383 default:
384 /* Take whatever the function returns */
385 value = ce->proc(value + ((x >= SETTING_BUTTON_WIDTH / 2) ? 1 : -1), (x >= SETTING_BUTTON_WIDTH / 2) ? 1 : -1);
386
387 /* The first cheat (money), doesn't return a different value. */
388 if (value != oldvalue || btn == CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= SETTING_BUTTON_WIDTH / 2) != rtl ? 1 : 0);
389 break;
390 }
391
392 if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64_t)value);
393
394 this->SetTimeout();
395
396 this->SetDirty();
397 }
398
399 void OnTimeout() override
400 {
401 this->clicked = 0;
402 this->SetDirty();
403 }
404
405 void OnQueryTextFinished(char *str) override
406 {
407 /* Was 'cancel' pressed or nothing entered? */
408 if (str == nullptr || StrEmpty(str)) return;
409
410 const CheatEntry *ce = &_cheats_ui[clicked_widget];
411 int oldvalue = (int32_t)ReadValue(ce->variable, ce->type);
412 int value = atoi(str);
413 *ce->been_used = true;
414 value = ce->proc(value, value - oldvalue);
415
416 if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64_t)value);
417 this->SetDirty();
418 }
419
420 IntervalTimer<TimerGameCalendar> daily_interval = {{TimerGameCalendar::MONTH, TimerGameCalendar::Priority::NONE}, [this](auto) {
421 this->SetDirty();
422 }};
423 };
424
426 static WindowDesc _cheats_desc(__FILE__, __LINE__,
427 WDP_AUTO, "cheats", 0, 0,
428 WC_CHEATS, WC_NONE,
429 0,
430 std::begin(_nested_cheat_widgets), std::end(_nested_cheat_widgets)
431 );
432
434 void ShowCheatWindow()
435 {
436 CloseWindowById(WC_CHEATS, 0);
437 new CheatWindow(&_cheats_desc);
438 }
CheatEntry::type
VarType type
type of selector
Definition: cheat_gui.cpp:187
_nested_cheat_widgets
static constexpr NWidgetPart _nested_cheat_widgets[]
Widget definitions of the cheat GUI.
Definition: cheat_gui.cpp:213
Window::SetTimeout
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Definition: window_gui.h:355
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:3082
ReloadNewGRFData
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
Definition: afterload.cpp:3336
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:224
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:186
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:1141
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:228
LinkGraphSchedule::instance
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
Definition: linkgraphschedule.h:52
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:1151
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:114
vehicle_base.h
CHT_CHANGE_COMPANY
@ CHT_CHANGE_COMPANY
Switch company.
Definition: cheat_gui.cpp:166
saveload.h
_cheats_desc
static WindowDesc _cheats_desc(__FILE__, __LINE__, WDP_AUTO, "cheats", 0, 0, WC_CHEATS, WC_NONE, 0, std::begin(_nested_cheat_widgets), std::end(_nested_cheat_widgets))
Window description of the cheats GUI.
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:397
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
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
StrEmpty
bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:56
WC_CHEATS
@ WC_CHEATS
Cheat window; Window numbers:
Definition: window_type.h:631
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:1038
CheatEntry::been_used
bool * been_used
has this cheat been used before?
Definition: cheat_gui.cpp:190
textbuf_gui.h
CHT_MONEY
@ CHT_MONEY
Change amount of money.
Definition: cheat_gui.cpp:165
ReadValue
int64_t ReadValue(const void *ptr, VarType conv)
Return a signed-long version of the value of a setting.
Definition: saveload.cpp:782
CheatNumbers
CheatNumbers
Available cheats.
Definition: cheat_gui.cpp:164
WindowDesc
High level window description.
Definition: window_gui.h:153
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:139
window_gui.h
Pool::PoolItem<&_company_pool >::GetPoolSize
static size_t GetPoolSize()
Returns first unused index.
Definition: pool_type.hpp:356
CHT_EDIT_MAX_HL
@ CHT_EDIT_MAX_HL
Edit maximum allowed heightlevel.
Definition: cheat_gui.cpp:172
tile_map.h
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:141
CheatWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: cheat_gui.cpp:399
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:308
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:203
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:1747
CheatEntry::proc
CheckButtonClick * proc
procedure
Definition: cheat_gui.cpp:191
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:941
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:370
_cheats
Cheats _cheats
All the cheats.
Definition: cheat.cpp:16
CHT_NUM_CHEATS
@ CHT_NUM_CHEATS
Number of cheats.
Definition: cheat_gui.cpp:175
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:409
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:55
WC_BUS_STATION
@ WC_BUS_STATION
Build bus station; Window numbers:
Definition: window_type.h:403
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:183
MAX_COMPANIES
@ MAX_COMPANIES
Maximum number of companies.
Definition: company_type.h:23
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1258
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:49
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:1086
timer.h
CheatEntry::variable
void * variable
pointer to the variable
Definition: cheat_gui.cpp:189
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
DrawArrowButtons
void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
Draw [<][>] boxes.
Definition: settings_gui.cpp:2909
CheatWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition: cheat_gui.cpp:235
_cheats_ui
static const CheatEntry _cheats_ui[]
The available cheats.
Definition: cheat_gui.cpp:198
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:158
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:941
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:384
strings_func.h
CHT_STATION_RATING
@ CHT_STATION_RATING
Fix station ratings at 100%.
Definition: cheat_gui.cpp:171
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:188
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:3217
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:170
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:2332
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:169
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:78
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:300
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:305
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:658
CHT_CROSSINGTUNNELS
@ CHT_CROSSINGTUNNELS
Allow tunnels to cross each other.
Definition: cheat_gui.cpp:168
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:620
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:267
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:324
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:2961
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1162
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:173
_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:852
WriteValue
void WriteValue(void *ptr, VarType conv, int64_t val)
Write the value of a setting.
Definition: saveload.cpp:806
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:167
ShowCheatWindow
void ShowCheatWindow()
Open cheat window.
Definition: cheat_gui.cpp:434
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