NetworkContentListWindow Class Reference

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

Inheritance diagram for NetworkContentListWindow:
QueryStringBaseWindow ContentCallback Window QueryString ZeroedMemoryAllocator

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
 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)
 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)
 Callback for when on input has been entered with the OSK.
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
 List with content infos.

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 ContentInfoselected
 The selected content info.
int list_pos
 Our position in the list.
uint filesize_sum
 The sum of all selected file sizes.
Scrollbarvscroll
 Cache of the vertical scrollbar.

Static Private Attributes

static const uint EDITBOX_MAX_SIZE = 50
 Maximum size of the editbox in characters.
static const uint EDITBOX_MAX_LENGTH = 300
 Maximum size of the editbox in pixels.
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 222 of file network_content_gui.cpp.


Member Typedef Documentation

List with content infos.

Definition at line 224 of file network_content_gui.cpp.


Constructor & Destructor Documentation

NetworkContentListWindow::NetworkContentListWindow ( const WindowDesc desc,
bool  select_all 
) [inline]

Member Function Documentation

void NetworkContentListWindow::DrawDetails ( const Rect r  )  const [inline]
void NetworkContentListWindow::DrawMatrix ( const Rect r  )  const [inline]
virtual void NetworkContentListWindow::DrawWidget ( const Rect r,
int  widget 
) const [inline, virtual]

Draw the contents of a nested widget.

Parameters:
r Rectangle occupied by the widget.
widget Number of the widget to draw.
Note:
This method may not change any state, it may only use drawing functions.

Reimplemented from Window.

Definition at line 403 of file network_content_gui.cpp.

References DrawDetails(), DrawMatrix(), 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 265 of file network_content_gui.cpp.

References strnatcmp().

Referenced by TypeSorter().

virtual void NetworkContentListWindow::OnClick ( Point  pt,
int  widget,
int  click_count 
) [inline, virtual]
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 746 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 740 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.

Reimplemented from Window.

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

Parameters:
key the Unicode value of the key.
keycode the untranslated key code including shift state.
Returns:
ES_HANDLED if the key press has been handled and no other window should receive the event.

Reimplemented from Window.

Definition at line 658 of file network_content_gui.cpp.

References _network_content_client, 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, OnOSKInput(), ScrollToSelected(), selected, ClientNetworkContentSocketHandler::ToggleSelectedState(), and vscroll.

virtual void NetworkContentListWindow::OnOSKInput ( int  wid  )  [inline, virtual]

Callback for when on input has been entered with the OSK.

Parameters:
wid The widget the OSK was attached to.

Reimplemented from QueryStringBaseWindow.

Definition at line 721 of file network_content_gui.cpp.

References content, QueryStringBaseWindow::edit_str_buf, GUIList< T, F >::ForceRebuild(), Window::InvalidateData(), GUIList< T, F >::SetFilterState(), and StrEmpty().

Referenced by OnKeyPress().

virtual void NetworkContentListWindow::OnPaint (  )  [inline, virtual]

The window must be repainted.

Note:
This method should not change any state, it should only use drawing functions.

Reimplemented from Window.

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

Parameters:
ci the content info

Reimplemented from ContentCallback.

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

References Scrollbar::GetCapacity(), MAT_COL_START, MAT_ROW_START, NCLWW_MATRIX, Scrollbar::SetCapacityFromWidget(), and vscroll.

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

Sort content by state.

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

Parameters:
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 379 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.


Field Documentation

Initial value:

Filter functions.

Definition at line 232 of file network_content_gui.cpp.

Referenced by NetworkContentListWindow().

Initial value:

Sorter functions.

Definition at line 231 of file network_content_gui.cpp.

Referenced by NetworkContentListWindow().


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

Generated on Sun May 8 07:31:17 2011 for OpenTTD by  doxygen 1.6.1