OpenTTD
Data Structures | Typedefs | Functions | Variables
network_gui.cpp File Reference

Implementation of the Network related GUIs. More...

#include "../stdafx.h"
#include "../strings_func.h"
#include "../date_func.h"
#include "../fios.h"
#include "network_client.h"
#include "network_gui.h"
#include "network_gamelist.h"
#include "network.h"
#include "network_base.h"
#include "network_content.h"
#include "../gui.h"
#include "network_udp.h"
#include "../window_func.h"
#include "../gfx_func.h"
#include "../widgets/dropdown_func.h"
#include "../querystring_gui.h"
#include "../sortlist_type.h"
#include "../company_func.h"
#include "../core/geometry_func.hpp"
#include "../genworld.h"
#include "../map_type.h"
#include "../widgets/network_widget.h"
#include "table/strings.h"
#include "../table/sprites.h"
#include "../stringfilter_type.h"
#include "../safeguards.h"

Go to the source code of this file.

Data Structures

class  NWidgetServerListHeader
 Full blown container to make it behave exactly as we want :) More...
 
class  NetworkGameWindow
 
struct  NetworkStartServerWindow
 
struct  NetworkLobbyWindow
 
struct  NetworkClientListPopupWindow
 Popup selection window to chose an action to perform. More...
 
struct  NetworkClientListPopupWindow::ClientListAction
 Container for actions that can be executed. More...
 
struct  NetworkClientListWindow
 Main handle for clientlist. More...
 
struct  NetworkJoinStatusWindow
 
struct  NetworkCompanyPasswordWindow
 

Typedefs

typedef GUIList< NetworkGameList *, StringFilter & > GUIGameServerList
 
typedef uint16 ServerListPosition
 
typedef void ClientList_Action_Proc(const NetworkClientInfo *ci)
 Prototype for ClientList actions. More...
 

Functions

static void ShowNetworkStartServerWindow ()
 
static void ShowNetworkLobbyWindow (NetworkGameList *ngl)
 Show the networklobbywindow with the selected server. More...
 
void SortNetworkLanguages ()
 
void UpdateNetworkGameWindow ()
 Update the network new window because a new server is found on the network.
 
static NWidgetBaseMakeResizableHeader (int *biggest_index)
 
void ShowNetworkGameWindow ()
 
NetworkCompanyInfoGetLobbyCompanyInfo (CompanyID company)
 Get the company information of a given company to fill for the lobby. More...
 
void DrawCompanyIcon (CompanyID cid, int x, int y)
 Draw the icon of a company. More...
 
static void ClientList_Kick (const NetworkClientInfo *ci)
 
static void ClientList_Ban (const NetworkClientInfo *ci)
 
static void ClientList_GiveMoney (const NetworkClientInfo *ci)
 
static void ClientList_SpeakToClient (const NetworkClientInfo *ci)
 
static void ClientList_SpeakToCompany (const NetworkClientInfo *ci)
 
static void ClientList_SpeakToAll (const NetworkClientInfo *ci)
 
static void PopupClientList (ClientID client_id, int x, int y)
 Show the popup (action list)
 
void ShowClientList ()
 
void ShowJoinStatusWindow ()
 
void ShowNetworkNeedPassword (NetworkPasswordType npt)
 
void ShowNetworkCompanyPasswordWindow (Window *parent)
 

Variables

static const StringID _connection_types_dropdown []
 Advertisement options in the start server window. More...
 
static const StringID _lan_internet_types_dropdown []
 Advertisement options in the server list. More...
 
static StringID _language_dropdown [NETLANG_COUNT+1] = {STR_NULL}
 
static const ServerListPosition SLP_INVALID = 0xFFFF
 
static const NWidgetPart _nested_network_game_widgets []
 
static WindowDesc _network_game_window_desc (WDP_CENTER, "list_servers", 1000, 730, WC_NETWORK_WINDOW, WC_NONE, 0, _nested_network_game_widgets, lengthof(_nested_network_game_widgets))
 
static const NWidgetPart _nested_network_start_server_window_widgets []
 
