|
OpenTTD Source 20260421-master-gc2fbc6fdeb
|
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 "../stringfilter_type.h"#include "../core/string_consumer.hpp"#include "../widgets/network_widget.h"#include "table/strings.h"#include "../table/sprites.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 |
| Window with the list of game servers. More... | |
| struct | NetworkStartServerWindow |
| Window to configure and start your server with. More... | |
| 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... | |
| class | ButtonLine |
| Base interface for a network client list line. More... | |
| class | CompanyButtonLine |
| A line in the NetworkClientList with a company on it. More... | |
| class | ClientButtonLine |
| A line in the NetworkClientList with a client on it. More... | |
| struct | NetworkClientListWindow |
| Main handle for clientlist. More... | |
| struct | NetworkJoinStatusWindow |
| Window showing the progress during joining. More... | |
| 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 | |
| using | GUIGameServerList = GUIList<NetworkGame*, std::nullptr_t, StringFilter&> |
| The list of servers with sorting/filtering. | |
| using | ServerListPosition = int |
| A location within the server list. | |
| using | CompanyButton = Button<CompanyID> |
| Button linked to a company. | |
| using | ClientButton = Button<ClientID> |
| Button linked to a client. | |
Functions | |
| static void | ShowNetworkStartServerWindow () |
| Show the window to configure and start your server with. | |
| void | UpdateNetworkGameWindow () |
| Update the network new window because a new server is found on the network. | |
| static DropDownList | BuildVisibilityDropDownList () |
| Create the dropdown with visibility options for the server. | |
| void | ShowNetworkGameWindow () |
| Show the server list window. | |
| 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 () |
| Open the client list window. | |
| void | ShowJoinStatusWindow () |
| Open the window showing the status of joining the server. | |
| void | ShowNetworkNeedPassword (std::shared_ptr< NetworkAuthenticationPasswordRequest > request) |
| Update the NetworkJoinStatusWindow to start requesting the server password. | |
| void | ShowNetworkAskRelay (std::string_view server_connection_string, std::string &&relay_connection_string, 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 (Window *parent) |
| Show the surver results as a text file. | |
Variables | |
| static ClientID | _admin_client_id = INVALID_CLIENT_ID |
| For what client a confirmation window is open. | |
| static CompanyID | _admin_company_id = CompanyID::Invalid() |
| For what company a confirmation window is open. | |
| static const ServerListPosition | SLP_INVALID = -1 |
| Sentinel for an invalid location in the server list. | |
| static constexpr std::initializer_list< NWidgetPart > | _nested_network_game_widgets |
| Widgets and the structure of the NetworkGameWindow. | |
| static WindowDesc | _network_game_window_desc (WDP_CENTER, "list_servers", 1000, 730, WC_NETWORK_WINDOW, WC_NONE, {}, _nested_network_game_widgets) |
| Description of the NetworkGameWindow. | |
| static constexpr std::initializer_list< NWidgetPart > | _nested_network_start_server_window_widgets |
| Widgets and the structure of the NetworkStartServerWindow. | |
| static WindowDesc | _network_start_server_window_desc (WDP_CENTER, {}, 0, 0, WC_NETWORK_WINDOW, WC_NONE, {}, _nested_network_start_server_window_widgets) |
| Description of the NetworkStartServerWindow. | |
| static constexpr std::initializer_list< NWidgetPart > | _nested_client_list_widgets |
| Widgets and the structure of the NetworkClientListWindow. | |
| static WindowDesc | _client_list_desc (WDP_AUTO, "list_clients", 220, 300, WC_CLIENT_LIST, WC_NONE, {}, _nested_client_list_widgets) |
| Description of the NetworkClientListWindow. | |
| 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 std::initializer_list< NWidgetPart > | _nested_network_join_status_window_widgets |
| Widgets and the structure of the NetworkJoinStatusWindow. | |
| static WindowDesc | _network_join_status_window_desc (WDP_CENTER, {}, 0, 0, WC_NETWORK_STATUS_WINDOW, WC_NONE, WindowDefaultFlag::Modal, _nested_network_join_status_window_widgets) |
| Description of the NetworkJoinStatusWindow. | |
| static constexpr std::initializer_list< NWidgetPart > | _nested_network_ask_relay_widgets |
| Widgets and the structure of the NetworkAskRelayWindow. | |
| static WindowDesc | _network_ask_relay_desc (WDP_CENTER, {}, 0, 0, WC_NETWORK_ASK_RELAY, WC_NONE, WindowDefaultFlag::Modal, _nested_network_ask_relay_widgets) |
| Description of the NetworkAskRelayWindow. | |
| static constexpr std::initializer_list< NWidgetPart > | _nested_network_ask_survey_widgets |
| Widgets and the structure of the NetworkAskSurveyWindow. | |
| static WindowDesc | _network_ask_survey_desc (WDP_CENTER, {}, 0, 0, WC_NETWORK_ASK_SURVEY, WC_NONE, WindowDefaultFlag::Modal, _nested_network_ask_survey_widgets) |
| Description of the NetworkAskSurveyWindow. | |
Implementation of the Network related GUIs.
Definition in file network_gui.cpp.
| using ClientButton = Button<ClientID> |
Button linked to a client.
Definition at line 1426 of file network_gui.cpp.
| using CompanyButton = Button<CompanyID> |
Button linked to a company.
Definition at line 1425 of file network_gui.cpp.
| using GUIGameServerList = GUIList<NetworkGame*, std::nullptr_t, StringFilter&> |
The list of servers with sorting/filtering.
Definition at line 86 of file network_gui.cpp.
| using ServerListPosition = int |
A location within the server list.
Definition at line 87 of file network_gui.cpp.
|
static |
Callback function for admin command to ban client.
| confirmed | Iff the user pressed Yes. |
Definition at line 1328 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 1319 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 1337 of file network_gui.cpp.
References _admin_company_id, Delete, INVALID_CLIENT_ID, Manual, and NetworkCompanyHasClients().
Referenced by NetworkClientListWindow::OnDropdownSelect().
|
static |
Create the dropdown with visibility options for the server.
Definition at line 75 of file network_gui.cpp.
References InviteOnly, Local, MakeDropDownListStringItem(), Public, and to_underlying().
Referenced by NetworkClientListWindow::OnClick(), and NetworkStartServerWindow::OnClick().
|
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 179 of file company_cmd.cpp.
References DrawSprite(), and GetCompanyPalette().
Referenced by TownAuthorityWindow::DrawRatings(), GraphLegendWindow::DrawWidget(), LinkGraphLegendWindow::DrawWidget(), PerformanceLeagueWindow::DrawWidget(), PerformanceRatingDetailWindow::DrawWidget(), ScriptLeagueWindow::DrawWidget(), SignListWindow::DrawWidget(), and ScriptDebugWindow::DrawWidgetCompanyButton().
| void ShowClientList | ( | ) |
Open the client list window.
Definition at line 2075 of file network_gui.cpp.
References _client_list_desc, and AllocateWindowDescFront().
Referenced by MenuClickCompany(), NetworkOnGameStart(), MainToolbarWindow::OnHotkey(), and ClientNetworkGameSocketHandler::ReceiveServerMapDone().
| void ShowJoinStatusWindow | ( | ) |
Open the window showing the status of joining the server.
Definition at line 2218 of file network_gui.cpp.
References _network_join_status_window_desc, CloseWindowById(), WC_NETWORK_STATUS_WINDOW, and WN_NETWORK_STATUS_WINDOW_JOIN.
Referenced by NetworkClientJoinGame(), and ClientNetworkGameSocketHandler::ReceiveServerMapDone().
| void ShowNetworkAskRelay | ( | std::string_view | server_connection_string, |
| std::string && | relay_connection_string, | ||
| 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 2345 of file network_gui.cpp.
References _network_ask_relay_desc, CloseWindowByClass(), GetMainWindow(), NRWCD_HANDLED, and WC_NETWORK_ASK_RELAY.
Referenced by ClientNetworkCoordinatorSocketHandler::ReceiveGameCoordinatorTurnConnect().
| void ShowNetworkAskSurvey | ( | ) |
Show a modal confirmation window with "no" / "preview" / "yes" buttons.
Definition at line 2447 of file network_gui.cpp.
References _network_ask_survey_desc, CloseWindowByClass(), GetMainWindow(), NetworkSurveyHandler::IsSurveyPossible(), and WC_NETWORK_ASK_SURVEY.
| void ShowNetworkGameWindow | ( | ) |
Show the server list window.
Definition at line 962 of file network_gui.cpp.
References _network_game_window_desc, _network_host_list, CloseWindowById(), NetworkAddServer(), WC_NETWORK_WINDOW, and WN_NETWORK_WINDOW_START.
Referenced by NetworkJoinStatusWindow::OnClick(), NetworkStartServerWindow::OnClick(), and SelectGameWindow::OnClick().
| void ShowNetworkNeedPassword | ( | std::shared_ptr< NetworkAuthenticationPasswordRequest > | request | ) |
Update the NetworkJoinStatusWindow to start requesting the server password.
| request | The callback for the reply to the request. |
Definition at line 2228 of file network_gui.cpp.
References CS_ALPHANUMERAL, FindWindowById(), NETWORK_PASSWORD_LENGTH, NetworkJoinStatusWindow::request, ShowQueryString(), WC_NETWORK_STATUS_WINDOW, and WN_NETWORK_STATUS_WINDOW_JOIN.
Referenced by ClientGamePasswordRequestHandler::AskUserForPassword().
|
static |
Show the window to configure and start your server with.
Definition at line 1239 of file network_gui.cpp.
References _network_start_server_window_desc, CloseWindowById(), NetworkValidateOurClientName(), WC_NETWORK_WINDOW, and WN_NETWORK_WINDOW_GAME.
Referenced by NetworkGameWindow::OnClick().
| void ShowSurveyResultTextfileWindow | ( | Window * | parent | ) |
Show the surver results as a text file.
| parent | The parent of the text file window. |
Definition at line 2481 of file network_gui.cpp.
References Window::CloseChildWindowById(), TFT_SURVEY_RESULT, and WC_TEXTFILE.
Referenced by GameOptionsWindow::OnClick(), and NetworkAskSurveyWindow::OnClick().
| 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::ReceiveGameCoordinatorError(), ClientNetworkCoordinatorSocketHandler::ReceiveGameCoordinatorListing(), QueryNetworkGameSocketHandler::ReceiveServerBanned(), QueryNetworkGameSocketHandler::ReceiveServerError(), QueryNetworkGameSocketHandler::ReceiveServerFull(), and QueryNetworkGameSocketHandler::ReceiveServerGameInfo().
|
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 |
Widgets and the structure of the NetworkClientListWindow.
Definition at line 1254 of file network_gui.cpp.
|
staticconstexpr |
Widgets and the structure of the NetworkAskRelayWindow.
Definition at line 2314 of file network_gui.cpp.
|
staticconstexpr |
Widgets and the structure of the NetworkAskSurveyWindow.
Definition at line 2416 of file network_gui.cpp.
|
staticconstexpr |
Widgets and the structure of the NetworkGameWindow.
Definition at line 876 of file network_gui.cpp.
|
staticconstexpr |
Widgets and the structure of the NetworkJoinStatusWindow.
Definition at line 2198 of file network_gui.cpp.
|
staticconstexpr |
Widgets and the structure of the NetworkStartServerWindow.
Definition at line 1163 of file network_gui.cpp.
| uint32_t _network_join_bytes |
The number of bytes we already downloaded.
Definition at line 2082 of file network_gui.cpp.
Referenced by NetworkJoinStatusWindow::DrawWidget(), ClientNetworkGameSocketHandler::ReceiveServerMapBegin(), and ClientNetworkGameSocketHandler::ReceiveServerMapData().
| uint32_t _network_join_bytes_total |
The total number of bytes to download.
Definition at line 2083 of file network_gui.cpp.
Referenced by NetworkJoinStatusWindow::DrawWidget(), ClientNetworkGameSocketHandler::ReceiveServerMapBegin(), and ClientNetworkGameSocketHandler::ReceiveServerMapSize().
| NetworkJoinStatus _network_join_status |
The status of joining.
Definition at line 2080 of file network_gui.cpp.
Referenced by NetworkJoinStatusWindow::DrawWidget(), NetworkClientJoinGame(), ClientNetworkGameSocketHandler::ReceiveServerMapBegin(), ClientNetworkGameSocketHandler::ReceiveServerMapDone(), ClientNetworkGameSocketHandler::ReceiveServerWaitForMap(), and ClientNetworkGameSocketHandler::SendJoin().
| uint8_t _network_join_waiting |
The number of clients waiting in front of us.
Definition at line 2081 of file network_gui.cpp.
Referenced by NetworkJoinStatusWindow::DrawWidget(), and ClientNetworkGameSocketHandler::ReceiveServerWaitForMap().
|
static |
Sentinel for an invalid location in the server list.
Definition at line 88 of file network_gui.cpp.
Referenced by NetworkGameWindow::BuildGUINetworkGameList(), NetworkGameWindow::OnClick(), NetworkGameWindow::OnKeyPress(), NetworkGameWindow::ScrollToSelectedServer(), and NetworkGameWindow::UpdateListPos().