NetworkGameWindow Class Reference

Inheritance diagram for NetworkGameWindow:
QueryStringBaseWindow Window QueryString ZeroedMemoryAllocator

Public Member Functions

 NetworkGameWindow (const WindowDesc *desc)
virtual void SetStringParameters (int widget) const
 Initialize string parameters for a widget.
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 DrawDetails (const Rect &r) const
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 OnDropdownSelect (int widget, int index)
 A dropdown option associated to this window has been selected.
virtual void OnMouseLoop ()
 Called for every mouse loop run, which is at least once per (game) tick.
virtual void OnInvalidateData (int data=0, bool gui_scope=true)
 Some data on this window has become invalid.
virtual EventState OnKeyPress (uint16 key, uint16 keycode)
 A key has been pressed.
virtual void OnQueryTextFinished (char *str)
 The query window opened from this window has closed.
virtual void OnResize ()
 Called after the window got resized.

Protected Member Functions

void BuildNetworkGameList ()
 (Re)build the network game list as its amount has changed because an item has been added or deleted for example
void SortNetworkGameList ()
 Sort the server list.
void DrawServerLine (const NetworkGameList *cur_item, uint y, bool highlight) const
 Draw a single server line.
void ScrollToSelectedServer ()
 Scroll the list up or down to the currently selected server.

Static Protected Member Functions

static int CDECL NGameNameSorter (NetworkGameList *const *a, NetworkGameList *const *b)
 Sort servers by name.
static int CDECL NGameClientSorter (NetworkGameList *const *a, NetworkGameList *const *b)
 Sort servers by the amount of clients online on a server.
static int CDECL NGameMapSizeSorter (NetworkGameList *const *a, NetworkGameList *const *b)
 Sort servers by map size.
static int CDECL NGameDateSorter (NetworkGameList *const *a, NetworkGameList *const *b)
 Sort servers by current date.
static int CDECL NGameYearsSorter (NetworkGameList *const *a, NetworkGameList *const *b)
 Sort servers by the number of days the game is running.
static int CDECL NGameAllowedSorter (NetworkGameList *const *a, NetworkGameList *const *b)
 Sort servers by joinability.

Protected Attributes

byte field
 selected text-field
NetworkGameListserver
 selected server
NetworkGameListlast_joined
 the last joined server
GUIGameServerList servers
 list with game servers.
ServerListPosition list_pos
 position of the selected server
Scrollbarvscroll

Static Protected Attributes

static Listing last_sorting = {false, 5}
static
GUIGameServerList::SortFunction
*const 
sorter_funcs []

Detailed Description

Definition at line 245 of file network_gui.cpp.


Member Function Documentation

void NetworkGameWindow::DrawServerLine ( const NetworkGameList cur_item,
uint  y,
bool  highlight 
) const [inline, protected]
virtual void NetworkGameWindow::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 545 of file network_gui.cpp.

References DrawServerLine(), Window::DrawSortButtonState(), Scrollbar::GetCapacity(), Scrollbar::GetPosition(), GUIList< T, F >::IsDescSortOrder(), last_joined, SmallVector< T, S >::Length(), max(), min(), NGWW_CLIENTS, NGWW_DATE, NGWW_DETAILS, NGWW_INFO, NGWW_LASTJOINED, NGWW_MAPSIZE, NGWW_MATRIX, NGWW_NAME, NGWW_YEARS, Window::resize, SBS_DOWN, SBS_UP, server, servers, GUIList< T, F >::SortType(), ResizeInfo::step_height, and WD_MATRIX_TOP.

static int CDECL NetworkGameWindow::NGameAllowedSorter ( NetworkGameList *const *  a,
NetworkGameList *const *  b 
) [inline, static, protected]

Sort servers by joinability.

If both servers are the same, prefer the non-passworded server first.

Definition at line 330 of file network_gui.cpp.

References NGameNameSorter(), and StrEmpty().

static int CDECL NetworkGameWindow::NGameClientSorter ( NetworkGameList *const *  a,
NetworkGameList *const *  b 
) [inline, static, protected]

Sort servers by the amount of clients online on a server.

If the two servers have the same amount, the one with the higher maximum is preferred.

Definition at line 291 of file network_gui.cpp.

References NGameNameSorter().

