48 if (_game_mode == GM_MENU)
return;
52 if (c->error == NULL || c->error->severity != STR_NEWGRF_ERROR_MSG_FATAL)
continue;
54 SetDParam (0, c->error->custom_message == NULL ? c->error->message : STR_JUST_RAW_STRING);
58 for (uint i = 0; i <
lengthof(c->error->param_value); i++) {
59 SetDParam(4 + i, c->error->param_value[i]);
66 static void ShowNewGRFInfo(
const GRFConfig *c, uint x, uint y, uint right, uint bottom,
bool show_params)
68 if (c->
error != NULL) {
115 SetDParam(0, STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY_NONE);
206 d.width += padding.width;
207 d.height += padding.height;
225 if (par_info == NULL)
continue;
227 if (desc == NULL)
continue;
230 suggestion =
maxdim(d, suggestion);
232 size->height = suggestion.height;
250 if (par_info == NULL)
return;
252 if (desc == NULL)
return;
275 SetDParam(2, par_info->
GetValue(this->grf_config) == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
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);
340 if (num >= this->vscroll->
GetCount())
break;
349 int x = pt.x - wid->
pos_x;
375 if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
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++;
402 if (val != old_val) {
433 int32 value = atoi(str);
473 if (!gui_scope)
return;
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)
576 bool Selectable()
const
581 void Draw(
int left,
int right,
int top,
int bottom,
bool sel,
int bg_colour)
const
588 typedef std::map<uint32, const GRFConfig *>
GrfIdMap;
598 std::pair<uint32, const GRFConfig *> p(c->
ident.
grfid, c);
599 grfid_map->insert(p);
613 static const uint EDITBOX_MAX_SIZE = 50;
617 static GUIGRFConfigList::SortFunction *
const sorter_funcs[];
618 static GUIGRFConfigList::FilterFunction *
const filter_funcs[];
641 this->avail_sel = NULL;
642 this->avail_pos = -1;
643 this->active_sel = NULL;
644 this->actives = NULL;
645 this->orig_list = orig_list;
647 this->execute = execute;
648 this->show_params = show_params;
650 this->active_over = -1;
659 this->GetWidget<NWidgetStacked>(
WID_NS_SHOW_REMOVE)->SetDisplayedPlane(this->editable ? 0 : 1);
671 this->avails.SetListing(this->last_sorting);
672 this->avails.SetFiltering(this->last_filtering);
673 this->avails.SetSortFuncs(this->sorter_funcs);
674 this->avails.SetFilterFuncs(this->filter_funcs);
675 this->avails.ForceRebuild();
686 if (this->
editable && !this->execute) {
701 bool CanUpgradeCurrent()
707 GrfIdMap::const_iterator iter = grfid_map.find(a->ident.grfid);
708 if (iter != grfid_map.end() && a->version > iter->second->version)
return true;
714 void UpgradeCurrent()
720 GrfIdMap::iterator iter = grfid_map.find(a->ident.grfid);
721 if (iter == grfid_map.end() || iter->second->version >= a->version)
continue;
724 while (*c != iter->second) c = &(*c)->
next;
728 if (this->active_sel == *c) this->active_sel = NULL;
770 d.width += padding.width;
779 size->width += padding.width;
780 size->height += padding.height;
796 if (this->preset == -1) {
819 pal = PALETTE_TO_RED;
822 pal = PALETTE_TO_GREEN;
825 pal = PALETTE_TO_BLUE;
830 if (pal != PALETTE_TO_RED) {
832 pal = PALETTE_TO_GREY;
834 pal = PALETTE_TO_ORANGE;
847 uint step_height = this->GetWidget<NWidgetBase>(
WID_NS_FILE_LIST)->resize_y;
851 int square_offset_y = (step_height - square.height) / 2;
852 int warning_offset_y = (step_height - warning.height) / 2;
858 uint square_left = rtl ? r.right - square.width - 5 : r.left + 5;
859 uint warning_left = rtl ? r.right - square.width - warning.width - 10 : r.left + square.width + 10;
862 for (
const GRFConfig *c = this->actives; c != NULL; c = c->
next, i++) {
863 if (this->vscroll->IsVisible(i)) {
864 const char *text = c->
GetName();
865 bool h = (this->active_sel == c);
870 }
else if (i == this->active_over) {
872 int active_sel_pos = 0;
873 for (
GRFConfig *c = this->actives; c != NULL && c != this->active_sel; c = c->
next, active_sel_pos++) {}
874 if (active_sel_pos != this->active_over) {
875 uint
top = this->active_over < active_sel_pos ? y + 1 : y + step_height - 2;
879 DrawSprite(SPR_SQUARE, pal, square_left, y + square_offset_y);
880 if (c->
error != NULL)
DrawSprite(SPR_WARNING_SIGN, 0, warning_left, y + warning_offset_y);
881 uint txtoffset = c->
error == NULL ? 0 : warning.width;
882 DrawString(text_left + (rtl ? 0 : txtoffset), text_right - (rtl ? txtoffset : 0), y + offset_y, text, h ? TC_WHITE : TC_ORANGE);
886 if (i == this->active_over && this->vscroll->IsVisible(i)) {
898 uint min_index = this->vscroll2->GetPosition();
899 uint max_index =
min(min_index + this->vscroll2->GetCapacity(), this->avails.Length());
901 for (uint i = min_index; i < max_index; i++) {
903 bool h = (c == this->avail_sel);
904 const char *text = c->
GetName();
920 const GRFConfig *selected = this->active_sel;
921 if (selected == NULL) selected = this->avail_sel;
922 if (selected != NULL) {
933 if (this->active_sel == NULL && this->avail_sel == NULL)
return;
958 const GRFConfig *c = (this->avail_sel == NULL) ? this->active_sel : this->avail_sel;
960 extern void OpenBrowser(
const char *url);
970 if (this->preset == -1)
return;
980 if (this->active_sel == NULL || !this->
editable)
break;
983 for (
GRFConfig **pc = &this->actives; *pc != NULL; pc = &(*pc)->
next, pos++) {
985 if (c->
next == this->active_sel) {
987 this->active_sel->
next = c;
988 *pc = this->active_sel;
992 this->vscroll->ScrollTowards(pos);
999 if (this->active_sel == NULL || !this->
editable)
break;
1002 for (
GRFConfig **pc = &this->actives; *pc != NULL; pc = &(*pc)->
next, pos++) {
1004 if (c == this->active_sel) {
1011 this->vscroll->ScrollTowards(pos);
1020 uint i = this->vscroll->GetScrolledRowFromWidget(pt.y,
this,
WID_NS_FILE_LIST);
1023 for (c = this->actives; c != NULL && i > 0; c = c->
next, i--) {}
1026 this->active_sel = c;
1027 this->avail_sel = NULL;
1028 this->avail_pos = -1;
1031 if (click_count == 1) {
1040 if (this->active_sel == NULL || !this->
editable)
break;
1045 for (
GRFConfig **pc = &this->actives; *pc != NULL; pc = &(*pc)->
next) {
1049 if (newsel == NULL && c->
next == this->active_sel) newsel = c;
1051 if (c == this->active_sel) {
1052 if (newsel == c) newsel = NULL;
1060 this->active_sel = newsel;
1062 this->avail_pos = -1;
1063 this->avail_sel = NULL;
1064 this->avails.ForceRebuild();
1070 if (!this->
editable || this->actives == NULL)
break;
1079 uint i = this->vscroll2->GetScrolledRowFromWidget(pt.y,
this,
WID_NS_AVAIL_LIST);
1080 this->active_sel = NULL;
1082 if (i < this->avails.Length()) {
1083 this->avail_sel = this->avails[i];
1084 this->avail_pos = i;
1087 if (click_count == 1) {
1098 this->AddGRFToActive();
1103 if (this->execute) {
1105 STR_NEWGRF_POPUP_CAUTION_CAPTION,
1106 STR_NEWGRF_CONFIRMATION_TEXT,
1120 if (this->active_sel == NULL || !this->show_params || this->active_sel->num_valid_params == 0)
break;
1122 OpenGRFParameterWindow(this->active_sel, this->
editable);
1127 if (this->active_sel != NULL && this->
editable) {
1138 #if defined(ENABLE_NETWORK)
1153 virtual void OnNewGRFsScanned()
1155 this->avail_sel = NULL;
1156 this->avail_pos = -1;
1157 this->avails.ForceRebuild();
1167 this->preset = index;
1172 this->avails.ForceRebuild();
1176 this->active_sel = NULL;
1182 if (str == NULL)
return;
1205 if (!gui_scope)
return;
1213 for (
GRFConfig **l = &this->actives; *l != NULL; l = &(*l)->
next) {
1222 (*l)->next = c->
next;
1224 if (active_sel == c) active_sel = *l;
1229 this->avails.ForceRebuild();
1239 for (
const GRFConfig *c = this->actives; c != NULL; c = c->
next, i++) {}
1241 this->vscroll->SetCount(i + 1);
1243 if (this->avail_pos >= 0) this->vscroll2->ScrollTowards(this->avail_pos);
1248 this->BuildAvailables();
1259 bool disable_all = this->active_sel == NULL || !this->
editable;
1267 const GRFConfig *c = (this->avail_sel == NULL) ? this->active_sel : this->avail_sel;
1268 for (
TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
1286 bool has_missing =
false;
1287 bool has_compatible =
false;
1288 for (
const GRFConfig *c = this->actives; !has_missing && c != NULL; c = c->
next) {
1294 if (has_missing || has_compatible) {
1295 widget_data = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON;
1296 tool_tip = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP;
1298 widget_data = STR_INTRO_ONLINE_CONTENT;
1299 tool_tip = STR_INTRO_TOOLTIP_ONLINE_CONTENT;
1316 if (this->avail_pos > 0) this->avail_pos--;
1321 if (this->avail_pos < (
int)this->avails.Length() - 1) this->avail_pos++;
1326 this->avail_pos = (this->avail_pos < this->vscroll2->GetCapacity()) ? 0 : this->avail_pos - this->vscroll2->GetCapacity();
1331 this->avail_pos =
min(this->avail_pos + this->vscroll2->GetCapacity(), (int)this->avails.Length() - 1);
1336 this->avail_pos = 0;
1341 this->avail_pos = this->avails.Length() - 1;
1348 if (this->avails.Length() == 0) this->avail_pos = -1;
1349 if (this->avail_pos >= 0) {
1350 this->avail_sel = this->avails[this->avail_pos];
1351 this->vscroll2->ScrollTowards(this->avail_pos);
1362 string_filter.SetFilterTerm(this->filter_editbox.text.buf);
1363 this->avails.SetFilterState(!string_filter.IsEmpty());
1364 this->avails.ForceRebuild();
1373 if (this->active_sel != NULL) {
1377 for (from_prev = &this->actives; *from_prev != this->active_sel; from_prev = &(*from_prev)->
next, from_pos++) {}
1380 int to_pos =
min(this->vscroll->GetScrolledRowFromWidget(pt.y,
this,
WID_NS_FILE_LIST), this->vscroll->GetCount() - 2);
1381 if (to_pos != from_pos) {
1384 for (
int i = from_pos < to_pos ? -1 : 0; *to_prev != NULL && i < to_pos; to_prev = &(*to_prev)->
next, i++) {}
1387 *from_prev = this->active_sel->
next;
1390 this->active_sel->
next = *to_prev;
1391 *to_prev = this->active_sel;
1393 this->vscroll->ScrollTowards(to_pos);
1397 }
else if (this->avail_sel != NULL) {
1398 int to_pos =
min(this->vscroll->GetScrolledRowFromWidget(pt.y,
this,
WID_NS_FILE_LIST), this->vscroll->GetCount() - 1);
1399 this->AddGRFToActive(to_pos);
1403 Point dummy = {-1, -1};
1409 if (this->active_over != -1) {
1412 this->active_over = -1;
1420 if (widget ==
WID_NS_FILE_LIST && (this->active_sel != NULL || this->avail_sel != NULL)) {
1422 int to_pos = this->vscroll->GetScrolledRowFromWidget(pt.y,
this,
WID_NS_FILE_LIST);
1424 to_pos =
min(to_pos, this->vscroll->GetCount() - (this->active_sel != NULL ? 2 : 1));
1426 if (to_pos != this->active_over) {
1427 this->active_over = to_pos;
1431 this->active_over = -2;
1433 }
else if (this->active_over != -1) {
1435 this->active_over = -1;
1443 int i =
strnatcmp((*a)->GetName(), (*b)->GetName(),
true);
1444 if (i != 0)
return i;
1446 i = (*a)->version - (*b)->version;
1447 if (i != 0)
return i;
1449 return memcmp((*a)->ident.md5sum, (*b)->ident.md5sum,
lengthof((*b)->ident.md5sum));
1456 filter.
AddLine((*a)->GetName());
1457 filter.
AddLine((*a)->filename);
1458 filter.
AddLine((*a)->GetDescription());
1462 void BuildAvailables()
1464 if (!this->avails.NeedRebuild())
return;
1466 this->avails.Clear();
1471 if (found)
continue;
1474 *this->avails.Append() = c;
1485 *this->avails.Append() = c;
1490 this->avails.Filter(this->string_filter);
1491 this->avails.Compact();
1492 this->avails.RebuildDone();
1493 this->avails.Sort();
1495 if (this->avail_sel != NULL) {
1496 this->avail_pos = this->avails.FindIndex(this->avail_sel);
1497 if (this->avail_pos < 0) this->avail_sel = NULL;
1500 this->vscroll2->SetCount(this->avails.Length());
1508 bool AddGRFToActive(
int ins_pos = -1)
1516 for (list = &this->actives; *list != NULL; list = &(*list)->
next, ins_pos--) {
1517 if (ins_pos == 0) entry = list;
1518 if ((*list)->ident.grfid == this->avail_sel->ident.grfid) {
1524 if (entry == NULL) entry = list;
1538 int new_pos = this->avail_pos + 1;
1539 if (new_pos >= (
int)this->avails.Length()) new_pos = this->avail_pos - 1;
1540 this->avail_pos = new_pos;
1541 if (new_pos >= 0) this->avail_sel = this->avails[new_pos];
1543 this->avails.ForceRebuild();
1549 #if defined(ENABLE_NETWORK)
1608 this->Add(this->avs);
1609 this->Add(this->acs);
1610 this->Add(this->inf);
1615 virtual void SetupSmallestSize(
Window *w,
bool init_array)
1618 assert(dynamic_cast<NewGRFWindow *>(w) != NULL);
1622 this->avs->SetupSmallestSize(w, init_array);
1623 this->acs->SetupSmallestSize(w, init_array);
1624 this->inf->SetupSmallestSize(w, init_array);
1626 uint min_avs_width = this->avs->smallest_x + this->avs->padding_left + this->avs->padding_right;
1627 uint min_acs_width = this->acs->smallest_x + this->acs->padding_left + this->acs->padding_right;
1628 uint min_inf_width = this->inf->smallest_x + this->inf->padding_left + this->inf->padding_right;
1630 uint min_avs_height = this->avs->smallest_y + this->avs->padding_top + this->avs->padding_bottom;
1631 uint min_acs_height = this->acs->smallest_y + this->acs->padding_top + this->acs->padding_bottom;
1632 uint min_inf_height = this->inf->smallest_y + this->inf->padding_top + this->inf->padding_bottom;
1635 this->smallest_x =
max(min_avs_width, min_acs_width) + INTER_COLUMN_SPACING + min_inf_width;
1636 this->smallest_y =
max(min_inf_height, min_acs_height + INTER_LIST_SPACING + min_avs_height);
1640 if (this->inf->fill_x > 0 && (this->fill_x == 0 || this->fill_x > this->inf->fill_x)) this->fill_x = this->inf->fill_x;
1642 this->fill_y = this->avs->fill_y;
1643 if (this->acs->fill_y > 0 && (this->fill_y == 0 || this->fill_y > this->acs->fill_y)) this->fill_y = this->acs->fill_y;
1648 if (this->inf->resize_x > 0 && (this->resize_x == 0 || this->resize_x > this->inf->resize_x)) this->resize_x = this->inf->resize_x;
1650 this->resize_y = this->avs->resize_y;
1651 if (this->acs->resize_y > 0 && (this->resize_y == 0 || this->resize_y > this->acs->resize_y)) this->resize_y = this->acs->resize_y;
1655 this->smallest_y =
ComputeMaxSize(min_acs_height, this->smallest_y + this->resize_y - 1, this->resize_y);
1658 virtual void AssignSizePosition(
SizingType sizing, uint x, uint y, uint given_width, uint given_height,
bool rtl)
1660 this->StoreSizePosition(sizing, x, y, given_width, given_height);
1662 uint min_avs_width = this->avs->smallest_x + this->avs->padding_left + this->avs->padding_right;
1663 uint min_acs_width = this->acs->smallest_x + this->acs->padding_left + this->acs->padding_right;
1664 uint min_inf_width = this->inf->smallest_x + this->inf->padding_left + this->inf->padding_right;
1666 uint min_list_width =
max(min_avs_width, min_acs_width);
1667 uint avs_extra_width = min_list_width - min_avs_width;
1668 uint acs_extra_width = min_list_width - min_acs_width;
1671 uint min_three_columns = min_avs_width + min_acs_width + min_inf_width + 2 * INTER_COLUMN_SPACING;
1672 uint min_two_columns = min_list_width + min_inf_width + INTER_COLUMN_SPACING;
1673 bool use_three_columns = this->
editable && (min_three_columns + MIN_EXTRA_FOR_3_COLUMNS <= given_width);
1676 uint extra_width, inf_width;
1677 if (use_three_columns) {
1678 extra_width = given_width - min_three_columns;
1679 inf_width =
min(MAX_EXTRA_INFO_WIDTH, extra_width / 2);
1681 extra_width = given_width - min_two_columns;
1682 inf_width =
min(MAX_EXTRA_INFO_WIDTH, extra_width / 2);
1684 inf_width =
ComputeMaxSize(this->inf->smallest_x, this->inf->smallest_x + inf_width, this->inf->GetHorizontalStepSize(sizing));
1685 extra_width -= inf_width - this->inf->smallest_x;
1687 uint inf_height =
ComputeMaxSize(this->inf->smallest_y, given_height, this->inf->GetVerticalStepSize(sizing));
1689 if (use_three_columns) {
1692 uint avs_width =
min(avs_extra_width, extra_width);
1693 extra_width -= avs_width;
1694 extra_width -=
min(acs_extra_width, extra_width);
1695 avs_width += extra_width / 2;
1697 avs_width =
ComputeMaxSize(this->avs->smallest_x, this->avs->smallest_x + avs_width, this->avs->GetHorizontalStepSize(sizing));
1699 uint acs_width = given_width -
1700 inf_width - this->inf->padding_left - this->inf->padding_right -
1701 avs_width - this->avs->padding_left - this->avs->padding_right - 2 * INTER_COLUMN_SPACING;
1702 acs_width =
ComputeMaxSize(min_acs_width, acs_width, this->acs->GetHorizontalStepSize(sizing)) -
1703 this->acs->padding_left - this->acs->padding_right;
1706 uint avs_height =
ComputeMaxSize(this->avs->smallest_y, given_height, this->avs->resize_y);
1707 uint acs_height =
ComputeMaxSize(this->acs->smallest_y, given_height, this->acs->resize_y);
1711 x += this->inf->padding_left;
1712 this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
1713 x += inf_width + this->inf->padding_right + INTER_COLUMN_SPACING;
1715 x += this->avs->padding_left;
1716 this->avs->AssignSizePosition(sizing, x, y + this->avs->padding_top, avs_width, avs_height, rtl);
1717 x += avs_width + this->avs->padding_right + INTER_COLUMN_SPACING;
1720 x += this->acs->padding_left;
1721 this->acs->AssignSizePosition(sizing, x, y + this->acs->padding_top, acs_width, acs_height, rtl);
1722 x += acs_width + this->acs->padding_right + INTER_COLUMN_SPACING;
1725 x += this->avs->padding_left;
1726 this->avs->AssignSizePosition(sizing, x, y + this->avs->padding_top, avs_width, avs_height, rtl);
1728 x += this->inf->padding_left;
1729 this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
1734 uint avs_width =
ComputeMaxSize(this->avs->smallest_x, this->avs->smallest_x + avs_extra_width + extra_width,
1735 this->avs->GetHorizontalStepSize(sizing));
1736 uint acs_width =
ComputeMaxSize(this->acs->smallest_x, this->acs->smallest_x + acs_extra_width + extra_width,
1737 this->acs->GetHorizontalStepSize(sizing));
1739 uint min_avs_height = (!this->
editable) ? 0 : this->avs->smallest_y + this->avs->padding_top + this->avs->padding_bottom + INTER_LIST_SPACING;
1740 uint min_acs_height = this->acs->smallest_y + this->acs->padding_top + this->acs->padding_bottom;
1741 uint extra_height = given_height - min_acs_height - min_avs_height;
1744 uint avs_height =
ComputeMaxSize(this->avs->smallest_y, this->avs->smallest_y + extra_height / 2, this->avs->resize_y);
1745 if (this->
editable) extra_height -= avs_height - this->avs->smallest_y;
1746 uint acs_height =
ComputeMaxSize(this->acs->smallest_y, this->acs->smallest_y + extra_height, this->acs->resize_y);
1750 x += this->inf->padding_left;
1751 this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
1752 x += inf_width + this->inf->padding_right + INTER_COLUMN_SPACING;
1754 this->acs->AssignSizePosition(sizing, x + this->acs->padding_left, y + this->acs->padding_top, acs_width, acs_height, rtl);
1756 this->avs->AssignSizePosition(sizing, x + this->avs->padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
1758 this->avs->AssignSizePosition(sizing, 0, 0, this->avs->smallest_x, this->avs->smallest_y, rtl);
1761 this->acs->AssignSizePosition(sizing, x + this->acs->padding_left, y + this->acs->padding_top, acs_width, acs_height, rtl);
1763 this->avs->AssignSizePosition(sizing, x + this->avs->padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
1765 this->avs->AssignSizePosition(sizing, 0, 0, this->avs->smallest_x, this->avs->smallest_y, rtl);
1767 uint dx = this->acs->current_x + this->acs->padding_left + this->acs->padding_right;
1769 dx =
max(dx, this->avs->current_x + this->avs->padding_left + this->avs->padding_right);
1771 x += dx + INTER_COLUMN_SPACING + this->inf->padding_left;
1772 this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
1779 if (!
IsInsideBS(x, this->pos_x, this->current_x) || !
IsInsideBS(y, this->pos_y, this->current_y))
return NULL;
1800 static const NWidgetPart _nested_newgrf_actives_widgets[] = {
1806 SetDataTip(STR_JUST_STRING, STR_NEWGRF_SETTINGS_PRESET_LIST_TOOLTIP),
1810 SetDataTip(STR_NEWGRF_SETTINGS_PRESET_SAVE, STR_NEWGRF_SETTINGS_PRESET_SAVE_TOOLTIP),
1812 SetDataTip(STR_NEWGRF_SETTINGS_PRESET_DELETE, STR_NEWGRF_SETTINGS_PRESET_DELETE_TOOLTIP),
1832 SetDataTip(STR_NEWGRF_SETTINGS_REMOVE, STR_NEWGRF_SETTINGS_REMOVE_TOOLTIP),
1835 SetDataTip(STR_NEWGRF_SETTINGS_MOVEUP, STR_NEWGRF_SETTINGS_MOVEUP_TOOLTIP),
1837 SetDataTip(STR_NEWGRF_SETTINGS_MOVEDOWN, STR_NEWGRF_SETTINGS_MOVEDOWN_TOOLTIP),
1840 SetDataTip(STR_NEWGRF_SETTINGS_UPGRADE, STR_NEWGRF_SETTINGS_UPGRADE_TOOLTIP),
1845 SetDataTip(STR_NEWGRF_SETTINGS_RESCAN_FILES, STR_NEWGRF_SETTINGS_RESCAN_FILES_TOOLTIP),
1847 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
1853 static const NWidgetPart _nested_newgrf_availables_widgets[] = {
1862 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1876 SetDataTip(STR_NEWGRF_SETTINGS_ADD, STR_NEWGRF_SETTINGS_ADD_FILE_TOOLTIP),
1879 SetDataTip(STR_NEWGRF_SETTINGS_RESCAN_FILES, STR_NEWGRF_SETTINGS_RESCAN_FILES_TOOLTIP),
1881 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
1887 static const NWidgetPart _nested_newgrf_infopanel_widgets[] = {
1895 SetDataTip(STR_CONTENT_OPEN_URL, STR_CONTENT_OPEN_URL_TOOLTIP),
1897 SetDataTip(STR_TEXTFILE_VIEW_README, STR_NULL),
1900 SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_NULL),
1902 SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_NULL),
1910 SetDataTip(STR_NEWGRF_SETTINGS_SET_PARAMETERS, STR_NULL),
1912 SetDataTip(STR_NEWGRF_SETTINGS_TOGGLE_PALETTE, STR_NEWGRF_SETTINGS_TOGGLE_PALETTE_TOOLTIP),
1915 SetDataTip(STR_NEWGRF_SETTINGS_APPLY_CHANGES, STR_NULL),
1918 SetDataTip(STR_NEWGRF_SETTINGS_SHOW_PARAMETERS, STR_NULL),
1929 *biggest_index =
max(*biggest_index, biggest2);
1932 *biggest_index =
max(*biggest_index, biggest2);
1938 static const NWidgetPart _nested_newgrf_widgets[] = {
1959 _nested_newgrf_widgets,
lengthof(_nested_newgrf_widgets)
1984 for (c = nw->
actives; c != NULL && i > 0; c = c->
next, i--) {}
2008 new NewGRFWindow(&_newgrf_desc, editable, show_params, exec_changes, config);
2024 NWidget(
WWT_EDITBOX, COLOUR_GREY,
WID_SVP_EDITBOX),
SetPadding(3, 2, 2, 2),
SetFill(1, 0),
SetResize(1, 0),
2025 SetDataTip(STR_SAVE_PRESET_TITLE, STR_SAVE_PRESET_EDITBOX_TOOLTIP),
2056 this->selected = -1;
2057 if (initial_text != NULL) {
2058 for (uint i = 0; i < this->presets.Length(); i++) {
2059 if (!strcmp(initial_text, this->presets[i])) {
2074 this->vscroll->SetCount(this->presets.Length());
2076 if (initial_text != NULL) this->presetname_editbox.text.Assign(initial_text);
2089 for (uint i = 0; i < this->presets.Length(); i++) {
2092 resize->height =
max(resize->height, d.height);
2094 size->height =
ClampU(this->presets.Length(), 5, 20) * resize->height + 1;
2109 uint min_index = this->vscroll->GetPosition();
2110 uint max_index =
min(min_index + this->vscroll->GetCapacity(), this->presets.Length());
2112 for (uint i = min_index; i < max_index; i++) {
2115 const char *text = this->presets[i];
2129 if (row < this->presets.Length()) {
2130 this->selected = row;
2131 this->presetname_editbox.text.Assign(this->presets[row]);
2236 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);
2259 free(this->last_name);
2262 GetString(buf, STR_NEWGRF_SCAN_ARCHIVES,
lastof(buf));
2263 this->last_name =
stredup(buf);
2265 this->last_name =
stredup(name);
2267 this->scanned = num;