Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes

# NetworkGameWindow Class Reference

Inheritance diagram for NetworkGameWindow:

## Public Member Functions
| NetworkGameWindow (const WindowDesc *desc)
virtual void | SetStringParameters (int widget) const
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 | DrawDetails (const Rect &r) const
virtual void | OnClick (Point pt, int widget, int click_count)
virtual void | OnDropdownSelect (int widget, int index)
virtual void | OnMouseLoop ()
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)
virtual void | OnQueryTextFinished (char *str)
virtual void | OnResize ()
virtual void | OnTick ()
## 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 const char * | SkipGarbage (const char *str)
| Skip some of the 'garbage' in the string that we don't want to use to sort on.
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
NetworkGameList * | server
| selected server
NetworkGameList * | last_joined
| the last joined server
GUIGameServerList | servers
| list with game servers.
ServerListPosition | list_pos
| position of the selected server
Scrollbar * | vscroll
## Static Protected Attributes
static Listing | last_sorting = {false, 5}
static GUIGameServerList::SortFunction *const | sorter_funcs []

## Detailed Description

Definition at line 212 of file network_gui.cpp.

## Member Function Documentation

void NetworkGameWindow::DrawServerLine | ( | const NetworkGameList * | cur_item,
|  | uint | y,
|  | bool | highlight |
| ) |  |  | const`[inline, protected]`

Draw a single server line.

Parameters:

  | cur_item | the server to draw.
  | y | from where to draw?
  | highlight | does the line need to be highlighted?

Definition at line 361 of file network_gui.cpp.

References NetworkGameInfo::clients_max, NetworkServerGameInfo::clients_on, NetworkGameInfo::companies_max, NetworkGameInfo::companies_on, NetworkGameInfo::compatible, ConvertDateToYMD(), NWidgetBase::current_x, DrawSprite(), DrawString(), FONT_HEIGHT_NORMAL, NetworkGameInfo::game_date, GfxFillRect(), NetworkGameList::info, NWidgetServerListHeader::IsWidgetVisible(), NetworkGameInfo::map_height, NetworkGameInfo::map_width, NetworkGameList::online, PC_GREY, NWidgetBase::pos_x, SA_HOR_CENTER, NetworkGameInfo::server_lang, NetworkGameInfo::server_name, SetDParam(), SPR_FLAGS_BASE, NetworkGameInfo::start_date, NetworkGameInfo::use_password, NetworkGameInfo::version_compatible, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WID_NG_CLIENTS, WID_NG_DATE, WID_NG_MAPSIZE, and WID_NG_YEARS.

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 312 of file network_gui.cpp.

References NGameClientSorter(), 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 273 of file network_gui.cpp.

References NGameNameSorter().

Referenced by NGameAllowedSorter(), NGameDateSorter(), and NGameMapSizeSorter().

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

Sort servers by name.

Definition at line 262 of file network_gui.cpp.

References SkipGarbage(), and strnatcmp().

Referenced by NGameClientSorter().

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.

Definition at line 793 of file network_gui.cpp.

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

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 432 of file network_gui.cpp.

References list_pos, and Scrollbar::ScrollTowards().

static const char* NetworkGameWindow::SkipGarbage | ( | const char * | str | ) | `[inline, static, protected]`

Skip some of the 'garbage' in the string that we don't want to use to sort on.

This way the alphabetical sorting will work better as we would be actually using those characters instead of some other characters such as spaces and tildes at the begin of the name.

Parameters:

  | str | The string to skip the initial garbage of.

Returns:
  The string with the garbage skipped.

Definition at line 255 of file network_gui.cpp.

References IsInsideMM().

Referenced by NGameNameSorter().

## Field Documentation

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

Initial value:

     {
      &NGameNameSorter,
      &NGameClientSorter,
      &NGameMapSizeSorter,
      &NGameDateSorter,
      &NGameYearsSorter,
      &NGameAllowedSorter
    }

Definition at line 218 of file network_gui.cpp.

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

- src/network/network_gui.cpp