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"
32 #include "../safeguards.h"
45 const char *textfile = this->ci->
GetTextfile(file_type);
62 default: NOT_REACHED();
100 _nested_network_content_download_status_window_widgets,
lengthof(_nested_network_content_download_status_window_widgets)
104 Window(desc), cur_id(UINT32_MAX)
117 void BaseNetworkContentDownloadStatusWindow::DrawWidget(
const Rect &r,
int widget)
const
122 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);
132 str = STR_CONTENT_DOWNLOAD_COMPLETE;
137 str = STR_CONTENT_DOWNLOAD_FILE;
139 str = STR_CONTENT_DOWNLOAD_INITIALISE;
146 void BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(
const ContentInfo *ci,
int bytes)
148 if (ci->
id != this->cur_id) {
259 virtual void OnClick(
Point pt,
int widget,
int click_count)
273 virtual void OnDownloadProgress(
const ContentInfo *ci,
int bytes)
275 BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(ci, bytes);
310 extern void OpenBrowser(
const char *url);
313 const char *last =
lastof(url);
315 char *pos =
strecpy(url,
"http://grfsearch.openttd.org/?", last);
318 pos =
strecpy(pos,
"do=searchgrfid&q=", last);
325 if (!first) pos =
strecpy(pos,
",", last);
333 pos =
strecpy(pos,
"do=searchtext&q=", last);
336 for (
const char *search = this->
filter_editbox.text.
buf; *search !=
'\0'; search++) {
338 if (*search ==
'\'' || *search ==
'"')
continue;
341 if (*search < 0x30) {
342 pos +=
seprintf(pos, last,
"%%%02X", *search);
343 }
else if (pos < last) {
375 bool all_available =
true;
396 return strnatcmp((*a)->name, (*b)->name,
true);
403 if ((*a)->type != (*b)->type) {
417 int r = (*a)->state - (*b)->state;
439 for (
int i = 0; i < (*a)->tag_count; i++) {
537 size->height = 10 * resize->height;
543 virtual void DrawWidget(
const Rect &r,
int widget)
const
547 DrawString(r.left, r.right, r.top, STR_CONTENT_FILTER_TITLE, TC_FROMSTRING,
SA_RIGHT);
560 virtual void OnPaint()
607 default: NOT_REACHED();
609 DrawSprite(sprite, pal, nwi_checkbox->
pos_x + (pal == PAL_NONE ? 2 : 3), y + sprite_y_offset + (pal == PAL_NONE ? 1 : 0));
612 DrawString(nwi_type->pos_x, nwi_type->pos_x + nwi_type->current_x - 1, y + text_y_offset, str, TC_BLACK,
SA_HOR_CENTER);
615 y += this->resize.step_height;
625 static const int DETAIL_LEFT = 5;
626 static const int DETAIL_RIGHT = 5;
627 static const int DETAIL_TOP = 5;
647 int y = r.top + DETAIL_TITLE_HEIGHT + DETAIL_TOP;
651 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_UPDATE);
656 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_NAME);
660 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_VERSION);
665 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_DESCRIPTION);
670 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_URL);
674 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_TYPE);
678 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_FILESIZE);
691 if (ci->
id != cid)
continue;
693 p +=
seprintf(p,
lastof(buf), p == buf ?
"%s" :
", %s", (*iter)->name);
698 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_DEPENDENCIES);
709 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_TAGS);
727 y =
DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_SELECTED_BECAUSE_OF);
732 virtual void OnClick(
Point pt,
int widget,
int click_count)
795 extern void OpenBrowser(
const char *url);
873 virtual void OnEditboxChanged(
int wid)
883 virtual void OnResize()
888 virtual void OnReceiveContentInfo(
const ContentInfo *rci)
895 virtual void OnDownloadComplete(
ContentID cid)
901 virtual void OnConnect(
bool success)
919 if (!gui_scope)
return;
924 bool show_select_all =
false;
925 bool show_select_upgrade =
false;
935 show_select_all =
true;
936 show_select_upgrade |= ci->
upgrade;
950 for (
TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
954 this->GetWidget<NWidgetCore>(
WID_NCL_CANCEL)->widget_data = this->
filesize_sum == 0 ? STR_AI_SETTINGS_CLOSE : STR_AI_LIST_CANCEL;
984 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
995 SetDataTip(STR_CONTENT_TYPE_CAPTION, STR_CONTENT_TYPE_CAPTION_TOOLTIP),
997 SetDataTip(STR_CONTENT_NAME_CAPTION, STR_CONTENT_NAME_CAPTION_TOOLTIP),
999 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),
1006 SetDataTip(STR_CONTENT_SELECT_UPDATES_CAPTION, STR_CONTENT_SELECT_UPDATES_CAPTION_TOOLTIP),
1008 SetDataTip(STR_CONTENT_SELECT_ALL_CAPTION, STR_CONTENT_SELECT_ALL_CAPTION_TOOLTIP),
1011 SetDataTip(STR_CONTENT_UNSELECT_ALL_CAPTION, STR_CONTENT_UNSELECT_ALL_CAPTION_TOOLTIP),
1031 SetDataTip(STR_CONTENT_SEARCH_EXTERNAL, STR_CONTENT_SEARCH_EXTERNAL_TOOLTIP),
1036 SetDataTip(STR_CONTENT_DOWNLOAD_CAPTION, STR_CONTENT_DOWNLOAD_CAPTION_TOOLTIP),
1053 _nested_network_content_list_widgets,
lengthof(_nested_network_content_list_widgets)
1063 #if defined(WITH_ZLIB)