12 #if defined(ENABLE_NETWORK) 13 #include "../stdafx.h" 14 #include "../strings_func.h" 15 #include "../gfx_func.h" 16 #include "../window_func.h" 18 #include "../ai/ai.hpp" 19 #include "../game/game.hpp" 20 #include "../base_media_base.h" 21 #include "../sortlist_type.h" 22 #include "../stringfilter_type.h" 23 #include "../querystring_gui.h" 24 #include "../core/geometry_func.hpp" 25 #include "../textfile_gui.h" 29 #include "table/strings.h" 30 #include "../table/sprites.h" 34 #include "../safeguards.h" 47 const char *textfile = this->ci->
GetTextfile(file_type);
53 switch (this->ci->
type) {
64 default: NOT_REACHED();
102 _nested_network_content_download_status_window_widgets,
lengthof(_nested_network_content_download_status_window_widgets)
106 Window(desc), cur_id(UINT32_MAX)
124 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);
134 str = STR_CONTENT_DOWNLOAD_COMPLETE;
139 str = STR_CONTENT_DOWNLOAD_FILE;
141 str = STR_CONTENT_DOWNLOAD_INITIALISE;
150 if (ci->
id != this->cur_id) {
180 for (
ContentType *iter = this->receivedTypes.
Begin(); iter != this->receivedTypes.
End(); iter++) {
214 for (
ContentType *iter = this->receivedTypes.
Begin(); iter != this->receivedTypes.
End(); iter++) {
290 std::bitset<CONTENT_TYPE_END>
types;
304 static const uint EDITBOX_MAX_SIZE = 50;
308 static GUIContentList::SortFunction *
const sorter_funcs[];
309 static GUIContentList::FilterFunction *
const filter_funcs[];
326 extern void OpenBrowser(
const char *url);
329 const char *last =
lastof(url);
331 char *pos =
strecpy(url,
"http://grfsearch.openttd.org/?", last);
333 if (this->auto_select) {
334 pos =
strecpy(pos,
"do=searchgrfid&q=", last);
341 if (!first) pos =
strecpy(pos,
",", last);
349 pos =
strecpy(pos,
"do=searchtext&q=", last);
352 for (
const char *search = this->filter_editbox.text.
buf; *search !=
'\0'; search++) {
354 if (*search ==
'\'' || *search ==
'"')
continue;
357 if (*search < 0x30) {
358 pos +=
seprintf(pos, last,
"%%%02X", *search);
359 }
else if (pos < last) {
389 this->content.
Clear();
391 bool all_available =
true;
395 *this->content.
Append() = *iter;
400 this->FilterContentList();
403 this->SortContentList();
406 this->ScrollToSelected();
412 return strnatcmp((*a)->name, (*b)->name,
true);
419 if ((*a)->type != (*b)->type) {
420 r =
strnatcmp(content_type_strs[(*a)->type], content_type_strs[(*b)->type]);
422 if (r == 0) r = NameSorter(a, b);
429 int r = (*a)->state - (*b)->state;
430 if (r == 0) r = TypeSorter(a, b);
437 if (!this->content.
Sort())
return;
440 if (*iter == this->selected) {
441 this->list_pos = iter - this->content.
Begin();
451 for (
int i = 0; i < (*a)->tag_count; i++) {
461 if (filter.
types.none())
return true;
462 if (filter.
types[(*a)->type])
return true;
470 bool changed =
false;
473 changed |= this->content.
Filter(this->filter_data);
475 if (this->filter_data.
types.any()) {
477 changed |= this->content.
Filter(this->filter_data);
479 if (!changed)
return;
483 if (*iter == this->selected) {
484 this->list_pos = iter - this->content.
Begin();
490 this->selected = NULL;
502 if (new_state != old_params.
state) {
505 return new_state != old_params.
state;
511 if (this->selected == NULL)
return;
529 auto_select(select_all),
530 filter_editbox(EDITBOX_MAX_SIZE),
546 this->filter_data.
types = types;
553 this->UpdateFilterState();
555 this->FilterContentList();
556 this->SortContentList();
588 size->height = 10 * resize->height;
598 DrawString(r.left, r.right, r.top, STR_CONTENT_FILTER_TITLE, TC_FROMSTRING,
SA_RIGHT);
602 this->DrawDetails(r);
616 this->BuildContentList();
641 int sprite_y_offset =
WD_MATRIX_TOP + (line_height - this->checkbox_size.height) / 2 - 1;
648 if (ci == this->selected)
GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->resize.step_height - 1,
PC_GREY);
658 default: NOT_REACHED();
660 DrawSprite(sprite, pal, nwi_checkbox->
pos_x + (pal == PAL_NONE ? 2 : 3), y + sprite_y_offset + (pal == PAL_NONE ? 1 : 0));
663 DrawString(nwi_type->pos_x, nwi_type->pos_x + nwi_type->current_x - 1, y + text_y_offset, str, TC_BLACK,
SA_HOR_CENTER);
676 static const int DETAIL_LEFT = 5;
677 static const int DETAIL_RIGHT = 5;
678 static const int DETAIL_TOP = 5;
691 if (this->selected == NULL)
return;
698 int y = r.top + DETAIL_TITLE_HEIGHT + DETAIL_TOP;
702 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_UPDATE);
707 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_NAME);
711 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_VERSION);
716 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_DESCRIPTION);
721 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_URL);
725 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_TYPE);
729 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_FILESIZE);
742 if (ci->
id != cid)
continue;
744 p +=
seprintf(p,
lastof(buf), p == buf ?
"%s" :
", %s", (*iter)->name);
749 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_DEPENDENCIES);
756 for (uint i = 0; i < this->selected->
tag_count; i++) {
760 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_TAGS);
778 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_SELECTED_BECAUSE_OF);
795 if (id_v >= this->content.
Length())
return;
797 this->selected = *this->content.
Get(id_v);
798 this->list_pos = id_v;
806 if (this->filter_data.
types.any()) {
819 if (this->content.
Length() > 0) this->list_pos = this->content.
Length() - this->list_pos - 1;
823 this->SortContentList();
825 this->ScrollToSelected();
849 if (this->selected != NULL) {
850 extern void OpenBrowser(
const char *url);
851 OpenBrowser(this->selected->
url);
861 this->OpenExternalSearch();
863 ShowQuery(STR_CONTENT_SEARCH_EXTERNAL_DISCLAIMER_CAPTION, STR_CONTENT_SEARCH_EXTERNAL_DISCLAIMER,
this, ExternalSearchDisclaimerCallback);
874 if (this->list_pos > 0) this->list_pos--;
878 if (this->list_pos < (
int)this->content.
Length() - 1) this->list_pos++;
882 this->list_pos = (this->list_pos < this->vscroll->
GetCapacity()) ? 0 : this->list_pos - this->vscroll->
GetCapacity();
886 this->list_pos =
min(this->list_pos + this->vscroll->
GetCapacity(), (int)this->content.
Length() - 1);
894 this->list_pos = this->content.
Length() - 1;
900 if (this->selected != NULL) {
905 if (this->filter_data.
types.any()) {
918 if (this->content.
Length() == 0) {
920 if (this->UpdateFilterState()) {
927 this->selected = *this->content.
Get(this->list_pos);
929 if (this->UpdateFilterState()) {
933 this->ScrollToSelected();
945 this->UpdateFilterState();
987 if (!gui_scope)
return;
988 if (this->content.
NeedRebuild()) this->BuildContentList();
991 this->filesize_sum = 0;
992 bool show_select_all =
false;
993 bool show_select_upgrade =
false;
1003 show_select_all =
true;
1004 show_select_upgrade |= ci->
upgrade;
1018 for (
TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
1022 this->GetWidget<NWidgetCore>(
WID_NCL_CANCEL)->widget_data = this->filesize_sum == 0 ? STR_AI_SETTINGS_CLOSE : STR_AI_LIST_CANCEL;
1037 &TypeOrSelectedFilter,
1065 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1076 SetDataTip(STR_CONTENT_TYPE_CAPTION, STR_CONTENT_TYPE_CAPTION_TOOLTIP),
1078 SetDataTip(STR_CONTENT_NAME_CAPTION, STR_CONTENT_NAME_CAPTION_TOOLTIP),
1080 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),
1087 SetDataTip(STR_CONTENT_SELECT_UPDATES_CAPTION, STR_CONTENT_SELECT_UPDATES_CAPTION_TOOLTIP),
1089 SetDataTip(STR_CONTENT_SELECT_ALL_CAPTION, STR_CONTENT_SELECT_ALL_CAPTION_TOOLTIP),
1092 SetDataTip(STR_CONTENT_UNSELECT_ALL_CAPTION, STR_CONTENT_UNSELECT_ALL_CAPTION_TOOLTIP),
1112 SetDataTip(STR_CONTENT_SEARCH_EXTERNAL, STR_CONTENT_SEARCH_EXTERNAL_TOOLTIP),
1117 SetDataTip(STR_CONTENT_DOWNLOAD_CAPTION, STR_CONTENT_DOWNLOAD_CAPTION_TOOLTIP),
1134 _nested_network_content_list_widgets,
lengthof(_nested_network_content_list_widgets)
1146 #if defined(WITH_ZLIB) 1147 std::bitset<CONTENT_TYPE_END> types;
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.
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?
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.
virtual void OnResize()
Called after the window got resized.
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)
Window * parent
Parent window.
void Close()
Disconnect from the content server.
const ContentInfo * selected
The selected content info.
High level window description.
Saveload window; Window numbers:
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
void DrawWidgets() const
Paint all widgets of a window.
virtual void OnPaint()
The window must be repainted.
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.
static bool IsInsideBS(const T x, const uint base, const uint size)
Checks if a value is between a window started at some base point.
void Clear()
Remove all items from the list.
void ReverseLookupTreeDependency(ConstContentVector &tree, const ContentInfo *child) const
Reverse lookup the dependencies of all parents over a given child.
void Compact()
Compact the list down to the smallest block size boundary.
const T * Begin() const
Get the pointer to the first item (const)
GUIContentList content
List with content.
ContentID * dependencies
Malloced array of dependencies (unique server side ids)
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
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.
virtual void OnReceiveContentInfo(const ContentInfo *rci)
We received a content info.
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
static T max(const T a, const T b)
Returns the maximum of two values.
ContentID
Unique identifier for the content.
The content has not been selected.
const T * End() const
Get the pointer behind the last valid item (const)
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.
T * Append(uint to_add=1)
Append an item and return it.
The content does not exist in the content system.
void ForceRebuild()
Force that a rebuild is needed.
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.
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=NULL, uint textref_stack_size=0, const uint32 *textref_stack=NULL)
Display an error message in a window.
'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.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
void AddCallback(ContentCallback *cb)
Add a callback to this class.
StringFilter string_filter
Text filter of content list.
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.
uint Length() const
Get the number of items in the list.
uint8 tag_count
Number of tags.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
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...
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.
Scan for scenarios and heightmaps.
static int CDECL TypeSorter(const ContentInfo *const *a, const ContentInfo *const *b)
Sort content by type.
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.
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.
static WindowDesc _network_content_download_status_window_desc(WDP_CENTER, NULL, 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.
virtual void OnEditboxChanged(int wid)
The text in an editbox has been edited.
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.
SmallVector< ContentType, 4 > receivedTypes
Types we received so we can update their cache.
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.
virtual void OnDownloadProgress(const ContentInfo *ci, int bytes)
We have progress in the download of a file.
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.
static int CDECL NameSorter(const ContentInfo *const *a, const ContentInfo *const *b)
Sort content by name.
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.
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
byte md5sum[16]
The MD5 checksum.
virtual void OnDownloadComplete(ContentID cid)
We have finished downloading a file.
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.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
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.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
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 criterias 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.
uint total_files
Number of files to download.
The content consists of a heightmap.
The content consists of an AI.
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.
virtual void OnConnect(bool success)
Callback for when the connection has finished.
TextfileType file_type
Type of textfile to view.
static void Rescan()
Rescans all searchpaths for available AIs.
int CDECL SortFunction(const T *, const T *)
Signature of sort function.
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 Include(const T &item)
Tests whether a item is present in the vector, and appends it to the end if not.
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
void ScanNewGRFFiles(NewGRFScanCallback *callback)
Scan for all NewGRFs.
Coordinates of a point in 2D.
virtual EventState OnKeyPress(WChar key, uint16 keycode)
A key has been pressed.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
static Listing last_sorting
The last sorting setting.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
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.
const T * Get(uint index) const
Get the pointer to item "number" (const)
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.
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.
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.
void SetStringParameters(int widget) const
Initialize string parameters for a widget.
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.
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.
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.
void ToggleSelectedState(const ContentInfo *ci)
Toggle the state of a content info and check its dependencies.
The content consists of base sounds.
static int CDECL StateSorter(const ContentInfo *const *a, const ContentInfo *const *b)
Sort content by state.
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.
virtual void OnDownloadProgress(const ContentInfo *ci, int bytes)
We have progress in the download of a file.