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 "../sortlist_type.h" 19 #include "../stringfilter_type.h" 20 #include "../querystring_gui.h" 21 #include "../core/geometry_func.hpp" 22 #include "../textfile_gui.h" 26 #include "table/strings.h" 27 #include "../table/sprites.h" 31 #include "../safeguards.h" 44 const char *textfile = this->ci->
GetTextfile(file_type);
50 switch (this->ci->
type) {
61 default: NOT_REACHED();
99 _nested_network_content_download_status_window_widgets,
lengthof(_nested_network_content_download_status_window_widgets)
103 Window(desc), cur_id(UINT32_MAX)
121 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);
131 str = STR_CONTENT_DOWNLOAD_COMPLETE;
136 str = STR_CONTENT_DOWNLOAD_FILE;
138 str = STR_CONTENT_DOWNLOAD_INITIALISE;
147 if (ci->
id != this->cur_id) {
177 for (
auto ctype : this->receivedTypes) {
211 for (
auto ctype : this->receivedTypes) {
287 std::bitset<CONTENT_TYPE_END>
types;
301 static const uint EDITBOX_MAX_SIZE = 50;
305 static GUIContentList::SortFunction *
const sorter_funcs[];
306 static GUIContentList::FilterFunction *
const filter_funcs[];
323 extern void OpenBrowser(
const char *url);
326 const char *last =
lastof(url);
328 char *pos =
strecpy(url,
"http://grfsearch.openttd.org/?", last);
330 if (this->auto_select) {
331 pos =
strecpy(pos,
"do=searchgrfid&q=", last);
337 if (!first) pos =
strecpy(pos,
",", last);
345 pos =
strecpy(pos,
"do=searchtext&q=", last);
348 for (
const char *search = this->filter_editbox.text.
buf; *search !=
'\0'; search++) {
350 if (*search ==
'\'' || *search ==
'"')
continue;
353 if (*search < 0x30) {
354 pos +=
seprintf(pos, last,
"%%%02X", *search);
355 }
else if (pos < last) {
385 this->content.clear();
387 bool all_available =
true;
391 this->content.push_back(*iter);
396 this->FilterContentList();
397 this->content.shrink_to_fit();
399 this->SortContentList();
401 this->vscroll->
SetCount((
int)this->content.size());
402 this->ScrollToSelected();
418 if (r == 0)
return NameSorter(a, b);
426 if (r == 0)
return TypeSorter(a, b);
433 if (!this->content.
Sort())
return;
435 int idx =
find_index(this->content, this->selected);
436 if (idx >= 0) this->list_pos = idx;
443 for (
int i = 0; i < (*a)->tag_count; i++) {
453 if (filter.
types.none())
return true;
454 if (filter.
types[(*a)->type])
return true;
462 bool changed =
false;
465 changed |= this->content.
Filter(this->filter_data);
467 if (this->filter_data.
types.any()) {
469 changed |= this->content.
Filter(this->filter_data);
471 if (!changed)
return;
474 int idx =
find_index(this->content, this->selected);
476 this->list_pos = idx;
481 this->selected =
nullptr;
493 if (new_state != old_params.
state) {
496 return new_state != old_params.
state;
502 if (this->selected ==
nullptr)
return;
520 auto_select(select_all),
521 filter_editbox(EDITBOX_MAX_SIZE),
537 this->filter_data.
types = types;
544 this->UpdateFilterState();
546 this->FilterContentList();
547 this->SortContentList();
579 size->height = 10 * resize->height;
589 DrawString(r.left, r.right, r.top, STR_CONTENT_FILTER_TITLE, TC_FROMSTRING,
SA_RIGHT);
593 this->DrawDetails(r);
607 this->BuildContentList();
632 int sprite_y_offset =
WD_MATRIX_TOP + (line_height - this->checkbox_size.height) / 2 - 1;
636 auto iter = this->content.begin() + this->vscroll->
GetPosition();
638 auto end = (last < this->content.size()) ? this->content.begin() + last : this->content.end();
640 for (; iter != end; iter++) {
643 if (ci == this->selected)
GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->resize.step_height - 1,
PC_GREY);
653 default: NOT_REACHED();
655 DrawSprite(sprite, pal, nwi_checkbox->
pos_x + (pal == PAL_NONE ? 2 : 3), y + sprite_y_offset + (pal == PAL_NONE ? 1 : 0));
658 DrawString(nwi_type->pos_x, nwi_type->pos_x + nwi_type->current_x - 1, y + text_y_offset, str, TC_BLACK,
SA_HOR_CENTER);
671 static const int DETAIL_LEFT = 5;
672 static const int DETAIL_RIGHT = 5;
673 static const int DETAIL_TOP = 5;
686 if (this->selected ==
nullptr)
return;
693 int y = r.top + DETAIL_TITLE_HEIGHT + DETAIL_TOP;
697 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_UPDATE);
702 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_NAME);
706 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_VERSION);
711 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_DESCRIPTION);
716 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_URL);
720 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_TYPE);
724 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_FILESIZE);
737 if (ci->
id != cid)
continue;
739 p +=
seprintf(p,
lastof(buf), p == buf ?
"%s" :
", %s", (*iter)->name);
744 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_DEPENDENCIES);
751 for (uint i = 0; i < this->selected->
tag_count; i++) {
755 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_TAGS);
772 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_SELECTED_BECAUSE_OF);
789 if (id_v >= this->content.size())
return;
791 this->selected = this->content[id_v];
792 this->list_pos = id_v;
800 if (this->filter_data.
types.any()) {
813 if (this->content.size() > 0) this->list_pos = (
int)this->content.size() - this->list_pos - 1;
817 this->SortContentList();
819 this->ScrollToSelected();
843 if (this->selected !=
nullptr) {
844 extern void OpenBrowser(
const char *url);
845 OpenBrowser(this->selected->
url);
855 this->OpenExternalSearch();
857 ShowQuery(STR_CONTENT_SEARCH_EXTERNAL_DISCLAIMER_CAPTION, STR_CONTENT_SEARCH_EXTERNAL_DISCLAIMER,
this, ExternalSearchDisclaimerCallback);
868 if (this->list_pos > 0) this->list_pos--;
872 if (this->list_pos < (
int)this->content.size() - 1) this->list_pos++;
876 this->list_pos = (this->list_pos < this->vscroll->
GetCapacity()) ? 0 : this->list_pos - this->vscroll->
GetCapacity();
880 this->list_pos =
min(this->list_pos + this->vscroll->
GetCapacity(), (int)this->content.size() - 1);
888 this->list_pos = (int)this->content.size() - 1;
894 if (this->selected !=
nullptr) {
899 if (this->filter_data.
types.any()) {
912 if (this->content.size() == 0) {
914 if (this->UpdateFilterState()) {
921 this->selected = this->content[this->list_pos];
923 if (this->UpdateFilterState()) {
927 this->ScrollToSelected();
939 this->UpdateFilterState();
981 if (!gui_scope)
return;
982 if (this->content.
NeedRebuild()) this->BuildContentList();
985 this->filesize_sum = 0;
986 bool show_select_all =
false;
987 bool show_select_upgrade =
false;
996 show_select_all =
true;
997 show_select_upgrade |= ci->
upgrade;
1011 for (
TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
1015 this->GetWidget<NWidgetCore>(
WID_NCL_CANCEL)->widget_data = this->filesize_sum == 0 ? STR_AI_SETTINGS_CLOSE : STR_AI_LIST_CANCEL;
1030 &TypeOrSelectedFilter,
1058 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1069 SetDataTip(STR_CONTENT_TYPE_CAPTION, STR_CONTENT_TYPE_CAPTION_TOOLTIP),
1071 SetDataTip(STR_CONTENT_NAME_CAPTION, STR_CONTENT_NAME_CAPTION_TOOLTIP),
1073 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),
1080 SetDataTip(STR_CONTENT_SELECT_UPDATES_CAPTION, STR_CONTENT_SELECT_UPDATES_CAPTION_TOOLTIP),
1082 SetDataTip(STR_CONTENT_SELECT_ALL_CAPTION, STR_CONTENT_SELECT_ALL_CAPTION_TOOLTIP),
1085 SetDataTip(STR_CONTENT_UNSELECT_ALL_CAPTION, STR_CONTENT_UNSELECT_ALL_CAPTION_TOOLTIP),
1105 SetDataTip(STR_CONTENT_SEARCH_EXTERNAL, STR_CONTENT_SEARCH_EXTERNAL_TOOLTIP),
1110 SetDataTip(STR_CONTENT_DOWNLOAD_CAPTION, STR_CONTENT_DOWNLOAD_CAPTION_TOOLTIP),
1127 _nested_network_content_list_widgets,
lengthof(_nested_network_content_list_widgets)
1139 #if defined(WITH_ZLIB) 1140 std::bitset<CONTENT_TYPE_END> types;
1142 if (cv ==
nullptr) {
1159 if (cv !=
nullptr) {
EventState
State of handling an event.
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.
void Close() override
Disconnect from the content server.
Helper to mark the end of the types.
const ContentInfo *const * ConstContentIterator
Iterator for the constant content vector.
void RebuildDone()
Notify the sortlist that the rebuild is done.
The content consists of base graphics.
Panel with content details.
bool IsSelected() const
Is the state either selected or autoselected?
std::vector< ContentType > receivedTypes
Types we received so we can update their cache.
void DownloadSelectedContent(uint &files, uint &bytes, bool fallback=false)
Actually begin downloading the content we selected.
char filename[48]
Filename (for the .tar.gz; only valid on download)
ConstContentIterator Begin() const
Get the begin of the content inf iterator.
~BaseNetworkContentDownloadStatusWindow()
Free everything associated with this window.
Horizontally center the text.
ResizeInfo resize
Resize information.
static bool _accepted_external_search
Whether the user accepted to enter external websites during this session.
Panel with list of content.
Window that lists the content that's at the content server.
uint32 unique_id
Unique ID; either GRF ID or shortname.
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen...
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Offset at right of a matrix cell.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Window * parent
Parent window.
const ContentInfo * selected
The selected content info.
High level window description.
Saveload window; Window numbers:
void OnDownloadProgress(const ContentInfo *ci, int bytes) override
We have progress in the download of a file.
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
void DrawWidgets() const
Paint all widgets of a window.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Offset at top to draw the frame rectangular area.
Dimension checkbox_size
Size of checkbox/"blot" sprite.
Normal amount of vertical space between two paragraphs of text.
textfile; Window numbers:
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
void ResetState()
Reset the matching state to process a new item.
The passed event is not handled.
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
bool GetState() const
Get the matching state of the current item.
Callbacks for notifying others about incoming data.
Filter data for NetworkContentListWindow.
uint32 filesize
Size of the file.
The content consists of a scenario.
uint8 dependency_count
Number of dependencies.
char(* tags)[32]
Malloced array of tags (strings)
char * md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
Convert the md5sum to a hexadecimal string representation.
void SetFilterType(uint8 n_type)
Set the filtertype of the list.
static const int ACTION_CLEAR
Clear editbox.
void OnPaint() override
The window must be repainted.
void ReverseLookupTreeDependency(ConstContentVector &tree, const ContentInfo *child) const
Reverse lookup the dependencies of all parents over a given child.
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.
GUIContentList content
List with content.
ContentID * dependencies
Malloced array of dependencies (unique server side ids)
Scrollbar * vscroll
Cache of the vertical scrollbar.
static const int DRAW_STRING_BUFFER
Size of the buffer used for drawing strings.
Offset at top of a matrix cell.
ContentListFilterData filter_data
Filter for content list.
The content has been selected as dependency.
std::bitset< CONTENT_TYPE_END > types
Content types displayed.
NetworkContentDownloadStatusWindow()
Create a new download window based on a list of content information with flags whether to download th...
#define lastof(x)
Get the last element of an fixed size array.
static bool StateSorter(const ContentInfo *const &a, const ContentInfo *const &b)
Sort content by state.
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
static T max(const T a, const T b)
Returns the maximum of two values.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
ContentID
Unique identifier for the content.
void OnEditboxChanged(int wid) override
The text in an editbox has been edited.
The content has not been selected.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
void SetListing(Listing l)
Import sort conditions.
Large amount of vertical space between two paragraphs of text.
Data structure describing what to show in the list (filter criteria).
Search external sites for missing NewGRF.
bool NeedRebuild() const
Check if a rebuild is needed.
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.
The content does not exist in the content system.
void ForceRebuild()
Force that a rebuild is needed.
void ScrollToSelected()
Make sure that the currently selected content info is within the visible part of the matrix...
Data structure for an opened window.
void UnselectAll()
Unselect everything that we've not downloaded so far.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void BuildContentTypeStringList()
Build array of all strings corresponding to the content types.
void SetFilterTerm(const char *str)
Set the term to filter on.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
'Download' button.
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
~NetworkContentDownloadStatusWindow()
Free whatever we've allocated.
char name[32]
Name of the content.
The content consists of a game script.
void OnDownloadProgress(const ContentInfo *ci, int bytes) override
We have progress in the download of a file.
void AddCallback(ContentCallback *cb)
Add a callback to this class.
StringFilter string_filter
Text filter of content list.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
static void ExternalSearchDisclaimerCallback(Window *w, bool accepted)
Callback function for disclaimer about entering external websites.
ConstContentIterator End() const
Get the end of the content inf iterator.
Offset at bottom of a matrix cell.
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.
std::vector< ContentInfo * > ContentVector
Vector with content info.
uint8 tag_count
Number of tags.
char version[16]
Version of the content.
static bool CDECL TypeOrSelectedFilter(const ContentInfo *const *a, ContentListFilterData &filter)
Filter content by type, but still show content selected for download.
void SelectUpgrade()
Select everything that's an update for something we've got.
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...
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
static const NWidgetPart _nested_network_content_list_widgets[]
The widgets for the content list.
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
NetworkContentListWindow(WindowDesc *desc, bool select_all, const std::bitset< CONTENT_TYPE_END > &types)
Create the content list window.
Data stored about a string that can be modified in the GUI.
Window for displaying the textfile of an item in the content list.
Center both horizontally and vertically.
The content is already at the client side.
ContentID id
Unique (server side) ID for the content.
int list_pos
Our position in the list.
static bool CDECL TagNameFilter(const ContentInfo *const *a, ContentListFilterData &filter)
Filter content by tags/name.
'Unselect all' button.
void ScanScenarios()
Force a (re)scan of the scenarios.
bool UpdateFilterState()
Update filter state based on current window state.
void Clear()
Clear all downloaded content information.
static const NWidgetPart _nested_network_content_download_status_window_widgets[]
Nested widgets for the download window.
static bool TypeSorter(const ContentInfo *const &a, const ContentInfo *const &b)
Sort content by type.
Scan for scenarios and heightmaps.
void DrawSortButtonState(int widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
uint step_height
Step-size of height resize changes.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Offset at left of a matrix cell.
void RequestContentList(ContentType type)
Request the content list for the given type.
State state
Whether the content info is selected (for download)
Background of the window.
void OnReceiveContentInfo(const ContentInfo *rci) override
We received a content info.
virtual void LoadTextfile(const char *textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
SortButtonState
State of a sort direction button.
Offset at bottom to draw the frame rectangular area.
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
const ContentInfo * ci
View the textfile of this ContentInfo.
#define lengthof(x)
Return the length of an fixed size array.
TextfileType
Additional text files accompanying Tar archives.
static T min(const T a, const T b)
Returns the minimum of two values.
void DrawMatrix(const Rect &r) const
Draw/fill the matrix with the list of content to download.
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
void SetSortType(uint8 n_type)
Set the sorttype of the list.
bool Sort(SortFunction *compare)
Sort the list.
void BuildContentList()
(Re)build the network game list as its amount has changed because an item has been added or deleted f...
QueryString filter_editbox
Filter editbox;.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
byte md5sum[16]
The MD5 checksum.
uint total_bytes
Number of bytes to download.
The content consists of a GS library.
'Select updates' button.
void SortContentList()
Sort the content list.
Window for showing the download status of content.
bool auto_select
Automatically select all content when the meta-data becomes available.
The window is a modal child of some other window, meaning the parent is 'inactive'.
uint DoScan(Subdirectory sd)
Perform the scanning of a particular subdirectory.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
The content consists of a NewGRF.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
ContentType
The values in the enum are important; they are used as database 'keys'.
Network status window; Window numbers:
void AddLine(const char *str)
Pass another text line from the current item to the filter.
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
No window, redirects to WC_MAIN_WINDOW.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
NWID_SELECTION widget for select all/update buttons..
static const uint8 PC_GREY
Grey palette colour.
static const uint8 PC_DARK_BLUE
Dark blue palette colour.
The content consists of an AI library.
Mode
The mode of tar scanning.
User interface for downloading files.
char *const buf
buffer in which text is saved
void FilterContentList()
Filter the content list.
void SelectAll()
Select everything we can select.
(Optional) Cancel/OK button.
char name[48]
The current name of the downloaded file.
ContentListFilterCriteria
Filter criteria for NetworkContentListWindow.
uint downloaded_files
Number of files downloaded.
Window for displaying a textfile.
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
void RemoveCallback(ContentCallback *cb)
Remove a callback.
'Select all' button.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
void SetFilterState(bool state)
Enable or disable the filter.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
uint total_files
Number of files to download.
The content consists of a heightmap.
The content consists of an AI.
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...
const char * GetTextfile(TextfileType type) const
Search a textfile file next to this file in the content list.
void ToggleSortOrder()
Toggle the sort order Since that is the worst condition for the sort function reverse the list here...
ContentType type
Type of content.
bool upgrade
This item is an upgrade.
bool CDECL FilterFunction(const T *, F)
Signature of filter function.
void ShowNetworkContentListWindow(ContentVector *cv, ContentType type1, ContentType type2)
Show the content list window with a given set of content.
'Open url' button.
TextfileType file_type
Type of textfile to view.
static void Rescan()
Rescans all searchpaths for available AIs.
static bool NameSorter(const ContentInfo *const &a, const ContentInfo *const &b)
Sort content by name.
Network window; Window numbers:
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
static GUIContentList::FilterFunction *const filter_funcs[]
Filter functions.
Helper to mark the begin of the types.
The content consists of base music.
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
void ScanNewGRFFiles(NewGRFScanCallback *callback)
Scan for all NewGRFs.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Coordinates of a point in 2D.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
static Listing last_sorting
The last sorting setting.
Data structure describing how to show the list (what sort direction and criteria).
Open readme, changelog (+1) or license (+2) of a file in the content window.
static char content_type_strs[CONTENT_TYPE_END][64]
Cached strings for all content types.
uint downloaded_bytes
Number of bytes downloaded.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
The content has been manually selected.
Offset at right to draw the frame rectangular area.
void SetFiltering(Filtering f)
Import filter conditions.
static GUIContentList::SortFunction *const sorter_funcs[]
Sorter functions.
bool IsDescSortOrder() const
Check if the sort order is descending.
Caption for the filter editbox.
static Filtering last_filtering
The last filtering setting.
Specification of a rectangle with absolute coordinates of all edges.
void OnConnect(bool success) override
Callback for when the connection has finished.
The passed event is handled.
Right align the text (must be a single bit).
BaseNetworkContentDownloadStatusWindow(WindowDesc *desc)
Create the window with the given description.
Filtering GetFiltering() const
Export current filter conditions.
Base window for showing the download status of content.
Filter by being of displayed type or selected for download.
uint32 cur_id
The current ID of the downloaded file.
void OnResize() override
Called after the window got resized.
void OnDownloadComplete(ContentID cid) override
We have finished downloading a file.
bool SortFunction(const T &, const T &)
Signature of sort function.
Subdirectory GetContentInfoSubDir(ContentType type)
Helper to get the subdirectory a ContentInfo is located in.
char url[96]
URL related to the content.
Errors (eg. saving/loading failed)
GUIList< const ContentInfo *, ContentListFilterData & > GUIContentList
List with content infos.
uint32 WChar
Type for wide characters, i.e.
char description[512]
Description of the content.
bool IsWidgetFocused(byte widget_index) const
Check if given widget is focused within this window.
Dimensions (a width and height) of a rectangle in 2D.
Container for all important information about a piece of content.
bool IsEmpty() const
Check whether any filter words were entered.
Offset at left to draw the frame rectangular area.
void DrawDetails(const Rect &r) const
Helper function to draw the details part of this window.
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
Game options window; Window numbers:
void OpenExternalSearch()
Search external websites for content.
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_...
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Network content download status.
~NetworkContentListWindow()
Free everything we allocated.
EventState OnKeyPress(WChar key, uint16 keycode) override
A key has been pressed.
ClientNetworkContentSocketHandler _network_content_client
The client we use to connect to the server.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
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-...
uint filesize_sum
The sum of all selected file sizes.
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.
std::vector< const ContentInfo * > ConstContentVector
Vector with constant content info.
void ToggleSelectedState(const ContentInfo *ci)
Toggle the state of a content info and check its dependencies.
The content consists of base sounds.
uint8 SortType() const
Get the sorttype of the list.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.