52 if (_game_mode == GM_MENU)
return;
56 if (c->error == NULL || c->error->severity != STR_NEWGRF_ERROR_MSG_FATAL)
continue;
58 SetDParam (0, c->error->custom_message == NULL ? c->error->message : STR_JUST_RAW_STRING);
62 for (uint i = 0; i <
lengthof(c->error->param_value); i++) {
63 SetDParam(4 + i, c->error->param_value[i]);
70 static void ShowNewGRFInfo(
const GRFConfig *c, uint x, uint y, uint right, uint bottom,
bool show_params)
72 if (c->
error != NULL) {
119 SetDParam(0, STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY_NONE);
210 d.width += padding.width;
211 d.height += padding.height;
229 if (par_info == NULL)
continue;
231 if (desc == NULL)
continue;
234 suggestion =
maxdim(d, suggestion);
236 size->height = suggestion.height;
254 if (par_info == NULL)
return;
256 if (desc == NULL)
return;
279 SetDParam(2, par_info->
GetValue(this->grf_config) == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
302 SetDParam(0, STR_NEWGRF_PARAMETERS_DEFAULT_NAME);
306 DrawString(text_left, text_right, y + text_y_offset, STR_NEWGRF_PARAMETERS_SETTING, selected ? TC_WHITE : TC_LIGHT_BLUE);
344 if (num >= this->vscroll->
GetCount())
break;
353 int x = pt.x - wid->
pos_x;
379 if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
384 for (uint32 i = par_info->
min_value; i <= par_info->max_value; i++) {
392 uint32 val = old_val;
398 if (val < par_info->max_value) val++;
406 if (val != old_val) {
437 int32 value = atoi(str);
477 if (!gui_scope)
return;
501 static const NWidgetPart _nested_newgrf_parameter_widgets[] = {
512 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),
517 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),
535 WDP_CENTER,
"settings_newgrf_config", 500, 208,
538 _nested_newgrf_parameter_widgets,
lengthof(_nested_newgrf_parameter_widgets)
580 bool Selectable()
const
585 void Draw(
int left,
int right,
int top,
int bottom,
bool sel,
int bg_colour)
const
592 typedef std::map<uint32, const GRFConfig *>
GrfIdMap;
602 std::pair<uint32, const GRFConfig *> p(c->
ident.
grfid, c);
603 grfid_map->insert(p);
617 static const uint EDITBOX_MAX_SIZE = 50;
621 static GUIGRFConfigList::SortFunction *
const sorter_funcs[];
622 static GUIGRFConfigList::FilterFunction *
const filter_funcs[];
645 this->avail_sel = NULL;
646 this->avail_pos = -1;
647 this->active_sel = NULL;
648 this->actives = NULL;
649 this->orig_list = orig_list;
651 this->execute = execute;
652 this->show_params = show_params;
654 this->active_over = -1;
663 this->GetWidget<NWidgetStacked>(
WID_NS_SHOW_REMOVE)->SetDisplayedPlane(this->editable ? 0 : 1);
675 this->avails.SetListing(this->last_sorting);
676 this->avails.SetFiltering(this->last_filtering);
677 this->avails.SetSortFuncs(this->sorter_funcs);
678 this->avails.SetFilterFuncs(this->filter_funcs);
679 this->avails.ForceRebuild();
690 if (this->
editable && !this->execute) {
705 bool CanUpgradeCurrent()
711 GrfIdMap::const_iterator iter = grfid_map.find(a->ident.grfid);
712 if (iter != grfid_map.end() && a->version > iter->second->version)
return true;
718 void UpgradeCurrent()
724 GrfIdMap::iterator iter = grfid_map.find(a->ident.grfid);
725 if (iter == grfid_map.end() || iter->second->version >= a->version)
continue;
728 while (*c != iter->second) c = &(*c)->
next;
732 if (this->active_sel == *c) this->active_sel = NULL;
774 d.width += padding.width;
783 size->width += padding.width;
784 size->height += padding.height;
800 if (this->preset == -1) {
823 pal = PALETTE_TO_RED;
826 pal = PALETTE_TO_GREEN;
829 pal = PALETTE_TO_BLUE;
834 if (pal != PALETTE_TO_RED) {
836 pal = PALETTE_TO_GREY;
838 pal = PALETTE_TO_ORANGE;
851 uint step_height = this->GetWidget<NWidgetBase>(
WID_NS_FILE_LIST)->resize_y;
855 int square_offset_y = (step_height - square.height) / 2;
856 int warning_offset_y = (step_height - warning.height) / 2;
862 uint square_left = rtl ? r.right - square.width - 5 : r.left + 5;
863 uint warning_left = rtl ? r.right - square.width - warning.width - 10 : r.left + square.width + 10;
866 for (
const GRFConfig *c = this->actives; c != NULL; c = c->
next, i++) {
867 if (this->vscroll->IsVisible(i)) {
868 const char *text = c->
GetName();
869 bool h = (this->active_sel == c);
874 }
else if (i == this->active_over) {
876 int active_sel_pos = 0;
877 for (
GRFConfig *c = this->actives; c != NULL && c != this->active_sel; c = c->
next, active_sel_pos++) {}
878 if (active_sel_pos != this->active_over) {
879 uint
top = this->active_over < active_sel_pos ? y + 1 : y + step_height - 2;
883 DrawSprite(SPR_SQUARE, pal, square_left, y + square_offset_y);
884 if (c->
error != NULL)
DrawSprite(SPR_WARNING_SIGN, 0, warning_left, y + warning_offset_y);
885 uint txtoffset = c->
error == NULL ? 0 : warning.width;
886 DrawString(text_left + (rtl ? 0 : txtoffset), text_right - (rtl ? txtoffset : 0), y + offset_y, text, h ? TC_WHITE : TC_ORANGE);
890 if (i == this->active_over && this->vscroll->IsVisible(i)) {
902 uint min_index = this->vscroll2->GetPosition();
903 uint max_index =
min(min_index + this->vscroll2->GetCapacity(), this->avails.Length());
905 for (uint i = min_index; i < max_index; i++) {
907 bool h = (c == this->avail_sel);
908 const char *text = c->
GetName();
924 const GRFConfig *selected = this->active_sel;
925 if (selected == NULL) selected = this->avail_sel;
926 if (selected != NULL) {
937 if (this->active_sel == NULL && this->avail_sel == NULL)
return;
962 const GRFConfig *c = (this->avail_sel == NULL) ? this->active_sel : this->avail_sel;
964 extern void OpenBrowser(
const char *url);
974 if (this->preset == -1)
return;
984 if (this->active_sel == NULL || !this->
editable)
break;
987 for (
GRFConfig **pc = &this->actives; *pc != NULL; pc = &(*pc)->
next, pos++) {
989 if (c->
next == this->active_sel) {
991 this->active_sel->
next = c;
992 *pc = this->active_sel;
996 this->vscroll->ScrollTowards(pos);
1003 if (this->active_sel == NULL || !this->
editable)
break;
1006 for (
GRFConfig **pc = &this->actives; *pc != NULL; pc = &(*pc)->
next, pos++) {
1008 if (c == this->active_sel) {
1015 this->vscroll->ScrollTowards(pos);
1024 uint i = this->vscroll->GetScrolledRowFromWidget(pt.y,
this,
WID_NS_FILE_LIST);
1027 for (c = this->actives; c != NULL && i > 0; c = c->
next, i--) {}
1030 this->active_sel = c;
1031 this->avail_sel = NULL;
1032 this->avail_pos = -1;
1035 if (click_count == 1) {
1043 if (this->active_sel == NULL || !this->
editable)
break;
1048 for (
GRFConfig **pc = &this->actives; *pc != NULL; pc = &(*pc)->
next) {
1052 if (newsel == NULL && c->
next == this->active_sel) newsel = c;
1054 if (c == this->active_sel) {
1055 if (newsel == c) newsel = NULL;
1063 this->active_sel = newsel;
1065 this->avail_pos = -1;
1066 this->avail_sel = NULL;
1067 this->avails.ForceRebuild();
1073 if (!this->
editable || this->actives == NULL)
break;
1082 uint i = this->vscroll2->GetScrolledRowFromWidget(pt.y,
this,
WID_NS_AVAIL_LIST);
1083 this->active_sel = NULL;
1085 if (i < this->avails.Length()) {
1086 this->avail_sel = this->avails[i];
1087 this->avail_pos = i;
1090 if (click_count == 1) {
1100 this->AddGRFToActive();
1105 if (this->execute) {
1107 STR_NEWGRF_POPUP_CAUTION_CAPTION,
1108 STR_NEWGRF_CONFIRMATION_TEXT,
1122 if (this->active_sel == NULL || !this->show_params || this->active_sel->num_valid_params == 0)
break;
1124 OpenGRFParameterWindow(this->active_sel, this->
editable);
1129 if (this->active_sel != NULL && this->
editable) {
1140 #if defined(ENABLE_NETWORK)
1155 virtual void OnNewGRFsScanned()
1157 this->avail_sel = NULL;
1158 this->avail_pos = -1;
1159 this->avails.ForceRebuild();
1169 this->preset = index;
1174 this->avails.ForceRebuild();
1178 this->active_sel = NULL;
1184 if (str == NULL)
return;
1207 if (!gui_scope)
return;
1215 for (
GRFConfig **l = &this->actives; *l != NULL; l = &(*l)->
next) {
1224 (*l)->next = c->
next;
1226 if (active_sel == c) active_sel = *l;
1231 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++) {
1287 bool has_missing =
false;
1288 bool has_compatible =
false;
1289 for (
const GRFConfig *c = this->actives; !has_missing && c != NULL; c = c->
next) {
1295 if (has_missing || has_compatible) {
1296 widget_data = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON;
1297 tool_tip = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP;
1299 widget_data = STR_INTRO_ONLINE_CONTENT;
1300 tool_tip = STR_INTRO_TOOLTIP_ONLINE_CONTENT;
1317 if (this->avail_pos > 0) this->avail_pos--;
1322 if (this->avail_pos < (
int)this->avails.Length() - 1) this->avail_pos++;
1327 this->avail_pos = (this->avail_pos < this->vscroll2->GetCapacity()) ? 0 : this->avail_pos - this->vscroll2->GetCapacity();
1332 this->avail_pos =
min(this->avail_pos + this->vscroll2->GetCapacity(), (int)this->avails.Length() - 1);
1337 this->avail_pos = 0;
1342 this->avail_pos = this->avails.Length() - 1;
1349 if (this->avails.Length() == 0) this->avail_pos = -1;
1350 if (this->avail_pos >= 0) {
1351 this->avail_sel = this->avails[this->avail_pos];
1352 this->vscroll2->ScrollTowards(this->avail_pos);
1363 string_filter.SetFilterTerm(this->filter_editbox.text.buf);
1364 this->avails.SetFilterState(!string_filter.IsEmpty());
1365 this->avails.ForceRebuild();
1374 if (this->active_sel != NULL) {
1378 for (from_prev = &this->actives; *from_prev != this->active_sel; from_prev = &(*from_prev)->
next, from_pos++) {}
1381 int to_pos =
min(this->vscroll->GetScrolledRowFromWidget(pt.y,
this,
WID_NS_FILE_LIST), this->vscroll->GetCount() - 2);
1382 if (to_pos != from_pos) {
1385 for (
int i = from_pos < to_pos ? -1 : 0; *to_prev != NULL && i < to_pos; to_prev = &(*to_prev)->
next, i++) {}
1388 *from_prev = this->active_sel->
next;
1391 this->active_sel->
next = *to_prev;
1392 *to_prev = this->active_sel;
1394 this->vscroll->ScrollTowards(to_pos);
1398 }
else if (this->avail_sel != NULL) {
1399 int to_pos =
min(this->vscroll->GetScrolledRowFromWidget(pt.y,
this,
WID_NS_FILE_LIST), this->vscroll->GetCount() - 1);
1400 this->AddGRFToActive(to_pos);
1404 Point dummy = {-1, -1};
1410 if (this->active_over != -1) {
1413 this->active_over = -1;
1421 if (widget ==
WID_NS_FILE_LIST && (this->active_sel != NULL || this->avail_sel != NULL)) {
1423 int to_pos = this->vscroll->GetScrolledRowFromWidget(pt.y,
this,
WID_NS_FILE_LIST);
1425 to_pos =
min(to_pos, this->vscroll->GetCount() - (this->active_sel != NULL ? 2 : 1));
1427 if (to_pos != this->active_over) {
1428 this->active_over = to_pos;
1432 this->active_over = -2;
1434 }
else if (this->active_over != -1) {
1436 this->active_over = -1;
1444 int i =
strnatcmp((*a)->GetName(), (*b)->GetName(),
true);
1445 if (i != 0)
return i;
1447 i = (*a)->version - (*b)->version;
1448 if (i != 0)
return i;
1450 return memcmp((*a)->ident.md5sum, (*b)->ident.md5sum,
lengthof((*b)->ident.md5sum));
1457 filter.
AddLine((*a)->GetName());
1458 filter.
AddLine((*a)->filename);
1459 filter.
AddLine((*a)->GetDescription());
1463 void BuildAvailables()
1465 if (!this->avails.NeedRebuild())
return;
1467 this->avails.Clear();
1472 if (found)
continue;
1475 *this->avails.Append() = c;
1486 *this->avails.Append() = c;
1491 this->avails.Filter(this->string_filter);
1492 this->avails.Compact();
1493 this->avails.RebuildDone();
1494 this->avails.Sort();
1496 if (this->avail_sel != NULL) {
1497 this->avail_pos = this->avails.FindIndex(this->avail_sel);
1498 if (this->avail_pos < 0) this->avail_sel = NULL;
1501 this->vscroll2->SetCount(this->avails.Length());
1509 bool AddGRFToActive(
int ins_pos = -1)
1517 for (list = &this->actives; *list != NULL; list = &(*list)->
next, ins_pos--) {
1518 if (ins_pos == 0) entry = list;
1519 if ((*list)->ident.grfid == this->avail_sel->ident.grfid) {
1525 if (entry == NULL) entry = list;
1526 if (count >= MAX_NEWGRFS) {
1539 int new_pos = this->avail_pos + 1;
1540 if (new_pos >= (
int)this->avails.Length()) new_pos = this->avail_pos - 1;
1541 this->avail_pos = new_pos;
1542 if (new_pos >= 0) this->avail_sel = this->avails[new_pos];
1544 this->avails.ForceRebuild();
1550 #if defined(ENABLE_NETWORK)
1609 this->Add(this->avs);
1610 this->Add(this->acs);
1611 this->Add(this->inf);
1616 virtual void SetupSmallestSize(
Window *w,
bool init_array)
1619 assert(dynamic_cast<NewGRFWindow *>(w) != NULL);
1623 this->avs->SetupSmallestSize(w, init_array);
1624 this->acs->SetupSmallestSize(w, init_array);
1625 this->inf->SetupSmallestSize(w, init_array);
1627 uint min_avs_width = this->avs->smallest_x + this->avs->padding_left + this->avs->padding_right;
1628 uint min_acs_width = this->acs->smallest_x + this->acs->padding_left + this->acs->padding_right;
1629 uint min_inf_width = this->inf->smallest_x + this->inf->padding_left + this->inf->padding_right;
1631 uint min_avs_height = this->avs->smallest_y + this->avs->padding_top + this->avs->padding_bottom;
1632 uint min_acs_height = this->acs->smallest_y + this->acs->padding_top + this->acs->padding_bottom;
1633 uint min_inf_height = this->inf->smallest_y + this->inf->padding_top + this->inf->padding_bottom;
1636 this->smallest_x =
max(min_avs_width, min_acs_width) + INTER_COLUMN_SPACING + min_inf_width;
1637 this->smallest_y =
max(min_inf_height, min_acs_height + INTER_LIST_SPACING + min_avs_height);
1641 if (this->inf->fill_x > 0 && (this->fill_x == 0 || this->fill_x > this->inf->fill_x)) this->fill_x = this->inf->fill_x;
1643 this->fill_y = this->avs->fill_y;
1644 if (this->acs->fill_y > 0 && (this->fill_y == 0 || this->fill_y > this->acs->fill_y)) this->fill_y = this->acs->fill_y;
1649 if (this->inf->resize_x > 0 && (this->resize_x == 0 || this->resize_x > this->inf->resize_x)) this->resize_x = this->inf->resize_x;
1651 this->resize_y = this->avs->resize_y;
1652 if (this->acs->resize_y > 0 && (this->resize_y == 0 || this->resize_y > this->acs->resize_y)) this->resize_y = this->acs->resize_y;
1656 this->smallest_y =
ComputeMaxSize(min_acs_height, this->smallest_y + this->resize_y - 1, this->resize_y);
1659 virtual void AssignSizePosition(
SizingType sizing, uint x, uint y, uint given_width, uint given_height,
bool rtl)
1661 this->StoreSizePosition(sizing, x, y, given_width, given_height);
1663 uint min_avs_width = this->avs->smallest_x + this->avs->padding_left + this->avs->padding_right;
1664 uint min_acs_width = this->acs->smallest_x + this->acs->padding_left + this->acs->padding_right;
1665 uint min_inf_width = this->inf->smallest_x + this->inf->padding_left + this->inf->padding_right;
1667 uint min_list_width =
max(min_avs_width, min_acs_width);
1668 uint avs_extra_width = min_list_width - min_avs_width;
1669 uint acs_extra_width = min_list_width - min_acs_width;
1672 uint min_three_columns = min_avs_width + min_acs_width + min_inf_width + 2 * INTER_COLUMN_SPACING;
1673 uint min_two_columns = min_list_width + min_inf_width + INTER_COLUMN_SPACING;
1674 bool use_three_columns = this->
editable && (min_three_columns + MIN_EXTRA_FOR_3_COLUMNS <= given_width);
1677 uint extra_width, inf_width;
1678 if (use_three_columns) {
1679 extra_width = given_width - min_three_columns;
1680 inf_width =
min(MAX_EXTRA_INFO_WIDTH, extra_width / 2);
1682 extra_width = given_width - min_two_columns;
1683 inf_width =
min(MAX_EXTRA_INFO_WIDTH, extra_width / 2);
1685 inf_width =
ComputeMaxSize(this->inf->smallest_x, this->inf->smallest_x + inf_width, this->inf->GetHorizontalStepSize(sizing));
1686 extra_width -= inf_width - this->inf->smallest_x;
1688 uint inf_height =
ComputeMaxSize(this->inf->smallest_y, given_height, this->inf->GetVerticalStepSize(sizing));
1690 if (use_three_columns) {
1693 uint avs_width =
min(avs_extra_width, extra_width);
1694 extra_width -= avs_width;
1695 extra_width -=
min(acs_extra_width, extra_width);
1696 avs_width += extra_width / 2;
1698 avs_width =
ComputeMaxSize(this->avs->smallest_x, this->avs->smallest_x + avs_width, this->avs->GetHorizontalStepSize(sizing));
1700 uint acs_width = given_width -
1701 inf_width - this->inf->padding_left - this->inf->padding_right -
1702 avs_width - this->avs->padding_left - this->avs->padding_right - 2 * INTER_COLUMN_SPACING;
1703 acs_width =
ComputeMaxSize(min_acs_width, acs_width, this->acs->GetHorizontalStepSize(sizing)) -
1704 this->acs->padding_left - this->acs->padding_right;
1707 uint avs_height =
ComputeMaxSize(this->avs->smallest_y, given_height, this->avs->resize_y);
1708 uint acs_height =
ComputeMaxSize(this->acs->smallest_y, given_height, this->acs->resize_y);
1712 x += this->inf->padding_left;
1713 this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
1714 x += inf_width + this->inf->padding_right + INTER_COLUMN_SPACING;
1716 x += this->avs->padding_left;
1717 this->avs->AssignSizePosition(sizing, x, y + this->avs->padding_top, avs_width, avs_height, rtl);
1718 x += avs_width + this->avs->padding_right + INTER_COLUMN_SPACING;
1721 x += this->acs->padding_left;
1722 this->acs->AssignSizePosition(sizing, x, y + this->acs->padding_top, acs_width, acs_height, rtl);
1723 x += acs_width + this->acs->padding_right + INTER_COLUMN_SPACING;
1726 x += this->avs->padding_left;
1727 this->avs->AssignSizePosition(sizing, x, y + this->avs->padding_top, avs_width, avs_height, rtl);
1729 x += this->inf->padding_left;
1730 this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
1735 uint avs_width =
ComputeMaxSize(this->avs->smallest_x, this->avs->smallest_x + avs_extra_width + extra_width,
1736 this->avs->GetHorizontalStepSize(sizing));
1737 uint acs_width =
ComputeMaxSize(this->acs->smallest_x, this->acs->smallest_x + acs_extra_width + extra_width,
1738 this->acs->GetHorizontalStepSize(sizing));
1740 uint min_avs_height = (!this->
editable) ? 0 : this->avs->smallest_y + this->avs->padding_top + this->avs->padding_bottom + INTER_LIST_SPACING;
1741 uint min_acs_height = this->acs->smallest_y + this->acs->padding_top + this->acs->padding_bottom;
1742 uint extra_height = given_height - min_acs_height - min_avs_height;
1745 uint avs_height =
ComputeMaxSize(this->avs->smallest_y, this->avs->smallest_y + extra_height / 2, this->avs->resize_y);
1746 if (this->
editable) extra_height -= avs_height - this->avs->smallest_y;
1747 uint acs_height =
ComputeMaxSize(this->acs->smallest_y, this->acs->smallest_y + extra_height, this->acs->resize_y);
1751 x += this->inf->padding_left;
1752 this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
1753 x += inf_width + this->inf->padding_right + INTER_COLUMN_SPACING;
1755 this->acs->AssignSizePosition(sizing, x + this->acs->padding_left, y + this->acs->padding_top, acs_width, acs_height, rtl);
1757 this->avs->AssignSizePosition(sizing, x + this->avs->padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
1759 this->avs->AssignSizePosition(sizing, 0, 0, this->avs->smallest_x, this->avs->smallest_y, rtl);
1762 this->acs->AssignSizePosition(sizing, x + this->acs->padding_left, y + this->acs->padding_top, acs_width, acs_height, rtl);
1764 this->avs->AssignSizePosition(sizing, x + this->avs->padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
1766 this->avs->AssignSizePosition(sizing, 0, 0, this->avs->smallest_x, this->avs->smallest_y, rtl);
1768 uint dx = this->acs->current_x + this->acs->padding_left + this->acs->padding_right;
1770 dx =
max(dx, this->avs->current_x + this->avs->padding_left + this->avs->padding_right);
1772 x += dx + INTER_COLUMN_SPACING + this->inf->padding_left;
1773 this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
1780 if (!
IsInsideBS(x, this->pos_x, this->current_x) || !
IsInsideBS(y, this->pos_y, this->current_y))
return NULL;
1801 static const NWidgetPart _nested_newgrf_actives_widgets[] = {
1807 SetDataTip(STR_JUST_STRING, STR_NEWGRF_SETTINGS_PRESET_LIST_TOOLTIP),
1811 SetDataTip(STR_NEWGRF_SETTINGS_PRESET_SAVE, STR_NEWGRF_SETTINGS_PRESET_SAVE_TOOLTIP),
1813 SetDataTip(STR_NEWGRF_SETTINGS_PRESET_DELETE, STR_NEWGRF_SETTINGS_PRESET_DELETE_TOOLTIP),
1833 SetDataTip(STR_NEWGRF_SETTINGS_REMOVE, STR_NEWGRF_SETTINGS_REMOVE_TOOLTIP),
1836 SetDataTip(STR_NEWGRF_SETTINGS_MOVEUP, STR_NEWGRF_SETTINGS_MOVEUP_TOOLTIP),
1838 SetDataTip(STR_NEWGRF_SETTINGS_MOVEDOWN, STR_NEWGRF_SETTINGS_MOVEDOWN_TOOLTIP),
1841 SetDataTip(STR_NEWGRF_SETTINGS_UPGRADE, STR_NEWGRF_SETTINGS_UPGRADE_TOOLTIP),
1846 SetDataTip(STR_NEWGRF_SETTINGS_RESCAN_FILES, STR_NEWGRF_SETTINGS_RESCAN_FILES_TOOLTIP),
1848 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
1854 static const NWidgetPart _nested_newgrf_availables_widgets[] = {
1863 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1877 SetDataTip(STR_NEWGRF_SETTINGS_ADD, STR_NEWGRF_SETTINGS_ADD_FILE_TOOLTIP),
1880 SetDataTip(STR_NEWGRF_SETTINGS_RESCAN_FILES, STR_NEWGRF_SETTINGS_RESCAN_FILES_TOOLTIP),
1882 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
1888 static const NWidgetPart _nested_newgrf_infopanel_widgets[] = {
1896 SetDataTip(STR_CONTENT_OPEN_URL, STR_CONTENT_OPEN_URL_TOOLTIP),
1898 SetDataTip(STR_TEXTFILE_VIEW_README, STR_NULL),
1901 SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_NULL),
1903 SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_NULL),
1911 SetDataTip(STR_NEWGRF_SETTINGS_SET_PARAMETERS, STR_NULL),
1913 SetDataTip(STR_NEWGRF_SETTINGS_TOGGLE_PALETTE, STR_NEWGRF_SETTINGS_TOGGLE_PALETTE_TOOLTIP),
1916 SetDataTip(STR_NEWGRF_SETTINGS_APPLY_CHANGES, STR_NULL),
1919 SetDataTip(STR_NEWGRF_SETTINGS_SHOW_PARAMETERS, STR_NULL),
1930 *biggest_index =
max(*biggest_index, biggest2);
1933 *biggest_index =
max(*biggest_index, biggest2);
1939 static const NWidgetPart _nested_newgrf_widgets[] = {
1960 _nested_newgrf_widgets,
lengthof(_nested_newgrf_widgets)
1985 for (c = nw->
actives; c != NULL && i > 0; c = c->
next, i--) {}
2009 new NewGRFWindow(&_newgrf_desc, editable, show_params, exec_changes, config);
2025 NWidget(
WWT_EDITBOX, COLOUR_GREY,
WID_SVP_EDITBOX),
SetPadding(3, 2, 2, 2),
SetFill(1, 0),
SetResize(1, 0),
2026 SetDataTip(STR_SAVE_PRESET_TITLE, STR_SAVE_PRESET_EDITBOX_TOOLTIP),
2057 this->selected = -1;
2058 if (initial_text != NULL) {
2059 for (uint i = 0; i < this->presets.Length(); i++) {
2060 if (!strcmp(initial_text, this->presets[i])) {
2075 this->vscroll->SetCount(this->presets.Length());
2077 if (initial_text != NULL) this->presetname_editbox.text.Assign(initial_text);
2090 for (uint i = 0; i < this->presets.Length(); i++) {
2093 resize->height =
max(resize->height, d.height);
2095 size->height =
ClampU(this->presets.Length(), 5, 20) * resize->height + 1;
2110 uint min_index = this->vscroll->GetPosition();
2111 uint max_index =
min(min_index + this->vscroll->GetCapacity(), this->presets.Length());
2113 for (uint i = min_index; i < max_index; i++) {
2116 const char *text = this->presets[i];
2130 if (row < this->presets.Length()) {
2131 this->selected = row;
2132 this->presetname_editbox.text.Assign(this->presets[row]);
2237 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);
2260 free(this->last_name);
2263 GetString(buf, STR_NEWGRF_SCAN_ARCHIVES,
lastof(buf));
2264 this->last_name =
stredup(buf);
2266 this->last_name =
stredup(name);
2268 this->scanned = num;