OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
47 if (_game_mode == GM_MENU)
return;
51 if (c->error ==
nullptr || (c->error->severity != STR_NEWGRF_ERROR_MSG_FATAL && c->error->severity != STR_NEWGRF_ERROR_MSG_ERROR))
continue;
53 SetDParam (0, c->error->message != STR_NULL ? c->error->message : STR_JUST_RAW_STRING);
57 for (uint i = 0; i <
lengthof(c->error->param_value); i++) {
58 SetDParam(4 + i, c->error->param_value[i]);
60 if (c->error->severity == STR_NEWGRF_ERROR_MSG_FATAL) {
69 static void ShowNewGRFInfo(
const GRFConfig *c, uint x, uint y, uint right, uint bottom,
bool show_params)
71 if (c->
error !=
nullptr) {
118 SetDParam(0, STR_NEWGRF_SETTINGS_PARAMETER_NONE);
208 d.width += padding.width;
209 d.height += padding.height;
225 for (uint i = 0; i < this->grf_config->
param_info.size(); i++) {
227 if (par_info ==
nullptr)
continue;
229 if (desc ==
nullptr)
continue;
232 suggestion =
maxdim(d, suggestion);
234 size->height = suggestion.height;
252 if (par_info ==
nullptr)
return;
254 if (desc ==
nullptr)
return;
272 uint32 current_value = par_info->
GetValue(this->grf_config);
276 DrawBoolButton(buttons_left, y + button_y_offset, current_value != 0, this->editable);
277 SetDParam(2, par_info->
GetValue(this->grf_config) == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
280 DrawDropDownButton(buttons_left, y + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && this->clicked_dropdown, this->editable);
282 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);
288 if (label !=
nullptr) {
296 if (name !=
nullptr) {
300 SetDParam(0, STR_NEWGRF_PARAMETERS_DEFAULT_NAME);
304 DrawString(text_left, text_right, y + text_y_offset, STR_NEWGRF_PARAMETERS_SETTING, selected ? TC_WHITE : TC_LIGHT_BLUE);
311 if (this->closing_dropdown) {
312 this->closing_dropdown =
false;
313 this->clicked_dropdown =
false;
322 if (this->editable && !this->action14present && this->grf_config->
num_params > 0) {
340 if (!this->editable)
break;
342 if (num >= this->vscroll->
GetCount())
break;
343 if (this->clicked_row != num) {
346 this->clicked_row = num;
347 this->clicked_dropdown =
false;
351 int x = pt.x - wid->
pos_x;
359 uint32 old_val = par_info->
GetValue(this->grf_config);
361 if (this->clicked_dropdown) {
364 this->clicked_dropdown =
false;
365 this->closing_dropdown =
false;
377 if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
378 this->clicked_dropdown =
true;
379 this->closing_dropdown =
false;
382 for (uint32 i = par_info->
min_value; i <= par_info->max_value; i++) {
390 uint32 val = old_val;
396 if (val < par_info->max_value) val++;
397 this->clicked_increase =
true;
401 this->clicked_increase =
false;
404 if (val != old_val) {
405 par_info->
SetValue(this->grf_config, val);
407 this->clicked_button = num;
408 this->timeout.SetInterval(150);
420 if (!this->editable)
break;
435 int32 value = atoi(str);
439 par_info->
SetValue(this->grf_config, val);
445 assert(this->clicked_dropdown);
448 par_info->
SetValue(this->grf_config, index);
458 assert(this->clicked_dropdown);
459 this->closing_dropdown =
true;
475 if (!gui_scope)
return;
476 if (!this->action14present) {
482 if (this->clicked_row != UINT_MAX && this->clicked_row >= this->vscroll->
GetCount()) {
483 this->clicked_row = UINT_MAX;
491 this->clicked_button = UINT_MAX;
499 static const NWidgetPart _nested_newgrf_parameter_widgets[] = {
510 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),
515 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),
533 WDP_CENTER,
"settings_newgrf_config", 500, 208,
536 _nested_newgrf_parameter_widgets,
lengthof(_nested_newgrf_parameter_widgets)
539 static void OpenGRFParameterWindow(
GRFConfig *c,
bool editable)
570 typedef std::map<uint32, const GRFConfig *>
GrfIdMap;
579 while (c !=
nullptr) {
580 std::pair<uint32, const GRFConfig *> p(c->
ident.
grfid, c);
581 grfid_map->insert(p);
595 static const uint EDITBOX_MAX_SIZE = 50;
626 this->avail_sel =
nullptr;
627 this->avail_pos = -1;
628 this->active_sel =
nullptr;
629 this->actives =
nullptr;
635 this->active_over = -1;
644 this->GetWidget<NWidgetStacked>(
WID_NS_SHOW_REMOVE)->SetDisplayedPlane(this->editable ? 0 : 1);
671 if (this->editable && this->modified && !this->execute && !_exit_game) {
696 GrfIdMap::const_iterator iter = grfid_map.find(a->ident.grfid);
697 if (iter != grfid_map.end() && a->version > iter->second->version)
return true;
709 GrfIdMap::iterator iter = grfid_map.find(a->ident.grfid);
710 if (iter == grfid_map.end() || iter->second->version >= a->version)
continue;
713 while (*c != iter->second) c = &(*c)->
next;
717 if (this->active_sel == *c) {
720 this->active_sel =
nullptr;
757 for (
const auto &i : this->grf_presets) {
761 d.width += padding.width;
770 size->width += padding.width;
771 size->height += padding.height;
787 if (this->preset == -1) {
810 pal = PALETTE_TO_RED;
813 pal = PALETTE_TO_GREEN;
816 pal = PALETTE_TO_BLUE;
821 if (pal != PALETTE_TO_RED) {
823 pal = PALETTE_TO_GREY;
825 pal = PALETTE_TO_ORANGE;
838 uint step_height = this->GetWidget<NWidgetBase>(
WID_NS_FILE_LIST)->resize_y;
842 int square_offset_y = (step_height - square.height) / 2;
843 int warning_offset_y = (step_height - warning.height) / 2;
849 uint square_left = rtl ? r.right - square.width - 5 : r.left + 5;
850 uint warning_left = rtl ? r.right - square.width - warning.width - 10 : r.left + square.width + 10;
853 for (
const GRFConfig *c = this->actives; c !=
nullptr; c = c->
next, i++) {
855 const char *text = c->
GetName();
856 bool h = (this->active_sel == c);
861 }
else if (i == this->active_over) {
863 int active_sel_pos = 0;
865 if (active_sel_pos != this->active_over) {
866 uint
top = this->active_over < active_sel_pos ? y + 1 : y + step_height - 2;
870 DrawSprite(SPR_SQUARE, pal, square_left, y + square_offset_y);
871 if (c->
error !=
nullptr)
DrawSprite(SPR_WARNING_SIGN, 0, warning_left, y + warning_offset_y);
872 uint txtoffset = c->
error ==
nullptr ? 0 : warning.width;
873 DrawString(text_left + (rtl ? 0 : txtoffset), text_right - (rtl ? txtoffset : 0), y + offset_y, text, h ? TC_WHITE : TC_ORANGE);
877 if (i == this->active_over && this->vscroll->
IsVisible(i)) {
890 uint max_index = std::min(min_index + this->vscroll2->
GetCapacity(), (uint)this->avails.size());
892 for (uint i = min_index; i < max_index; i++) {
895 const char *text = c->
GetName();
912 if (selected ==
nullptr) selected = this->
avail_sel;
913 if (selected !=
nullptr) {
924 if (this->active_sel ==
nullptr && this->avail_sel ==
nullptr)
return;
937 for (uint i = 0; i < this->grf_presets.size(); i++) {
947 const GRFConfig *c = (this->avail_sel ==
nullptr) ? this->active_sel : this->avail_sel;
949 extern void OpenBrowser(
const char *url);
959 if (this->preset == -1)
return;
969 if (this->active_sel ==
nullptr || !this->editable)
break;
972 for (
GRFConfig **pc = &this->actives; *pc !=
nullptr; pc = &(*pc)->
next, pos++) {
974 if (c->
next == this->active_sel) {
976 this->active_sel->
next = c;
988 if (this->active_sel ==
nullptr || !this->editable)
break;
991 for (
GRFConfig **pc = &this->actives; *pc !=
nullptr; pc = &(*pc)->
next, pos++) {
993 if (c == this->active_sel) {
1012 for (c = this->actives; c !=
nullptr && i > 0; c = c->
next, i--) {}
1014 if (this->active_sel != c) {
1018 this->active_sel = c;
1019 this->avail_sel =
nullptr;
1020 this->avail_pos = -1;
1023 if (click_count == 1) {
1032 if (this->active_sel ==
nullptr || !this->editable)
break;
1038 for (
GRFConfig **pc = &this->actives; *pc !=
nullptr; pc = &(*pc)->
next) {
1042 if (newsel ==
nullptr && c->
next == this->active_sel) newsel = c;
1044 if (c == this->active_sel) {
1045 if (newsel == c) newsel =
nullptr;
1053 this->active_sel = newsel;
1055 this->avail_pos = -1;
1056 this->avail_sel =
nullptr;
1063 if (!this->editable || this->actives ==
nullptr)
break;
1073 this->active_sel =
nullptr;
1075 if (i < this->
avails.size()) {
1077 this->avail_sel = this->avails[i];
1078 this->avail_pos = i;
1081 if (click_count == 1) {
1096 if (!this->editable)
break;
1097 if (this->execute) {
1099 STR_NEWGRF_POPUP_CAUTION_CAPTION,
1100 STR_NEWGRF_CONFIRMATION_TEXT,
1115 if (this->active_sel ==
nullptr || !this->show_params || this->active_sel->
num_valid_params == 0)
break;
1117 OpenGRFParameterWindow(this->active_sel, this->editable);
1123 if (this->active_sel !=
nullptr && this->editable) {
1151 this->avail_sel =
nullptr;
1152 this->avail_pos = -1;
1159 if (!this->editable)
return;
1162 this->preset = index;
1172 this->active_sel =
nullptr;
1178 if (str ==
nullptr)
return;
1184 for (uint i = 0; i < this->grf_presets.size(); i++) {
1185 if (this->grf_presets[i] == str) {
1201 for (
const GRFConfig *c = this->actives; c !=
nullptr; c = c->
next, i++) {}
1205 if (this->avail_pos >= 0) this->vscroll2->
ScrollTowards(this->avail_pos);
1215 if (!gui_scope)
return;
1223 for (
GRFConfig **l = &this->actives; *l !=
nullptr; l = &(*l)->
next) {
1232 (*l)->next = c->
next;
1234 if (this->active_sel == c) this->active_sel = *l;
1243 this->modified =
false;
1255 this->modified =
true;
1261 this->modified =
false;
1265 this->BuildAvailables();
1276 bool disable_all = this->active_sel ==
nullptr || !this->
editable;
1284 const GRFConfig *c = (this->avail_sel ==
nullptr) ? this->active_sel : this->avail_sel;
1285 for (
TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
1303 bool has_missing =
false;
1304 bool has_compatible =
false;
1305 for (
const GRFConfig *c = this->actives; !has_missing && c !=
nullptr; c = c->
next) {
1311 if (has_missing || has_compatible) {
1312 widget_data = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON;
1313 tool_tip = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP;
1315 widget_data = STR_INTRO_ONLINE_CONTENT;
1316 tool_tip = STR_INTRO_TOOLTIP_ONLINE_CONTENT;
1332 if (this->avail_pos >= 0) {
1333 this->active_sel =
nullptr;
1336 this->avail_sel = this->avails[this->
avail_pos];
1346 if (!this->editable)
return;
1356 if (!this->editable)
return;
1359 if (this->active_sel !=
nullptr) {
1363 for (from_prev = &this->actives; *from_prev != this->
active_sel; from_prev = &(*from_prev)->
next, from_pos++) {}
1367 if (to_pos != from_pos) {
1370 for (
int i = from_pos < to_pos ? -1 : 0; *to_prev !=
nullptr && i < to_pos; to_prev = &(*to_prev)->
next, i++) {}
1373 *from_prev = this->active_sel->
next;
1376 this->active_sel->
next = *to_prev;
1383 }
else if (this->avail_sel !=
nullptr) {
1389 Point dummy = {-1, -1};
1395 if (this->active_over != -1) {
1398 this->active_over = -1;
1404 if (!this->editable)
return;
1406 if (widget ==
WID_NS_FILE_LIST && (this->active_sel !=
nullptr || this->avail_sel !=
nullptr)) {
1410 to_pos = std::min(to_pos, this->vscroll->
GetCount() - (this->active_sel !=
nullptr ? 2 : 1));
1412 if (to_pos != this->active_over) {
1413 this->active_over = to_pos;
1417 this->active_over = -2;
1419 }
else if (this->active_over != -1) {
1421 this->active_over = -1;
1430 if (i != 0)
return i < 0;
1433 if (i != 0)
return i < 0;
1442 filter.
AddLine((*a)->GetName());
1443 filter.
AddLine((*a)->filename);
1444 filter.
AddLine((*a)->GetDescription());
1448 void BuildAvailables()
1452 this->avails.clear();
1457 if (found)
continue;
1460 this->avails.push_back(c);
1471 this->avails.push_back(c);
1476 this->avails.
Filter(this->string_filter);
1477 this->avails.shrink_to_fit();
1479 this->avails.
Sort();
1481 if (this->avail_sel !=
nullptr) {
1482 this->avail_pos =
find_index(this->avails, this->avail_sel);
1483 if (this->avail_pos == -1) {
1484 this->avail_sel =
nullptr;
1488 this->vscroll2->
SetCount((uint)this->avails.size());
1498 if (this->avail_sel ==
nullptr || !this->editable ||
HasBit(this->avail_sel->
flags,
GCF_INVALID))
return false;
1506 for (list = &this->actives; *list !=
nullptr; list = &(*list)->
next, ins_pos--) {
1507 if (ins_pos == 0) entry = list;
1508 if ((*list)->ident.grfid == this->avail_sel->ident.grfid) {
1514 if (entry ==
nullptr) entry = list;
1528 int new_pos = this->avail_pos + 1;
1529 if (new_pos >= (
int)this->avails.size()) new_pos = this->avail_pos - 1;
1530 this->avail_pos = new_pos;
1531 if (new_pos >= 0) this->avail_sel = this->avails[new_pos];
1547 for (
const GRFConfig *c = list; c !=
nullptr; c = c->
next) {
1596 this->
Add(this->avs);
1597 this->
Add(this->acs);
1598 this->
Add(this->inf);
1600 this->editable =
true;
1628 if (this->inf->
fill_x > 0 && (this->fill_x == 0 || this->fill_x > this->inf->fill_x)) this->
fill_x = this->inf->
fill_x;
1631 if (this->acs->
fill_y > 0 && (this->fill_y == 0 || this->fill_y > this->acs->fill_y)) this->
fill_y = this->acs->
fill_y;
1636 if (this->inf->
resize_x > 0 && (this->resize_x == 0 || this->resize_x > this->inf->resize_x)) this->
resize_x = this->inf->
resize_x;
1639 if (this->acs->
resize_y > 0 && (this->resize_y == 0 || this->resize_y > this->acs->resize_y)) this->
resize_y = this->acs->
resize_y;
1654 uint min_list_width = std::max(min_avs_width, min_acs_width);
1655 uint avs_extra_width = min_list_width - min_avs_width;
1656 uint acs_extra_width = min_list_width - min_acs_width;
1659 uint min_three_columns = min_avs_width + min_acs_width + min_inf_width + 2 *
INTER_COLUMN_SPACING;
1664 uint extra_width, inf_width;
1665 if (use_three_columns) {
1666 extra_width = given_width - min_three_columns;
1669 extra_width = given_width - min_two_columns;
1672 inf_width =
ComputeMaxSize(this->inf->
smallest_x, this->inf->smallest_x + inf_width, this->inf->GetHorizontalStepSize(sizing));
1673 extra_width -= inf_width - this->inf->
smallest_x;
1677 if (use_three_columns) {
1680 uint avs_width = std::min(avs_extra_width, extra_width);
1681 extra_width -= avs_width;
1682 extra_width -= std::min(acs_extra_width, extra_width);
1683 avs_width += extra_width / 2;
1685 avs_width =
ComputeMaxSize(this->avs->
smallest_x, this->avs->smallest_x + avs_width, this->avs->GetHorizontalStepSize(sizing));
1687 uint acs_width = given_width -
1723 this->avs->GetHorizontalStepSize(sizing));
1725 this->acs->GetHorizontalStepSize(sizing));
1728 uint min_acs_height = this->acs->smallest_y + this->acs->padding_top + this->acs->padding_bottom;
1729 uint extra_height = given_height - min_acs_height - min_avs_height;
1732 uint avs_height =
ComputeMaxSize(this->avs->
smallest_y, this->avs->smallest_y + extra_height / 2, this->avs->resize_y);
1733 if (this->editable) extra_height -= avs_height - this->avs->
smallest_y;
1734 uint acs_height =
ComputeMaxSize(this->acs->
smallest_y, this->acs->smallest_y + extra_height, this->acs->resize_y);
1743 if (this->editable) {
1744 this->avs->
AssignSizePosition(sizing, x + this->avs->
padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
1750 if (this->editable) {
1751 this->avs->
AssignSizePosition(sizing, x + this->avs->
padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
1756 if (this->editable) {
1757 dx = std::max(dx, this->avs->
current_x + this->avs->padding_left + this->avs->padding_right);
1777 if (this->editable) this->avs->
Draw(w);
1788 static const NWidgetPart _nested_newgrf_actives_widgets[] = {
1794 SetDataTip(STR_JUST_STRING, STR_NEWGRF_SETTINGS_PRESET_LIST_TOOLTIP),
1798 SetDataTip(STR_NEWGRF_SETTINGS_PRESET_SAVE, STR_NEWGRF_SETTINGS_PRESET_SAVE_TOOLTIP),
1800 SetDataTip(STR_NEWGRF_SETTINGS_PRESET_DELETE, STR_NEWGRF_SETTINGS_PRESET_DELETE_TOOLTIP),
1820 SetDataTip(STR_NEWGRF_SETTINGS_REMOVE, STR_NEWGRF_SETTINGS_REMOVE_TOOLTIP),
1823 SetDataTip(STR_NEWGRF_SETTINGS_MOVEUP, STR_NEWGRF_SETTINGS_MOVEUP_TOOLTIP),
1825 SetDataTip(STR_NEWGRF_SETTINGS_MOVEDOWN, STR_NEWGRF_SETTINGS_MOVEDOWN_TOOLTIP),
1828 SetDataTip(STR_NEWGRF_SETTINGS_UPGRADE, STR_NEWGRF_SETTINGS_UPGRADE_TOOLTIP),
1833 SetDataTip(STR_NEWGRF_SETTINGS_RESCAN_FILES, STR_NEWGRF_SETTINGS_RESCAN_FILES_TOOLTIP),
1835 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
1841 static const NWidgetPart _nested_newgrf_availables_widgets[] = {
1850 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1864 SetDataTip(STR_NEWGRF_SETTINGS_ADD, STR_NEWGRF_SETTINGS_ADD_FILE_TOOLTIP),
1867 SetDataTip(STR_NEWGRF_SETTINGS_RESCAN_FILES, STR_NEWGRF_SETTINGS_RESCAN_FILES_TOOLTIP),
1869 SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
1875 static const NWidgetPart _nested_newgrf_infopanel_widgets[] = {
1883 SetDataTip(STR_CONTENT_OPEN_URL, STR_CONTENT_OPEN_URL_TOOLTIP),
1885 SetDataTip(STR_TEXTFILE_VIEW_README, STR_NULL),
1888 SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_NULL),
1890 SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_NULL),
1898 SetDataTip(STR_NEWGRF_SETTINGS_SET_PARAMETERS, STR_NULL),
1900 SetDataTip(STR_NEWGRF_SETTINGS_TOGGLE_PALETTE, STR_NEWGRF_SETTINGS_TOGGLE_PALETTE_TOOLTIP),
1903 SetDataTip(STR_NEWGRF_SETTINGS_APPLY_CHANGES, STR_NULL),
1906 SetDataTip(STR_NEWGRF_SETTINGS_SHOW_PARAMETERS, STR_NULL),
1917 *biggest_index = std::max(*biggest_index, biggest2);
1920 *biggest_index = std::max(*biggest_index, biggest2);
1926 static const NWidgetPart _nested_newgrf_widgets[] = {
1947 _nested_newgrf_widgets,
lengthof(_nested_newgrf_widgets)
1973 for (c = nw->
actives; c !=
nullptr && i > 0; c = c->
next, i--) {}
1998 new NewGRFWindow(&_newgrf_desc, editable, show_params, exec_changes, config);
2014 NWidget(
WWT_EDITBOX, COLOUR_GREY,
WID_SVP_EDITBOX),
SetPadding(3, 2, 2, 2),
SetFill(1, 0),
SetResize(1, 0),
2015 SetDataTip(STR_SAVE_PRESET_TITLE, STR_SAVE_PRESET_EDITBOX_TOOLTIP),
2046 this->selected = -1;
2047 if (initial_text !=
nullptr) {
2048 for (uint i = 0; i < this->presets.size(); i++) {
2049 if (this->presets[i] == initial_text) {
2064 this->vscroll->
SetCount((uint)this->presets.size());
2066 if (initial_text !=
nullptr) this->presetname_editbox.text.
Assign(initial_text);
2079 for (uint i = 0; i < this->presets.size(); i++) {
2084 size->height =
ClampU((uint)this->presets.size(), 5, 20) *
resize->height + 1;
2100 uint max_index = std::min(min_index + this->vscroll->
GetCapacity(), (uint)this->presets.size());
2102 for (uint i = min_index; i < max_index; i++) {
2105 const char *text = this->presets[i].c_str();
2119 if (row < this->
presets.size()) {
2120 this->selected = row;
2121 this->presetname_editbox.text.
Assign(this->presets[row].c_str());
2226 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);
2249 free(this->last_name);
2250 if (name ==
nullptr) {
2252 GetString(buf, STR_NEWGRF_SCAN_ARCHIVES,
lastof(buf));
2253 this->last_name =
stredup(buf);
2255 this->last_name =
stredup(name);
2257 this->scanned = num;
uint32 version
NOSAVE: Version a NewGRF can set so only the newest NewGRF is shown.
void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
A dropdown window associated to this window has been closed.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
@ ES_HANDLED
The passed event is handled.
@ GRFP_USE_MASK
Bitmask to get only the use palette use states.
bool AddGRFToActive(int ins_pos=-1)
Insert a GRF into the active list.
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.
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
uint8 num_valid_params
NOSAVE: Number of valid parameters (action 0x14)
~ScanProgressWindow()
Free the last name buffer.
std::string name
Name of the content.
StringFilter string_filter
Filter for available grf.
bool HasGrfIdentifier(uint32 grfid, const uint8 *md5sum) const
Does the identification match the provided values?
virtual void LoadTextfile(const char *textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
int ok_button
Widget button of parent window to simulate when pressing OK in OSK.
ContentType type
Type of content.
GRFError * error
NOSAVE: Error/Warning during GRF loading (Action 0x0B)
@ GOID_NEWGRF_CHANGES_MADE
Changes have been made to a given NewGRF either through the palette or its parameters.
char32_t WChar
Type for wide characters, i.e.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
Window for showing the progress of NewGRF scanning.
bool newgrf_developer_tools
activate NewGRF developer tools and allow modifying NewGRFs in an existing game
void OnNewGRFsScanned() override
Called whenever the NewGRF scan completed.
EventState OnKeyPress(WChar key, uint16 keycode) override
A key has been pressed.
Dimensions (a width and height) of a rectangle in 2D.
static GRFParameterInfo * GetDummyParameterInfo(uint nr)
Get a dummy parameter-info object with default information.
std::string custom_message
Custom message (if present)
const GRFConfig * FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8 *md5sum, uint32 desired_version)
Find a NewGRF in the scanned list.
@ GCS_ACTIVATED
GRF file has been activated.
bool Sort(Comp compare)
Sort the list.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
void ClearGRFConfigList(GRFConfig **config)
Clear a GRF Config list, freeing all nodes.
bool IsEmpty() const
Check whether any filter words were entered.
@ DOES_NOT_EXIST
The content does not exist in the content system.
void SetFilterTerm(const char *str)
Set the term to filter on.
@ WD_MATRIX_TOP
Offset at top of a matrix cell.
Class for the save preset window.
void UpdateNewGRFScanStatus(uint num, const char *name)
Update the NewGRF scan status.
static void ShowSavePresetWindow(const char *initial_text)
Open the window for saving a preset.
uint8 num_params
Number of used parameters.
void Assign(StringID string)
Render a string into the textbuffer.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
std::map< uint32, const GRFConfig * > GrfIdMap
Map of grfid to the grf config.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
GRFConfig * _all_grfs
First item in list of all scanned NewGRFs.
List item containing a C char string.
void ShowNetworkContentListWindow(ContentVector *cv=nullptr, ContentType type1=CONTENT_TYPE_END, ContentType type2=CONTENT_TYPE_END)
Show the content list window with a given set of content.
Window for showing NewGRF files.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
static const NWidgetPart _nested_save_preset_widgets[]
Widget parts of the save preset window.
@ CONTENT_TYPE_NEWGRF
The content consists of a NewGRF.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
static uint ClampU(const uint a, const uint min, const uint max)
Clamp an unsigned integer between an interval.
std::vector< ContentInfo * > ContentVector
Vector with content info.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
void ShowMissingContentWindow(const GRFConfig *list)
Show the content list window with all missing grfs from the given list.
SavePresetWindow(const char *initial_text)
Constructor of the save preset window.
void SetValue(struct GRFConfig *config, uint32 value)
Set the value of this user-changeable parameter in the given config.
byte param_nr
GRF parameter to store content in.
static GUIGRFConfigList::FilterFunction *const filter_funcs[]
Filter functions of the #GUIGRFConfigList.
bool modified
The list of active NewGRFs has been modified since the last time they got saved.
StringID severity
Info / Warning / Error / Fatal.
GRFConfig * actives
Temporary active grf list to which changes are made.
bool RequestNewGRFScan(NewGRFScanCallback *callback)
Request a new NewGRF scan.
@ GCS_NOT_FOUND
GRF file was not found in the local cache.
ScanProgressWindow()
Create the window.
@ WD_FRAMETEXT_TOP
Top offset of the text of the frame.
static GUIGRFConfigList::SortFunction *const sorter_funcs[]
Sort functions of the #GUIGRFConfigList.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
GRFIdentifier ident
grfid and md5sum to uniquely identify newgrfs
ClientSettings _settings_client
The current settings for this game.
bool editable
Allow editing parameters.
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.
NWidgetBase * NewGRFDisplay(int *biggest_index)
Construct nested container widget for managing the lists and the info panel of the NewGRF GUI.
GRFStatus status
NOSAVE: GRFStatus, enum.
@ GRFP_GRF_UNSET
The NewGRF provided no information.
void AddLine(const char *str)
Pass another text line from the current item to the filter.
bool execute
On pressing 'apply changes' are grf changes applied immediately, or only list is updated.
static bool NameSorter(const GRFConfig *const &a, const GRFConfig *const &b)
Sort grfs by name.
int preset
Selected preset or -1 if none selected.
GRFParameterType type
The type of this parameter.
bool clicked_dropdown
Whether the dropdown is open.
@ WD_FRAMETEXT_LEFT
Left offset of the text of the frame.
TextfileType file_type
Type of textfile to view.
@ TFT_CHANGELOG
NewGRF changelog.
uint8 md5sum[16]
MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF)
@ WN_GAME_OPTIONS_NEWGRF_STATE
NewGRF settings.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
GRFConfig * active_sel
Selected active grf item.
Data stored about a string that can be modified in the GUI.
@ WC_GRF_PARAMETERS
NewGRF parameters; Window numbers:
int active_over
Active GRF item over which another one is dragged, -1 if none.
@ WC_SAVE_PRESET
Save preset; Window numbers:
uint32 grfid
GRF ID (defined by Action 0x08)
uint32 GetValue(struct GRFConfig *config) const
Get the value of this user-changeable parameter from the given config.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
@ GCF_COMPATIBLE
GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches)
char *const buf
buffer in which text is saved
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=nullptr, uint textref_stack_size=0, const uint32 *textref_stack=nullptr)
Display an error message in a window.
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.
@ GCF_INVALID
GRF is unusable with this version of OpenTTD.
void OnPaint() override
The window must be repainted.
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
bool clicked_increase
True if the increase button was clicked, false for the decrease button.
int selected
Selected entry in the preset list, or -1 if none selected.
High level window description.
char * GRFBuildParamList(char *dst, const GRFConfig *c, const char *last)
Build a string containing space separated parameter values, and terminate.
@ WC_MODAL_PROGRESS
Progress report of landscape generation; Window numbers:
void OnMouseDrag(Point pt, int widget) override
An 'object' is being dragged at the provided position, highlight the target if possible.
static const uint NETWORK_MAX_GRF_COUNT
Maximum number of GRFs that can be sent.
StringList GetGRFPresetList()
Get the list of known NewGrf presets.
@ WC_QUERY_STRING
Query string window; Window numbers:
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
Draw a dropdown button.
Data structure describing how to show the list (what sort direction and criteria).
void SetFilterState(bool state)
Enable or disable the filter.
bool CanUpgradeCurrent()
Test whether the currently active set of NewGRFs can be upgraded with the available NewGRFs.
ResizeInfo resize
Resize information.
@ GOID_NEWGRF_CURRENT_LOADED
The current list of active NewGRF has been loaded.
void UpdateNewGRFScanStatus(uint num, const char *name)
Update the NewGRF scan status.
void UpdateScrollBars()
Updates the scroll bars for the active and inactive NewGRF lists.
Information about GRF, used in the game and (part of it) in savegames.
void OnRealtimeTick(uint delta_ms) override
Called periodically.
static Listing last_sorting
Default sorting of #GUIGRFConfigList.
static const NWidgetPart _nested_scan_progress_widgets[]
Widgets for the progress window.
Window for setting the parameters of a NewGRF.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
void ReInitAllWindows(bool zoom_changed)
Re-initialize all windows.
@ GOID_NEWGRF_LIST_EDITED
List of active NewGRFs is being edited.
bool SortFunction(const const GRFConfig * &, const const GRFConfig * &)
Signature of sort function.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
void SetParameterDefaults()
Set the default value for all parameters as specified by action14.
void SetListing(Listing l)
Import sort conditions.
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
uint8 flags
NOSAVE: GCF_Flags, bitset.
Container for all important information about a piece of content.
@ GRFP_USE_WINDOWS
The palette state is set to use the Windows palette.
static void FillGrfidMap(const GRFConfig *c, GrfIdMap *grfid_map)
Add all grf configs from c into the map.
static bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
int find_index(std::vector< T > const &vec, T const &item)
Helper function to get the index of an item Consider using std::set, std::unordered_set or std::flat_...
@ ES_NOT_HANDLED
The passed event is not handled.
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
GRFConfig ** CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only)
Copy a GRF Config list.
const char * GetGRFStringFromGRFText(const GRFTextList &text_list)
Get a C-string from a GRFText-list.
@ WD_FRAMETEXT_BOTTOM
Bottom offset of the text of the frame.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
byte md5sum[16]
The MD5 checksum.
void ShowNewGRFError()
Show the first NewGRF error we can find.
const char * GetTextfile(TextfileType type) const
Search a textfile file next to this NewGRF.
Data structure describing what to show in the list (filter criteria).
void GamelogStartAction(GamelogActionType at)
Stores information about new action, but doesn't allocate it Action is allocated only when there is a...
Information about one grf parameter.
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
std::vector< std::string > StringList
Type for a list of strings.
void UpgradeCurrent()
Upgrade the currently active set of NewGRFs.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void OnEditboxChanged(int wid) override
The text in an editbox has been edited.
@ GOID_NEWGRF_CHANGES_APPLIED
The active NewGRF list changes have been applied.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
@ GRFP_BLT_32BPP
The NewGRF prefers a 32 bpp blitter.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
@ WDF_MODAL
The window is a modal child of some other window, meaning the parent is 'inactive'.
void DeleteGRFPresetFromConfig(const char *config_name)
Delete a NewGRF configuration by preset name.
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
Calculate string bounding box for multi-line strings.
Coordinates of a point in 2D.
static void NewGRFConfirmationCallback(Window *w, bool confirmed)
Callback function for the newgrf 'apply changes' confirmation window.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
const char * GetURL() const
Get the grf url.
@ GRFP_GRF_MASK
Bitmask to get only the NewGRF supplied information.
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
@ WD_FRAMETEXT_RIGHT
Right offset of the text of the frame.
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
static const uint8 PC_BLACK
Black palette colour.
void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
Draw [<][>] boxes.
void CopyParams(const GRFConfig &src)
Copy the parameter information from the src config.
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.
@ TFT_README
NewGRF readme.
static uint32 BSWAP32(uint32 x)
Perform a 32 bits endianness bitswap on x.
GRFConfig ** orig_list
List active grfs in the game. Used as initial value, may be updated by the window.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
@ NEWGRF_DIR
Subdirectory for all NewGRFs.
static bool CDECL TagNameFilter(const GRFConfig *const *a, StringFilter &filter)
Filter grfs by tags/name.
QueryString presetname_editbox
Edit box of the save preset.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
int scanned
The number of NewGRFs that we have seen.
@ SA_HOR_CENTER
Horizontally center the text.
void GamelogStopAction()
Stops logging of any changes.
static const uint8 PC_GREY
Grey palette colour.
GRFConfig * LoadGRFPresetFromConfig(const char *config_name)
Load a NewGRF configuration by preset-name.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
@ HT_DRAG
dragging items in the depot windows
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
bool newgrf_show_old_versions
whether to show old versions in the NewGRF list
bool NeedRebuild() const
Check if a rebuild is needed.
@ TFT_LICENSE
NewGRF license.
QueryString filter_editbox
Filter editbox;.
@ GCS_DISABLED
GRF file is disabled.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
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 cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
uint32 max_value
The maximal value of this parameter.
StringID message
Default message.
@ WC_GAME_OPTIONS
Game options window; Window numbers:
int line_height
Height of a row in the matrix widget.
void OnResize() override
Called after the window got resized.
SmallMap< uint32, GRFTextList > value_names
Names for each value.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
const GRFConfig * avail_sel
Currently selected available grf. nullptr is none is selected.
GRFTextList desc
The description of this parameter.
int HideDropDownMenu(Window *pw)
Delete the drop-down menu from window pw.
bool closing_dropdown
True, if the dropdown list is currently closing.
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
void CloseChildWindows(WindowClass wc=WC_INVALID) const
Close all children a window might have in a head-recursive manner.
uint32 min_loadable_version
NOSAVE: Minimum compatible version a NewGRF can define.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
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.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
const char * GetDescription() const
Get the grf info.
uint8 original_md5sum[16]
MD5 checksum of original file if only a 'compatible' file was loaded.
static const uint8 PC_DARK_BLUE
Dark blue palette colour.
bool CDECL FilterFunction(const const GRFConfig * *, StringFilter &)
Signature of filter function.
uint32 PaletteID
The number of the palette.
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.
void CloseWindowByClass(WindowClass cls)
Close all windows of a given class.
StringList grf_presets
List of known NewGRF presets.
@ GOID_NEWGRF_RESCANNED
NewGRFs were just rescanned.
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
struct GRFConfig * next
NOSAVE: Next item in the linked list.
void ResetState()
Reset the matching state to process a new item.
GUITimer timeout
How long before we unpress the last-pressed button?
void GamelogGRFUpdate(const GRFConfig *oldc, const GRFConfig *newc)
Compares two NewGRF lists and logs any change.
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
EventState
State of handling an event.
@ FGCM_NEWEST
Find newest Grf.
@ FGCM_NEWEST_VALID
Find newest Grf, ignoring Grfs with GCF_INVALID set.
GRFTextList name
The name of this parameter.
void SetFiltering(Filtering f)
Import filter conditions.
Window * FindWindowByClass(WindowClass cls)
Find any window by its class.
bool show_params
Are the grf-parameters shown in the info-panel?
bool GetState() const
Get the matching state of the current item.
bool action14present
True if action14 information is present.
@ WD_RESIZEBOX_WIDTH
Width of a resize box widget.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
@ WL_ERROR
Errors (eg. saving/loading failed)
static const int ACTION_CLEAR
Clear editbox.
int top
y position of top edge of the window
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
bool Elapsed(uint delta)
Test if a timer has elapsed.
uint8 palette
GRFPalette, bitset.
bool complete_labels
True if all values have a label.
GRFConfig * _grfconfig
First item in list of current GRF set up.
State state
Whether the content info is selected (for download)
const GRFConfig * grf_config
View the textfile of this GRFConfig.
std::vector< Pair >::const_iterator Find(const T &key) const
Finds given key in this map.
uint32 unique_id
Unique ID; either GRF ID or shortname.
@ WD_MATRIX_BOTTOM
Offset at bottom of a matrix cell.
void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width, bool instant_close)
Show a drop down list.
void ForceRebuild()
Force that a rebuild is needed.
Callback for NewGRF scanning.
#define lengthof(x)
Return the length of an fixed size array.
int width
width of the window (number of pixels to the right in x direction)
static WindowDesc _scan_progress_desc(WDP_CENTER, nullptr, 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.
@ WC_BUILD_OBJECT
Build object; Window numbers:
static Filtering last_filtering
Default filtering of #GUIGRFConfigList.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
bool editable
Is the window editable?
@ PTYPE_BOOL
The parameter is either 0 or 1.
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...
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
bool scenario_developer
activate scenario developer: allow modifying NewGRFs in an existing game
Window for displaying a textfile.
void OnDragDrop(Point pt, int widget) override
A dragged 'object' has been released.
GRFConfig * grf_config
Set the parameters of this GRFConfig.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
uint32 last_newgrf_count
the numbers of NewGRFs we found during the last scan
@ PTYPE_UINT_ENUM
The parameter allows a range of numbers, each of which can have a special name.
Data structure for an opened window.
void RebuildDone()
Notify the sortlist that the rebuild is done.
TextfileType
Additional text files accompanying Tar archives.
char * md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
Convert the md5sum to a hexadecimal string representation.
void ResetGRFConfig(bool defaults)
Reset the current GRF Config to either blank or newgame settings.
void DrawWidgets() const
Paint all widgets of a window.
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
@ FGCM_EXACT
Only find Grfs matching md5sum.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
static const uint8 PC_DARK_GREY
Dark grey palette colour.
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
char * filename
Filename - either with or without full path.
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
bool _network_available
is network mode available?
Window for displaying the textfile of a NewGRF.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
uint clicked_button
The row in which a button was clicked or UINT_MAX.
PaletteID GetPalette(const GRFConfig *c) const
Pick the palette for the sprite of the grf to display.
Specification of a rectangle with absolute coordinates of all edges.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
void OnResize() override
Called after the window got resized.
int avail_pos
Index of avail_sel if existing, else -1.
uint32 param_value[2]
Values of GRF parameters to show for message and custom_message.
void DisableWidget(byte widget_index)
Sets a widget to disabled.
@ WC_TEXTFILE
textfile; Window numbers:
#define lastof(x)
Get the last element of an fixed size array.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
void SetDParamMaxDigits(uint n, uint count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
void SaveGRFPresetToConfig(const char *config_name, GRFConfig *config)
Save a NewGRF configuration with a preset name.
Scrollbar * vscroll
Pointer to the scrollbar widget.
@ WDP_CENTER
Center the window.
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
@ TD_RTL
Text is written right-to-left by default.
TextDirection _current_text_dir
Text direction of the currently selected language.
int LeastCommonMultiple(int a, int b)
Compute least common multiple (lcm) of arguments a and b, the smallest integer value that is a multip...
@ CS_NUMERAL
Only numeric ones.
@ WD_TEXTPANEL_BOTTOM
Offset at bottom to draw below the text.
StringList presets
Available presets.
uint clicked_row
The selected parameter.
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
void OnResize() override
Called after the window got resized.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
@ GCF_STATIC
GRF file is used statically (can be used in any MP game)
std::vector< GRFParameterInfo * > param_info
NOSAVE: extra information about the parameters.
GUISettings gui
settings related to the GUI
@ WL_CRITICAL
Critical errors, the MessageBox is shown in all cases.
uint32 param[0x80]
GRF parameters.
uint32 min_value
The minimal value this parameter can have.
@ FR_BORDERONLY
Draw border only, no background.
const char * GetName() const
Get the name of this grf.
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
@ WD_TEXTPANEL_TOP
Offset at top to draw above the text.
char * last_name
The name of the last 'seen' NewGRF.
std::string data
Additional data for message and custom_message.
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
GUIGRFConfigList avails
Available (non-active) grfs.
static GRFParameterInfo dummy_parameter_info
Dummy info in case a newgrf didn't provide info about some parameter.
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.
bool Contains(const T &key) const
Tests whether a key is assigned in this map.