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) |
Update size and resize step of a widget in the window. | |
virtual void | DrawWidget (const Rect &r, int widget) const |
Draw the contents of a nested widget. | |
virtual void | OnPaint () |
The window must be repainted. | |
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) |
A click with the left mouse button has been made on the window. | |
virtual void | OnMouseLoop () |
Called for every mouse loop run, which is at least once per (game) tick. | |
virtual EventState | OnKeyPress (uint16 key, uint16 keycode) |
A key has been pressed. | |
virtual void | OnOSKInput (int wid) |
virtual void | OnResize () |
Called after the window got resized. | |
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(), CS_ALPHANUMERAL, 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, NCLWW_SEL_ALL_UPDATE, 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, WD_PAR_VSEP_NORMAL, and WD_PAR_VSEP_WIDE.
Referenced by DrawWidget().
virtual void NetworkContentListWindow::DrawWidget | ( | const Rect & | r, | |
int | widget | |||
) | const [inline, virtual] |
Draw the contents of a nested widget.
r | Rectangle occupied by the widget. | |
widget | Number of the widget to draw. |
Reimplemented from Window.
Definition at line 404 of file network_content_gui.cpp.
References DrawDetails(), DrawString(), NCLWW_DETAILS, NCLWW_FILTER_CAPT, NCLWW_MATRIX, and SA_RIGHT.
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::OnClick | ( | Point | pt, | |
int | widget, | |||
int | click_count | |||
) | [inline, virtual] |
A click with the left mouse button has been made on the window.
pt | the point inside the window that has been clicked. | |
widget | the clicked widget. | |
click_count | Number of fast consecutive clicks at same position |
Reimplemented from Window.
Definition at line 590 of file network_content_gui.cpp.
References BringWindowToFrontById(), content, NWidgetBase::current_x, GUIList< T, F >::ForceResort(), SmallVector< T, S >::Get(), Scrollbar::GetScrolledRowFromWidget(), Window::InvalidateData(), IsInsideBS(), SmallVector< T, S >::Length(), list_pos, NCLWW_CANCEL, NCLWW_CHECKBOX, NCLWW_DOWNLOAD, NCLWW_MATRIX, NCLWW_NAME, NCLWW_SELECT_ALL, NCLWW_SELECT_UPDATE, NCLWW_TYPE, NCLWW_UNSELECT, NWidgetBase::pos_x, ScrollToSelected(), ClientNetworkContentSocketHandler::SelectAll(), selected, ClientNetworkContentSocketHandler::SelectUpgrade(), GUIList< T, F >::SetSortType(), SortContentList(), GUIList< T, F >::SortType(), ClientNetworkContentSocketHandler::ToggleSelectedState(), GUIList< T, F >::ToggleSortOrder(), and ClientNetworkContentSocketHandler::UnselectAll().
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. |
Reimplemented from Window.
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_CANCEL, 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 EventState NetworkContentListWindow::OnKeyPress | ( | uint16 | key, | |
uint16 | keycode | |||
) | [inline, virtual] |
A key has been pressed.
key | the Unicode value of the key. | |
keycode | the untranslated key code including shift state. |
Reimplemented from Window.
Definition at line 655 of file network_content_gui.cpp.
References content, ES_HANDLED, ES_NOT_HANDLED, GUIList< T, F >::ForceResort(), SmallVector< T, S >::Get(), Scrollbar::GetCapacity(), Window::InvalidateData(), Window::IsWidgetFocused(), ClientNetworkContentSocketHandler::Length(), SmallVector< T, S >::Length(), list_pos, min(), NCLWW_FILTER, ScrollToSelected(), selected, and ClientNetworkContentSocketHandler::ToggleSelectedState().
virtual void NetworkContentListWindow::OnPaint | ( | ) | [inline, virtual] |
The window must be repainted.
Reimplemented from Window.
Definition at line 421 of file network_content_gui.cpp.
References BuildContentList(), content, Window::DrawSortButtonState(), Window::DrawWidgets(), GUIList< T, F >::IsDescSortOrder(), NCLWW_CHECKBOX, NCLWW_FILTER, NCLWW_NAME, NCLWW_TYPE, GUIList< T, F >::NeedRebuild(), SBS_DOWN, SBS_UP, and GUIList< T, F >::SortType().
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().
virtual void NetworkContentListWindow::OnResize | ( | ) | [inline, virtual] |
Called after the window got resized.
For nested windows with a viewport, call NWidgetViewport::UpdateViewportCoordinates.
Reimplemented from Window.
Definition at line 725 of file network_content_gui.cpp.
References Scrollbar::GetCapacity(), MAT_COL_START, MAT_ROW_START, NCLWW_MATRIX, and Scrollbar::SetCapacityFromWidget().
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().
virtual void NetworkContentListWindow::UpdateWidgetSize | ( | int | widget, | |
Dimension * | size, | |||
const Dimension & | padding, | |||
Dimension * | fill, | |||
Dimension * | resize | |||
) | [inline, virtual] |
Update size and resize step of a widget in the window.
After retrieval of the minimal size and the resize-steps of a widget, this function is called to allow further refinement, typically by computing the real maximal size of the content. Afterwards, size is taken to be the minimal size of the widget and resize is taken to contain the resize steps. For the convenience of the callee, padding contains the amount of padding between the content and the edge of the widget. This should be added to the returned size.
widget | Widget number. | |
size | Size of the widget. | |
padding | Recommended amount of space between the widget content and the widget edge. | |
fill | Fill step of the widget. | |
resize | Resize step of the widget. |
Reimplemented from Window.
Definition at line 380 of file network_content_gui.cpp.
References CONTENT_TYPE_BASE_GRAPHICS, CONTENT_TYPE_BEGIN, CONTENT_TYPE_END, FONT_HEIGHT_NORMAL, GetStringBoundingBox(), maxdim(), NCLWW_FILTER_CAPT, NCLWW_MATRIX, NCLWW_TYPE, WD_MATRIX_BOTTOM, WD_MATRIX_LEFT, WD_MATRIX_RIGHT, and WD_MATRIX_TOP.
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().