47 if (_game_mode == GM_MENU)
return;
51 if (c->error ==
nullptr || c->error->severity != STR_NEWGRF_ERROR_MSG_FATAL)
continue;
53 SetDParam (0, c->error->custom_message ==
nullptr ? c->error->message : STR_JUST_RAW_STRING);
57 for (uint i = 0; i <
lengthof(c->error->param_value); i++) {
58 SetDParam(4 + i, c->error->param_value[i]);
65 static void ShowNewGRFInfo(
const GRFConfig *c, uint x, uint y, uint right, uint bottom,
bool show_params)
67 if (c->
error !=
nullptr) {
114 SetDParam(0, STR_NEWGRF_SETTINGS_PARAMETER_NONE);
161 clicked_button(UINT_MAX),
162 clicked_dropdown(false),
163 closing_dropdown(false),
164 clicked_row(UINT_MAX),
172 this->GetWidget<NWidgetStacked>(
WID_NP_SHOW_DESCRIPTION)->SetDisplayedPlane(this->action14present ? 0 : SZSP_HORIZONTAL);
204 d.width += padding.width;
205 d.height += padding.height;
221 for (uint i = 0; i < this->grf_config->
param_info.size(); i++) {
223 if (par_info ==
nullptr)
continue;
225 if (desc ==
nullptr)
continue;
228 suggestion =
maxdim(d, suggestion);
230 size->height = suggestion.height;
248 if (par_info ==
nullptr)
return;
250 if (desc ==
nullptr)
return;
268 uint32 current_value = par_info->
GetValue(this->grf_config);
272 DrawBoolButton(buttons_left, y + button_y_offset, current_value != 0, this->editable);
273 SetDParam(2, par_info->
GetValue(this->grf_config) == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
276 DrawDropDownButton(buttons_left, y + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && this->clicked_dropdown, this->editable);
278 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);
284 if (label !=
nullptr) {
292 if (name !=
nullptr) {
296 SetDParam(0, STR_NEWGRF_PARAMETERS_DEFAULT_NAME);
300 DrawString(text_left, text_right, y + text_y_offset, STR_NEWGRF_PARAMETERS_SETTING, selected ? TC_WHITE : TC_LIGHT_BLUE);
307 if (this->closing_dropdown) {
308 this->closing_dropdown =
false;
309 this->clicked_dropdown =
false;
318 if (this->editable && !this->action14present && this->grf_config->
num_params > 0) {
336 if (!this->editable)
break;
338 if (num >= this->vscroll->
GetCount())
break;
339 if (this->clicked_row != num) {
342 this->clicked_row = num;
343 this->clicked_dropdown =
false;
347 int x = pt.x - wid->
pos_x;
355 uint32 old_val = par_info->
GetValue(this->grf_config);
357 if (this->clicked_dropdown) {
360 this->clicked_dropdown =
false;
361 this->closing_dropdown =
false;
373 if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
374 this->clicked_dropdown =
true;
375 this->closing_dropdown =
false;
378 for (uint32 i = par_info->
min_value; i <= par_info->max_value; i++) {
386 uint32 val = old_val;
392 if (val < par_info->max_value) val++;
393 this->clicked_increase =
true;
397 this->clicked_increase =
false;
400 if (val != old_val) {
401 par_info->
SetValue(this->grf_config, val);
403 this->clicked_button = num;
404 this->timeout.SetInterval(150);
416 if (!this->editable)
break;
431 int32 value = atoi(str);
435 par_info->
SetValue(this->grf_config, val);
441 assert(this->clicked_dropdown);
444 par_info->
SetValue(this->grf_config, index);
454 assert(this->clicked_dropdown);
455 this->closing_dropdown =
true;
471 if (!gui_scope)
return;
472 if (!this->action14present) {
478 if (this->clicked_row != UINT_MAX && this->clicked_row >= this->vscroll->
GetCount()) {
479 this->clicked_row = UINT_MAX;
486 if (timeout.
Elapsed(delta_ms)) {
487 this->clicked_button = UINT_MAX;
495 static const NWidgetPart _nested_newgrf_parameter_widgets[] = {
506 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 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),
529 WDP_CENTER,
"settings_newgrf_config", 500, 208,
532 _nested_newgrf_parameter_widgets,
lengthof(_nested_newgrf_parameter_widgets)
547 const char *textfile = this->grf_config->
GetTextfile(file_type);
566 typedef std::map<uint32, const GRFConfig *>
GrfIdMap;
575 while (c !=
nullptr) {
576 std::pair<uint32, const GRFConfig *> p(c->
ident.
grfid, c);
577 grfid_map->insert(p);
591 static const uint EDITBOX_MAX_SIZE = 50;
595 static GUIGRFConfigList::SortFunction *
const sorter_funcs[];
596 static GUIGRFConfigList::FilterFunction *
const filter_funcs[];
621 this->avail_sel =
nullptr;
622 this->avail_pos = -1;
623 this->active_sel =
nullptr;
624 this->actives =
nullptr;
625 this->orig_list = orig_list;
627 this->execute = execute;
628 this->show_params = show_params;
630 this->active_over = -1;
639 this->GetWidget<NWidgetStacked>(
WID_NS_SHOW_REMOVE)->SetDisplayedPlane(this->editable ? 0 : 1);
666 if (this->editable && !this->execute) {
686 GrfIdMap::const_iterator iter = grfid_map.find(a->ident.grfid);
687 if (iter != grfid_map.end() && a->version > iter->second->version)
return true;
699 GrfIdMap::iterator iter = grfid_map.find(a->ident.grfid);
700 if (iter == grfid_map.end() || iter->second->version >= a->version)
continue;
703 while (*c != iter->second) c = &(*c)->
next;
707 if (this->active_sel == *c) {
710 this->active_sel =
nullptr;
747 for (
const auto &i : this->grf_presets) {
751 d.width += padding.width;
760 size->width += padding.width;
761 size->height += padding.height;
777 if (this->preset == -1) {
781 SetDParamStr(1, this->grf_presets[this->preset].c_str());
800 pal = PALETTE_TO_RED;
803 pal = PALETTE_TO_GREEN;
806 pal = PALETTE_TO_BLUE;
811 if (pal != PALETTE_TO_RED) {
813 pal = PALETTE_TO_GREY;
815 pal = PALETTE_TO_ORANGE;
828 uint step_height = this->GetWidget<NWidgetBase>(
WID_NS_FILE_LIST)->resize_y;
832 int square_offset_y = (step_height - square.height) / 2;
833 int warning_offset_y = (step_height - warning.height) / 2;
839 uint square_left = rtl ? r.right - square.width - 5 : r.left + 5;
840 uint warning_left = rtl ? r.right - square.width - warning.width - 10 : r.left + square.width + 10;
843 for (
const GRFConfig *c = this->actives; c !=
nullptr; c = c->
next, i++) {
845 const char *text = c->
GetName();
846 bool h = (this->active_sel == c);
851 }
else if (i == this->active_over) {
853 int active_sel_pos = 0;
854 for (
GRFConfig *c = this->actives; c !=
nullptr && c != this->active_sel; c = c->
next, active_sel_pos++) {}
855 if (active_sel_pos != this->active_over) {
856 uint
top = this->active_over < active_sel_pos ? y + 1 : y + step_height - 2;
860 DrawSprite(SPR_SQUARE, pal, square_left, y + square_offset_y);
861 if (c->
error !=
nullptr)
DrawSprite(SPR_WARNING_SIGN, 0, warning_left, y + warning_offset_y);
862 uint txtoffset = c->
error ==
nullptr ? 0 : warning.width;
863 DrawString(text_left + (rtl ? 0 : txtoffset), text_right - (rtl ? txtoffset : 0), y + offset_y, text, h ? TC_WHITE : TC_ORANGE);
867 if (i == this->active_over && this->vscroll->
IsVisible(i)) {
880 uint max_index =
min(min_index + this->vscroll2->
GetCapacity(), (uint)this->avails.size());
882 for (uint i = min_index; i < max_index; i++) {
884 bool h = (c == this->avail_sel);
885 const char *text = c->
GetName();
901 const GRFConfig *selected = this->active_sel;
902 if (selected ==
nullptr) selected = this->avail_sel;
903 if (selected !=
nullptr) {
914 if (this->active_sel ==
nullptr && this->avail_sel ==
nullptr)
return;
927 for (uint i = 0; i < this->grf_presets.size(); i++) {
937 const GRFConfig *c = (this->avail_sel ==
nullptr) ? this->active_sel : this->avail_sel;
939 extern void OpenBrowser(
const char *url);
949 if (this->preset == -1)
return;
959 if (this->active_sel ==
nullptr || !this->editable)
break;
962 for (
GRFConfig **pc = &this->actives; *pc !=
nullptr; pc = &(*pc)->
next, pos++) {
964 if (c->
next == this->active_sel) {
966 this->active_sel->
next = c;
967 *pc = this->active_sel;
978 if (this->active_sel ==
nullptr || !this->editable)
break;
981 for (
GRFConfig **pc = &this->actives; *pc !=
nullptr; pc = &(*pc)->
next, pos++) {
983 if (c == this->active_sel) {
1002 for (c = this->actives; c !=
nullptr && i > 0; c = c->
next, i--) {}
1004 if (this->active_sel != c) {
1008 this->active_sel = c;
1009 this->avail_sel =
nullptr;
1010 this->avail_pos = -1;
1013 if (click_count == 1) {
1022 if (this->active_sel ==
nullptr || !this->editable)
break;
1028 for (
GRFConfig **pc = &this->actives; *pc !=
nullptr; pc = &(*pc)->
next) {
1032 if (newsel ==
nullptr && c->
next == this->active_sel) newsel = c;
1034 if (c == this->active_sel) {
1035 if (newsel == c) newsel =
nullptr;
1043 this->active_sel = newsel;
1045 this->avail_pos = -1;
1046 this->avail_sel =
nullptr;
1053 if (!this->editable || this->actives ==
nullptr)
break;
1063 this->active_sel =
nullptr;
1065 if (i < this->avails.size()) {
1067 this->avail_sel = this->avails[i];
1068 this->avail_pos = i;
1071 if (click_count == 1) {
1082 this->AddGRFToActive();
1086 if (!this->editable)
break;
1087 if (this->execute) {
1089 STR_NEWGRF_POPUP_CAUTION_CAPTION,
1090 STR_NEWGRF_CONFIRMATION_TEXT,
1104 if (this->active_sel ==
nullptr || !this->show_params || this->active_sel->
num_valid_params == 0)
break;
1106 OpenGRFParameterWindow(this->active_sel, this->editable);
1111 if (this->active_sel !=
nullptr && this->editable) {
1138 this->avail_sel =
nullptr;
1139 this->avail_pos = -1;
1146 if (!this->editable)
return;
1149 this->preset = index;
1159 this->active_sel =
nullptr;
1165 if (str ==
nullptr)
return;
1171 for (uint i = 0; i < this->grf_presets.size(); i++) {
1172 if (this->grf_presets[i] == str) {
1188 if (!gui_scope)
return;
1196 for (
GRFConfig **l = &this->actives; *l !=
nullptr; l = &(*l)->
next) {
1205 (*l)->next = c->
next;
1207 if (this->active_sel == c) this->active_sel = *l;
1222 for (
const GRFConfig *c = this->actives; c !=
nullptr; c = c->
next, i++) {}
1226 if (this->avail_pos >= 0) this->vscroll2->
ScrollTowards(this->avail_pos);
1231 this->BuildAvailables();
1242 bool disable_all = this->active_sel ==
nullptr || !this->
editable;
1250 const GRFConfig *c = (this->avail_sel ==
nullptr) ? this->active_sel : this->avail_sel;
1251 for (
TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
1269 bool has_missing =
false;
1270 bool has_compatible =
false;
1271 for (
const GRFConfig *c = this->actives; !has_missing && c !=
nullptr; c = c->
next) {
1277 if (has_missing || has_compatible) {
1278 widget_data = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON;
1279 tool_tip = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP;
1281 widget_data = STR_INTRO_ONLINE_CONTENT;
1282 tool_tip = STR_INTRO_TOOLTIP_ONLINE_CONTENT;
1299 if (this->avail_pos > 0) this->avail_pos--;
1304 if (this->avail_pos < (
int)this->avails.size() - 1) this->avail_pos++;
1309 this->avail_pos = (this->avail_pos < this->vscroll2->
GetCapacity()) ? 0 : this->avail_pos - this->vscroll2->
GetCapacity();
1314 this->avail_pos =
min(this->avail_pos + this->vscroll2->
GetCapacity(), (int)this->avails.size() - 1);
1319 this->avail_pos = 0;
1324 this->avail_pos = (uint)this->avails.size() - 1;
1331 if (this->avails.size() == 0) this->avail_pos = -1;
1332 if (this->avail_pos >= 0) {
1333 this->active_sel =
nullptr;
1336 this->avail_sel = this->avails[this->avail_pos];
1346 if (!this->editable)
return;
1356 if (!this->editable)
return;
1359 if (this->active_sel !=
nullptr) {
1363 for (from_prev = &this->actives; *from_prev != this->active_sel; from_prev = &(*from_prev)->
next, from_pos++) {}
1367 if (to_pos != from_pos) {
1370 for (
int i = from_pos < to_pos ? -1 : 0; *to_prev !=
nullptr && i < to_pos; to_prev = &(*to_prev)->
next, i++) {}
1373 *from_prev = this->active_sel->
next;
1376 this->active_sel->
next = *to_prev;
1377 *to_prev = this->active_sel;
1383 }
else if (this->avail_sel !=
nullptr) {
1385 this->AddGRFToActive(to_pos);
1389 Point dummy = {-1, -1};
1395 if (this->active_over != -1) {
1398 this->active_over = -1;
1404 if (!this->editable)
return;
1406 if (widget ==
WID_NS_FILE_LIST && (this->active_sel !=
nullptr || this->avail_sel !=
nullptr)) {
1410 to_pos =
min(to_pos, this->vscroll->
GetCount() - (this->active_sel !=
nullptr ? 2 : 1));
1412 if (to_pos != this->active_over) {
1413 this->active_over = to_pos;
1417 this->active_over = -2;
1419 }
else if (this->active_over != -1) {
1421 this->active_over = -1;
1430 if (i != 0)
return i < 0;
1433 if (i != 0)
return i < 0;
1442 filter.
AddLine((*a)->GetName());
1443 filter.
AddLine((*a)->filename);
1444 filter.
AddLine((*a)->GetDescription());
1448 void BuildAvailables()
1452 this->avails.clear();
1457 if (found)
continue;
1460 this->avails.push_back(c);
1471 this->avails.push_back(c);
1476 this->avails.
Filter(this->string_filter);
1477 this->avails.shrink_to_fit();
1479 this->avails.
Sort();
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;
1488 this->vscroll2->
SetCount((uint)this->avails.size());
1498 if (this->avail_sel ==
nullptr || !this->editable ||
HasBit(this->avail_sel->
flags,
GCF_INVALID))
return false;
1506 for (list = &this->actives; *list !=
nullptr; list = &(*list)->
next, ins_pos--) {
1507 if (ins_pos == 0) entry = list;
1508 if ((*list)->ident.grfid == this->avail_sel->ident.grfid) {
1514 if (entry ==
nullptr) entry = 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];
1547 for (
const GRFConfig *c = list; c !=
nullptr; c = c->
next) {
1596 this->Add(this->avs);
1597 this->Add(this->acs);
1598 this->Add(this->inf);
1600 this->editable =
true;
1606 assert(dynamic_cast<NewGRFWindow *>(w) !=
nullptr);
1623 this->smallest_x =
max(min_avs_width, min_acs_width) + INTER_COLUMN_SPACING + min_inf_width;
1624 this->smallest_y =
max(min_inf_height, min_acs_height + INTER_LIST_SPACING + min_avs_height);
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;
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;
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;
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;
1643 this->smallest_y =
ComputeMaxSize(min_acs_height, this->smallest_y + this->resize_y - 1, this->resize_y);
1648 this->StoreSizePosition(sizing, x, y, given_width, given_height);
1654 uint min_list_width =
max(min_avs_width, min_acs_width);
1655 uint avs_extra_width = min_list_width - min_avs_width;
1656 uint acs_extra_width = min_list_width - min_acs_width;
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);
1664 uint extra_width, inf_width;
1665 if (use_three_columns) {
1666 extra_width = given_width - min_three_columns;
1667 inf_width =
min(MAX_EXTRA_INFO_WIDTH, extra_width / 2);
1669 extra_width = given_width - min_two_columns;
1670 inf_width =
min(MAX_EXTRA_INFO_WIDTH, extra_width / 2);
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;
1677 if (use_three_columns) {
1680 uint avs_width =
min(avs_extra_width, extra_width);
1681 extra_width -= avs_width;
1682 extra_width -=
min(acs_extra_width, extra_width);
1683 avs_width += extra_width / 2;
1685 avs_width =
ComputeMaxSize(this->avs->
smallest_x, this->avs->smallest_x + avs_width, this->avs->GetHorizontalStepSize(sizing));
1687 uint acs_width = given_width -
1701 x += inf_width + this->inf->
padding_right + INTER_COLUMN_SPACING;
1705 x += avs_width + this->avs->
padding_right + INTER_COLUMN_SPACING;
1710 x += acs_width + this->acs->
padding_right + INTER_COLUMN_SPACING;
1723 this->avs->GetHorizontalStepSize(sizing));
1725 this->acs->GetHorizontalStepSize(sizing));
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;
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);
1740 x += inf_width + this->inf->
padding_right + INTER_COLUMN_SPACING;
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);
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);
1756 if (this->editable) {
1757 dx =
max(dx, this->avs->
current_x + this->avs->padding_left + this->avs->padding_right);
1759 x += dx + INTER_COLUMN_SPACING + this->inf->
padding_left;
1767 if (!
IsInsideBS(x, this->pos_x, this->current_x) || !
IsInsideBS(y, this->pos_y, this->current_y))
return nullptr;
1777 if (this->editable) this->avs->
Draw(w);
1788 static const NWidgetPart _nested_newgrf_actives_widgets[] = {
1794 SetDataTip(STR_JUST_STRING, STR_NEWGRF_SETTINGS_PRESET_LIST_TOOLTIP),
1798 SetDataTip(STR_NEWGRF_SETTINGS_PRESET_SAVE, STR_NEWGRF_SETTINGS_PRESET_SAVE_TOOLTIP),
1800 SetDataTip(STR_NEWGRF_SETTINGS_PRESET_DELETE, STR_NEWGRF_SETTINGS_PRESET_DELETE_TOOLTIP),
1820 SetDataTip(STR_NEWGRF_SETTINGS_REMOVE, STR_NEWGRF_SETTINGS_REMOVE_TOOLTIP),
1823 SetDataTip(STR_NEWGRF_SETTINGS_MOVEUP, STR_NEWGRF_SETTINGS_MOVEUP_TOOLTIP),
1825 SetDataTip(STR_NEWGRF_SETTINGS_MOVEDOWN, STR_NEWGRF_SETTINGS_MOVEDOWN_TOOLTIP),
1828 SetDataTip(STR_NEWGRF_SETTINGS_UPGRADE, STR_NEWGRF_SETTINGS_UPGRADE_TOOLTIP),
1833 SetDataTip(STR_NEWGRF_SETTINGS_RESCAN_FILES, STR_NEWGRF_SETTINGS_RESCAN_FILES_TOOLTIP),
1835 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
1841 static const NWidgetPart _nested_newgrf_availables_widgets[] = {
1850 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1864 SetDataTip(STR_NEWGRF_SETTINGS_ADD, STR_NEWGRF_SETTINGS_ADD_FILE_TOOLTIP),
1867 SetDataTip(STR_NEWGRF_SETTINGS_RESCAN_FILES, STR_NEWGRF_SETTINGS_RESCAN_FILES_TOOLTIP),
1869 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
1875 static const NWidgetPart _nested_newgrf_infopanel_widgets[] = {
1883 SetDataTip(STR_CONTENT_OPEN_URL, STR_CONTENT_OPEN_URL_TOOLTIP),
1885 SetDataTip(STR_TEXTFILE_VIEW_README, STR_NULL),
1888 SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_NULL),
1890 SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_NULL),
1898 SetDataTip(STR_NEWGRF_SETTINGS_SET_PARAMETERS, STR_NULL),
1900 SetDataTip(STR_NEWGRF_SETTINGS_TOGGLE_PALETTE, STR_NEWGRF_SETTINGS_TOGGLE_PALETTE_TOOLTIP),
1903 SetDataTip(STR_NEWGRF_SETTINGS_APPLY_CHANGES, STR_NULL),
1906 SetDataTip(STR_NEWGRF_SETTINGS_SHOW_PARAMETERS, STR_NULL),
1917 *biggest_index =
max(*biggest_index, biggest2);
1920 *biggest_index =
max(*biggest_index, biggest2);
1926 static const NWidgetPart _nested_newgrf_widgets[] = {
1947 _nested_newgrf_widgets,
lengthof(_nested_newgrf_widgets)
1973 for (c = nw->
actives; c !=
nullptr && i > 0; c = c->
next, i--) {}
1997 new NewGRFWindow(&_newgrf_desc, editable, show_params, exec_changes, config);
2013 NWidget(
WWT_EDITBOX, COLOUR_GREY,
WID_SVP_EDITBOX),
SetPadding(3, 2, 2, 2),
SetFill(1, 0),
SetResize(1, 0),
2014 SetDataTip(STR_SAVE_PRESET_TITLE, STR_SAVE_PRESET_EDITBOX_TOOLTIP),
2028 _nested_save_preset_widgets,
lengthof(_nested_save_preset_widgets)
2045 this->selected = -1;
2046 if (initial_text !=
nullptr) {
2047 for (uint i = 0; i < this->presets.size(); i++) {
2048 if (this->presets[i] == initial_text) {
2063 this->vscroll->
SetCount((uint)this->presets.size());
2065 if (initial_text !=
nullptr) this->presetname_editbox.text.
Assign(initial_text);
2078 for (uint i = 0; i < this->presets.size(); i++) {
2081 resize->height =
max(resize->height, d.height);
2083 size->height =
ClampU((uint)this->presets.size(), 5, 20) * resize->height + 1;
2099 uint max_index =
min(min_index + this->vscroll->
GetCapacity(), (uint)this->presets.size());
2101 for (uint i = min_index; i < max_index; i++) {
2104 const char *text = this->presets[i].c_str();
2118 if (row < this->presets.size()) {
2119 this->selected = row;
2120 this->presetname_editbox.text.
Assign(this->presets[row].c_str());
2175 _nested_scan_progress_widgets,
lengthof(_nested_scan_progress_widgets)
2225 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);
2248 free(this->last_name);
2249 if (name ==
nullptr) {
2251 GetString(buf, STR_NEWGRF_SCAN_ARCHIVES,
lastof(buf));
2252 this->last_name =
stredup(buf);
2254 this->last_name =
stredup(name);
2256 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.