static WindowDesc _network_start_server_window_desc (WDP_CENTER, NULL, 0, 0, WC_NETWORK_WINDOW, WC_NONE, 0, _nested_network_start_server_window_widgets, lengthof(_nested_network_start_server_window_widgets))
 
static const NWidgetPart _nested_network_lobby_window_widgets []
 
static WindowDesc _network_lobby_window_desc (WDP_CENTER, NULL, 0, 0, WC_NETWORK_WINDOW, WC_NONE, 0, _nested_network_lobby_window_widgets, lengthof(_nested_network_lobby_window_widgets))
 
static const NWidgetPart _nested_client_list_popup_widgets []
 
static WindowDesc _client_list_popup_desc (WDP_AUTO, NULL, 0, 0, WC_CLIENT_LIST_POPUP, WC_CLIENT_LIST, 0, _nested_client_list_popup_widgets, lengthof(_nested_client_list_popup_widgets))
 
static const NWidgetPart _nested_client_list_widgets []
 
static WindowDesc _client_list_desc (WDP_AUTO, "list_clients", 0, 0, WC_CLIENT_LIST, WC_NONE, 0, _nested_client_list_widgets, lengthof(_nested_client_list_widgets))
 
NetworkJoinStatus _network_join_status
 The status of joining.
 
uint8 _network_join_waiting
 The number of clients waiting in front of us.
 
uint32 _network_join_bytes
 The number of bytes we already downloaded.
 
uint32 _network_join_bytes_total
 The total number of bytes to download.
 
static const NWidgetPart _nested_network_join_status_window_widgets []
 
static WindowDesc _network_join_status_window_desc (WDP_CENTER, NULL, 0, 0, WC_NETWORK_STATUS_WINDOW, WC_NONE, WDF_MODAL, _nested_network_join_status_window_widgets, lengthof(_nested_network_join_status_window_widgets))
 
static const NWidgetPart _nested_network_company_password_window_widgets []
 
static WindowDesc _network_company_password_window_desc (WDP_AUTO, NULL, 0, 0, WC_COMPANY_PASSWORD_WINDOW, WC_NONE, 0, _nested_network_company_password_window_widgets, lengthof(_nested_network_company_password_window_widgets))
 

Detailed Description

Implementation of the Network related GUIs.

Definition in file network_gui.cpp.

Typedef Documentation

◆ ClientList_Action_Proc

typedef void ClientList_Action_Proc(const NetworkClientInfo *ci)

Prototype for ClientList actions.

Parameters
ciThe information about the current client.

Definition at line 1670 of file network_gui.cpp.

Function Documentation

◆ DrawCompanyIcon()

void DrawCompanyIcon ( CompanyID  c,
int  x,
int  y 
)

Draw the icon of a company.

Parameters
cCompany that needs its icon drawn.
xHorizontal coordinate of the icon.
yVertical coordinate of the icon.

Definition at line 141 of file company_cmd.cpp.

Referenced by GetLobbyCompanyInfo(), and AIDebugWindow::OnPaint().

◆ GetLobbyCompanyInfo()

NetworkCompanyInfo* GetLobbyCompanyInfo ( CompanyID  company)

Get the company information of a given company to fill for the lobby.

Parameters
companythe company to get the company info struct from.
Returns
the company info struct to write the (downloaded) data to.

Definition at line 1654 of file network_gui.cpp.

References DrawCompanyIcon(), FindWindowById(), MAX_COMPANIES, WC_NETWORK_WINDOW, and WN_NETWORK_WINDOW_LOBBY.

Referenced by NetworkLobbyWindow::OnPaint(), and ClientNetworkGameSocketHandler::Receive_SERVER_COMPANY_INFO().

◆ ShowNetworkLobbyWindow()

static void ShowNetworkLobbyWindow ( NetworkGameList ngl)
static

Show the networklobbywindow with the selected server.

Parameters
nglSelected game pointer which is passed to the new window.

Definition at line 1638 of file network_gui.cpp.

References DeleteWindowById(), WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME, and WN_NETWORK_WINDOW_START.

Variable Documentation

◆ _connection_types_dropdown

