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
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)
 Some data on this window has become invalid.

Private Types

enum  { EDITBOX_MAX_SIZE = 50, EDITBOX_MAX_LENGTH = 300 }
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 ContentInfoselected
 The selected content info.
int list_pos
 Our position in the list.
uint filesize_sum
 The sum of all selected file sizes.

Static Private Attributes

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 []

Detailed Description

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

Definition at line 220 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]
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 400 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 265 of file network_content_gui.cpp.

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

References INVALID_STRING_ID, Window::InvalidateData(), and ShowErrorMessage().

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

References content, GUIList< T, F >::ForceResort(), and Window::InvalidateData().

virtual void NetworkContentListWindow::OnInvalidateData ( int  data  )  [inline, virtual]
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 654 of file network_content_gui.cpp.

References content, Window::ES_HANDLED, Window::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, ClientNetworkContentSocketHandler::ToggleSelectedState(), and Window::vscroll.

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 417 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 730 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 724 of file network_content_gui.cpp.

References Scrollbar::GetCapacity(), MAT_COL_START, MAT_ROW_START, NCLWW_MATRIX, Scrollbar::SetCapacityFromWidget(), and Window::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, and NameSorter().

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 376 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

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

Definition at line 233 of file network_content_gui.cpp.

Initial value:

The sorter functions.

Definition at line 232 of file network_content_gui.cpp.

Referenced by NetworkContentListWindow().


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

Generated on Wed Feb 17 23:07:35 2010 for OpenTTD by  doxygen 1.6.1