49 if (_game_mode == GM_MENU)
return;
53 if (c->error ==
nullptr || c->error->severity != STR_NEWGRF_ERROR_MSG_FATAL)
continue;
55 SetDParam (0, c->error->custom_message ==
nullptr ? c->error->message : STR_JUST_RAW_STRING);
59 for (uint i = 0; i <
lengthof(c->error->param_value); i++) {
60 SetDParam(4 + i, c->error->param_value[i]);
67 static void ShowNewGRFInfo(
const GRFConfig *c, uint x, uint y, uint right, uint bottom,
bool show_params)
69 if (c->
error !=
nullptr) {
116 SetDParam(0, STR_NEWGRF_SETTINGS_PARAMETER_NONE);
163 clicked_button(UINT_MAX),
164 clicked_dropdown(false),
165 closing_dropdown(false),
166 clicked_row(UINT_MAX),
174 this->GetWidget<NWidgetStacked>(
WID_NP_SHOW_DESCRIPTION)->SetDisplayedPlane(this->action14present ? 0 : SZSP_HORIZONTAL);
206 d.width += padding.width;
207 d.height += padding.height;
223 for (uint i = 0; i < this->grf_config->
param_info.size(); i++) {
225 if (par_info ==
nullptr)
continue;
227 if (desc ==
nullptr)
continue;
230 suggestion =
maxdim(d, suggestion);
232 size->height = suggestion.height;
250 if (par_info ==
nullptr)
return;
252 if (desc ==
nullptr)
return;
270 uint32 current_value = par_info->
GetValue(this->grf_config);
274 DrawBoolButton(buttons_left, y + button_y_offset, current_value != 0, this->editable);
275 SetDParam(2, par_info->
GetValue(this->grf_config) == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
278 DrawDropDownButton(buttons_left, y + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && this->clicked_dropdown, this->editable);
280 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);
286 if (label !=
nullptr) {
294 if (name !=
nullptr) {
298 SetDParam(0, STR_NEWGRF_PARAMETERS_DEFAULT_NAME);
302 DrawString(text_left, text_right, y + text_y_offset, STR_NEWGRF_PARAMETERS_SETTING, selected ? TC_WHITE : TC_LIGHT_BLUE);
309 if (this->closing_dropdown) {
310 this->closing_dropdown =
false;
311 this->clicked_dropdown =
false;
320 if (this->editable && !this->action14present && this->grf_config->
num_params > 0) {
338 if (!this->editable)
break;
340 if (num >= this->vscroll->
GetCount())
break;
341 if (this->clicked_row != num) {
344 this->clicked_row = num;
345 this->clicked_dropdown =
false;
349 int x = pt.x - wid->
pos_x;
357 uint32 old_val = par_info->
GetValue(this->grf_config);
359 if (this->clicked_dropdown) {
362 this->clicked_dropdown =
false;
363 this->closing_dropdown =
false;
375 if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
376 this->clicked_dropdown =
true;
377 this->closing_dropdown =
false;
380 for (uint32 i = par_info->
min_value; i <= par_info->max_value; i++) {
388 uint32 val = old_val;
394 if (val < par_info->max_value) val++;
395 this->clicked_increase =
true;
399 this->clicked_increase =
false;
402 if (val != old_val) {
403 par_info->
SetValue(this->grf_config, val);
405 this->clicked_button = num;
406 this->timeout.SetInterval(150);
418 if (!this->editable)
break;
433 int32 value = atoi(str);
437 par_info->
SetValue(this->grf_config, val);
443 assert(this->clicked_dropdown);
446 par_info->
SetValue(this->grf_config, index);
456 assert(this->clicked_dropdown);
457 this->closing_dropdown =
true;
473 if (!gui_scope)
return;
474 if (!this->action14present) {
480 if (this->clicked_row != UINT_MAX && this->clicked_row >= this->vscroll->
GetCount()) {
481 this->clicked_row = UINT_MAX;
488 if (timeout.
Elapsed(delta_ms)) {
489 this->clicked_button = UINT_MAX;
497 static const NWidgetPart _nested_newgrf_parameter_widgets[] = {
508 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),
513 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),
531 WDP_CENTER,
"settings_newgrf_config", 500, 208,
534 _nested_newgrf_parameter_widgets,
lengthof(_nested_newgrf_parameter_widgets)
549 const char *textfile = this->grf_config->
GetTextfile(file_type);
568 typedef std::map<uint32, const GRFConfig *>
GrfIdMap;
577 while (c !=
nullptr) {
578 std::pair<uint32, const GRFConfig *> p(c->
ident.
grfid, c);
579 grfid_map->insert(p);
593 static const uint EDITBOX_MAX_SIZE = 50;
597 static GUIGRFConfigList::SortFunction *
const sorter_funcs[];
598 static GUIGRFConfigList::FilterFunction *
const filter_funcs[];
623 this->avail_sel =
nullptr;
624 this->avail_pos = -1;
625 this->active_sel =
nullptr;
626 this->actives =
nullptr;
627 this->orig_list = orig_list;
629 this->execute = execute;
630 this->show_params = show_params;
632 this->active_over = -1;
641 this->GetWidget<NWidgetStacked>(
WID_NS_SHOW_REMOVE)->SetDisplayedPlane(this->editable ? 0 : 1);
668 if (this->editable && !this->execute) {
688 GrfIdMap::const_iterator iter = grfid_map.find(a->ident.grfid);
689 if (iter != grfid_map.end() && a->version > iter->second->version)
return true;
701 GrfIdMap::iterator iter = grfid_map.find(a->ident.grfid);
702 if (iter == grfid_map.end() || iter->second->version >= a->version)
continue;
705 while (*c != iter->second) c = &(*c)->
next;
709 if (this->active_sel == *c) {
712 this->active_sel =
nullptr;
749 for (
const auto &i : this->grf_presets) {
753 d.width += padding.width;
762 size->width += padding.width;
763 size->height += padding.height;
779 if (this->preset == -1) {
783 SetDParamStr(1, this->grf_presets[this->preset].c_str());
802 pal = PALETTE_TO_RED;
805 pal = PALETTE_TO_GREEN;
808 pal = PALETTE_TO_BLUE;
813 if (pal != PALETTE_TO_RED) {
815 pal = PALETTE_TO_GREY;
817 pal = PALETTE_TO_ORANGE;
830 uint step_height = this->GetWidget<NWidgetBase>(
WID_NS_FILE_LIST)->resize_y;
834 int square_offset_y = (step_height - square.height) / 2;
835 int warning_offset_y = (step_height - warning.height) / 2;
841 uint square_left = rtl ? r.right - square.width - 5 : r.left + 5;
842 uint warning_left = rtl ? r.right - square.width - warning.width - 10 : r.left + square.width + 10;
845 for (
const GRFConfig *c = this->actives; c !=
nullptr; c = c->
next, i++) {
847 const char *text = c->
GetName();
848 bool h = (this->active_sel == c);
853 }
else if (i == this->active_over) {
855 int active_sel_pos = 0;
856 for (
GRFConfig *c = this->actives; c !=
nullptr && c != this->active_sel; c = c->
next, active_sel_pos++) {}
857 if (active_sel_pos != this->active_over) {
858 uint
top = this->active_over < active_sel_pos ? y + 1 : y + step_height - 2;
862 DrawSprite(SPR_SQUARE, pal, square_left, y + square_offset_y);
863 if (c->
error !=
nullptr)
DrawSprite(SPR_WARNING_SIGN, 0, warning_left, y + warning_offset_y);
864 uint txtoffset = c->
error ==
nullptr ? 0 : warning.width;
865 DrawString(text_left + (rtl ? 0 : txtoffset), text_right - (rtl ? txtoffset : 0), y + offset_y, text, h ? TC_WHITE : TC_ORANGE);
869 if (i == this->active_over && this->vscroll->
IsVisible(i)) {
882 uint max_index =
min(min_index + this->vscroll2->
GetCapacity(), (uint)this->avails.size());
884 for (uint i = min_index; i < max_index; i++) {
886 bool h = (c == this->avail_sel);
887 const char *text = c->
GetName();
903 const GRFConfig *selected = this->active_sel;
904 if (selected ==
nullptr) selected = this->avail_sel;
905 if (selected !=
nullptr) {
916 if (this->active_sel ==
nullptr && this->avail_sel ==
nullptr)
return;
929 for (uint i = 0; i < this->grf_presets.size(); i++) {
939 const GRFConfig *c = (this->avail_sel ==
nullptr) ? this->active_sel : this->avail_sel;
941 extern void OpenBrowser(
const char *url);
951 if (this->preset == -1)
return;
961 if (this->active_sel ==
nullptr || !this->editable)
break;
964 for (
GRFConfig **pc = &this->actives; *pc !=
nullptr; pc = &(*pc)->
next, pos++) {
966 if (c->
next == this->active_sel) {
968 this->active_sel->
next = c;
969 *pc = this->active_sel;
980 if (this->active_sel ==
nullptr || !this->editable)
break;
983 for (
GRFConfig **pc = &this->actives; *pc !=
nullptr; pc = &(*pc)->
next, pos++) {
985 if (c == this->active_sel) {
1004 for (c = this->actives; c !=
nullptr && i > 0; c = c->
next, i--) {}
1006 if (this->active_sel != c) {
1010 this->active_sel = c;
1011 this->avail_sel =
nullptr;
1012 this->avail_pos = -1;
1015 if (click_count == 1) {
1024 if (this->active_sel ==
nullptr || !this->editable)
break;
1030 for (
GRFConfig **pc = &this->actives; *pc !=
nullptr; pc = &(*pc)->
next) {
1034 if (newsel ==
nullptr && c->
next == this->active_sel) newsel = c;
1036 if (c == this->active_sel) {
1037 if (newsel == c) newsel =
nullptr;
1045 this->active_sel = newsel;
1047 this->avail_pos = -1;
1048 this->avail_sel =
nullptr;
1055 if (!this->editable || this->actives ==
nullptr)
break;
1065 this->active_sel =
nullptr;
1067 if (i < this->avails.size()) {
1069 this->avail_sel = this->avails[i];
1070 this->avail_pos = i;
1073 if (click_count == 1) {
1084 this->AddGRFToActive();
1088 if (!this->editable)
break;
1089 if (this->execute) {
1091 STR_NEWGRF_POPUP_CAUTION_CAPTION,
1092 STR_NEWGRF_CONFIRMATION_TEXT,
1106 if (this->active_sel ==
nullptr || !this->show_params || this->active_sel->
num_valid_params == 0)
break;
1108 OpenGRFParameterWindow(this->active_sel, this->editable);
1113 if (this->active_sel !=
nullptr && this->editable) {
1140 this->avail_sel =
nullptr;
1141 this->avail_pos = -1;
1148 if (!this->editable)
return;
1151 this->preset = index;
1161 this->active_sel =
nullptr;
1167 if (str ==
nullptr)
return;
1173 for (uint i = 0; i < this->grf_presets.size(); i++) {
1174 if (this->grf_presets[i] == str) {
1190 if (!gui_scope)
return;
1198 for (
GRFConfig **l = &this->actives; *l !=
nullptr; l = &(*l)->
next) {
1207 (*l)->next = c->
next;
1209 if (this->active_sel == c) this->active_sel = *l;
1224 for (
const GRFConfig *c = this->actives; c !=
nullptr; c = c->
next, i++) {}
1228 if (this->avail_pos >= 0) this->vscroll2->
ScrollTowards(this->avail_pos);
1233 this->BuildAvailables();
1244 bool disable_all = this->active_sel ==
nullptr || !this->
editable;
1252 const GRFConfig *c = (this->avail_sel ==
nullptr) ? this->active_sel : this->avail_sel;
1253 for (
TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
1271 bool has_missing =
false;
1272 bool has_compatible =
false;
1273 for (
const GRFConfig *c = this->actives; !has_missing && c !=
nullptr; c = c->
next) {
1279 if (has_missing || has_compatible) {
1280 widget_data = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON;
1281 tool_tip = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP;
1283 widget_data = STR_INTRO_ONLINE_CONTENT;
1284 tool_tip = STR_INTRO_TOOLTIP_ONLINE_CONTENT;
1301 if (this->avail_pos > 0) this->avail_pos--;
1306 if (this->avail_pos < (
int)this->avails.size() - 1) this->avail_pos++;
1311 this->avail_pos = (this->avail_pos < this->vscroll2->
GetCapacity()) ? 0 : this->avail_pos - this->vscroll2->
GetCapacity();
1316 this->avail_pos =
min(this->avail_pos + this->vscroll2->
GetCapacity(), (int)this->avails.size() - 1);
1321 this->avail_pos = 0;
1326 this->avail_pos = (uint)this->avails.size() - 1;
1333 if (this->avails.size() == 0) this->avail_pos = -1;
1334 if (this->avail_pos >= 0) {
1335 this->active_sel =
nullptr;
1338 this->avail_sel = this->avails[this->avail_pos];
1348 if (!this->editable)
return;
1358 if (!this->editable)
return;
1361 if (this->active_sel !=
nullptr) {
1365 for (from_prev = &this->actives; *from_prev != this->active_sel; from_prev = &(*from_prev)->
next, from_pos++) {}
1369 if (to_pos != from_pos) {
1372 for (
int i = from_pos < to_pos ? -1 : 0; *to_prev !=
nullptr && i < to_pos; to_prev = &(*to_prev)->
next, i++) {}
1375 *from_prev = this->active_sel->
next;
1378 this->active_sel->
next = *to_prev;
1379 *to_prev = this->active_sel;
1385 }
else if (this->avail_sel !=
nullptr) {
1387 this->AddGRFToActive(to_pos);
1391 Point dummy = {-1, -1};
1397 if (this->active_over != -1) {
1400 this->active_over = -1;
1406 if (!this->editable)
return;
1408 if (widget ==
WID_NS_FILE_LIST && (this->active_sel !=
nullptr || this->avail_sel !=
nullptr)) {
1412 to_pos =
min(to_pos, this->vscroll->
GetCount() - (this->active_sel !=
nullptr ? 2 : 1));
1414 if (to_pos != this->active_over) {
1415 this->active_over = to_pos;
1419 this->active_over = -2;
1421 }
else if (this->active_over != -1) {
1423 this->active_over = -1;
1432 if (i != 0)
return i < 0;
1435 if (i != 0)
return i < 0;
1444 filter.
AddLine((*a)->GetName());
1445 filter.
AddLine((*a)->filename);
1446 filter.
AddLine((*a)->GetDescription());
1450 void BuildAvailables()
1454 this->avails.clear();
1459 if (found)
continue;
1462 this->avails.push_back(c);
1473 this->avails.push_back(c);
1478 this->avails.
Filter(this->string_filter);
1479 this->avails.shrink_to_fit();
1481 this->avails.
Sort();
1483 if (this->avail_sel !=
nullptr) {
1484 this->avail_pos =
find_index(this->avails, this->avail_sel);
1485 if (this->avail_pos == -1) {
1486 this->avail_sel =
nullptr;
1490 this->vscroll2->
SetCount((uint)this->avails.size());
1500 if (this->avail_sel ==
nullptr || !this->editable ||
HasBit(this->avail_sel->
flags,
GCF_INVALID))
return false;
1508 for (list = &this->actives; *list !=
nullptr; list = &(*list)->
next, ins_pos--) {
1509 if (ins_pos == 0) entry = list;
1510 if ((*list)->ident.grfid == this->avail_sel->ident.grfid) {
1516 if (entry ==
nullptr) entry = list;
1530 int new_pos = this->avail_pos + 1;
1531 if (new_pos >= (
int)this->avails.size()) new_pos = this->avail_pos - 1;
1532 this->avail_pos = new_pos;
1533 if (new_pos >= 0) this->avail_sel = this->avails[new_pos];
1549 for (
const GRFConfig *c = list; c !=
nullptr; c = c->
next) {
1598 this->Add(this->avs);
1599 this->Add(this->acs);
1600 this->Add(this->inf);
1602 this->editable =
true;
1608 assert(dynamic_cast<NewGRFWindow *>(w) !=
nullptr);
1625 this->smallest_x =
max(min_avs_width, min_acs_width) + INTER_COLUMN_SPACING + min_inf_width;
1626 this->smallest_y =
max(min_inf_height, min_acs_height + INTER_LIST_SPACING + min_avs_height);
1630 if (this->inf->
fill_x > 0 && (this->fill_x == 0 || this->fill_x > this->inf->fill_x)) this->fill_x = this->inf->
fill_x;
1632 this->fill_y = this->avs->
fill_y;
1633 if (this->acs->
fill_y > 0 && (this->fill_y == 0 || this->fill_y > this->acs->fill_y)) this->fill_y = this->acs->
fill_y;
1638 if (this->inf->
resize_x > 0 && (this->resize_x == 0 || this->resize_x > this->inf->resize_x)) this->resize_x = this->inf->
resize_x;
1640 this->resize_y = this->avs->
resize_y;
1641 if (this->acs->
resize_y > 0 && (this->resize_y == 0 || this->resize_y > this->acs->resize_y)) this->resize_y = this->acs->
resize_y;
1645 this->smallest_y =
ComputeMaxSize(min_acs_height, this->smallest_y + this->resize_y - 1, this->resize_y);
1650 this->StoreSizePosition(sizing, x, y, given_width, given_height);
1656 uint min_list_width =
max(min_avs_width, min_acs_width);
1657 uint avs_extra_width = min_list_width - min_avs_width;
1658 uint acs_extra_width = min_list_width - min_acs_width;
1661 uint min_three_columns = min_avs_width + min_acs_width + min_inf_width + 2 * INTER_COLUMN_SPACING;
1662 uint min_two_columns = min_list_width + min_inf_width + INTER_COLUMN_SPACING;
1663 bool use_three_columns = this->editable && (min_three_columns + MIN_EXTRA_FOR_3_COLUMNS <= given_width);
1666 uint extra_width, inf_width;
1667 if (use_three_columns) {
1668 extra_width = given_width - min_three_columns;
1669 inf_width =
min(MAX_EXTRA_INFO_WIDTH, extra_width / 2);
1671 extra_width = given_width - min_two_columns;
1672 inf_width =
min(MAX_EXTRA_INFO_WIDTH, extra_width / 2);
1674 inf_width =
ComputeMaxSize(this->inf->
smallest_x, this->inf->smallest_x + inf_width, this->inf->GetHorizontalStepSize(sizing));
1675 extra_width -= inf_width - this->inf->
smallest_x;
1679 if (use_three_columns) {
1682 uint avs_width =
min(avs_extra_width, extra_width);
1683 extra_width -= avs_width;
1684 extra_width -=
min(acs_extra_width, extra_width);
1685 avs_width += extra_width / 2;
1687 avs_width =
ComputeMaxSize(this->avs->
smallest_x, this->avs->smallest_x + avs_width, this->avs->GetHorizontalStepSize(sizing));
1689 uint acs_width = given_width -
1703 x += inf_width + this->inf->
padding_right + INTER_COLUMN_SPACING;
1707 x += avs_width + this->avs->
padding_right + INTER_COLUMN_SPACING;
1712 x += acs_width + this->acs->
padding_right + INTER_COLUMN_SPACING;
1725 this->avs->GetHorizontalStepSize(sizing));
1727 this->acs->GetHorizontalStepSize(sizing));
1729 uint min_avs_height = (!this->
editable) ? 0 : this->avs->
smallest_y + this->avs->padding_top + this->avs->padding_bottom + INTER_LIST_SPACING;
1730 uint min_acs_height = this->acs->smallest_y + this->acs->padding_top + this->acs->padding_bottom;
1731 uint extra_height = given_height - min_acs_height - min_avs_height;
1734 uint avs_height =
ComputeMaxSize(this->avs->
smallest_y, this->avs->smallest_y + extra_height / 2, this->avs->resize_y);
1735 if (this->editable) extra_height -= avs_height - this->avs->
smallest_y;
1736 uint acs_height =
ComputeMaxSize(this->acs->
smallest_y, this->acs->smallest_y + extra_height, this->acs->resize_y);
1742 x += inf_width + this->inf->
padding_right + INTER_COLUMN_SPACING;
1745 if (this->editable) {
1746 this->avs->
AssignSizePosition(sizing, x + this->avs->
padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
1752 if (this->editable) {
1753 this->avs->
AssignSizePosition(sizing, x + this->avs->
padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
1758 if (this->editable) {
1759 dx =
max(dx, this->avs->
current_x + this->avs->padding_left + this->avs->padding_right);
1761 x += dx + INTER_COLUMN_SPACING + this->inf->
padding_left;
1769 if (!
IsInsideBS(x, this->pos_x, this->current_x) || !
IsInsideBS(y, this->pos_y, this->current_y))
return nullptr;
1779 if (this->editable) this->avs->
Draw(w);
1790 static const NWidgetPart _nested_newgrf_actives_widgets[] = {
1796 SetDataTip(STR_JUST_STRING, STR_NEWGRF_SETTINGS_PRESET_LIST_TOOLTIP),
1800 SetDataTip(STR_NEWGRF_SETTINGS_PRESET_SAVE, STR_NEWGRF_SETTINGS_PRESET_SAVE_TOOLTIP),
1802 SetDataTip(STR_NEWGRF_SETTINGS_PRESET_DELETE, STR_NEWGRF_SETTINGS_PRESET_DELETE_TOOLTIP),
1822 SetDataTip(STR_NEWGRF_SETTINGS_REMOVE, STR_NEWGRF_SETTINGS_REMOVE_TOOLTIP),
1825 SetDataTip(STR_NEWGRF_SETTINGS_MOVEUP, STR_NEWGRF_SETTINGS_MOVEUP_TOOLTIP),
1827 SetDataTip(STR_NEWGRF_SETTINGS_MOVEDOWN, STR_NEWGRF_SETTINGS_MOVEDOWN_TOOLTIP),
1830 SetDataTip(STR_NEWGRF_SETTINGS_UPGRADE, STR_NEWGRF_SETTINGS_UPGRADE_TOOLTIP),
1835 SetDataTip(STR_NEWGRF_SETTINGS_RESCAN_FILES, STR_NEWGRF_SETTINGS_RESCAN_FILES_TOOLTIP),
1837 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
1843 static const NWidgetPart _nested_newgrf_availables_widgets[] = {
1852 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1866 SetDataTip(STR_NEWGRF_SETTINGS_ADD, STR_NEWGRF_SETTINGS_ADD_FILE_TOOLTIP),
1869 SetDataTip(STR_NEWGRF_SETTINGS_RESCAN_FILES, STR_NEWGRF_SETTINGS_RESCAN_FILES_TOOLTIP),
1871 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
1877 static const NWidgetPart _nested_newgrf_infopanel_widgets[] = {
1885 SetDataTip(STR_CONTENT_OPEN_URL, STR_CONTENT_OPEN_URL_TOOLTIP),
1887 SetDataTip(STR_TEXTFILE_VIEW_README, STR_NULL),
1890 SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_NULL),
1892 SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_NULL),
1900 SetDataTip(STR_NEWGRF_SETTINGS_SET_PARAMETERS, STR_NULL),
1902 SetDataTip(STR_NEWGRF_SETTINGS_TOGGLE_PALETTE, STR_NEWGRF_SETTINGS_TOGGLE_PALETTE_TOOLTIP),
1905 SetDataTip(STR_NEWGRF_SETTINGS_APPLY_CHANGES, STR_NULL),
1908 SetDataTip(STR_NEWGRF_SETTINGS_SHOW_PARAMETERS, STR_NULL),
1919 *biggest_index =
max(*biggest_index, biggest2);
1922 *biggest_index =
max(*biggest_index, biggest2);
1928 static const NWidgetPart _nested_newgrf_widgets[] = {
1949 _nested_newgrf_widgets,
lengthof(_nested_newgrf_widgets)
1975 for (c = nw->
actives; c !=
nullptr && i > 0; c = c->
next, i--) {}
1999 new NewGRFWindow(&_newgrf_desc, editable, show_params, exec_changes, config);
2015 NWidget(
WWT_EDITBOX, COLOUR_GREY,
WID_SVP_EDITBOX),
SetPadding(3, 2, 2, 2),
SetFill(1, 0),
SetResize(1, 0),
2016 SetDataTip(STR_SAVE_PRESET_TITLE, STR_SAVE_PRESET_EDITBOX_TOOLTIP),
2030 _nested_save_preset_widgets,
lengthof(_nested_save_preset_widgets)
2047 this->selected = -1;
2048 if (initial_text !=
nullptr) {
2049 for (uint i = 0; i < this->presets.size(); i++) {
2050 if (this->presets[i] == initial_text) {
2065 this->vscroll->
SetCount((uint)this->presets.size());
2067 if (initial_text !=
nullptr) this->presetname_editbox.text.
Assign(initial_text);
2080 for (uint i = 0; i < this->presets.size(); i++) {
2083 resize->height =
max(resize->height, d.height);
2085 size->height =
ClampU((uint)this->presets.size(), 5, 20) * resize->height + 1;
2101 uint max_index =
min(min_index + this->vscroll->
GetCapacity(), (uint)this->presets.size());
2103 for (uint i = min_index; i < max_index; i++) {
2106 const char *text = this->presets[i].c_str();
2120 if (row < this->presets.size()) {
2121 this->selected = row;
2122 this->presetname_editbox.text.
Assign(this->presets[row].c_str());
2177 _nested_scan_progress_widgets,
lengthof(_nested_scan_progress_widgets)
2227 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);
2250 free(this->last_name);
2251 if (name ==
nullptr) {
2253 GetString(buf, STR_NEWGRF_SCAN_ARCHIVES,
lastof(buf));
2254 this->last_name =
stredup(buf);
2256 this->last_name =
stredup(name);
2258 this->scanned = num;
EventState
State of handling an event.
StringList presets
Available presets.
Functions related to OTTD's strings.
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
Base types for having sorted lists in GUIs.
uint32 PaletteID
The number of the palette.
void RebuildDone()
Notify the sortlist that the rebuild is done.
QueryString filter_editbox
Filter editbox;.
void OnMouseDrag(Point pt, int widget) override
An 'object' is being dragged at the provided position, highlight the target if possible.
SmallMap< uint32, struct GRFText * > value_names
Names for each value.
void SetValue(struct GRFConfig *config, uint32 value)
Set the value of this user-changeable parameter in the given config.
static const NWidgetPart _nested_save_preset_widgets[]
Widget parts of the save preset window.
void OnResize() override
Called after the window got resized.
Horizontally center the text.
ResizeInfo resize
Resize information.
bool editable
Allow editing parameters.
uint32 param_value[2]
Values of GRF parameters to show for message and custom_message.
GRFConfig ** orig_list
List active grfs in the game. Used as initial value, may be updated by the window.
uint32 unique_id
Unique ID; either GRF ID or shortname.
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...
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
The parameter allows a range of numbers, each of which can have a special name.
NWidgetBase * NewGRFDisplay(int *biggest_index)
Construct nested container widget for managing the lists and the info panel of the NewGRF GUI...
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
GRFConfig * _grfconfig
First item in list of current GRF set up.
High level window description.
static bool CDECL TagNameFilter(const GRFConfig *const *a, StringFilter &filter)
Filter grfs by tags/name.
NewGRFs were just rescanned.
void SetParameterDefaults()
Set the default value for all parameters as specified by action14.
void SaveGRFPresetToConfig(const char *config_name, GRFConfig *config)
Save a NewGRF configuration with a preset name.
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
void DrawWidgets() const
Paint all widgets of a window.
static GRFParameterInfo * GetDummyParameterInfo(uint nr)
Get a dummy parameter-info object with default information.
void OnResize() override
Called after the window got resized.
void ClearGRFConfigList(GRFConfig **config)
Clear a GRF Config list, freeing all nodes.
GRFParameterType type
The type of this parameter.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
GUIGRFConfigList avails
Available (non-active) grfs.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Offset at top to draw the frame rectangular area.
Progress report of landscape generation; Window numbers:
Normal amount of vertical space between two paragraphs of text.
textfile; Window numbers:
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
void ResetState()
Reset the matching state to process a new item.
The passed event is not handled.
bool Elapsed(uint delta)
Test if a timer has elapsed.
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
bool GetState() const
Get the matching state of the current item.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
Functions to be called to log possibly unsafe game events.
The NewGRF prefers a 32 bpp blitter.
Window for showing the progress of NewGRF scanning.
std::vector< Pair >::const_iterator Find(const T &key) const
Finds given key in this map.
void GamelogStartAction(GamelogActionType at)
Stores information about new action, but doesn't allocate it Action is allocated only when there is a...
StringFilter string_filter
Filter for available grf.
GRFConfig * LoadGRFPresetFromConfig(const char *config_name)
Load a NewGRF configuration by preset-name.
GRFStatus status
NOSAVE: GRFStatus, enum.
void UpdateNewGRFScanStatus(uint num, const char *name)
Update the NewGRF scan status.
static GRFParameterInfo dummy_parameter_info
Dummy info in case a newgrf didn't provide info about some parameter.
char * md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
Convert the md5sum to a hexadecimal string representation.
static const int ACTION_CLEAR
Clear editbox.
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.
bool clicked_increase
True if the increase button was clicked, false for the decrease button.
~ScanProgressWindow()
Free the last name buffer.
static void ShowSavePresetWindow(const char *initial_text)
Open the window for saving a preset.
int top
y position of top edge of the window
GRF file is used statically (can be used in any MP game)
int LeastCommonMultiple(int a, int b)
Compute least common multiple (lcm) of arguments a and b, the smallest integer value that is a multip...
uint8 num_valid_params
NOSAVE: Number of valid parameters (action 0x14)
char * custom_message
Custom message (if present)
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.
std::map< uint32, const GRFConfig * > GrfIdMap
Map of grfid to the grf config.
GRFError * error
NOSAVE: Error/Warning during GRF loading (Action 0x0B)
Offset at top of a matrix cell.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
The NewGRF provided no information.
byte param_nr
GRF parameter to store content in.
void OnNewGRFsScanned() override
Called whenever the NewGRF scan completed.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
uint8 original_md5sum[16]
MD5 checksum of original file if only a 'compatible' file was loaded.
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.
bool show_params
Are the grf-parameters shown in the info-panel?
#define lastof(x)
Get the last element of an fixed size array.
void OnPaint() override
The window must be repainted.
StringID severity
Info / Warning / Error / Fatal.
GRF file was not found in the local cache.
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
static const NWidgetPart _nested_scan_progress_widgets[]
Widgets for the progress window.
SavePresetWindow(const char *initial_text)
Constructor of the save preset window.
void DisableWidget(byte widget_index)
Sets a widget to disabled.
const GRFConfig * FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8 *md5sum, uint32 desired_version)
Find a NewGRF in the scanned list.
GRFIdentifier ident
grfid and md5sum to uniquely identify newgrfs
static T max(const T a, const T b)
Returns the maximum of two values.
uint32 last_newgrf_count
the numbers of NewGRFs we found during the last scan
bool newgrf_show_old_versions
whether to show old versions in the NewGRF list
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
void SetListing(Listing l)
Import sort conditions.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
struct GRFConfig * next
NOSAVE: Next item in the linked list.
int selected
Selected entry in the preset list, or -1 if none selected.
Data structure describing what to show in the list (filter criteria).
int HideDropDownMenu(Window *pw)
Delete the drop-down menu from window pw.
bool NeedRebuild() const
Check if a rebuild is needed.
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.
static uint ClampU(const uint a, const uint min, const uint max)
Clamp an unsigned integer between an interval.
A NewGRF preset was picked.
bool _network_available
is network mode available?
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
The content does not exist in the content system.
void ForceRebuild()
Force that a rebuild is needed.
Base for the GUIs that have an edit box in them.
Data structure for an opened window.
GRFConfig * _all_grfs
First item in list of all scanned NewGRFs.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void SetFilterTerm(const char *str)
Set the term to filter on.
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
bool clicked_dropdown
Whether the dropdown is open.
dragging items in the depot windows
Critical errors, the MessageBox is shown in all cases.
struct GRFText * desc
The description of this parameter.
Bottom offset of the text of the frame.
Header of Action 04 "universal holder" structure and functions.
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
char name[32]
Name of the content.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
void ShowMissingContentWindow(const GRFConfig *list)
Show the content list window with all missing grfs from the given list.
GRFConfig * actives
Temporary active grf list to which changes are made.
uint32 GetValue(struct GRFConfig *config) const
Get the value of this user-changeable parameter from the given config.
uint8 num_params
Number of used parameters.
static const uint8 PC_DARK_GREY
Dark grey palette colour.
int preset
Selected preset or -1 if none selected.
Functions related to errors.
Offset at bottom of a matrix cell.
static void FillGrfidMap(const GRFConfig *c, GrfIdMap *grfid_map)
Add all grf configs from c into the map.
char * last_name
The name of the last 'seen' NewGRF.
std::vector< ContentInfo * > ContentVector
Vector with content info.
EventState OnKeyPress(WChar key, uint16 keycode) override
A key has been pressed.
Information about GRF, used in the game and (part of it) in savegames.
Window for showing NewGRF files.
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...
int ok_button
Widget button of parent window to simulate when pressing OK in OSK.
GRFConfig ** CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only)
Copy a GRF Config list.
void ShowNewGRFError()
Show the first NewGRF error we can find.
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Bitmask to get only the use palette use states.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
bool Contains(const T &key) const
Tests whether a key is assigned in this map.
const char * GetDescription() const
Get the grf info.
Functions related to setting/changing the settings.
void CopyParams(const GRFConfig &src)
Copy the parameter information from the src config.
Data stored about a string that can be modified in the GUI.
char * GRFBuildParamList(char *dst, const GRFConfig *c, const char *last)
Build a string containing space separated parameter values, and terminate.
ClientSettings _settings_client
The current settings for this game.
ScanProgressWindow()
Create the window.
Types related to global configuration settings.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
The palette state is set to use the Windows palette.
Definition of base types and functions in a cross-platform compatible way.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void OnRealtimeTick(uint delta_ms) override
Called periodically.
A number of safeguards to prevent using unsafe methods.
uint32 max_value
The maximal value of this parameter.
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.
bool closing_dropdown
True, if the dropdown list is currently closing.
void DeleteChildWindows(WindowClass wc=WC_INVALID) const
Delete all children a window might have in a head-recursive manner.
Offset at bottom to draw below the text.
static Listing last_sorting
Default sorting of #GUIGRFConfigList.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
uint8 flags
NOSAVE: GCF_Flags, bitset.
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
GRF is unusable with this version of OpenTTD.
State state
Whether the content info is selected (for download)
void SetDParamMaxDigits(uint n, uint count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
const GRFConfig * grf_config
View the textfile of this GRFConfig.
int avail_pos
Index of avail_sel if existing, else -1.
Find newest Grf, ignoring Grfs with GCF_INVALID set.
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.
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
Offset at bottom to draw the frame rectangular area.
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.
Window for setting the parameters of a NewGRF.
StringList grf_presets
List of known NewGRF presets.
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Basic functions/variables used all over the place.
Part of the network protocol handling content distribution.
Right offset of the text of the frame.
#define lengthof(x)
Return the length of an fixed size array.
TextfileType
Additional text files accompanying Tar archives.
StringID message
Default message.
static T min(const T a, const T b)
Returns the minimum of two values.
Top offset of the text of the frame.
Left offset of the text of the frame.
Types related to the drop down widget.
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
Draw [<][>] boxes.
bool Sort(SortFunction *compare)
Sort the list.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
int active_over
Active GRF item over which another one is dragged, -1 if none.
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
static const uint8 PC_BLACK
Black palette colour.
byte md5sum[16]
The MD5 checksum.
bool HasGrfIdentifier(uint32 grfid, const uint8 *md5sum) const
Does the identification match the provided values?
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
static void NewGRFConfirmationCallback(Window *w, bool confirmed)
Callback function for the newgrf 'apply changes' confirmation window.
Build object; Window numbers:
bool CanUpgradeCurrent()
Test whether the currently active set of NewGRFs can be upgraded with the available NewGRFs...
Draw border only, no background.
List of active NewGRFs is being edited.
Subdirectory for all NewGRFs.
Offset at top to draw above the text.
The window is a modal child of some other window, meaning the parent is 'inactive'.
void GamelogStopAction()
Stops logging of any changes.
uint32 version
NOSAVE: Version a NewGRF can set so only the newest NewGRF is shown.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
void Assign(StringID string)
Render a string into the textbuffer.
The content consists of a NewGRF.
void DeleteGRFPresetFromConfig(const char *config_name)
Delete a NewGRF configuration by preset name.
bool newgrf_developer_tools
activate NewGRF developer tools and allow modifying NewGRFs in an existing game
QueryString presetname_editbox
Edit box of the save preset.
GUITimer timeout
How long before we unpress the last-pressed button?
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
bool execute
On pressing 'apply changes' are grf changes applied immediately, or only list is updated.
const GRFConfig * avail_sel
Currently selected available grf. nullptr is none is selected.
void AddLine(const char *str)
Pass another text line from the current item to the filter.
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
Calculate string bounding box for multi-line strings.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
No window, redirects to WC_MAIN_WINDOW.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
static const uint8 PC_GREY
Grey palette colour.
static const uint8 PC_DARK_BLUE
Dark blue palette colour.
Callback for NewGRF scanning.
const char * GetURL() const
Get the grf url.
const char * GetGRFStringFromGRFText(const GRFText *text)
Get a C-string from a GRFText-list.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
char *const buf
buffer in which text is saved
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...
bool editable
Is the window editable?
static bool NameSorter(const GRFConfig *const &a, const GRFConfig *const &b)
Sort grfs by name.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
bool scenario_developer
activate scenario developer: allow modifying NewGRFs in an existing game
void ReInitAllWindows()
Re-initialize all windows.
Save preset; Window numbers:
GUISettings gui
settings related to the GUI
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.
PaletteID GetPalette(const GRFConfig *c) const
Pick the palette for the sprite of the grf to display.
void OnDragDrop(Point pt, int widget) override
A dragged 'object' has been released.
Information about one grf parameter.
Window for displaying a textfile.
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Declarations for savegames operations.
void SetFilterState(bool state)
Enable or disable the filter.
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.
const char * GetTextfile(TextfileType type) const
Search a textfile file next to this NewGRF.
uint8 palette
GRFPalette, bitset.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
int scanned
The number of NewGRFs that we have seen.
bool complete_labels
True if all values have a label.
TextDirection _current_text_dir
Text direction of the currently selected language.
ContentType type
Type of content.
bool CDECL FilterFunction(const T *, F)
Signature of filter function.
void OnResize() override
Called after the window got resized.
Searching and filtering using a stringterm.
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.
std::vector< std::string > StringList
Type for a list of strings.
void ResetGRFConfig(bool defaults)
Reset the current GRF Config to either blank or newgame settings.
Functions for setting GUIs.
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
GRFConfig * grf_config
Set the parameters of this GRFConfig.
char * filename
Filename - either with or without full path.
bool action14present
True if action14 information is present.
int line_height
Height of a row in the matrix widget.
uint clicked_button
The row in which a button was clicked or UINT_MAX.
static GUIGRFConfigList::FilterFunction *const filter_funcs[]
Filter functions of the #GUIGRFConfigList.
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
Functions related to the drop down widget.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
Draw a dropdown button.
Window * FindWindowByClass(WindowClass cls)
Find any window by its class.
void OnEditboxChanged(int wid) override
The text in an editbox has been edited.
void ScanNewGRFFiles(NewGRFScanCallback *callback)
Scan for all NewGRFs.
Coordinates of a point in 2D.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
List item containing a C char string.
uint32 min_loadable_version
NOSAVE: Minimum compatible version a NewGRF can define.
Data structure describing how to show the list (what sort direction and criteria).
std::vector< GRFParameterInfo * > param_info
NOSAVE: extra information about the parameters.
The parameter is either 0 or 1.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
uint32 min_value
The minimal value this parameter can have.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
const char * GetName() const
Get the name of this grf.
uint32 grfid
GRF ID (defined by Action 0x08)
char * data
Additional data for message and custom_message.
struct GRFText * name
The name of this parameter.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Width of a resize box widget.
Offset at right to draw the frame rectangular area.
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.
void SetFiltering(Filtering f)
Import filter conditions.
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
int width
width of the window (number of pixels to the right in x direction)
uint32 param[0x80]
GRF parameters.
GRF file has been activated.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
bool AddGRFToActive(int ins_pos=-1)
Insert a GRF into the active list.
NewGRF parameters; Window numbers:
Scrollbar * vscroll
Pointer to the scrollbar widget.
GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches) ...
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
Specification of a rectangle with absolute coordinates of all edges.
The passed event is handled.
Text is written right-to-left by default.
static GUIGRFConfigList::SortFunction *const sorter_funcs[]
Sort functions of the #GUIGRFConfigList.
Bitmask to get only the NewGRF supplied information.
Functions related to tile highlights.
static uint32 BSWAP32(uint32 x)
Perform a 32 bits endianness bitswap on x.
Window functions not directly related to making/drawing windows.
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
uint8 md5sum[16]
MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF) ...
Only find Grfs matching md5sum.
bool SortFunction(const T &, const T &)
Signature of sort function.
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Errors (eg. saving/loading failed)
void GamelogGRFUpdate(const GRFConfig *oldc, const GRFConfig *newc)
Compares two NewGRF lists and logs any change.
uint32 WChar
Type for wide characters, i.e.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
GRFConfig * active_sel
Selected active grf item.
Dimensions (a width and height) of a rectangle in 2D.
Container for all important information about a piece of content.
Query string window; Window numbers:
bool IsEmpty() const
Check whether any filter words were entered.
Offset at left to draw the frame rectangular area.
This file contains all sprite-related enums and defines.
static Filtering last_filtering
Default filtering of #GUIGRFConfigList.
Game options window; Window numbers:
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_...
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
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.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
static const uint NETWORK_MAX_GRF_COUNT
Maximum number of GRFs that can be sent.
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.
Window for displaying the textfile of a NewGRF.
void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
A dropdown window associated to this window has been closed.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
uint clicked_row
The selected parameter.
void UpdateNewGRFScanStatus(uint num, const char *name)
Update the NewGRF scan status.
GUI functions related to textfiles.
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.
StringList GetGRFPresetList()
Get the list of known NewGrf presets.
Class for the save preset window.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
void UpgradeCurrent()
Upgrade the currently active set of NewGRFs.
Base for the NewGRF implementation.