Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes

# NetworkContentListWindow Class Reference

Window that lists the content that's at the content server. More...

Inheritance diagram for NetworkContentListWindow:

## Public Member Functions
| NetworkContentListWindow (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
| Draw/fill the matrix with the list of content to download.
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 EventState | OnKeyPress (WChar key, uint16 keycode)
virtual void | OnEditboxChanged (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 *, StringFilter & > | GUIContentList
| List with content infos.
## Private Member Functions
void | OpenExternalSearch ()
| Search external websites for content.
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 void | ExternalSearchDisclaimerCallback (Window *w, bool accepted)
| Callback function for disclaimer about entering external websites.
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, StringFilter &filter)
| Filter content by tags/name.
## Private Attributes
GUIContentList | content
| List with content.
bool | auto_select
| Automatically select all content when the meta-data becomes available.
StringFilter | string_filter
| Filter for content list.
QueryString | filter_editbox
| Filter editbox;.
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
| Cache of the vertical scrollbar.
## Static Private Attributes
static const uint | EDITBOX_MAX_SIZE = 50
| Maximum size of the editbox in characters.
static Listing | last_sorting = {false, 1}
| The last sorting setting.
static Filtering | last_filtering = {false, 0}
| The last filtering setting.
static GUIContentList::SortFunction *const | sorter_funcs []
| Sorter functions.
static GUIContentList::FilterFunction *const | filter_funcs []
| Filter functions.

## Detailed Description

Window that lists the content that's at the content server.

Definition at line 284 of file network_content_gui.cpp.

## Member Typedef Documentation

typedef GUIList<const ContentInfo *, StringFilter &> NetworkContentListWindow::GUIContentList`[private]`

List with content infos.

Definition at line 286 of file network_content_gui.cpp.

## Constructor & Destructor Documentation

NetworkContentListWindow::NetworkContentListWindow | ( | WindowDesc * | desc,
|  | bool | select_all |
| ) |  |  | `[inline]`

Create the content list window.

Parameters:

  | desc | the window description to pass to Window's constructor.
  | select_all | Whether the select all button is allowed or not.

Definition at line 475 of file network_content_gui.cpp.

References _network_content_client, QueryString::ACTION_CLEAR, ClientNetworkContentSocketHandler::AddCallback(), auto_select, QueryString::cancel_button, content, Window::CreateNestedTree(), filter_editbox, filter_funcs, FilterContentList(), Window::FinishInitNested(), GUIList< T, F >::ForceRebuild(), Window::GetScrollbar(), Window::InvalidateData(), last_filtering, last_sorting, Window::querystrings, GUIList< T, F >::SetFilterFuncs(), GUIList< T, F >::SetFiltering(), Window::SetFocusedWidget(), GUIList< T, F >::SetListing(), GUIList< T, F >::SetSortFuncs(), Window::SetWidgetDisabledState(), SortContentList(), sorter_funcs, vscroll, WID_NCL_FILTER, WID_NCL_SCROLLBAR, WID_NCL_SEARCH_EXTERNAL, and WN_NETWORK_WINDOW_CONTENT_LIST.

## Member Function Documentation

void NetworkContentListWindow::DrawDetails | ( | const Rect & | r | ) | const`[inline]`

Helper function to draw the details part of this window.

Parameters:

  | 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 612 of file network_content_gui.cpp.

References _network_content_client, 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, PC_DARK_BLUE, 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.

void NetworkContentListWindow::DrawMatrix | ( | const Rect & | r | ) | const`[inline]`

Draw/fill the matrix with the list of content to download.

Parameters:

  | r | The boundaries of the matrix.

Definition at line 572 of file network_content_gui.cpp.

References ContentInfo::ALREADY_HERE, ContentInfo::AUTOSELECTED, content, ContentInfo::DOES_NOT_EXIST, DrawSprite(), DrawString(), SmallVector< T, S >::End(), FONT_HEIGHT_NORMAL, SmallVector< T, S >::Get(), Scrollbar::GetCapacity(), GfxFillRect(), ContentInfo::name, PC_GREY, NWidgetBase::pos_x, SA_HOR_CENTER, ContentInfo::SELECTED, selected, ContentInfo::state, ContentInfo::type, ContentInfo::UNSELECTED, vscroll, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, and WD_MATRIX_TOP.

static int CDECL NetworkContentListWindow::NameSorter | ( | const ContentInfo *const * | a,
|  | const ContentInfo *const * | b |
| ) |  |  | `[inline, static, private]`

Sort content by name.

Definition at line 391 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.

Parameters:

  | success | whether the connection was made or that we failed to make it

Reimplemented from ContentCallback.

Definition at line 890 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.

Parameters:

  | cid | the ContentID of the downloaded file

Reimplemented from ContentCallback.

Definition at line 884 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.

Parameters:

  | 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 906 of file network_content_gui.cpp.

References ContentInfo::ALREADY_HERE, ContentInfo::AUTOSELECTED, SmallVector< T, S >::Begin(), BuildContentList(), content, SmallVector< T, S >::End(), ContentInfo::filesize, filesize_sum, FindWindowById(), GUIList< T, F >::NeedRebuild(), selected, ContentInfo::SELECTED, Window::SetWidgetDisabledState(), ContentInfo::state, StrEmpty(), ContentInfo::UNSELECTED, ContentInfo::upgrade, ContentInfo::url, WC_NETWORK_STATUS_WINDOW, WID_NCL_DOWNLOAD, WID_NCL_OPEN_URL, WID_NCL_SELECT_ALL, WID_NCL_SELECT_UPDATE, WID_NCL_TEXTFILE, WID_NCL_UNSELECT, and WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD.

virtual void NetworkContentListWindow::OnReceiveContentInfo | ( | const ContentInfo * | ci | ) | `[inline, virtual]`

We received a content info.

Parameters:

  | ci | the content info

Reimplemented from ContentCallback.

Definition at line 877 of file network_content_gui.cpp.

References _network_content_client, auto_select, content, GUIList< T, F >::ForceRebuild(), Window::InvalidateData(), ContentInfo::IsSelected(), and ClientNetworkContentSocketHandler::ToggleSelectedState().

static int CDECL NetworkContentListWindow::StateSorter | ( | const ContentInfo *const * | a,
|  | const ContentInfo *const * | b |
| ) |  |  | `[inline, static, private]`

Sort content by state.

Definition at line 412 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 397 of file network_content_gui.cpp.

References CONTENT_TYPE_BASE_GRAPHICS, lastof, NameSorter(), and strnatcmp().

Referenced by StateSorter().

## Field Documentation

NetworkContentListWindow::GUIContentList::FilterFunction *const NetworkContentListWindow::filter_funcs`[static, private]`

Initial value:

     {
      &TagNameFilter,
    }

Filter functions.

Definition at line 293 of file network_content_gui.cpp.

Referenced by NetworkContentListWindow().

NetworkContentListWindow::GUIContentList::SortFunction *const NetworkContentListWindow::sorter_funcs`[static, private]`

Initial value:

     {
      &StateSorter,
      &TypeSorter,
      &NameSorter,
    }

Sorter functions.

Definition at line 292 of file network_content_gui.cpp.

Referenced by NetworkContentListWindow().

The documentation for this class was generated from the following file:

- src/network/network_content_gui.cpp