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) {
1039 if (this->active_sel == NULL || !this->
editable)
break;
1044 for (
GRFConfig **pc = &this->actives; *pc != NULL; pc = &(*pc)->
next) {
1048 if (newsel == NULL && c->
next == this->active_sel) newsel = c;
1050 if (c == this->active_sel) {
1051 if (newsel == c) newsel = NULL;
1059 this->active_sel = newsel;
1061 this->avail_pos = -1;
1062 this->avail_sel = NULL;
1063 this->avails.ForceRebuild();
1069 if (!this->
editable || this->actives == NULL)
break;
1078 uint i = this->vscroll2->GetScrolledRowFromWidget(pt.y,
this,
WID_NS_AVAIL_LIST);
1079 this->active_sel = NULL;
1081 if (i < this->avails.Length()) {
1082 this->avail_sel = this->avails[i];
1083 this->avail_pos = i;
1086 if (click_count == 1) {
1096 this->AddGRFToActive();
1101 if (this->execute) {
1103 STR_NEWGRF_POPUP_CAUTION_CAPTION,
1104 STR_NEWGRF_CONFIRMATION_TEXT,
1118 if (this->active_sel == NULL || !this->show_params || this->active_sel->num_valid_params == 0)
break;
1120 OpenGRFParameterWindow(this->active_sel, this->
editable);
1125 if (this->active_sel != NULL && this->
editable) {
1136 #if defined(ENABLE_NETWORK)
1151 virtual void OnNewGRFsScanned()
1153 this->avail_sel = NULL;
1154 this->avail_pos = -1;
1155 this->avails.ForceRebuild();
1165 this->preset = index;
1170 this->avails.ForceRebuild();
1174 this->active_sel = NULL;
1180 if (str == NULL)
return;
1203 if (!gui_scope)
return;
1211 for (
GRFConfig **l = &this->actives; *l != NULL; l = &(*l)->
next) {
1220 (*l)->next = c->
next;
1222 if (active_sel == c) active_sel = *l;
1227 this->avails.ForceRebuild();
1235 for (
const GRFConfig *c = this->actives; c != NULL; c = c->
next, i++) {}
1237 this->vscroll->SetCount(i + 1);
1239 if (this->avail_pos >= 0) this->vscroll2->ScrollTowards(this->avail_pos);
1244 this->BuildAvailables();
1255 bool disable_all = this->active_sel == NULL || !this->
editable;
1263 const GRFConfig *c = (this->avail_sel == NULL) ? this->active_sel : this->avail_sel;
1264 for (
TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
1282 bool has_missing =
false;
1283 bool has_compatible =
false;
1284 for (
const GRFConfig *c = this->actives; !has_missing && c != NULL; c = c->
next) {
1290 if (has_missing || has_compatible) {
1291 widget_data = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON;
1292 tool_tip = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP;
1294 widget_data = STR_INTRO_ONLINE_CONTENT;
1295 tool_tip = STR_INTRO_TOOLTIP_ONLINE_CONTENT;
1312 if (this->avail_pos > 0) this->avail_pos--;
1317 if (this->avail_pos < (
int)this->avails.Length() - 1) this->avail_pos++;
1322 this->avail_pos = (this->avail_pos < this->vscroll2->GetCapacity()) ? 0 : this->avail_pos - this->vscroll2->GetCapacity();
1327 this->avail_pos =
min(this->avail_pos + this->vscroll2->GetCapacity(), (int)this->avails.Length() - 1);
1332 this->avail_pos = 0;
1337 this->avail_pos = this->avails.Length() - 1;
1344 if (this->avails.Length() == 0) this->avail_pos = -1;
1345 if (this->avail_pos >= 0) {
1346 this->avail_sel = this->avails[this->avail_pos];
1347 this->vscroll2->ScrollTowards(this->avail_pos);
1358 string_filter.SetFilterTerm(this->filter_editbox.text.buf);
1359 this->avails.SetFilterState(!string_filter.IsEmpty());
1360 this->avails.ForceRebuild();
1369 if (this->active_sel != NULL) {
1373 for (from_prev = &this->actives; *from_prev != this->active_sel; from_prev = &(*from_prev)->
next, from_pos++) {}
1376 int to_pos =
min(this->vscroll->GetScrolledRowFromWidget(pt.y,
this,
WID_NS_FILE_LIST), this->vscroll->GetCount() - 2);
1377 if (to_pos != from_pos) {
1380 for (
int i = from_pos < to_pos ? -1 : 0; *to_prev != NULL && i < to_pos; to_prev = &(*to_prev)->
next, i++) {}
1383 *from_prev = this->active_sel->
next;
1386 this->active_sel->
next = *to_prev;
1387 *to_prev = this->active_sel;
1389 this->vscroll->ScrollTowards(to_pos);
1393 }
else if (this->avail_sel != NULL) {
1394 int to_pos =
min(this->vscroll->GetScrolledRowFromWidget(pt.y,
this,
WID_NS_FILE_LIST), this->vscroll->GetCount() - 1);
1395 this->AddGRFToActive(to_pos);
1399 Point dummy = {-1, -1};
1405 if (this->active_over != -1) {
1408 this->active_over = -1;
1416 if (widget ==
WID_NS_FILE_LIST && (this->active_sel != NULL || this->avail_sel != NULL)) {
1418 int to_pos = this->vscroll->GetScrolledRowFromWidget(pt.y,
this,
WID_NS_FILE_LIST);
1420 to_pos =
min(to_pos, this->vscroll->GetCount() - (this->active_sel != NULL ? 2 : 1));
1422 if (to_pos != this->active_over) {
1423 this->active_over = to_pos;
1427 this->active_over = -2;
1429 }
else if (this->active_over != -1) {
1431 this->active_over = -1;
1439 int i =
strnatcmp((*a)->GetName(), (*b)->GetName(),
true);
1440 if (i != 0)
return i;
1442 i = (*a)->version - (*b)->version;
1443 if (i != 0)
return i;
1445 return memcmp((*a)->ident.md5sum, (*b)->ident.md5sum,
lengthof((*b)->ident.md5sum));
1452 filter.
AddLine((*a)->GetName());
1453 filter.
AddLine((*a)->filename);
1454 filter.
AddLine((*a)->GetDescription());
1458 void BuildAvailables()
1460 if (!this->avails.NeedRebuild())
return;
1462 this->avails.Clear();
1467 if (found)
continue;
1470 *this->avails.Append() = c;
1481 *this->avails.Append() = c;
1486 this->avails.Filter(this->string_filter);
1487 this->avails.Compact();
1488 this->avails.RebuildDone();
1489 this->avails.Sort();
1491 if (this->avail_sel != NULL) {
1492 this->avail_pos = this->avails.FindIndex(this->avail_sel);
1493 if (this->avail_pos < 0) this->avail_sel = NULL;
1496 this->vscroll2->SetCount(this->avails.Length());
1504 bool AddGRFToActive(
int ins_pos = -1)
1512 for (list = &this->actives; *list != NULL; list = &(*list)->
next, ins_pos--) {
1513 if (ins_pos == 0) entry = list;
1514 if ((*list)->ident.grfid == this->avail_sel->ident.grfid) {
1520 if (entry == NULL) entry = list;
1534 int new_pos = this->avail_pos + 1;
1535 if (new_pos >= (
int)this->avails.Length()) new_pos = this->avail_pos - 1;
1536 this->avail_pos = new_pos;
1537 if (new_pos >= 0) this->avail_sel = this->avails[new_pos];
1539 this->avails.ForceRebuild();
1545 #if defined(ENABLE_NETWORK)
1604 this->Add(this->avs);
1605 this->Add(this->acs);
1606 this->Add(this->inf);
1611 virtual void SetupSmallestSize(
Window *w,
bool init_array)
1614 assert(dynamic_cast<NewGRFWindow *>(w) != NULL);
1618 this->avs->SetupSmallestSize(w, init_array);
1619 this->acs->SetupSmallestSize(w, init_array);
1620 this->inf->SetupSmallestSize(w, init_array);
1622 uint min_avs_width = this->avs->smallest_x + this->avs->padding_left + this->avs->padding_right;
1623 uint min_acs_width = this->acs->smallest_x + this->acs->padding_left + this->acs->padding_right;
1624 uint min_inf_width = this->inf->smallest_x + this->inf->padding_left + this->inf->padding_right;
1626 uint min_avs_height = this->avs->smallest_y + this->avs->padding_top + this->avs->padding_bottom;
1627 uint min_acs_height = this->acs->smallest_y + this->acs->padding_top + this->acs->padding_bottom;
1628 uint min_inf_height = this->inf->smallest_y + this->inf->padding_top + this->inf->padding_bottom;
1631 this->smallest_x =
max(min_avs_width, min_acs_width) + INTER_COLUMN_SPACING + min_inf_width;
1632 this->smallest_y =
max(min_inf_height, min_acs_height + INTER_LIST_SPACING + min_avs_height);
1636 if (this->inf->fill_x > 0 && (this->fill_x == 0 || this->fill_x > this->inf->fill_x)) this->fill_x = this->inf->fill_x;
1638 this->fill_y = this->avs->fill_y;
1639 if (this->acs->fill_y > 0 && (this->fill_y == 0 || this->fill_y > this->acs->fill_y)) this->fill_y = this->acs->fill_y;
1644 if (this->inf->resize_x > 0 && (this->resize_x == 0 || this->resize_x > this->inf->resize_x)) this->resize_x = this->inf->resize_x;
1646 this->resize_y = this->avs->resize_y;
1647 if (this->acs->resize_y > 0 && (this->resize_y == 0 || this->resize_y > this->acs->resize_y)) this->resize_y = this->acs->resize_y;
1651 this->smallest_y =
ComputeMaxSize(min_acs_height, this->smallest_y + this->resize_y - 1, this->resize_y);
1654 virtual void AssignSizePosition(
SizingType sizing, uint x, uint y, uint given_width, uint given_height,
bool rtl)
1656 this->StoreSizePosition(sizing, x, y, given_width, given_height);
1658 uint min_avs_width = this->avs->smallest_x + this->avs->padding_left + this->avs->padding_right;
1659 uint min_acs_width = this->acs->smallest_x + this->acs->padding_left + this->acs->padding_right;
1660 uint min_inf_width = this->inf->smallest_x + this->inf->padding_left + this->inf->padding_right;
1662 uint min_list_width =
max(min_avs_width, min_acs_width);
1663 uint avs_extra_width = min_list_width - min_avs_width;
1664 uint acs_extra_width = min_list_width - min_acs_width;
1667 uint min_three_columns = min_avs_width + min_acs_width + min_inf_width + 2 * INTER_COLUMN_SPACING;
1668 uint min_two_columns = min_list_width + min_inf_width + INTER_COLUMN_SPACING;
1669 bool use_three_columns = this->
editable && (min_three_columns + MIN_EXTRA_FOR_3_COLUMNS <= given_width);
1672 uint extra_width, inf_width;
1673 if (use_three_columns) {
1674 extra_width = given_width - min_three_columns;
1675 inf_width =
min(MAX_EXTRA_INFO_WIDTH, extra_width / 2);
1677 extra_width = given_width - min_two_columns;
1678 inf_width =
min(MAX_EXTRA_INFO_WIDTH, extra_width / 2);
1680 inf_width =
ComputeMaxSize(this->inf->smallest_x, this->inf->smallest_x + inf_width, this->inf->GetHorizontalStepSize(sizing));
1681 extra_width -= inf_width - this->inf->smallest_x;
1683 uint inf_height =
ComputeMaxSize(this->inf->smallest_y, given_height, this->inf->GetVerticalStepSize(sizing));
1685 if (use_three_columns) {
1688 uint avs_width =
min(avs_extra_width, extra_width);
1689 extra_width -= avs_width;
1690 extra_width -=
min(acs_extra_width, extra_width);
1691 avs_width += extra_width / 2;
1693 avs_width =
ComputeMaxSize(this->avs->smallest_x, this->avs->smallest_x + avs_width, this->avs->GetHorizontalStepSize(sizing));
1695 uint acs_width = given_width -
1696 inf_width - this->inf->padding_left - this->inf->padding_right -
1697 avs_width - this->avs->padding_left - this->avs->padding_right - 2 * INTER_COLUMN_SPACING;
1698 acs_width =
ComputeMaxSize(min_acs_width, acs_width, this->acs->GetHorizontalStepSize(sizing)) -
1699 this->acs->padding_left - this->acs->padding_right;
1702 uint avs_height =
ComputeMaxSize(this->avs->smallest_y, given_height, this->avs->resize_y);
1703 uint acs_height =
ComputeMaxSize(this->acs->smallest_y, given_height, this->acs->resize_y);
1707 x += this->inf->padding_left;
1708 this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
1709 x += inf_width + this->inf->padding_right + INTER_COLUMN_SPACING;
1711 x += this->avs->padding_left;
1712 this->avs->AssignSizePosition(sizing, x, y + this->avs->padding_top, avs_width, avs_height, rtl);
1713 x += avs_width + this->avs->padding_right + INTER_COLUMN_SPACING;
1716 x += this->acs->padding_left;
1717 this->acs->AssignSizePosition(sizing, x, y + this->acs->padding_top, acs_width, acs_height, rtl);
1718 x += acs_width + this->acs->padding_right + INTER_COLUMN_SPACING;
1721 x += this->avs->padding_left;
1722 this->avs->AssignSizePosition(sizing, x, y + this->avs->padding_top, avs_width, avs_height, rtl);
1724 x += this->inf->padding_left;
1725 this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
1730 uint avs_width =
ComputeMaxSize(this->avs->smallest_x, this->avs->smallest_x + avs_extra_width + extra_width,
1731 this->avs->GetHorizontalStepSize(sizing));
1732 uint acs_width =
ComputeMaxSize(this->acs->smallest_x, this->acs->smallest_x + acs_extra_width + extra_width,
1733 this->acs->GetHorizontalStepSize(sizing));
1735 uint min_avs_height = (!this->
editable) ? 0 : this->avs->smallest_y + this->avs->padding_top + this->avs->padding_bottom + INTER_LIST_SPACING;
1736 uint min_acs_height = this->acs->smallest_y + this->acs->padding_top + this->acs->padding_bottom;
1737 uint extra_height = given_height - min_acs_height - min_avs_height;
1740 uint avs_height =
ComputeMaxSize(this->avs->smallest_y, this->avs->smallest_y + extra_height / 2, this->avs->resize_y);
1741 if (this->
editable) extra_height -= avs_height - this->avs->smallest_y;
1742 uint acs_height =
ComputeMaxSize(this->acs->smallest_y, this->acs->smallest_y + extra_height, this->acs->resize_y);
1746 x += this->inf->padding_left;
1747 this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
1748 x += inf_width + this->inf->padding_right + INTER_COLUMN_SPACING;
1750 this->acs->AssignSizePosition(sizing, x + this->acs->padding_left, y + this->acs->padding_top, acs_width, acs_height, rtl);
1752 this->avs->AssignSizePosition(sizing, x + this->avs->padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
1754 this->avs->AssignSizePosition(sizing, 0, 0, this->avs->smallest_x, this->avs->smallest_y, rtl);
1757 this->acs->AssignSizePosition(sizing, x + this->acs->padding_left, y + this->acs->padding_top, acs_width, acs_height, rtl);
1759 this->avs->AssignSizePosition(sizing, x + this->avs->padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
1761 this->avs->AssignSizePosition(sizing, 0, 0, this->avs->smallest_x, this->avs->smallest_y, rtl);
1763 uint dx = this->acs->current_x + this->acs->padding_left + this->acs->padding_right;
1765 dx =
max(dx, this->avs->current_x + this->avs->padding_left + this->avs->padding_right);
1767 x += dx + INTER_COLUMN_SPACING + this->inf->padding_left;
1768 this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
1775 if (!
IsInsideBS(x, this->pos_x, this->current_x) || !
IsInsideBS(y, this->pos_y, this->current_y))
return NULL;
1796 static const NWidgetPart _nested_newgrf_actives_widgets[] = {
1802 SetDataTip(STR_JUST_STRING, STR_NEWGRF_SETTINGS_PRESET_LIST_TOOLTIP),
1806 SetDataTip(STR_NEWGRF_SETTINGS_PRESET_SAVE, STR_NEWGRF_SETTINGS_PRESET_SAVE_TOOLTIP),
1808 SetDataTip(STR_NEWGRF_SETTINGS_PRESET_DELETE, STR_NEWGRF_SETTINGS_PRESET_DELETE_TOOLTIP),
1828 SetDataTip(STR_NEWGRF_SETTINGS_REMOVE, STR_NEWGRF_SETTINGS_REMOVE_TOOLTIP),
1831 SetDataTip(STR_NEWGRF_SETTINGS_MOVEUP, STR_NEWGRF_SETTINGS_MOVEUP_TOOLTIP),
1833 SetDataTip(STR_NEWGRF_SETTINGS_MOVEDOWN, STR_NEWGRF_SETTINGS_MOVEDOWN_TOOLTIP),
1836 SetDataTip(STR_NEWGRF_SETTINGS_UPGRADE, STR_NEWGRF_SETTINGS_UPGRADE_TOOLTIP),
1841 SetDataTip(STR_NEWGRF_SETTINGS_RESCAN_FILES, STR_NEWGRF_SETTINGS_RESCAN_FILES_TOOLTIP),
1843 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
1849 static const NWidgetPart _nested_newgrf_availables_widgets[] = {
1858 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1872 SetDataTip(STR_NEWGRF_SETTINGS_ADD, STR_NEWGRF_SETTINGS_ADD_FILE_TOOLTIP),
1875 SetDataTip(STR_NEWGRF_SETTINGS_RESCAN_FILES, STR_NEWGRF_SETTINGS_RESCAN_FILES_TOOLTIP),
1877 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
1883 static const NWidgetPart _nested_newgrf_infopanel_widgets[] = {
1891 SetDataTip(STR_CONTENT_OPEN_URL, STR_CONTENT_OPEN_URL_TOOLTIP),
1893 SetDataTip(STR_TEXTFILE_VIEW_README, STR_NULL),
1896 SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_NULL),
1898 SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_NULL),
1906 SetDataTip(STR_NEWGRF_SETTINGS_SET_PARAMETERS, STR_NULL),
1908 SetDataTip(STR_NEWGRF_SETTINGS_TOGGLE_PALETTE, STR_NEWGRF_SETTINGS_TOGGLE_PALETTE_TOOLTIP),
1911 SetDataTip(STR_NEWGRF_SETTINGS_APPLY_CHANGES, STR_NULL),
1914 SetDataTip(STR_NEWGRF_SETTINGS_SHOW_PARAMETERS, STR_NULL),
1925 *biggest_index =
max(*biggest_index, biggest2);
1928 *biggest_index =
max(*biggest_index, biggest2);
1934 static const NWidgetPart _nested_newgrf_widgets[] = {
1955 _nested_newgrf_widgets,
lengthof(_nested_newgrf_widgets)
1980 for (c = nw->
actives; c != NULL && i > 0; c = c->
next, i--) {}
2004 new NewGRFWindow(&_newgrf_desc, editable, show_params, exec_changes, config);
2020 NWidget(
WWT_EDITBOX, COLOUR_GREY,
WID_SVP_EDITBOX),
SetPadding(3, 2, 2, 2),
SetFill(1, 0),
SetResize(1, 0),
2021 SetDataTip(STR_SAVE_PRESET_TITLE, STR_SAVE_PRESET_EDITBOX_TOOLTIP),
2052 this->selected = -1;
2053 if (initial_text != NULL) {
2054 for (uint i = 0; i < this->presets.Length(); i++) {
2055 if (!strcmp(initial_text, this->presets[i])) {
2070 this->vscroll->SetCount(this->presets.Length());
2072 if (initial_text != NULL) this->presetname_editbox.text.Assign(initial_text);
2085 for (uint i = 0; i < this->presets.Length(); i++) {
2088 resize->height =
max(resize->height, d.height);
2090 size->height =
ClampU(this->presets.Length(), 5, 20) * resize->height + 1;
2105 uint min_index = this->vscroll->GetPosition();
2106 uint max_index =
min(min_index + this->vscroll->GetCapacity(), this->presets.Length());
2108 for (uint i = min_index; i < max_index; i++) {
2111 const char *text = this->presets[i];
2125 if (row < this->presets.Length()) {
2126 this->selected = row;
2127 this->presetname_editbox.text.Assign(this->presets[row]);
2232 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);
2255 free(this->last_name);
2258 GetString(buf, STR_NEWGRF_SCAN_ARCHIVES,
lastof(buf));
2259 this->last_name =
stredup(buf);
2261 this->last_name =
stredup(name);
2263 this->scanned = num;