Referenced by NGameDateSorter(), and NGameMapSizeSorter().

static int CDECL NetworkGameWindow::NGameNameSorter ( NetworkGameList *const *  a,
NetworkGameList *const *  b 
) [inline, static, protected]

Sort servers by name.

Definition at line 281 of file network_gui.cpp.

References strnatcmp().

Referenced by NGameAllowedSorter(), and NGameClientSorter().

virtual void NetworkGameWindow::OnClick ( Point  pt,
int  widget,
int  click_count 
) [inline, virtual]
virtual void NetworkGameWindow::OnDropdownSelect ( int  widget,
int  index 
) [inline, virtual]

A dropdown option associated to this window has been selected.

Parameters:
widget the widget (button) that the dropdown is associated with.
index the element in the dropdown that is selected.

Reimplemented from Window.

Definition at line 777 of file network_gui.cpp.

References _settings_client, NetworkSettings::lan_internet, ClientSettings::network, NGWW_CONN_BTN, and Window::SetDirty().

virtual void NetworkGameWindow::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 801 of file network_gui.cpp.

References GUIList< T, F >::ForceRebuild(), list_pos, server, servers, and Window::SetDirty().

virtual EventState NetworkGameWindow::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 811 of file network_gui.cpp.

References _settings_client, NetworkSettings::client_name, QueryStringBaseWindow::edit_str_buf, ES_HANDLED, ES_NOT_HANDLED, field, Scrollbar::GetCapacity(), lastof, SmallVector< T, S >::Length(), list_pos, min(), ClientSettings::network, NetworkGameListRemoveItem(), NGWW_CLIENT, ScrollToSelectedServer(), server, servers, Window::SetDirty(), strecpy(), and StrEmpty().

virtual void NetworkGameWindow::OnPaint (  )  [inline, virtual]
virtual void NetworkGameWindow::OnQueryTextFinished ( char *  str  )  [inline, virtual]

The query window opened from this window has closed.

Parameters:
str the new value of the string, NULL if the window was cancelled or an empty string when the default button was pressed, i.e. StrEmpty(str).

Reimplemented from Window.

Definition at line 882 of file network_gui.cpp.

References StrEmpty().

virtual void NetworkGameWindow::OnResize (  )  [inline, virtual]

Called after the window got resized.

For nested windows with a viewport, call NWidgetViewport::UpdateViewportCoordinates.

Reimplemented from Window.

Definition at line 887 of file network_gui.cpp.

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

void NetworkGameWindow::ScrollToSelectedServer (  )  [inline, protected]

Scroll the list up or down to the currently selected server.

If the server is below the currently displayed servers, it will scroll down an amount so that the server appears at the bottom. If the server is above the currently displayed servers, it will scroll up so that the server appears at the top.

Definition at line 450 of file network_gui.cpp.

References list_pos, and Scrollbar::ScrollTowards().

Referenced by OnClick(), and OnKeyPress().

virtual void NetworkGameWindow::SetStringParameters ( int  widget  )  const [inline, virtual]

Initialize string parameters for a widget.

Calls to this function are made during initialization to measure the size (that is as part of InitNested()), during drawing, and while re-initializing the window. Only for widgets that render text initializing is requested.

Parameters:
widget Widget number.

Reimplemented from Window.

Definition at line 485 of file network_gui.cpp.

References _settings_client, NetworkSettings::lan_internet, ClientSettings::network, NGWW_CONN_BTN, and SetDParam().

virtual void NetworkGameWindow::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 494 of file network_gui.cpp.

References FONT_HEIGHT_NORMAL, GetStringBoundingBox(), maxdim(), NGWW_CLIENTS, NGWW_CONN_BTN, NGWW_DATE, NGWW_DETAILS_SPACER, NGWW_LASTJOINED, NGWW_MAPSIZE, NGWW_MATRIX, NGWW_NAME, NGWW_YEARS, SetDParam(), WD_MATRIX_BOTTOM, WD_MATRIX_TOP, and WD_SORTBUTTON_ARROW_WIDTH.


Field Documentation

GUIGameServerList::SortFunction *const NetworkGameWindow::sorter_funcs [static, protected]

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

Generated on Fri May 27 04:20:54 2011 for OpenTTD by  doxygen 1.6.1