OpenTTD Source
1.11.0-beta2
|
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 "../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"
50 switch (this->ci->
type) {
61 default: NOT_REACHED();
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;
323 extern void OpenBrowser(
const char *url);
326 const char *last =
lastof(url);
328 char *pos =
strecpy(url,
"https://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);
397 this->content.shrink_to_fit();
401 this->vscroll->
SetCount((
int)this->content.size());
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;
537 this->filter_data.
types = types;
579 size->height = 10 *
resize->height;
589 DrawString(r.left, r.right, r.top, STR_CONTENT_FILTER_TITLE, TC_FROMSTRING,
SA_RIGHT);
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));
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;
843 if (this->selected !=
nullptr) {
844 extern void OpenBrowser(
const char *url);
845 OpenBrowser(this->selected->
url);
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 = std::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) {
921 this->selected = this->content[this->
list_pos];
981 if (!gui_scope)
return;
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),
1139 #if defined(WITH_ZLIB)
1140 std::bitset<CONTENT_TYPE_END> types;
1142 if (cv ==
nullptr) {
1159 if (cv !=
nullptr) {
@ WID_NCL_NAME
'Name' button.
const ContentInfo * ci
View the textfile of this ContentInfo.
void OnDownloadProgress(const ContentInfo *ci, int bytes) override
We have progress in the download of a file.
@ 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:
void OnEditboxChanged(int wid) override
The text in an editbox has been edited.
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
Callbacks for notifying others about incoming data.
uint8 tag_count
Number of tags.
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-...
@ WID_NCL_DETAILS
Panel with content details.
void OnConnect(bool success) override
Callback for when the connection has finished.
virtual void LoadTextfile(const char *textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
uint8 SortType() const
Get the sorttype of the list.
const char * GetTextfile(TextfileType type) const
Search a textfile file next to this file in the content list.
char name[48]
The current name of the downloaded file.
ContentType type
Type of content.
@ WID_NCL_MATRIX
Panel with list of content.
@ WD_MATRIX_RIGHT
Offset at right of a matrix cell.
char32_t WChar
Type for wide characters, i.e.
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.
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.
ContentType
The values in the enum are important; they are used as database 'keys'.
void DrawSortButtonState(int widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
bool Sort(Comp compare)
Sort the list.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
GUIList< const ContentInfo *, ContentListFilterData & > GUIContentList
List with content infos.
NetworkContentDownloadStatusWindow()
Create a new download window based on a list of content information with flags whether to download th...
bool IsEmpty() const
Check whether any filter words were entered.
bool upgrade
This item is an upgrade.
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.
@ DOES_NOT_EXIST
The content does not exist in the content system.
@ CONTENT_TYPE_BASE_SOUNDS
The content consists of base sounds.
void SetFilterTerm(const char *str)
Set the term to filter on.
void SetFilterType(uint8 n_type)
Set the filtertype of the list.
@ WD_MATRIX_TOP
Offset at top of a matrix cell.
void OpenExternalSearch()
Search external websites for content.
void ScanScenarios()
Force a (re)scan of the scenarios.
void OnDownloadComplete(ContentID cid) override
We have finished downloading a file.
uint DoScan(Subdirectory sd)
Perform the scanning of a particular subdirectory.
@ SA_RIGHT
Right align the text (must be a single bit).
@ CONTENT_TYPE_AI
The content consists of an AI.
char(* tags)[32]
Malloced array of tags (strings)
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
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.
@ CONTENT_TYPE_BASE_GRAPHICS
The content consists of base graphics.
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 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,...
@ WID_NCL_SCROLLBAR
Scrollbar of matrix.
uint32 cur_id
The current ID of the downloaded file.
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.
~NetworkContentListWindow()
Free everything we allocated.
EventState OnKeyPress(WChar key, uint16 keycode) override
A key has been pressed.
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.
@ SA_CENTER
Center both horizontally and vertically.
char filename[48]
Filename (for the .tar.gz; only valid on download)
void Clear()
Clear all downloaded content information.
@ SA_HOR_CENTER
Horizontally center the text.
void SetSortType(uint8 n_type)
Set the sorttype of the list.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
TextfileType file_type
Type of textfile to view.
@ TFT_CHANGELOG
NewGRF changelog.
const typedef ContentInfo *const * ConstContentIterator
Iterator for the constant content vector.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Dimension checkbox_size
Size of checkbox/"blot" sprite.
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.
@ CONTENT_TYPE_BASE_MUSIC
The content consists of base music.
static const NWidgetPart _nested_network_content_list_widgets[]
The widgets for the content list.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
@ WN_NETWORK_WINDOW_CONTENT_LIST
Network content list.
@ WD_INSET_TOP
Top offset of string.
char *const buf
buffer in which text is saved
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=nullptr, uint textref_stack_size=0, const uint32 *textref_stack=nullptr)
Display an error message in a window.
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
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.
static bool CDECL TagNameFilter(const ContentInfo *const *a, ContentListFilterData &filter)
Filter content by tags/name.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
High level window description.
void RequestContentList(ContentType type)
Request the content list for the given type.
bool UpdateFilterState()
Update filter state based on current window state.
friend void BuildContentTypeStringList()
Build array of all strings corresponding to the content types.
bool IsDescSortOrder() const
Check if the sort order is descending.
Data structure describing how to show the list (what sort direction and criteria).
void SetFilterState(bool state)
Enable or disable the filter.
@ UNSELECTED
The content has not been selected.
static const int DRAW_STRING_BUFFER
Size of the buffer used for drawing strings.
Scrollbar * vscroll
Cache of the vertical scrollbar.
ResizeInfo resize
Resize information.
@ WID_NCL_UNSELECT
'Unselect all' button.
@ CONTENT_TYPE_HEIGHTMAP
The content consists of a heightmap.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
@ WD_INSET_RIGHT
Right offset of string.
bool SortFunction(const const ContentInfo * &, const const ContentInfo * &)
Signature of sort function.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
uint total_files
Number of files to download.
void SetListing(Listing l)
Import sort conditions.
@ WID_NCL_DOWNLOAD
'Download' button.
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
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 OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
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 IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
static bool _accepted_external_search
Whether the user accepted to enter external websites during this session.
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
int find_index(std::vector< T > const &vec, T const &item)
Helper function to get the index of an item Consider using std::set, std::unordered_set or std::flat_...
@ ES_NOT_HANDLED
The passed event is not handled.
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
void ShowNetworkContentListWindow(ContentVector *cv, ContentType type1, ContentType type2)
Show the content list window with a given set of content.
~NetworkContentDownloadStatusWindow()
Free whatever we've allocated.
@ CONTENT_FILTER_TEXT
Filter by query sting.
void SortContentList()
Sort the content list.
byte md5sum[16]
The MD5 checksum.
Data structure describing what to show in the list (filter criteria).
@ WID_NCL_CHECKBOX
Button above checkboxes.
StringFilter string_filter
Text filter of content list.
ContentListFilterData filter_data
Filter for content list.
void BuildContentTypeStringList()
Build array of all strings corresponding to the content types.
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Window * parent
Parent window.
@ CONTENT_TYPE_GAME
The content consists of a game script.
@ WID_NCL_BACKGROUND
Resize button.
@ CONTENT_TYPE_SCENARIO
The content consists of a scenario.
void Close() override
Disconnect from the content server.
@ WID_NCL_FILTER_CAPT
Caption for the filter editbox.
~BaseNetworkContentDownloadStatusWindow()
Free everything associated with this window.
void OnDownloadProgress(const ContentInfo *ci, int bytes) override
We have progress in the download of a file.
@ WID_NCL_FILTER
Filter editbox.
@ WD_INSET_LEFT
Left offset of string.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
@ SELECTED
The content has been manually selected.
@ CONTENT_TYPE_AI_LIBRARY
The content consists of an AI library.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
@ WDF_MODAL
The window is a modal child of some other window, meaning the parent is 'inactive'.
void ScanNewGRFFiles(NewGRFScanCallback *callback)
Scan for all NewGRFs.
@ WID_NCL_CANCEL
'Cancel' button.
Coordinates of a point in 2D.
static const NWidgetPart _nested_network_content_download_status_window_widgets[]
Nested widgets for the download window.
@ WID_NCDS_BACKGROUND
Background of the window.
bool IsWidgetFocused(byte widget_index) const
Check if given widget is focused within this window.
void RemoveCallback(ContentCallback *cb)
Remove a callback.
char url[96]
URL related to the content.
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
void DownloadSelectedContent(uint &files, uint &bytes, bool fallback=false)
Actually begin downloading the content we selected.
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.
uint step_height
Step-size of height resize changes.
@ WID_NCL_SEL_ALL_UPDATE
NWID_SELECTION widget for select all/update buttons..
void ToggleSortOrder()
Toggle the sort order Since that is the worst condition for the sort function reverse the list here.
@ TFT_README
NewGRF readme.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
@ CONTENT_TYPE_GAME_LIBRARY
The content consists of a GS library.
@ CONTENT_TYPE_NEWGRF
The content consists of a NewGRF.
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.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Window for showing the download status of content.
@ WID_NCL_SEARCH_EXTERNAL
Search external sites for missing NewGRF.
static const uint8 PC_GREY
Grey palette colour.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
char description[512]
Description of the content.
bool NeedRebuild() const
Check if a rebuild is needed.
ClientNetworkContentSocketHandler _network_content_client
The client we use to connect to the server.
@ TFT_LICENSE
NewGRF license.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
static void ExternalSearchDisclaimerCallback(Window *w, bool accepted)
Callback function for disclaimer about entering external websites.
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...
@ SBS_DOWN
Sort ascending.
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
@ WC_GAME_OPTIONS
Game options window; Window numbers:
@ SCENARIO
Scan for scenarios and heightmaps.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
@ ALREADY_HERE
The content is already at the client side.
Filter data for NetworkContentListWindow.
int list_pos
Our position in the list.
void ReverseLookupTreeDependency(ConstContentVector &tree, const ContentInfo *child) const
Reverse lookup the dependencies of all parents over a given child.
void OnReceiveContentInfo(const ContentInfo *rci) override
We received a content info.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
@ AUTOSELECTED
The content has been selected as dependency.
static const uint8 PC_DARK_BLUE
Dark blue palette colour.
void ToggleSelectedState(const ContentInfo *ci)
Toggle the state of a content info and check its dependencies.
@ WC_NETWORK_WINDOW
Network window; Window numbers:
bool CDECL FilterFunction(const const ContentInfo * *, ContentListFilterData &)
Signature of filter function.
static Listing last_sorting
The last sorting setting.
@ WC_NETWORK_STATUS_WINDOW
Network status window; Window numbers:
void ResetState()
Reset the matching state to process a new item.
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.
@ WID_NCL_TEXTFILE
Open readme, changelog (+1) or license (+2) of a file in the content window.
bool auto_select
Automatically select all content when the meta-data becomes available.
uint filesize_sum
The sum of all selected file sizes.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
EventState
State of handling an event.
void SetFiltering(Filtering f)
Import filter conditions.
bool GetState() const
Get the matching state of the current item.
uint8 dependency_count
Number of dependencies.
static bool TypeSorter(const ContentInfo *const &a, const ContentInfo *const &b)
Sort content by type.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
@ WL_ERROR
Errors (eg. saving/loading failed)
char version[16]
Version of the content.
@ WID_NCDS_CANCELOK
(Optional) Cancel/OK button.
uint downloaded_bytes
Number of bytes downloaded.
static const int ACTION_CLEAR
Clear editbox.
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
void AddCallback(ContentCallback *cb)
Add a callback to this class.
State state
Whether the content info is selected (for download)
uint32 unique_id
Unique ID; either GRF ID or shortname.
@ WD_MATRIX_BOTTOM
Offset at bottom of a matrix cell.
QueryString filter_editbox
Filter editbox;.
BaseNetworkContentDownloadStatusWindow(WindowDesc *desc)
Create the window with the given description.
@ CONTENT_TYPE_BEGIN
Helper to mark the begin of the types.
void ForceRebuild()
Force that a rebuild is needed.
void DrawDetails(const Rect &r) const
Helper function to draw the details part of this window.
#define lengthof(x)
Return the length of an fixed size array.
@ WID_NCL_TYPE
'Type' button.
void SelectAll()
Select everything we can select.
@ BASESET
Scan for base sets.
ContentID
Unique identifier for the content.
@ CONTENT_FILTER_TYPE_OR_SELECTED
Filter by being of displayed type or selected for download.
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
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...
Filtering GetFiltering() const
Export current filter conditions.
Data structure for an opened window.
void RebuildDone()
Notify the sortlist that the rebuild is done.
TextfileType
Additional text files accompanying Tar archives.
char * md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
Convert the md5sum to a hexadecimal string representation.
@ WD_MATRIX_LEFT
Offset at left of a matrix cell.
const ContentInfo * selected
The selected content info.
char name[32]
Name of the content.
void DrawWidgets() const
Paint all widgets of a window.
void SelectUpgrade()
Select everything that's an update for something we've got.
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
ContentID * dependencies
Malloced array of dependencies (unique server side ids)
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.
@ WID_NCL_SELECT_UPDATE
'Select updates' button.
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.
@ WC_TEXTFILE
textfile; Window numbers:
@ WID_NCL_OPEN_URL
'Open url' button.
#define lastof(x)
Get the last element of an fixed size array.
@ WD_PAR_VSEP_WIDE
Large amount of vertical space between two paragraphs of text.
std::vector< const ContentInfo * > ConstContentVector
Vector with constant content info.
static char content_type_strs[CONTENT_TYPE_END][64]
Cached strings for all content types.
void FilterContentList()
Filter the content list.
@ WDP_CENTER
Center the window.
void OnPaint() override
The window must be repainted.
@ WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD
Network content download status.
@ CONTENT_TYPE_END
Helper to mark the end of the types.
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
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)
uint32 filesize
Size of the file.
static GUIContentList::FilterFunction *const filter_funcs[]
Filter functions.
ConstContentIterator Begin() const
Get the begin of the content inf iterator.
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
static Filtering last_filtering
The last filtering setting.
ContentListFilterCriteria
Filter criteria for NetworkContentListWindow.
@ WID_NCL_SELECT_ALL
'Select all' button.