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)
541 static void OpenGRFParameterWindow(
GRFConfig *c,
bool editable)
580 bool Selectable()
const
585 void Draw(
int left,
int right,
int top,
int bottom,
bool sel,
int bg_colour)
const
587 DrawString(left + 2, right + 2, top, _grf_preset_list[this->result], sel ? TC_WHITE : TC_BLACK);
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;
663 this->GetWidget<NWidgetStacked>(
WID_NS_SHOW_REMOVE)->SetDisplayedPlane(this->editable ? 0 : 1);
698 _grf_preset_list.
Clear();
711 GrfIdMap::const_iterator iter = grfid_map.find(a->ident.grfid);
712 if (iter != grfid_map.end() && a->version > iter->second->version)
return true;
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;
768 for (uint i = 0; i < _grf_preset_list.
Length(); i++) {
769 if (_grf_preset_list[i] != NULL) {
774 d.width += padding.width;
783 size->width += padding.width;
784 size->height += padding.height;
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;
868 const char *text = c->
GetName();
876 int active_sel_pos = 0;
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);
905 for (uint i = min_index; i < max_index; i++) {
908 const char *text = c->
GetName();
925 if (selected == NULL) selected = this->
avail_sel;
926 if (selected != NULL) {
950 for (uint i = 0; i < _grf_preset_list.
Length(); i++) {
951 if (_grf_preset_list[i] != NULL) {
964 extern void OpenBrowser(
const char *url);
974 if (this->preset == -1)
return;
989 if (c->
next == this->active_sel) {
1022 ResetObjectToPlace();
1027 for (c = this->
actives; c != NULL && i > 0; c = c->
next, i--) {}
1035 if (click_count == 1) {
1052 if (newsel == NULL && c->
next == this->active_sel) newsel = c;
1055 if (newsel == c) newsel = NULL;
1080 ResetObjectToPlace();
1090 if (click_count == 1) {
1107 STR_NEWGRF_POPUP_CAUTION_CAPTION,
1108 STR_NEWGRF_CONFIRMATION_TEXT,
1140 #if defined(ENABLE_NETWORK)
1176 ResetObjectToPlace();
1184 if (str == NULL)
return;
1190 for (uint i = 0; i < _grf_preset_list.
Length(); i++) {
1191 if (_grf_preset_list[i] != NULL && strcmp(_grf_preset_list[i], str) == 0) {
1207 if (!gui_scope)
return;
1224 (*l)->next = c->
next;
1248 this->BuildAvailables();
1268 for (
TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
1287 bool has_missing =
false;
1288 bool has_compatible =
false;
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;
1378 for (from_prev = &this->
actives; *from_prev != this->
active_sel; from_prev = &(*from_prev)->
next, from_pos++) {}
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++) {}
1404 Point dummy = {-1, -1};
1408 ResetObjectToPlace();
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()
1472 if (found)
continue;
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) {
1550 #if defined(ENABLE_NETWORK)
1609 this->
Add(this->avs);
1610 this->
Add(this->acs);
1611 this->
Add(this->inf);
1619 assert(dynamic_cast<NewGRFWindow *>(w) != NULL);
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;
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;
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;
1677 uint extra_width, inf_width;
1678 if (use_three_columns) {
1679 extra_width = given_width - min_three_columns;
1682 extra_width = given_width - min_two_columns;
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;
1700 uint acs_width = given_width -
1736 this->avs->GetHorizontalStepSize(sizing));
1738 this->acs->GetHorizontalStepSize(sizing));
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;
1770 dx =
max(dx, this->
avs->
current_x + this->avs->padding_left + this->avs->padding_right);
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),
2040 _nested_save_preset_widgets,
lengthof(_nested_save_preset_widgets)
2058 if (initial_text != NULL) {
2060 if (!strcmp(initial_text, this->
presets[i])) {
2093 resize->height =
max(resize->height, d.height);
2113 for (uint i = min_index; i < max_index; i++) {
2116 const char *text = this->
presets[i];
2187 _nested_scan_progress_widgets,
lengthof(_nested_scan_progress_widgets)
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);
2263 GetString(buf, STR_NEWGRF_SCAN_ARCHIVES,
lastof(buf));