OpenTTD Source  12.0-beta2
newgrf_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 "error.h"
12 #include "settings_gui.h"
13 #include "newgrf.h"
14 #include "strings_func.h"
15 #include "window_func.h"
16 #include "gamelog.h"
17 #include "settings_type.h"
18 #include "settings_func.h"
19 #include "widgets/dropdown_type.h"
20 #include "widgets/dropdown_func.h"
21 #include "network/network.h"
23 #include "sortlist_type.h"
24 #include "stringfilter_type.h"
25 #include "querystring_gui.h"
26 #include "core/geometry_func.hpp"
27 #include "newgrf_text.h"
28 #include "textfile_gui.h"
29 #include "tilehighlight_func.h"
30 #include "fios.h"
31 #include "guitimer_func.h"
32 
33 #include "widgets/newgrf_widget.h"
34 #include "widgets/misc_widget.h"
35 
36 #include "table/sprites.h"
37 
38 #include <map>
39 #include "safeguards.h"
40 
45 {
46  /* Do not show errors when entering the main screen */
47  if (_game_mode == GM_MENU) return;
48 
49  for (const GRFConfig *c = _grfconfig; c != nullptr; c = c->next) {
50  /* Only show Fatal and Error level messages */
51  if (c->error == nullptr || (c->error->severity != STR_NEWGRF_ERROR_MSG_FATAL && c->error->severity != STR_NEWGRF_ERROR_MSG_ERROR)) continue;
52 
53  SetDParam (0, c->error->message != STR_NULL ? c->error->message : STR_JUST_RAW_STRING);
54  SetDParamStr(1, c->error->custom_message);
55  SetDParamStr(2, c->filename);
56  SetDParamStr(3, c->error->data);
57  for (uint i = 0; i < lengthof(c->error->param_value); i++) {
58  SetDParam(4 + i, c->error->param_value[i]);
59  }
60  if (c->error->severity == STR_NEWGRF_ERROR_MSG_FATAL) {
61  ShowErrorMessage(STR_NEWGRF_ERROR_FATAL_POPUP, INVALID_STRING_ID, WL_CRITICAL);
62  } else {
63  ShowErrorMessage(STR_NEWGRF_ERROR_POPUP, INVALID_STRING_ID, WL_ERROR);
64  }
65  break;
66  }
67 }
68 
69 static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint right, uint bottom, bool show_params)
70 {
71  if (c->error != nullptr) {
72  char message[512];
73  SetDParamStr(0, c->error->custom_message); // is skipped by built-in messages
74  SetDParamStr(1, c->filename);
75  SetDParamStr(2, c->error->data);
76  for (uint i = 0; i < lengthof(c->error->param_value); i++) {
77  SetDParam(3 + i, c->error->param_value[i]);
78  }
79  GetString(message, c->error->message != STR_NULL ? c->error->message : STR_JUST_RAW_STRING, lastof(message));
80 
81  SetDParamStr(0, message);
82  y = DrawStringMultiLine(x, right, y, bottom, c->error->severity);
83  }
84 
85  /* Draw filename or not if it is not known (GRF sent over internet) */
86  if (c->filename != nullptr) {
87  SetDParamStr(0, c->filename);
88  y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_FILENAME);
89  }
90 
91  /* Prepare and draw GRF ID */
92  char buff[256];
93  seprintf(buff, lastof(buff), "%08X", BSWAP32(c->ident.grfid));
94  SetDParamStr(0, buff);
95  y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_GRF_ID);
96 
98  SetDParam(0, c->version);
99  y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_VERSION);
100  }
103  y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_MIN_VERSION);
104  }
105 
106  /* Prepare and draw MD5 sum */
107  md5sumToString(buff, lastof(buff), c->ident.md5sum);
108  SetDParamStr(0, buff);
109  y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_MD5SUM);
110 
111  /* Show GRF parameter list */
112  if (show_params) {
113  if (c->num_params > 0) {
114  GRFBuildParamList(buff, c, lastof(buff));
115  SetDParam(0, STR_JUST_RAW_STRING);
116  SetDParamStr(1, buff);
117  } else {
118  SetDParam(0, STR_NEWGRF_SETTINGS_PARAMETER_NONE);
119  }
120  y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_PARAMETER);
121 
122  /* Draw the palette of the NewGRF */
123  if (c->palette & GRFP_BLT_32BPP) {
124  SetDParam(0, (c->palette & GRFP_USE_WINDOWS) ? STR_NEWGRF_SETTINGS_PALETTE_LEGACY_32BPP : STR_NEWGRF_SETTINGS_PALETTE_DEFAULT_32BPP);
125  } else {
126  SetDParam(0, (c->palette & GRFP_USE_WINDOWS) ? STR_NEWGRF_SETTINGS_PALETTE_LEGACY : STR_NEWGRF_SETTINGS_PALETTE_DEFAULT);
127  }
128  y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_PALETTE);
129  }
130 
131  /* Show flags */
132  if (c->status == GCS_NOT_FOUND) y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_NOT_FOUND);
133  if (c->status == GCS_DISABLED) y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_DISABLED);
134  if (HasBit(c->flags, GCF_INVALID)) y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_INCOMPATIBLE);
135  if (HasBit(c->flags, GCF_COMPATIBLE)) y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_COMPATIBLE_LOADED);
136 
137  /* Draw GRF info if it exists */
138  if (!StrEmpty(c->GetDescription())) {
139  SetDParamStr(0, c->GetDescription());
140  y = DrawStringMultiLine(x, right, y, bottom, STR_BLACK_RAW_STRING);
141  } else {
142  y = DrawStringMultiLine(x, right, y, bottom, STR_NEWGRF_SETTINGS_NO_INFO);
143  }
144 }
145 
157  uint clicked_row;
159  Scrollbar *vscroll;
161  bool editable;
162 
163  NewGRFParametersWindow(WindowDesc *desc, GRFConfig *c, bool editable) : Window(desc),
164  grf_config(c),
165  clicked_button(UINT_MAX),
166  clicked_dropdown(false),
167  closing_dropdown(false),
168  clicked_row(UINT_MAX),
170  {
171  this->action14present = (c->num_valid_params != lengthof(c->param) || c->param_info.size() != 0);
172 
173  this->CreateNestedTree();
174  this->vscroll = this->GetScrollbar(WID_NP_SCROLLBAR);
175  this->GetWidget<NWidgetStacked>(WID_NP_SHOW_NUMPAR)->SetDisplayedPlane(this->action14present ? SZSP_HORIZONTAL : 0);
176  this->GetWidget<NWidgetStacked>(WID_NP_SHOW_DESCRIPTION)->SetDisplayedPlane(this->action14present ? 0 : SZSP_HORIZONTAL);
177  this->FinishInitNested(); // Initializes 'this->line_height' as side effect.
178 
179  this->SetWidgetDisabledState(WID_NP_RESET, !this->editable);
180 
181  this->InvalidateData();
182  }
183 
190  {
192  return &dummy_parameter_info;
193  }
194 
195  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
196  {
197  switch (widget) {
198  case WID_NP_NUMPAR_DEC:
199  case WID_NP_NUMPAR_INC: {
200  size->width = std::max(SETTING_BUTTON_WIDTH / 2, FONT_HEIGHT_NORMAL);
201  size->height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL);
202  break;
203  }
204 
205  case WID_NP_NUMPAR: {
206  SetDParamMaxValue(0, lengthof(this->grf_config->param));
207  Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
208  d.width += padding.width;
209  d.height += padding.height;
210  *size = maxdim(*size, d);
211  break;
212  }
213 
214  case WID_NP_BACKGROUND:
215  this->line_height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
216 
217  resize->width = 1;
218  resize->height = this->line_height;
219  size->height = 5 * this->line_height;
220  break;
221 
222  case WID_NP_DESCRIPTION:
223  /* Minimum size of 4 lines. The 500 is the default size of the window. */
225  for (uint i = 0; i < this->grf_config->param_info.size(); i++) {
226  const GRFParameterInfo *par_info = this->grf_config->param_info[i];
227  if (par_info == nullptr) continue;
228  const char *desc = GetGRFStringFromGRFText(par_info->desc);
229  if (desc == nullptr) continue;
230  Dimension d = GetStringMultiLineBoundingBox(desc, suggestion);
232  suggestion = maxdim(d, suggestion);
233  }
234  size->height = suggestion.height;
235  break;
236  }
237  }
238 
239  void SetStringParameters(int widget) const override
240  {
241  switch (widget) {
242  case WID_NP_NUMPAR:
243  SetDParam(0, this->vscroll->GetCount());
244  break;
245  }
246  }
247 
248  void DrawWidget(const Rect &r, int widget) const override
249  {
250  if (widget == WID_NP_DESCRIPTION) {
251  const GRFParameterInfo *par_info = (this->clicked_row < this->grf_config->param_info.size()) ? this->grf_config->param_info[this->clicked_row] : nullptr;
252  if (par_info == nullptr) return;
253  const char *desc = GetGRFStringFromGRFText(par_info->desc);
254  if (desc == nullptr) return;
255  DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_TEXTPANEL_TOP, r.bottom - WD_TEXTPANEL_BOTTOM, desc, TC_BLACK);
256  return;
257  } else if (widget != WID_NP_BACKGROUND) {
258  return;
259  }
260 
261  bool rtl = _current_text_dir == TD_RTL;
262  uint buttons_left = rtl ? r.right - SETTING_BUTTON_WIDTH - 3 : r.left + 4;
263  uint text_left = r.left + (rtl ? WD_FRAMERECT_LEFT : SETTING_BUTTON_WIDTH + 8);
264  uint text_right = r.right - (rtl ? SETTING_BUTTON_WIDTH + 8 : WD_FRAMERECT_RIGHT);
265 
266  int y = r.top;
267  int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
268  int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
269  for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) {
270  GRFParameterInfo *par_info = (i < this->grf_config->param_info.size()) ? this->grf_config->param_info[i] : nullptr;
271  if (par_info == nullptr) par_info = GetDummyParameterInfo(i);
272  uint32 current_value = par_info->GetValue(this->grf_config);
273  bool selected = (i == this->clicked_row);
274 
275  if (par_info->type == PTYPE_BOOL) {
276  DrawBoolButton(buttons_left, y + button_y_offset, current_value != 0, this->editable);
277  SetDParam(2, par_info->GetValue(this->grf_config) == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
278  } else if (par_info->type == PTYPE_UINT_ENUM) {
279  if (par_info->complete_labels) {
280  DrawDropDownButton(buttons_left, y + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && this->clicked_dropdown, this->editable);
281  } else {
282  DrawArrowButtons(buttons_left, y + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, this->editable && current_value > par_info->min_value, this->editable && current_value < par_info->max_value);
283  }
284  SetDParam(2, STR_JUST_INT);
285  SetDParam(3, current_value);
286  if (par_info->value_names.Contains(current_value)) {
287  const char *label = GetGRFStringFromGRFText(par_info->value_names.Find(current_value)->second);
288  if (label != nullptr) {
289  SetDParam(2, STR_JUST_RAW_STRING);
290  SetDParamStr(3, label);
291  }
292  }
293  }
294 
295  const char *name = GetGRFStringFromGRFText(par_info->name);
296  if (name != nullptr) {
297  SetDParam(0, STR_JUST_RAW_STRING);
298  SetDParamStr(1, name);
299  } else {
300  SetDParam(0, STR_NEWGRF_PARAMETERS_DEFAULT_NAME);
301  SetDParam(1, i + 1);
302  }
303 
304  DrawString(text_left, text_right, y + text_y_offset, STR_NEWGRF_PARAMETERS_SETTING, selected ? TC_WHITE : TC_LIGHT_BLUE);
305  y += this->line_height;
306  }
307  }
308 
309  void OnPaint() override
310  {
311  if (this->closing_dropdown) {
312  this->closing_dropdown = false;
313  this->clicked_dropdown = false;
314  }
315  this->DrawWidgets();
316  }
317 
318  void OnClick(Point pt, int widget, int click_count) override
319  {
320  switch (widget) {
321  case WID_NP_NUMPAR_DEC:
322  if (this->editable && !this->action14present && this->grf_config->num_params > 0) {
323  this->grf_config->num_params--;
324  this->InvalidateData();
326  }
327  break;
328 
329  case WID_NP_NUMPAR_INC: {
330  GRFConfig *c = this->grf_config;
331  if (this->editable && !this->action14present && c->num_params < c->num_valid_params) {
332  c->param[c->num_params++] = 0;
333  this->InvalidateData();
335  }
336  break;
337  }
338 
339  case WID_NP_BACKGROUND: {
340  if (!this->editable) break;
341  uint num = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NP_BACKGROUND);
342  if (num >= this->vscroll->GetCount()) break;
343  if (this->clicked_row != num) {
345  HideDropDownMenu(this);
346  this->clicked_row = num;
347  this->clicked_dropdown = false;
348  }
349 
350  const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_NP_BACKGROUND);
351  int x = pt.x - wid->pos_x;
352  if (_current_text_dir == TD_RTL) x = wid->current_x - 1 - x;
353  x -= 4;
354 
355  GRFParameterInfo *par_info = (num < this->grf_config->param_info.size()) ? this->grf_config->param_info[num] : nullptr;
356  if (par_info == nullptr) par_info = GetDummyParameterInfo(num);
357 
358  /* One of the arrows is clicked */
359  uint32 old_val = par_info->GetValue(this->grf_config);
360  if (par_info->type != PTYPE_BOOL && IsInsideMM(x, 0, SETTING_BUTTON_WIDTH) && par_info->complete_labels) {
361  if (this->clicked_dropdown) {
362  /* unclick the dropdown */
363  HideDropDownMenu(this);
364  this->clicked_dropdown = false;
365  this->closing_dropdown = false;
366  } else {
367  const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_NP_BACKGROUND);
368  int rel_y = (pt.y - (int)wid->pos_y) % this->line_height;
369 
370  Rect wi_rect;
371  wi_rect.left = pt.x - (_current_text_dir == TD_RTL ? SETTING_BUTTON_WIDTH - 1 - x : x);;
372  wi_rect.right = wi_rect.left + SETTING_BUTTON_WIDTH - 1;
373  wi_rect.top = pt.y - rel_y + (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
374  wi_rect.bottom = wi_rect.top + SETTING_BUTTON_HEIGHT - 1;
375 
376  /* For dropdowns we also have to check the y position thoroughly, the mouse may not above the just opening dropdown */
377  if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
378  this->clicked_dropdown = true;
379  this->closing_dropdown = false;
380 
381  DropDownList list;
382  for (uint32 i = par_info->min_value; i <= par_info->max_value; i++) {
383  list.emplace_back(new DropDownListCharStringItem(GetGRFStringFromGRFText(par_info->value_names.Find(i)->second), i, false));
384  }
385 
386  ShowDropDownListAt(this, std::move(list), old_val, -1, wi_rect, COLOUR_ORANGE, true);
387  }
388  }
389  } else if (IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) {
390  uint32 val = old_val;
391  if (par_info->type == PTYPE_BOOL) {
392  val = !val;
393  } else {
394  if (x >= SETTING_BUTTON_WIDTH / 2) {
395  /* Increase button clicked */
396  if (val < par_info->max_value) val++;
397  this->clicked_increase = true;
398  } else {
399  /* Decrease button clicked */
400  if (val > par_info->min_value) val--;
401  this->clicked_increase = false;
402  }
403  }
404  if (val != old_val) {
405  par_info->SetValue(this->grf_config, val);
406 
407  this->clicked_button = num;
408  this->timeout.SetInterval(150);
409  }
410  } else if (par_info->type == PTYPE_UINT_ENUM && !par_info->complete_labels && click_count >= 2) {
411  /* Display a query box so users can enter a custom value. */
412  SetDParam(0, old_val);
413  ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 10, this, CS_NUMERAL, QSF_NONE);
414  }
415  this->SetDirty();
416  break;
417  }
418 
419  case WID_NP_RESET:
420  if (!this->editable) break;
421  this->grf_config->SetParameterDefaults();
422  this->InvalidateData();
424  break;
425 
426  case WID_NP_ACCEPT:
427  this->Close();
428  break;
429  }
430  }
431 
432  void OnQueryTextFinished(char *str) override
433  {
434  if (StrEmpty(str)) return;
435  int32 value = atoi(str);
436  GRFParameterInfo *par_info = ((uint)this->clicked_row < this->grf_config->param_info.size()) ? this->grf_config->param_info[this->clicked_row] : nullptr;
437  if (par_info == nullptr) par_info = GetDummyParameterInfo(this->clicked_row);
438  uint32 val = Clamp<uint32>(value, par_info->min_value, par_info->max_value);
439  par_info->SetValue(this->grf_config, val);
440  this->SetDirty();
441  }
442 
443  void OnDropdownSelect(int widget, int index) override
444  {
445  assert(this->clicked_dropdown);
446  GRFParameterInfo *par_info = ((uint)this->clicked_row < this->grf_config->param_info.size()) ? this->grf_config->param_info[this->clicked_row] : nullptr;
447  if (par_info == nullptr) par_info = GetDummyParameterInfo(this->clicked_row);
448  par_info->SetValue(this->grf_config, index);
449  this->SetDirty();
450  }
451 
452  void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
453  {
454  /* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
455  * the same dropdown button was clicked again, and then not open the dropdown again.
456  * So, we only remember that it was closed, and process it on the next OnPaint, which is
457  * after OnClick. */
458  assert(this->clicked_dropdown);
459  this->closing_dropdown = true;
460  this->SetDirty();
461  }
462 
463  void OnResize() override
464  {
465  this->vscroll->SetCapacityFromWidget(this, WID_NP_BACKGROUND);
466  }
467 
473  void OnInvalidateData(int data = 0, bool gui_scope = true) override
474  {
475  if (!gui_scope) return;
476  if (!this->action14present) {
477  this->SetWidgetDisabledState(WID_NP_NUMPAR_DEC, !this->editable || this->grf_config->num_params == 0);
478  this->SetWidgetDisabledState(WID_NP_NUMPAR_INC, !this->editable || this->grf_config->num_params >= this->grf_config->num_valid_params);
479  }
480 
481  this->vscroll->SetCount(this->action14present ? this->grf_config->num_valid_params : this->grf_config->num_params);
482  if (this->clicked_row != UINT_MAX && this->clicked_row >= this->vscroll->GetCount()) {
483  this->clicked_row = UINT_MAX;
485  }
486  }
487 
488  void OnRealtimeTick(uint delta_ms) override
489  {
490  if (timeout.Elapsed(delta_ms)) {
491  this->clicked_button = UINT_MAX;
492  this->SetDirty();
493  }
494  }
495 };
497 
498 
499 static const NWidgetPart _nested_newgrf_parameter_widgets[] = {
501  NWidget(WWT_CLOSEBOX, COLOUR_MAUVE),
502  NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_NEWGRF_PARAMETERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
503  NWidget(WWT_DEFSIZEBOX, COLOUR_MAUVE),
504  EndContainer(),
505  NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NP_SHOW_NUMPAR),
506  NWidget(WWT_PANEL, COLOUR_MAUVE), SetResize(1, 0), SetFill(1, 0), SetPIP(4, 0, 4),
507  NWidget(NWID_HORIZONTAL), SetPIP(4, 0, 4),
508  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_NP_NUMPAR_DEC), SetMinimalSize(12, 12), SetDataTip(AWV_DECREASE, STR_NULL),
509  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_NP_NUMPAR_INC), SetMinimalSize(12, 12), SetDataTip(AWV_INCREASE, STR_NULL),
510  NWidget(WWT_TEXT, COLOUR_MAUVE, WID_NP_NUMPAR), SetResize(1, 0), SetFill(1, 0), SetPadding(0, 0, 0, 4), SetDataTip(STR_NEWGRF_PARAMETERS_NUM_PARAM, STR_NULL),
511  EndContainer(),
512  EndContainer(),
513  EndContainer(),
515  NWidget(WWT_MATRIX, COLOUR_MAUVE, WID_NP_BACKGROUND), SetMinimalSize(188, 182), SetResize(1, 1), SetFill(1, 0), SetMatrixDataTip(1, 0, STR_NULL), SetScrollbar(WID_NP_SCROLLBAR),
516  NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_NP_SCROLLBAR),
517  EndContainer(),
519  NWidget(WWT_PANEL, COLOUR_MAUVE, WID_NP_DESCRIPTION), SetResize(1, 0), SetFill(1, 0),
520  EndContainer(),
521  EndContainer(),
524  NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_NP_ACCEPT), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NEWGRF_PARAMETERS_CLOSE, STR_NULL),
525  NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_NP_RESET), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NEWGRF_PARAMETERS_RESET, STR_NEWGRF_PARAMETERS_RESET_TOOLTIP),
526  EndContainer(),
527  NWidget(WWT_RESIZEBOX, COLOUR_MAUVE),
528  EndContainer(),
529 };
530 
533  WDP_CENTER, "settings_newgrf_config", 500, 208,
535  0,
536  _nested_newgrf_parameter_widgets, lengthof(_nested_newgrf_parameter_widgets)
537 );
538 
539 static void OpenGRFParameterWindow(GRFConfig *c, bool editable)
540 {
543 }
544 
548 
550  {
551  const char *textfile = this->grf_config->GetTextfile(file_type);
552  this->LoadTextfile(textfile, NEWGRF_DIR);
553  }
554 
555  void SetStringParameters(int widget) const override
556  {
557  if (widget == WID_TF_CAPTION) {
558  SetDParam(0, STR_CONTENT_TYPE_NEWGRF);
559  SetDParamStr(1, this->grf_config->GetName());
560  }
561  }
562 };
563 
564 void ShowNewGRFTextfileWindow(TextfileType file_type, const GRFConfig *c)
565 {
566  CloseWindowById(WC_TEXTFILE, file_type);
567  new NewGRFTextfileWindow(file_type, c);
568 }
569 
570 typedef std::map<uint32, const GRFConfig *> GrfIdMap;
571 
577 static void FillGrfidMap(const GRFConfig *c, GrfIdMap *grfid_map)
578 {
579  while (c != nullptr) {
580  std::pair<uint32, const GRFConfig *> p(c->ident.grfid, c);
581  grfid_map->insert(p);
582  c = c->next;
583  }
584 }
585 
586 static void NewGRFConfirmationCallback(Window *w, bool confirmed);
587 static void ShowSavePresetWindow(const char *initial_text);
588 
594 
595  static const uint EDITBOX_MAX_SIZE = 50;
596 
601 
604  int avail_pos;
607 
609 
612 
614  bool editable;
615  bool show_params;
616  bool execute;
617  int preset;
619  bool modified;
620 
621  Scrollbar *vscroll;
622  Scrollbar *vscroll2;
623 
624  NewGRFWindow(WindowDesc *desc, bool editable, bool show_params, bool execute, GRFConfig **orig_list) : Window(desc), filter_editbox(EDITBOX_MAX_SIZE)
625  {
626  this->avail_sel = nullptr;
627  this->avail_pos = -1;
628  this->active_sel = nullptr;
629  this->actives = nullptr;
630  this->orig_list = orig_list;
631  this->editable = editable;
632  this->execute = execute;
633  this->show_params = show_params;
634  this->preset = -1;
635  this->active_over = -1;
636 
637  CopyGRFConfigList(&this->actives, *orig_list, false);
638  this->grf_presets = GetGRFPresetList();
639 
640  this->CreateNestedTree();
641  this->vscroll = this->GetScrollbar(WID_NS_SCROLLBAR);
642  this->vscroll2 = this->GetScrollbar(WID_NS_SCROLL2BAR);
643 
644  this->GetWidget<NWidgetStacked>(WID_NS_SHOW_REMOVE)->SetDisplayedPlane(this->editable ? 0 : 1);
645  this->GetWidget<NWidgetStacked>(WID_NS_SHOW_APPLY)->SetDisplayedPlane(this->editable ? 0 : this->show_params ? 1 : SZSP_HORIZONTAL);
647 
648  this->querystrings[WID_NS_FILTER] = &this->filter_editbox;
649  this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;
650  if (editable) {
652  } else {
654  }
655 
656  this->avails.SetListing(this->last_sorting);
657  this->avails.SetFiltering(this->last_filtering);
658  this->avails.SetSortFuncs(this->sorter_funcs);
659  this->avails.SetFilterFuncs(this->filter_funcs);
660  this->avails.ForceRebuild();
661 
663  }
664 
665  void Close() override
666  {
670 
671  if (this->editable && this->modified && !this->execute && !_exit_game) {
672  CopyGRFConfigList(this->orig_list, this->actives, true);
673  ResetGRFConfig(false);
675  }
676 
677  this->Window::Close();
678  }
679 
680  ~NewGRFWindow()
681  {
682  /* Remove the temporary copy of grf-list used in window */
683  ClearGRFConfigList(&this->actives);
684  }
685 
691  {
692  GrfIdMap grfid_map;
693  FillGrfidMap(this->actives, &grfid_map);
694 
695  for (const GRFConfig *a = _all_grfs; a != nullptr; a = a->next) {
696  GrfIdMap::const_iterator iter = grfid_map.find(a->ident.grfid);
697  if (iter != grfid_map.end() && a->version > iter->second->version) return true;
698  }
699  return false;
700  }
701 
704  {
705  GrfIdMap grfid_map;
706  FillGrfidMap(this->actives, &grfid_map);
707 
708  for (const GRFConfig *a = _all_grfs; a != nullptr; a = a->next) {
709  GrfIdMap::iterator iter = grfid_map.find(a->ident.grfid);
710  if (iter == grfid_map.end() || iter->second->version >= a->version) continue;
711 
712  GRFConfig **c = &this->actives;
713  while (*c != iter->second) c = &(*c)->next;
714  GRFConfig *d = new GRFConfig(*a);
715  d->next = (*c)->next;
716  d->CopyParams(**c);
717  if (this->active_sel == *c) {
720  this->active_sel = nullptr;
721  }
722  delete *c;
723  *c = d;
724  iter->second = d;
725  }
726  }
727 
728  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
729  {
730  switch (widget) {
731  case WID_NS_FILE_LIST:
732  {
733  Dimension d = maxdim(GetSpriteSize(SPR_SQUARE), GetSpriteSize(SPR_WARNING_SIGN));
734  resize->height = std::max(d.height + 2U, FONT_HEIGHT_NORMAL + 2U);
735  size->height = std::max(size->height, WD_FRAMERECT_TOP + 6 * resize->height + WD_FRAMERECT_BOTTOM);
736  break;
737  }
738 
739  case WID_NS_AVAIL_LIST:
740  resize->height = std::max(12, FONT_HEIGHT_NORMAL + 2);
741  size->height = std::max(size->height, WD_FRAMERECT_TOP + 8 * resize->height + WD_FRAMERECT_BOTTOM);
742  break;
743 
745  Dimension dim = GetStringBoundingBox(STR_NEWGRF_SETTINGS_INFO_TITLE);
746  size->height = std::max(size->height, dim.height + WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM);
747  size->width = std::max(size->width, dim.width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT);
748  break;
749  }
750 
751  case WID_NS_NEWGRF_INFO:
752  size->height = std::max(size->height, WD_FRAMERECT_TOP + 10 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM + padding.height + 2);
753  break;
754 
755  case WID_NS_PRESET_LIST: {
756  Dimension d = GetStringBoundingBox(STR_NUM_CUSTOM);
757  for (const auto &i : this->grf_presets) {
758  SetDParamStr(0, i);
759  d = maxdim(d, GetStringBoundingBox(STR_JUST_RAW_STRING));
760  }
761  d.width += padding.width;
762  *size = maxdim(d, *size);
763  break;
764  }
765 
768  Dimension d = GetStringBoundingBox(STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON);
769  *size = maxdim(d, GetStringBoundingBox(STR_INTRO_ONLINE_CONTENT));
770  size->width += padding.width;
771  size->height += padding.height;
772  break;
773  }
774  }
775  }
776 
777  void OnResize() override
778  {
779  this->vscroll->SetCapacityFromWidget(this, WID_NS_FILE_LIST);
780  this->vscroll2->SetCapacityFromWidget(this, WID_NS_AVAIL_LIST);
781  }
782 
783  void SetStringParameters(int widget) const override
784  {
785  switch (widget) {
786  case WID_NS_PRESET_LIST:
787  if (this->preset == -1) {
788  SetDParam(0, STR_NUM_CUSTOM);
789  } else {
790  SetDParam(0, STR_JUST_RAW_STRING);
791  SetDParamStr(1, this->grf_presets[this->preset]);
792  }
793  break;
794  }
795  }
796 
802  inline PaletteID GetPalette(const GRFConfig *c) const
803  {
804  PaletteID pal;
805 
806  /* Pick a colour */
807  switch (c->status) {
808  case GCS_NOT_FOUND:
809  case GCS_DISABLED:
810  pal = PALETTE_TO_RED;
811  break;
812  case GCS_ACTIVATED:
813  pal = PALETTE_TO_GREEN;
814  break;
815  default:
816  pal = PALETTE_TO_BLUE;
817  break;
818  }
819 
820  /* Do not show a "not-failure" colour when it actually failed to load */
821  if (pal != PALETTE_TO_RED) {
822  if (HasBit(c->flags, GCF_STATIC)) {
823  pal = PALETTE_TO_GREY;
824  } else if (HasBit(c->flags, GCF_COMPATIBLE)) {
825  pal = PALETTE_TO_ORANGE;
826  }
827  }
828 
829  return pal;
830  }
831 
832  void DrawWidget(const Rect &r, int widget) const override
833  {
834  switch (widget) {
835  case WID_NS_FILE_LIST: {
836  GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK);
837 
838  uint step_height = this->GetWidget<NWidgetBase>(WID_NS_FILE_LIST)->resize_y;
839  uint y = r.top + WD_FRAMERECT_TOP;
840  Dimension square = GetSpriteSize(SPR_SQUARE);
841  Dimension warning = GetSpriteSize(SPR_WARNING_SIGN);
842  int square_offset_y = (step_height - square.height) / 2;
843  int warning_offset_y = (step_height - warning.height) / 2;
844  int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
845 
846  bool rtl = _current_text_dir == TD_RTL;
847  uint text_left = rtl ? r.left + WD_FRAMERECT_LEFT : r.left + square.width + 15;
848  uint text_right = rtl ? r.right - square.width - 15 : r.right - WD_FRAMERECT_RIGHT;
849  uint square_left = rtl ? r.right - square.width - 5 : r.left + 5;
850  uint warning_left = rtl ? r.right - square.width - warning.width - 10 : r.left + square.width + 10;
851 
852  int i = 0;
853  for (const GRFConfig *c = this->actives; c != nullptr; c = c->next, i++) {
854  if (this->vscroll->IsVisible(i)) {
855  const char *text = c->GetName();
856  bool h = (this->active_sel == c);
857  PaletteID pal = this->GetPalette(c);
858 
859  if (h) {
860  GfxFillRect(r.left + 1, y, r.right - 1, y + step_height - 1, PC_DARK_BLUE);
861  } else if (i == this->active_over) {
862  /* Get index of current selection. */
863  int active_sel_pos = 0;
864  for (GRFConfig *c = this->actives; c != nullptr && c != this->active_sel; c = c->next, active_sel_pos++) {}
865  if (active_sel_pos != this->active_over) {
866  uint top = this->active_over < active_sel_pos ? y + 1 : y + step_height - 2;
867  GfxFillRect(r.left + WD_FRAMERECT_LEFT, top - 1, r.right - WD_FRAMERECT_RIGHT, top + 1, PC_GREY);
868  }
869  }
870  DrawSprite(SPR_SQUARE, pal, square_left, y + square_offset_y);
871  if (c->error != nullptr) DrawSprite(SPR_WARNING_SIGN, 0, warning_left, y + warning_offset_y);
872  uint txtoffset = c->error == nullptr ? 0 : warning.width;
873  DrawString(text_left + (rtl ? 0 : txtoffset), text_right - (rtl ? txtoffset : 0), y + offset_y, text, h ? TC_WHITE : TC_ORANGE);
874  y += step_height;
875  }
876  }
877  if (i == this->active_over && this->vscroll->IsVisible(i)) { // Highlight is after the last GRF entry.
878  GfxFillRect(r.left + WD_FRAMERECT_LEFT, y, r.right - WD_FRAMERECT_RIGHT, y + 2, PC_GREY);
879  }
880  break;
881  }
882 
883  case WID_NS_AVAIL_LIST: {
884  GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, this->active_over == -2 ? PC_DARK_GREY : PC_BLACK);
885 
886  uint step_height = this->GetWidget<NWidgetBase>(WID_NS_AVAIL_LIST)->resize_y;
887  int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
888  uint y = r.top + WD_FRAMERECT_TOP;
889  uint min_index = this->vscroll2->GetPosition();
890  uint max_index = std::min(min_index + this->vscroll2->GetCapacity(), (uint)this->avails.size());
891 
892  for (uint i = min_index; i < max_index; i++) {
893  const GRFConfig *c = this->avails[i];
894  bool h = (c == this->avail_sel);
895  const char *text = c->GetName();
896 
897  if (h) GfxFillRect(r.left + 1, y, r.right - 1, y + step_height - 1, PC_DARK_BLUE);
898  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y + offset_y, text, h ? TC_WHITE : TC_SILVER);
899  y += step_height;
900  }
901  break;
902  }
903 
905  /* Create the nice grayish rectangle at the details top. */
906  GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_DARK_BLUE);
907  DrawString(r.left, r.right, (r.top + r.bottom - FONT_HEIGHT_NORMAL) / 2, STR_NEWGRF_SETTINGS_INFO_TITLE, TC_FROMSTRING, SA_HOR_CENTER);
908  break;
909 
910  case WID_NS_NEWGRF_INFO: {
911  const GRFConfig *selected = this->active_sel;
912  if (selected == nullptr) selected = this->avail_sel;
913  if (selected != nullptr) {
914  ShowNewGRFInfo(selected, r.left + WD_FRAMERECT_LEFT, r.top + WD_FRAMERECT_TOP, r.right - WD_FRAMERECT_RIGHT, r.bottom - WD_FRAMERECT_BOTTOM, this->show_params);
915  }
916  break;
917  }
918  }
919  }
920 
921  void OnClick(Point pt, int widget, int click_count) override
922  {
923  if (widget >= WID_NS_NEWGRF_TEXTFILE && widget < WID_NS_NEWGRF_TEXTFILE + TFT_END) {
924  if (this->active_sel == nullptr && this->avail_sel == nullptr) return;
925 
926  ShowNewGRFTextfileWindow((TextfileType)(widget - WID_NS_NEWGRF_TEXTFILE), this->active_sel != nullptr ? this->active_sel : this->avail_sel);
927  return;
928  }
929 
930  switch (widget) {
931  case WID_NS_PRESET_LIST: {
932  DropDownList list;
933 
934  /* Add 'None' option for clearing list */
935  list.emplace_back(new DropDownListStringItem(STR_NONE, -1, false));
936 
937  for (uint i = 0; i < this->grf_presets.size(); i++) {
938  list.emplace_back(new DropDownListCharStringItem(this->grf_presets[i], i, false));
939  }
940 
941  this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window
942  ShowDropDownList(this, std::move(list), this->preset, WID_NS_PRESET_LIST);
943  break;
944  }
945 
946  case WID_NS_OPEN_URL: {
947  const GRFConfig *c = (this->avail_sel == nullptr) ? this->active_sel : this->avail_sel;
948 
949  extern void OpenBrowser(const char *url);
950  OpenBrowser(c->GetURL());
951  break;
952  }
953 
954  case WID_NS_PRESET_SAVE:
955  ShowSavePresetWindow((this->preset == -1) ? nullptr : this->grf_presets[this->preset].c_str());
956  break;
957 
959  if (this->preset == -1) return;
960 
961  DeleteGRFPresetFromConfig(this->grf_presets[this->preset].c_str());
962  this->grf_presets = GetGRFPresetList();
963  this->preset = -1;
964  this->InvalidateData();
965  this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window
966  break;
967 
968  case WID_NS_MOVE_UP: { // Move GRF up
969  if (this->active_sel == nullptr || !this->editable) break;
970 
971  int pos = 0;
972  for (GRFConfig **pc = &this->actives; *pc != nullptr; pc = &(*pc)->next, pos++) {
973  GRFConfig *c = *pc;
974  if (c->next == this->active_sel) {
975  c->next = this->active_sel->next;
976  this->active_sel->next = c;
977  *pc = this->active_sel;
978  break;
979  }
980  }
981  this->vscroll->ScrollTowards(pos);
982  this->preset = -1;
984  break;
985  }
986 
987  case WID_NS_MOVE_DOWN: { // Move GRF down
988  if (this->active_sel == nullptr || !this->editable) break;
989 
990  int pos = 1; // Start at 1 as we swap the selected newgrf with the next one
991  for (GRFConfig **pc = &this->actives; *pc != nullptr; pc = &(*pc)->next, pos++) {
992  GRFConfig *c = *pc;
993  if (c == this->active_sel) {
994  *pc = c->next;
995  c->next = c->next->next;
996  (*pc)->next = c;
997  break;
998  }
999  }
1000  this->vscroll->ScrollTowards(pos);
1001  this->preset = -1;
1003  break;
1004  }
1005 
1006  case WID_NS_FILE_LIST: { // Select an active GRF.
1008 
1009  uint i = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NS_FILE_LIST);
1010 
1011  GRFConfig *c;
1012  for (c = this->actives; c != nullptr && i > 0; c = c->next, i--) {}
1013 
1014  if (this->active_sel != c) {
1017  }
1018  this->active_sel = c;
1019  this->avail_sel = nullptr;
1020  this->avail_pos = -1;
1021 
1022  this->InvalidateData();
1023  if (click_count == 1) {
1024  if (this->editable && this->active_sel != nullptr) SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
1025  break;
1026  }
1027  /* With double click, continue */
1028  FALLTHROUGH;
1029  }
1030 
1031  case WID_NS_REMOVE: { // Remove GRF
1032  if (this->active_sel == nullptr || !this->editable) break;
1035 
1036  /* Choose the next GRF file to be the selected file. */
1037  GRFConfig *newsel = this->active_sel->next;
1038  for (GRFConfig **pc = &this->actives; *pc != nullptr; pc = &(*pc)->next) {
1039  GRFConfig *c = *pc;
1040  /* If the new selection is empty (i.e. we're deleting the last item
1041  * in the list, pick the file just before the selected file */
1042  if (newsel == nullptr && c->next == this->active_sel) newsel = c;
1043 
1044  if (c == this->active_sel) {
1045  if (newsel == c) newsel = nullptr;
1046 
1047  *pc = c->next;
1048  delete c;
1049  break;
1050  }
1051  }
1052 
1053  this->active_sel = newsel;
1054  this->preset = -1;
1055  this->avail_pos = -1;
1056  this->avail_sel = nullptr;
1057  this->avails.ForceRebuild();
1059  break;
1060  }
1061 
1062  case WID_NS_UPGRADE: { // Upgrade GRF.
1063  if (!this->editable || this->actives == nullptr) break;
1064  UpgradeCurrent();
1066  break;
1067  }
1068 
1069  case WID_NS_AVAIL_LIST: { // Select a non-active GRF.
1071 
1072  uint i = this->vscroll2->GetScrolledRowFromWidget(pt.y, this, WID_NS_AVAIL_LIST);
1073  this->active_sel = nullptr;
1075  if (i < this->avails.size()) {
1076  if (this->avail_sel != this->avails[i]) CloseWindowByClass(WC_TEXTFILE);
1077  this->avail_sel = this->avails[i];
1078  this->avail_pos = i;
1079  }
1080  this->InvalidateData();
1081  if (click_count == 1) {
1082  if (this->editable && this->avail_sel != nullptr && !HasBit(this->avail_sel->flags, GCF_INVALID)) SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
1083  break;
1084  }
1085  /* With double click, continue */
1086  FALLTHROUGH;
1087  }
1088 
1089  case WID_NS_ADD:
1090  if (this->avail_sel == nullptr || !this->editable || HasBit(this->avail_sel->flags, GCF_INVALID)) break;
1091 
1092  this->AddGRFToActive();
1093  break;
1094 
1095  case WID_NS_APPLY_CHANGES: // Apply changes made to GRF list
1096  if (!this->editable) break;
1097  if (this->execute) {
1098  ShowQuery(
1099  STR_NEWGRF_POPUP_CAUTION_CAPTION,
1100  STR_NEWGRF_CONFIRMATION_TEXT,
1101  this,
1103  );
1104  } else {
1105  CopyGRFConfigList(this->orig_list, this->actives, true);
1106  ResetGRFConfig(false);
1107  ReloadNewGRFData();
1109  }
1110  this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window
1111  break;
1112 
1114  case WID_NS_SET_PARAMETERS: { // Edit parameters
1115  if (this->active_sel == nullptr || !this->show_params || this->active_sel->num_valid_params == 0) break;
1116 
1117  OpenGRFParameterWindow(this->active_sel, this->editable);
1119  break;
1120  }
1121 
1122  case WID_NS_TOGGLE_PALETTE:
1123  if (this->active_sel != nullptr && this->editable) {
1124  this->active_sel->palette ^= GRFP_USE_MASK;
1125  this->SetDirty();
1127  }
1128  break;
1129 
1132  if (!_network_available) {
1133  ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
1134  } else {
1135  this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window
1136 
1137  ShowMissingContentWindow(this->actives);
1138  }
1139  break;
1140 
1141  case WID_NS_RESCAN_FILES:
1142  case WID_NS_RESCAN_FILES2:
1143  RequestNewGRFScan(this);
1144  break;
1145  }
1146  }
1147 
1148  void OnNewGRFsScanned() override
1149  {
1150  if (this->active_sel == nullptr) CloseWindowByClass(WC_TEXTFILE);
1151  this->avail_sel = nullptr;
1152  this->avail_pos = -1;
1153  this->avails.ForceRebuild();
1154  this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window
1155  }
1156 
1157  void OnDropdownSelect(int widget, int index) override
1158  {
1159  if (!this->editable) return;
1160 
1161  ClearGRFConfigList(&this->actives);
1162  this->preset = index;
1163 
1164  if (index != -1) {
1165  this->actives = LoadGRFPresetFromConfig(this->grf_presets[index].c_str());
1166  }
1167  this->avails.ForceRebuild();
1168 
1172  this->active_sel = nullptr;
1174  }
1175 
1176  void OnQueryTextFinished(char *str) override
1177  {
1178  if (str == nullptr) return;
1179 
1180  SaveGRFPresetToConfig(str, this->actives);
1181  this->grf_presets = GetGRFPresetList();
1182 
1183  /* Switch to this preset */
1184  for (uint i = 0; i < this->grf_presets.size(); i++) {
1185  if (this->grf_presets[i] == str) {
1186  this->preset = i;
1187  break;
1188  }
1189  }
1190 
1191  this->InvalidateData();
1192  }
1193 
1198  {
1199  /* Update scrollbars */
1200  int i = 0;
1201  for (const GRFConfig *c = this->actives; c != nullptr; c = c->next, i++) {}
1202 
1203  this->vscroll->SetCount(i + 1); // Reserve empty space for drag and drop handling.
1204 
1205  if (this->avail_pos >= 0) this->vscroll2->ScrollTowards(this->avail_pos);
1206  }
1207 
1213  void OnInvalidateData(int data = 0, bool gui_scope = true) override
1214  {
1215  if (!gui_scope) return;
1216  switch (data) {
1217  default:
1218  /* Nothing important to do */
1219  break;
1220 
1221  case GOID_NEWGRF_RESCANNED:
1222  /* Search the list for items that are now found and mark them as such. */
1223  for (GRFConfig **l = &this->actives; *l != nullptr; l = &(*l)->next) {
1224  GRFConfig *c = *l;
1225  bool compatible = HasBit(c->flags, GCF_COMPATIBLE);
1226  if (c->status != GCS_NOT_FOUND && !compatible) continue;
1227 
1228  const GRFConfig *f = FindGRFConfig(c->ident.grfid, FGCM_EXACT, compatible ? c->original_md5sum : c->ident.md5sum);
1229  if (f == nullptr || HasBit(f->flags, GCF_INVALID)) continue;
1230 
1231  *l = new GRFConfig(*f);
1232  (*l)->next = c->next;
1233 
1234  if (this->active_sel == c) this->active_sel = *l;
1235 
1236  delete c;
1237  }
1238 
1239  this->avails.ForceRebuild();
1240  FALLTHROUGH;
1241 
1243  this->modified = false;
1244  UpdateScrollBars();
1245  break;
1246 
1248  this->preset = -1;
1249  FALLTHROUGH;
1250 
1252  UpdateScrollBars();
1253 
1254  /* Changes have been made to the list of active NewGRFs */
1255  this->modified = true;
1256 
1257  break;
1258 
1260  /* No changes have been made to the list of active NewGRFs since the last time the changes got applied */
1261  this->modified = false;
1262  break;
1263  }
1264 
1265  this->BuildAvailables();
1266 
1267  this->SetWidgetDisabledState(WID_NS_APPLY_CHANGES, !((this->editable && this->modified) || _settings_client.gui.newgrf_developer_tools));
1268  this->SetWidgetsDisabledState(!this->editable,
1272  );
1273  this->SetWidgetDisabledState(WID_NS_ADD, !this->editable || this->avail_sel == nullptr || HasBit(this->avail_sel->flags, GCF_INVALID));
1274  this->SetWidgetDisabledState(WID_NS_UPGRADE, !this->editable || this->actives == nullptr || !this->CanUpgradeCurrent());
1275 
1276  bool disable_all = this->active_sel == nullptr || !this->editable;
1277  this->SetWidgetsDisabledState(disable_all,
1278  WID_NS_REMOVE,
1282  );
1283 
1284  const GRFConfig *c = (this->avail_sel == nullptr) ? this->active_sel : this->avail_sel;
1285  for (TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
1286  this->SetWidgetDisabledState(WID_NS_NEWGRF_TEXTFILE + tft, c == nullptr || c->GetTextfile(tft) == nullptr);
1287  }
1288  this->SetWidgetDisabledState(WID_NS_OPEN_URL, c == nullptr || StrEmpty(c->GetURL()));
1289 
1290  this->SetWidgetDisabledState(WID_NS_SET_PARAMETERS, !this->show_params || this->active_sel == nullptr || this->active_sel->num_valid_params == 0);
1291  this->SetWidgetDisabledState(WID_NS_VIEW_PARAMETERS, !this->show_params || this->active_sel == nullptr || this->active_sel->num_valid_params == 0);
1292  this->SetWidgetDisabledState(WID_NS_TOGGLE_PALETTE, disable_all ||
1294 
1295  if (!disable_all) {
1296  /* All widgets are now enabled, so disable widgets we can't use */
1297  if (this->active_sel == this->actives) this->DisableWidget(WID_NS_MOVE_UP);
1298  if (this->active_sel->next == nullptr) this->DisableWidget(WID_NS_MOVE_DOWN);
1299  }
1300 
1301  this->SetWidgetDisabledState(WID_NS_PRESET_DELETE, this->preset == -1);
1302 
1303  bool has_missing = false;
1304  bool has_compatible = false;
1305  for (const GRFConfig *c = this->actives; !has_missing && c != nullptr; c = c->next) {
1306  has_missing |= c->status == GCS_NOT_FOUND;
1307  has_compatible |= HasBit(c->flags, GCF_COMPATIBLE);
1308  }
1309  uint32 widget_data;
1310  StringID tool_tip;
1311  if (has_missing || has_compatible) {
1312  widget_data = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON;
1313  tool_tip = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP;
1314  } else {
1315  widget_data = STR_INTRO_ONLINE_CONTENT;
1316  tool_tip = STR_INTRO_TOOLTIP_ONLINE_CONTENT;
1317  }
1318  this->GetWidget<NWidgetCore>(WID_NS_CONTENT_DOWNLOAD)->widget_data = widget_data;
1319  this->GetWidget<NWidgetCore>(WID_NS_CONTENT_DOWNLOAD)->tool_tip = tool_tip;
1320  this->GetWidget<NWidgetCore>(WID_NS_CONTENT_DOWNLOAD2)->widget_data = widget_data;
1321  this->GetWidget<NWidgetCore>(WID_NS_CONTENT_DOWNLOAD2)->tool_tip = tool_tip;
1322 
1323  this->SetWidgetDisabledState(WID_NS_PRESET_SAVE, has_missing);
1324  }
1325 
1326  EventState OnKeyPress(WChar key, uint16 keycode) override
1327  {
1328  if (!this->editable) return ES_NOT_HANDLED;
1329 
1330  if (this->vscroll2->UpdateListPositionOnKeyPress(this->avail_pos, keycode) == ES_NOT_HANDLED) return ES_NOT_HANDLED;
1331 
1332  if (this->avail_pos >= 0) {
1333  this->active_sel = nullptr;
1335  if (this->avail_sel != this->avails[this->avail_pos]) CloseWindowByClass(WC_TEXTFILE);
1336  this->avail_sel = this->avails[this->avail_pos];
1337  this->vscroll2->ScrollTowards(this->avail_pos);
1338  this->InvalidateData(0);
1339  }
1340 
1341  return ES_HANDLED;
1342  }
1343 
1344  void OnEditboxChanged(int wid) override
1345  {
1346  if (!this->editable) return;
1347 
1348  string_filter.SetFilterTerm(this->filter_editbox.text.buf);
1349  this->avails.SetFilterState(!string_filter.IsEmpty());
1350  this->avails.ForceRebuild();
1351  this->InvalidateData(0);
1352  }
1353 
1354  void OnDragDrop(Point pt, int widget) override
1355  {
1356  if (!this->editable) return;
1357 
1358  if (widget == WID_NS_FILE_LIST) {
1359  if (this->active_sel != nullptr) {
1360  /* Get pointer to the selected file in the active list. */
1361  int from_pos = 0;
1362  GRFConfig **from_prev;
1363  for (from_prev = &this->actives; *from_prev != this->active_sel; from_prev = &(*from_prev)->next, from_pos++) {}
1364 
1365  /* Gets the drag-and-drop destination offset. Ignore the last dummy line. */
1366  int to_pos = std::min(this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NS_FILE_LIST), this->vscroll->GetCount() - 2);
1367  if (to_pos != from_pos) { // Don't move NewGRF file over itself.
1368  /* Get pointer to destination position. */
1369  GRFConfig **to_prev = &this->actives;
1370  for (int i = from_pos < to_pos ? -1 : 0; *to_prev != nullptr && i < to_pos; to_prev = &(*to_prev)->next, i++) {}
1371 
1372  /* Detach NewGRF file from its original position. */
1373  *from_prev = this->active_sel->next;
1374 
1375  /* Attach NewGRF file to its new position. */
1376  this->active_sel->next = *to_prev;
1377  *to_prev = this->active_sel;
1378 
1379  this->vscroll->ScrollTowards(to_pos);
1380  this->preset = -1;
1381  this->InvalidateData();
1382  }
1383  } else if (this->avail_sel != nullptr) {
1384  int to_pos = std::min(this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NS_FILE_LIST), this->vscroll->GetCount() - 1);
1385  this->AddGRFToActive(to_pos);
1386  }
1387  } else if (widget == WID_NS_AVAIL_LIST && this->active_sel != nullptr) {
1388  /* Remove active NewGRF file by dragging it over available list. */
1389  Point dummy = {-1, -1};
1390  this->OnClick(dummy, WID_NS_REMOVE, 1);
1391  }
1392 
1394 
1395  if (this->active_over != -1) {
1396  /* End of drag-and-drop, hide dragged destination highlight. */
1397  this->SetWidgetDirty(this->active_over == -2 ? WID_NS_AVAIL_LIST : WID_NS_FILE_LIST);
1398  this->active_over = -1;
1399  }
1400  }
1401 
1402  void OnMouseDrag(Point pt, int widget) override
1403  {
1404  if (!this->editable) return;
1405 
1406  if (widget == WID_NS_FILE_LIST && (this->active_sel != nullptr || this->avail_sel != nullptr)) {
1407  /* An NewGRF file is dragged over the active list. */
1408  int to_pos = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NS_FILE_LIST);
1409  /* Skip the last dummy line if the source is from the active list. */
1410  to_pos = std::min(to_pos, this->vscroll->GetCount() - (this->active_sel != nullptr ? 2 : 1));
1411 
1412  if (to_pos != this->active_over) {
1413  this->active_over = to_pos;
1415  }
1416  } else if (widget == WID_NS_AVAIL_LIST && this->active_sel != nullptr) {
1417  this->active_over = -2;
1419  } else if (this->active_over != -1) {
1420  this->SetWidgetDirty(this->active_over == -2 ? WID_NS_AVAIL_LIST : WID_NS_FILE_LIST);
1421  this->active_over = -1;
1422  }
1423  }
1424 
1425 private:
1427  static bool NameSorter(const GRFConfig * const &a, const GRFConfig * const &b)
1428  {
1429  int i = strnatcmp(a->GetName(), b->GetName(), true); // Sort by name (natural sorting).
1430  if (i != 0) return i < 0;
1431 
1432  i = a->version - b->version;
1433  if (i != 0) return i < 0;
1434 
1435  return memcmp(a->ident.md5sum, b->ident.md5sum, lengthof(b->ident.md5sum)) < 0;
1436  }
1437 
1439  static bool CDECL TagNameFilter(const GRFConfig * const *a, StringFilter &filter)
1440  {
1441  filter.ResetState();
1442  filter.AddLine((*a)->GetName());
1443  filter.AddLine((*a)->filename);
1444  filter.AddLine((*a)->GetDescription());
1445  return filter.GetState();;
1446  }
1447 
1448  void BuildAvailables()
1449  {
1450  if (!this->avails.NeedRebuild()) return;
1451 
1452  this->avails.clear();
1453 
1454  for (const GRFConfig *c = _all_grfs; c != nullptr; c = c->next) {
1455  bool found = false;
1456  for (const GRFConfig *grf = this->actives; grf != nullptr && !found; grf = grf->next) found = grf->ident.HasGrfIdentifier(c->ident.grfid, c->ident.md5sum);
1457  if (found) continue;
1458 
1460  this->avails.push_back(c);
1461  } else {
1463  /*
1464  * If the best version is 0, then all NewGRF with this GRF ID
1465  * have version 0, so for backward compatibility reasons we
1466  * want to show them all.
1467  * If we are the best version, then we definitely want to
1468  * show that NewGRF!.
1469  */
1470  if (best->version == 0 || best->ident.HasGrfIdentifier(c->ident.grfid, c->ident.md5sum)) {
1471  this->avails.push_back(c);
1472  }
1473  }
1474  }
1475 
1476  this->avails.Filter(this->string_filter);
1477  this->avails.shrink_to_fit();
1478  this->avails.RebuildDone();
1479  this->avails.Sort();
1480 
1481  if (this->avail_sel != nullptr) {
1482  this->avail_pos = find_index(this->avails, this->avail_sel);
1483  if (this->avail_pos == -1) {
1484  this->avail_sel = nullptr;
1485  }
1486  }
1487 
1488  this->vscroll2->SetCount((uint)this->avails.size()); // Update the scrollbar
1489  }
1490 
1496  bool AddGRFToActive(int ins_pos = -1)
1497  {
1498  if (this->avail_sel == nullptr || !this->editable || HasBit(this->avail_sel->flags, GCF_INVALID)) return false;
1499 
1501 
1502  uint count = 0;
1503  GRFConfig **entry = nullptr;
1504  GRFConfig **list;
1505  /* Find last entry in the list, checking for duplicate grfid on the way */
1506  for (list = &this->actives; *list != nullptr; list = &(*list)->next, ins_pos--) {
1507  if (ins_pos == 0) entry = list; // Insert position? Save.
1508  if ((*list)->ident.grfid == this->avail_sel->ident.grfid) {
1509  ShowErrorMessage(STR_NEWGRF_DUPLICATE_GRFID, INVALID_STRING_ID, WL_INFO);
1510  return false;
1511  }
1512  if (!HasBit((*list)->flags, GCF_STATIC)) count++;
1513  }
1514  if (entry == nullptr) entry = list;
1515  if (count >= NETWORK_MAX_GRF_COUNT) {
1516  ShowErrorMessage(STR_NEWGRF_TOO_MANY_NEWGRFS, INVALID_STRING_ID, WL_INFO);
1517  return false;
1518  }
1519 
1520  GRFConfig *c = new GRFConfig(*this->avail_sel); // Copy GRF details from scanned list.
1521  c->SetParameterDefaults();
1522 
1523  /* Insert GRF config to configuration list. */
1524  c->next = *entry;
1525  *entry = c;
1526 
1527  /* Select next (or previous, if last one) item in the list. */
1528  int new_pos = this->avail_pos + 1;
1529  if (new_pos >= (int)this->avails.size()) new_pos = this->avail_pos - 1;
1530  this->avail_pos = new_pos;
1531  if (new_pos >= 0) this->avail_sel = this->avails[new_pos];
1532 
1533  this->avails.ForceRebuild();
1535  return true;
1536  }
1537 };
1538 
1544 {
1545  /* Only show the things in the current list, or everything when nothing's selected */
1546  ContentVector cv;
1547  for (const GRFConfig *c = list; c != nullptr; c = c->next) {
1548  if (c->status != GCS_NOT_FOUND && !HasBit(c->flags, GCF_COMPATIBLE)) continue;
1549 
1550  ContentInfo *ci = new ContentInfo();
1551  ci->type = CONTENT_TYPE_NEWGRF;
1553  ci->name = c->GetName();
1554  ci->unique_id = BSWAP32(c->ident.grfid);
1555  memcpy(ci->md5sum, HasBit(c->flags, GCF_COMPATIBLE) ? c->original_md5sum : c->ident.md5sum, sizeof(ci->md5sum));
1556  cv.push_back(ci);
1557  }
1558  ShowNetworkContentListWindow(cv.size() == 0 ? nullptr : &cv, CONTENT_TYPE_NEWGRF);
1559 }
1560 
1561 Listing NewGRFWindow::last_sorting = {false, 0};
1563 
1565  &NameSorter,
1566 };
1567 
1569  &TagNameFilter,
1570 };
1571 
1579 public:
1580  static const uint INTER_LIST_SPACING;
1581  static const uint INTER_COLUMN_SPACING;
1582  static const uint MAX_EXTRA_INFO_WIDTH;
1583  static const uint MIN_EXTRA_FOR_3_COLUMNS;
1584 
1588  bool editable;
1589 
1591  {
1592  this->avs = avs;
1593  this->acs = acs;
1594  this->inf = inf;
1595 
1596  this->Add(this->avs);
1597  this->Add(this->acs);
1598  this->Add(this->inf);
1599 
1600  this->editable = true; // Temporary setting, 'real' value is set in SetupSmallestSize().
1601  }
1602 
1603  void SetupSmallestSize(Window *w, bool init_array) override
1604  {
1605  /* Copy state flag from the window. */
1606  assert(dynamic_cast<NewGRFWindow *>(w) != nullptr);
1607  NewGRFWindow *ngw = (NewGRFWindow *)w;
1608  this->editable = ngw->editable;
1609 
1610  this->avs->SetupSmallestSize(w, init_array);
1611  this->acs->SetupSmallestSize(w, init_array);
1612  this->inf->SetupSmallestSize(w, init_array);
1613 
1614  uint min_avs_width = this->avs->smallest_x + this->avs->padding_left + this->avs->padding_right;
1615  uint min_acs_width = this->acs->smallest_x + this->acs->padding_left + this->acs->padding_right;
1616  uint min_inf_width = this->inf->smallest_x + this->inf->padding_left + this->inf->padding_right;
1617 
1618  uint min_avs_height = this->avs->smallest_y + this->avs->padding_top + this->avs->padding_bottom;
1619  uint min_acs_height = this->acs->smallest_y + this->acs->padding_top + this->acs->padding_bottom;
1620  uint min_inf_height = this->inf->smallest_y + this->inf->padding_top + this->inf->padding_bottom;
1621 
1622  /* Smallest window is in two column mode. */
1623  this->smallest_x = std::max(min_avs_width, min_acs_width) + INTER_COLUMN_SPACING + min_inf_width;
1624  this->smallest_y = std::max(min_inf_height, min_acs_height + INTER_LIST_SPACING + min_avs_height);
1625 
1626  /* Filling. */
1627  this->fill_x = LeastCommonMultiple(this->avs->fill_x, this->acs->fill_x);
1628  if (this->inf->fill_x > 0 && (this->fill_x == 0 || this->fill_x > this->inf->fill_x)) this->fill_x = this->inf->fill_x;
1629 
1630  this->fill_y = this->avs->fill_y;
1631  if (this->acs->fill_y > 0 && (this->fill_y == 0 || this->fill_y > this->acs->fill_y)) this->fill_y = this->acs->fill_y;
1632  this->fill_y = LeastCommonMultiple(this->fill_y, this->inf->fill_y);
1633 
1634  /* Resizing. */
1635  this->resize_x = LeastCommonMultiple(this->avs->resize_x, this->acs->resize_x);
1636  if (this->inf->resize_x > 0 && (this->resize_x == 0 || this->resize_x > this->inf->resize_x)) this->resize_x = this->inf->resize_x;
1637 
1638  this->resize_y = this->avs->resize_y;
1639  if (this->acs->resize_y > 0 && (this->resize_y == 0 || this->resize_y > this->acs->resize_y)) this->resize_y = this->acs->resize_y;
1640  this->resize_y = LeastCommonMultiple(this->resize_y, this->inf->resize_y);
1641 
1642  /* Make sure the height suits the 3 column (resp. not-editable) format; the 2 column format can easily fill space between the lists */
1643  this->smallest_y = ComputeMaxSize(min_acs_height, this->smallest_y + this->resize_y - 1, this->resize_y);
1644  }
1645 
1646  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
1647  {
1648  this->StoreSizePosition(sizing, x, y, given_width, given_height);
1649 
1650  uint min_avs_width = this->avs->smallest_x + this->avs->padding_left + this->avs->padding_right;
1651  uint min_acs_width = this->acs->smallest_x + this->acs->padding_left + this->acs->padding_right;
1652  uint min_inf_width = this->inf->smallest_x + this->inf->padding_left + this->inf->padding_right;
1653 
1654  uint min_list_width = std::max(min_avs_width, min_acs_width); // Smallest width of the lists such that they have equal width (incl padding).
1655  uint avs_extra_width = min_list_width - min_avs_width; // Additional width needed for avs to reach min_list_width.
1656  uint acs_extra_width = min_list_width - min_acs_width; // Additional width needed for acs to reach min_list_width.
1657 
1658  /* Use 2 or 3 columns? */
1659  uint min_three_columns = min_avs_width + min_acs_width + min_inf_width + 2 * INTER_COLUMN_SPACING;
1660  uint min_two_columns = min_list_width + min_inf_width + INTER_COLUMN_SPACING;
1661  bool use_three_columns = this->editable && (min_three_columns + MIN_EXTRA_FOR_3_COLUMNS <= given_width);
1662 
1663  /* Info panel is a separate column in both modes. Compute its width first. */
1664  uint extra_width, inf_width;
1665  if (use_three_columns) {
1666  extra_width = given_width - min_three_columns;
1667  inf_width = std::min(MAX_EXTRA_INFO_WIDTH, extra_width / 2);
1668  } else {
1669  extra_width = given_width - min_two_columns;
1670  inf_width = std::min(MAX_EXTRA_INFO_WIDTH, extra_width / 2);
1671  }
1672  inf_width = ComputeMaxSize(this->inf->smallest_x, this->inf->smallest_x + inf_width, this->inf->GetHorizontalStepSize(sizing));
1673  extra_width -= inf_width - this->inf->smallest_x;
1674 
1675  uint inf_height = ComputeMaxSize(this->inf->smallest_y, given_height, this->inf->GetVerticalStepSize(sizing));
1676 
1677  if (use_three_columns) {
1678  /* Three column display, first make both lists equally wide, then divide whatever is left between both lists.
1679  * Only keep track of what avs gets, all other space goes to acs. */
1680  uint avs_width = std::min(avs_extra_width, extra_width);
1681  extra_width -= avs_width;
1682  extra_width -= std::min(acs_extra_width, extra_width);
1683  avs_width += extra_width / 2;
1684 
1685  avs_width = ComputeMaxSize(this->avs->smallest_x, this->avs->smallest_x + avs_width, this->avs->GetHorizontalStepSize(sizing));
1686 
1687  uint acs_width = given_width - // Remaining space, including horizontal padding.
1688  inf_width - this->inf->padding_left - this->inf->padding_right -
1689  avs_width - this->avs->padding_left - this->avs->padding_right - 2 * INTER_COLUMN_SPACING;
1690  acs_width = ComputeMaxSize(min_acs_width, acs_width, this->acs->GetHorizontalStepSize(sizing)) -
1691  this->acs->padding_left - this->acs->padding_right;
1692 
1693  /* Never use fill_y on these; the minimal size is chosen, so that the 3 column view looks nice */
1694  uint avs_height = ComputeMaxSize(this->avs->smallest_y, given_height, this->avs->resize_y);
1695  uint acs_height = ComputeMaxSize(this->acs->smallest_y, given_height, this->acs->resize_y);
1696 
1697  /* Assign size and position to the children. */
1698  if (rtl) {
1699  x += this->inf->padding_left;
1700  this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
1701  x += inf_width + this->inf->padding_right + INTER_COLUMN_SPACING;
1702  } else {
1703  x += this->avs->padding_left;
1704  this->avs->AssignSizePosition(sizing, x, y + this->avs->padding_top, avs_width, avs_height, rtl);
1705  x += avs_width + this->avs->padding_right + INTER_COLUMN_SPACING;
1706  }
1707 
1708  x += this->acs->padding_left;
1709  this->acs->AssignSizePosition(sizing, x, y + this->acs->padding_top, acs_width, acs_height, rtl);
1710  x += acs_width + this->acs->padding_right + INTER_COLUMN_SPACING;
1711 
1712  if (rtl) {
1713  x += this->avs->padding_left;
1714  this->avs->AssignSizePosition(sizing, x, y + this->avs->padding_top, avs_width, avs_height, rtl);
1715  } else {
1716  x += this->inf->padding_left;
1717  this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
1718  }
1719  } else {
1720  /* Two columns, all space in extra_width goes to both lists. Since the lists are underneath each other,
1721  * the column is min_list_width wide at least. */
1722  uint avs_width = ComputeMaxSize(this->avs->smallest_x, this->avs->smallest_x + avs_extra_width + extra_width,
1723  this->avs->GetHorizontalStepSize(sizing));
1724  uint acs_width = ComputeMaxSize(this->acs->smallest_x, this->acs->smallest_x + acs_extra_width + extra_width,
1725  this->acs->GetHorizontalStepSize(sizing));
1726 
1727  uint min_avs_height = (!this->editable) ? 0 : this->avs->smallest_y + this->avs->padding_top + this->avs->padding_bottom + INTER_LIST_SPACING;
1728  uint min_acs_height = this->acs->smallest_y + this->acs->padding_top + this->acs->padding_bottom;
1729  uint extra_height = given_height - min_acs_height - min_avs_height;
1730 
1731  /* Never use fill_y on these; instead use the INTER_LIST_SPACING as filler */
1732  uint avs_height = ComputeMaxSize(this->avs->smallest_y, this->avs->smallest_y + extra_height / 2, this->avs->resize_y);
1733  if (this->editable) extra_height -= avs_height - this->avs->smallest_y;
1734  uint acs_height = ComputeMaxSize(this->acs->smallest_y, this->acs->smallest_y + extra_height, this->acs->resize_y);
1735 
1736  /* Assign size and position to the children. */
1737  if (rtl) {
1738  x += this->inf->padding_left;
1739  this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
1740  x += inf_width + this->inf->padding_right + INTER_COLUMN_SPACING;
1741 
1742  this->acs->AssignSizePosition(sizing, x + this->acs->padding_left, y + this->acs->padding_top, acs_width, acs_height, rtl);
1743  if (this->editable) {
1744  this->avs->AssignSizePosition(sizing, x + this->avs->padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
1745  } else {
1746  this->avs->AssignSizePosition(sizing, 0, 0, this->avs->smallest_x, this->avs->smallest_y, rtl);
1747  }
1748  } else {
1749  this->acs->AssignSizePosition(sizing, x + this->acs->padding_left, y + this->acs->padding_top, acs_width, acs_height, rtl);
1750  if (this->editable) {
1751  this->avs->AssignSizePosition(sizing, x + this->avs->padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
1752  } else {
1753  this->avs->AssignSizePosition(sizing, 0, 0, this->avs->smallest_x, this->avs->smallest_y, rtl);
1754  }
1755  uint dx = this->acs->current_x + this->acs->padding_left + this->acs->padding_right;
1756  if (this->editable) {
1757  dx = std::max(dx, this->avs->current_x + this->avs->padding_left + this->avs->padding_right);
1758  }
1759  x += dx + INTER_COLUMN_SPACING + this->inf->padding_left;
1760  this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
1761  }
1762  }
1763  }
1764 
1765  NWidgetCore *GetWidgetFromPos(int x, int y) override
1766  {
1767  if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return nullptr;
1768 
1769  NWidgetCore *nw = (this->editable) ? this->avs->GetWidgetFromPos(x, y) : nullptr;
1770  if (nw == nullptr) nw = this->acs->GetWidgetFromPos(x, y);
1771  if (nw == nullptr) nw = this->inf->GetWidgetFromPos(x, y);
1772  return nw;
1773  }
1774 
1775  void Draw(const Window *w) override
1776  {
1777  if (this->editable) this->avs->Draw(w);
1778  this->acs->Draw(w);
1779  this->inf->Draw(w);
1780  }
1781 };
1782 
1787 
1788 static const NWidgetPart _nested_newgrf_actives_widgets[] = {
1789  /* Left side, presets. */
1791  NWidget(WWT_TEXT, COLOUR_MAUVE), SetDataTip(STR_NEWGRF_SETTINGS_SELECT_PRESET, STR_NULL),
1792  SetPadding(0, WD_FRAMETEXT_RIGHT, 0, 0),
1793  NWidget(WWT_DROPDOWN, COLOUR_YELLOW, WID_NS_PRESET_LIST), SetFill(1, 0), SetResize(1, 0),
1794  SetDataTip(STR_JUST_STRING, STR_NEWGRF_SETTINGS_PRESET_LIST_TOOLTIP),
1795  EndContainer(),
1797  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_PRESET_SAVE), SetFill(1, 0), SetResize(1, 0),
1798  SetDataTip(STR_NEWGRF_SETTINGS_PRESET_SAVE, STR_NEWGRF_SETTINGS_PRESET_SAVE_TOOLTIP),
1799  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_PRESET_DELETE), SetFill(1, 0), SetResize(1, 0),
1800  SetDataTip(STR_NEWGRF_SETTINGS_PRESET_DELETE, STR_NEWGRF_SETTINGS_PRESET_DELETE_TOOLTIP),
1801  EndContainer(),
1802 
1804  NWidget(WWT_PANEL, COLOUR_MAUVE),
1805  NWidget(WWT_LABEL, COLOUR_MAUVE), SetDataTip(STR_NEWGRF_SETTINGS_ACTIVE_LIST, STR_NULL),
1807  /* Left side, active grfs. */
1808  NWidget(NWID_HORIZONTAL), SetPadding(0, 2, 0, 2),
1809  NWidget(WWT_PANEL, COLOUR_MAUVE),
1810  NWidget(WWT_INSET, COLOUR_MAUVE, WID_NS_FILE_LIST), SetMinimalSize(100, 1), SetPadding(2, 2, 2, 2),
1811  SetFill(1, 1), SetResize(1, 1), SetScrollbar(WID_NS_SCROLLBAR), SetDataTip(STR_NULL, STR_NEWGRF_SETTINGS_FILE_TOOLTIP),
1812  EndContainer(),
1813  EndContainer(),
1814  NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_NS_SCROLLBAR),
1815  EndContainer(),
1816  /* Buttons. */
1817  NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NS_SHOW_REMOVE),
1819  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_REMOVE), SetFill(1, 0), SetResize(1, 0),
1820  SetDataTip(STR_NEWGRF_SETTINGS_REMOVE, STR_NEWGRF_SETTINGS_REMOVE_TOOLTIP),
1822  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_MOVE_UP), SetFill(1, 0), SetResize(1, 0),
1823  SetDataTip(STR_NEWGRF_SETTINGS_MOVEUP, STR_NEWGRF_SETTINGS_MOVEUP_TOOLTIP),
1824  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_MOVE_DOWN), SetFill(1, 0), SetResize(1, 0),
1825  SetDataTip(STR_NEWGRF_SETTINGS_MOVEDOWN, STR_NEWGRF_SETTINGS_MOVEDOWN_TOOLTIP),
1826  EndContainer(),
1827  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_UPGRADE), SetFill(1, 0), SetResize(1, 0),
1828  SetDataTip(STR_NEWGRF_SETTINGS_UPGRADE, STR_NEWGRF_SETTINGS_UPGRADE_TOOLTIP),
1829  EndContainer(),
1830 
1832  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_RESCAN_FILES2), SetFill(1, 0), SetResize(1, 0),
1833  SetDataTip(STR_NEWGRF_SETTINGS_RESCAN_FILES, STR_NEWGRF_SETTINGS_RESCAN_FILES_TOOLTIP),
1834  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_CONTENT_DOWNLOAD2), SetFill(1, 0), SetResize(1, 0),
1835  SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
1836  EndContainer(),
1837  EndContainer(),
1838  EndContainer(),
1839 };
1840 
1841 static const NWidgetPart _nested_newgrf_availables_widgets[] = {
1842  NWidget(WWT_PANEL, COLOUR_MAUVE),
1843  NWidget(WWT_LABEL, COLOUR_MAUVE), SetDataTip(STR_NEWGRF_SETTINGS_INACTIVE_LIST, STR_NULL),
1845  /* Left side, available grfs, filter edit box. */
1848  NWidget(WWT_TEXT, COLOUR_MAUVE), SetFill(0, 1), SetDataTip(STR_NEWGRF_FILTER_TITLE, STR_NULL),
1849  NWidget(WWT_EDITBOX, COLOUR_MAUVE, WID_NS_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0),
1850  SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1851  EndContainer(),
1852  /* Left side, available grfs. */
1853  NWidget(NWID_HORIZONTAL), SetPadding(0, 2, 0, 2),
1854  NWidget(WWT_PANEL, COLOUR_MAUVE),
1855  NWidget(WWT_INSET, COLOUR_MAUVE, WID_NS_AVAIL_LIST), SetMinimalSize(100, 1), SetPadding(2, 2, 2, 2),
1857  EndContainer(),
1858  EndContainer(),
1859  NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_NS_SCROLL2BAR),
1860  EndContainer(),
1861  /* Left side, available grfs, buttons. */
1863  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_ADD), SetFill(1, 0), SetResize(1, 0),
1864  SetDataTip(STR_NEWGRF_SETTINGS_ADD, STR_NEWGRF_SETTINGS_ADD_FILE_TOOLTIP),
1866  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_RESCAN_FILES), SetFill(1, 0), SetResize(1, 0),
1867  SetDataTip(STR_NEWGRF_SETTINGS_RESCAN_FILES, STR_NEWGRF_SETTINGS_RESCAN_FILES_TOOLTIP),
1868  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_CONTENT_DOWNLOAD), SetFill(1, 0), SetResize(1, 0),
1869  SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
1870  EndContainer(),
1871  EndContainer(),
1872  EndContainer(),
1873 };
1874 
1875 static const NWidgetPart _nested_newgrf_infopanel_widgets[] = {
1876  /* Right side, info panel. */
1877  NWidget(NWID_VERTICAL), SetPadding(0, 0, 2, 0),
1878  NWidget(WWT_PANEL, COLOUR_MAUVE), SetPadding(0, 0, 2, 0),
1879  NWidget(WWT_EMPTY, COLOUR_MAUVE, WID_NS_NEWGRF_INFO_TITLE), SetFill(1, 0), SetResize(1, 0),
1880  NWidget(WWT_EMPTY, COLOUR_MAUVE, WID_NS_NEWGRF_INFO), SetFill(1, 1), SetResize(1, 1), SetMinimalSize(150, 100),
1881  EndContainer(),
1882  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_OPEN_URL), SetFill(1, 0), SetResize(1, 0),
1883  SetDataTip(STR_CONTENT_OPEN_URL, STR_CONTENT_OPEN_URL_TOOLTIP),
1884  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_NEWGRF_TEXTFILE + TFT_README), SetFill(1, 0), SetResize(1, 0),
1885  SetDataTip(STR_TEXTFILE_VIEW_README, STR_NULL),
1888  SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_NULL),
1889  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_NEWGRF_TEXTFILE + TFT_LICENSE), SetFill(1, 0), SetResize(1, 0),
1890  SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_NULL),
1891  EndContainer(),
1892  EndContainer(),
1893  NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NS_SHOW_APPLY),
1894  /* Right side, buttons. */
1897  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_SET_PARAMETERS), SetFill(1, 0), SetResize(1, 0),
1898  SetDataTip(STR_NEWGRF_SETTINGS_SET_PARAMETERS, STR_NULL),
1899  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_TOGGLE_PALETTE), SetFill(1, 0), SetResize(1, 0),
1900  SetDataTip(STR_NEWGRF_SETTINGS_TOGGLE_PALETTE, STR_NEWGRF_SETTINGS_TOGGLE_PALETTE_TOOLTIP),
1901  EndContainer(),
1902  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_APPLY_CHANGES), SetFill(1, 0), SetResize(1, 0),
1903  SetDataTip(STR_NEWGRF_SETTINGS_APPLY_CHANGES, STR_NULL),
1904  EndContainer(),
1905  NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_VIEW_PARAMETERS), SetFill(1, 0), SetResize(1, 0),
1906  SetDataTip(STR_NEWGRF_SETTINGS_SHOW_PARAMETERS, STR_NULL),
1907  EndContainer(),
1908 };
1909 
1911 NWidgetBase* NewGRFDisplay(int *biggest_index)
1912 {
1913  NWidgetBase *avs = MakeNWidgets(_nested_newgrf_availables_widgets, lengthof(_nested_newgrf_availables_widgets), biggest_index, nullptr);
1914 
1915  int biggest2;
1916  NWidgetBase *acs = MakeNWidgets(_nested_newgrf_actives_widgets, lengthof(_nested_newgrf_actives_widgets), &biggest2, nullptr);
1917  *biggest_index = std::max(*biggest_index, biggest2);
1918 
1919  NWidgetBase *inf = MakeNWidgets(_nested_newgrf_infopanel_widgets, lengthof(_nested_newgrf_infopanel_widgets), &biggest2, nullptr);
1920  *biggest_index = std::max(*biggest_index, biggest2);
1921 
1922  return new NWidgetNewGRFDisplay(avs, acs, inf);
1923 }
1924 
1925 /* Widget definition of the manage newgrfs window */
1926 static const NWidgetPart _nested_newgrf_widgets[] = {
1928  NWidget(WWT_CLOSEBOX, COLOUR_MAUVE),
1929  NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_NEWGRF_SETTINGS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1930  NWidget(WWT_DEFSIZEBOX, COLOUR_MAUVE),
1931  EndContainer(),
1932  NWidget(WWT_PANEL, COLOUR_MAUVE),
1934  /* Resize button. */
1936  NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
1937  NWidget(WWT_RESIZEBOX, COLOUR_MAUVE),
1938  EndContainer(),
1939  EndContainer(),
1940 };
1941 
1942 /* Window definition of the manage newgrfs window */
1943 static WindowDesc _newgrf_desc(
1944  WDP_CENTER, "settings_newgrf", 300, 263,
1946  0,
1947  _nested_newgrf_widgets, lengthof(_nested_newgrf_widgets)
1948 );
1949 
1955 static void NewGRFConfirmationCallback(Window *w, bool confirmed)
1956 {
1957  if (confirmed) {
1960  NewGRFWindow *nw = dynamic_cast<NewGRFWindow*>(w);
1961 
1963  GamelogGRFUpdate(_grfconfig, nw->actives); // log GRF changes
1964  CopyGRFConfigList(nw->orig_list, nw->actives, false);
1965  ReloadNewGRFData();
1967 
1968  /* Show new, updated list */
1969  GRFConfig *c;
1970  int i = 0;
1971  for (c = nw->actives; c != nullptr && c != nw->active_sel; c = c->next, i++) {}
1972  CopyGRFConfigList(&nw->actives, *nw->orig_list, false);
1973  for (c = nw->actives; c != nullptr && i > 0; c = c->next, i--) {}
1974  nw->active_sel = c;
1975  nw->avails.ForceRebuild();
1976  nw->modified = false;
1977 
1978  w->InvalidateData();
1979 
1980  ReInitAllWindows(false);
1982  }
1983 }
1984 
1985 
1986 
1995 void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
1996 {
1998  new NewGRFWindow(&_newgrf_desc, editable, show_params, exec_changes, config);
1999 }
2000 
2004  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
2005  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_SAVE_PRESET_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
2006  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
2007  EndContainer(),
2008  NWidget(WWT_PANEL, COLOUR_GREY),
2010  NWidget(WWT_INSET, COLOUR_GREY, WID_SVP_PRESET_LIST), SetPadding(2, 1, 0, 2),
2011  SetDataTip(0x0, STR_SAVE_PRESET_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(WID_SVP_SCROLLBAR), EndContainer(),
2012  NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SVP_SCROLLBAR),
2013  EndContainer(),
2014  NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SVP_EDITBOX), SetPadding(3, 2, 2, 2), SetFill(1, 0), SetResize(1, 0),
2015  SetDataTip(STR_SAVE_PRESET_TITLE, STR_SAVE_PRESET_EDITBOX_TOOLTIP),
2016  EndContainer(),
2018  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SVP_CANCEL), SetDataTip(STR_SAVE_PRESET_CANCEL, STR_SAVE_PRESET_CANCEL_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
2019  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SVP_SAVE), SetDataTip(STR_SAVE_PRESET_SAVE, STR_SAVE_PRESET_SAVE_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
2020  NWidget(WWT_RESIZEBOX, COLOUR_GREY),
2021  EndContainer(),
2022 };
2023 
2026  WDP_CENTER, "save_preset", 140, 110,
2028  WDF_MODAL,
2030 );
2031 
2033 struct SavePresetWindow : public Window {
2037  int selected;
2038 
2044  {
2045  this->presets = GetGRFPresetList();
2046  this->selected = -1;
2047  if (initial_text != nullptr) {
2048  for (uint i = 0; i < this->presets.size(); i++) {
2049  if (this->presets[i] == initial_text) {
2050  this->selected = i;
2051  break;
2052  }
2053  }
2054  }
2055 
2057  this->presetname_editbox.ok_button = WID_SVP_SAVE;
2058  this->presetname_editbox.cancel_button = WID_SVP_CANCEL;
2059 
2060  this->CreateNestedTree();
2061  this->vscroll = this->GetScrollbar(WID_SVP_SCROLLBAR);
2062  this->FinishInitNested(0);
2063 
2064  this->vscroll->SetCount((uint)this->presets.size());
2066  if (initial_text != nullptr) this->presetname_editbox.text.Assign(initial_text);
2067  }
2068 
2069  ~SavePresetWindow()
2070  {
2071  }
2072 
2073  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
2074  {
2075  switch (widget) {
2076  case WID_SVP_PRESET_LIST: {
2077  resize->height = FONT_HEIGHT_NORMAL + 2U;
2078  size->height = 0;
2079  for (uint i = 0; i < this->presets.size(); i++) {
2080  Dimension d = GetStringBoundingBox(this->presets[i].c_str());
2081  size->width = std::max(size->width, d.width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT);
2082  resize->height = std::max(resize->height, d.height);
2083  }
2084  size->height = ClampU((uint)this->presets.size(), 5, 20) * resize->height + 1;
2085  break;
2086  }
2087  }
2088  }
2089 
2090  void DrawWidget(const Rect &r, int widget) const override
2091  {
2092  switch (widget) {
2093  case WID_SVP_PRESET_LIST: {
2094  GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK);
2095 
2096  uint step_height = this->GetWidget<NWidgetBase>(WID_SVP_PRESET_LIST)->resize_y;
2097  int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
2098  uint y = r.top + WD_FRAMERECT_TOP;
2099  uint min_index = this->vscroll->GetPosition();
2100  uint max_index = std::min(min_index + this->vscroll->GetCapacity(), (uint)this->presets.size());
2101 
2102  for (uint i = min_index; i < max_index; i++) {
2103  if ((int)i == this->selected) GfxFillRect(r.left + 1, y, r.right - 1, y + step_height - 2, PC_DARK_BLUE);
2104 
2105  const char *text = this->presets[i].c_str();
2106  DrawString(r.left + WD_FRAMERECT_LEFT, r.right, y + offset_y, text, ((int)i == this->selected) ? TC_WHITE : TC_SILVER);
2107  y += step_height;
2108  }
2109  break;
2110  }
2111  }
2112  }
2113 
2114  void OnClick(Point pt, int widget, int click_count) override
2115  {
2116  switch (widget) {
2117  case WID_SVP_PRESET_LIST: {
2118  uint row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SVP_PRESET_LIST);
2119  if (row < this->presets.size()) {
2120  this->selected = row;
2121  this->presetname_editbox.text.Assign(this->presets[row].c_str());
2124  }
2125  break;
2126  }
2127 
2128  case WID_SVP_CANCEL:
2129  this->Close();
2130  break;
2131 
2132  case WID_SVP_SAVE: {
2134  if (w != nullptr && !StrEmpty(this->presetname_editbox.text.buf)) w->OnQueryTextFinished(this->presetname_editbox.text.buf);
2135  this->Close();
2136  break;
2137  }
2138  }
2139  }
2140 
2141  void OnResize() override
2142  {
2143  this->vscroll->SetCapacityFromWidget(this, WID_SVP_PRESET_LIST);
2144  }
2145 };
2146 
2151 static void ShowSavePresetWindow(const char *initial_text)
2152 {
2154  new SavePresetWindow(initial_text);
2155 }
2156 
2159  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_NEWGRF_SCAN_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
2160  NWidget(WWT_PANEL, COLOUR_GREY),
2161  NWidget(NWID_HORIZONTAL), SetPIP(20, 0, 20),
2162  NWidget(NWID_VERTICAL), SetPIP(11, 8, 11),
2163  NWidget(WWT_LABEL, INVALID_COLOUR), SetDataTip(STR_NEWGRF_SCAN_MESSAGE, STR_NULL), SetFill(1, 0),
2164  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SP_PROGRESS_BAR), SetFill(1, 0),
2165  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SP_PROGRESS_TEXT), SetFill(1, 0),
2166  EndContainer(),
2167  EndContainer(),
2168  EndContainer(),
2169 };
2170 
2173  WDP_CENTER, nullptr, 0, 0,
2175  0,
2177 );
2178 
2180 struct ScanProgressWindow : public Window {
2181  char *last_name;
2182  int scanned;
2183 
2186  {
2187  this->InitNested(1);
2188  }
2189 
2192  {
2193  free(last_name);
2194  }
2195 
2196  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
2197  {
2198  switch (widget) {
2199  case WID_SP_PROGRESS_BAR: {
2200  SetDParamMaxValue(0, 100);
2201  *size = GetStringBoundingBox(STR_GENERATION_PROGRESS);
2202  /* We need some spacing for the 'border' */
2203  size->height += 8;
2204  size->width += 8;
2205  break;
2206  }
2207 
2208  case WID_SP_PROGRESS_TEXT:
2209  SetDParamMaxDigits(0, 4);
2210  SetDParamMaxDigits(1, 4);
2211  /* We really don't know the width. We could determine it by scanning the NewGRFs,
2212  * but this is the status window for scanning them... */
2213  size->width = std::max(400U, GetStringBoundingBox(STR_NEWGRF_SCAN_STATUS).width);
2214  size->height = FONT_HEIGHT_NORMAL * 2 + WD_PAR_VSEP_NORMAL;
2215  break;
2216  }
2217  }
2218 
2219  void DrawWidget(const Rect &r, int widget) const override
2220  {
2221  switch (widget) {
2222  case WID_SP_PROGRESS_BAR: {
2223  /* Draw the % complete with a bar and a text */
2224  DrawFrameRect(r.left, r.top, r.right, r.bottom, COLOUR_GREY, FR_BORDERONLY);
2225  uint percent = scanned * 100 / std::max(1U, _settings_client.gui.last_newgrf_count);
2226  DrawFrameRect(r.left + 1, r.top + 1, (int)((r.right - r.left - 2) * percent / 100) + r.left + 1, r.bottom - 1, COLOUR_MAUVE, FR_NONE);
2227  SetDParam(0, percent);
2228  DrawString(r.left, r.right, r.top + 5, STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
2229  break;
2230  }
2231 
2232  case WID_SP_PROGRESS_TEXT:
2233  SetDParam(0, this->scanned);
2235  DrawString(r.left, r.right, r.top, STR_NEWGRF_SCAN_STATUS, TC_FROMSTRING, SA_HOR_CENTER);
2236 
2237  DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL, this->last_name == nullptr ? "" : this->last_name, TC_BLACK, SA_HOR_CENTER);
2238  break;
2239  }
2240  }
2241 
2247  void UpdateNewGRFScanStatus(uint num, const char *name)
2248  {
2249  free(this->last_name);
2250  if (name == nullptr) {
2251  char buf[256];
2252  GetString(buf, STR_NEWGRF_SCAN_ARCHIVES, lastof(buf));
2253  this->last_name = stredup(buf);
2254  } else {
2255  this->last_name = stredup(name);
2256  }
2257  this->scanned = num;
2259 
2260  this->SetDirty();
2261  }
2262 };
2263 
2269 void UpdateNewGRFScanStatus(uint num, const char *name)
2270 {
2272  if (w == nullptr) w = new ScanProgressWindow();
2273  w->UpdateNewGRFScanStatus(num, name);
2274 }
GRFConfig::version
uint32 version
NOSAVE: Version a NewGRF can set so only the newest NewGRF is shown.
Definition: newgrf_config.h:171
NewGRFParametersWindow::OnDropdownClose
void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
A dropdown window associated to this window has been closed.
Definition: newgrf_gui.cpp:452
NewGRFWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: newgrf_gui.cpp:1213
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:718
network_content.h
GRFP_USE_MASK
@ GRFP_USE_MASK
Bitmask to get only the use palette use states.
Definition: newgrf_config.h:68
NewGRFWindow::AddGRFToActive
bool AddGRFToActive(int ins_pos=-1)
Insert a GRF into the active list.
Definition: newgrf_gui.cpp:1496
_save_preset_desc
static WindowDesc _save_preset_desc(WDP_CENTER, "save_preset", 140, 110, WC_SAVE_PRESET, WC_GAME_OPTIONS, WDF_MODAL, _nested_save_preset_widgets, lengthof(_nested_save_preset_widgets))
Window description of the preset save window.
WD_FRAMERECT_TOP
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:64
GRFConfig::num_valid_params
uint8 num_valid_params
NOSAVE: Number of valid parameters (action 0x14)
Definition: newgrf_config.h:178
ScanProgressWindow::~ScanProgressWindow
~ScanProgressWindow()
Free the last name buffer.
Definition: newgrf_gui.cpp:2191
ContentInfo::name
std::string name
Name of the content.
Definition: tcp_content_type.h:65
NewGRFWindow::string_filter
StringFilter string_filter
Filter for available grf.
Definition: newgrf_gui.cpp:605
WID_NS_SCROLLBAR
@ WID_NS_SCROLLBAR
Scrollbar for active NewGRF list.
Definition: newgrf_widget.h:43
NWidgetFunction
static NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition: widget_type.h:1239
ComputeMaxSize
static uint ComputeMaxSize(uint base, uint max_space, uint step)
Return the biggest possible size of a nested widget.
Definition: widget_type.h:843
GRFIdentifier::HasGrfIdentifier
bool HasGrfIdentifier(uint32 grfid, const uint8 *md5sum) const
Does the identification match the provided values?
Definition: newgrf_config.h:103
TextfileWindow::LoadTextfile
virtual void LoadTextfile(const char *textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
Definition: textfile_gui.cpp:340
NWidgetNewGRFDisplay::MAX_EXTRA_INFO_WIDTH
static const uint MAX_EXTRA_INFO_WIDTH
Maximal additional width given to the panel.
Definition: newgrf_gui.cpp:1582
QueryString::ok_button
int ok_button
Widget button of parent window to simulate when pressing OK in OSK.
Definition: querystring_gui.h:27
ContentInfo::type
ContentType type
Type of content.
Definition: tcp_content_type.h:61
GRFConfig::error
GRFError * error
NOSAVE: Error/Warning during GRF loading (Action 0x0B)
Definition: newgrf_config.h:169
GOID_NEWGRF_CHANGES_MADE
@ GOID_NEWGRF_CHANGES_MADE
Changes have been made to a given NewGRF either through the palette or its parameters.
Definition: window_type.h:707
GLAT_GRF
@ GLAT_GRF
GRF changed.
Definition: gamelog.h:19
WChar
char32_t WChar
Type for wide characters, i.e.
Definition: string_type.h:35
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3120
querystring_gui.h
ReloadNewGRFData
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
Definition: afterload.cpp:3182
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1188
ScanProgressWindow
Window for showing the progress of NewGRF scanning.
Definition: newgrf_gui.cpp:2180
GUISettings::newgrf_developer_tools
bool newgrf_developer_tools
activate NewGRF developer tools and allow modifying NewGRFs in an existing game
Definition: settings_type.h:186
NewGRFWindow::OnNewGRFsScanned
void OnNewGRFsScanned() override
Called whenever the NewGRF scan completed.
Definition: newgrf_gui.cpp:1148
NewGRFWindow::OnKeyPress
EventState OnKeyPress(WChar key, uint16 keycode) override
A key has been pressed.
Definition: newgrf_gui.cpp:1326
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
NewGRFParametersWindow::GetDummyParameterInfo
static GRFParameterInfo * GetDummyParameterInfo(uint nr)
Get a dummy parameter-info object with default information.
Definition: newgrf_gui.cpp:189
Scrollbar::GetCapacity
uint16 GetCapacity() const
Gets the number of visible elements of the scrollbar.
Definition: widget_type.h:662
GRFError::custom_message
std::string custom_message
Custom message (if present)
Definition: newgrf_config.h:119
FindGRFConfig
const GRFConfig * FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8 *md5sum, uint32 desired_version)
Find a NewGRF in the scanned list.
Definition: newgrf_config.cpp:736
GCS_ACTIVATED
@ GCS_ACTIVATED
GRF file has been activated.
Definition: newgrf_config.h:39
SetPadding
static NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1139
GUIList::Sort
bool Sort(Comp compare)
Sort the list.
Definition: sortlist_type.h:247
Window::GetScrollbar
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:320
dropdown_func.h
ClearGRFConfigList
void ClearGRFConfigList(GRFConfig **config)
Clear a GRF Config list, freeing all nodes.
Definition: newgrf_config.cpp:400
StringFilter::IsEmpty
bool IsEmpty() const
Check whether any filter words were entered.
Definition: stringfilter_type.h:59
WID_NS_TOGGLE_PALETTE
@ WID_NS_TOGGLE_PALETTE
Toggle Palette of selected, active NewGRF.
Definition: newgrf_widget.h:52
NWidgetNewGRFDisplay::avs
NWidgetBase * avs
Widget with the available grfs list and buttons.
Definition: newgrf_gui.cpp:1585
guitimer_func.h
ContentInfo::DOES_NOT_EXIST
@ DOES_NOT_EXIST
The content does not exist in the content system.
Definition: tcp_content_type.h:57
NWidgetContainer::Add
void Add(NWidgetBase *wid)
Append widget wid to container.
Definition: widget.cpp:1047
StringFilter::SetFilterTerm
void SetFilterTerm(const char *str)
Set the term to filter on.
Definition: stringfilter.cpp:27
WD_MATRIX_TOP
@ WD_MATRIX_TOP
Offset at top of a matrix cell.
Definition: window_gui.h:80
SavePresetWindow
Class for the save preset window.
Definition: newgrf_gui.cpp:2033
Scrollbar::ScrollTowards
void ScrollTowards(int position)
Scroll towards the given position; if the item is visible nothing happens, otherwise it will be shown...
Definition: widget_type.h:775
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
UpdateNewGRFScanStatus
void UpdateNewGRFScanStatus(uint num, const char *name)
Update the NewGRF scan status.
Definition: newgrf_gui.cpp:2269
ShowSavePresetWindow
static void ShowSavePresetWindow(const char *initial_text)
Open the window for saving a preset.
Definition: newgrf_gui.cpp:2151
GRFConfig::num_params
uint8 num_params
Number of used parameters.
Definition: newgrf_config.h:177
NWidgetBase::GetHorizontalStepSize
uint GetHorizontalStepSize(SizingType sizing) const
Get the horizontal sizing step.
Definition: widget_type.h:213
GUIList< const GRFConfig *, StringFilter & >
Textbuf::Assign
void Assign(StringID string)
Render a string into the textbuffer.
Definition: textbuf.cpp:396
WID_NS_PRESET_LIST
@ WID_NS_PRESET_LIST
Active NewGRF preset.
Definition: newgrf_widget.h:33
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:55
NWidgetNewGRFDisplay::Draw
void Draw(const Window *w) override
Definition: newgrf_gui.cpp:1775
DropDownList
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
Definition: dropdown_type.h:99
GrfIdMap
std::map< uint32, const GRFConfig * > GrfIdMap
Map of grfid to the grf config.
Definition: newgrf_gui.cpp:570
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:63
NWidgetNewGRFDisplay::acs
NWidgetBase * acs
Widget with the active grfs list and buttons.
Definition: newgrf_gui.cpp:1586
Window::CreateNestedTree
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1760
_all_grfs
GRFConfig * _all_grfs
First item in list of all scanned NewGRFs.
Definition: newgrf_config.cpp:170
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
DropDownListCharStringItem
List item containing a C char string.
Definition: dropdown_type.h:70
ShowNetworkContentListWindow
void ShowNetworkContentListWindow(ContentVector *cv=nullptr, ContentType type1=CONTENT_TYPE_END, ContentType type2=CONTENT_TYPE_END)
Show the content list window with a given set of content.
Definition: network_content_gui.cpp:1113
NewGRFWindow
Window for showing NewGRF files.
Definition: newgrf_gui.cpp:592
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
WID_NS_PRESET_DELETE
@ WID_NS_PRESET_DELETE
Delete active preset.
Definition: newgrf_widget.h:35
_nested_save_preset_widgets
static const NWidgetPart _nested_save_preset_widgets[]
Widget parts of the save preset window.
Definition: newgrf_gui.cpp:2002
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:57
CONTENT_TYPE_NEWGRF
@ CONTENT_TYPE_NEWGRF
The content consists of a NewGRF.
Definition: tcp_content_type.h:19
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1146
ClampU
static uint ClampU(const uint a, const uint min, const uint max)
Clamp an unsigned integer between an interval.
Definition: math_func.hpp:122
ContentVector
std::vector< ContentInfo * > ContentVector
Vector with content info.
Definition: network_content.h:17
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
ShowMissingContentWindow
void ShowMissingContentWindow(const GRFConfig *list)
Show the content list window with all missing grfs from the given list.
Definition: newgrf_gui.cpp:1543
SavePresetWindow::SavePresetWindow
SavePresetWindow(const char *initial_text)
Constructor of the save preset window.
Definition: newgrf_gui.cpp:2043
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:710
GRFParameterInfo::SetValue
void SetValue(struct GRFConfig *config, uint32 value)
Set the value of this user-changeable parameter in the given config.
Definition: newgrf_config.cpp:256
GRFParameterInfo::param_nr
byte param_nr
GRF parameter to store content in.
Definition: newgrf_config.h:143
NewGRFWindow::filter_funcs
static GUIGRFConfigList::FilterFunction *const filter_funcs[]
Filter functions of the #GUIGRFConfigList.
Definition: newgrf_gui.cpp:600
NewGRFWindow::modified
bool modified
The list of active NewGRFs has been modified since the last time they got saved.
Definition: newgrf_gui.cpp:619
GRFError::severity
StringID severity
Info / Warning / Error / Fatal.
Definition: newgrf_config.h:122
NewGRFWindow::actives
GRFConfig * actives
Temporary active grf list to which changes are made.
Definition: newgrf_gui.cpp:610
RequestNewGRFScan
bool RequestNewGRFScan(NewGRFScanCallback *callback)
Request a new NewGRF scan.
Definition: openttd.cpp:1411
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:993
GCS_NOT_FOUND
@ GCS_NOT_FOUND
GRF file was not found in the local cache.
Definition: newgrf_config.h:37
ScanProgressWindow::ScanProgressWindow
ScanProgressWindow()
Create the window.
Definition: newgrf_gui.cpp:2185
WD_FRAMETEXT_TOP
@ WD_FRAMETEXT_TOP
Top offset of the text of the frame.
Definition: window_gui.h:74
NewGRFWindow::sorter_funcs
static GUIGRFConfigList::SortFunction *const sorter_funcs[]
Sort functions of the #GUIGRFConfigList.
Definition: newgrf_gui.cpp:599
NewGRFWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: newgrf_gui.cpp:783
GRFConfig::ident
GRFIdentifier ident
grfid and md5sum to uniquely identify newgrfs
Definition: newgrf_config.h:163
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:52
NWidgetNewGRFDisplay::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: newgrf_gui.cpp:1765
NewGRFParametersWindow::editable
bool editable
Allow editing parameters.
Definition: newgrf_gui.cpp:161
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:642
NewGRFDisplay
NWidgetBase * NewGRFDisplay(int *biggest_index)
Construct nested container widget for managing the lists and the info panel of the NewGRF GUI.
Definition: newgrf_gui.cpp:1911
WID_NP_RESET
@ WID_NP_RESET
Reset button.
Definition: newgrf_widget.h:26
SZSP_HORIZONTAL
@ SZSP_HORIZONTAL
Display plane with zero size vertically, and filling and resizing horizontally.
Definition: widget_type.h:422
WID_NS_NEWGRF_TEXTFILE
@ WID_NS_NEWGRF_TEXTFILE
Open NewGRF readme, changelog (+1) or license (+2).
Definition: newgrf_widget.h:49
GRFConfig::status
GRFStatus status
NOSAVE: GRFStatus, enum.
Definition: newgrf_config.h:174
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
WWT_PUSHARROWBTN
@ WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
Definition: widget_type.h:106
GRFP_GRF_UNSET
@ GRFP_GRF_UNSET
The NewGRF provided no information.
Definition: newgrf_config.h:70
StringFilter::AddLine
void AddLine(const char *str)
Pass another text line from the current item to the filter.
Definition: stringfilter.cpp:104
NewGRFWindow::execute
bool execute
On pressing 'apply changes' are grf changes applied immediately, or only list is updated.
Definition: newgrf_gui.cpp:616
WID_NS_AVAIL_LIST
@ WID_NS_AVAIL_LIST
List window of available NewGRFs.
Definition: newgrf_widget.h:44
NewGRFWindow::NameSorter
static bool NameSorter(const GRFConfig *const &a, const GRFConfig *const &b)
Sort grfs by name.
Definition: newgrf_gui.cpp:1427
NewGRFWindow::preset
int preset
Selected preset or -1 if none selected.
Definition: newgrf_gui.cpp:617
GRFParameterInfo::type
GRFParameterType type
The type of this parameter.
Definition: newgrf_config.h:139
Scrollbar::GetScrolledRowFromWidget
int GetScrolledRowFromWidget(int clickpos, const Window *const w, int widget, int padding=0) const
Compute the row of a scrolled widget that a user clicked in.
Definition: widget.cpp:2098
gamelog.h
fios.h
NewGRFParametersWindow::clicked_dropdown
bool clicked_dropdown
Whether the dropdown is open.
Definition: newgrf_gui.cpp:154
NWidgetBase::smallest_y
uint smallest_y
Smallest vertical size of the widget in a filled window.
Definition: widget_type.h:184
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:629
MakeNWidgets
NWidgetContainer * MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index, NWidgetContainer *container)
Construct a nested widget tree from an array of parts.
Definition: widget.cpp:3015
NWidgetBase::padding_top
uint8 padding_top
Paddings added to the top of the widget. Managed by parent container widget.
Definition: widget_type.h:195
WID_NP_BACKGROUND
@ WID_NP_BACKGROUND
Panel to draw the settings on.
Definition: newgrf_widget.h:23
WD_FRAMETEXT_LEFT
@ WD_FRAMETEXT_LEFT
Left offset of the text of the frame.
Definition: window_gui.h:72
TextfileWindow::file_type
TextfileType file_type
Type of textfile to view.
Definition: textfile_gui.h:30
TFT_CHANGELOG
@ TFT_CHANGELOG
NewGRF changelog.
Definition: textfile_type.h:18
GRFIdentifier::md5sum
uint8 md5sum[16]
MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF)
Definition: newgrf_config.h:85
WN_GAME_OPTIONS_NEWGRF_STATE
@ WN_GAME_OPTIONS_NEWGRF_STATE
NewGRF settings.
Definition: window_type.h:17
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:196
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:971
textfile_gui.h
NewGRFWindow::active_sel
GRFConfig * active_sel
Selected active grf item.
Definition: newgrf_gui.cpp:611
WID_NS_NEWGRF_INFO
@ WID_NS_NEWGRF_INFO
Panel for Info on selected NewGRF.
Definition: newgrf_widget.h:47
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1107
QueryString
Data stored about a string that can be modified in the GUI.
Definition: querystring_gui.h:20
WC_GRF_PARAMETERS
@ WC_GRF_PARAMETERS
NewGRF parameters; Window numbers:
Definition: window_type.h:173
WID_NS_MOVE_DOWN
@ WID_NS_MOVE_DOWN
Move NewGRF down in active list.
Definition: newgrf_widget.h:39
NewGRFWindow::active_over
int active_over
Active GRF item over which another one is dragged, -1 if none.
Definition: newgrf_gui.cpp:618
WC_SAVE_PRESET
@ WC_SAVE_PRESET
Save preset; Window numbers:
Definition: window_type.h:678
GRFIdentifier::grfid
uint32 grfid
GRF ID (defined by Action 0x08)
Definition: newgrf_config.h:84
GRFParameterInfo::GetValue
uint32 GetValue(struct GRFConfig *config) const
Get the value of this user-changeable parameter from the given config.
Definition: newgrf_config.cpp:244
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:888
GUIList::SetFilterFuncs
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
Definition: sortlist_type.h:341
GCF_COMPATIBLE
@ GCF_COMPATIBLE
GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches)
Definition: newgrf_config.h:26
Textbuf::buf
char *const buf
buffer in which text is saved
Definition: textbuf_type.h:32
Window::querystrings
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition: window_gui.h:323
ShowErrorMessage
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=nullptr, uint textref_stack_size=0, const uint32 *textref_stack=nullptr)
Display an error message in a window.
Definition: error_gui.cpp:383
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:787
GCF_INVALID
@ GCF_INVALID
GRF is unusable with this version of OpenTTD.
Definition: newgrf_config.h:30
NewGRFParametersWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: newgrf_gui.cpp:309
IsInsideMM
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
Definition: math_func.hpp:204
SavePresetWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: newgrf_gui.cpp:2114
NWidgetBase::Draw
virtual void Draw(const Window *w)=0
NewGRFParametersWindow::clicked_increase
bool clicked_increase
True if the increase button was clicked, false for the decrease button.
Definition: newgrf_gui.cpp:153
SavePresetWindow::selected
int selected
Selected entry in the preset list, or -1 if none selected.
Definition: newgrf_gui.cpp:2037
WindowDesc
High level window description.
Definition: window_gui.h:168
GRFBuildParamList
char * GRFBuildParamList(char *dst, const GRFConfig *c, const char *last)
Build a string containing space separated parameter values, and terminate.
Definition: newgrf_config.cpp:775
WC_MODAL_PROGRESS
@ WC_MODAL_PROGRESS
Progress report of landscape generation; Window numbers:
Definition: window_type.h:455
NewGRFWindow::OnMouseDrag
void OnMouseDrag(Point pt, int widget) override
An 'object' is being dragged at the provided position, highlight the target if possible.
Definition: newgrf_gui.cpp:1402
NETWORK_MAX_GRF_COUNT
static const uint NETWORK_MAX_GRF_COUNT
Maximum number of GRFs that can be sent.
Definition: config.h:95
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:463
GetGRFPresetList
StringList GetGRFPresetList()
Get the list of known NewGrf presets.
Definition: settings.cpp:1294
WC_QUERY_STRING
@ WC_QUERY_STRING
Query string window; Window numbers:
Definition: window_type.h:115
GUITimer
Definition: guitimer_func.h:13
DrawDropDownButton
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
Draw a dropdown button.
Definition: settings_gui.cpp:2529
Listing
Data structure describing how to show the list (what sort direction and criteria).
Definition: sortlist_type.h:30
GUIList::SetFilterState
void SetFilterState(bool state)
Enable or disable the filter.
Definition: sortlist_type.h:302
NWidgetBase::padding_left
uint8 padding_left
Paddings added to the left of the widget. Managed by parent container widget. (parent container may s...
Definition: widget_type.h:198
NewGRFWindow::CanUpgradeCurrent
bool CanUpgradeCurrent()
Test whether the currently active set of NewGRFs can be upgraded with the available NewGRFs.
Definition: newgrf_gui.cpp:690
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:317
NWidgetNewGRFDisplay::inf
NWidgetBase * inf
Info panel.
Definition: newgrf_gui.cpp:1587
GOID_NEWGRF_CURRENT_LOADED
@ GOID_NEWGRF_CURRENT_LOADED
The current list of active NewGRF has been loaded.
Definition: window_type.h:705
settings_func.h
ScanProgressWindow::UpdateNewGRFScanStatus
void UpdateNewGRFScanStatus(uint num, const char *name)
Update the NewGRF scan status.
Definition: newgrf_gui.cpp:2247
Scrollbar::GetCount
uint16 GetCount() const
Gets the number of elements in the list.
Definition: widget_type.h:653
NewGRFWindow::UpdateScrollBars
void UpdateScrollBars()
Updates the scroll bars for the active and inactive NewGRF lists.
Definition: newgrf_gui.cpp:1197
tilehighlight_func.h
GRFConfig
Information about GRF, used in the game and (part of it) in savegames.
Definition: newgrf_config.h:155
NewGRFParametersWindow::OnRealtimeTick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition: newgrf_gui.cpp:488
NewGRFWindow::last_sorting
static Listing last_sorting
Default sorting of #GUIGRFConfigList.
Definition: newgrf_gui.cpp:597
_nested_scan_progress_widgets
static const NWidgetPart _nested_scan_progress_widgets[]
Widgets for the progress window.
Definition: newgrf_gui.cpp:2158
NewGRFParametersWindow
Window for setting the parameters of a NewGRF.
Definition: newgrf_gui.cpp:149
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1789
NWidgetNewGRFDisplay
Custom nested widget container for the NewGRF gui.
Definition: newgrf_gui.cpp:1578
WWT_EDITBOX
@ WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:69
ReInitAllWindows
void ReInitAllWindows(bool zoom_changed)
Re-initialize all windows.
Definition: window.cpp:3331
WID_NS_RESCAN_FILES2
@ WID_NS_RESCAN_FILES2
Rescan files (active NewGRFs).
Definition: newgrf_widget.h:55
WID_SVP_SAVE
@ WID_SVP_SAVE
Button to save the preset.
Definition: newgrf_widget.h:68
GOID_NEWGRF_LIST_EDITED
@ GOID_NEWGRF_LIST_EDITED
List of active NewGRFs is being edited.
Definition: window_type.h:706
GUIList< const GRFConfig *, StringFilter & >::SortFunction
bool SortFunction(const const GRFConfig * &, const const GRFConfig * &)
Signature of sort function.
Definition: sortlist_type.h:48
WID_NP_NUMPAR_INC
@ WID_NP_NUMPAR_INC
Button to increase number of parameters.
Definition: newgrf_widget.h:20
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:993
GRFConfig::SetParameterDefaults
void SetParameterDefaults()
Set the default value for all parameters as specified by action14.
Definition: newgrf_config.cpp:130
WID_NP_SCROLLBAR
@ WID_NP_SCROLLBAR
Scrollbar to scroll through all settings.
Definition: newgrf_widget.h:24
GUIList::SetListing
void SetListing(Listing l)
Import sort conditions.
Definition: sortlist_type.h:130
NWidgetBase::smallest_x
uint smallest_x
Smallest horizontal size of the widget in a filled window.
Definition: widget_type.h:183
WD_FRAMERECT_LEFT
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:62
GRFConfig::flags
uint8 flags
NOSAVE: GCF_Flags, bitset.
Definition: newgrf_config.h:173
ContentInfo
Container for all important information about a piece of content.
Definition: tcp_content_type.h:50
GRFP_USE_WINDOWS
@ GRFP_USE_WINDOWS
The palette state is set to use the Windows palette.
Definition: newgrf_config.h:67
NWidgetBase::AssignSizePosition
virtual void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)=0
FillGrfidMap
static void FillGrfidMap(const GRFConfig *c, GrfIdMap *grfid_map)
Add all grf configs from c into the map.
Definition: newgrf_gui.cpp:577
IsInsideBS
static bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
Definition: math_func.hpp:188
WD_PAR_VSEP_NORMAL
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
Definition: window_gui.h:139
WD_FRAMERECT_RIGHT
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:63
find_index
int find_index(std::vector< T > const &vec, T const &item)
Helper function to get the index of an item Consider using std::set, std::unordered_set or std::flat_...
Definition: smallvec_type.hpp:44
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:719
WD_FRAMERECT_BOTTOM
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:65
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
CopyGRFConfigList
GRFConfig ** CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only)
Copy a GRF Config list.
Definition: newgrf_config.cpp:418
GetGRFStringFromGRFText
const char * GetGRFStringFromGRFText(const GRFTextList &text_list)
Get a C-string from a GRFText-list.
Definition: newgrf_text.cpp:620
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:126
WID_NS_OPEN_URL
@ WID_NS_OPEN_URL
Open URL of NewGRF.
Definition: newgrf_widget.h:48
WD_FRAMETEXT_BOTTOM
@ WD_FRAMETEXT_BOTTOM
Bottom offset of the text of the frame.
Definition: window_gui.h:75
WID_NS_UPGRADE
@ WID_NS_UPGRADE
Upgrade NewGRFs that have a newer version available.
Definition: newgrf_widget.h:40
ShowDropDownList
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
Definition: dropdown.cpp:443
SetMatrixDataTip
static NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1125
NWidgetNewGRFDisplay::INTER_COLUMN_SPACING
static const uint INTER_COLUMN_SPACING
Empty horizontal space between two columns.
Definition: newgrf_gui.cpp:1581
ContentInfo::md5sum
byte md5sum[16]
The MD5 checksum.
Definition: tcp_content_type.h:70
ShowNewGRFError
void ShowNewGRFError()
Show the first NewGRF error we can find.
Definition: newgrf_gui.cpp:44
dropdown_type.h
Scrollbar::UpdateListPositionOnKeyPress
EventState UpdateListPositionOnKeyPress(int &list_position, uint16 keycode) const
Update the given list position as if it were on this scroll bar when the given keycode was pressed.
Definition: widget.cpp:2119
GRFConfig::GetTextfile
const char * GetTextfile(TextfileType type) const
Search a textfile file next to this NewGRF.
Definition: newgrf_config.cpp:794
Filtering
Data structure describing what to show in the list (filter criteria).
Definition: sortlist_type.h:35
GamelogStartAction
void GamelogStartAction(GamelogActionType at)
Stores information about new action, but doesn't allocate it Action is allocated only when there is a...
Definition: gamelog.cpp:69
GRFParameterInfo
Information about one grf parameter.
Definition: newgrf_config.h:134
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:386
WL_INFO
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
Definition: error.h:22
StringList
std::vector< std::string > StringList
Type for a list of strings.
Definition: string_type.h:58
NewGRFWindow::UpgradeCurrent
void UpgradeCurrent()
Upgrade the currently active set of NewGRFs.
Definition: newgrf_gui.cpp:703
DropDownListStringItem
Common string list item.
Definition: dropdown_type.h:39
NewGRFParametersWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: newgrf_gui.cpp:473
safeguards.h
NewGRFWindow::OnEditboxChanged
void OnEditboxChanged(int wid) override
The text in an editbox has been edited.
Definition: newgrf_gui.cpp:1344
GOID_NEWGRF_CHANGES_APPLIED
@ GOID_NEWGRF_CHANGES_APPLIED
The active NewGRF list changes have been applied.
Definition: window_type.h:708
sortlist_type.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:1118
WID_NS_MOVE_UP
@ WID_NS_MOVE_UP
Move NewGRF up in active list.
Definition: newgrf_widget.h:38
GRFP_BLT_32BPP
@ GRFP_BLT_32BPP
The NewGRF prefers a 32 bpp blitter.
Definition: newgrf_config.h:77
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:64
WID_NS_APPLY_CHANGES
@ WID_NS_APPLY_CHANGES
Apply changes to NewGRF config.
Definition: newgrf_widget.h:53
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:1041
WDF_MODAL
@ WDF_MODAL
The window is a modal child of some other window, meaning the parent is 'inactive'.
Definition: window_gui.h:211
DeleteGRFPresetFromConfig
void DeleteGRFPresetFromConfig(const char *config_name)
Delete a NewGRF configuration by preset name.
Definition: settings.cpp:1347
newgrf_text.h
WID_NS_CONTENT_DOWNLOAD2
@ WID_NS_CONTENT_DOWNLOAD2
Open content download (active NewGRFs).
Definition: newgrf_widget.h:57
settings_type.h
GetStringMultiLineBoundingBox
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
Calculate string bounding box for multi-line strings.
Definition: gfx.cpp:753
WID_NS_REMOVE
@ WID_NS_REMOVE
Remove NewGRF from active list.
Definition: newgrf_widget.h:37
sprites.h
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
error.h
NewGRFConfirmationCallback
static void NewGRFConfirmationCallback(Window *w, bool confirmed)
Callback function for the newgrf 'apply changes' confirmation window.
Definition: newgrf_gui.cpp:1955
NewGRFTextfileWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: newgrf_gui.cpp:555
GRFConfig::GetURL
const char * GetURL() const
Get the grf url.
Definition: newgrf_config.cpp:124
GRFP_GRF_MASK
@ GRFP_GRF_MASK
Bitmask to get only the NewGRF supplied information.
Definition: newgrf_config.h:74
SETTING_BUTTON_WIDTH
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
Definition: settings_gui.h:17
NWidgetNewGRFDisplay::MIN_EXTRA_FOR_3_COLUMNS
static const uint MIN_EXTRA_FOR_3_COLUMNS
Minimal additional width needed before switching to 3 columns.
Definition: newgrf_gui.cpp:1583
WD_FRAMETEXT_RIGHT
@ WD_FRAMETEXT_RIGHT
Right offset of the text of the frame.
Definition: window_gui.h:73
Window::SetFocusedWidget
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
Definition: window.cpp:506
stdafx.h
PC_BLACK
static const uint8 PC_BLACK
Black palette colour.
Definition: gfx_func.h:190
DrawArrowButtons
void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
Draw [<][>] boxes.
Definition: settings_gui.cpp:2501
GRFConfig::CopyParams
void CopyParams(const GRFConfig &src)
Copy the parameter information from the src config.
Definition: newgrf_config.cpp:93
GfxFillRect
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
Definition: gfx.cpp:116
WID_SVP_CANCEL
@ WID_SVP_CANCEL
Button to cancel saving the preset.
Definition: newgrf_widget.h:67
NWidgetNewGRFDisplay::INTER_LIST_SPACING
static const uint INTER_LIST_SPACING
Empty vertical space between both lists in the 2 column mode.
Definition: newgrf_gui.cpp:1580
TFT_README
@ TFT_README
NewGRF readme.
Definition: textfile_type.h:17
BSWAP32
static uint32 BSWAP32(uint32 x)
Perform a 32 bits endianness bitswap on x.
Definition: bitmath_func.hpp:390
NewGRFWindow::orig_list
GRFConfig ** orig_list
List active grfs in the game. Used as initial value, may be updated by the window.
Definition: newgrf_gui.cpp:613
NWidgetNewGRFDisplay::editable
bool editable
Editable status of the parent NewGRF window (if false, drop all widgets that make the window editable...
Definition: newgrf_gui.cpp:1588
Window::InvalidateData
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Definition: window.cpp:3158
NEWGRF_DIR
@ NEWGRF_DIR
Subdirectory for all NewGRFs.
Definition: fileio_type.h:117
NewGRFWindow::TagNameFilter
static bool CDECL TagNameFilter(const GRFConfig *const *a, StringFilter &filter)
Filter grfs by tags/name.
Definition: newgrf_gui.cpp:1439
WID_NS_CONTENT_DOWNLOAD
@ WID_NS_CONTENT_DOWNLOAD
Open content download (available NewGRFs).
Definition: newgrf_widget.h:56
SavePresetWindow::presetname_editbox
QueryString presetname_editbox
Edit box of the save preset.
Definition: newgrf_gui.cpp:2034
NWidgetBase::current_y
uint current_y
Current vertical size (after resizing).
Definition: widget_type.h:187
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:37
WID_NP_NUMPAR_DEC
@ WID_NP_NUMPAR_DEC
Button to decrease number of parameters.
Definition: newgrf_widget.h:19
ScanProgressWindow::scanned
int scanned
The number of NewGRFs that we have seen.
Definition: newgrf_gui.cpp:2182
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_type.h:329
GamelogStopAction
void GamelogStopAction()
Stops logging of any changes.
Definition: gamelog.cpp:78
PC_GREY
static const uint8 PC_GREY
Grey palette colour.
Definition: gfx_func.h:192
WID_NS_SHOW_APPLY
@ WID_NS_SHOW_APPLY
Select display of the buttons below the 'details'.
Definition: newgrf_widget.h:59
LoadGRFPresetFromConfig
GRFConfig * LoadGRFPresetFromConfig(const char *config_name)
Load a NewGRF configuration by preset-name.
Definition: settings.cpp:1314
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
NewGRFWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: newgrf_gui.cpp:832
HT_DRAG
@ HT_DRAG
dragging items in the depot windows
Definition: tilehighlight_type.h:24
NewGRFParametersWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: newgrf_gui.cpp:239
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:976
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:66
WID_NS_ADD
@ WID_NS_ADD
Add NewGRF to active list.
Definition: newgrf_widget.h:36
GUISettings::newgrf_show_old_versions
bool newgrf_show_old_versions
whether to show old versions in the NewGRF list
Definition: settings_type.h:190
GUIList::NeedRebuild
bool NeedRebuild() const
Check if a rebuild is needed.
Definition: sortlist_type.h:362
NWidgetBase::GetWidgetFromPos
virtual NWidgetCore * GetWidgetFromPos(int x, int y)=0
WID_NP_NUMPAR
@ WID_NP_NUMPAR
Optional number of parameters.
Definition: newgrf_widget.h:21
TFT_LICENSE
@ TFT_LICENSE
NewGRF license.
Definition: textfile_type.h:19
NewGRFWindow::filter_editbox
QueryString filter_editbox
Filter editbox;.
Definition: newgrf_gui.cpp:606
GCS_DISABLED
@ GCS_DISABLED
GRF file is disabled.
Definition: newgrf_config.h:36
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
NWidgetBase::fill_y
uint fill_y
Vertical fill stepsize (from initial size, 0 means not resizable).
Definition: widget_type.h:177
ShowQuery
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
Show a modal confirmation window with standard 'yes' and 'no' buttons The window is aligned to the ce...
Definition: misc_gui.cpp:1267
QueryString::cancel_button
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
Definition: querystring_gui.h:28
GRFParameterInfo::max_value
uint32 max_value
The maximal value of this parameter.
Definition: newgrf_config.h:141
GRFError::message
StringID message
Default message.
Definition: newgrf_config.h:121
WID_SP_PROGRESS_TEXT
@ WID_SP_PROGRESS_TEXT
Text explaining what is happening.
Definition: newgrf_widget.h:74
WID_NS_VIEW_PARAMETERS
@ WID_NS_VIEW_PARAMETERS
Open Parameters Window for selected NewGRF for viewing parameters.
Definition: newgrf_widget.h:51
WC_GAME_OPTIONS
@ WC_GAME_OPTIONS
Game options window; Window numbers:
Definition: window_type.h:604
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1092
NewGRFParametersWindow::line_height
int line_height
Height of a row in the matrix widget.
Definition: newgrf_gui.cpp:158
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
NewGRFWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: newgrf_gui.cpp:777
GRFParameterInfo::value_names
SmallMap< uint32, GRFTextList > value_names
Names for each value.
Definition: newgrf_config.h:146
ScanProgressWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: newgrf_gui.cpp:2196
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:189
WID_SVP_PRESET_LIST
@ WID_SVP_PRESET_LIST
List with available preset names.
Definition: newgrf_widget.h:64
NewGRFWindow::avail_sel
const GRFConfig * avail_sel
Currently selected available grf. nullptr is none is selected.
Definition: newgrf_gui.cpp:603
GRFParameterInfo::desc
GRFTextList desc
The description of this parameter.
Definition: newgrf_config.h:138
HideDropDownMenu
int HideDropDownMenu(Window *pw)
Delete the drop-down menu from window pw.
Definition: dropdown.cpp:498
NewGRFParametersWindow::closing_dropdown
bool closing_dropdown
True, if the dropdown list is currently closing.
Definition: newgrf_gui.cpp:155
WIDGET_LIST_END
static const int WIDGET_LIST_END
indicate the end of widgets' list for vararg functions
Definition: widget_type.h:20
NewGRFParametersWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: newgrf_gui.cpp:443
Window::CloseChildWindows
void CloseChildWindows(WindowClass wc=WC_INVALID) const
Close all children a window might have in a head-recursive manner.
Definition: window.cpp:1080
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:56
GRFConfig::min_loadable_version
uint32 min_loadable_version
NOSAVE: Minimum compatible version a NewGRF can define.
Definition: newgrf_config.h:172
SavePresetWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: newgrf_gui.cpp:2073
_newgrf_parameters_desc
static WindowDesc _newgrf_parameters_desc(WDP_CENTER, "settings_newgrf_config", 500, 208, WC_GRF_PARAMETERS, WC_NONE, 0, _nested_newgrf_parameter_widgets, lengthof(_nested_newgrf_parameter_widgets))
Window definition for the change grf parameters window.
WID_NS_SET_PARAMETERS
@ WID_NS_SET_PARAMETERS
Open Parameters Window for selected NewGRF for editing parameters.
Definition: newgrf_widget.h:50
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:165
GRFConfig::GetDescription
const char * GetDescription() const
Get the grf info.
Definition: newgrf_config.cpp:115
GRFConfig::original_md5sum
uint8 original_md5sum[16]
MD5 checksum of original file if only a 'compatible' file was loaded.
Definition: newgrf_config.h:164
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1207
PC_DARK_BLUE
static const uint8 PC_DARK_BLUE
Dark blue palette colour.
Definition: gfx_func.h:210
NWidgetBase::fill_x
uint fill_x
Horizontal fill stepsize (from initial size, 0 means not resizable).
Definition: widget_type.h:176
Scrollbar::IsVisible
bool IsVisible(uint16 item) const
Checks whether given current item is visible in the list.
Definition: widget_type.h:681
geometry_func.hpp
GUIList< const GRFConfig *, StringFilter & >::FilterFunction
bool CDECL FilterFunction(const const GRFConfig * *, StringFilter &)
Signature of filter function.
Definition: sortlist_type.h:49
PaletteID
uint32 PaletteID
The number of the palette.
Definition: gfx_type.h:18
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:94
CloseWindowByClass
void CloseWindowByClass(WindowClass cls)
Close all windows of a given class.
Definition: window.cpp:1188
NewGRFWindow::grf_presets
StringList grf_presets
List of known NewGRF presets.
Definition: newgrf_gui.cpp:608
GOID_NEWGRF_RESCANNED
@ GOID_NEWGRF_RESCANNED
NewGRFs were just rescanned.
Definition: window_type.h:704
ShowNewGRFSettings
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
Definition: newgrf_gui.cpp:1995
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1010
GRFConfig::next
struct GRFConfig * next
NOSAVE: Next item in the linked list.
Definition: newgrf_config.h:183
StringFilter::ResetState
void ResetState()
Reset the matching state to process a new item.
Definition: stringfilter.cpp:88
NewGRFParametersWindow::timeout
GUITimer timeout
How long before we unpress the last-pressed button?
Definition: newgrf_gui.cpp:156
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
GamelogGRFUpdate
void GamelogGRFUpdate(const GRFConfig *oldc, const GRFConfig *newc)
Compares two NewGRF lists and logs any change.
Definition: gamelog.cpp:722
Window::SetWidgetsDisabledState
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
Definition: window.cpp:547
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:179
newgrf.h
NWidgetBase::StoreSizePosition
void StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height)
Store size and position.
Definition: widget_type.h:235
NewGRFWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: newgrf_gui.cpp:728
EventState
EventState
State of handling an event.
Definition: window_type.h:717
FGCM_NEWEST
@ FGCM_NEWEST
Find newest Grf.
Definition: newgrf_config.h:201
FGCM_NEWEST_VALID
@ FGCM_NEWEST_VALID
Find newest Grf, ignoring Grfs with GCF_INVALID set.
Definition: newgrf_config.h:202
GRFParameterInfo::name
GRFTextList name
The name of this parameter.
Definition: newgrf_config.h:137
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:671
GUIList::SetFiltering
void SetFiltering(Filtering f)
Import filter conditions.
Definition: sortlist_type.h:181
FindWindowByClass
Window * FindWindowByClass(WindowClass cls)
Find any window by its class.
Definition: window.cpp:1161
NewGRFWindow::show_params
bool show_params
Are the grf-parameters shown in the info-panel?
Definition: newgrf_gui.cpp:615
StringFilter::GetState
bool GetState() const
Get the matching state of the current item.
Definition: stringfilter_type.h:69
NewGRFParametersWindow::action14present
bool action14present
True if action14 information is present.
Definition: newgrf_gui.cpp:160
WID_NS_FILTER
@ WID_NS_FILTER
Filter list of available NewGRFs.
Definition: newgrf_widget.h:41
WD_RESIZEBOX_WIDTH
@ WD_RESIZEBOX_WIDTH
Width of a resize box widget.
Definition: window_gui.h:112
NewGRFParametersWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: newgrf_gui.cpp:318
seprintf
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Definition: string.cpp:535
GUIList::Filter
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
Definition: sortlist_type.h:318
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1776
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
NewGRFParametersWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: newgrf_gui.cpp:432
WWT_INSET
@ WWT_INSET
Pressed (inset) panel, most commonly used as combo box text area.
Definition: widget_type.h:49
WL_ERROR
@ WL_ERROR
Errors (eg. saving/loading failed)
Definition: error.h:24
QueryString::ACTION_CLEAR
static const int ACTION_CLEAR
Clear editbox.
Definition: querystring_gui.h:24
NWidgetContainer
Baseclass for container widgets.
Definition: widget_type.h:400
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:313
WID_NS_SCROLL2BAR
@ WID_NS_SCROLL2BAR
Scrollbar for available NewGRF list.
Definition: newgrf_widget.h:45
NWidgetBase::padding_right
uint8 padding_right
Paddings added to the right of the widget. Managed by parent container widget. (parent container may ...
Definition: widget_type.h:196
stredup
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
Definition: string.cpp:137
GUITimer::Elapsed
bool Elapsed(uint delta)
Test if a timer has elapsed.
Definition: guitimer_func.h:55
GRFConfig::palette
uint8 palette
GRFPalette, bitset.
Definition: newgrf_config.h:179
GRFParameterInfo::complete_labels
bool complete_labels
True if all values have a label.
Definition: newgrf_config.h:147
DrawFrameRect
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition: widget.cpp:209
network.h
_grfconfig
GRFConfig * _grfconfig
First item in list of current GRF set up.
Definition: newgrf_config.cpp:171
ContentInfo::state
State state
Whether the content info is selected (for download)
Definition: tcp_content_type.h:73
NewGRFTextfileWindow::grf_config
const GRFConfig * grf_config
View the textfile of this GRFConfig.
Definition: newgrf_gui.cpp:547
SmallMap::Find
std::vector< Pair >::const_iterator Find(const T &key) const
Finds given key in this map.
Definition: smallmap_type.hpp:41
ContentInfo::unique_id
uint32 unique_id
Unique ID; either GRF ID or shortname.
Definition: tcp_content_type.h:69
WD_MATRIX_BOTTOM
@ WD_MATRIX_BOTTOM
Offset at bottom of a matrix cell.
Definition: window_gui.h:81
ShowDropDownListAt
void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width, bool instant_close)
Show a drop down list.
Definition: dropdown.cpp:356
window_func.h
WID_NP_SHOW_NUMPAR
@ WID_NP_SHOW_NUMPAR
NWID_SELECTION to optionally display WID_NP_NUMPAR.
Definition: newgrf_widget.h:18
GUIList::ForceRebuild
void ForceRebuild()
Force that a rebuild is needed.
Definition: sortlist_type.h:370
NewGRFScanCallback
Callback for NewGRF scanning.
Definition: newgrf_config.h:213
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:378
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:314
_scan_progress_desc
static WindowDesc _scan_progress_desc(WDP_CENTER, nullptr, 0, 0, WC_MODAL_PROGRESS, WC_NONE, 0, _nested_scan_progress_widgets, lengthof(_nested_scan_progress_widgets))
Description of the widgets and other settings of the window.
stringfilter_type.h
WID_NS_NEWGRF_INFO_TITLE
@ WID_NS_NEWGRF_INFO_TITLE
Title for Info on selected NewGRF.
Definition: newgrf_widget.h:46
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, int widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition: widget.cpp:2172
WC_BUILD_OBJECT
@ WC_BUILD_OBJECT
Build object; Window numbers:
Definition: window_type.h:368
WID_NS_FILE_LIST
@ WID_NS_FILE_LIST
List window of active NewGRFs.
Definition: newgrf_widget.h:42
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1169
NewGRFWindow::last_filtering
static Filtering last_filtering
Default filtering of #GUIGRFConfigList.
Definition: newgrf_gui.cpp:598
ScanProgressWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: newgrf_gui.cpp:2219
WID_NP_SHOW_DESCRIPTION
@ WID_NP_SHOW_DESCRIPTION
NWID_SELECTION to optionally display parameter descriptions.
Definition: newgrf_widget.h:27
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1176
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:190
NewGRFWindow::editable
bool editable
Is the window editable?
Definition: newgrf_gui.cpp:614
PTYPE_BOOL
@ PTYPE_BOOL
The parameter is either 0 or 1.
Definition: newgrf_config.h:129
SetObjectToPlaceWnd
void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Window *w)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
Definition: viewport.cpp:3360
strnatcmp
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
Definition: string.cpp:718
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1076
GUISettings::scenario_developer
bool scenario_developer
activate scenario developer: allow modifying NewGRFs in an existing game
Definition: settings_type.h:188
TextfileWindow
Window for displaying a textfile.
Definition: textfile_gui.h:21
NewGRFWindow::OnDragDrop
void OnDragDrop(Point pt, int widget) override
A dragged 'object' has been released.
Definition: newgrf_gui.cpp:1354
NewGRFParametersWindow::grf_config
GRFConfig * grf_config
Set the parameters of this GRFConfig.
Definition: newgrf_gui.cpp:151
NewGRFParametersWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: newgrf_gui.cpp:248
WID_SVP_SCROLLBAR
@ WID_SVP_SCROLLBAR
Scrollbar for the list available preset names.
Definition: newgrf_widget.h:65
SPR_CURSOR_MOUSE
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
Definition: sprites.h:1380
GUISettings::last_newgrf_count
uint32 last_newgrf_count
the numbers of NewGRFs we found during the last scan
Definition: settings_type.h:164
NWidgetBase::padding_bottom
uint8 padding_bottom
Paddings added to the bottom of the widget. Managed by parent container widget.
Definition: widget_type.h:197
PTYPE_UINT_ENUM
@ PTYPE_UINT_ENUM
The parameter allows a range of numbers, each of which can have a special name.
Definition: newgrf_config.h:128
newgrf_widget.h
NWidgetNewGRFDisplay::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: newgrf_gui.cpp:1603
Window
Data structure for an opened window.
Definition: window_gui.h:279
WID_NP_ACCEPT
@ WID_NP_ACCEPT
Accept button.
Definition: newgrf_widget.h:25
SizingType
SizingType
Different forms of sizing nested widgets, using NWidgetBase::AssignSizePosition()
Definition: widget_type.h:111
GUIList::RebuildDone
void RebuildDone()
Notify the sortlist that the rebuild is done.
Definition: sortlist_type.h:380
TextfileType
TextfileType
Additional text files accompanying Tar archives.
Definition: textfile_type.h:14
md5sumToString
char * md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
Convert the md5sum to a hexadecimal string representation.
Definition: string.cpp:553
ResetGRFConfig
void ResetGRFConfig(bool defaults)
Reset the current GRF Config to either blank or newgame settings.
Definition: newgrf_config.cpp:495
NWidgetNewGRFDisplay::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: newgrf_gui.cpp:1646
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:636
NewGRFWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: newgrf_gui.cpp:1157
FGCM_EXACT
@ FGCM_EXACT
Only find Grfs matching md5sum.
Definition: newgrf_config.h:199
NewGRFParametersWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: newgrf_gui.cpp:195
PC_DARK_GREY
static const uint8 PC_DARK_GREY
Dark grey palette colour.
Definition: gfx_func.h:191
Window::OnQueryTextFinished
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
Definition: window_gui.h:734
GRFConfig::filename
char * filename
Filename - either with or without full path.
Definition: newgrf_config.h:165
DrawBoolButton
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
Definition: settings_gui.cpp:2548
NewGRFWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: newgrf_gui.cpp:921
settings_gui.h
_network_available
bool _network_available
is network mode available?
Definition: network.cpp:58
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:78
NewGRFTextfileWindow
Window for displaying the textfile of a NewGRF.
Definition: newgrf_gui.cpp:546
WID_TF_CAPTION
@ WID_TF_CAPTION
The caption of the window.
Definition: misc_widget.h:51
free
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: stdafx.h:460
NWidgetCore
Base class for a 'real' widget.
Definition: widget_type.h:311
Window::SetWidgetDirty
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:608
NewGRFParametersWindow::clicked_button
uint clicked_button
The row in which a button was clicked or UINT_MAX.
Definition: newgrf_gui.cpp:152
NewGRFWindow::GetPalette
PaletteID GetPalette(const GRFConfig *c) const
Pick the palette for the sprite of the grf to display.
Definition: newgrf_gui.cpp:802
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
WID_NP_DESCRIPTION
@ WID_NP_DESCRIPTION
Multi-line description of a parameter.
Definition: newgrf_widget.h:28
SavePresetWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: newgrf_gui.cpp:2090
NWidgetBase::resize_x
uint resize_x
Horizontal resize step (0 means not resizable).
Definition: widget_type.h:178
NewGRFParametersWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: newgrf_gui.cpp:463
AWV_INCREASE
@ AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition: widget_type.h:36
NewGRFWindow::avail_pos
int avail_pos
Index of avail_sel if existing, else -1.
Definition: newgrf_gui.cpp:604
GRFError::param_value
uint32 param_value[2]
Values of GRF parameters to show for message and custom_message.
Definition: newgrf_config.h:123
Window::DisableWidget
void DisableWidget(byte widget_index)
Sets a widget to disabled.
Definition: window_gui.h:396
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:186
WC_TEXTFILE
@ WC_TEXTFILE
textfile; Window numbers:
Definition: window_type.h:179
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:394
NewGRFWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: newgrf_gui.cpp:1176
WID_NS_PRESET_SAVE
@ WID_NS_PRESET_SAVE
Save list of active NewGRFs as presets.
Definition: newgrf_widget.h:34
SetDParamMaxDigits
void SetDParamMaxDigits(uint n, uint count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
Definition: strings.cpp:110
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3423
SaveGRFPresetToConfig
void SaveGRFPresetToConfig(const char *config_name, GRFConfig *config)
Save a NewGRF configuration with a preset name.
Definition: settings.cpp:1332
SavePresetWindow::vscroll
Scrollbar * vscroll
Pointer to the scrollbar widget.
Definition: newgrf_gui.cpp:2036
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition: window_gui.h:157
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
_current_text_dir
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:48
WID_SVP_EDITBOX
@ WID_SVP_EDITBOX
Edit box for changing the preset name.
Definition: newgrf_widget.h:66
LeastCommonMultiple
int LeastCommonMultiple(int a, int b)
Compute least common multiple (lcm) of arguments a and b, the smallest integer value that is a multip...
Definition: math_func.cpp:24
CS_NUMERAL
@ CS_NUMERAL
Only numeric ones.
Definition: string_type.h:28
misc_widget.h
WD_TEXTPANEL_BOTTOM
@ WD_TEXTPANEL_BOTTOM
Offset at bottom to draw below the text.
Definition: window_gui.h:69
StringFilter
String filter and state.
Definition: stringfilter_type.h:31
SavePresetWindow::presets
StringList presets
Available presets.
Definition: newgrf_gui.cpp:2035
NewGRFParametersWindow::clicked_row
uint clicked_row
The selected parameter.
Definition: newgrf_gui.cpp:157
SetDParamStr
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Definition: strings.cpp:296
SavePresetWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: newgrf_gui.cpp:2141
WID_NS_SHOW_REMOVE
@ WID_NS_SHOW_REMOVE
Select active list buttons (0 = normal, 1 = simple layout).
Definition: newgrf_widget.h:58
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
GCF_STATIC
@ GCF_STATIC
GRF file is used statically (can be used in any MP game)
Definition: newgrf_config.h:25
GRFConfig::param_info
std::vector< GRFParameterInfo * > param_info
NOSAVE: extra information about the parameters.
Definition: newgrf_config.h:180
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:593
WL_CRITICAL
@ WL_CRITICAL
Critical errors, the MessageBox is shown in all cases.
Definition: error.h:25
WID_NS_RESCAN_FILES
@ WID_NS_RESCAN_FILES
Rescan files (available NewGRFs).
Definition: newgrf_widget.h:54
GRFConfig::param
uint32 param[0x80]
GRF parameters.
Definition: newgrf_config.h:176
GRFParameterInfo::min_value
uint32 min_value
The minimal value this parameter can have.
Definition: newgrf_config.h:140
FR_BORDERONLY
@ FR_BORDERONLY
Draw border only, no background.
Definition: window_gui.h:30
AWV_DECREASE
@ AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition: widget_type.h:35
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:68
GRFConfig::GetName
const char * GetName() const
Get the name of this grf.
Definition: newgrf_config.cpp:105
GUIList::SetSortFuncs
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
Definition: sortlist_type.h:270
WD_TEXTPANEL_TOP
@ WD_TEXTPANEL_TOP
Offset at top to draw above the text.
Definition: window_gui.h:68
ScanProgressWindow::last_name
char * last_name
The name of the last 'seen' NewGRF.
Definition: newgrf_gui.cpp:2181
GRFError::data
std::string data
Additional data for message and custom_message.
Definition: newgrf_config.h:120
NewGRFWindow::Close
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: newgrf_gui.cpp:665
NWidgetBase::SetupSmallestSize
virtual void SetupSmallestSize(Window *w, bool init_array)=0
NewGRFWindow::avails
GUIGRFConfigList avails
Available (non-active) grfs.
Definition: newgrf_gui.cpp:602
NewGRFParametersWindow::dummy_parameter_info
static GRFParameterInfo dummy_parameter_info
Dummy info in case a newgrf didn't provide info about some parameter.
Definition: newgrf_gui.cpp:150
Window::Close
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:1092
SmallMap::Contains
bool Contains(const T &key) const
Tests whether a key is assigned in this map.
Definition: smallmap_type.hpp:79
WID_SP_PROGRESS_BAR
@ WID_SP_PROGRESS_BAR
Simple progress bar.
Definition: newgrf_widget.h:73