|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
10 #include "../stdafx.h"
11 #include "../strings_func.h"
12 #include "../gfx_func.h"
13 #include "../window_func.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"
28 #include "table/strings.h"
29 #include "../table/sprites.h"
33 #include "../safeguards.h"
46 this->ConstructWindow();
54 switch (this->ci->
type) {
65 default: NOT_REACHED();
69 void SetStringParameters(
WidgetID widget)
const override
105 Window(desc), downloaded_bytes(0), downloaded_files(0), cur_id(UINT32_MAX)
113 void BaseNetworkContentDownloadStatusWindow::Close([[maybe_unused]]
int data)
138 void BaseNetworkContentDownloadStatusWindow::DrawWidget(
const Rect &r,
WidgetID widget)
const
156 str = STR_CONTENT_DOWNLOAD_COMPLETE;
157 }
else if (!this->
name.empty()) {
161 str = STR_CONTENT_DOWNLOAD_FILE;
163 str = STR_CONTENT_DOWNLOAD_INITIALISE;
171 void BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(
const ContentInfo *ci,
int bytes)
173 if (ci->
id != this->cur_id) {
205 void Close([[maybe_unused]]
int data = 0)
override
208 for (
auto ctype : this->receivedTypes) {
242 for (
auto ctype : this->receivedTypes) {
287 this->BaseNetworkContentDownloadStatusWindow::Close();
290 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
304 void OnDownloadProgress(
const ContentInfo *ci,
int bytes)
override
306 BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(ci, bytes);
319 std::bitset<CONTENT_TYPE_END>
types;
358 url +=
"https://grfsearch.openttd.org/?";
360 if (this->auto_select) {
361 url +=
"do=searchgrfid&q=";
367 if (!first) url.push_back(
',');
373 url +=
"do=searchtext&q=";
376 for (
const char *search = this->filter_editbox.text.
buf; *search !=
'\0'; search++) {
378 if (*search ==
'\'' || *search ==
'"')
continue;
381 if (*search < 0x30) {
382 fmt::format_to(std::back_inserter(url),
"%{:02X}", *search);
384 url.push_back(*search);
412 this->content.clear();
414 bool all_available =
true;
418 this->content.push_back(*iter);
424 this->content.shrink_to_fit();
428 this->vscroll->
SetCount(this->content.size());
460 if (!this->content.
Sort())
return;
462 int idx =
find_index(this->content, this->selected);
463 if (idx >= 0) this->list_pos = idx;
479 if (filter.
types.none())
return true;
480 if (filter.
types[(*a)->type])
return true;
488 bool changed =
false;
491 changed |= this->content.
Filter(this->filter_data);
493 if (this->filter_data.
types.any()) {
495 changed |= this->content.
Filter(this->filter_data);
497 if (!changed)
return;
500 int idx =
find_index(this->content, this->selected);
502 this->list_pos = idx;
507 this->selected =
nullptr;
519 if (new_state != old_params.
state) {
522 return new_state != old_params.
state;
528 if (this->selected ==
nullptr)
return;
561 this->filter_data.
types = types;
575 void Close([[maybe_unused]]
int data = 0)
override
590 size->width = this->checkbox_size.width + padding.width;
598 size->width = d.width + padding.width;
604 size->height = 10 *
resize->height;
610 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
651 int sprite_y_offset = (this->resize.step_height - this->checkbox_size.height) / 2;
655 auto iter = this->content.begin() + this->vscroll->
GetPosition();
657 auto end = (last < this->content.size()) ? this->content.begin() + last : this->content.end();
659 for (; iter != end; iter++) {
672 default: NOT_REACHED();
674 DrawSprite(sprite, pal, checkbox.left + (sprite == SPR_BLOT ? 3 : 2), mr.top + sprite_y_offset + (sprite == SPR_BLOT ? 0 : 1));
679 DrawString(name.left, name.right, mr.top + text_y_offset, ci->
name, TC_BLACK);
680 mr = mr.
Translate(0, this->resize.step_height);
695 tr.top += HEADER_HEIGHT;
705 if (this->selected ==
nullptr)
return;
722 if (!this->selected->
version.empty()) {
732 if (!this->selected->
url.empty()) {
752 if (ci->
id != cid)
continue;
754 if (!buf.empty()) buf +=
", ";
755 buf += (*iter)->
name;
763 if (!this->selected->
tags.empty()) {
766 for (
auto &tag : this->selected->
tags) {
767 if (!buf.empty()) buf +=
", ";
783 if (!buf.empty()) buf +=
", ";
793 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
805 if (it == this->content.end())
return;
807 this->selected = *it;
808 this->list_pos = it - this->content.begin();
816 if (this->filter_data.
types.any()) {
829 if (!this->content.empty()) this->list_pos = (int)this->content.size() - this->list_pos - 1;
859 if (this->selected !=
nullptr) {
860 OpenBrowser(this->selected->
url);
878 EventState OnKeyPress([[maybe_unused]] char32_t key, uint16_t keycode)
override
885 if (this->selected !=
nullptr) {
890 if (this->filter_data.
types.any()) {
904 if (this->content.empty()) {
912 this->selected = this->content[this->
list_pos];
926 void OnEditboxChanged(
WidgetID wid)
override
941 void OnReceiveContentInfo(
const ContentInfo *rci)
override
948 void OnDownloadComplete(
ContentID)
override
954 void OnConnect(
bool success)
override
970 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
972 if (!gui_scope)
return;
976 this->filesize_sum = 0;
977 bool show_select_all =
false;
978 bool show_select_upgrade =
false;
987 show_select_all =
true;
988 show_select_upgrade |= ci->
upgrade;
1002 for (
TextfileType tft = TFT_CONTENT_BEGIN; tft < TFT_CONTENT_END; tft++) {
1006 this->GetWidget<NWidgetCore>(
WID_NCL_CANCEL)->widget_data = this->filesize_sum == 0 ? STR_AI_SETTINGS_CLOSE : STR_AI_LIST_CANCEL;
1021 &TypeOrSelectedFilter,
1047 NWidget(
WWT_TEXT, COLOUR_LIGHT_BLUE,
WID_NCL_FILTER_CAPT),
SetFill(1, 0),
SetResize(1, 0),
SetDataTip(STR_CONTENT_FILTER_TITLE, STR_NULL),
SetAlignment(
SA_RIGHT |
SA_VERT_CENTER),
1049 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1060 SetDataTip(STR_CONTENT_TYPE_CAPTION, STR_CONTENT_TYPE_CAPTION_TOOLTIP),
1062 SetDataTip(STR_CONTENT_NAME_CAPTION, STR_CONTENT_NAME_CAPTION_TOOLTIP),
1064 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),
1071 SetDataTip(STR_CONTENT_SELECT_UPDATES_CAPTION, STR_CONTENT_SELECT_UPDATES_CAPTION_TOOLTIP),
1073 SetDataTip(STR_CONTENT_SELECT_ALL_CAPTION, STR_CONTENT_SELECT_ALL_CAPTION_TOOLTIP),
1076 SetDataTip(STR_CONTENT_UNSELECT_ALL_CAPTION, STR_CONTENT_UNSELECT_ALL_CAPTION_TOOLTIP),
1098 SetDataTip(STR_CONTENT_SEARCH_EXTERNAL, STR_CONTENT_SEARCH_EXTERNAL_TOOLTIP),
1103 SetDataTip(STR_CONTENT_DOWNLOAD_CAPTION, STR_CONTENT_DOWNLOAD_CAPTION_TOOLTIP),
1132 #if defined(WITH_ZLIB)
1133 std::bitset<CONTENT_TYPE_END> types;
1135 if (cv ==
nullptr) {
1152 if (cv !=
nullptr) {
@ WID_NCL_CANCEL
'Cancel' button.
const ContentInfo * ci
View the textfile of this ContentInfo.
@ ES_HANDLED
The passed event is handled.
bool IsSelected() const
Is the state either selected or autoselected?
static bool NameSorter(const ContentInfo *const &a, const ContentInfo *const &b)
Sort content by name.
@ WC_SAVELOAD
Saveload window; Window numbers:
@ WID_NCL_SELECT_ALL
'Select all' button.
Callbacks for notifying others about incoming data.
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-...
std::optional< std::string > GetTextfile(TextfileType type) const
Search a textfile file next to this file in the content list.
static const uint8_t PC_DARK_BLUE
Dark blue palette colour.
std::string FormatArrayAsHex(std::span< const byte > data)
Format a byte array into a continuous hex string.
std::string name
Name of the content.
ContentType type
Type of content.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
ConstContentIterator End() const
Get the end of the content inf iterator.
SortButtonState
State of a sort direction button.
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback, bool focus)
Show a confirmation window with standard 'yes' and 'no' buttons The window is aligned to the centre o...
void SetDParamMaxDigits(size_t n, uint count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
@ WID_NCL_TYPE
'Type' button.
Dimensions (a width and height) of a rectangle in 2D.
static bool StateSorter(const ContentInfo *const &a, const ContentInfo *const &b)
Sort content by state.
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
NetworkContentDownloadStatusWindow()
Create a new download window based on a list of content information with flags whether to download th...
void SetFilterState(bool state)
Enable or disable the filter.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
@ CONTENT_TYPE_GAME_LIBRARY
The content consists of a GS library.
bool IsEmpty() const
Check whether any filter words were entered.
bool upgrade
This item is an upgrade.
@ DOES_NOT_EXIST
The content does not exist in the content system.
void SetFilterTerm(const char *str)
Set the term to filter on.
void OpenExternalSearch()
Search external websites for content.
void ScanScenarios()
Force a (re)scan of the scenarios.
@ WID_NCL_NAME
'Name' button.
uint32_t filesize
Size of the file.
uint DoScan(Subdirectory sd)
Perform the scanning of a particular subdirectory.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
GUIList< const ContentInfo *, std::nullptr_t, ContentListFilterData & > GUIContentList
List with content infos.
void OnResize() override
Called after the window got resized.
std::vector< ContentType > receivedTypes
Types we received so we can update their cache.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
@ CONTENT_TYPE_NEWGRF
The content consists of a NewGRF.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
std::vector< ContentInfo * > ContentVector
Vector with content info.
std::bitset< CONTENT_TYPE_END > types
Content types displayed.
bool IsWidgetFocused(WidgetID widget_index) const
Check if given widget is focused within this window.
@ WID_NCL_UNSELECT
'Unselect all' button.
std::string url
URL related to the content.
bool RequestNewGRFScan(NewGRFScanCallback *callback)
Request a new NewGRF scan.
void SetSortType(uint8_t n_type)
Set the sorttype of the list.
int StrNaturalCompare(std::string_view s1, std::string_view s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
@ WID_NCL_TEXTFILE
Open readme, changelog (+1) or license (+2) of a file in the content window.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Base window for showing the download status of content.
uint downloaded_files
Number of files downloaded.
void AddLine(const char *str)
Pass another text line from the current item to the filter.
static const uint EDITBOX_MAX_SIZE
Maximum size of the editbox in characters.
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
@ CONTENT_TYPE_END
Helper to mark the end of the types.
std::string version
Version of the content.
@ SA_RIGHT
Right align the text (must be a single bit).
@ SA_VERT_CENTER
Vertically center the text.
void Clear()
Clear all downloaded content information.
@ WID_NCDS_PROGRESS_TEXT
Text explaining what is happening.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
MD5Hash md5sum
The MD5 checksum.
TextfileType file_type
Type of textfile to view.
@ TFT_CHANGELOG
Content changelog.
const typedef ContentInfo *const * ConstContentIterator
Iterator for the constant content vector.
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
@ WID_NCL_FILTER
Filter editbox.
@ WID_NCL_MATRIX
Panel with list of content.
Dimension checkbox_size
Size of checkbox/"blot" sprite.
ContentType
The values in the enum are important; they are used as database 'keys'.
NetworkContentListWindow(WindowDesc *desc, bool select_all, const std::bitset< CONTENT_TYPE_END > &types)
Create the content list window.
bool NeedRebuild() const
Check if a rebuild is needed.
Data stored about a string that can be modified in the GUI.
@ WN_NETWORK_WINDOW_CONTENT_LIST
Network content list.
char *const buf
buffer in which text is saved
Subdirectory GetContentInfoSubDir(ContentType type)
Helper to get the subdirectory a ContentInfo is located in.
void DrawMatrix(const Rect &r) const
Draw/fill the matrix with the list of content to download.
int find_index(Container const &container, typename Container::const_reference item)
Helper function to get the index of an item Consider using std::set, std::unordered_set or std::flat_...
static bool CDECL TagNameFilter(const ContentInfo *const *a, ContentListFilterData &filter)
Filter content by tags/name.
void OnInit() override
Notification that the nested widget tree gets initialized.
@ WID_NCL_BACKGROUND
Resize button.
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
uint32_t cur_id
The current ID of the downloaded file.
High level window description.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
void RequestContentList(ContentType type)
Request the content list for the given type.
bool UpdateFilterState()
Update filter state based on current window state.
bool include(Container &container, typename Container::const_reference &item)
Helper function to append an item to a container if it is not already contained.
friend void BuildContentTypeStringList()
Build array of all strings corresponding to the content types.
@ CONTENT_TYPE_GAME
The content consists of a game script.
constexpr 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.
Filtering GetFiltering() const
Export current filter conditions.
Data structure describing how to show the list (what sort direction and criteria).
@ UNSELECTED
The content has not been selected.
Scrollbar * vscroll
Cache of the vertical scrollbar.
ResizeInfo resize
Resize information.
@ FS_NORMAL
Index of the normal font in the font tables.
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
std::conditional_t< std::is_same_v< P, std::nullptr_t >, bool(const T &, const T &), bool(const T &, const T &, const P)> SortFunction
Signature of sort function.
uint total_files
Number of files to download.
uint total_bytes
Number of bytes to download.
void UnselectAll()
Unselect everything that we've not downloaded so far.
GUIContentList content
List with content.
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
Container for all important information about a piece of content.
void ScrollToSelected()
Make sure that the currently selected content info is within the visible part of the matrix.
static bool _accepted_external_search
Whether the user accepted to enter external websites during this session.
@ ES_NOT_HANDLED
The passed event is not handled.
void ShowNetworkContentListWindow(ContentVector *cv, ContentType type1, ContentType type2)
Show the content list window with a given set of content.
void ToggleSortOrder()
Toggle the sort order Since that is the worst condition for the sort function reverse the list here.
@ CONTENT_FILTER_TEXT
Filter by query sting.
void SortContentList()
Sort the content list.
@ WID_NCL_FILTER_CAPT
Caption for the filter editbox.
Data structure describing what to show in the list (filter criteria).
StringFilter string_filter
Text filter of content list.
@ WID_NCL_DETAILS
Panel with content details.
virtual void LoadTextfile(const std::string &textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
ContentListFilterData filter_data
Filter for content list.
void BuildContentTypeStringList()
Build array of all strings corresponding to the content types.
Window * parent
Parent window.
bool IsDescSortOrder() const
Check if the sort order is descending.
@ SELECTED
The content has been manually selected.
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
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'.
Coordinates of a point in 2D.
static constexpr NWidgetPart _nested_network_content_list_widgets[]
The widgets for the content list.
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
void RemoveCallback(ContentCallback *cb)
Remove a callback.
StringList tags
Tags associated with the content.
void DownloadSelectedContent(uint &files, uint &bytes, bool fallback=false)
Actually begin downloading the content we selected.
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
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.
static bool CDECL TypeOrSelectedFilter(const ContentInfo *const *a, ContentListFilterData &filter)
Filter content by type, but still show content selected for download.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
static constexpr NWidgetPart _nested_network_content_download_status_window_widgets[]
Nested widgets for the download window.
@ TFT_README
Content readme.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Window for showing the download status of content.
@ SA_HOR_CENTER
Horizontally center the text.
std::vector< ContentID > dependencies
The dependencies (unique server side ids)
@ WID_NCDS_CANCELOK
(Optional) Cancel/OK button.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
@ WID_NCL_DOWNLOAD
'Download' button.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
void ForceRebuild()
Force that a rebuild is needed.
@ CONTENT_TYPE_AI
The content consists of an AI.
ClientNetworkContentSocketHandler _network_content_client
The client we use to connect to the server.
@ TFT_LICENSE
Content license.
static void ExternalSearchDisclaimerCallback(Window *w, bool accepted)
Callback function for disclaimer about entering external websites.
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
std::string name
The current name of the downloaded file.
@ SBS_DOWN
Sort ascending.
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
@ CONTENT_TYPE_BASE_GRAPHICS
The content consists of base graphics.
void DrawSortButtonState(WidgetID widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
@ WC_GAME_OPTIONS
Game options window; Window numbers:
@ SCENARIO
Scan for scenarios and heightmaps.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
@ WID_NCL_SCROLLBAR
Scrollbar of matrix.
@ ALREADY_HERE
The content is already at the client side.
@ WID_NCL_OPEN_URL
'Open url' button.
Filter data for NetworkContentListWindow.
int list_pos
Our position in the list.
@ WID_NCL_SELECT_UPDATE
'Select updates' button.
void ReverseLookupTreeDependency(ConstContentVector &tree, const ContentInfo *child) const
Reverse lookup the dependencies of all parents over a given child.
@ AUTOSELECTED
The content has been selected as dependency.
@ CONTENT_TYPE_AI_LIBRARY
The content consists of an AI library.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
void ToggleSelectedState(const ContentInfo *ci)
Toggle the state of a content info and check its dependencies.
@ WC_NETWORK_WINDOW
Network window; Window numbers:
@ WID_NCL_SEL_ALL_UPDATE
NWID_SELECTION widget for select all/update buttons..
static Listing last_sorting
The last sorting setting.
@ WC_NETWORK_STATUS_WINDOW
Network status window; Window numbers:
ContentID
Unique identifier for the content.
void ResetState()
Reset the matching state to process a new item.
std::string filename
Filename (for the .tar.gz; only valid on download)
bool auto_select
Automatically select all content when the meta-data becomes available.
uint filesize_sum
The sum of all selected file sizes.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
EventState
State of handling an event.
@ CONTENT_TYPE_BEGIN
Helper to mark the begin of the types.
static const uint8_t PC_GREY
Grey palette colour.
bool GetState() const
Get the matching state of the current item.
static bool TypeSorter(const ContentInfo *const &a, const ContentInfo *const &b)
Sort content by type.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
@ WL_ERROR
Errors (eg. saving/loading failed)
uint downloaded_bytes
Number of bytes downloaded.
static const int ACTION_CLEAR
Clear editbox.
void AddCallback(ContentCallback *cb)
Add a callback to this class.
State state
Whether the content info is selected (for download)
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
@ CONTENT_TYPE_BASE_SOUNDS
The content consists of base sounds.
uint8_t SortType() const
Get the sorttype of the list.
QueryString filter_editbox
Filter editbox;.
BaseNetworkContentDownloadStatusWindow(WindowDesc *desc)
Create the window with the given description.
@ SA_CENTER
Center both horizontally and vertically.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
void DrawDetails(const Rect &r) const
Helper function to draw the details part of this window.
@ WID_NCL_CHECKBOX
Button above checkboxes.
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
void RebuildDone()
Notify the sortlist that the rebuild is done.
bool CDECL FilterFunction(const const ContentInfo * *, ContentListFilterData &)
Signature of filter function.
void SelectAll()
Select everything we can select.
@ BASESET
Scan for base sets.
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
@ CONTENT_FILTER_TYPE_OR_SELECTED
Filter by being of displayed type or selected for download.
Window that lists the content that's at the content server.
Window for displaying a textfile.
void BuildContentList()
(Re)build the network game list as its amount has changed because an item has been added or deleted f...
@ CONTENT_TYPE_SCENARIO
The content consists of a scenario.
static WindowDesc _network_content_list_desc(__FILE__, __LINE__, WDP_CENTER, "list_content", 630, 460, WC_NETWORK_WINDOW, WC_NONE, 0, std::begin(_nested_network_content_list_widgets), std::end(_nested_network_content_list_widgets))
Window description of the content list.
static std::string content_type_strs[CONTENT_TYPE_END]
Cached strings for all content types.
Data structure for an opened window.
TextfileType
Additional text files accompanying Tar archives.
const ContentInfo * selected
The selected content info.
void DrawWidgets() const
Paint all widgets of a window.
NetworkRecvStatus CloseConnection(bool error=true) override
Disconnect from the content server.
void SelectUpgrade()
Select everything that's an update for something we've got.
int Width() const
Get width of Rect.
ContentID id
Unique (server side) ID for the content.
static void Rescan()
Rescans all searchpaths for available AIs.
Specification of a rectangle with absolute coordinates of all edges.
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
Mode
The mode of tar scanning.
@ WID_NCL_SEARCH_EXTERNAL
Search external sites for missing NewGRF.
std::string description
Description of the content.
bool Sort(Comp compare)
Sort the list.
@ CONTENT_TYPE_HEIGHTMAP
The content consists of a heightmap.
@ WC_TEXTFILE
textfile; Window numbers:
std::vector< const ContentInfo * > ConstContentVector
Vector with constant content info.
void FilterContentList()
Filter the content list.
@ WDP_CENTER
Center the window.
static WindowDesc _network_content_download_status_window_desc(__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_NETWORK_STATUS_WINDOW, WC_NONE, WDF_MODAL, std::begin(_nested_network_content_download_status_window_widgets), std::end(_nested_network_content_download_status_window_widgets))
Window description for the download window.
void OnPaint() override
The window must be repainted.
void SetFiltering(Filtering f)
Import filter conditions.
@ WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD
Network content download status.
@ WID_NCDS_PROGRESS_BAR
Simple progress bar.
uint32_t unique_id
Unique ID; either GRF ID or shortname.
void SetFilterType(uint8_t n_type)
Set the filtertype of the list.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
static GUIContentList::SortFunction *const sorter_funcs[]
Sorter functions.
Window for displaying the textfile of an item in the content list.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
@ FR_BORDERONLY
Draw border only, no background.
static GUIContentList::FilterFunction *const filter_funcs[]
Filter functions.
ConstContentIterator Begin() const
Get the begin of the content inf iterator.
@ CONTENT_TYPE_BASE_MUSIC
The content consists of base music.
void SetListing(Listing l)
Import sort conditions.
static Filtering last_filtering
The last filtering setting.
ContentListFilterCriteria
Filter criteria for NetworkContentListWindow.