49 if (_game_mode == GM_MENU)
return;
53 if (c->error == NULL || c->error->severity != STR_NEWGRF_ERROR_MSG_FATAL)
continue;
55 SetDParam (0, c->error->custom_message == NULL ? c->error->message : STR_JUST_RAW_STRING);
59 for (uint i = 0; i <
lengthof(c->error->param_value); i++) {
60 SetDParam(4 + i, c->error->param_value[i]);
67 static void ShowNewGRFInfo(
const GRFConfig *c, uint x, uint y, uint right, uint bottom,
bool show_params)
69 if (c->
error != NULL) {
116 SetDParam(0, STR_NEWGRF_SETTINGS_PARAMETER_NONE);
163 clicked_button(UINT_MAX),
164 clicked_dropdown(false),
165 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;
406 this->timeout.SetInterval(150);
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 (timeout.
Elapsed(delta_ms)) {
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) {
731 this->active_sel = NULL;
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;
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++) {
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)) {
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;
950 for (uint i = 0; i < _grf_preset_list.
Length(); i++) {
951 if (_grf_preset_list[i] != NULL) {
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;
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) {
1027 for (c = this->actives; c != NULL && i > 0; c = c->
next, i--) {}
1029 if (this->active_sel != c) {
1033 this->active_sel = c;
1034 this->avail_sel = NULL;
1035 this->avail_pos = -1;
1038 if (click_count == 1) {
1047 if (this->active_sel == NULL || !this->editable)
break;
1053 for (
GRFConfig **pc = &this->actives; *pc != NULL; pc = &(*pc)->
next) {
1057 if (newsel == NULL && c->
next == this->active_sel) newsel = c;
1059 if (c == this->active_sel) {
1060 if (newsel == c) newsel = NULL;
1068 this->active_sel = newsel;
1070 this->avail_pos = -1;
1071 this->avail_sel = NULL;
1078 if (!this->editable || this->actives == NULL)
break;
1088 this->active_sel = NULL;
1090 if (i < this->avails.
Length()) {
1092 this->avail_sel = this->avails[i];
1093 this->avail_pos = i;
1096 if (click_count == 1) {
1107 this->AddGRFToActive();
1111 if (!this->editable)
break;
1112 if (this->execute) {
1114 STR_NEWGRF_POPUP_CAUTION_CAPTION,
1115 STR_NEWGRF_CONFIRMATION_TEXT,
1129 if (this->active_sel == NULL || !this->show_params || this->active_sel->
num_valid_params == 0)
break;
1131 OpenGRFParameterWindow(this->active_sel, this->editable);
1136 if (this->active_sel != NULL && this->editable) {
1147 #if defined(ENABLE_NETWORK) 1165 this->avail_sel = NULL;
1166 this->avail_pos = -1;
1173 if (!this->editable)
return;
1176 this->preset = index;
1186 this->active_sel = NULL;
1192 if (str == NULL)
return;
1198 for (uint i = 0; i < _grf_preset_list.
Length(); i++) {
1199 if (_grf_preset_list[i] != NULL && strcmp(_grf_preset_list[i], str) == 0) {
1215 if (!gui_scope)
return;
1223 for (
GRFConfig **l = &this->actives; *l != NULL; l = &(*l)->
next) {
1232 (*l)->next = c->
next;
1234 if (this->active_sel == c) this->active_sel = *l;
1249 for (
const GRFConfig *c = this->actives; c != NULL; c = c->
next, i++) {}
1253 if (this->avail_pos >= 0) this->vscroll2->
ScrollTowards(this->avail_pos);
1258 this->BuildAvailables();
1269 bool disable_all = this->active_sel == NULL || !this->
editable;
1277 const GRFConfig *c = (this->avail_sel == NULL) ? this->active_sel : this->avail_sel;
1278 for (
TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
1296 bool has_missing =
false;
1297 bool has_compatible =
false;
1298 for (
const GRFConfig *c = this->actives; !has_missing && c != NULL; c = c->
next) {
1304 if (has_missing || has_compatible) {
1305 widget_data = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON;
1306 tool_tip = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP;
1308 widget_data = STR_INTRO_ONLINE_CONTENT;
1309 tool_tip = STR_INTRO_TOOLTIP_ONLINE_CONTENT;
1326 if (this->avail_pos > 0) this->avail_pos--;
1331 if (this->avail_pos < (
int)this->avails.
Length() - 1) this->avail_pos++;
1336 this->avail_pos = (this->avail_pos < this->vscroll2->
GetCapacity()) ? 0 : this->avail_pos - this->vscroll2->
GetCapacity();
1341 this->avail_pos =
min(this->avail_pos + this->vscroll2->
GetCapacity(), (int)this->avails.
Length() - 1);
1346 this->avail_pos = 0;
1351 this->avail_pos = this->avails.
Length() - 1;
1358 if (this->avails.
Length() == 0) this->avail_pos = -1;
1359 if (this->avail_pos >= 0) {
1360 this->active_sel = NULL;
1363 this->avail_sel = this->avails[this->avail_pos];
1373 if (!this->editable)
return;
1383 if (!this->editable)
return;
1386 if (this->active_sel != NULL) {
1390 for (from_prev = &this->actives; *from_prev != this->active_sel; from_prev = &(*from_prev)->
next, from_pos++) {}
1394 if (to_pos != from_pos) {
1397 for (
int i = from_pos < to_pos ? -1 : 0; *to_prev != NULL && i < to_pos; to_prev = &(*to_prev)->
next, i++) {}
1400 *from_prev = this->active_sel->
next;
1403 this->active_sel->
next = *to_prev;
1404 *to_prev = this->active_sel;
1410 }
else if (this->avail_sel != NULL) {
1412 this->AddGRFToActive(to_pos);
1416 Point dummy = {-1, -1};
1422 if (this->active_over != -1) {
1425 this->active_over = -1;
1431 if (!this->editable)
return;
1433 if (widget ==
WID_NS_FILE_LIST && (this->active_sel != NULL || this->avail_sel != NULL)) {
1437 to_pos =
min(to_pos, this->vscroll->
GetCount() - (this->active_sel != NULL ? 2 : 1));
1439 if (to_pos != this->active_over) {
1440 this->active_over = to_pos;
1444 this->active_over = -2;
1446 }
else if (this->active_over != -1) {
1448 this->active_over = -1;
1456 int i =
strnatcmp((*a)->GetName(), (*b)->GetName(),
true);
1457 if (i != 0)
return i;
1459 i = (*a)->version - (*b)->version;
1460 if (i != 0)
return i;
1462 return memcmp((*a)->ident.md5sum, (*b)->ident.md5sum,
lengthof((*b)->ident.md5sum));
1469 filter.
AddLine((*a)->GetName());
1470 filter.
AddLine((*a)->filename);
1471 filter.
AddLine((*a)->GetDescription());
1475 void BuildAvailables()
1479 this->avails.
Clear();
1484 if (found)
continue;
1487 *this->avails.
Append() = c;
1498 *this->avails.
Append() = c;
1503 this->avails.
Filter(this->string_filter);
1506 this->avails.
Sort();
1508 if (this->avail_sel != NULL) {
1509 this->avail_pos = this->avails.
FindIndex(this->avail_sel);
1510 if (this->avail_pos < 0) this->avail_sel = NULL;
1523 if (this->avail_sel == NULL || !this->editable ||
HasBit(this->avail_sel->
flags,
GCF_INVALID))
return false;
1531 for (list = &this->actives; *list != NULL; list = &(*list)->
next, ins_pos--) {
1532 if (ins_pos == 0) entry = list;
1533 if ((*list)->ident.grfid == this->avail_sel->ident.grfid) {
1539 if (entry == NULL) entry = list;
1553 int new_pos = this->avail_pos + 1;
1554 if (new_pos >= (
int)this->avails.
Length()) new_pos = this->avail_pos - 1;
1555 this->avail_pos = new_pos;
1556 if (new_pos >= 0) this->avail_sel = this->avails[new_pos];
1564 #if defined(ENABLE_NETWORK) 1623 this->Add(this->avs);
1624 this->Add(this->acs);
1625 this->Add(this->inf);
1627 this->editable =
true;
1633 assert(dynamic_cast<NewGRFWindow *>(w) != NULL);
1650 this->smallest_x =
max(min_avs_width, min_acs_width) + INTER_COLUMN_SPACING + min_inf_width;
1651 this->smallest_y =
max(min_inf_height, min_acs_height + INTER_LIST_SPACING + min_avs_height);
1655 if (this->inf->
fill_x > 0 && (this->fill_x == 0 || this->fill_x > this->inf->fill_x)) this->fill_x = this->inf->
fill_x;
1657 this->fill_y = this->avs->
fill_y;
1658 if (this->acs->
fill_y > 0 && (this->fill_y == 0 || this->fill_y > this->acs->fill_y)) this->fill_y = this->acs->
fill_y;
1663 if (this->inf->
resize_x > 0 && (this->resize_x == 0 || this->resize_x > this->inf->resize_x)) this->resize_x = this->inf->
resize_x;
1665 this->resize_y = this->avs->
resize_y;
1666 if (this->acs->
resize_y > 0 && (this->resize_y == 0 || this->resize_y > this->acs->resize_y)) this->resize_y = this->acs->
resize_y;
1670 this->smallest_y =
ComputeMaxSize(min_acs_height, this->smallest_y + this->resize_y - 1, this->resize_y);
1675 this->StoreSizePosition(sizing, x, y, given_width, given_height);
1681 uint min_list_width =
max(min_avs_width, min_acs_width);
1682 uint avs_extra_width = min_list_width - min_avs_width;
1683 uint acs_extra_width = min_list_width - min_acs_width;
1686 uint min_three_columns = min_avs_width + min_acs_width + min_inf_width + 2 * INTER_COLUMN_SPACING;
1687 uint min_two_columns = min_list_width + min_inf_width + INTER_COLUMN_SPACING;
1688 bool use_three_columns = this->editable && (min_three_columns + MIN_EXTRA_FOR_3_COLUMNS <= given_width);
1691 uint extra_width, inf_width;
1692 if (use_three_columns) {
1693 extra_width = given_width - min_three_columns;
1694 inf_width =
min(MAX_EXTRA_INFO_WIDTH, extra_width / 2);
1696 extra_width = given_width - min_two_columns;
1697 inf_width =
min(MAX_EXTRA_INFO_WIDTH, extra_width / 2);
1699 inf_width =
ComputeMaxSize(this->inf->
smallest_x, this->inf->smallest_x + inf_width, this->inf->GetHorizontalStepSize(sizing));
1700 extra_width -= inf_width - this->inf->
smallest_x;
1704 if (use_three_columns) {
1707 uint avs_width =
min(avs_extra_width, extra_width);
1708 extra_width -= avs_width;
1709 extra_width -=
min(acs_extra_width, extra_width);
1710 avs_width += extra_width / 2;
1712 avs_width =
ComputeMaxSize(this->avs->
smallest_x, this->avs->smallest_x + avs_width, this->avs->GetHorizontalStepSize(sizing));
1714 uint acs_width = given_width -
1728 x += inf_width + this->inf->
padding_right + INTER_COLUMN_SPACING;
1732 x += avs_width + this->avs->
padding_right + INTER_COLUMN_SPACING;
1737 x += acs_width + this->acs->
padding_right + INTER_COLUMN_SPACING;
1750 this->avs->GetHorizontalStepSize(sizing));
1752 this->acs->GetHorizontalStepSize(sizing));
1754 uint min_avs_height = (!this->
editable) ? 0 : this->avs->
smallest_y + this->avs->padding_top + this->avs->padding_bottom + INTER_LIST_SPACING;
1755 uint min_acs_height = this->acs->smallest_y + this->acs->padding_top + this->acs->padding_bottom;
1756 uint extra_height = given_height - min_acs_height - min_avs_height;
1759 uint avs_height =
ComputeMaxSize(this->avs->
smallest_y, this->avs->smallest_y + extra_height / 2, this->avs->resize_y);
1760 if (this->editable) extra_height -= avs_height - this->avs->
smallest_y;
1761 uint acs_height =
ComputeMaxSize(this->acs->
smallest_y, this->acs->smallest_y + extra_height, this->acs->resize_y);
1767 x += inf_width + this->inf->
padding_right + INTER_COLUMN_SPACING;
1770 if (this->editable) {
1771 this->avs->
AssignSizePosition(sizing, x + this->avs->
padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
1777 if (this->editable) {
1778 this->avs->
AssignSizePosition(sizing, x + this->avs->
padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
1783 if (this->editable) {
1784 dx =
max(dx, this->avs->
current_x + this->avs->padding_left + this->avs->padding_right);
1786 x += dx + INTER_COLUMN_SPACING + this->inf->
padding_left;
1794 if (!
IsInsideBS(x, this->pos_x, this->current_x) || !
IsInsideBS(y, this->pos_y, this->current_y))
return NULL;
1804 if (this->editable) this->avs->
Draw(w);
1815 static const NWidgetPart _nested_newgrf_actives_widgets[] = {
1821 SetDataTip(STR_JUST_STRING, STR_NEWGRF_SETTINGS_PRESET_LIST_TOOLTIP),
1825 SetDataTip(STR_NEWGRF_SETTINGS_PRESET_SAVE, STR_NEWGRF_SETTINGS_PRESET_SAVE_TOOLTIP),
1827 SetDataTip(STR_NEWGRF_SETTINGS_PRESET_DELETE, STR_NEWGRF_SETTINGS_PRESET_DELETE_TOOLTIP),
1847 SetDataTip(STR_NEWGRF_SETTINGS_REMOVE, STR_NEWGRF_SETTINGS_REMOVE_TOOLTIP),
1850 SetDataTip(STR_NEWGRF_SETTINGS_MOVEUP, STR_NEWGRF_SETTINGS_MOVEUP_TOOLTIP),
1852 SetDataTip(STR_NEWGRF_SETTINGS_MOVEDOWN, STR_NEWGRF_SETTINGS_MOVEDOWN_TOOLTIP),
1855 SetDataTip(STR_NEWGRF_SETTINGS_UPGRADE, STR_NEWGRF_SETTINGS_UPGRADE_TOOLTIP),
1860 SetDataTip(STR_NEWGRF_SETTINGS_RESCAN_FILES, STR_NEWGRF_SETTINGS_RESCAN_FILES_TOOLTIP),
1862 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
1868 static const NWidgetPart _nested_newgrf_availables_widgets[] = {
1877 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1891 SetDataTip(STR_NEWGRF_SETTINGS_ADD, STR_NEWGRF_SETTINGS_ADD_FILE_TOOLTIP),
1894 SetDataTip(STR_NEWGRF_SETTINGS_RESCAN_FILES, STR_NEWGRF_SETTINGS_RESCAN_FILES_TOOLTIP),
1896 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
1902 static const NWidgetPart _nested_newgrf_infopanel_widgets[] = {
1910 SetDataTip(STR_CONTENT_OPEN_URL, STR_CONTENT_OPEN_URL_TOOLTIP),
1912 SetDataTip(STR_TEXTFILE_VIEW_README, STR_NULL),
1915 SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_NULL),
1917 SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_NULL),
1925 SetDataTip(STR_NEWGRF_SETTINGS_SET_PARAMETERS, STR_NULL),
1927 SetDataTip(STR_NEWGRF_SETTINGS_TOGGLE_PALETTE, STR_NEWGRF_SETTINGS_TOGGLE_PALETTE_TOOLTIP),
1930 SetDataTip(STR_NEWGRF_SETTINGS_APPLY_CHANGES, STR_NULL),
1933 SetDataTip(STR_NEWGRF_SETTINGS_SHOW_PARAMETERS, STR_NULL),
1944 *biggest_index =
max(*biggest_index, biggest2);
1947 *biggest_index =
max(*biggest_index, biggest2);
1953 static const NWidgetPart _nested_newgrf_widgets[] = {
1974 _nested_newgrf_widgets,
lengthof(_nested_newgrf_widgets)
2000 for (c = nw->
actives; c != NULL && i > 0; c = c->
next, i--) {}
2024 new NewGRFWindow(&_newgrf_desc, editable, show_params, exec_changes, config);
2040 NWidget(
WWT_EDITBOX, COLOUR_GREY,
WID_SVP_EDITBOX),
SetPadding(3, 2, 2, 2),
SetFill(1, 0),
SetResize(1, 0),
2041 SetDataTip(STR_SAVE_PRESET_TITLE, STR_SAVE_PRESET_EDITBOX_TOOLTIP),
2055 _nested_save_preset_widgets,
lengthof(_nested_save_preset_widgets)
2072 this->selected = -1;
2073 if (initial_text != NULL) {
2074 for (uint i = 0; i < this->presets.
Length(); i++) {
2075 if (!strcmp(initial_text, this->presets[i])) {
2092 if (initial_text != NULL) this->presetname_editbox.text.
Assign(initial_text);
2105 for (uint i = 0; i < this->presets.
Length(); i++) {
2108 resize->height =
max(resize->height, d.height);
2110 size->height =
ClampU(this->presets.
Length(), 5, 20) * resize->height + 1;
2128 for (uint i = min_index; i < max_index; i++) {
2131 const char *text = this->presets[i];
2145 if (row < this->presets.
Length()) {
2146 this->selected = row;
2147 this->presetname_editbox.text.
Assign(this->presets[row]);
2202 _nested_scan_progress_widgets,
lengthof(_nested_scan_progress_widgets)
2252 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);
2275 free(this->last_name);
2278 GetString(buf, STR_NEWGRF_SCAN_ARCHIVES,
lastof(buf));
2279 this->last_name =
stredup(buf);
2281 this->last_name =
stredup(name);
2283 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.
bool Elapsed(uint delta)
Test if a timer has elapsed.
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.
GUITimer timeout
How long before we unpress the last-pressed button?
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.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
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.
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.
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.
virtual void OnRealtimeTick(uint delta_ms)
Called periodically.
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.