Window that lists the content that's at the content server. More...
Public Member Functions | |
NetworkContentListWindow (const WindowDesc *desc, bool select_all) | |
Create the content list window. | |
~NetworkContentListWindow () | |
Free everything we allocated. | |
virtual void | UpdateWidgetSize (int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
virtual void | DrawWidget (const Rect &r, int widget) const |
virtual void | OnPaint () |
void | DrawMatrix (const Rect &r) const |
void | DrawDetails (const Rect &r) const |
Helper function to draw the details part of this window. | |
virtual void | OnClick (Point pt, int widget, int click_count) |
virtual void | OnMouseLoop () |
virtual EventState | OnKeyPress (uint16 key, uint16 keycode) |
virtual void | OnOSKInput (int wid) |
virtual void | OnResize () |
virtual void | OnReceiveContentInfo (const ContentInfo *rci) |
We received a content info. | |
virtual void | OnDownloadComplete (ContentID cid) |
We have finished downloading a file. | |
virtual void | OnConnect (bool success) |
Callback for when the connection has finished. | |
virtual void | OnInvalidateData (int data=0, bool gui_scope=true) |
Some data on this window has become invalid. | |
Private Types | |
typedef GUIList< const ContentInfo * > | GUIContentList |
Private Member Functions | |
void | BuildContentList () |
(Re)build the network game list as its amount has changed because an item has been added or deleted for example | |
void | SortContentList () |
Sort the content list. | |
void | FilterContentList () |
Filter the content list. | |
void | ScrollToSelected () |
Make sure that the currently selected content info is within the visible part of the matrix. | |
Static Private Member Functions | |
static int CDECL | NameSorter (const ContentInfo *const *a, const ContentInfo *const *b) |
Sort content by name. | |
static int CDECL | TypeSorter (const ContentInfo *const *a, const ContentInfo *const *b) |
Sort content by type. | |
static int CDECL | StateSorter (const ContentInfo *const *a, const ContentInfo *const *b) |
Sort content by state. | |
static bool CDECL | TagNameFilter (const ContentInfo *const *a, const char *filter_string) |
Filter content by tags/name. | |
Private Attributes | |
GUIContentList | content |
List with content. | |
const ContentInfo * | selected |
The selected content info. | |
int | list_pos |
Our position in the list. | |
uint | filesize_sum |
The sum of all selected file sizes. | |
Scrollbar * | vscroll |
Static Private Attributes | |
static const uint | EDITBOX_MAX_SIZE = 50 |
static const uint | EDITBOX_MAX_LENGTH = 300 |
static Listing | last_sorting = {false, 1} |
Runtime saved values. | |
static Filtering | last_filtering = {false, 0} |
static GUIContentList::SortFunction *const | sorter_funcs [] |
The sorter functions. | |
static GUIContentList::FilterFunction *const | filter_funcs [] |
Window that lists the content that's at the content server.
Definition at line 223 of file network_content_gui.cpp.
NetworkContentListWindow::NetworkContentListWindow | ( | const WindowDesc * | desc, | |
bool | select_all | |||
) | [inline] |
Create the content list window.
desc | the window description to pass to Window's constructor. |
Definition at line 348 of file network_content_gui.cpp.
References ClientNetworkContentSocketHandler::AddCallback(), content, Window::CreateNestedTree(), QueryStringBaseWindow::edit_str_buf, QueryStringBaseWindow::edit_str_size, FilterContentList(), Window::FinishInitNested(), GUIList< T, F >::ForceRebuild(), Window::GetScrollbar(), InitializeTextBuffer(), Window::InvalidateData(), last_sorting, NCLWW_FILTER, NCLWW_SCROLLBAR, GUIList< T, F >::SetFilterFuncs(), GUIList< T, F >::SetFiltering(), Window::SetFocusedWidget(), GUIList< T, F >::SetListing(), GUIList< T, F >::SetSortFuncs(), SortContentList(), and sorter_funcs.
void NetworkContentListWindow::DrawDetails | ( | const Rect & | r | ) | const [inline] |
Helper function to draw the details part of this window.
r | the rectangle to stay within while drawing |
< Number of pixels at the left
< Number of pixels at the right
< Number of pixels at the top
Definition at line 481 of file network_content_gui.cpp.
References SmallVector< T, S >::Begin(), ClientNetworkContentSocketHandler::Begin(), CONTENT_TYPE_BASE_GRAPHICS, ContentInfo::dependencies, ContentInfo::dependency_count, ContentInfo::description, DRAW_STRING_BUFFER, DrawString(), DrawStringMultiLine(), SmallVector< T, S >::End(), ClientNetworkContentSocketHandler::End(), ContentInfo::filesize, filesize_sum, FONT_HEIGHT_NORMAL, GfxFillRect(), ContentInfo::id, ContentInfo::IsSelected(), lastof, ContentInfo::name, ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(), SA_CENTER, SA_HOR_CENTER, ContentInfo::SELECTED, selected, seprintf(), SetDParam(), SetDParamStr(), ContentInfo::state, StrEmpty(), ContentInfo::tag_count, ContentInfo::tags, ContentInfo::type, ContentInfo::upgrade, ContentInfo::url, ContentInfo::version, WD_INSET_LEFT, WD_INSET_RIGHT, WD_INSET_TOP, and WD_PAR_VSEP_NORMAL.
static int CDECL NetworkContentListWindow::NameSorter | ( | const ContentInfo *const * | a, | |
const ContentInfo *const * | b | |||
) | [inline, static, private] |
Sort content by name.
Definition at line 267 of file network_content_gui.cpp.
References strnatcmp().
Referenced by TypeSorter().
virtual void NetworkContentListWindow::OnConnect | ( | bool | success | ) | [inline, virtual] |
Callback for when the connection has finished.
success | whether the connection was made or that we failed to make it |
Reimplemented from ContentCallback.
Definition at line 743 of file network_content_gui.cpp.
References INVALID_STRING_ID, Window::InvalidateData(), ShowErrorMessage(), and WL_ERROR.
virtual void NetworkContentListWindow::OnDownloadComplete | ( | ContentID | cid | ) | [inline, virtual] |
We have finished downloading a file.
cid | the ContentID of the downloaded file |
Reimplemented from ContentCallback.
Definition at line 737 of file network_content_gui.cpp.
References content, GUIList< T, F >::ForceResort(), and Window::InvalidateData().
virtual void NetworkContentListWindow::OnInvalidateData | ( | int | data = 0 , |
|
bool | gui_scope = true | |||
) | [inline, virtual] |
Some data on this window has become invalid.
data | Information about the changed data. | |
gui_scope | Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See InvalidateWindowData() for details. |
Definition at line 759 of file network_content_gui.cpp.
References ContentInfo::AUTOSELECTED, SmallVector< T, S >::Begin(), BuildContentList(), content, SmallVector< T, S >::End(), ContentInfo::filesize, filesize_sum, FindWindowById(), NCLWW_DOWNLOAD, NCLWW_SELECT_ALL, NCLWW_SELECT_UPDATE, NCLWW_UNSELECT, GUIList< T, F >::NeedRebuild(), ContentInfo::SELECTED, Window::SetWidgetDisabledState(), ContentInfo::state, ContentInfo::UNSELECTED, and ContentInfo::upgrade.
virtual void NetworkContentListWindow::OnReceiveContentInfo | ( | const ContentInfo * | ci | ) | [inline, virtual] |
We received a content info.
ci | the content info |
Reimplemented from ContentCallback.
Definition at line 731 of file network_content_gui.cpp.
References content, GUIList< T, F >::ForceRebuild(), and Window::InvalidateData().
static int CDECL NetworkContentListWindow::StateSorter | ( | const ContentInfo *const * | a, | |
const ContentInfo *const * | b | |||
) | [inline, static, private] |
Sort content by state.
Definition at line 288 of file network_content_gui.cpp.
References TypeSorter().
static int CDECL NetworkContentListWindow::TypeSorter | ( | const ContentInfo *const * | a, | |
const ContentInfo *const * | b | |||
) | [inline, static, private] |
Sort content by type.
Definition at line 273 of file network_content_gui.cpp.
References CONTENT_TYPE_BASE_GRAPHICS, lastof, NameSorter(), and strnatcmp().
Referenced by StateSorter().
NetworkContentListWindow::GUIContentList::FilterFunction *const NetworkContentListWindow::filter_funcs [static, private] |
{ &TagNameFilter, }
Definition at line 234 of file network_content_gui.cpp.
NetworkContentListWindow::GUIContentList::SortFunction *const NetworkContentListWindow::sorter_funcs [static, private] |
{ &StateSorter, &TypeSorter, &NameSorter, }
The sorter functions.
Definition at line 233 of file network_content_gui.cpp.
Referenced by NetworkContentListWindow().