OpenTTD Source 20241224-master-gf74b0cf984
|
Implementation of the Network related GUIs. More...
#include "../stdafx.h"
#include "../strings_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 "network_server.h"
#include "network_coordinator.h"
#include "network_survey.h"
#include "../gui.h"
#include "network_udp.h"
#include "../window_func.h"
#include "../gfx_func.h"
#include "../dropdown_type.h"
#include "../dropdown_func.h"
#include "../querystring_gui.h"
#include "../sortlist_type.h"
#include "../company_func.h"
#include "../command_func.h"
#include "../core/geometry_func.hpp"
#include "../genworld.h"
#include "../map_type.h"
#include "../zoom_func.h"
#include "../sprite.h"
#include "../settings_internal.h"
#include "../company_cmd.h"
#include "../timer/timer.h"
#include "../timer/timer_window.h"
#include "../timer/timer_game_calendar.h"
#include "../textfile_gui.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 |
class | ButtonCommon |
Button shown for either a company or client in the client-list. More... | |
class | Button< T > |
Template version of Button, with callback support. More... | |
struct | NetworkClientListWindow |
Main handle for clientlist. More... | |
struct | NetworkJoinStatusWindow |
struct | NetworkAskRelayWindow |
Window used for asking the user if he is okay using a relay server. More... | |
struct | NetworkAskSurveyWindow |
Window used for asking if the user wants to participate in the automated survey. More... | |
struct | SurveyResultTextfileWindow |
Window for displaying the textfile of a survey result. More... | |
Typedefs | |
typedef GUIList< NetworkGameList *, std::nullptr_t, StringFilter & > | GUIGameServerList |
typedef int | ServerListPosition |
using | CompanyButton = Button< CompanyID > |
using | ClientButton = Button< ClientID > |
Enumerations | |
enum | DropDownAdmin { DD_CLIENT_ADMIN_KICK , DD_CLIENT_ADMIN_BAN , DD_COMPANY_ADMIN_RESET } |
The possibly entries in a DropDown for an admin. More... | |
Functions | |
static void | ShowNetworkStartServerWindow () |
void | UpdateNetworkGameWindow () |
Update the network new window because a new server is found on the network. | |
static DropDownList | BuildVisibilityDropDownList () |
static std::unique_ptr< NWidgetBase > | MakeResizableHeader () |
void | ShowNetworkGameWindow () |
void | DrawCompanyIcon (CompanyID cid, int x, int y) |
Draw the icon of a company. | |
static void | AdminClientKickCallback (Window *, bool confirmed) |
Callback function for admin command to kick client. | |
static void | AdminClientBanCallback (Window *, bool confirmed) |
Callback function for admin command to ban client. | |
static void | AdminCompanyResetCallback (Window *, bool confirmed) |
Callback function for admin command to reset company. | |
void | ShowClientList () |
void | ShowJoinStatusWindow () |
void | ShowNetworkNeedPassword (std::shared_ptr< NetworkAuthenticationPasswordRequest > request) |
void | ShowNetworkAskRelay (const std::string &server_connection_string, const std::string &relay_connection_string, const std::string &token) |
Show a modal confirmation window with "no" / "yes, once" / "yes, always" buttons. | |
void | ShowNetworkAskSurvey () |
Show a modal confirmation window with "no" / "preview" / "yes" buttons. | |
void | ShowSurveyResultTextfileWindow () |
Variables | |
static ClientID | _admin_client_id = INVALID_CLIENT_ID |
For what client a confirmation window is open. | |
static CompanyID | _admin_company_id = INVALID_COMPANY |
For what company a confirmation window is open. | |
static const ServerListPosition | SLP_INVALID = -1 |
static constexpr 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) |
static constexpr NWidgetPart | _nested_network_start_server_window_widgets [] |
static WindowDesc | _network_start_server_window_desc (WDP_CENTER, nullptr, 0, 0, WC_NETWORK_WINDOW, WC_NONE, 0, _nested_network_start_server_window_widgets) |
static constexpr NWidgetPart | _nested_client_list_widgets [] |
static WindowDesc | _client_list_desc (WDP_AUTO, "list_clients", 220, 300, WC_CLIENT_LIST, WC_NONE, 0, _nested_client_list_widgets) |
NetworkJoinStatus | _network_join_status |
The status of joining. | |
uint8_t | _network_join_waiting |
The number of clients waiting in front of us. | |
uint32_t | _network_join_bytes |
The number of bytes we already downloaded. | |
uint32_t | _network_join_bytes_total |
The total number of bytes to download. | |
static constexpr NWidgetPart | _nested_network_join_status_window_widgets [] |
static WindowDesc | _network_join_status_window_desc (WDP_CENTER, nullptr, 0, 0, WC_NETWORK_STATUS_WINDOW, WC_NONE, WDF_MODAL, _nested_network_join_status_window_widgets) |
static constexpr NWidgetPart | _nested_network_ask_relay_widgets [] |
static WindowDesc | _network_ask_relay_desc (WDP_CENTER, nullptr, 0, 0, WC_NETWORK_ASK_RELAY, WC_NONE, WDF_MODAL, _nested_network_ask_relay_widgets) |
static constexpr NWidgetPart | _nested_network_ask_survey_widgets [] |
static WindowDesc | _network_ask_survey_desc (WDP_CENTER, nullptr, 0, 0, WC_NETWORK_ASK_SURVEY, WC_NONE, WDF_MODAL, _nested_network_ask_survey_widgets) |
Implementation of the Network related GUIs.
Definition in file network_gui.cpp.
using ClientButton = Button<ClientID> |
Definition at line 1415 of file network_gui.cpp.
using CompanyButton = Button<CompanyID> |
Definition at line 1414 of file network_gui.cpp.
typedef GUIList<NetworkGameList*, std::nullptr_t, StringFilter&> GUIGameServerList |
Definition at line 82 of file network_gui.cpp.
typedef int ServerListPosition |
Definition at line 83 of file network_gui.cpp.
enum DropDownAdmin |
The possibly entries in a DropDown for an admin.
Client and companies are mixed; they just have to be unique.
Definition at line 1317 of file network_gui.cpp.
|
static |
Callback function for admin command to ban client.
confirmed | Iff the user pressed Yes. |
Definition at line 1336 of file network_gui.cpp.
References _admin_client_id, and NetworkServerKickOrBanIP().
Referenced by NetworkClientListWindow::OnDropdownSelect().
|
static |
Callback function for admin command to kick client.
confirmed | Iff the user pressed Yes. |
Definition at line 1327 of file network_gui.cpp.
References _admin_client_id, and NetworkServerKickClient().
Referenced by NetworkClientListWindow::OnDropdownSelect().
|
static |
Callback function for admin command to reset company.
confirmed | Iff the user pressed Yes. |
Definition at line 1345 of file network_gui.cpp.
References _admin_company_id, CCA_DELETE, CRR_MANUAL, INVALID_CLIENT_ID, and NetworkCompanyHasClients().
Referenced by NetworkClientListWindow::OnDropdownSelect().
|
static |
Definition at line 71 of file network_gui.cpp.
|
extern |
Draw the icon of a company.
c | Company that needs its icon drawn. |
x | Horizontal coordinate of the icon. |
y | Vertical coordinate of the icon. |
Definition at line 161 of file company_cmd.cpp.
References DrawSprite().
Referenced by NetworkClientListWindow::DrawCompany(), TownAuthorityWindow::DrawRatings(), CheatWindow::DrawWidget(), GraphLegendWindow::DrawWidget(), PerformanceRatingDetailWindow::DrawWidget(), PerformanceLeagueWindow::DrawWidget(), ScriptLeagueWindow::DrawWidget(), LinkGraphLegendWindow::DrawWidget(), SignListWindow::DrawWidget(), and ScriptDebugWindow::DrawWidgetCompanyButton().
|
static |
Definition at line 882 of file network_gui.cpp.
void ShowClientList | ( | ) |
Definition at line 2074 of file network_gui.cpp.
void ShowJoinStatusWindow | ( | ) |
Definition at line 2208 of file network_gui.cpp.
void ShowNetworkAskRelay | ( | const std::string & | server_connection_string, |
const std::string & | relay_connection_string, | ||
const std::string & | token | ||
) |
Show a modal confirmation window with "no" / "yes, once" / "yes, always" buttons.
server_connection_string | The game server we want to connect to. |
relay_connection_string | The relay server we want to connect to. |
token | The token for this connection. |
Definition at line 2331 of file network_gui.cpp.
References CloseWindowByClass(), GetMainWindow(), NRWCD_HANDLED, and WC_NETWORK_ASK_RELAY.
Referenced by ClientNetworkCoordinatorSocketHandler::Receive_GC_TURN_CONNECT().
void ShowNetworkAskSurvey | ( | ) |
Show a modal confirmation window with "no" / "preview" / "yes" buttons.
Definition at line 2426 of file network_gui.cpp.
References CloseWindowByClass(), GetMainWindow(), and WC_NETWORK_ASK_SURVEY.
void ShowNetworkGameWindow | ( | ) |
Definition at line 972 of file network_gui.cpp.
void ShowNetworkNeedPassword | ( | std::shared_ptr< NetworkAuthenticationPasswordRequest > | request | ) |
Definition at line 2214 of file network_gui.cpp.
|
static |
Definition at line 1239 of file network_gui.cpp.
void ShowSurveyResultTextfileWindow | ( | ) |
Definition at line 2451 of file network_gui.cpp.
void UpdateNetworkGameWindow | ( | ) |
Update the network new window because a new server is found on the network.
Definition at line 66 of file network_gui.cpp.
References InvalidateWindowData(), WC_NETWORK_WINDOW, and WN_NETWORK_WINDOW_GAME.
Referenced by QueryNetworkGameSocketHandler::CloseConnection(), NetworkAddServer(), NetworkGameListAddItem(), NetworkGameListRemoveExpired(), NetworkGameListRemoveItem(), TCPQueryConnecter::OnFailure(), ClientNetworkCoordinatorSocketHandler::Receive_GC_ERROR(), ClientNetworkCoordinatorSocketHandler::Receive_GC_LISTING(), QueryNetworkGameSocketHandler::Receive_SERVER_BANNED(), QueryNetworkGameSocketHandler::Receive_SERVER_ERROR(), QueryNetworkGameSocketHandler::Receive_SERVER_FULL(), and QueryNetworkGameSocketHandler::Receive_SERVER_GAME_INFO().
|
static |
For what client a confirmation window is open.
Definition at line 59 of file network_gui.cpp.
Referenced by AdminClientBanCallback(), AdminClientKickCallback(), and NetworkClientListWindow::OnDropdownSelect().
|
static |
For what company a confirmation window is open.
Definition at line 60 of file network_gui.cpp.
Referenced by AdminCompanyResetCallback(), and NetworkClientListWindow::OnDropdownSelect().
|
staticconstexpr |
Definition at line 1253 of file network_gui.cpp.
|
staticconstexpr |
Definition at line 2301 of file network_gui.cpp.
|
staticconstexpr |
Definition at line 2396 of file network_gui.cpp.
|
staticconstexpr |
Definition at line 887 of file network_gui.cpp.
|
staticconstexpr |
Definition at line 2190 of file network_gui.cpp.
|
staticconstexpr |
Definition at line 1165 of file network_gui.cpp.
uint32_t _network_join_bytes |
The number of bytes we already downloaded.
Definition at line 2081 of file network_gui.cpp.
Referenced by NetworkJoinStatusWindow::DrawWidget(), ClientNetworkGameSocketHandler::Receive_SERVER_MAP_BEGIN(), and ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DATA().
uint32_t _network_join_bytes_total |
The total number of bytes to download.
Definition at line 2082 of file network_gui.cpp.
Referenced by NetworkJoinStatusWindow::DrawWidget(), ClientNetworkGameSocketHandler::Receive_SERVER_MAP_BEGIN(), and ClientNetworkGameSocketHandler::Receive_SERVER_MAP_SIZE().
NetworkJoinStatus _network_join_status |
The status of joining.
Definition at line 2079 of file network_gui.cpp.
Referenced by NetworkJoinStatusWindow::DrawWidget(), NetworkClientJoinGame(), ClientNetworkGameSocketHandler::Receive_SERVER_MAP_BEGIN(), ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(), ClientNetworkGameSocketHandler::Receive_SERVER_WAIT(), and ClientNetworkGameSocketHandler::SendJoin().
uint8_t _network_join_waiting |
The number of clients waiting in front of us.
Definition at line 2080 of file network_gui.cpp.
Referenced by NetworkJoinStatusWindow::DrawWidget(), and ClientNetworkGameSocketHandler::Receive_SERVER_WAIT().
|
static |
Definition at line 84 of file network_gui.cpp.