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);
 
   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)
 
  119  void BaseNetworkContentDownloadStatusWindow::DrawWidget(
const Rect &r, 
int widget)
 const 
  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;
 
  148  void BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(
const ContentInfo *ci, 
int bytes)
 
  150   if (ci->
id != this->cur_id) {
 
  261   virtual void OnClick(
Point pt, 
int widget, 
int click_count)
 
  275   virtual void OnDownloadProgress(
const ContentInfo *ci, 
int bytes)
 
  277     BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(ci, bytes);
 
  290   std::bitset<CONTENT_TYPE_END> 
types; 
 
  326     extern void OpenBrowser(
const char *url);
 
  329     const char *last = 
lastof(url);
 
  331     char *pos = 
strecpy(url, 
"http://grfsearch.openttd.org/?", last);
 
  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) {
 
  391     bool all_available = 
true;
 
  412     return strnatcmp((*a)->name, (*b)->name, 
true); 
 
  419     if ((*a)->type != (*b)->type) {
 
  429     int r = (*a)->state - (*b)->state;
 
  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;
 
  479     if (!changed) 
return;
 
  502     if (new_state != old_params.
state) {
 
  505     return new_state != old_params.
state;
 
  588         size->height = 10 * resize->height;
 
  594   virtual void DrawWidget(
const Rect &r, 
int widget)
 const 
  598         DrawString(r.left, r.right, r.top, STR_CONTENT_FILTER_TITLE, TC_FROMSTRING, 
SA_RIGHT);
 
  611   virtual void OnPaint()
 
  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);
 
  666       y += this->resize.step_height;
 
  676     static const int DETAIL_LEFT         =  5; 
 
  677     static const int DETAIL_RIGHT        =  5; 
 
  678     static const int DETAIL_TOP          =  5; 
 
  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);
 
  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);
 
  783   virtual void OnClick(
Point pt, 
int widget, 
int click_count)
 
  850           extern void OpenBrowser(
const char *url);
 
  940   virtual void OnEditboxChanged(
int wid)
 
  950   virtual void OnResize()
 
  955   virtual void OnReceiveContentInfo(
const ContentInfo *rci)
 
  962   virtual void OnDownloadComplete(
ContentID cid)
 
  968   virtual void OnConnect(
bool success)
 
  986     if (!gui_scope) 
return;
 
  991     bool show_select_all = 
false;
 
  992     bool show_select_upgrade = 
false;
 
 1002           show_select_all = 
true;
 
 1003           show_select_upgrade |= ci->
upgrade;
 
 1017     for (
TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
 
 1021     this->GetWidget<NWidgetCore>(
WID_NCL_CANCEL)->widget_data = this->
filesize_sum == 0 ? STR_AI_SETTINGS_CLOSE : STR_AI_LIST_CANCEL;
 
 1036   &TypeOrSelectedFilter,
 
 1047     GetString(NetworkContentListWindow::content_type_strs[i], STR_CONTENT_TYPE_BASE_GRAPHICS + i - 
CONTENT_TYPE_BASE_GRAPHICS, 
lastof(NetworkContentListWindow::content_type_strs[i]));
 
 1064             SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
 
 1075                       SetDataTip(STR_CONTENT_TYPE_CAPTION, STR_CONTENT_TYPE_CAPTION_TOOLTIP),
 
 1077                       SetDataTip(STR_CONTENT_NAME_CAPTION, STR_CONTENT_NAME_CAPTION_TOOLTIP),
 
 1079             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),
 
 1086                         SetDataTip(STR_CONTENT_SELECT_UPDATES_CAPTION, STR_CONTENT_SELECT_UPDATES_CAPTION_TOOLTIP),
 
 1088                         SetDataTip(STR_CONTENT_SELECT_ALL_CAPTION, STR_CONTENT_SELECT_ALL_CAPTION_TOOLTIP),
 
 1091                         SetDataTip(STR_CONTENT_UNSELECT_ALL_CAPTION, STR_CONTENT_UNSELECT_ALL_CAPTION_TOOLTIP),
 
 1111                     SetDataTip(STR_CONTENT_SEARCH_EXTERNAL, STR_CONTENT_SEARCH_EXTERNAL_TOOLTIP),
 
 1116                       SetDataTip(STR_CONTENT_DOWNLOAD_CAPTION, STR_CONTENT_DOWNLOAD_CAPTION_TOOLTIP),
 
 1133   _nested_network_content_list_widgets, 
lengthof(_nested_network_content_list_widgets)
 
 1145 #if defined(WITH_ZLIB) 
 1146   std::bitset<CONTENT_TYPE_END> types;