const StringID _connection_types_dropdown[]
static
Initial value:
= {
STR_NETWORK_START_SERVER_UNADVERTISED,
STR_NETWORK_START_SERVER_ADVERTISED,
}
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:19

Advertisement options in the start server window.

Definition at line 51 of file network_gui.cpp.

Referenced by NetworkStartServerWindow::SetStringParameters(), and NetworkStartServerWindow::UpdateWidgetSize().

◆ _lan_internet_types_dropdown

const StringID _lan_internet_types_dropdown[]
static
Initial value:
= {
STR_NETWORK_SERVER_LIST_ADVERTISED_NO,
STR_NETWORK_SERVER_LIST_ADVERTISED_YES,
}
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:19

Advertisement options in the server list.

Definition at line 60 of file network_gui.cpp.

Referenced by NetworkGameWindow::OnClick(), NetworkGameWindow::SetStringParameters(), and NetworkGameWindow::UpdateWidgetSize().

◆ _nested_client_list_popup_widgets

const NWidgetPart _nested_client_list_popup_widgets[]
static
Initial value:
= {
}
Simple depressed panel.
Definition: widget_type.h:50
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
Panel of the window.

Definition at line 1672 of file network_gui.cpp.

◆ _nested_client_list_widgets

const NWidgetPart _nested_client_list_widgets[]
static
Initial value:
= {
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_STICKYBOX, COLOUR_GREY),
}
Panel of the window.
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:930
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:64
Horizontal container.
Definition: widget_type.h:75
Close box (at top-left of a window)
Definition: widget_type.h:69
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
Simple depressed panel.
Definition: widget_type.h:50
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:65
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:66

Definition at line 1843 of file network_gui.cpp.

◆ _nested_network_company_password_window_widgets

const NWidgetPart _nested_network_company_password_window_widgets[]
static
Initial value:
= {
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_COMPANY_PASSWORD_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_TEXT, COLOUR_GREY, WID_NCP_LABEL), SetDataTip(STR_COMPANY_VIEW_PASSWORD, STR_NULL),
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_NCP_PASSWORD), SetFill(1, 0), SetMinimalSize(194, 12), SetDataTip(STR_COMPANY_VIEW_SET_PASSWORD, STR_NULL),
SetDataTip(STR_COMPANY_PASSWORD_MAKE_DEFAULT, STR_COMPANY_PASSWORD_MAKE_DEFAULT_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NCP_CANCEL), SetFill(1, 0), SetDataTip(STR_BUTTON_CANCEL, STR_COMPANY_PASSWORD_CANCEL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NCP_OK), SetFill(1, 0), SetDataTip(STR_BUTTON_OK, STR_COMPANY_PASSWORD_OK),
}
Horizontal container.
Definition: widget_type.h:75
Input field for the password.
a textbox for typing
Definition: widget_type.h:71
Toggle &#39;button&#39; for saving the current password as default password.
Close box (at top-left of a window)
Definition: widget_type.h:69
Pure simple text.
Definition: widget_type.h:58
Invisible widget that takes some space.
Definition: widget_type.h:79
Safe the password etc.
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
Simple depressed panel.
Definition: widget_type.h:50
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
Vertical container.
Definition: widget_type.h:77
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
Background of the window.
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:983
Close the window without changing anything.
Label in front of the password field.
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:429
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1076
(Toggle) Button with text
Definition: widget_type.h:55

Definition at line 2200 of file network_gui.cpp.

◆ _nested_network_join_status_window_widgets

const NWidgetPart _nested_network_join_status_window_widgets[]
static
Initial value:
= {
NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_NETWORK_CONNECTING_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_PANEL, COLOUR_GREY),
NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NJS_CANCELOK), SetMinimalSize(101, 12), SetDataTip(STR_NETWORK_CONNECTION_DISCONNECT, STR_NULL),
}
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:48
Horizontal container.
Definition: widget_type.h:75
Invisible widget that takes some space.
Definition: widget_type.h:79
Cancel / OK button.
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
Simple depressed panel.
Definition: widget_type.h:50
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
Background of the window.
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:983

Definition at line 2117 of file network_gui.cpp.