OpenTTD Source: src/cheat_gui.cpp Source File

OpenTTD Source 15.3

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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
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 "currency.h"
16#include "saveload/saveload.h"
17#include "vehicle_base.h"
18#include "textbuf_gui.h"
19#include "window_gui.h"
20#include "string_func.h"
21#include "strings_func.h"
22#include "window_func.h"
23#include "rail_gui.h"
24#include "settings_gui.h"
25#include "company_gui.h"
26#include "linkgraph/linkgraphschedule.h"
27#include "map_func.h"
28#include "tile_map.h"
29#include "newgrf.h"
30#include "error.h"
31#include "misc_cmd.h"
32#include "settings_type.h"
33#include "settings_internal.h"
34#include "timer/timer.h"
35#include "timer/timer_game_calendar.h"
36#include "timer/timer_game_economy.h"
37#include "core/string_consumer.hpp"
38
39#include "widgets/cheat_widget.h"
40
41#include "table/sprites.h"
42#include "table/strings.h"
43
44#include "safeguards.h"
45
46
52 static int32_t _money_cheat_amount = 10000000;
53
62 static int32_t ClickMoneyCheat(int32_t, int32_t change_direction)
63{
64 Command<CMD_MONEY_CHEAT>::Post(Money(_money_cheat_amount) * change_direction);
65 return _money_cheat_amount;
66}
67
74 static int32_t ClickChangeCompanyCheat(int32_t new_value, int32_t change_direction)
75{
76 while ((uint)new_value < Company::GetPoolSize()) {
77 if (Company::IsValidID((CompanyID)new_value)) {
78 SetLocalCompany((CompanyID)new_value);
79 return _local_company.base();
80 }
81 new_value += change_direction;
82 }
83
84 return _local_company.base();
85}
86
92 static int32_t ClickSetProdCheat(int32_t new_value, int32_t)
93{
94 _cheats.setup_prod.value = (new_value != 0);
95 InvalidateWindowClassesData(WC_INDUSTRY_VIEW);
96 return _cheats.setup_prod.value;
97}
98
99extern void CalendarEnginesMonthlyLoop();
100
106 static int32_t ClickChangeDateCheat(int32_t new_value, int32_t)
107{
108 /* Don't allow changing to an invalid year, or the current year. */
109 auto new_year = Clamp(TimerGameCalendar::Year(new_value), CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
110 if (new_year == TimerGameCalendar::year) return TimerGameCalendar::year.base();
111
112 TimerGameCalendar::YearMonthDay ymd = TimerGameCalendar::ConvertDateToYMD(TimerGameCalendar::date);
113 TimerGameCalendar::Date new_calendar_date = TimerGameCalendar::ConvertYMDToDate(new_year, ymd.month, ymd.day);
114
115 TimerGameCalendar::SetDate(new_calendar_date, TimerGameCalendar::date_fract);
116
117 /* If not using wallclock units, we keep economy date in sync with calendar date and must change it also. */
118 if (!TimerGameEconomy::UsingWallclockUnits()) {
119 /* Keep economy and calendar dates synced. */
120 TimerGameEconomy::Date new_economy_date{new_calendar_date.base()};
121
122 /* Shift cached dates before we change the date. */
123 for (auto v : Vehicle::Iterate()) v->ShiftDates(new_economy_date - TimerGameEconomy::date);
124 LinkGraphSchedule::instance.ShiftDates(new_economy_date - TimerGameEconomy::date);
125
126 /* Now it's safe to actually change the date. */
127 TimerGameEconomy::SetDate(new_economy_date, TimerGameEconomy::date_fract);
128 }
129
130 CalendarEnginesMonthlyLoop();
131 SetWindowDirty(WC_STATUS_BAR, 0);
132 InvalidateWindowClassesData(WC_BUILD_STATION, 0);
133 InvalidateWindowClassesData(WC_BUS_STATION, 0);
134 InvalidateWindowClassesData(WC_TRUCK_STATION, 0);
135 InvalidateWindowClassesData(WC_BUILD_OBJECT, 0);
136 InvalidateWindowClassesData(WC_FINANCES, 0);
137 ResetSignalVariant();
138 return TimerGameCalendar::year.base();
139}
140
147 static int32_t ClickChangeMaxHlCheat(int32_t new_value, int32_t)
148{
149 new_value = Clamp(new_value, MIN_MAP_HEIGHT_LIMIT, MAX_MAP_HEIGHT_LIMIT);
150
151 /* Check if at least one mountain on the map is higher than the new value.
152 * If yes, disallow the change. */
153 for (const auto t : Map::Iterate()) {
154 if ((int32_t)TileHeight(t) > new_value) {
155 ShowErrorMessage(GetEncodedString(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN), {}, WL_ERROR);
156 /* Return old, unchanged value */
157 return _settings_game.construction.map_height_limit;
158 }
159 }
160
161 /* Execute the change and reload GRF Data */
162 _settings_game.construction.map_height_limit = new_value;
163 ReloadNewGRFData();
164
165 /* The smallmap uses an index from heightlevels to colours. Trigger rebuilding it. */
166 InvalidateWindowClassesData(WC_SMALLMAP, 2);
167
168 return _settings_game.construction.map_height_limit;
169}
170
172 enum CheatNumbers : uint8_t {
173 CHT_MONEY,
174 CHT_CHANGE_COMPANY,
175 CHT_EXTRA_DYNAMITE,
176 CHT_CROSSINGTUNNELS,
177 CHT_NO_JETCRASH,
178 CHT_SETUP_PROD,
179 CHT_STATION_RATING,
180 CHT_EDIT_MAX_HL,
181 CHT_CHANGE_DATE,
182
183 CHT_NUM_CHEATS,
184};
185
191 typedef int32_t CheckButtonClick(int32_t new_value, int32_t change_direction);
192
194 struct CheatEntry {
195 VarType type;
196 StringID str;
197 void *variable;
198 bool *been_used;
199 CheckButtonClick *proc;
200};
201
206 static const CheatEntry _cheats_ui[] = {
207 {SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
208 {SLE_UINT8, STR_CHEAT_CHANGE_COMPANY, &_local_company, &_cheats.switch_company.been_used, &ClickChangeCompanyCheat },
209 {SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, nullptr },
210 {SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, nullptr },
211 {SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, nullptr },
212 {SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, &ClickSetProdCheat },
213 {SLE_BOOL, STR_CHEAT_STATION_RATING, &_cheats.station_rating.value, &_cheats.station_rating.been_used, nullptr },
214 {SLE_UINT8, STR_CHEAT_EDIT_MAX_HL, &_settings_game.construction.map_height_limit, &_cheats.edit_max_hl.been_used, &ClickChangeMaxHlCheat },
215 {SLE_INT32, STR_CHEAT_CHANGE_DATE, &TimerGameCalendar::year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
216};
217
218static_assert(CHT_NUM_CHEATS == lengthof(_cheats_ui));
219
221 static constexpr std::initializer_list<NWidgetPart> _nested_cheat_widgets = {
222 NWidget(NWID_HORIZONTAL),
223 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
224 NWidget(WWT_CAPTION, COLOUR_GREY), SetStringTip(STR_CHEATS, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
225 NWidget(WWT_SHADEBOX, COLOUR_GREY),
226 NWidget(WWT_STICKYBOX, COLOUR_GREY),
227 EndContainer(),
228 NWidget(WWT_PANEL, COLOUR_GREY),
229 NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.framerect),
230 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_C_PANEL),
231 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_C_SETTINGS),
232 EndContainer(),
233 EndContainer(),
234};
235
237 struct CheatWindow : Window {
238 int clicked = 0;
239 int clicked_cheat = 0;
240 uint line_height = 0;
241 Dimension icon{};
242
243 std::vector<const SettingDesc *> sandbox_settings{};
244 const SettingDesc *clicked_setting = nullptr;
245 const SettingDesc *last_clicked_setting = nullptr;
246 const SettingDesc *valuewindow_entry = nullptr;
247
248 CheatWindow(WindowDesc &desc) : Window(desc)
249 {
250 this->sandbox_settings = GetFilteredSettingCollection([](const SettingDesc &sd) { return sd.flags.Test(SettingFlag::Sandbox); });
251 this->InitNested();
252 }
253
254 void OnInit() override
255 {
256 this->icon = GetSpriteSize(SPR_COMPANY_ICON);
257 }
258
259 void DrawWidget(const Rect &r, WidgetID widget) const override
260 {
261 switch (widget) {
262 case WID_C_PANEL: DrawCheatWidget(r); break;
263 case WID_C_SETTINGS: DrawSettingsWidget(r); break;
264 }
265 }
266
267 void DrawCheatWidget(const Rect &r) const
268 {
269 const Rect ir = r;
270 int y = ir.top;
271
272 bool rtl = _current_text_dir == TD_RTL;
273 uint button_left = rtl ? ir.right - SETTING_BUTTON_WIDTH : ir.left;
274 uint text_left = ir.left + (rtl ? 0 : WidgetDimensions::scaled.hsep_wide + SETTING_BUTTON_WIDTH);
275 uint text_right = ir.right - (rtl ? WidgetDimensions::scaled.hsep_wide + SETTING_BUTTON_WIDTH : 0);
276
277 int text_y_offset = (this->line_height - GetCharacterHeight(FS_NORMAL)) / 2;
278 int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
279 int icon_y_offset = (this->line_height - this->icon.height) / 2;
280
281 for (int i = 0; i != lengthof(_cheats_ui); i++) {
282 const CheatEntry *ce = &_cheats_ui[i];
283
284 std::string str;
285 switch (ce->type) {
286 case SLE_BOOL: {
287 bool on = (*(bool*)ce->variable);
288
289 DrawBoolButton(button_left, y + button_y_offset, COLOUR_YELLOW, COLOUR_GREY, on, true);
290 str = GetString(ce->str, on ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
291 break;
292 }
293
294 default: {
295 int32_t val = static_cast<int32_t>(ReadValue(ce->variable, ce->type));
296
297 /* Draw [<][>] boxes for settings of an integer-type */
298 DrawArrowButtons(button_left, y + button_y_offset, COLOUR_YELLOW, clicked - (i * 2), true, true);
299
300 switch (ce->str) {
301 /* Display date for change date cheat */
302 case STR_CHEAT_CHANGE_DATE:
303 str = GetString(ce->str, TimerGameCalendar::date);
304 break;
305
306 /* Draw coloured flag for change company cheat */
307 case STR_CHEAT_CHANGE_COMPANY: {
308 str = GetString(ce->str, val + 1);
309 uint offset = WidgetDimensions::scaled.hsep_indent + GetStringBoundingBox(str).width;
310 DrawCompanyIcon(_local_company, rtl ? text_right - offset - WidgetDimensions::scaled.hsep_indent : text_left + offset, y + icon_y_offset);
311 break;
312 }
313
314 default:
315 str = GetString(ce->str, val);
316 break;
317 }
318 break;
319 }
320 }
321
322 DrawString(text_left, text_right, y + text_y_offset, str);
323
324 y += this->line_height;
325 }
326 }
327
328 void DrawSettingsWidget(const Rect &r) const
329 {
330 Rect ir = r.WithHeight(this->line_height);
331
332 for (const auto &desc : this->sandbox_settings) {
333 DrawSetting(ir, desc);
334 ir = ir.Translate(0, this->line_height);
335 }
336 }
337
338 void DrawSetting(const Rect r, const SettingDesc *desc) const
339 {
340 const IntSettingDesc *sd = desc->AsIntSetting();
341 int state = this->clicked_setting == sd ? this->clicked : 0;
342
343 bool rtl = _current_text_dir == TD_RTL;
344
345 Rect buttons = r.WithWidth(SETTING_BUTTON_WIDTH, rtl);
346 Rect text = r.Indent(SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_wide, rtl);
347 buttons.top += (r.Height() - SETTING_BUTTON_HEIGHT) / 2;
348 text.top += (r.Height() - GetCharacterHeight(FS_NORMAL)) / 2;
349
350 /* We do not allow changes of some items when we are a client in a network game */
351 bool editable = sd->IsEditable();
352
353 auto [min_val, max_val] = sd->GetRange();
354 int32_t value = sd->Read(&GetGameSettings());
355 if (sd->IsBoolSetting()) {
356 /* Draw checkbox for boolean-value either on/off */
357 DrawBoolButton(buttons.left, buttons.top, COLOUR_YELLOW, COLOUR_GREY, value != 0, editable);
358 } else if (sd->flags.Test(SettingFlag::GuiDropdown)) {
359 /* Draw [v] button for settings of an enum-type */
360 DrawDropDownButton(buttons.left, buttons.top, COLOUR_YELLOW, state != 0, editable);
361 } else {
362 /* Draw [<][>] boxes for settings of an integer-type */
363 DrawArrowButtons(buttons.left, buttons.top, COLOUR_YELLOW, state,
364 editable && value != (sd->flags.Test(SettingFlag::GuiZeroIsSpecial) ? 0 : min_val), editable && static_cast<uint32_t>(value) != max_val);
365 }
366 auto [param1, param2] = sd->GetValueParams(value);
367 DrawString(text.left, text.right, text.top, GetString(sd->GetTitle(), STR_CONFIG_SETTING_VALUE, param1, param2), TC_LIGHT_BLUE);
368 }
369
370 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
371 {
372 switch (widget) {
373 case WID_C_PANEL: UpdateCheatPanelSize(size); break;
374 case WID_C_SETTINGS: UpdateSettingsPanelSize(size); break;
375 }
376 }
377
378 void UpdateCheatPanelSize(Dimension &size)
379 {
380 uint width = 0;
381 for (const auto &ce : _cheats_ui) {
382 switch (ce.type) {
383 case SLE_BOOL:
384 width = std::max(width, GetStringBoundingBox(GetString(ce.str, STR_CONFIG_SETTING_ON)).width);
385 width = std::max(width, GetStringBoundingBox(GetString(ce.str, STR_CONFIG_SETTING_OFF)).width);
386 break;
387
388 default:
389 switch (ce.str) {
390 /* Display date for change date cheat */
391 case STR_CHEAT_CHANGE_DATE:
392 width = std::max(width, GetStringBoundingBox(GetString(ce.str, TimerGameCalendar::ConvertYMDToDate(CalendarTime::MAX_YEAR, 11, 31))).width);
393 break;
394
395 /* Draw coloured flag for change company cheat */
396 case STR_CHEAT_CHANGE_COMPANY:
397 width = std::max(width, GetStringBoundingBox(GetString(ce.str, MAX_COMPANIES)).width + WidgetDimensions::scaled.hsep_wide);
398 break;
399
400 default:
401 width = std::max(width, GetStringBoundingBox(GetString(ce.str, INT64_MAX)).width);
402 break;
403 }
404 break;
405 }
406 }
407
408 this->line_height = std::max<uint>(this->icon.height, SETTING_BUTTON_HEIGHT);
409 this->line_height = std::max<uint>(this->line_height, GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.framerect.Vertical();
410
411 size.width = width + WidgetDimensions::scaled.hsep_wide * 2 + SETTING_BUTTON_WIDTH;
412 size.height = this->line_height * lengthof(_cheats_ui);
413 }
414
415 void UpdateSettingsPanelSize(Dimension &size)
416 {
417 uint width = 0;
418 for (const auto &desc : this->sandbox_settings) {
419 const IntSettingDesc *sd = desc->AsIntSetting();
420
421 auto [param1, param2] = sd->GetValueParams(sd->GetDefaultValue());
422 width = std::max(width, GetStringBoundingBox(GetString(sd->GetTitle(), STR_CONFIG_SETTING_VALUE, param1, param2)).width);
423 }
424
425 size.width = width + WidgetDimensions::scaled.hsep_wide * 2 + SETTING_BUTTON_WIDTH;
426 size.height = this->line_height * static_cast<uint>(std::size(this->sandbox_settings));
427 }
428
429 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
430 {
431 switch (widget) {
432 case WID_C_PANEL: CheatPanelClick(pt); break;
433 case WID_C_SETTINGS: SettingsPanelClick(pt); break;
434 }
435 }
436
437 void CheatPanelClick(Point pt)
438 {
439 Rect r = this->GetWidget<NWidgetBase>(WID_C_PANEL)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
440 uint btn = (pt.y - r.top) / this->line_height;
441 int x = pt.x - r.left;
442 bool rtl = _current_text_dir == TD_RTL;
443 if (rtl) x = r.Width() - 1 - x;
444
445 if (btn >= lengthof(_cheats_ui)) return;
446
447 const CheatEntry *ce = &_cheats_ui[btn];
448 int value = static_cast<int32_t>(ReadValue(ce->variable, ce->type));
449 int oldvalue = value;
450
451 if (btn == CHT_CHANGE_DATE && x >= SETTING_BUTTON_WIDTH) {
452 /* Click at the date text directly. */
453 clicked_cheat = CHT_CHANGE_DATE;
454 ShowQueryString(GetString(STR_JUST_INT, value), STR_CHEAT_CHANGE_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QueryStringFlag::AcceptUnchanged);
455 return;
456 } else if (btn == CHT_EDIT_MAX_HL && x >= SETTING_BUTTON_WIDTH) {
457 clicked_cheat = CHT_EDIT_MAX_HL;
458 ShowQueryString(GetString(STR_JUST_INT, value), STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT, 8, this, CS_NUMERAL, QueryStringFlag::AcceptUnchanged);
459 return;
460 }
461
462 /* Not clicking a button? */
463 if (!IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) return;
464
465 this->clicked_setting = nullptr;
466 *ce->been_used = true;
467
468 switch (ce->type) {
469 case SLE_BOOL:
470 value ^= 1;
471 if (ce->proc != nullptr) ce->proc(value, 0);
472 break;
473
474 default:
475 /* Take whatever the function returns */
476 value = ce->proc(value + ((x >= SETTING_BUTTON_WIDTH / 2) ? 1 : -1), (x >= SETTING_BUTTON_WIDTH / 2) ? 1 : -1);
477
478 /* The first cheat (money), doesn't return a different value. */
479 if (value != oldvalue || btn == CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= SETTING_BUTTON_WIDTH / 2) != rtl ? 1 : 0);
480 break;
481 }
482
483 if (value != oldvalue) WriteValue(ce->variable, ce->type, static_cast<int64_t>(value));
484
485 this->SetTimeout();
486
487 this->SetDirty();
488 }
489
490 void SettingsPanelClick(Point pt)
491 {
492 int row = this->GetRowFromWidget(pt.y, WID_C_SETTINGS, WidgetDimensions::scaled.framerect.top, this->line_height);
493 if (row == INT_MAX) return;
494
495 const SettingDesc *desc = this->sandbox_settings[row];
496 const IntSettingDesc *sd = desc->AsIntSetting();
497
498 if (!sd->IsEditable()) return;
499
500 Rect r = this->GetWidget<NWidgetBase>(WID_C_SETTINGS)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
501 int x = pt.x - r.left;
502 bool rtl = _current_text_dir == TD_RTL;
503 if (rtl) x = r.Width() - 1 - x;
504
505 if (x < SETTING_BUTTON_WIDTH) {
506 ChangeSettingValue(sd, x);
507 } else {
508 /* Only open editbox if clicked for the second time, and only for types where it is sensible for. */
509 if (this->last_clicked_setting == sd && !sd->IsBoolSetting() && !sd->flags.Test(SettingFlag::GuiDropdown)) {
510 int64_t value64 = sd->Read(&GetGameSettings());
511
512 /* Show the correct currency-translated value */
513 if (sd->flags.Test(SettingFlag::GuiCurrency)) value64 *= GetCurrency().rate;
514
515 CharSetFilter charset_filter = CS_NUMERAL; //default, only numeric input allowed
516 if (sd->min < 0) charset_filter = CS_NUMERAL_SIGNED; // special case, also allow '-' sign for negative input
517
518 this->valuewindow_entry = sd;
519
520 /* Limit string length to 14 so that MAX_INT32 * max currency rate doesn't exceed MAX_INT64. */
521 ShowQueryString(GetString(STR_JUST_INT, value64), STR_CONFIG_SETTING_QUERY_CAPTION, 15, this, charset_filter, QueryStringFlag::EnableDefault);
522 }
523
524 this->clicked_setting = sd;
525 }
526 }
527
528 void ChangeSettingValue(const IntSettingDesc *sd, int x)
529 {
530 int32_t value = sd->Read(&GetGameSettings());
531 int32_t oldvalue = value;
532 if (sd->IsBoolSetting()) {
533 value ^= 1;
534 } else {
535 /* don't allow too fast scrolling */
536 if (this->flags.Test(WindowFlag::Timeout) && this->timeout_timer > 1) {
537 _left_button_clicked = false;
538 return;
539 }
540
541 /* Add a dynamic step-size to the scroller. In a maximum of
542 * 50-steps you should be able to get from min to max,
543 * unless specified otherwise in the 'interval' variable
544 * of the current setting. */
545 uint32_t step = (sd->interval == 0) ? ((sd->max - sd->min) / 50) : sd->interval;
546 if (step == 0) step = 1;
547
548 /* Increase or decrease the value and clamp it to extremes */
549 if (x >= SETTING_BUTTON_WIDTH / 2) {
550 value += step;
551 if (sd->min < 0) {
552 assert(static_cast<int32_t>(sd->max) >= 0);
553 if (value > static_cast<int32_t>(sd->max)) value = static_cast<int32_t>(sd->max);
554 } else {
555 if (static_cast<uint32_t>(value) > sd->max) value = static_cast<int32_t>(sd->max);
556 }
557 if (value < sd->min) value = sd->min; // skip between "disabled" and minimum
558 } else {
559 value -= step;
560 if (value < sd->min) value = sd->flags.Test(SettingFlag::GuiZeroIsSpecial) ? 0 : sd->min;
561 }
562
563 /* Set up scroller timeout for numeric values */
564 if (value != oldvalue) {
565 this->last_clicked_setting = nullptr;
566 this->clicked_setting = sd;
567 this->clicked = (x >= SETTING_BUTTON_WIDTH / 2) != (_current_text_dir == TD_RTL) ? 2 : 1;
568 this->SetTimeout();
569 _left_button_clicked = false;
570 }
571 }
572
573 if (value != oldvalue) {
574 SetSettingValue(sd, value);
575 this->SetDirty();
576 }
577 }
578
579 bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override
580 {
581 if (widget != WID_C_SETTINGS) return false;
582
583 int row = GetRowFromWidget(pt.y, widget, WidgetDimensions::scaled.framerect.top, this->line_height);
584 if (row == INT_MAX) return false;
585
586 const SettingDesc *desc = this->sandbox_settings[row];
587 const IntSettingDesc *sd = desc->AsIntSetting();
588 GuiShowTooltips(this, GetEncodedString(sd->GetHelp()), close_cond);
589
590 return true;
591 }
592
593 void OnTimeout() override
594 {
595 this->clicked_setting = nullptr;
596 this->clicked = 0;
597 this->SetDirty();
598 }
599
600 void OnQueryTextFinished(std::optional<std::string> str) override
601 {
602 /* Was 'cancel' pressed or nothing entered? */
603 if (!str.has_value() || str->empty()) return;
604
605 if (this->valuewindow_entry != nullptr) {
606 const IntSettingDesc *sd = this->valuewindow_entry->AsIntSetting();
607
608 int32_t value;
609 if (!str->empty()) {
610 auto llvalue = ParseInteger<int64_t>(*str, 10, true);
611 if (!llvalue.has_value()) return;
612
613 /* Save the correct currency-translated value */
614 if (sd->flags.Test(SettingFlag::GuiCurrency)) llvalue = *llvalue / GetCurrency().rate;
615
616 value = ClampTo<int32_t>(*llvalue);
617 } else {
618 value = sd->GetDefaultValue();
619 }
620
621 SetSettingValue(sd, value);
622 } else {
623 const CheatEntry *ce = &_cheats_ui[clicked_cheat];
624 int oldvalue = static_cast<int32_t>(ReadValue(ce->variable, ce->type));
625 auto value = ParseInteger<int32_t>(*str, 10, true);
626 if (!value.has_value()) return;
627 *ce->been_used = true;
628 value = ce->proc(*value, *value - oldvalue);
629
630 if (*value != oldvalue) WriteValue(ce->variable, ce->type, static_cast<int64_t>(*value));
631 }
632
633 this->valuewindow_entry = nullptr;
634 this->SetDirty();
635 }
636
637 const IntervalTimer<TimerGameCalendar> daily_interval = {{TimerGameCalendar::MONTH, TimerGameCalendar::Priority::NONE}, [this](auto) {
638 this->SetDirty();
639 }};
640};
641
643 static WindowDesc _cheats_desc(
644 WDP_AUTO, "cheats", 0, 0,
645 WC_CHEATS, WC_NONE,
646 {},
647 _nested_cheat_widgets
648);
649
651 void ShowCheatWindow()
652{
653 CloseWindowById(WC_CHEATS, 0);
654 new CheatWindow(_cheats_desc);
655}
_cheats
Cheats _cheats
All the cheats.
Definition cheat.cpp:16
_nested_cheat_widgets
static constexpr std::initializer_list< NWidgetPart > _nested_cheat_widgets
Widget definitions of the cheat GUI.
Definition cheat_gui.cpp:221
CheatNumbers
CheatNumbers
Available cheats.
Definition cheat_gui.cpp:172
CHT_NO_JETCRASH
@ CHT_NO_JETCRASH
Disable jet-airplane crashes.
Definition cheat_gui.cpp:177
CHT_CHANGE_DATE
@ CHT_CHANGE_DATE
Do time traveling.
Definition cheat_gui.cpp:181
CHT_CROSSINGTUNNELS
@ CHT_CROSSINGTUNNELS
Allow tunnels to cross each other.
Definition cheat_gui.cpp:176
CHT_SETUP_PROD
@ CHT_SETUP_PROD
Allow manually editing of industry production.
Definition cheat_gui.cpp:178
CHT_CHANGE_COMPANY
@ CHT_CHANGE_COMPANY
Switch company.
Definition cheat_gui.cpp:174
CHT_NUM_CHEATS
@ CHT_NUM_CHEATS
Number of cheats.
Definition cheat_gui.cpp:183
CHT_EXTRA_DYNAMITE
@ CHT_EXTRA_DYNAMITE
Dynamite anything.
Definition cheat_gui.cpp:175
CHT_MONEY
@ CHT_MONEY
Change amount of money.
Definition cheat_gui.cpp:173
CHT_STATION_RATING
@ CHT_STATION_RATING
Fix station ratings at 100%.
Definition cheat_gui.cpp:179
CHT_EDIT_MAX_HL
@ CHT_EDIT_MAX_HL
Edit maximum allowed heightlevel.
Definition cheat_gui.cpp:180
_money_cheat_amount
static int32_t _money_cheat_amount
The 'amount' to cheat with.
Definition cheat_gui.cpp:52
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:147
CalendarEnginesMonthlyLoop
void CalendarEnginesMonthlyLoop()
Monthly update of the availability, reliability, and preview offers of the engines.
Definition engine.cpp:1139
ClickMoneyCheat
static int32_t ClickMoneyCheat(int32_t, int32_t change_direction)
Handle cheating of money.
Definition cheat_gui.cpp:62
ClickSetProdCheat
static int32_t ClickSetProdCheat(int32_t new_value, int32_t)
Allow (or disallow) changing production of all industries.
Definition cheat_gui.cpp:92
ClickChangeDateCheat
static int32_t ClickChangeDateCheat(int32_t new_value, int32_t)
Handle changing of the current year.
Definition cheat_gui.cpp:106
ClickChangeCompanyCheat
static int32_t ClickChangeCompanyCheat(int32_t new_value, int32_t change_direction)
Handle changing of company.
Definition cheat_gui.cpp:74
_cheats_desc
static WindowDesc _cheats_desc(WDP_AUTO, "cheats", 0, 0, WC_CHEATS, WC_NONE, {}, _nested_cheat_widgets)
Window description of the cheats GUI.
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:191
ShowCheatWindow
void ShowCheatWindow()
Open cheat window.
Definition cheat_gui.cpp:651
_cheats_ui
static const CheatEntry _cheats_ui[]
The available cheats.
Definition cheat_gui.cpp:206
cheat_type.h
Types related to cheating.
cheat_widget.h
Types related to the cheat widgets.
WID_C_PANEL
@ WID_C_PANEL
Panel where all cheats are shown in.
Definition cheat_widget.h:16
WID_C_SETTINGS
@ WID_C_SETTINGS
Panel where sandbox settings are shown.
Definition cheat_widget.h:17
BaseBitSet::Test
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Definition base_bitset_type.hpp:141
IntervalTimer
An interval timer will fire every interval, and will continue to fire until it is deleted.
Definition timer.h:76
LinkGraphSchedule::instance
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
Definition linkgraphschedule.h:52
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
OverflowSafeInt< int64_t >
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
TimerGameCalendar::ConvertDateToYMD
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
Definition timer_game_calendar.cpp:42
TimerGameCalendar::SetDate
static void SetDate(Date date, DateFract fract)
Set the date.
Definition timer_game_calendar.cpp:66
TimerGameCalendar::date
static Date date
Current date in days (day counter).
Definition timer_game_calendar.h:33
TimerGameCalendar::year
static Year year
Current year, starting at 0.
Definition timer_game_calendar.h:31
TimerGameCalendar::date_fract
static DateFract date_fract
Fractional part of the day.
Definition timer_game_calendar.h:34
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
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
TimerGameEconomy::date
static Date date
Current date in days (day counter).
Definition timer_game_economy.h:38
TimerGameEconomy::UsingWallclockUnits
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
Definition timer_game_economy.cpp:98
TimerGameEconomy::date_fract
static DateFract date_fract
Fractional part of the day.
Definition timer_game_economy.h:39
TimerGameEconomy::SetDate
static void SetDate(Date date, DateFract fract)
Set the date.
Definition timer_game_economy.cpp:82
WidgetDimensions::framerect
RectPadding framerect
Standard padding inside many panels.
Definition window_gui.h:40
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition window_gui.h:30
WidgetDimensions::hsep_wide
int hsep_wide
Wide horizontal spacing.
Definition window_gui.h:62
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:93
WidgetDimensions::hsep_indent
int hsep_indent
Width of indentation for tree layouts.
Definition window_gui.h:63
command_func.h
Functions related to commands.
company_base.h
Definition of stuff that is very close to a company, like the company struct itself.
DrawCompanyIcon
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
Definition company_cmd.cpp:175
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition company_cmd.cpp:55
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:119
company_func.h
Functions related to companies.
company_gui.h
GUI Functions related to companies.
currency.h
Functions to handle different currencies.
GetCurrency
const CurrencySpec & GetCurrency()
Get the currently selected currency.
Definition currency.h:119
error.h
Functions related to errors.
WL_ERROR
@ WL_ERROR
Errors (eg. saving/loading failed)
Definition error.h:26
ShowErrorMessage
void ShowErrorMessage(EncodedString &&summary_msg, int x, int y, CommandCost &cc)
Display an error message in a window.
Definition error_gui.cpp:296
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition fontcache.cpp:87
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition gfx.cpp:968
GetStringBoundingBox
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition gfx.cpp:897
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:668
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition gfx.cpp:42
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition gfx_type.h:249
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition widget_type.h:1335
SetStringTip
constexpr NWidgetPart SetStringTip(StringID string, StringID tip={})
Widget part function for setting the string and tooltip.
Definition widget_type.h:1243
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition widget_type.h:1232
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=INVALID_WIDGET)
Widget part function for starting a new 'real' widget.
Definition widget_type.h:1427
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition window.cpp:968
linkgraphschedule.h
Declaration of link graph schedule used for cargo distribution.
map_func.h
Functions related to maps.
IsInsideMM
constexpr bool IsInsideMM(const size_t x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
Definition math_func.hpp:267
Clamp
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition math_func.hpp:79
misc_cmd.h
Miscellaneous command definitions.
GuiShowTooltips
void GuiShowTooltips(Window *parent, EncodedString &&text, TooltipCloseCondition close_tooltip)
Shows a tooltip.
Definition misc_gui.cpp:693
ShowQueryString
void ShowQueryString(std::string_view 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:1064
newgrf.h
Base for the NewGRF implementation.
ReloadNewGRFData
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
Definition afterload.cpp:3445
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:1990
rail_gui.h
Functions/types etc.
safeguards.h
A number of safeguards to prevent using unsafe methods.
WriteValue
void WriteValue(void *ptr, VarType conv, int64_t val)
Write the value of a setting.
Definition saveload.cpp:836
ReadValue
int64_t ReadValue(const void *ptr, VarType conv)
Return a signed-long version of the value of a setting.
Definition saveload.cpp:812
saveload.h
Functions/types related to saving and loading games.
GetFilteredSettingCollection
std::vector< const SettingDesc * > GetFilteredSettingCollection(std::function< bool(const SettingDesc &desc)> func)
Get a collection of settings matching a custom filter.
Definition settings.cpp:1745
SetSettingValue
bool SetSettingValue(const IntSettingDesc *sd, int32_t value, bool force_newgame)
Top function to save the new value of an element of the Settings struct.
Definition settings.cpp:1818
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:61
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:1866
DrawBoolButton
void DrawBoolButton(int x, int y, Colours button_colour, Colours background, bool state, bool clickable)
Draw a toggle button.
Definition settings_gui.cpp:1947
DrawDropDownButton
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
Draw a dropdown button.
Definition settings_gui.cpp:1924
settings_gui.h
Functions for setting GUIs.
SETTING_BUTTON_WIDTH
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
Definition settings_gui.h:17
SETTING_BUTTON_HEIGHT
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
Definition settings_gui.h:19
settings_internal.h
Functions and types used internally for the settings configurations.
SettingFlag::GuiCurrency
@ GuiCurrency
The number represents money, so when reading value multiply by exchange rate.
SettingFlag::Sandbox
@ Sandbox
This setting is a sandbox setting.
SettingFlag::GuiZeroIsSpecial
@ GuiZeroIsSpecial
A value of zero is possible and has a custom string (the one after "strval").
SettingFlag::GuiDropdown
@ GuiDropdown
The value represents a limited number of string-options (internally integer) presented as dropdown.
settings_type.h
Types related to global configuration settings.
GetGameSettings
GameSettings & GetGameSettings()
Get the settings-object applicable for the current situation: the newgame settings when we're in the ...
Definition settings_type.h:674
sprites.h
This file contains all sprite-related enums and defines.
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
lengthof
#define lengthof(array)
Return the length of an fixed size array.
Definition stdafx.h:271
string_consumer.hpp
Parse strings.
string_func.h
Functions related to low-level strings.
CharSetFilter
CharSetFilter
Valid filter types for IsValidChar.
Definition string_type.h:24
CS_NUMERAL
@ CS_NUMERAL
Only numeric ones.
Definition string_type.h:26
CS_NUMERAL_SIGNED
@ CS_NUMERAL_SIGNED
Only numbers and '-' for negative values.
Definition string_type.h:28
GetEncodedString
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
Definition strings.cpp:90
GetString
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:424
_current_text_dir
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition strings.cpp:56
strings_func.h
Functions related to OTTD's strings.
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition strings_type.h:19
TD_RTL
@ TD_RTL
Text is written right-to-left by default.
Definition strings_type.h:27
CheatEntry
Information of a cheat.
Definition cheat_gui.cpp:194
CheatEntry::type
VarType type
type of selector
Definition cheat_gui.cpp:195
CheatEntry::variable
void * variable
pointer to the variable
Definition cheat_gui.cpp:197
CheatEntry::str
StringID str
string with descriptive text
Definition cheat_gui.cpp:196
CheatEntry::proc
CheckButtonClick * proc
procedure
Definition cheat_gui.cpp:199
CheatEntry::been_used
bool * been_used
has this cheat been used before?
Definition cheat_gui.cpp:198
CheatWindow
GUI for the cheats.
Definition cheat_gui.cpp:237
CheatWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition cheat_gui.cpp:593
CheatWindow::icon
Dimension icon
Dimension of company icon sprite.
Definition cheat_gui.cpp:241
CheatWindow::DrawWidget
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
Definition cheat_gui.cpp:259
CheatWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition cheat_gui.cpp:254
CheatWindow::UpdateWidgetSize
void UpdateWidgetSize(WidgetID 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:370
CheatWindow::OnQueryTextFinished
void OnQueryTextFinished(std::optional< std::string > str) override
The query window opened from this window has closed.
Definition cheat_gui.cpp:600
CheatWindow::OnTooltip
bool OnTooltip(Point pt, WidgetID widget, TooltipCloseCondition close_cond) override
Event to display a custom tooltip.
Definition cheat_gui.cpp:579
CheatWindow::OnClick
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition cheat_gui.cpp:429
Cheat::value
bool value
tells if the bool cheat is active or not
Definition cheat_type.h:18
Cheat::been_used
bool been_used
has this cheat been used before?
Definition cheat_type.h:17
Cheats::crossing_tunnels
Cheat crossing_tunnels
allow tunnels that cross each other
Definition cheat_type.h:30
Cheats::no_jetcrash
Cheat no_jetcrash
no jet will crash on small airports anymore
Definition cheat_type.h:31
Cheats::change_date
Cheat change_date
changes date ingame
Definition cheat_type.h:32
Cheats::station_rating
Cheat station_rating
Fix station ratings at 100%.
Definition cheat_type.h:35
Cheats::money
Cheat money
get rich or poor
Definition cheat_type.h:29
Cheats::setup_prod
Cheat setup_prod
setup raw-material production in game
Definition cheat_type.h:33
Cheats::switch_company
Cheat switch_company
change to another company
Definition cheat_type.h:28
Cheats::magic_bulldozer
Cheat magic_bulldozer
dynamite industries, objects
Definition cheat_type.h:27
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
CommandHelper
Definition command_func.h:84
ConstructionSettings::map_height_limit
uint8_t map_height_limit
the maximum allowed heightlevel
Definition settings_type.h:410
Coord2D< int >
Coord2D::y
T y
Y coordinate.
Definition geometry_type.hpp:35
Coord2D::x
T x
X coordinate.
Definition geometry_type.hpp:34
CurrencySpec::rate
uint16_t rate
The conversion rate compared to the base currency.
Definition currency.h:78
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition geometry_type.hpp:56
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition settings_type.h:635
IntSettingDesc
Base integer type, including boolean, settings.
Definition settings_internal.h:148
IntSettingDesc::GetRange
std::tuple< int32_t, uint32_t > GetRange() const
Get the min/max range for the setting.
Definition settings.cpp:476
IntSettingDesc::GetTitle
StringID GetTitle() const
Get the title of the setting.
Definition settings.cpp:427
IntSettingDesc::max
uint32_t max
maximum values
Definition settings_internal.h:208
IntSettingDesc::min
int32_t min
minimum values
Definition settings_internal.h:207
IntSettingDesc::GetDefaultValue
int32_t GetDefaultValue() const
Get the default value of the setting.
Definition settings.cpp:467
IntSettingDesc::GetHelp
StringID GetHelp() const
Get the help text of the setting.
Definition settings.cpp:436
IntSettingDesc::IsBoolSetting
virtual bool IsBoolSetting() const
Check whether this setting is a boolean type setting.
Definition settings_internal.h:232
IntSettingDesc::GetValueParams
std::pair< StringParameter, StringParameter > GetValueParams(int32_t value) const
Get parameters for drawing the value of the setting.
Definition settings.cpp:445
IntSettingDesc::Read
int32_t Read(const void *object) const
Read the integer from the the actual setting.
Definition settings.cpp:567
IntSettingDesc::interval
int32_t interval
the interval to use between settings in the 'settings' window. If interval is '0' the interval is dyn...
Definition settings_internal.h:209
Map::Iterate
static IterateWrapper Iterate()
Returns an iterable ensemble of all Tiles.
Definition map_func.h:375
PoolID< uint8_t, struct CompanyIDTag, 0xF, 0xFF >
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:436
Pool::PoolItem<&_company_pool >::GetPoolSize
static size_t GetPoolSize()
Returns first unused index.
Definition pool_type.hpp:408
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(auto index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition pool_type.hpp:376
RectPadding::Vertical
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Definition geometry_type.hpp:95
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition geometry_type.hpp:101
Rect::WithWidth
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
Definition geometry_type.hpp:211
Rect::Width
int Width() const
Get width of Rect.
Definition geometry_type.hpp:111
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition geometry_type.hpp:124
Rect::WithHeight
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
Definition geometry_type.hpp:237
Rect::Indent
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
Definition geometry_type.hpp:224
Rect::Height
int Height() const
Get height of Rect.
Definition geometry_type.hpp:117
Rect::Translate
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
Definition geometry_type.hpp:200
SettingDesc
Properties of config file settings.
Definition settings_internal.h:71
SettingDesc::IsEditable
bool IsEditable(bool do_command=false) const
Check whether the setting is editable in the current gamemode.
Definition settings.cpp:894
SettingDesc::flags
SettingFlags flags
Handles how a setting would show up in the GUI (text/currency, etc.).
Definition settings_internal.h:76
SettingDesc::AsIntSetting
const struct IntSettingDesc * AsIntSetting() const
Get the setting description of this setting as an integer setting.
Definition settings.cpp:921
StrongType::Typedef
Templated helper to make a type-safe 'typedef' representing a single POD value.
Definition strong_typedef_type.hpp:130
WindowDesc
High level window description.
Definition window_gui.h:168
Window
Data structure for an opened window.
Definition window_gui.h:274
Window::resize
ResizeInfo resize
Resize information.
Definition window_gui.h:315
Window::SetTimeout
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Definition window_gui.h:356
Window::GetRowFromWidget
int GetRowFromWidget(int clickpos, WidgetID widget, int padding, int line_height=-1) const
Compute the row of a widget that a user clicked in.
Definition window.cpp:212
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition window.cpp:1823
Window::flags
WindowFlags flags
Window flags.
Definition window_gui.h:301
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition window_gui.h:312
textbuf_gui.h
Stuff related to the text buffer GUI.
QueryStringFlag::AcceptUnchanged
@ AcceptUnchanged
return success even when the text didn't change
QueryStringFlag::EnableDefault
@ EnableDefault
enable the 'Default' button ("\0" is returned)
tile_map.h
Map writing/reading functions for tiles.
TileHeight
static uint TileHeight(Tile tile)
Returns the height of a tile.
Definition tile_map.h:29
MIN_MAP_HEIGHT_LIMIT
static constexpr uint MIN_MAP_HEIGHT_LIMIT
Lower bound of maximum allowed heightlevel (in the construction settings)
Definition tile_type.h:29
MAX_MAP_HEIGHT_LIMIT
static constexpr uint MAX_MAP_HEIGHT_LIMIT
Upper bound of maximum allowed heightlevel (in the construction settings)
Definition tile_type.h:30
timer.h
Definition of Interval and OneShot timers.
timer_game_calendar.h
Definition of the game-calendar-timer.
timer_game_economy.h
Definition of the game-economy-timer.
vehicle_base.h
Base class for all vehicles.
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:66
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:39
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition widget_type.h:57
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition widget_type.h:55
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition widget_type.h:52
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition widget_type.h:68
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition widget_type.h:60
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition widget_type.h:37
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:1195
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition window.cpp:3179
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:3314
window_func.h
Window functions not directly related to making/drawing windows.
window_gui.h
Functions, definitions and such used only by the GUI.
WindowFlag::Timeout
@ Timeout
Window timeout counter.
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition window_gui.h:144
WidgetID
int WidgetID
Widget ID.
Definition window_type.h:20
WC_BUILD_STATION
@ WC_BUILD_STATION
Build station; Window numbers:
Definition window_type.h:408
WC_BUILD_OBJECT
@ WC_BUILD_OBJECT
Build object; Window numbers:
Definition window_type.h:381
WC_STATUS_BAR
@ WC_STATUS_BAR
Statusbar (at the bottom of your screen); Window numbers:
Definition window_type.h:69
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition window_type.h:50
WC_CHEATS
@ WC_CHEATS
Cheat window; Window numbers:
Definition window_type.h:647
WC_TRUCK_STATION
@ WC_TRUCK_STATION
Build truck station; Window numbers:
Definition window_type.h:420
WC_INDUSTRY_VIEW
@ WC_INDUSTRY_VIEW
Industry view; Window numbers:
Definition window_type.h:368
WC_FINANCES
@ WC_FINANCES
Finances of a company; Window numbers:
Definition window_type.h:532
WC_BUS_STATION
@ WC_BUS_STATION
Build bus station; Window numbers:
Definition window_type.h:414
WC_SMALLMAP
@ WC_SMALLMAP
Small map; Window numbers:
Definition window_type.h:109