OpenTTD

cheat_gui.cpp
Go to the documentation of this file.
1 /* $Id: cheat_gui.cpp 27178 2015-03-07 18:27:01Z frosch $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #include "stdafx.h"
13 #include "command_func.h"
14 #include "cheat_type.h"
15 #include "company_base.h"
16 #include "company_func.h"
17 #include "date_func.h"
18 #include "saveload/saveload.h"
19 #include "textbuf_gui.h"
20 #include "window_gui.h"
21 #include "string_func.h"
22 #include "strings_func.h"
23 #include "window_func.h"
24 #include "rail_gui.h"
25 #include "settings_gui.h"
26 #include "company_gui.h"
27 #include "linkgraph/linkgraphschedule.h"
28 #include "map_func.h"
29 #include "tile_map.h"
30 #include "newgrf.h"
31 #include "error.h"
32
33 #include "widgets/cheat_widget.h"
34
35 #include "table/sprites.h"
36
37 #include "safeguards.h"
38
39
45 static int32 _money_cheat_amount = 10000000;
46
56 static int32 ClickMoneyCheat(int32 p1, int32 p2)
57 {
58 DoCommandP(0, (uint32)(p2 * _money_cheat_amount), 0, CMD_MONEY_CHEAT);
59 return _money_cheat_amount;
60 }
61
68 static int32 ClickChangeCompanyCheat(int32 p1, int32 p2)
69 {
70 while ((uint)p1 < Company::GetPoolSize()) {
71 if (Company::IsValidID((CompanyID)p1)) {
72 SetLocalCompany((CompanyID)p1);
73 return _local_company;
74 }
75 p1 += p2;
76 }
77
78 return _local_company;
79 }
80
87 static int32 ClickSetProdCheat(int32 p1, int32 p2)
88 {
89 _cheats.setup_prod.value = (p1 != 0);
90 InvalidateWindowClassesData(WC_INDUSTRY_VIEW);
91 return _cheats.setup_prod.value;
92 }
93
94 extern void EnginesMonthlyLoop();
95
102 static int32 ClickChangeDateCheat(int32 p1, int32 p2)
103 {
104 YearMonthDay ymd;
105 ConvertDateToYMD(_date, &ymd);
106
107 p1 = Clamp(p1, MIN_YEAR, MAX_YEAR);
108 if (p1 == _cur_year) return _cur_year;
109
110 Date new_date = ConvertYMDToDate(p1, ymd.month, ymd.day);
111 LinkGraphSchedule::instance.ShiftDates(new_date - _date);
112 SetDate(new_date, _date_fract);
113 EnginesMonthlyLoop();
114 SetWindowDirty(WC_STATUS_BAR, 0);
115 InvalidateWindowClassesData(WC_BUILD_STATION, 0);
116 InvalidateWindowClassesData(WC_BUILD_OBJECT, 0);
117 ResetSignalVariant();
118 return _cur_year;
119 }
120
128 static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2)
129 {
130 p1 = Clamp(p1, MIN_MAX_HEIGHTLEVEL, MAX_MAX_HEIGHTLEVEL);
131
132 /* Check if at least one mountain on the map is higher than the new value.
133 * If yes, disallow the change. */
134 for (TileIndex t = 0; t < MapSize(); t++) {
135 if ((int32)TileHeight(t) > p1) {
136 ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR);
137 /* Return old, unchanged value */
138 return _settings_game.construction.max_heightlevel;
139 }
140 }
141
142 /* Execute the change and reload GRF Data */
143 _settings_game.construction.max_heightlevel = p1;
144 ReloadNewGRFData();
145
146 /* The smallmap uses an index from heightlevels to colours. Trigger rebuilding it. */
147 InvalidateWindowClassesData(WC_SMALLMAP, 2);
148
149 return _settings_game.construction.max_heightlevel;
150 }
151
153 enum CheatNumbers {
154 CHT_MONEY,
155 CHT_CHANGE_COMPANY,
156 CHT_EXTRA_DYNAMITE,
157 CHT_CROSSINGTUNNELS,
158 CHT_NO_JETCRASH,
159 CHT_SETUP_PROD,
160 CHT_EDIT_MAX_HL,
161 CHT_CHANGE_DATE,
162
163 CHT_NUM_CHEATS,
164 };
165
171 typedef int32 CheckButtonClick(int32 p1, int32 p2);
172
174 struct CheatEntry {
175 VarType type;
176 StringID str;
177 void *variable;
178 bool *been_used;
179 CheckButtonClick *proc;
180 };
181
186 static const CheatEntry _cheats_ui[] = {
187 {SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
188 {SLE_UINT8, STR_CHEAT_CHANGE_COMPANY, &_local_company, &_cheats.switch_company.been_used, &ClickChangeCompanyCheat },
189 {SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, NULL },
190 {SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, NULL },
191 {SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, NULL },
192 {SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, &ClickSetProdCheat },
193 {SLE_UINT8, STR_CHEAT_EDIT_MAX_HL, &_settings_game.construction.max_heightlevel, &_cheats.edit_max_hl.been_used, &ClickChangeMaxHlCheat },
194 {SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
195 };
196
197 assert_compile(CHT_NUM_CHEATS == lengthof(_cheats_ui));
198
200 static const NWidgetPart _nested_cheat_widgets[] = {
201 NWidget(NWID_HORIZONTAL),
202 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
203 NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CHEATS, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
204 NWidget(WWT_SHADEBOX, COLOUR_GREY),
205 NWidget(WWT_STICKYBOX, COLOUR_GREY),
206 EndContainer(),
207 NWidget(WWT_PANEL, COLOUR_GREY, WID_C_PANEL), SetDataTip(0x0, STR_CHEATS_TOOLTIP), EndContainer(),
208 };
209
211 struct CheatWindow : Window {
212 int clicked;
213 int header_height;
214 int clicked_widget;
215 uint line_height;
216 int box_width;
217
218 CheatWindow(WindowDesc *desc) : Window(desc)
219 {
220 this->box_width = GetSpriteSize(SPR_BOX_EMPTY).width;
221 this->InitNested();
222 }
223
224 virtual void DrawWidget(const Rect &r, int widget) const
225 {
226 if (widget != WID_C_PANEL) return;
227
228 int y = r.top + WD_FRAMERECT_TOP + this->header_height;
229 DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, r.top + WD_FRAMERECT_TOP, y, STR_CHEATS_WARNING, TC_FROMSTRING, SA_CENTER);
230
231 bool rtl = _current_text_dir == TD_RTL;
232 uint box_left = rtl ? r.right - this->box_width - 5 : r.left + 5;
233 uint button_left = rtl ? r.right - this->box_width - 10 - SETTING_BUTTON_WIDTH : r.left + this->box_width + 10;
234 uint text_left = r.left + (rtl ? WD_FRAMERECT_LEFT : 20 + this->box_width + SETTING_BUTTON_WIDTH);
235 uint text_right = r.right - (rtl ? 20 + this->box_width + SETTING_BUTTON_WIDTH : WD_FRAMERECT_RIGHT);
236
237 int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
238 int icon_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
239
240 for (int i = 0; i != lengthof(_cheats_ui); i++) {
241 const CheatEntry *ce = &_cheats_ui[i];
242
243 DrawSprite((*ce->been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, box_left, y + icon_y_offset + 2);
244
245 switch (ce->type) {
246 case SLE_BOOL: {
247 bool on = (*(bool*)ce->variable);
248
249 DrawBoolButton(button_left, y + icon_y_offset, on, true);
250 SetDParam(0, on ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
251 break;
252 }
253
254 default: {
255 int32 val = (int32)ReadValue(ce->variable, ce->type);
256 char buf[512];
257
258 /* Draw [<][>] boxes for settings of an integer-type */
259 DrawArrowButtons(button_left, y + icon_y_offset, COLOUR_YELLOW, clicked - (i * 2), true, true);
260
261 switch (ce->str) {
262 /* Display date for change date cheat */
263 case STR_CHEAT_CHANGE_DATE: SetDParam(0, _date); break;
264
265 /* Draw coloured flag for change company cheat */
266 case STR_CHEAT_CHANGE_COMPANY: {
267 SetDParam(0, val + 1);
268 GetString(buf, STR_CHEAT_CHANGE_COMPANY, lastof(buf));
269 uint offset = 10 + GetStringBoundingBox(buf).width;
270 DrawCompanyIcon(_local_company, rtl ? text_right - offset - 10 : text_left + offset, y + icon_y_offset + 2);
271 break;
272 }
273
274 default: SetDParam(0, val);
275 }
276 break;
277 }
278 }
279
280 DrawString(text_left, text_right, y + text_y_offset, ce->str);
281
282 y += this->line_height;
283 }
284 }
285
286 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
287 {
288 if (widget != WID_C_PANEL) return;
289
290 uint width = 0;
291 for (int i = 0; i != lengthof(_cheats_ui); i++) {
292 const CheatEntry *ce = &_cheats_ui[i];
293 switch (ce->type) {
294 case SLE_BOOL:
295 SetDParam(0, STR_CONFIG_SETTING_ON);
296 width = max(width, GetStringBoundingBox(ce->str).width);
297 SetDParam(0, STR_CONFIG_SETTING_OFF);
298 width = max(width, GetStringBoundingBox(ce->str).width);
299 break;
300
301 default:
302 switch (ce->str) {
303 /* Display date for change date cheat */
304 case STR_CHEAT_CHANGE_DATE:
305 SetDParam(0, ConvertYMDToDate(MAX_YEAR, 11, 31));
306 width = max(width, GetStringBoundingBox(ce->str).width);
307 break;
308
309 /* Draw coloured flag for change company cheat */
310 case STR_CHEAT_CHANGE_COMPANY:
311 SetDParamMaxValue(0, MAX_COMPANIES);
312 width = max(width, GetStringBoundingBox(ce->str).width + 10 + 10);
313 break;
314
315 default:
316 SetDParam(0, INT64_MAX);
317 width = max(width, GetStringBoundingBox(ce->str).width);
318 break;
319 }
320 break;
321 }
322 }
323
324 this->line_height = max(GetSpriteSize(SPR_BOX_CHECKED).height, GetSpriteSize(SPR_BOX_EMPTY).height);
325 this->line_height = max<uint>(this->line_height, SETTING_BUTTON_HEIGHT);
326 this->line_height = max<uint>(this->line_height, FONT_HEIGHT_NORMAL) + WD_PAR_VSEP_NORMAL;
327
328 size->width = width + 20 + this->box_width + SETTING_BUTTON_WIDTH /* stuff on the left */ + 10 /* extra spacing on right */;
329 this->header_height = GetStringHeight(STR_CHEATS_WARNING, size->width - WD_FRAMERECT_LEFT - WD_FRAMERECT_RIGHT) + WD_PAR_VSEP_WIDE;
330 size->height = this->header_height + WD_FRAMERECT_TOP + WD_PAR_VSEP_NORMAL + WD_FRAMERECT_BOTTOM + this->line_height * lengthof(_cheats_ui);
331 }
332
333 virtual void OnClick(Point pt, int widget, int click_count)
334 {
335 const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_C_PANEL);
336 uint btn = (pt.y - wid->pos_y - WD_FRAMERECT_TOP - this->header_height) / this->line_height;
337 int x = pt.x - wid->pos_x;
338 bool rtl = _current_text_dir == TD_RTL;
339 if (rtl) x = wid->current_x - x;
340
341 if (btn >= lengthof(_cheats_ui)) return;
342
343 const CheatEntry *ce = &_cheats_ui[btn];
344 int value = (int32)ReadValue(ce->variable, ce->type);
345 int oldvalue = value;
346
347 if (btn == CHT_CHANGE_DATE && x >= 20 + this->box_width + SETTING_BUTTON_WIDTH) {
348 /* Click at the date text directly. */
349 clicked_widget = CHT_CHANGE_DATE;
350 SetDParam(0, value);
351 ShowQueryString(STR_JUST_INT, STR_CHEAT_CHANGE_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
352 return;
353 } else if (btn == CHT_EDIT_MAX_HL && x >= 20 + this->box_width + SETTING_BUTTON_WIDTH) {
354 clicked_widget = CHT_EDIT_MAX_HL;
355 SetDParam(0, value);
356 ShowQueryString(STR_JUST_INT, STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
357 return;
358 }
359
360 /* Not clicking a button? */
361 if (!IsInsideMM(x, 10 + this->box_width, 10 + this->box_width + SETTING_BUTTON_WIDTH)) return;
362
363 *ce->been_used = true;
364
365 switch (ce->type) {
366 case SLE_BOOL:
367 value ^= 1;
368 if (ce->proc != NULL) ce->proc(value, 0);
369 break;
370
371 default:
372 /* Take whatever the function returns */
373 value = ce->proc(value + ((x >= 20 + SETTING_BUTTON_WIDTH / 2) ? 1 : -1), (x >= 10 + this->box_width + SETTING_BUTTON_WIDTH / 2) ? 1 : -1);
374
375 /* The first cheat (money), doesn't return a different value. */
376 if (value != oldvalue || btn == CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= 10 + this->box_width + SETTING_BUTTON_WIDTH / 2) != rtl ? 1 : 0);
377 break;
378 }
379
380 if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
381
382 this->SetTimeout();
383
384 this->SetDirty();
385 }
386
387 virtual void OnTimeout()
388 {
389 this->clicked = 0;
390 this->SetDirty();
391 }
392
393 virtual void OnQueryTextFinished(char *str)
394 {
395 /* Was 'cancel' pressed or nothing entered? */
396 if (str == NULL || StrEmpty(str)) return;
397
398 const CheatEntry *ce = &_cheats_ui[clicked_widget];
399 int oldvalue = (int32)ReadValue(ce->variable, ce->type);
400 int value = atoi(str);
401 *ce->been_used = true;
402 value = ce->proc(value, value - oldvalue);
403
404 if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
405 this->SetDirty();
406 }
407 };
408
410 static WindowDesc _cheats_desc(
411 WDP_AUTO, "cheats", 0, 0,
412 WC_CHEATS, WC_NONE,
413 0,
414 _nested_cheat_widgets, lengthof(_nested_cheat_widgets)
415 );
416
418 void ShowCheatWindow()
419 {
420 DeleteWindowById(WC_CHEATS, 0);
421 new CheatWindow(&_cheats_desc);
422 }
strings_func.h
Functions related to OTTD&#39;s strings.
ConstructionSettings::max_heightlevel
uint8 max_heightlevel
maximum allowed heightlevel
Definition: settings_type.h:300
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:77
company_base.h
Definition of stuff that is very close to a company, like the company struct itself.
Cheats::switch_company
Cheat switch_company
change to another company
Definition: cheat_type.h:30
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3120
ClickChangeCompanyCheat
static int32 ClickChangeCompanyCheat(int32 p1, int32 p2)
Handle changing of company.
Definition: cheat_gui.cpp:68
WindowDesc
High level window description.
Definition: window_gui.h:168
MAX_MAX_HEIGHTLEVEL
static const uint MAX_MAX_HEIGHTLEVEL
Upper bound of maximum allowed heightlevel (in the construction settings)
Definition: tile_type.h:28
ShowCheatWindow
void ShowCheatWindow()
Open cheat window.
Definition: cheat_gui.cpp:418
date_func.h
Functions related to dates.
IsInsideMM
static bool IsInsideMM(const T x, const uint min, const uint max)
Checks if a value is in an interval.
Definition: math_func.hpp:266
YearMonthDay::day
Day day
Day (1..31)
Definition: date_type.h:106
WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:64
CHT_SETUP_PROD
Allow manually editing of industry production.
Definition: cheat_gui.cpp:159
WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
Definition: window_gui.h:139
NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:75
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:1066
CHT_EDIT_MAX_HL
Edit maximum allowed heightlevel.
Definition: cheat_gui.cpp:160
DrawCompanyIcon
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
Definition: company_cmd.cpp:141
CheatNumbers
CheatNumbers
Available cheats.
Definition: cheat_gui.cpp:153
ReadValue
int64 ReadValue(const void *ptr, VarType conv)
Return a signed-long version of the value of a setting.
Definition: saveload.cpp:946
GetStringHeight
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition: gfx.cpp:547
WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:69
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: depend.cpp:50
QSF_ACCEPT_UNCHANGED
return success even when the text didn&#39;t change
Definition: textbuf_gui.h:22
Cheat::been_used
bool been_used
has this cheat been used before?
Definition: cheat_type.h:19
textbuf_gui.h
Stuff related to the text buffer GUI.
CheatEntry::been_used
bool * been_used
has this cheat been used before?
Definition: cheat_gui.cpp:178
max
static T max(const T a, const T b)
Returns the maximum of two values.
Definition: math_func.hpp:26
_cur_year
Year _cur_year
Current year, starting at 0.
Definition: date.cpp:26
Cheats::money
Cheat money
get rich or poor
Definition: cheat_type.h:31
CheatWindow
GUI for the cheats.
Definition: cheat_gui.cpp:211
CHT_CROSSINGTUNNELS
Allow tunnels to cross each other.
Definition: cheat_gui.cpp:157
map_func.h
Functions related to maps.
WD_PAR_VSEP_WIDE
Large amount of vertical space between two paragraphs of text.
Definition: window_gui.h:140
CheatWindow::UpdateWidgetSize
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
Definition: cheat_gui.cpp:286
rail_gui.h
Functions/types etc.
window_gui.h
Functions, definitions and such used only by the GUI.
CheatEntry
Information of a cheat.
Definition: cheat_gui.cpp:174
_local_company
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
Cheats::no_jetcrash
Cheat no_jetcrash
no jet will crash on small airports anymore
Definition: cheat_type.h:34
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:910
LinkGraphSchedule::ShiftDates
void ShiftDates(int interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
Definition: linkgraphschedule.cpp:111
Window
Data structure for an opened window.
Definition: window_gui.h:271
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:3238
ShowErrorMessage
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=NULL, uint textref_stack_size=0, const uint32 *textref_stack=NULL)
Display an error message in a window.
Definition: error_gui.cpp:378
SetDate
void SetDate(Date date, DateFract fract)
Set the date.
Definition: date.cpp:37
string_func.h
Functions related to low-level strings.
CS_NUMERAL
Only numeric ones.
Definition: string_type.h:28
saveload.h
Functions/types related to saving and loading games.
cheat_type.h
Types related to cheating.
error.h
Functions related to errors.
CHT_NO_JETCRASH
Disable jet-airplane crashes.
Definition: cheat_gui.cpp:158
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:39
_date_fract
DateFract _date_fract
Fractional part of the day.
Definition: date.cpp:29
NWidgetBase::pos_y
uint pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:178
Pool::PoolItem<&_company_pool >::GetPoolSize
static size_t GetPoolSize()
Returns first unused index.
Definition: pool_type.hpp:267
_cheats_ui
static const CheatEntry _cheats_ui[]
The available cheats.
Definition: cheat_gui.cpp:186
CHT_NUM_CHEATS
Number of cheats.
Definition: cheat_gui.cpp:163
LinkGraphSchedule::instance
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
Definition: linkgraphschedule.h:54
WC_SMALLMAP
Small map; Window numbers:
Definition: window_type.h:99
Cheats::change_date
Cheat change_date
changes date ingame
Definition: cheat_type.h:36
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:180
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
ClickMoneyCheat
static int32 ClickMoneyCheat(int32 p1, int32 p2)
Handle cheating of money.
Definition: cheat_gui.cpp:56
SA_CENTER
Center both horizontally and vertically.
Definition: gfx_func.h:108
CheatEntry::proc
CheckButtonClick * proc
procedure
Definition: cheat_gui.cpp:179
YearMonthDay
Data structure to convert between Date and triplet (year, month, and day).
Definition: date_type.h:103
CHT_CHANGE_COMPANY
Switch company.
Definition: cheat_gui.cpp:155
safeguards.h
A number of safeguards to prevent using unsafe methods.
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:102
Cheat::value
bool value
tells if the bool cheat is active or not
Definition: cheat_type.h:20
linkgraphschedule.h
Declaration of link graph schedule used for cargo distribution.
ResetSignalVariant
bool ResetSignalVariant(int32 p)
Updates the current signal variant used in the signal GUI to the one adequate to current year...
Definition: rail_gui.cpp:1953
WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:50
Cheats::setup_prod
Cheat setup_prod
setup raw-material production in game
Definition: cheat_type.h:37
cheat_widget.h
Types related to the cheat widgets.
_money_cheat_amount
static int32 _money_cheat_amount
The &#39;amount&#39; to cheat with.
Definition: cheat_gui.cpp:45
company_gui.h
GUI Functions related to companies.
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:65
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:126
ClickSetProdCheat
static int32 ClickSetProdCheat(int32 p1, int32 p2)
Allow (or disallow) changing production of all industries.
Definition: cheat_gui.cpp:87
DrawString
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:499
WC_BUILD_STATION
Build station; Window numbers:
Definition: window_type.h:392
DoCommandP
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Definition: command.cpp:527
WC_INDUSTRY_VIEW
Industry view; Window numbers:
Definition: window_type.h:358
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: depend.cpp:42
NWidgetBase::pos_x
uint pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:177
CMD_MONEY_CHEAT
do the money cheat
Definition: command_type.h:274
DrawArrowButtons
void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
Draw [<][>] boxes.
Definition: settings_gui.cpp:2391
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
YearMonthDay::month
Month month
Month (0..11)
Definition: date_type.h:105
CheatWindow::OnQueryTextFinished
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
Definition: cheat_gui.cpp:393
SETTING_BUTTON_WIDTH
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
Definition: settings_gui.h:18
WC_BUILD_OBJECT
Build object; Window numbers:
Definition: window_type.h:371
_nested_cheat_widgets
static const NWidgetPart _nested_cheat_widgets[]
Widget definitions of the cheat GUI.
Definition: cheat_gui.cpp:200
MAX_COMPANIES
Maximum number of companies.
Definition: company_type.h:25
WID_C_PANEL
Panel where all cheats are shown in.
Definition: cheat_widget.h:17
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:139
CHT_CHANGE_DATE
Do time traveling.
Definition: cheat_gui.cpp:161
CheatEntry::variable
void * variable
pointer to the variable
Definition: cheat_gui.cpp:177
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:699
ClickChangeMaxHlCheat
static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2)
Allow (or disallow) a change of the maximum allowed heightlevel.
Definition: cheat_gui.cpp:128
WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:40
DeleteWindowById
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1137
_cheats_desc
static WindowDesc _cheats_desc(WDP_AUTO, "cheats", 0, 0, WC_CHEATS, WC_NONE, 0, _nested_cheat_widgets, lengthof(_nested_cheat_widgets))
Window description of the cheats GUI.
CheatWindow::OnTimeout
virtual void OnTimeout()
Called when this window&#39;s timeout has been reached.
Definition: cheat_gui.cpp:387
company_func.h
Functions related to companies.
MapSize
static uint MapSize()
Get the size of the map.
Definition: map_func.h:94
MIN_MAX_HEIGHTLEVEL
static const uint MIN_MAX_HEIGHTLEVEL
Lower bound of maximum allowed heightlevel (in the construction settings)
Definition: tile_type.h:26
WC_CHEATS
Cheat window; Window numbers:
Definition: window_type.h:620
WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:59
CHT_EXTRA_DYNAMITE
Dynamite anything.
Definition: cheat_gui.cpp:156
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
Cheats::crossing_tunnels
Cheat crossing_tunnels
allow tunnels that cross each other
Definition: cheat_type.h:32
_current_text_dir
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:52
SetDParamMaxValue
void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
Definition: strings.cpp:105
CheckButtonClick
int32 CheckButtonClick(int32 p1, int32 p2)
Signature of handler function when user clicks at a cheat.
Definition: cheat_gui.cpp:171
CheatEntry::str
StringID str
string with descriptive text
Definition: cheat_gui.cpp:176
Cheats::magic_bulldozer
Cheat magic_bulldozer
dynamite industries, objects
Definition: cheat_type.h:29
settings_gui.h
Functions for setting GUIs.
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:174
WC_STATUS_BAR
Statusbar (at the bottom of your screen); Window numbers:
Definition: window_type.h:59
command_func.h
Functions related to commands.
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:28
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:768
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
Definition: pool_type.hpp:235
TileHeight
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
Definition: tile_map.h:31
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition: settings_type.h:545
MIN_YEAR
static const Year MIN_YEAR
The absolute minimum & maximum years in OTTD.
Definition: date_type.h:85
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:19
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:16
WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:63
WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:66
DrawBoolButton
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
Definition: settings_gui.cpp:2438
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:40
EnginesMonthlyLoop
void EnginesMonthlyLoop()
Monthly update of the availability, reliability, and preview offers of the engines.
Definition: engine.cpp:967
TD_RTL
Text is written right-to-left by default.
Definition: strings_type.h:26
ConvertYMDToDate
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: date.cpp:149
tile_map.h
Map writing/reading functions for tiles.
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:20
window_func.h
Window functions not directly related to making/drawing windows.
ReloadNewGRFData
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
Definition: afterload.cpp:3004
WDP_AUTO
Find a place automatically.
Definition: window_gui.h:156
CHT_MONEY
Change amount of money.
Definition: cheat_gui.cpp:154
SETTING_BUTTON_HEIGHT
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
Definition: settings_gui.h:20
WL_ERROR
Errors (eg. saving/loading failed)
Definition: error.h:25
_date
Date _date
Current date in days (day counter)
Definition: date.cpp:28
ConvertDateToYMD
void ConvertDateToYMD(Date date, YearMonthDay *ymd)
Converts a Date to a Year, Month & Day.
Definition: date.cpp:94
ClickChangeDateCheat
static int32 ClickChangeDateCheat(int32 p1, int32 p2)
Handle changing of the current year.
Definition: cheat_gui.cpp:102
CheatWindow::DrawWidget
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Definition: cheat_gui.cpp:224
WriteValue
void WriteValue(void *ptr, VarType conv, int64 val)
Write the value of a setting.
Definition: saveload.cpp:970
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:34
WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:62
MAX_YEAR
static const Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date...
Definition: date_type.h:94
sprites.h
This file contains all sprite-related enums and defines.
WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:64
CheatEntry::type
VarType type
type of selector
Definition: cheat_gui.cpp:175
DrawSprite
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:833
DrawStringMultiLine
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition: gfx.cpp:620
_cheats
Cheats _cheats
All the cheats.
Definition: cheat.cpp:18
CheatWindow::OnClick
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Definition: cheat_gui.cpp:333
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:201
newgrf.h
Base for the NewGRF implementation.