OpenTTD Source: src/network/network_content_gui.cpp Source File

OpenTTD Source 1.11.0-RC1

network_content_gui.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #include "../stdafx.h"
11 #include "../strings_func.h"
12 #include "../gfx_func.h"
13 #include "../window_func.h"
14 #include "../error.h"
15 #include "../ai/ai.hpp"
16 #include "../game/game.hpp"
17 #include "../base_media_base.h"
18 #include "../openttd.h"
19 #include "../sortlist_type.h"
20 #include "../stringfilter_type.h"
21 #include "../querystring_gui.h"
22 #include "../core/geometry_func.hpp"
23 #include "../textfile_gui.h"
24 #include "network_content_gui.h"
25
26
27 #include "table/strings.h"
28 #include "../table/sprites.h"
29
30 #include <bitset>
31
32 #include "../safeguards.h"
33
34
36 static bool _accepted_external_search = false;
37
38
40 struct ContentTextfileWindow : public TextfileWindow {
41 const ContentInfo *ci;
42
43 ContentTextfileWindow(TextfileType file_type, const ContentInfo *ci) : TextfileWindow(file_type), ci(ci)
44 {
45 const char *textfile = this->ci->GetTextfile(file_type);
46 this->LoadTextfile(textfile, GetContentInfoSubDir(this->ci->type));
47 }
48
49 StringID GetTypeString() const
50 {
51 switch (this->ci->type) {
52 case CONTENT_TYPE_NEWGRF: return STR_CONTENT_TYPE_NEWGRF;
53 case CONTENT_TYPE_BASE_GRAPHICS: return STR_CONTENT_TYPE_BASE_GRAPHICS;
54 case CONTENT_TYPE_BASE_SOUNDS: return STR_CONTENT_TYPE_BASE_SOUNDS;
55 case CONTENT_TYPE_BASE_MUSIC: return STR_CONTENT_TYPE_BASE_MUSIC;
56 case CONTENT_TYPE_AI: return STR_CONTENT_TYPE_AI;
57 case CONTENT_TYPE_AI_LIBRARY: return STR_CONTENT_TYPE_AI_LIBRARY;
58 case CONTENT_TYPE_GAME: return STR_CONTENT_TYPE_GAME_SCRIPT;
59 case CONTENT_TYPE_GAME_LIBRARY: return STR_CONTENT_TYPE_GS_LIBRARY;
60 case CONTENT_TYPE_SCENARIO: return STR_CONTENT_TYPE_SCENARIO;
61 case CONTENT_TYPE_HEIGHTMAP: return STR_CONTENT_TYPE_HEIGHTMAP;
62 default: NOT_REACHED();
63 }
64 }
65
66 void SetStringParameters(int widget) const override
67 {
68 if (widget == WID_TF_CAPTION) {
69 SetDParam(0, this->GetTypeString());
70 SetDParamStr(1, this->ci->name);
71 }
72 }
73 };
74
75 void ShowContentTextfileWindow(TextfileType file_type, const ContentInfo *ci)
76 {
77 DeleteWindowById(WC_TEXTFILE, file_type);
78 new ContentTextfileWindow(file_type, ci);
79 }
80
82 static const NWidgetPart _nested_network_content_download_status_window_widgets[] = {
83 NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CONTENT_DOWNLOAD_TITLE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
84 NWidget(WWT_PANEL, COLOUR_GREY, WID_NCDS_BACKGROUND),
85 NWidget(NWID_SPACER), SetMinimalSize(350, 0), SetMinimalTextLines(3, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 30),
86 NWidget(NWID_HORIZONTAL),
87 NWidget(NWID_SPACER), SetMinimalSize(125, 0),
88 NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCDS_CANCELOK), SetMinimalSize(101, 12), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
89 NWidget(NWID_SPACER), SetFill(1, 0),
90 EndContainer(),
91 NWidget(NWID_SPACER), SetMinimalSize(0, 4),
92 EndContainer(),
93 };
94
96 static WindowDesc _network_content_download_status_window_desc(
97 WDP_CENTER, nullptr, 0, 0,
98 WC_NETWORK_STATUS_WINDOW, WC_NONE,
99 WDF_MODAL,
100 _nested_network_content_download_status_window_widgets, lengthof(_nested_network_content_download_status_window_widgets)
101 );
102
103 BaseNetworkContentDownloadStatusWindow::BaseNetworkContentDownloadStatusWindow(WindowDesc *desc) :
104 Window(desc), cur_id(UINT32_MAX)
105 {
106 _network_content_client.AddCallback(this);
107 _network_content_client.DownloadSelectedContent(this->total_files, this->total_bytes);
108
109 this->InitNested(WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD);
110 }
111
112 BaseNetworkContentDownloadStatusWindow::~BaseNetworkContentDownloadStatusWindow()
113 {
114 _network_content_client.RemoveCallback(this);
115 }
116
117 void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, int widget) const
118 {
119 if (widget != WID_NCDS_BACKGROUND) return;
120
121 /* Draw nice progress bar :) */
122 DrawFrameRect(r.left + 20, r.top + 4, r.left + 20 + (int)((this->width - 40LL) * this->downloaded_bytes / this->total_bytes), r.top + 14, COLOUR_MAUVE, FR_NONE);
123
124 int y = r.top + 20;
125 SetDParam(0, this->downloaded_bytes);
126 SetDParam(1, this->total_bytes);
127 SetDParam(2, this->downloaded_bytes * 100LL / this->total_bytes);
128 DrawString(r.left + 2, r.right - 2, y, STR_CONTENT_DOWNLOAD_PROGRESS_SIZE, TC_FROMSTRING, SA_HOR_CENTER);
129
130 StringID str;
131 if (this->downloaded_bytes == this->total_bytes) {
132 str = STR_CONTENT_DOWNLOAD_COMPLETE;
133 } else if (!StrEmpty(this->name)) {
134 SetDParamStr(0, this->name);
135 SetDParam(1, this->downloaded_files);
136 SetDParam(2, this->total_files);
137 str = STR_CONTENT_DOWNLOAD_FILE;
138 } else {
139 str = STR_CONTENT_DOWNLOAD_INITIALISE;
140 }
141
142 y += FONT_HEIGHT_NORMAL + 5;
143 DrawStringMultiLine(r.left + 2, r.right - 2, y, y + FONT_HEIGHT_NORMAL * 2, str, TC_FROMSTRING, SA_CENTER);
144 }
145
146 void BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(const ContentInfo *ci, int bytes)
147 {
148 if (ci->id != this->cur_id) {
149 strecpy(this->name, ci->filename, lastof(this->name));
150 this->cur_id = ci->id;
151 this->downloaded_files++;
152 }
153
154 this->downloaded_bytes += bytes;
155 this->SetDirty();
156 }
157
158
160 struct NetworkContentDownloadStatusWindow : public BaseNetworkContentDownloadStatusWindow {
161 private:
162 std::vector<ContentType> receivedTypes;
163
164 public:
169 NetworkContentDownloadStatusWindow() : BaseNetworkContentDownloadStatusWindow(&_network_content_download_status_window_desc)
170 {
171 this->parent = FindWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST);
172 }
173
175 ~NetworkContentDownloadStatusWindow()
176 {
177 TarScanner::Mode mode = TarScanner::NONE;
178 for (auto ctype : this->receivedTypes) {
179 switch (ctype) {
180 case CONTENT_TYPE_AI:
181 case CONTENT_TYPE_AI_LIBRARY:
182 /* AI::Rescan calls the scanner. */
183 break;
184 case CONTENT_TYPE_GAME:
185 case CONTENT_TYPE_GAME_LIBRARY:
186 /* Game::Rescan calls the scanner. */
187 break;
188
189 case CONTENT_TYPE_BASE_GRAPHICS:
190 case CONTENT_TYPE_BASE_SOUNDS:
191 case CONTENT_TYPE_BASE_MUSIC:
192 mode |= TarScanner::BASESET;
193 break;
194
195 case CONTENT_TYPE_NEWGRF:
196 /* ScanNewGRFFiles calls the scanner. */
197 break;
198
199 case CONTENT_TYPE_SCENARIO:
200 case CONTENT_TYPE_HEIGHTMAP:
201 mode |= TarScanner::SCENARIO;
202 break;
203
204 default:
205 break;
206 }
207 }
208
209 TarScanner::DoScan(mode);
210
211 /* Tell all the backends about what we've downloaded */
212 for (auto ctype : this->receivedTypes) {
213 switch (ctype) {
214 case CONTENT_TYPE_AI:
215 case CONTENT_TYPE_AI_LIBRARY:
216 AI::Rescan();
217 break;
218
219 case CONTENT_TYPE_GAME:
220 case CONTENT_TYPE_GAME_LIBRARY:
221 Game::Rescan();
222 break;
223
224 case CONTENT_TYPE_BASE_GRAPHICS:
225 BaseGraphics::FindSets();
226 SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_OPTIONS);
227 break;
228
229 case CONTENT_TYPE_BASE_SOUNDS:
230 BaseSounds::FindSets();
231 SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_OPTIONS);
232 break;
233
234 case CONTENT_TYPE_BASE_MUSIC:
235 BaseMusic::FindSets();
236 SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_OPTIONS);
237 break;
238
239 case CONTENT_TYPE_NEWGRF:
240 RequestNewGRFScan();
241 break;
242
243 case CONTENT_TYPE_SCENARIO:
244 case CONTENT_TYPE_HEIGHTMAP:
245 extern void ScanScenarios();
246 ScanScenarios();
247 InvalidateWindowData(WC_SAVELOAD, 0, 0);
248 break;
249
250 default:
251 break;
252 }
253 }
254
255 /* Always invalidate the download window; tell it we are going to be gone */
256 InvalidateWindowData(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST, 2);
257 }
258
259 void OnClick(Point pt, int widget, int click_count) override
260 {
261 if (widget == WID_NCDS_CANCELOK) {
262 if (this->downloaded_bytes != this->total_bytes) {
263 _network_content_client.Close();
264 delete this;
265 } else {
266 /* If downloading succeeded, close the online content window. This will close
267 * the current window as well. */
268 DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST);
269 }
270 }
271 }
272
273 void OnDownloadProgress(const ContentInfo *ci, int bytes) override
274 {
275 BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(ci, bytes);
276 include(this->receivedTypes, ci->type);
277
278 /* When downloading is finished change cancel in ok */
279 if (this->downloaded_bytes == this->total_bytes) {
280 this->GetWidget<NWidgetCore>(WID_NCDS_CANCELOK)->widget_data = STR_BUTTON_OK;
281 }
282 }
283 };
284
286 struct ContentListFilterData {
287 StringFilter string_filter;
288 std::bitset<CONTENT_TYPE_END> types;
289 };
290
292 enum ContentListFilterCriteria {
293 CONTENT_FILTER_TEXT = 0,
294 CONTENT_FILTER_TYPE_OR_SELECTED,
295 };
296
298 class NetworkContentListWindow : public Window, ContentCallback {
300 typedef GUIList<const ContentInfo *, ContentListFilterData &> GUIContentList;
301
302 static const uint EDITBOX_MAX_SIZE = 50;
303
304 static Listing last_sorting;
305 static Filtering last_filtering;
306 static GUIContentList::SortFunction * const sorter_funcs[];
307 static GUIContentList::FilterFunction * const filter_funcs[];
308 GUIContentList content;
309 bool auto_select;
310 ContentListFilterData filter_data;
311 QueryString filter_editbox;
312 Dimension checkbox_size;
313
314 const ContentInfo *selected;
315 int list_pos;
316 uint filesize_sum;
317 Scrollbar *vscroll;
318
319 static char content_type_strs[CONTENT_TYPE_END][64];
320
322 void OpenExternalSearch()
323 {
324 extern void OpenBrowser(const char *url);
325
326 char url[1024];
327 const char *last = lastof(url);
328
329 char *pos = strecpy(url, "https://grfsearch.openttd.org/?", last);
330
331 if (this->auto_select) {
332 pos = strecpy(pos, "do=searchgrfid&q=", last);
333
334 bool first = true;
335 for (const ContentInfo *ci : this->content) {
336 if (ci->state != ContentInfo::DOES_NOT_EXIST) continue;
337
338 if (!first) pos = strecpy(pos, ",", last);
339 first = false;
340
341 pos += seprintf(pos, last, "%08X", ci->unique_id);
342 pos = strecpy(pos, ":", last);
343 pos = md5sumToString(pos, last, ci->md5sum);
344 }
345 } else {
346 pos = strecpy(pos, "do=searchtext&q=", last);
347
348 /* Escape search term */
349 for (const char *search = this->filter_editbox.text.buf; *search != '\0'; search++) {
350 /* Remove quotes */
351 if (*search == '\'' || *search == '"') continue;
352
353 /* Escape special chars, such as &%,= */
354 if (*search < 0x30) {
355 pos += seprintf(pos, last, "%%%02X", *search);
356 } else if (pos < last) {
357 *pos = *search;
358 *++pos = '\0';
359 }
360 }
361 }
362
363 OpenBrowser(url);
364 }
365
369 static void ExternalSearchDisclaimerCallback(Window *w, bool accepted)
370 {
371 if (accepted) {
372 _accepted_external_search = true;
373 ((NetworkContentListWindow*)w)->OpenExternalSearch();
374 }
375 }
376
381 void BuildContentList()
382 {
383 if (!this->content.NeedRebuild()) return;
384
385 /* Create temporary array of games to use for listing */
386 this->content.clear();
387
388 bool all_available = true;
389
390 for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) {
391 if ((*iter)->state == ContentInfo::DOES_NOT_EXIST) all_available = false;
392 this->content.push_back(*iter);
393 }
394
395 this->SetWidgetDisabledState(WID_NCL_SEARCH_EXTERNAL, this->auto_select && all_available);
396
397 this->FilterContentList();
398 this->content.shrink_to_fit();
399 this->content.RebuildDone();
400 this->SortContentList();
401
402 this->vscroll->SetCount((int)this->content.size()); // Update the scrollbar
403 this->ScrollToSelected();
404 }
405
407 static bool NameSorter(const ContentInfo * const &a, const ContentInfo * const &b)
408 {
409 return strnatcmp(a->name, b->name, true) < 0; // Sort by name (natural sorting).
410 }
411
413 static bool TypeSorter(const ContentInfo * const &a, const ContentInfo * const &b)
414 {
415 int r = 0;
416 if (a->type != b->type) {
417 r = strnatcmp(content_type_strs[a->type], content_type_strs[b->type]);
418 }
419 if (r == 0) return NameSorter(a, b);
420 return r < 0;
421 }
422
424 static bool StateSorter(const ContentInfo * const &a, const ContentInfo * const &b)
425 {
426 int r = a->state - b->state;
427 if (r == 0) return TypeSorter(a, b);
428 return r < 0;
429 }
430
432 void SortContentList()
433 {
434 if (!this->content.Sort()) return;
435
436 int idx = find_index(this->content, this->selected);
437 if (idx >= 0) this->list_pos = idx;
438 }
439
441 static bool CDECL TagNameFilter(const ContentInfo * const *a, ContentListFilterData &filter)
442 {
443 filter.string_filter.ResetState();
444 for (int i = 0; i < (*a)->tag_count; i++) {
445 filter.string_filter.AddLine((*a)->tags[i]);
446 }
447 filter.string_filter.AddLine((*a)->name);
448 return filter.string_filter.GetState();
449 }
450
452 static bool CDECL TypeOrSelectedFilter(const ContentInfo * const *a, ContentListFilterData &filter)
453 {
454 if (filter.types.none()) return true;
455 if (filter.types[(*a)->type]) return true;
456 return ((*a)->state == ContentInfo::SELECTED || (*a)->state == ContentInfo::AUTOSELECTED);
457 }
458
460 void FilterContentList()
461 {
462 /* Apply filters. */
463 bool changed = false;
464 if (!this->filter_data.string_filter.IsEmpty()) {
465 this->content.SetFilterType(CONTENT_FILTER_TEXT);
466 changed |= this->content.Filter(this->filter_data);
467 }
468 if (this->filter_data.types.any()) {
469 this->content.SetFilterType(CONTENT_FILTER_TYPE_OR_SELECTED);
470 changed |= this->content.Filter(this->filter_data);
471 }
472 if (!changed) return;
473
474 /* update list position */
475 int idx = find_index(this->content, this->selected);
476 if (idx >= 0) {
477 this->list_pos = idx;
478 return;
479 }
480
481 /* previously selected item not in list anymore */
482 this->selected = nullptr;
483 this->list_pos = 0;
484 }
485
490 bool UpdateFilterState()
491 {
492 Filtering old_params = this->content.GetFiltering();
493 bool new_state = !this->filter_data.string_filter.IsEmpty() || this->filter_data.types.any();
494 if (new_state != old_params.state) {
495 this->content.SetFilterState(new_state);
496 }
497 return new_state != old_params.state;
498 }
499
501 void ScrollToSelected()
502 {
503 if (this->selected == nullptr) return;
504
505 this->vscroll->ScrollTowards(this->list_pos);
506 }
507
508 friend void BuildContentTypeStringList();
509 public:
519 NetworkContentListWindow(WindowDesc *desc, bool select_all, const std::bitset<CONTENT_TYPE_END> &types) :
520 Window(desc),
521 auto_select(select_all),
522 filter_editbox(EDITBOX_MAX_SIZE),
523 selected(nullptr),
524 list_pos(0)
525 {
526 this->checkbox_size = maxdim(maxdim(GetSpriteSize(SPR_BOX_EMPTY), GetSpriteSize(SPR_BOX_CHECKED)), GetSpriteSize(SPR_BLOT));
527
528 this->CreateNestedTree();
529 this->vscroll = this->GetScrollbar(WID_NCL_SCROLLBAR);
530 this->FinishInitNested(WN_NETWORK_WINDOW_CONTENT_LIST);
531
532 this->GetWidget<NWidgetStacked>(WID_NCL_SEL_ALL_UPDATE)->SetDisplayedPlane(select_all);
533
534 this->querystrings[WID_NCL_FILTER] = &this->filter_editbox;
535 this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;
536 this->SetFocusedWidget(WID_NCL_FILTER);
537 this->SetWidgetDisabledState(WID_NCL_SEARCH_EXTERNAL, this->auto_select);
538 this->filter_data.types = types;
539
540 _network_content_client.AddCallback(this);
541 this->content.SetListing(this->last_sorting);
542 this->content.SetFiltering(this->last_filtering);
543 this->content.SetSortFuncs(this->sorter_funcs);
544 this->content.SetFilterFuncs(this->filter_funcs);
545 this->UpdateFilterState();
546 this->content.ForceRebuild();
547 this->FilterContentList();
548 this->SortContentList();
549 this->InvalidateData();
550 }
551
553 ~NetworkContentListWindow()
554 {
555 _network_content_client.RemoveCallback(this);
556 }
557
558 void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
559 {
560 switch (widget) {
561 case WID_NCL_FILTER_CAPT:
562 *size = maxdim(*size, GetStringBoundingBox(STR_CONTENT_FILTER_TITLE));
563 break;
564
565 case WID_NCL_CHECKBOX:
566 size->width = this->checkbox_size.width + WD_MATRIX_RIGHT + WD_MATRIX_LEFT;
567 break;
568
569 case WID_NCL_TYPE: {
570 Dimension d = *size;
571 for (int i = CONTENT_TYPE_BEGIN; i < CONTENT_TYPE_END; i++) {
572 d = maxdim(d, GetStringBoundingBox(STR_CONTENT_TYPE_BASE_GRAPHICS + i - CONTENT_TYPE_BASE_GRAPHICS));
573 }
574 size->width = d.width + WD_MATRIX_RIGHT + WD_MATRIX_LEFT;
575 break;
576 }
577
578 case WID_NCL_MATRIX:
579 resize->height = std::max(this->checkbox_size.height, (uint)FONT_HEIGHT_NORMAL) + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
580 size->height = 10 * resize->height;
581 break;
582 }
583 }
584
585
586 void DrawWidget(const Rect &r, int widget) const override
587 {
588 switch (widget) {
589 case WID_NCL_FILTER_CAPT:
590 DrawString(r.left, r.right, r.top, STR_CONTENT_FILTER_TITLE, TC_FROMSTRING, SA_RIGHT);
591 break;
592
593 case WID_NCL_DETAILS:
594 this->DrawDetails(r);
595 break;
596
597 case WID_NCL_MATRIX:
598 this->DrawMatrix(r);
599 break;
600 }
601 }
602
603 void OnPaint() override
604 {
605 const SortButtonState arrow = this->content.IsDescSortOrder() ? SBS_DOWN : SBS_UP;
606
607 if (this->content.NeedRebuild()) {
608 this->BuildContentList();
609 }
610
611 this->DrawWidgets();
612
613 switch (this->content.SortType()) {
614 case WID_NCL_CHECKBOX - WID_NCL_CHECKBOX: this->DrawSortButtonState(WID_NCL_CHECKBOX, arrow); break;
615 case WID_NCL_TYPE - WID_NCL_CHECKBOX: this->DrawSortButtonState(WID_NCL_TYPE, arrow); break;
616 case WID_NCL_NAME - WID_NCL_CHECKBOX: this->DrawSortButtonState(WID_NCL_NAME, arrow); break;
617 }
618 }
619
624 void DrawMatrix(const Rect &r) const
625 {
626 const NWidgetBase *nwi_checkbox = this->GetWidget<NWidgetBase>(WID_NCL_CHECKBOX);
627 const NWidgetBase *nwi_name = this->GetWidget<NWidgetBase>(WID_NCL_NAME);
628 const NWidgetBase *nwi_type = this->GetWidget<NWidgetBase>(WID_NCL_TYPE);
629
630 int line_height = std::max(this->checkbox_size.height, (uint)FONT_HEIGHT_NORMAL);
631
632 /* Fill the matrix with the information */
633 int sprite_y_offset = WD_MATRIX_TOP + (line_height - this->checkbox_size.height) / 2 - 1;
634 int text_y_offset = WD_MATRIX_TOP + (line_height - FONT_HEIGHT_NORMAL) / 2;
635 uint y = r.top;
636
637 auto iter = this->content.begin() + this->vscroll->GetPosition();
638 size_t last = this->vscroll->GetPosition() + this->vscroll->GetCapacity();
639 auto end = (last < this->content.size()) ? this->content.begin() + last : this->content.end();
640
641 for (; iter != end; iter++) {
642 const ContentInfo *ci = *iter;
643
644 if (ci == this->selected) GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->resize.step_height - 1, PC_GREY);
645
646 SpriteID sprite;
647 SpriteID pal = PAL_NONE;
648 switch (ci->state) {
649 case ContentInfo::UNSELECTED: sprite = SPR_BOX_EMPTY; break;
650 case ContentInfo::SELECTED: sprite = SPR_BOX_CHECKED; break;
651 case ContentInfo::AUTOSELECTED: sprite = SPR_BOX_CHECKED; break;
652 case ContentInfo::ALREADY_HERE: sprite = SPR_BLOT; pal = PALETTE_TO_GREEN; break;
653 case ContentInfo::DOES_NOT_EXIST: sprite = SPR_BLOT; pal = PALETTE_TO_RED; break;
654 default: NOT_REACHED();
655 }
656 DrawSprite(sprite, pal, nwi_checkbox->pos_x + (pal == PAL_NONE ? 2 : 3), y + sprite_y_offset + (pal == PAL_NONE ? 1 : 0));
657
658 StringID str = STR_CONTENT_TYPE_BASE_GRAPHICS + ci->type - CONTENT_TYPE_BASE_GRAPHICS;
659 DrawString(nwi_type->pos_x, nwi_type->pos_x + nwi_type->current_x - 1, y + text_y_offset, str, TC_BLACK, SA_HOR_CENTER);
660
661 DrawString(nwi_name->pos_x + WD_FRAMERECT_LEFT, nwi_name->pos_x + nwi_name->current_x - WD_FRAMERECT_RIGHT, y + text_y_offset, ci->name, TC_BLACK);
662 y += this->resize.step_height;
663 }
664 }
665
670 void DrawDetails(const Rect &r) const
671 {
672 static const int DETAIL_LEFT = 5;
673 static const int DETAIL_RIGHT = 5;
674 static const int DETAIL_TOP = 5;
675
676 /* Height for the title banner */
677 int DETAIL_TITLE_HEIGHT = 5 * FONT_HEIGHT_NORMAL;
678
679 /* Create the nice grayish rectangle at the details top */
680 GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.top + DETAIL_TITLE_HEIGHT, PC_DARK_BLUE);
681 DrawString(r.left + WD_INSET_LEFT, r.right - WD_INSET_RIGHT, r.top + FONT_HEIGHT_NORMAL + WD_INSET_TOP, STR_CONTENT_DETAIL_TITLE, TC_FROMSTRING, SA_HOR_CENTER);
682
683 /* Draw the total download size */
684 SetDParam(0, this->filesize_sum);
685 DrawString(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, r.bottom - FONT_HEIGHT_NORMAL - WD_PAR_VSEP_NORMAL, STR_CONTENT_TOTAL_DOWNLOAD_SIZE);
686
687 if (this->selected == nullptr) return;
688
689 /* And fill the rest of the details when there's information to place there */
690 DrawStringMultiLine(r.left + WD_INSET_LEFT, r.right - WD_INSET_RIGHT, r.top + DETAIL_TITLE_HEIGHT / 2, r.top + DETAIL_TITLE_HEIGHT, STR_CONTENT_DETAIL_SUBTITLE_UNSELECTED + this->selected->state, TC_FROMSTRING, SA_CENTER);
691
692 /* Also show the total download size, so keep some space from the bottom */
693 const uint max_y = r.bottom - FONT_HEIGHT_NORMAL - WD_PAR_VSEP_WIDE;
694 int y = r.top + DETAIL_TITLE_HEIGHT + DETAIL_TOP;
695
696 if (this->selected->upgrade) {
697 SetDParam(0, STR_CONTENT_TYPE_BASE_GRAPHICS + this->selected->type - CONTENT_TYPE_BASE_GRAPHICS);
698 y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_UPDATE);
699 y += WD_PAR_VSEP_WIDE;
700 }
701
702 SetDParamStr(0, this->selected->name);
703 y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_NAME);
704
705 if (!StrEmpty(this->selected->version)) {
706 SetDParamStr(0, this->selected->version);
707 y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_VERSION);
708 }
709
710 if (!StrEmpty(this->selected->description)) {
711 SetDParamStr(0, this->selected->description);
712 y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_DESCRIPTION);
713 }
714
715 if (!StrEmpty(this->selected->url)) {
716 SetDParamStr(0, this->selected->url);
717 y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_URL);
718 }
719
720 SetDParam(0, STR_CONTENT_TYPE_BASE_GRAPHICS + this->selected->type - CONTENT_TYPE_BASE_GRAPHICS);
721 y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_TYPE);
722
723 y += WD_PAR_VSEP_WIDE;
724 SetDParam(0, this->selected->filesize);
725 y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_FILESIZE);
726
727 if (this->selected->dependency_count != 0) {
728 /* List dependencies */
729 char buf[DRAW_STRING_BUFFER] = "";
730 char *p = buf;
731 for (uint i = 0; i < this->selected->dependency_count; i++) {
732 ContentID cid = this->selected->dependencies[i];
733
734 /* Try to find the dependency */
735 ConstContentIterator iter = _network_content_client.Begin();
736 for (; iter != _network_content_client.End(); iter++) {
737 const ContentInfo *ci = *iter;
738 if (ci->id != cid) continue;
739
740 p += seprintf(p, lastof(buf), p == buf ? "%s" : ", %s", (*iter)->name);
741 break;
742 }
743 }
744 SetDParamStr(0, buf);
745 y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_DEPENDENCIES);
746 }
747
748 if (this->selected->tag_count != 0) {
749 /* List all tags */
750 char buf[DRAW_STRING_BUFFER] = "";
751 char *p = buf;
752 for (uint i = 0; i < this->selected->tag_count; i++) {
753 p += seprintf(p, lastof(buf), i == 0 ? "%s" : ", %s", this->selected->tags[i]);
754 }
755 SetDParamStr(0, buf);
756 y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_TAGS);
757 }
758
759 if (this->selected->IsSelected()) {
760 /* When selected show all manually selected content that depends on this */
761 ConstContentVector tree;
762 _network_content_client.ReverseLookupTreeDependency(tree, this->selected);
763
764 char buf[DRAW_STRING_BUFFER] = "";
765 char *p = buf;
766 for (const ContentInfo *ci : tree) {
767 if (ci == this->selected || ci->state != ContentInfo::SELECTED) continue;
768
769 p += seprintf(p, lastof(buf), buf == p ? "%s" : ", %s", ci->name);
770 }
771 if (p != buf) {
772 SetDParamStr(0, buf);
773 y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_SELECTED_BECAUSE_OF);
774 }
775 }
776 }
777
778 void OnClick(Point pt, int widget, int click_count) override
779 {
780 if (widget >= WID_NCL_TEXTFILE && widget < WID_NCL_TEXTFILE + TFT_END) {
781 if (this->selected == nullptr || this->selected->state != ContentInfo::ALREADY_HERE) return;
782
783 ShowContentTextfileWindow((TextfileType)(widget - WID_NCL_TEXTFILE), this->selected);
784 return;
785 }
786
787 switch (widget) {
788 case WID_NCL_MATRIX: {
789 uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NCL_MATRIX);
790 if (id_v >= this->content.size()) return; // click out of bounds
791
792 this->selected = this->content[id_v];
793 this->list_pos = id_v;
794
795 const NWidgetBase *checkbox = this->GetWidget<NWidgetBase>(WID_NCL_CHECKBOX);
796 if (click_count > 1 || IsInsideBS(pt.x, checkbox->pos_x, checkbox->current_x)) {
797 _network_content_client.ToggleSelectedState(this->selected);
798 this->content.ForceResort();
799 }
800
801 if (this->filter_data.types.any()) {
802 this->content.ForceRebuild();
803 }
804
805 this->InvalidateData();
806 break;
807 }
808
809 case WID_NCL_CHECKBOX:
810 case WID_NCL_TYPE:
811 case WID_NCL_NAME:
812 if (this->content.SortType() == widget - WID_NCL_CHECKBOX) {
813 this->content.ToggleSortOrder();
814 if (this->content.size() > 0) this->list_pos = (int)this->content.size() - this->list_pos - 1;
815 } else {
816 this->content.SetSortType(widget - WID_NCL_CHECKBOX);
817 this->content.ForceResort();
818 this->SortContentList();
819 }
820 this->ScrollToSelected();
821 this->InvalidateData();
822 break;
823
824 case WID_NCL_SELECT_ALL:
825 _network_content_client.SelectAll();
826 this->InvalidateData();
827 break;
828
829 case WID_NCL_SELECT_UPDATE:
830 _network_content_client.SelectUpgrade();
831 this->InvalidateData();
832 break;
833
834 case WID_NCL_UNSELECT:
835 _network_content_client.UnselectAll();
836 this->InvalidateData();
837 break;
838
839 case WID_NCL_CANCEL:
840 delete this;
841 break;
842
843 case WID_NCL_OPEN_URL:
844 if (this->selected != nullptr) {
845 extern void OpenBrowser(const char *url);
846 OpenBrowser(this->selected->url);
847 }
848 break;
849
850 case WID_NCL_DOWNLOAD:
851 if (BringWindowToFrontById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD) == nullptr) new NetworkContentDownloadStatusWindow();
852 break;
853
854 case WID_NCL_SEARCH_EXTERNAL:
855 if (_accepted_external_search) {
856 this->OpenExternalSearch();
857 } else {
858 ShowQuery(STR_CONTENT_SEARCH_EXTERNAL_DISCLAIMER_CAPTION, STR_CONTENT_SEARCH_EXTERNAL_DISCLAIMER, this, ExternalSearchDisclaimerCallback);
859 }
860 break;
861 }
862 }
863
864 EventState OnKeyPress(WChar key, uint16 keycode) override
865 {
866 switch (keycode) {
867 case WKC_UP:
868 /* scroll up by one */
869 if (this->list_pos > 0) this->list_pos--;
870 break;
871 case WKC_DOWN:
872 /* scroll down by one */
873 if (this->list_pos < (int)this->content.size() - 1) this->list_pos++;
874 break;
875 case WKC_PAGEUP:
876 /* scroll up a page */
877 this->list_pos = (this->list_pos < this->vscroll->GetCapacity()) ? 0 : this->list_pos - this->vscroll->GetCapacity();
878 break;
879 case WKC_PAGEDOWN:
880 /* scroll down a page */
881 this->list_pos = std::min(this->list_pos + this->vscroll->GetCapacity(), (int)this->content.size() - 1);
882 break;
883 case WKC_HOME:
884 /* jump to beginning */
885 this->list_pos = 0;
886 break;
887 case WKC_END:
888 /* jump to end */
889 this->list_pos = (int)this->content.size() - 1;
890 break;
891
892 case WKC_SPACE:
893 case WKC_RETURN:
894 if (keycode == WKC_RETURN || !IsWidgetFocused(WID_NCL_FILTER)) {
895 if (this->selected != nullptr) {
896 _network_content_client.ToggleSelectedState(this->selected);
897 this->content.ForceResort();
898 this->InvalidateData();
899 }
900 if (this->filter_data.types.any()) {
901 this->content.ForceRebuild();
902 this->InvalidateData();
903 }
904 return ES_HANDLED;
905 }
906 /* space is pressed and filter is focused. */
907 FALLTHROUGH;
908
909 default:
910 return ES_NOT_HANDLED;
911 }
912
913 if (this->content.size() == 0) {
914 this->list_pos = 0; // above stuff may result in "-1".
915 if (this->UpdateFilterState()) {
916 this->content.ForceRebuild();
917 this->InvalidateData();
918 }
919 return ES_HANDLED;
920 }
921
922 this->selected = this->content[this->list_pos];
923
924 if (this->UpdateFilterState()) {
925 this->content.ForceRebuild();
926 } else {
927 /* Scroll to the new content if it is outside the current range. */
928 this->ScrollToSelected();
929 }
930
931 /* redraw window */
932 this->InvalidateData();
933 return ES_HANDLED;
934 }
935
936 void OnEditboxChanged(int wid) override
937 {
938 if (wid == WID_NCL_FILTER) {
939 this->filter_data.string_filter.SetFilterTerm(this->filter_editbox.text.buf);
940 this->UpdateFilterState();
941 this->content.ForceRebuild();
942 this->InvalidateData();
943 }
944 }
945
946 void OnResize() override
947 {
948 this->vscroll->SetCapacityFromWidget(this, WID_NCL_MATRIX);
949 }
950
951 void OnReceiveContentInfo(const ContentInfo *rci) override
952 {
953 if (this->auto_select && !rci->IsSelected()) _network_content_client.ToggleSelectedState(rci);
954 this->content.ForceRebuild();
955 this->InvalidateData(0, false);
956 }
957
958 void OnDownloadComplete(ContentID cid) override
959 {
960 this->content.ForceResort();
961 this->InvalidateData();
962 }
963
964 void OnConnect(bool success) override
965 {
966 if (!success) {
967 ShowErrorMessage(STR_CONTENT_ERROR_COULD_NOT_CONNECT, INVALID_STRING_ID, WL_ERROR);
968 delete this;
969 return;
970 }
971
972 this->InvalidateData();
973 }
974
980 void OnInvalidateData(int data = 0, bool gui_scope = true) override
981 {
982 if (!gui_scope) return;
983 if (this->content.NeedRebuild()) this->BuildContentList();
984
985 /* To sum all the bytes we intend to download */
986 this->filesize_sum = 0;
987 bool show_select_all = false;
988 bool show_select_upgrade = false;
989 for (const ContentInfo *ci : this->content) {
990 switch (ci->state) {
991 case ContentInfo::SELECTED:
992 case ContentInfo::AUTOSELECTED:
993 this->filesize_sum += ci->filesize;
994 break;
995
996 case ContentInfo::UNSELECTED:
997 show_select_all = true;
998 show_select_upgrade |= ci->upgrade;
999 break;
1000
1001 default:
1002 break;
1003 }
1004 }
1005
1006 /* If data == 2 then the status window caused this OnInvalidate */
1007 this->SetWidgetDisabledState(WID_NCL_DOWNLOAD, this->filesize_sum == 0 || (FindWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD) != nullptr && data != 2));
1008 this->SetWidgetDisabledState(WID_NCL_UNSELECT, this->filesize_sum == 0);
1009 this->SetWidgetDisabledState(WID_NCL_SELECT_ALL, !show_select_all);
1010 this->SetWidgetDisabledState(WID_NCL_SELECT_UPDATE, !show_select_upgrade);
1011 this->SetWidgetDisabledState(WID_NCL_OPEN_URL, this->selected == nullptr || StrEmpty(this->selected->url));
1012 for (TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
1013 this->SetWidgetDisabledState(WID_NCL_TEXTFILE + tft, this->selected == nullptr || this->selected->state != ContentInfo::ALREADY_HERE || this->selected->GetTextfile(tft) == nullptr);
1014 }
1015
1016 this->GetWidget<NWidgetCore>(WID_NCL_CANCEL)->widget_data = this->filesize_sum == 0 ? STR_AI_SETTINGS_CLOSE : STR_AI_LIST_CANCEL;
1017 }
1018 };
1019
1020 Listing NetworkContentListWindow::last_sorting = {false, 1};
1021 Filtering NetworkContentListWindow::last_filtering = {false, 0};
1022
1023 NetworkContentListWindow::GUIContentList::SortFunction * const NetworkContentListWindow::sorter_funcs[] = {
1024 &StateSorter,
1025 &TypeSorter,
1026 &NameSorter,
1027 };
1028
1029 NetworkContentListWindow::GUIContentList::FilterFunction * const NetworkContentListWindow::filter_funcs[] = {
1030 &TagNameFilter,
1031 &TypeOrSelectedFilter,
1032 };
1033
1034 char NetworkContentListWindow::content_type_strs[CONTENT_TYPE_END][64];
1035
1039 void BuildContentTypeStringList()
1040 {
1041 for (int i = CONTENT_TYPE_BEGIN; i < CONTENT_TYPE_END; i++) {
1042 GetString(NetworkContentListWindow::content_type_strs[i], STR_CONTENT_TYPE_BASE_GRAPHICS + i - CONTENT_TYPE_BASE_GRAPHICS, lastof(NetworkContentListWindow::content_type_strs[i]));
1043 }
1044 }
1045
1047 static const NWidgetPart _nested_network_content_list_widgets[] = {
1048 NWidget(NWID_HORIZONTAL),
1049 NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE),
1050 NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_CONTENT_TITLE, STR_NULL),
1051 NWidget(WWT_DEFSIZEBOX, COLOUR_LIGHT_BLUE),
1052 EndContainer(),
1053 NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NCL_BACKGROUND),
1054 NWidget(NWID_SPACER), SetMinimalSize(0, 7), SetResize(1, 0),
1055 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(8, 8, 8),
1056 /* Top */
1057 NWidget(WWT_EMPTY, COLOUR_LIGHT_BLUE, WID_NCL_FILTER_CAPT), SetFill(1, 0), SetResize(1, 0),
1058 NWidget(WWT_EDITBOX, COLOUR_LIGHT_BLUE, WID_NCL_FILTER), SetFill(1, 0), SetResize(1, 0),
1059 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1060 EndContainer(),
1061 NWidget(NWID_SPACER), SetMinimalSize(0, 7), SetResize(1, 0),
1062 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(8, 8, 8),
1063 /* Left side. */
1064 NWidget(NWID_VERTICAL), SetPIP(0, 4, 0),
1065 NWidget(NWID_HORIZONTAL),
1066 NWidget(NWID_VERTICAL),
1067 NWidget(NWID_HORIZONTAL),
1068 NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_CHECKBOX), SetMinimalSize(13, 1), SetDataTip(STR_EMPTY, STR_NULL),
1069 NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_TYPE),
1070 SetDataTip(STR_CONTENT_TYPE_CAPTION, STR_CONTENT_TYPE_CAPTION_TOOLTIP),
1071 NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_NAME), SetResize(1, 0), SetFill(1, 0),
1072 SetDataTip(STR_CONTENT_NAME_CAPTION, STR_CONTENT_NAME_CAPTION_TOOLTIP),
1073 EndContainer(),
1074 NWidget(WWT_MATRIX, COLOUR_LIGHT_BLUE, WID_NCL_MATRIX), SetResize(1, 14), SetFill(1, 1), SetScrollbar(WID_NCL_SCROLLBAR), SetMatrixDataTip(1, 0, STR_CONTENT_MATRIX_TOOLTIP),
1075 EndContainer(),
1076 NWidget(NWID_VSCROLLBAR, COLOUR_LIGHT_BLUE, WID_NCL_SCROLLBAR),
1077 EndContainer(),
1078 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(0, 8, 0),
1079 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NCL_SEL_ALL_UPDATE), SetResize(1, 0), SetFill(1, 0),
1080 NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_SELECT_UPDATE), SetResize(1, 0), SetFill(1, 0),
1081 SetDataTip(STR_CONTENT_SELECT_UPDATES_CAPTION, STR_CONTENT_SELECT_UPDATES_CAPTION_TOOLTIP),
1082 NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_SELECT_ALL), SetResize(1, 0), SetFill(1, 0),
1083 SetDataTip(STR_CONTENT_SELECT_ALL_CAPTION, STR_CONTENT_SELECT_ALL_CAPTION_TOOLTIP),
1084 EndContainer(),
1085 NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_UNSELECT), SetResize(1, 0), SetFill(1, 0),
1086 SetDataTip(STR_CONTENT_UNSELECT_ALL_CAPTION, STR_CONTENT_UNSELECT_ALL_CAPTION_TOOLTIP),
1087 EndContainer(),
1088 EndContainer(),
1089 /* Right side. */
1090 NWidget(NWID_VERTICAL), SetPIP(0, 4, 0),
1091 NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NCL_DETAILS), SetResize(1, 1), SetFill(1, 1), EndContainer(),
1092 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(0, 8, 0),
1093 NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_TEXTFILE + TFT_README), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_README, STR_NULL),
1094 NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_TEXTFILE + TFT_CHANGELOG), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_NULL),
1095 EndContainer(),
1096 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(0, 8, 0),
1097 NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_OPEN_URL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_CONTENT_OPEN_URL, STR_CONTENT_OPEN_URL_TOOLTIP),
1098 NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_TEXTFILE + TFT_LICENSE), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_NULL),
1099 EndContainer(),
1100 EndContainer(),
1101 EndContainer(),
1102 NWidget(NWID_SPACER), SetMinimalSize(0, 7), SetResize(1, 0),
1103 /* Bottom. */
1104 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(8, 8, 8),
1105 NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_SEARCH_EXTERNAL), SetResize(1, 0), SetFill(1, 0),
1106 SetDataTip(STR_CONTENT_SEARCH_EXTERNAL, STR_CONTENT_SEARCH_EXTERNAL_TOOLTIP),
1107 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(0, 8, 0),
1108 NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_CANCEL), SetResize(1, 0), SetFill(1, 0),
1109 SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
1110 NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_DOWNLOAD), SetResize(1, 0), SetFill(1, 0),
1111 SetDataTip(STR_CONTENT_DOWNLOAD_CAPTION, STR_CONTENT_DOWNLOAD_CAPTION_TOOLTIP),
1112 EndContainer(),
1113 EndContainer(),
1114 NWidget(NWID_SPACER), SetMinimalSize(0, 2), SetResize(1, 0),
1115 /* Resize button. */
1116 NWidget(NWID_HORIZONTAL),
1117 NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
1118 NWidget(WWT_RESIZEBOX, COLOUR_LIGHT_BLUE),
1119 EndContainer(),
1120 EndContainer(),
1121 };
1122
1124 static WindowDesc _network_content_list_desc(
1125 WDP_CENTER, "list_content", 630, 460,
1126 WC_NETWORK_WINDOW, WC_NONE,
1127 0,
1128 _nested_network_content_list_widgets, lengthof(_nested_network_content_list_widgets)
1129 );
1130
1138 void ShowNetworkContentListWindow(ContentVector *cv, ContentType type1, ContentType type2)
1139 {
1140 #if defined(WITH_ZLIB)
1141 std::bitset<CONTENT_TYPE_END> types;
1142 _network_content_client.Clear();
1143 if (cv == nullptr) {
1144 assert(type1 != CONTENT_TYPE_END || type2 == CONTENT_TYPE_END);
1145 assert(type1 == CONTENT_TYPE_END || type1 != type2);
1146 _network_content_client.RequestContentList(type1);
1147 if (type2 != CONTENT_TYPE_END) _network_content_client.RequestContentList(type2);
1148
1149 if (type1 != CONTENT_TYPE_END) types[type1] = true;
1150 if (type2 != CONTENT_TYPE_END) types[type2] = true;
1151 } else {
1152 _network_content_client.RequestContentList(cv, true);
1153 }
1154
1155 DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST);
1156 new NetworkContentListWindow(&_network_content_list_desc, cv != nullptr, types);
1157 #else
1158 ShowErrorMessage(STR_CONTENT_NO_ZLIB, STR_CONTENT_NO_ZLIB_SUB, WL_ERROR);
1159 /* Connection failed... clean up the mess */
1160 if (cv != nullptr) {
1161 for (ContentInfo *ci : *cv) delete ci;
1162 }
1163 #endif /* WITH_ZLIB */
1164 }
WID_NCL_NAME
@ WID_NCL_NAME
'Name' button.
Definition: network_content_widget.h:30
ContentTextfileWindow::ci
const ContentInfo * ci
View the textfile of this ContentInfo.
Definition: network_content_gui.cpp:41
NetworkContentDownloadStatusWindow::OnDownloadProgress
void OnDownloadProgress(const ContentInfo *ci, int bytes) override
We have progress in the download of a file.
Definition: network_content_gui.cpp:273
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:718
ContentInfo::IsSelected
bool IsSelected() const
Is the state either selected or autoselected?
Definition: tcp_content.cpp:73
NetworkContentListWindow::NameSorter
static bool NameSorter(const ContentInfo *const &a, const ContentInfo *const &b)
Sort content by name.
Definition: network_content_gui.cpp:407
WC_SAVELOAD
@ WC_SAVELOAD
Saveload window; Window numbers:
Definition: window_type.h:137
NetworkContentListWindow::OnEditboxChanged
void OnEditboxChanged(int wid) override
The text in an editbox has been edited.
Definition: network_content_gui.cpp:936
WD_FRAMERECT_TOP
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:62
ContentCallback
Callbacks for notifying others about incoming data.
Definition: network_content.h:27
ContentInfo::tag_count
uint8 tag_count
Number of tags.
Definition: tcp_content.h:77
InvalidateWindowData
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
Definition: window.cpp:3321
WID_NCL_DETAILS
@ WID_NCL_DETAILS
Panel with content details.
Definition: network_content_widget.h:35
NetworkContentListWindow::OnConnect
void OnConnect(bool success) override
Callback for when the connection has finished.
Definition: network_content_gui.cpp:964
TextfileWindow::LoadTextfile
virtual void LoadTextfile(const char *textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
Definition: textfile_gui.cpp:317
GUIList::SortType
uint8 SortType() const
Get the sorttype of the list.
Definition: sortlist_type.h:93
ContentInfo::GetTextfile
const char * GetTextfile(TextfileType type) const
Search a textfile file next to this file in the content list.
Definition: tcp_content.cpp:101
BaseNetworkContentDownloadStatusWindow::name
char name[48]
The current name of the downloaded file.
Definition: network_content_gui.h:26
ContentInfo::type
ContentType type
Type of content.
Definition: tcp_content.h:65
WID_NCL_MATRIX
@ WID_NCL_MATRIX
Panel with list of content.
Definition: network_content_widget.h:32
WD_MATRIX_RIGHT
@ WD_MATRIX_RIGHT
Offset at right of a matrix cell.
Definition: window_gui.h:77
WChar
char32_t WChar
Type for wide characters, i.e.
Definition: string_type.h:35
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3220
ClientNetworkContentSocketHandler::End
ConstContentIterator End() const
Get the end of the content inf iterator.
Definition: network_content.h:136
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1094
SortButtonState
SortButtonState
State of a sort direction button.
Definition: window_gui.h:222
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
Scrollbar::GetCapacity
uint16 GetCapacity() const
Gets the number of visible elements of the scrollbar.
Definition: widget_type.h:621
NetworkContentListWindow::StateSorter
static bool StateSorter(const ContentInfo *const &a, const ContentInfo *const &b)
Sort content by state.
Definition: network_content_gui.cpp:424
ContentType
ContentType
The values in the enum are important; they are used as database 'keys'.
Definition: tcp_content.h:21
Window::DrawSortButtonState
void DrawSortButtonState(int widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
Definition: widget.cpp:636
GUIList::Sort
bool Sort(Comp compare)
Sort the list.
Definition: sortlist_type.h:247
Window::GetScrollbar
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:309
NetworkContentListWindow::GUIContentList
GUIList< const ContentInfo *, ContentListFilterData & > GUIContentList
List with content infos.
Definition: network_content_gui.cpp:300
NetworkContentDownloadStatusWindow::NetworkContentDownloadStatusWindow
NetworkContentDownloadStatusWindow()
Create a new download window based on a list of content information with flags whether to download th...
Definition: network_content_gui.cpp:169
StringFilter::IsEmpty
bool IsEmpty() const
Check whether any filter words were entered.
Definition: stringfilter_type.h:59
ContentInfo::upgrade
bool upgrade
This item is an upgrade.
Definition: tcp_content.h:80
_network_content_download_status_window_desc
static WindowDesc _network_content_download_status_window_desc(WDP_CENTER, nullptr, 0, 0, WC_NETWORK_STATUS_WINDOW, WC_NONE, WDF_MODAL, _nested_network_content_download_status_window_widgets, lengthof(_nested_network_content_download_status_window_widgets))
Window description for the download window.
ContentInfo::DOES_NOT_EXIST
@ DOES_NOT_EXIST
The content does not exist in the content system.
Definition: tcp_content.h:61
CONTENT_TYPE_BASE_SOUNDS
@ CONTENT_TYPE_BASE_SOUNDS
The content consists of base sounds.
Definition: tcp_content.h:29
StringFilter::SetFilterTerm
void SetFilterTerm(const char *str)
Set the term to filter on.
Definition: stringfilter.cpp:27
GUIList::SetFilterType
void SetFilterType(uint8 n_type)
Set the filtertype of the list.
Definition: sortlist_type.h:155
WD_MATRIX_TOP
@ WD_MATRIX_TOP
Offset at top of a matrix cell.
Definition: window_gui.h:78
NetworkContentListWindow::OpenExternalSearch
void OpenExternalSearch()
Search external websites for content.
Definition: network_content_gui.cpp:322
ScanScenarios
void ScanScenarios()
Force a (re)scan of the scenarios.
Definition: fios.cpp:748
NetworkContentListWindow::OnDownloadComplete
void OnDownloadComplete(ContentID cid) override
We have finished downloading a file.
Definition: network_content_gui.cpp:958
Filtering::state
bool state
Filter on/off.
Definition: sortlist_type.h:36
Scrollbar::ScrollTowards
void ScrollTowards(int position)
Scroll towards the given position; if the item is visible nothing happens, otherwise it will be shown...
Definition: widget_type.h:730
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
TarScanner::DoScan
uint DoScan(Subdirectory sd)
Perform the scanning of a particular subdirectory.
Definition: fileio.cpp:569
Scrollbar::GetScrolledRowFromWidget
int GetScrolledRowFromWidget(int clickpos, const Window *const w, int widget, int padding=0, int line_height=-1) const
Compute the row of a scrolled widget that a user clicked in.
Definition: widget.cpp:1966
SA_RIGHT
@ SA_RIGHT
Right align the text (must be a single bit).
Definition: gfx_func.h:98
CONTENT_TYPE_AI
@ CONTENT_TYPE_AI
The content consists of an AI.
Definition: tcp_content.h:25
GUIList< const ContentInfo *, ContentListFilterData & >
ContentInfo::tags
char(* tags)[32]
Malloced array of tags (strings)
Definition: tcp_content.h:78
BaseNetworkContentDownloadStatusWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: network_content_gui.cpp:117
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:63
Window::CreateNestedTree
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1832
ContentTextfileWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: network_content_gui.cpp:66
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
NetworkContentListWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: network_content_gui.cpp:946
NetworkContentDownloadStatusWindow::receivedTypes
std::vector< ContentType > receivedTypes
Types we received so we can update their cache.
Definition: network_content_gui.cpp:162
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
CONTENT_TYPE_BASE_GRAPHICS
@ CONTENT_TYPE_BASE_GRAPHICS
The content consists of base graphics.
Definition: tcp_content.h:23
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:57
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1133
ContentVector
std::vector< ContentInfo * > ContentVector
Vector with content info.
Definition: network_content.h:17
ContentListFilterData::types
std::bitset< CONTENT_TYPE_END > types
Content types displayed.
Definition: network_content_gui.cpp:288
include
bool include(std::vector< T > &vec, const T &item)
Helper function to append an item to a vector if it is not already contained Consider using std::set,...
Definition: smallvec_type.hpp:27
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:669
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:929
WID_NCL_SCROLLBAR
@ WID_NCL_SCROLLBAR
Scrollbar of matrix.
Definition: network_content_widget.h:33
BaseNetworkContentDownloadStatusWindow::cur_id
uint32 cur_id
The current ID of the downloaded file.
Definition: network_content_gui.h:25
DrawString
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.
Definition: gfx.cpp:640
NetworkContentListWindow::~NetworkContentListWindow
~NetworkContentListWindow()
Free everything we allocated.
Definition: network_content_gui.cpp:553
NetworkContentListWindow::OnKeyPress
EventState OnKeyPress(WChar key, uint16 keycode) override
A key has been pressed.
Definition: network_content_gui.cpp:864
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
BaseNetworkContentDownloadStatusWindow
Base window for showing the download status of content.
Definition: network_content_gui.h:18
BaseNetworkContentDownloadStatusWindow::downloaded_files
uint downloaded_files
Number of files downloaded.
Definition: network_content_gui.h:23
StringFilter::AddLine
void AddLine(const char *str)
Pass another text line from the current item to the filter.
Definition: stringfilter.cpp:104
NetworkContentListWindow::EDITBOX_MAX_SIZE
static const uint EDITBOX_MAX_SIZE
Maximum size of the editbox in characters.
Definition: network_content_gui.cpp:302
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition: gfx_func.h:106
ContentInfo::filename
char filename[48]
Filename (for the .tar.gz; only valid on download)
Definition: tcp_content.h:68
ClientNetworkContentSocketHandler::Clear
void Clear()
Clear all downloaded content information.
Definition: network_content.cpp:1033
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_func.h:97
GUIList::SetSortType
void SetSortType(uint8 n_type)
Set the sorttype of the list.
Definition: sortlist_type.h:103
NetworkContentListWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: network_content_gui.cpp:586
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:588
TextfileWindow::file_type
TextfileType file_type
Type of textfile to view.
Definition: textfile_gui.h:22
TFT_CHANGELOG
@ TFT_CHANGELOG
NewGRF changelog.
Definition: textfile_type.h:18
ConstContentIterator
const typedef ContentInfo *const * ConstContentIterator
Iterator for the constant content vector.
Definition: network_content.h:24
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:199
NetworkContentListWindow::checkbox_size
Dimension checkbox_size
Size of checkbox/"blot" sprite.
Definition: network_content_gui.cpp:312
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:909
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1013
NetworkContentListWindow::NetworkContentListWindow
NetworkContentListWindow(WindowDesc *desc, bool select_all, const std::bitset< CONTENT_TYPE_END > &types)
Create the content list window.
Definition: network_content_gui.cpp:519
QueryString
Data stored about a string that can be modified in the GUI.
Definition: querystring_gui.h:20
CONTENT_TYPE_BASE_MUSIC
@ CONTENT_TYPE_BASE_MUSIC
The content consists of base music.
Definition: tcp_content.h:30
_nested_network_content_list_widgets
static const NWidgetPart _nested_network_content_list_widgets[]
The widgets for the content list.
Definition: network_content_gui.cpp:1047
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:842
GUIList::SetFilterFuncs
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
Definition: sortlist_type.h:341
WN_NETWORK_WINDOW_CONTENT_LIST
@ WN_NETWORK_WINDOW_CONTENT_LIST
Network content list.
Definition: window_type.h:29
WD_INSET_TOP
@ WD_INSET_TOP
Top offset of string.
Definition: window_gui.h:46
Textbuf::buf
char *const buf
buffer in which text is saved
Definition: textbuf_type.h:32
Window::querystrings
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition: window_gui.h:328
ShowErrorMessage
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.
Definition: error_gui.cpp:372
DrawStringMultiLine
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.
Definition: gfx.cpp:763
GetContentInfoSubDir
Subdirectory GetContentInfoSubDir(ContentType type)
Helper to get the subdirectory a ContentInfo is located in.
Definition: tcp_content.cpp:245
NetworkContentListWindow::DrawMatrix
void DrawMatrix(const Rect &r) const
Draw/fill the matrix with the list of content to download.
Definition: network_content_gui.cpp:624
NetworkContentListWindow::TagNameFilter
static bool CDECL TagNameFilter(const ContentInfo *const *a, ContentListFilterData &filter)
Filter content by tags/name.
Definition: network_content_gui.cpp:441
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
WN_GAME_OPTIONS_GAME_OPTIONS
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
Definition: window_type.h:18
WindowDesc
High level window description.
Definition: window_gui.h:166
ClientNetworkContentSocketHandler::RequestContentList
void RequestContentList(ContentType type)
Request the content list for the given type.
Definition: network_content.cpp:185
NetworkContentListWindow::UpdateFilterState
bool UpdateFilterState()
Update filter state based on current window state.
Definition: network_content_gui.cpp:490
NetworkContentListWindow::BuildContentTypeStringList
friend void BuildContentTypeStringList()
Build array of all strings corresponding to the content types.
Definition: network_content_gui.cpp:1039
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:428
GUIList::IsDescSortOrder
bool IsDescSortOrder() const
Check if the sort order is descending.
Definition: sortlist_type.h:223
Listing
Data structure describing how to show the list (what sort direction and criteria).
Definition: sortlist_type.h:30
GUIList::SetFilterState
void SetFilterState(bool state)
Enable or disable the filter.
Definition: sortlist_type.h:302
ContentInfo::UNSELECTED
@ UNSELECTED
The content has not been selected.
Definition: tcp_content.h:57
DRAW_STRING_BUFFER
static const int DRAW_STRING_BUFFER
Size of the buffer used for drawing strings.
Definition: gfx_func.h:85
NetworkContentListWindow::vscroll
Scrollbar * vscroll
Cache of the vertical scrollbar.
Definition: network_content_gui.cpp:317
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:322
WID_NCL_UNSELECT
@ WID_NCL_UNSELECT
'Unselect all' button.
Definition: network_content_widget.h:40
CONTENT_TYPE_HEIGHTMAP
@ CONTENT_TYPE_HEIGHTMAP
The content consists of a heightmap.
Definition: tcp_content.h:28
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1861
WWT_EDITBOX
@ WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:69
NetworkContentListWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: network_content_gui.cpp:980
WD_INSET_RIGHT
@ WD_INSET_RIGHT
Right offset of string.
Definition: window_gui.h:45
GUIList< const ContentInfo *, ContentListFilterData & >::SortFunction
bool SortFunction(const const ContentInfo * &, const const ContentInfo * &)
Signature of sort function.
Definition: sortlist_type.h:48
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:984
BaseNetworkContentDownloadStatusWindow::total_files
uint total_files
Number of files to download.
Definition: network_content_gui.h:22
GUIList::SetListing
void SetListing(Listing l)
Import sort conditions.
Definition: sortlist_type.h:130
WID_NCL_DOWNLOAD
@ WID_NCL_DOWNLOAD
'Download' button.
Definition: network_content_widget.h:43
WD_FRAMERECT_LEFT
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:60
BaseNetworkContentDownloadStatusWindow::total_bytes
uint total_bytes
Number of bytes to download.
Definition: network_content_gui.h:20
ClientNetworkContentSocketHandler::UnselectAll
void UnselectAll()
Unselect everything that we've not downloaded so far.
Definition: network_content.cpp:874
NetworkContentListWindow::content
GUIContentList content
List with content.
Definition: network_content_gui.cpp:308
NetworkContentListWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: network_content_gui.cpp:778
ContentInfo
Container for all important information about a piece of content.
Definition: tcp_content.h:54
NetworkContentListWindow::ScrollToSelected
void ScrollToSelected()
Make sure that the currently selected content info is within the visible part of the matrix.
Definition: network_content_gui.cpp:501
IsInsideBS
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.
Definition: math_func.hpp:188
WD_PAR_VSEP_NORMAL
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
Definition: window_gui.h:137
_accepted_external_search
static bool _accepted_external_search
Whether the user accepted to enter external websites during this session.
Definition: network_content_gui.cpp:36
WD_FRAMERECT_RIGHT
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:61
find_index
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_...
Definition: smallvec_type.hpp:44
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:719
WD_FRAMERECT_BOTTOM
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:63
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:102
ShowNetworkContentListWindow
void ShowNetworkContentListWindow(ContentVector *cv, ContentType type1, ContentType type2)
Show the content list window with a given set of content.
Definition: network_content_gui.cpp:1138
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:124
NetworkContentDownloadStatusWindow::~NetworkContentDownloadStatusWindow
~NetworkContentDownloadStatusWindow()
Free whatever we've allocated.
Definition: network_content_gui.cpp:175
CONTENT_FILTER_TEXT
@ CONTENT_FILTER_TEXT
Filter by query sting.
Definition: network_content_gui.cpp:293
SetMatrixDataTip
static NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1031
NetworkContentListWindow::SortContentList
void SortContentList()
Sort the content list.
Definition: network_content_gui.cpp:432
ContentInfo::md5sum
byte md5sum[16]
The MD5 checksum.
Definition: tcp_content.h:74
Filtering
Data structure describing what to show in the list (filter criteria).
Definition: sortlist_type.h:35
WID_NCL_CHECKBOX
@ WID_NCL_CHECKBOX
Button above checkboxes.
Definition: network_content_widget.h:28
ContentListFilterData::string_filter
StringFilter string_filter
Text filter of content list.
Definition: network_content_gui.cpp:287
NetworkContentListWindow::filter_data
ContentListFilterData filter_data
Filter for content list.
Definition: network_content_gui.cpp:310
BuildContentTypeStringList
void BuildContentTypeStringList()
Build array of all strings corresponding to the content types.
Definition: network_content_gui.cpp:1039
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:392
Window::parent
Window * parent
Parent window.
Definition: window_gui.h:337
CONTENT_TYPE_GAME
@ CONTENT_TYPE_GAME
The content consists of a game script.
Definition: tcp_content.h:31
WID_NCL_BACKGROUND
@ WID_NCL_BACKGROUND
Resize button.
Definition: network_content_widget.h:23
CONTENT_TYPE_SCENARIO
@ CONTENT_TYPE_SCENARIO
The content consists of a scenario.
Definition: tcp_content.h:27
ClientNetworkContentSocketHandler::Close
void Close() override
Disconnect from the content server.
Definition: network_content.cpp:767
WID_NCL_FILTER_CAPT
@ WID_NCL_FILTER_CAPT
Caption for the filter editbox.
Definition: network_content_widget.h:25
BaseNetworkContentDownloadStatusWindow::~BaseNetworkContentDownloadStatusWindow
~BaseNetworkContentDownloadStatusWindow()
Free everything associated with this window.
Definition: network_content_gui.cpp:112
BaseNetworkContentDownloadStatusWindow::OnDownloadProgress
void OnDownloadProgress(const ContentInfo *ci, int bytes) override
We have progress in the download of a file.
Definition: network_content_gui.cpp:146
WID_NCL_FILTER
@ WID_NCL_FILTER
Filter editbox.
Definition: network_content_widget.h:26
WD_INSET_LEFT
@ WD_INSET_LEFT
Left offset of string.
Definition: window_gui.h:44
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:60
ContentInfo::SELECTED
@ SELECTED
The content has been manually selected.
Definition: tcp_content.h:58
CONTENT_TYPE_AI_LIBRARY
@ CONTENT_TYPE_AI_LIBRARY
The content consists of an AI library.
Definition: tcp_content.h:26
DrawSprite
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:978
WDF_MODAL
@ WDF_MODAL
The window is a modal child of some other window, meaning the parent is 'inactive'.
Definition: window_gui.h:209
WID_NCL_CANCEL
@ WID_NCL_CANCEL
'Cancel' button.
Definition: network_content_widget.h:42
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
_nested_network_content_download_status_window_widgets
static const NWidgetPart _nested_network_content_download_status_window_widgets[]
Nested widgets for the download window.
Definition: network_content_gui.cpp:82
WID_NCDS_BACKGROUND
@ WID_NCDS_BACKGROUND
Background of the window.
Definition: network_content_widget.h:17
Window::IsWidgetFocused
bool IsWidgetFocused(byte widget_index) const
Check if given widget is focused within this window.
Definition: window_gui.h:432
ClientNetworkContentSocketHandler::RemoveCallback
void RemoveCallback(ContentCallback *cb)
Remove a callback.
Definition: network_content.h:143
ContentInfo::url
char url[96]
URL related to the content.
Definition: tcp_content.h:71
Window::SetFocusedWidget
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
Definition: window.cpp:495
ClientNetworkContentSocketHandler::DownloadSelectedContent
void DownloadSelectedContent(uint &files, uint &bytes, bool fallback=false)
Actually begin downloading the content we selected.
Definition: network_content.cpp:292
GfxFillRect
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.
Definition: gfx.cpp:114
NetworkContentListWindow::TypeOrSelectedFilter
static bool CDECL TypeOrSelectedFilter(const ContentInfo *const *a, ContentListFilterData &filter)
Filter content by type, but still show content selected for download.
Definition: network_content_gui.cpp:452
ResizeInfo::step_height
uint step_height
Step-size of height resize changes.
Definition: window_gui.h:218
WID_NCL_SEL_ALL_UPDATE
@ WID_NCL_SEL_ALL_UPDATE
NWID_SELECTION widget for select all/update buttons..
Definition: network_content_widget.h:45
GUIList::ToggleSortOrder
void ToggleSortOrder()
Toggle the sort order Since that is the worst condition for the sort function reverse the list here.
Definition: sortlist_type.h:233
TFT_README
@ TFT_README
NewGRF readme.
Definition: textfile_type.h:17
Window::InvalidateData
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Definition: window.cpp:3261
CONTENT_TYPE_GAME_LIBRARY
@ CONTENT_TYPE_GAME_LIBRARY
The content consists of a GS library.
Definition: tcp_content.h:32
CONTENT_TYPE_NEWGRF
@ CONTENT_TYPE_NEWGRF
The content consists of a NewGRF.
Definition: tcp_content.h:24
NetworkContentListWindow::UpdateWidgetSize
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.
Definition: network_content_gui.cpp:558
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
NetworkContentDownloadStatusWindow
Window for showing the download status of content.
Definition: network_content_gui.cpp:160
WID_NCL_SEARCH_EXTERNAL
@ WID_NCL_SEARCH_EXTERNAL
Search external sites for missing NewGRF.
Definition: network_content_widget.h:46
TarScanner::NONE
@ NONE
Scan nothing.
Definition: fileio_func.h:86
PC_GREY
static const uint8 PC_GREY
Grey palette colour.
Definition: gfx_func.h:208
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:913
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:66
ContentInfo::description
char description[512]
Description of the content.
Definition: tcp_content.h:72
GUIList::NeedRebuild
bool NeedRebuild() const
Check if a rebuild is needed.
Definition: sortlist_type.h:362
_network_content_client
ClientNetworkContentSocketHandler _network_content_client
The client we use to connect to the server.
Definition: network_content.cpp:35
TFT_LICENSE
@ TFT_LICENSE
NewGRF license.
Definition: textfile_type.h:19
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
NetworkContentListWindow::ExternalSearchDisclaimerCallback
static void ExternalSearchDisclaimerCallback(Window *w, bool accepted)
Callback function for disclaimer about entering external websites.
Definition: network_content_gui.cpp:369
ShowQuery
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...
Definition: misc_gui.cpp:1274
RequestNewGRFScan
void RequestNewGRFScan(NewGRFScanCallback *callback)
Request a new NewGRF scan.
Definition: openttd.cpp:1454
SBS_DOWN
@ SBS_DOWN
Sort ascending.
Definition: window_gui.h:224
QueryString::cancel_button
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
Definition: querystring_gui.h:28
WC_GAME_OPTIONS
@ WC_GAME_OPTIONS
Game options window; Window numbers:
Definition: window_type.h:606
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:998
TarScanner::SCENARIO
@ SCENARIO
Scan for scenarios and heightmaps.
Definition: fileio_func.h:90
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
DeleteWindowById
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1165
ContentInfo::ALREADY_HERE
@ ALREADY_HERE
The content is already at the client side.
Definition: tcp_content.h:60
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:175
ContentListFilterData
Filter data for NetworkContentListWindow.
Definition: network_content_gui.cpp:286
NetworkContentListWindow::list_pos
int list_pos
Our position in the list.
Definition: network_content_gui.cpp:315
ClientNetworkContentSocketHandler::ReverseLookupTreeDependency
void ReverseLookupTreeDependency(ConstContentVector &tree, const ContentInfo *child) const
Reverse lookup the dependencies of all parents over a given child.
Definition: network_content.cpp:923
NetworkContentListWindow::OnReceiveContentInfo
void OnReceiveContentInfo(const ContentInfo *rci) override
We received a content info.
Definition: network_content_gui.cpp:951
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:179
ContentInfo::AUTOSELECTED
@ AUTOSELECTED
The content has been selected as dependency.
Definition: tcp_content.h:59
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1113
PC_DARK_BLUE
static const uint8 PC_DARK_BLUE
Dark blue palette colour.
Definition: gfx_func.h:226
ClientNetworkContentSocketHandler::ToggleSelectedState
void ToggleSelectedState(const ContentInfo *ci)
Toggle the state of a content info and check its dependencies.
Definition: network_content.cpp:882
WC_NETWORK_WINDOW
@ WC_NETWORK_WINDOW
Network window; Window numbers:
Definition: window_type.h:466
GUIList< const ContentInfo *, ContentListFilterData & >::FilterFunction
bool CDECL FilterFunction(const const ContentInfo * *, ContentListFilterData &)
Signature of filter function.
Definition: sortlist_type.h:49
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:946
NetworkContentListWindow::last_sorting
static Listing last_sorting
The last sorting setting.
Definition: network_content_gui.cpp:304
WC_NETWORK_STATUS_WINDOW
@ WC_NETWORK_STATUS_WINDOW
Network status window; Window numbers:
Definition: window_type.h:485
StringFilter::ResetState
void ResetState()
Reset the matching state to process a new item.
Definition: stringfilter.cpp:88
_network_content_list_desc
static WindowDesc _network_content_list_desc(WDP_CENTER, "list_content", 630, 460, WC_NETWORK_WINDOW, WC_NONE, 0, _nested_network_content_list_widgets, lengthof(_nested_network_content_list_widgets))
Window description of the content list.
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
network_content_gui.h
WID_NCL_TEXTFILE
@ WID_NCL_TEXTFILE
Open readme, changelog (+1) or license (+2) of a file in the content window.
Definition: network_content_widget.h:36
NetworkContentListWindow::auto_select
bool auto_select
Automatically select all content when the meta-data becomes available.
Definition: network_content_gui.cpp:309
NetworkContentListWindow::filesize_sum
uint filesize_sum
The sum of all selected file sizes.
Definition: network_content_gui.cpp:316
NetworkContentDownloadStatusWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: network_content_gui.cpp:259
EventState
EventState
State of handling an event.
Definition: window_type.h:717
BaseMedia< GraphicsSet >::FindSets
static uint FindSets()
Do the scan for files.
Definition: base_media_base.h:189
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:630
GUIList::SetFiltering
void SetFiltering(Filtering f)
Import filter conditions.
Definition: sortlist_type.h:181
StringFilter::GetState
bool GetState() const
Get the matching state of the current item.
Definition: stringfilter_type.h:69
ContentInfo::dependency_count
uint8 dependency_count
Number of dependencies.
Definition: tcp_content.h:75
NetworkContentListWindow::TypeSorter
static bool TypeSorter(const ContentInfo *const &a, const ContentInfo *const &b)
Sort content by type.
Definition: network_content_gui.cpp:413
seprintf
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Definition: string.cpp:442
GUIList::Filter
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
Definition: sortlist_type.h:318
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1848
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
WL_ERROR
@ WL_ERROR
Errors (eg. saving/loading failed)
Definition: error.h:24
ContentInfo::version
char version[16]
Version of the content.
Definition: tcp_content.h:70
WID_NCDS_CANCELOK
@ WID_NCDS_CANCELOK
(Optional) Cancel/OK button.
Definition: network_content_widget.h:18
BaseNetworkContentDownloadStatusWindow::downloaded_bytes
uint downloaded_bytes
Number of bytes downloaded.
Definition: network_content_gui.h:21
QueryString::ACTION_CLEAR
static const int ACTION_CLEAR
Clear editbox.
Definition: querystring_gui.h:24
GUIList::ForceResort
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
Definition: sortlist_type.h:213
ClientNetworkContentSocketHandler::AddCallback
void AddCallback(ContentCallback *cb)
Add a callback to this class.
Definition: network_content.h:141
DrawFrameRect
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition: widget.cpp:175
ContentInfo::state
State state
Whether the content info is selected (for download)
Definition: tcp_content.h:79
ContentInfo::unique_id
uint32 unique_id
Unique ID; either GRF ID or shortname.
Definition: tcp_content.h:73
WD_MATRIX_BOTTOM
@ WD_MATRIX_BOTTOM
Offset at bottom of a matrix cell.
Definition: window_gui.h:79
NetworkContentListWindow::filter_editbox
QueryString filter_editbox
Filter editbox;.
Definition: network_content_gui.cpp:311
BaseNetworkContentDownloadStatusWindow::BaseNetworkContentDownloadStatusWindow
BaseNetworkContentDownloadStatusWindow(WindowDesc *desc)
Create the window with the given description.
Definition: network_content_gui.cpp:103
CONTENT_TYPE_BEGIN
@ CONTENT_TYPE_BEGIN
Helper to mark the begin of the types.
Definition: tcp_content.h:22
GUIList::ForceRebuild
void ForceRebuild()
Force that a rebuild is needed.
Definition: sortlist_type.h:370
NetworkContentListWindow::DrawDetails
void DrawDetails(const Rect &r) const
Helper function to draw the details part of this window.
Definition: network_content_gui.cpp:670
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:367
WID_NCL_TYPE
@ WID_NCL_TYPE
'Type' button.
Definition: network_content_widget.h:29
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, int widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition: widget.cpp:1980
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1075
ClientNetworkContentSocketHandler::SelectAll
void SelectAll()
Select everything we can select.
Definition: network_content.cpp:852
TarScanner::BASESET
@ BASESET
Scan for base sets.
Definition: fileio_func.h:87
ContentID
ContentID
Unique identifier for the content.
Definition: tcp_content.h:49
CONTENT_FILTER_TYPE_OR_SELECTED
@ CONTENT_FILTER_TYPE_OR_SELECTED
Filter by being of displayed type or selected for download.
Definition: network_content_gui.cpp:294
strnatcmp
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
Definition: string.cpp:625
NetworkContentListWindow
Window that lists the content that's at the content server.
Definition: network_content_gui.cpp:298
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:982
TextfileWindow
Window for displaying a textfile.
Definition: textfile_gui.h:21
NetworkContentListWindow::BuildContentList
void BuildContentList()
(Re)build the network game list as its amount has changed because an item has been added or deleted f...
Definition: network_content_gui.cpp:381
GUIList::GetFiltering
Filtering GetFiltering() const
Export current filter conditions.
Definition: sortlist_type.h:167
Window
Data structure for an opened window.
Definition: window_gui.h:276
GUIList::RebuildDone
void RebuildDone()
Notify the sortlist that the rebuild is done.
Definition: sortlist_type.h:380
TextfileType
TextfileType
Additional text files accompanying Tar archives.
Definition: textfile_type.h:14
md5sumToString
char * md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
Convert the md5sum to a hexadecimal string representation.
Definition: string.cpp:460
WD_MATRIX_LEFT
@ WD_MATRIX_LEFT
Offset at left of a matrix cell.
Definition: window_gui.h:76
NetworkContentListWindow::selected
const ContentInfo * selected
The selected content info.
Definition: network_content_gui.cpp:314
ContentInfo::name
char name[32]
Name of the content.
Definition: tcp_content.h:69
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:602
SBS_UP
@ SBS_UP
Sort descending.
Definition: window_gui.h:225
ClientNetworkContentSocketHandler::SelectUpgrade
void SelectUpgrade()
Select everything that's an update for something we've got.
Definition: network_content.cpp:863
strecpy
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
Definition: string.cpp:112
ContentInfo::dependencies
ContentID * dependencies
Malloced array of dependencies (unique server side ids)
Definition: tcp_content.h:76
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:78
WID_TF_CAPTION
@ WID_TF_CAPTION
The caption of the window.
Definition: misc_widget.h:51
ContentInfo::id
ContentID id
Unique (server side) ID for the content.
Definition: tcp_content.h:66
AI::Rescan
static void Rescan()
Rescans all searchpaths for available AIs.
Definition: ai_core.cpp:348
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
WID_NCL_SELECT_UPDATE
@ WID_NCL_SELECT_UPDATE
'Select updates' button.
Definition: network_content_widget.h:39
BringWindowToFrontById
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
Definition: window.cpp:1262
TarScanner::Mode
Mode
The mode of tar scanning.
Definition: fileio_func.h:85
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:172
WC_TEXTFILE
@ WC_TEXTFILE
textfile; Window numbers:
Definition: window_type.h:180
WID_NCL_OPEN_URL
@ WID_NCL_OPEN_URL
'Open url' button.
Definition: network_content_widget.h:41
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:383
WD_PAR_VSEP_WIDE
@ WD_PAR_VSEP_WIDE
Large amount of vertical space between two paragraphs of text.
Definition: window_gui.h:138
ConstContentVector
std::vector< const ContentInfo * > ConstContentVector
Vector with constant content info.
Definition: network_content.h:19
NetworkContentListWindow::content_type_strs
static char content_type_strs[CONTENT_TYPE_END][64]
Cached strings for all content types.
Definition: network_content_gui.cpp:319
NetworkContentListWindow::FilterContentList
void FilterContentList()
Filter the content list.
Definition: network_content_gui.cpp:460
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition: window_gui.h:155
NetworkContentListWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: network_content_gui.cpp:603
WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD
@ WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD
Network content download status.
Definition: window_type.h:33
CONTENT_TYPE_END
@ CONTENT_TYPE_END
Helper to mark the end of the types.
Definition: tcp_content.h:33
StringFilter
String filter and state.
Definition: stringfilter_type.h:31
SetDParamStr
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Definition: strings.cpp:286
NetworkContentListWindow::sorter_funcs
static GUIContentList::SortFunction *const sorter_funcs[]
Sorter functions.
Definition: network_content_gui.cpp:306
ContentTextfileWindow
Window for displaying the textfile of an item in the content list.
Definition: network_content_gui.cpp:40
INVALID_STRING_ID
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17
ContentInfo::filesize
uint32 filesize
Size of the file.
Definition: tcp_content.h:67
NetworkContentListWindow::filter_funcs
static GUIContentList::FilterFunction *const filter_funcs[]
Filter functions.
Definition: network_content_gui.cpp:307
ClientNetworkContentSocketHandler::Begin
ConstContentIterator Begin() const
Get the begin of the content inf iterator.
Definition: network_content.h:132
SetMinimalTextLines
static NWidgetPart SetMinimalTextLines(uint8 lines, uint8 spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition: widget_type.h:964
GUIList::SetSortFuncs
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
Definition: sortlist_type.h:270
NetworkContentListWindow::last_filtering
static Filtering last_filtering
The last filtering setting.
Definition: network_content_gui.cpp:305
ContentListFilterCriteria
ContentListFilterCriteria
Filter criteria for NetworkContentListWindow.
Definition: network_content_gui.cpp:292
WID_NCL_SELECT_ALL
@ WID_NCL_SELECT_ALL
'Select all' button.
Definition: network_content_widget.h:38