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);
162 clicked_button(UINT_MAX),
163 clicked_dropdown(false),
164 closing_dropdown(false),
166 clicked_row(UINT_MAX),
174 this->GetWidget<NWidgetStacked>(
WID_NP_SHOW_DESCRIPTION)->SetDisplayedPlane(this->action14present ? 0 : SZSP_HORIZONTAL);
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;
270 uint32 current_value = par_info->
GetValue(this->grf_config);
274 DrawBoolButton(buttons_left, y + button_y_offset, current_value != 0, this->editable);
275 SetDParam(2, par_info->
GetValue(this->grf_config) == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
278 DrawDropDownButton(buttons_left, y + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && this->clicked_dropdown, this->editable);
280 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);
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);
309 if (this->closing_dropdown) {
310 this->closing_dropdown =
false;
311 this->clicked_dropdown =
false;
320 if (this->editable && !this->action14present && this->grf_config->
num_params > 0) {
338 if (!this->editable)
break;
340 if (num >= this->vscroll->
GetCount())
break;
341 if (this->clicked_row != num) {
344 this->clicked_row = num;
345 this->clicked_dropdown =
false;
349 int x = pt.x - wid->
pos_x;
357 uint32 old_val = par_info->
GetValue(this->grf_config);
359 if (this->clicked_dropdown) {
362 this->clicked_dropdown =
false;
363 this->closing_dropdown =
false;
375 if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
376 this->clicked_dropdown =
true;
377 this->closing_dropdown =
false;
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++;
395 this->clicked_increase =
true;
399 this->clicked_increase =
false;
402 if (val != old_val) {
403 par_info->
SetValue(this->grf_config, val);
405 this->clicked_button = num;
418 if (!this->editable)
break;
433 int32 value = atoi(str);
437 par_info->
SetValue(this->grf_config, val);
443 assert(this->clicked_dropdown);
446 par_info->
SetValue(this->grf_config, index);
456 assert(this->clicked_dropdown);
457 this->closing_dropdown =
true;
473 if (!gui_scope)
return;
474 if (!this->action14present) {
480 if (this->clicked_row != UINT_MAX && this->clicked_row >= this->vscroll->
GetCount()) {
481 this->clicked_row = UINT_MAX;
488 if (--this->timeout == 0) {
489 this->clicked_button = UINT_MAX;
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)
549 const char *textfile = this->grf_config->
GetTextfile(file_type);
576 bool Selectable()
const 581 void Draw(
int left,
int right,
int top,
int bottom,
bool sel,
int bg_colour)
const 583 DrawString(left + 2, right + 2, top, _grf_preset_list[this->result], sel ? TC_WHITE : TC_BLACK);
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);
686 if (this->editable && !this->execute) {
694 _grf_preset_list.
Clear();
707 GrfIdMap::const_iterator iter = grfid_map.find(a->ident.grfid);
708 if (iter != grfid_map.end() && a->version > iter->second->version)
return true;
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;
764 for (uint i = 0; i < _grf_preset_list.
Length(); i++) {
765 if (_grf_preset_list[i] != 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++) {
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)) {
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;
946 for (uint i = 0; i < _grf_preset_list.
Length(); i++) {
947 if (_grf_preset_list[i] != NULL) {
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;
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) {
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;
1070 if (!this->editable || this->actives == NULL)
break;
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();
1102 if (!this->editable)
break;
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) 1155 this->avail_sel = NULL;
1156 this->avail_pos = -1;
1164 if (!this->editable)
return;
1167 this->preset = index;
1176 this->active_sel = NULL;
1182 if (str == NULL)
return;
1188 for (uint i = 0; i < _grf_preset_list.
Length(); i++) {
1189 if (_grf_preset_list[i] != NULL && strcmp(_grf_preset_list[i], str) == 0) {
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;
1239 for (
const GRFConfig *c = this->actives; c != NULL; c = c->
next, i++) {}
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];
1360 if (!this->editable)
return;
1370 if (!this->editable)
return;
1373 if (this->active_sel != NULL) {
1377 for (from_prev = &this->actives; *from_prev != this->active_sel; from_prev = &(*from_prev)->
next, from_pos++) {}
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;
1397 }
else if (this->avail_sel != NULL) {
1399 this->AddGRFToActive(to_pos);
1403 Point dummy = {-1, -1};
1409 if (this->active_over != -1) {
1412 this->active_over = -1;
1418 if (!this->editable)
return;
1420 if (widget ==
WID_NS_FILE_LIST && (this->active_sel != NULL || this->avail_sel != NULL)) {
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()
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);
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;
1510 if (this->avail_sel == NULL || !this->editable ||
HasBit(this->avail_sel->
flags,
GCF_INVALID))
return false;
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];
1549 #if defined(ENABLE_NETWORK) 1608 this->Add(this->avs);
1609 this->Add(this->acs);
1610 this->Add(this->inf);
1612 this->editable =
true;
1618 assert(dynamic_cast<NewGRFWindow *>(w) != NULL);
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);
1660 this->StoreSizePosition(sizing, x, y, given_width, given_height);
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;
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 -
1713 x += inf_width + this->inf->
padding_right + INTER_COLUMN_SPACING;
1717 x += avs_width + this->avs->
padding_right + INTER_COLUMN_SPACING;
1722 x += acs_width + this->acs->
padding_right + INTER_COLUMN_SPACING;
1735 this->avs->GetHorizontalStepSize(sizing));
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);
1752 x += inf_width + this->inf->
padding_right + INTER_COLUMN_SPACING;
1755 if (this->editable) {
1756 this->avs->
AssignSizePosition(sizing, x + this->avs->
padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
1762 if (this->editable) {
1763 this->avs->
AssignSizePosition(sizing, x + this->avs->
padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
1768 if (this->editable) {
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;
1779 if (!
IsInsideBS(x, this->pos_x, this->current_x) || !
IsInsideBS(y, this->pos_y, this->current_y))
return NULL;
1789 if (this->editable) this->avs->
Draw(w);
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),
2039 _nested_save_preset_widgets,
lengthof(_nested_save_preset_widgets)
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])) {
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;
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]);
2186 _nested_scan_progress_widgets,
lengthof(_nested_scan_progress_widgets)
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;
EventState
State of handling an event.
Functions related to OTTD's strings.
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
virtual EventState OnKeyPress(WChar key, uint16 keycode)
A key has been pressed.
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;.
static int CDECL NameSorter(const GRFConfig *const *a, const GRFConfig *const *b)
Sort grfs by name.
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.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
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.
bool Contains(const T &key) const
Tests whether a key is assigned in this map.
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.
const Pair * Find(const T &key) const
Finds given key in this map.
void SaveGRFPresetToConfig(const char *config_name, GRFConfig *config)
Save a NewGRF configuration with a preset name.
int left
x position of left edge of the window
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.
static bool IsInsideMM(const T x, const uint min, const uint max)
Checks if a value is in an interval.
virtual void OnResize()
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:
GUIGRFConfigList avails
Available (non-active) grfs.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
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.
void SetStringParameters(int widget) const
Initialize string parameters for a widget.
virtual void OnDragDrop(Point pt, int widget)
A dragged 'object' has been released.
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.
void ShowDropDownList(Window *w, const DropDownList *list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
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.
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.
void ShowNetworkContentListWindow(ContentVector *cv=NULL, ContentType type1=CONTENT_TYPE_END, ContentType type2=CONTENT_TYPE_END)
Show the content list window with a given set of content.
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
static bool IsInsideBS(const T x, const uint base, const uint size)
Checks if a value is between a window started at some base point.
void Clear()
Remove all items from the list.
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...
void Compact()
Compact the list down to the smallest block size boundary.
uint8 num_valid_params
NOSAVE: Number of valid parameters (action 0x14)
char * custom_message
Custom message (if present)
virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close)
A dropdown window associated to this window has been closed.
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.
The NewGRF provided no information.
byte param_nr
GRF parameter to store content in.
uint8 original_md5sum[16]
MD5 checksum of original file if only a 'compatible' file was loaded.
bool show_params
Are the grf-parameters shown in the info-panel?
#define lastof(x)
Get the last element of an fixed size array.
StringID severity
Info / Warning / Error / Fatal.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
virtual void OnResize()
Called after the window got resized.
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.
SmallVector< GRFParameterInfo *, 4 > param_info
NOSAVE: extra information about the parameters.
void SetListing(Listing l)
Import sort conditions.
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.
GRFPresetList presets
Available presets.
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?
T * Append(uint to_add=1)
Append an item and return it.
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.
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.
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=NULL, uint textref_stack_size=0, const uint32 *textref_stack=NULL)
Display an error message in a window.
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.
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.
uint Length() const
Get the number of items in the list.
char * last_name
The name of the last 'seen' NewGRF.
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.
Simple vector template class, with automatic delete.
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.
SmallMap< uint32, struct GRFText *, 8 > value_names
Names for each value.
The palette state is set to use the Windows palette.
Definition of base types and functions in a cross-platform compatible way.
A number of safeguards to prevent using unsafe methods.
uint32 max_value
The maximal value of this parameter.
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.
const GRFConfig * grf_config
View the textfile of this GRFConfig.
int avail_pos
Index of avail_sel if existing, else -1.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
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.
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.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
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.
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. NULL is none is selected.
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
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.
static const uint8 PC_GREY
Grey palette colour.
static const uint8 PC_DARK_BLUE
Dark blue palette colour.
virtual void OnResize()
Called after the window got resized.
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.
char *const buf
buffer in which text is saved
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
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?
bool scenario_developer
activate scenario developer: allow modifying NewGRFs in an existing game
void ReInitAllWindows()
Re-initialize all windows.
int FindIndex(const T &item) const
Search for the first occurrence of an item.
int timeout
How long before we unpress the last-pressed button?
Save preset; Window numbers:
GUISettings gui
settings related to the GUI
virtual void OnDropdownSelect(int widget, int index)
A dropdown option associated to this window has been selected.
PaletteID GetPalette(const GRFConfig *c) const
Pick the palette for the sprite of the grf to display.
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.
virtual void OnPaint()
The window must be repainted.
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.
const char * GetTextfile(TextfileType type) const
Search a textfile file next to this NewGRF.
uint8 palette
GRFPalette, bitset.
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.
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.
int CDECL SortFunction(const T *, const T *)
Signature of sort function.
void ResetGRFConfig(bool defaults)
Reset the current GRF Config to either blank or newgame settings.
Functions for setting GUIs.
void GetGRFPresetList(GRFPresetList *list)
Get the list of known NewGrf presets.
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.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
Functions related to the drop down widget.
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 ScanNewGRFFiles(NewGRFScanCallback *callback)
Scan for all NewGRFs.
Coordinates of a point in 2D.
void Clear()
Remove all items from the list.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
List item containing a C char string.
virtual void OnDropdownSelect(int widget, int index)
A dropdown option associated to this window has been selected.
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).
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
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.
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.
static WindowDesc _scan_progress_desc(WDP_CENTER, NULL, 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 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.
static GRFPresetList _grf_preset_list
List of known NewGRF presets.
Bitmask to get only the NewGRF supplied information.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
virtual void OnTick()
Called once per (game) tick.
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.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
virtual void OnMouseDrag(Point pt, int widget)
An 'object' is being dragged at the provided position, highlight the target if possible.
virtual void OnNewGRFsScanned()
Called whenever the NewGRF scan completed.
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
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.
virtual void OnEditboxChanged(int wid)
The text in an editbox has been edited.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
GRFConfig * active_sel
Selected active grf item.
Base list item class from which others are derived.
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.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
This file contains all sprite-related enums and defines.
static Filtering last_filtering
Default filtering of #GUIGRFConfigList.
Game options window; Window numbers:
void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width, bool instant_close)
Show a drop down list.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
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.
Window for displaying the textfile of a NewGRF.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
uint clicked_row
The selected parameter.
void UpdateNewGRFScanStatus(uint num, const char *name)
Update the NewGRF scan status.
GUI functions related to textfiles.
AutoDeleteSmallVector< const DropDownListItem *, 4 > DropDownList
A drop down list is a collection of drop down list items.
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.
Class for the save preset window.
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
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.