Go to the documentation of this file.
10 #include "../stdafx.h"
11 #include "../strings_func.h"
12 #include "../date_func.h"
24 #include "../window_func.h"
25 #include "../gfx_func.h"
26 #include "../widgets/dropdown_type.h"
27 #include "../widgets/dropdown_func.h"
28 #include "../querystring_gui.h"
29 #include "../sortlist_type.h"
30 #include "../company_func.h"
31 #include "../command_func.h"
32 #include "../core/geometry_func.hpp"
33 #include "../genworld.h"
34 #include "../map_type.h"
35 #include "../guitimer_func.h"
36 #include "../zoom_func.h"
37 #include "../sprite.h"
38 #include "../settings_internal.h"
40 #include "../widgets/network_widget.h"
42 #include "table/strings.h"
43 #include "../table/sprites.h"
45 #include "../stringfilter_type.h"
48 # include <emscripten.h>
53 #include "../safeguards.h"
55 static void ShowNetworkStartServerWindow();
75 list.emplace_back(
new DropDownListStringItem(STR_NETWORK_SERVER_VISIBILITY_LOCAL, SERVER_GAME_TYPE_LOCAL,
false));
76 list.emplace_back(
new DropDownListStringItem(STR_NETWORK_SERVER_VISIBILITY_INVITE_ONLY, SERVER_GAME_TYPE_INVITE_ONLY,
false));
77 list.emplace_back(
new DropDownListStringItem(STR_NETWORK_SERVER_VISIBILITY_PUBLIC, SERVER_GAME_TYPE_PUBLIC,
false));
83 typedef int ServerListPosition;
84 static const ServerListPosition SLP_INVALID = -1;
111 this->visible[0] =
true;
112 *
lastof(this->visible) =
true;
127 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
128 child_wid->SetupSmallestSize(w, init_array);
129 this->
smallest_y = std::max(this->
smallest_y, child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom);
133 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
134 child_wid->current_x = child_wid->smallest_x;
153 for (uint i = 1; i <
lengthof(this->visible) - 1; i++) {
155 this->visible[i] =
true;
158 this->visible[i] =
false;
160 child_wid = child_wid->
next;
168 uint i = rtl ?
lengthof(this->visible) - 1 : 0;
169 child_wid = rtl ? this->
tail : this->
head;
170 while (child_wid !=
nullptr) {
171 if (this->visible[i]) {
176 child_wid = rtl ? child_wid->
prev : child_wid->
next;
184 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
185 if (!this->visible[i++])
continue;
196 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
197 if (!this->visible[i++])
continue;
199 if (nwid !=
nullptr)
return nwid;
249 this->servers.clear();
251 bool found_current_server =
false;
252 bool found_last_joined =
false;
254 this->servers.push_back(ngl);
255 if (ngl == this->server) {
256 found_current_server =
true;
258 if (ngl == this->last_joined) {
259 found_last_joined =
true;
263 if (!found_last_joined) {
264 this->last_joined =
nullptr;
266 if (!found_current_server) {
267 this->server =
nullptr;
268 this->list_pos = SLP_INVALID;
282 this->servers.shrink_to_fit();
284 this->vscroll->
SetCount((
int)this->servers.size());
287 this->servers.
Sort();
369 this->list_pos = SLP_INVALID;
370 for (uint i = 0; i != this->servers.size(); i++) {
371 if (this->servers[i] == this->server) {
380 assert(item !=
nullptr);
381 assert((*item) !=
nullptr);
384 sf.
AddLine((*item)->info.server_name.c_str());
466 if (this->list_pos == SLP_INVALID)
return;
473 this->list_pos = SLP_INVALID;
474 this->server =
nullptr;
476 this->lock_offset = 5;
477 this->blot_offset = this->lock_offset + 3 +
GetSpriteSize(SPR_LOCK).width;
478 this->flag_offset = this->blot_offset + 2 +
GetSpriteSize(SPR_BLOT).width;
495 #ifdef __EMSCRIPTEN__
496 EM_ASM(
if (window[
"openttd_server_list"]) openttd_server_list());
512 this->last_sorting = this->servers.
GetListing();
520 fill->height =
resize->height;
521 size->height = 12 *
resize->height;
529 size->width = NWidgetScrollbar::GetVerticalDimension().width;
567 const int max = std::min(this->vscroll->
GetPosition() + this->vscroll->GetCapacity(), (
int)this->servers.size());
569 for (
int i = this->vscroll->
GetPosition(); i < max; ++i) {
579 if (this->last_joined !=
nullptr) this->
DrawServerLine(this->last_joined, r.top, this->last_joined == this->server);
583 this->DrawDetails(r);
622 #ifdef __EMSCRIPTEN__
632 void DrawDetails(
const Rect &r)
const
640 if (sel ==
nullptr) {
647 case NGLS_OFFLINE: message = STR_NETWORK_SERVER_LIST_SERVER_OFFLINE;
break;
648 case NGLS_FULL: message = STR_NETWORK_SERVER_LIST_SERVER_FULL;
break;
649 case NGLS_BANNED: message = STR_NETWORK_SERVER_LIST_SERVER_BANNED;
break;
650 case NGLS_TOO_OLD: message = STR_NETWORK_SERVER_LIST_SERVER_TOO_OLD;
break;
661 uint16 y = r.top + detail_height + 4;
731 if (this->list_pos != SLP_INVALID) this->list_pos = (ServerListPosition)this->servers.size() - this->list_pos - 1;
743 this->server = (id_v < this->servers.size()) ? this->servers[id_v] :
nullptr;
744 this->list_pos = (
server ==
nullptr) ? SLP_INVALID : id_v;
753 if (this->last_joined !=
nullptr) {
769 this->searched_internet =
true;
780 STR_NETWORK_SERVER_LIST_ENTER_SERVER_ADDRESS,
786 ShowNetworkStartServerWindow();
790 if (this->server !=
nullptr) {
826 if (this->list_pos == SLP_INVALID)
return ES_HANDLED;
828 this->server = this->servers[this->
list_pos];
838 if (this->server !=
nullptr) {
839 if (keycode == WKC_DELETE) {
841 if (this->server == this->last_joined) this->last_joined =
nullptr;
842 this->server =
nullptr;
843 this->list_pos = SLP_INVALID;
874 NetworkRebuildHostList();
885 if (!this->searched_internet)
return;
886 if (!this->requery_timer.
Elapsed(delta_ms))
return;
893 Listing NetworkGameWindow::last_sorting = {
false, 5};
907 static NWidgetBase *MakeResizableHeader(
int *biggest_index)
909 *biggest_index = std::max<int>(*biggest_index,
WID_NG_INFO);
913 static const NWidgetPart _nested_network_game_widgets[] = {
928 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
943 SetDataTip(0x0, STR_NETWORK_SERVER_LIST_CLICK_TO_SELECT_LAST),
954 SetDataTip(STR_NETWORK_SERVER_LIST_PLAYER_NAME_OSKTITLE, STR_NETWORK_SERVER_LIST_ENTER_NAME_TOOLTIP),
958 NWidget(
WWT_EMPTY, INVALID_COLOUR,
WID_NG_DETAILS_SPACER),
SetMinimalSize(140, 0),
SetMinimalTextLines(15, 24 +
WD_PAR_VSEP_NORMAL),
SetResize(0, 1),
SetFill(1, 1),
1005 _nested_network_game_widgets,
lengthof(_nested_network_game_widgets)
1008 void ShowNetworkGameWindow()
1010 static bool first =
true;
1061 size->width += padding.width;
1062 size->height += padding.height;
1080 ShowNetworkGameWindow();
1100 default: NOT_REACHED();
1125 if (!CheckServerName())
return;
1135 if (!CheckServerName())
return;
1141 if (!CheckServerName())
return;
1147 if (!CheckServerName())
return;
1167 bool CheckServerName()
1169 std::string str = this->name_editbox.text.
buf;
1179 for (
const int *widget = raise_widgets; *widget !=
WIDGET_LIST_END; widget++) {
1189 if (str ==
nullptr)
return;
1194 int32 value = atoi(str);
1196 switch (this->widget_id) {
1197 default: NOT_REACHED();
1207 static const NWidgetPart _nested_network_start_server_window_widgets[] = {
1274 static WindowDesc _network_start_server_window_desc(
1278 _nested_network_start_server_window_widgets,
lengthof(_nested_network_start_server_window_widgets)
1281 static void ShowNetworkStartServerWindow()
1295 static const NWidgetPart _nested_client_list_widgets[] = {
1303 NWidget(
WWT_FRAME, COLOUR_GREY),
SetDataTip(STR_NETWORK_CLIENT_LIST_SERVER, STR_NULL),
SetPadding(4, 4, 0, 4),
SetPIP(0, 2, 0),
1307 NWidget(
WWT_TEXT, COLOUR_GREY,
WID_CL_SERVER_NAME),
SetFill(1, 0),
SetMinimalTextLines(1, 0),
SetResize(1, 0),
SetDataTip(STR_BLACK_RAW_STRING, STR_NETWORK_CLIENT_LIST_SERVER_NAME_TOOLTIP),
SetAlignment(
SA_VERT_CENTER |
SA_RIGHT),
1320 NWidget(
WWT_TEXT, COLOUR_GREY,
WID_CL_SERVER_INVITE_CODE),
SetFill(1, 0),
SetMinimalTextLines(1, 0),
SetResize(1, 0),
SetDataTip(STR_BLACK_RAW_STRING, STR_NETWORK_CLIENT_LIST_SERVER_INVITE_CODE_TOOLTIP),
SetAlignment(
SA_VERT_CENTER |
SA_RIGHT),
1325 NWidget(
WWT_TEXT, COLOUR_GREY,
WID_CL_SERVER_CONNECTION_TYPE),
SetFill(1, 0),
SetMinimalTextLines(1, 0),
SetResize(1, 0),
SetDataTip(STR_BLACK_STRING, STR_NETWORK_CLIENT_LIST_SERVER_CONNECTION_TYPE_TOOLTIP),
SetAlignment(
SA_VERT_CENTER |
SA_RIGHT),
1330 NWidget(
WWT_FRAME, COLOUR_GREY),
SetDataTip(STR_NETWORK_CLIENT_LIST_PLAYER, STR_NULL),
SetPadding(4, 4, 4, 4),
SetPIP(0, 2, 0),
1334 NWidget(
WWT_TEXT, COLOUR_GREY,
WID_CL_CLIENT_NAME),
SetFill(1, 0),
SetMinimalTextLines(1, 0),
SetResize(1, 0),
SetDataTip(STR_BLACK_RAW_STRING, STR_NETWORK_CLIENT_LIST_PLAYER_NAME_TOOLTIP),
SetAlignment(
SA_VERT_CENTER |
SA_RIGHT),
1340 NWidget(
WWT_MATRIX, COLOUR_GREY,
WID_CL_MATRIX),
SetMinimalSize(180, 0),
SetResize(1, 1),
SetFill(1, 1),
SetMatrixDataTip(1, 0, STR_NULL),
SetScrollbar(
WID_CL_SCROLLBAR),
1341 NWidget(
WWT_TEXT, COLOUR_GREY,
WID_CL_CLIENT_COMPANY_COUNT),
SetFill(1, 0),
SetMinimalTextLines(1, 0),
SetResize(1, 0),
SetPadding(2, 1, 2, 1),
SetAlignment(
SA_CENTER),
SetDataTip(STR_NETWORK_CLIENT_LIST_CLIENT_COMPANY_COUNT, STR_NULL),
1352 WDP_AUTO,
"list_clients", 220, 300,
1355 _nested_client_list_widgets,
lengthof(_nested_client_list_widgets)
1363 DD_CLIENT_ADMIN_KICK,
1364 DD_CLIENT_ADMIN_BAN,
1365 DD_COMPANY_ADMIN_RESET,
1366 DD_COMPANY_ADMIN_UNLOCK,
1449 template<
typename T>
1462 assert(
proc !=
nullptr);
1469 this->
proc(w, pt, this->
id);
1494 std::map<uint, std::vector<std::unique_ptr<ButtonCommon>>>
buttons;
1553 list.emplace_back(
new DropDownListStringItem(STR_NETWORK_CLIENT_LIST_ADMIN_CLIENT_KICK, DD_CLIENT_ADMIN_KICK,
false));
1554 list.emplace_back(
new DropDownListStringItem(STR_NETWORK_CLIENT_LIST_ADMIN_CLIENT_BAN, DD_CLIENT_ADMIN_BAN,
false));
1557 wi_rect.left = pt.x;
1558 wi_rect.right = pt.x;
1560 wi_rect.bottom = pt.y;
1579 wi_rect.left = pt.x;
1580 wi_rect.right = pt.x;
1582 wi_rect.bottom = pt.y;
1608 this->buttons[
line_count].emplace_back(chat_button);
1611 this->line_count += 1;
1613 bool has_players =
false;
1615 if (ci->client_playas != company_id)
continue;
1627 this->line_count += 1;
1631 chat_button->
disabled = !has_players;
1642 this->buttons.clear();
1643 this->line_count = 0;
1644 this->player_host_index = -1;
1645 this->player_self_index = -1;
1650 this->line_count += 1;
1659 if (c->index == client_playas)
continue;
1667 this->vscroll->
SetCount(this->line_count);
1684 auto button_find = this->buttons.find(index);
1685 if (button_find == this->buttons.end())
return nullptr;
1688 for (
auto &button : button_find->second) {
1689 uint
left = rtl ? x : x - button->width;
1690 uint right = rtl ? x + button->width : x;
1693 return button.get();
1730 size->width += padding.width;
1731 size->height += padding.height;
1742 size->height = std::max(size->height, 5 * this->line_height);
1765 static std::string empty = {};
1810 if (button ==
nullptr)
break;
1834 uint player_icon_x = rtl ? text_right - offset_x - d2.width : text_left + offset_x;
1836 if (
IsInsideMM(pt.x, player_icon_x, player_icon_x + d2.width)) {
1837 if (index == this->player_self_index) {
1838 GuiShowTooltips(
this, STR_NETWORK_CLIENT_LIST_PLAYER_ICON_SELF_TOOLTIP, 0,
nullptr, close_cond);
1840 }
else if (index == this->player_host_index) {
1841 GuiShowTooltips(
this, STR_NETWORK_CLIENT_LIST_PLAYER_ICON_HOST_TOOLTIP, 0,
nullptr, close_cond);
1847 if (button ==
nullptr)
return false;
1880 case DD_CLIENT_ADMIN_KICK:
1882 text = STR_NETWORK_CLIENT_LIST_ASK_CLIENT_KICK;
1887 case DD_CLIENT_ADMIN_BAN:
1889 text = STR_NETWORK_CLIENT_LIST_ASK_CLIENT_BAN;
1894 case DD_COMPANY_ADMIN_RESET:
1896 text = STR_NETWORK_CLIENT_LIST_ASK_COMPANY_RESET;
1901 case DD_COMPANY_ADMIN_UNLOCK:
1903 text = STR_NETWORK_CLIENT_LIST_ASK_COMPANY_UNLOCK;
1912 assert(text != STR_NULL);
1913 assert(callback !=
nullptr);
1916 ShowQuery(STR_NETWORK_CLIENT_LIST_ASK_CAPTION, text,
this, callback);
1930 if (str ==
nullptr)
return;
1932 switch (this->query_widget) {
1933 default: NOT_REACHED();
1967 for (
auto &button :
buttons) {
1970 uint
left = rtl ? x : x - button->width;
1971 uint right = rtl ? x + button->width : x;
1973 int offset = std::max(0, ((
int)(this->line_height + 1) - (
int)button->height) / 2);
1975 DrawFrameRect(
left, y + offset, right, y + offset + button->height, button->colour, FR_NONE);
1977 if (button->disabled) {
2000 int offset = std::max(0, ((
int)(this->line_height + 1) - (
int)d.height) / 2);
2006 uint line_end = line_start + this->vscroll->
GetCapacity();
2008 uint y =
top + (this->line_height * (line - line_start));
2011 if (
IsInsideMM(line, line_start, line_end)) {
2012 uint x = rtl ? text_left : text_right;
2015 auto button_find = this->buttons.find(line);
2016 if (button_find != this->buttons.end()) {
2021 DrawSprite(SPR_COMPANY_ICON, PALETTE_TO_GREY, rtl ? right - d.width - 4 :
left + 4, y + offset);
2022 DrawString(rtl ? x : text_left, rtl ? text_right : x, y + text_y_offset, STR_NETWORK_CLIENT_LIST_SPECTATORS, TC_SILVER);
2024 DrawSprite(SPR_COMPANY_ICON, PALETTE_TO_GREY, rtl ? right - d.width - 4 :
left + 4, y + offset);
2025 DrawString(rtl ? x : text_left, rtl ? text_right : x, y + text_y_offset, STR_NETWORK_CLIENT_LIST_NEW_COMPANY, TC_WHITE);
2031 DrawString(rtl ? x : text_left, rtl ? text_right : x, y + text_y_offset, STR_COMPANY_NAME, TC_SILVER);
2039 if (ci->client_playas != company_id)
continue;
2042 if (
IsInsideMM(line, line_start, line_end)) {
2043 uint x = rtl ? text_left : text_right;
2046 auto button_find = this->buttons.find(line);
2047 if (button_find != this->buttons.end()) {
2053 player_icon = SPR_PLAYER_SELF;
2055 player_icon = SPR_PLAYER_HOST;
2058 if (player_icon != 0) {
2061 int offset_y = std::max(0, ((
int)(this->line_height + 1) - (
int)d2.height) / 2);
2062 DrawSprite(player_icon, PALETTE_TO_GREY, rtl ? text_right - offset_x : text_left + offset_x - d2.width, y + offset_y);
2080 if (this->hover_index >= 0) {
2081 uint offset = this->hover_index * this->
line_height;
2082 GfxFillRect(r.left + 2, r.top + offset, r.right - 1, r.top + offset + this->line_height - 2,
GREY_SCALE(9));
2093 this->
DrawCompany(client_playas, r.left, r.right, r.top, line);
2097 if (client_playas == c->index)
continue;
2098 this->
DrawCompany(c->index, r.left, r.right, r.top, line);
2112 this->hover_index = -1;
2118 int y = _cursor.
pos.y - this->
top - nwi->
pos_y - 2;
2121 if (index != this->hover_index) {
2122 this->hover_index = index;
2128 void ShowClientList()
2130 AllocateWindowDescFront<NetworkClientListWindow>(&_client_list_desc, 0);
2154 case NETWORK_JOIN_STATUS_CONNECTING:
case NETWORK_JOIN_STATUS_AUTHORIZING:
2155 case NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO:
2158 case NETWORK_JOIN_STATUS_WAITING:
2163 case NETWORK_JOIN_STATUS_DOWNLOADING:
2178 DrawFrameRect(r.left + 20, r.top + 5, (
int)((this->width - 20) * progress / 100), r.top + 15, COLOUR_MAUVE, FR_NONE);
2189 for (uint i = 0; i < NETWORK_JOIN_STATUS_END; i++) {
2212 ShowNetworkGameWindow();
2223 switch (this->password_type) {
2226 default: NOT_REACHED();
2231 static const NWidgetPart _nested_network_join_status_window_widgets[] = {
2244 static WindowDesc _network_join_status_window_desc(
2248 _nested_network_join_status_window_widgets,
lengthof(_nested_network_join_status_window_widgets)
2251 void ShowJoinStatusWindow()
2260 if (w ==
nullptr)
return;
2261 w->password_type = npt;
2265 default: NOT_REACHED();
2279 this->UpdateWarningStringSize();
2288 void UpdateWarningStringSize()
2292 this->warning_size.height =
GetStringHeight(STR_WARNING_PASSWORD_SECURITY, this->warning_size.width);
2311 STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING,
SA_CENTER);
2342 static const NWidgetPart _nested_network_company_password_window_widgets[] = {
2356 SetDataTip(STR_COMPANY_PASSWORD_MAKE_DEFAULT, STR_COMPANY_PASSWORD_MAKE_DEFAULT_TOOLTIP),
2367 static WindowDesc _network_company_password_window_desc(
2371 _nested_network_company_password_window_widgets,
lengthof(_nested_network_company_password_window_widgets)
2374 void ShowNetworkCompanyPasswordWindow(
Window *parent)
2454 static const NWidgetPart _nested_network_ask_relay_widgets[] = {
2473 _nested_network_ask_relay_widgets,
lengthof(_nested_network_ask_relay_widgets)
2482 void ShowNetworkAskRelay(
const std::string &server_connection_string,
const std::string &relay_connection_string,
const std::string &token)
2487 new NetworkAskRelayWindow(&_network_ask_relay_desc, parent, server_connection_string, relay_connection_string, token);
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
@ ES_HANDLED
The passed event is handled.
std::string connect_to_ip
default for the "Add server" query
static bool NGameAllowedSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by joinability.
int gamescript_version
Version of the gamescript.
static ClientID _admin_client_id
For what client a confirmation window is open.
static void OnClickClientAdmin(NetworkClientListWindow *w, Point pt, ClientID client_id)
Admin button on a Client is clicked.
bool NetworkValidateServerName(std::string &server_name)
Trim the given server name in place, i.e.
std::string connection_string
Address of the server.
uint32 _network_join_bytes_total
The total number of bytes to download.
static void AdminCompanyUnlockCallback(Window *w, bool confirmed)
Callback function for admin command to unlock company.
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
QueryString name_editbox
Client name editbox.
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
std::string gamescript_name
Name of the gamescript.
@ FT_SCENARIO
old or new scenario
void ConnectFailure(const std::string &token, uint8 tracking_number)
Callback from a Connecter to let the Game Coordinator know the connection failed.
uint8 SortType() const
Get the sorttype of the list.
static Titem * Get(size_t index)
Returns Titem with given index.
int ok_button
Widget button of parent window to simulate when pressing OK in OSK.
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
char32_t WChar
Type for wide characters, i.e.
std::string relay_connection_string
The relay server we want to connect to.
bool NetworkValidateOurClientName()
Convenience method for NetworkValidateClientName on _settings_client.network.client_name.
@ INVALID_CLIENT_ID
Client is not part of anything.
NetworkGameList * NetworkAddServer(const std::string &connection_string, bool manually, bool never_expire)
Validates an address entered as a string and adds the server to the list.
@ QSF_PASSWORD
password entry box, show warning about password security
Dimensions (a width and height) of a rectangle in 2D.
void DrawSortButtonState(int widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
NWidgetBase * nested_root
Root of the nested tree.
bool Sort(Comp compare)
Sort the list.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Date game_date
Current date.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
void OnResize() override
Called after the window got resized.
uint8 _network_join_waiting
The number of clients waiting in front of us.
@ QSF_ACCEPT_UNCHANGED
return success even when the text didn't change
static const SettingDesc * GetSettingFromName(const std::string_view name, const SettingTable &settings)
Given a name of setting, return a setting description from the table.
Scrollbar * vscroll
Vertical scrollbar of the list of servers.
ConnectionType _network_server_connection_type
What type of connection the Game Coordinator detected we are on.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
bool IsEmpty() const
Check whether any filter words were entered.
uint8 max_clients
maximum amount of clients
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
ButtonCommon * GetButtonAtPoint(Point pt)
Get the button at a specific point on the WID_CL_MATRIX.
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
void SetFilterTerm(const char *str)
Set the term to filter on.
static const uint NETWORK_NAME_LENGTH
The maximum length of the server name and map name, in bytes including '\0'.
CompanyID client_playas
As which company is this client playing (CompanyID)
@ WD_MATRIX_TOP
Offset at top of a matrix cell.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
std::string server_revision
The version number the server is using (e.g.: 'r304' or 0.5.0)
void NetworkClientRequestMove(CompanyID company_id, const std::string &pass)
Notify the server of this client wanting to be moved to another company.
EventState OnKeyPress(WChar key, uint16 keycode) override
A key has been pressed.
std::string default_company_pass
default password for new companies in encrypted form
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
bool _network_server
network-server is active
void Assign(StringID string)
Render a string into the textbuffer.
void SortNetworkGameList()
Sort the server list.
int hover_index
Index of the current line we are hovering over, or -1 if none.
static const int NETWORK_LIST_REFRESH_DELAY
Time, in seconds, between updates of the network list.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
@ WC_CLIENT_LIST
Client list; Window numbers:
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
byte clients_max
Max clients allowed on server.
@ WC_COMPANY_PASSWORD_WINDOW
Company password query; Window numbers:
bool NetworkCompanyHasClients(CompanyID company)
Check whether a particular company has clients.
static void OnClickCompanyJoin(NetworkClientListWindow *w, Point pt, CompanyID company_id)
Join button on a Company is clicked.
GUIGameServerList servers
List with game servers.
NetworkJoinStatus
Status of the clients during joining.
void OnResize() override
Called after the window got resized.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
static bool NGameNameSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by name.
std::map< uint, std::vector< std::unique_ptr< ButtonCommon > > > buttons
Per line which buttons are available.
void ShowMissingContentWindow(const GRFConfig *list)
Show the content list window with all missing grfs from the given list.
static void AdminCompanyResetCallback(Window *w, bool confirmed)
Callback function for admin command to reset company.
void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
Handle the tid-bits of moving a client from one company to another.
QueryString password_editbox
Password editbox.
bool _ctrl_pressed
Is Ctrl pressed?
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
static const uint MAX_CLIENTS
How many clients can we have.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
void OnEditboxChanged(int wid) override
The text in an editbox has been edited.
@ WD_FRAMETEXT_TOP
Top offset of the text of the frame.
@ DESTTYPE_TEAM
Send message/notice to everyone playing the same company (Team)
ClientSettings _settings_client
The current settings for this game.
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
void UpdateNetworkGameWindow()
Update the network new window because a new server is found on the network.
void NetworkUDPSearchGame()
Find all servers.
void AddLine(const char *str)
Pass another text line from the current item to the filter.
ClientID dd_client_id
During admin dropdown, track which client this was for.
virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close)
A dropdown window associated to this window has been closed.
NetworkJoinStatus _network_join_status
The status of joining.
int32 WindowNumber
Number to differentiate different windows of the same class.
std::string _network_server_name
The current name of the server you are on.
@ SA_RIGHT
Right align the text (must be a single bit).
@ SA_VERT_CENTER
Vertically center the text.
UseRelayService use_relay_service
Use relay service?
static bool NGameClientSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by the amount of clients online on a server.
void SetSortType(uint8 n_type)
Set the sorttype of the list.
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
static const uint NETWORK_CLIENT_NAME_LENGTH
The maximum length of a client's name, in bytes including '\0'.
Owner
Enum for all companies/owners.
@ WD_FRAMETEXT_LEFT
Left offset of the text of the frame.
static void AdminClientKickCallback(Window *w, bool confirmed)
Callback function for admin command to kick client.
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
bool version_compatible
Can we connect to this server or not? (based on server_revision)
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, CompanyID company)
Prepare a DoCommand to be send over the network.
static const uint32 GENERATE_NEW_SEED
Create a new random seed.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Data stored about a string that can be modified in the GUI.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
char *const buf
buffer in which text is saved
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
@ QSF_LEN_IN_CHARS
the length of the string is counted in characters
NetworkGameList * _network_game_list
Game list of this client.
CompanyID dd_company_id
During admin dropdown, track which company this was for.
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
std::string NetworkChangeCompanyPassword(CompanyID company_id, std::string password)
Change the company password of a given company.
void NetworkQueryServer(const std::string &connection_string)
Query a server to fetch the game-info.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
static void OnClickCompanyAdmin(NetworkClientListWindow *w, Point pt, CompanyID company_id)
Admin button on a Company is clicked.
void OnRealtimeTick(uint delta_ms) override
Called periodically.
High level window description.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Window used for asking the user if he is okay using a relay server.
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
NetworkGameList * last_joined
The last joined server.
static NetworkRecvStatus SendCompanyPassword(const std::string &password)
Set the company password as requested.
@ NGLS_TOO_OLD
Server is too old to query.
bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override
Event to display a custom tooltip.
bool IsDescSortOrder() const
Check if the sort order is descending.
@ COMPANY_NEW_COMPANY
The client wants a new company.
void DrawButtons(uint &x, uint y, const std::vector< std::unique_ptr< ButtonCommon >> &buttons) const
Draw the buttons for a single line in the matrix.
@ WDP_AUTO
Find a place automatically.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Data structure describing how to show the list (what sort direction and criteria).
void SetFilterState(bool state)
Enable or disable the filter.
@ SLO_LOAD
File is being loaded.
ResizeInfo resize
Resize information.
void GuiShowTooltips(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip)
Shows a tooltip.
std::string last_joined
Last joined server.
static void OnClickClientChat(NetworkClientListWindow *w, Point pt, ClientID client_id)
Chat button on a Client is clicked.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Main handle for clientlist.
void ShowGenerateLandscape()
Start with a normal game.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
bool NetworkMaxCompaniesReached()
Check if max_companies has been reached on the server (local check only).
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
int height
Height of the window (number of pixels down in y direction)
@ WN_NETWORK_WINDOW_START
Network start server.
static void OnClickCompanyNew(NetworkClientListWindow *w, Point pt, CompanyID company_id)
Crete new company button is clicked.
QueryString name_editbox
Server name editbox.
bool SortFunction(const NetworkGameList * &, const NetworkGameList * &)
Signature of sort function.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
void SetListing(Listing l)
Import sort conditions.
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
static bool NGameDateSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by current date.
static bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
ClientID
'Unique' identifier to be given to clients
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
@ ES_NOT_HANDLED
The passed event is not handled.
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
@ WD_FRAMETEXT_BOTTOM
Bottom offset of the text of the frame.
QueryString filter_editbox
Editbox for filter on servers.
static bool NGameYearsSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by the number of days the game is running.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
GUITimer requery_timer
Timer for network requery.
bool StrStartsWith(const std::string_view str, const std::string_view prefix)
Check whether the given string starts with the given prefix.
@ CCA_NEW
Create a new company.
void ConvertDateToYMD(Date date, YearMonthDay *ymd)
Converts a Date to a Year, Month & Day.
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Window * parent
Parent window.
@ MAX_COMPANIES
Maximum number of companies.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
uint line_count
Amount of lines in the matrix.
@ NETWORK_COMPANY_PASSWORD
The password of the company.
void NetworkDisconnect(bool blocking, bool close_admins)
We want to disconnect from the host/clients.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
std::string client_name
name of the player (as client)
int left
x position of left edge of the window
WindowFlags flags
Window flags.
@ WF_TIMEOUT
Window timeout counter.
@ CLIENT_ID_SERVER
Servers always have this ID.
@ WN_NETWORK_WINDOW_GAME
Network game window.
int blot_offset
Left offset for green/yellow/red compatibility icon.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
static void OnClickCompanyChat(NetworkClientListWindow *w, Point pt, CompanyID company_id)
Chat button on a Company is clicked.
void BuildGUINetworkGameList()
(Re)build the GUI network game list (a.k.a.
byte widget_id
The widget that has the pop-up input menu.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
@ WDF_MODAL
The window is a modal child of some other window, meaning the parent is 'inactive'.
byte companies_on
How many started companies do we have.
uint NetworkServerKickOrBanIP(ClientID client_id, bool ban, const std::string &reason)
Ban, or kick, everyone joined from the given client's IP.
Coordinates of a point in 2D.
bool searched_internet
Did we ever press "Search Internet" button?
byte companies_max
Max companies allowed on server.
void GetListing()
Request a listing of all public servers.
std::string token
The token for this connection.
void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
A dropdown window associated to this window has been closed.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
int player_self_index
The line the current player is on.
@ CRR_MANUAL
The company is manually removed.
@ WD_FRAMETEXT_RIGHT
Right offset of the text of the frame.
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
@ FT_SAVEGAME
old or new savegame
WindowNumber window_number
Window number within the window class.
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
uint step_height
Step-size of height resize changes.
void ToggleSortOrder()
Toggle the sort order Since that is the worst condition for the sort function reverse the list here.
bool NeedResort()
Check if a resort is needed next loop If used the resort timer will decrease every call till 0.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
void OnTimeout() override
Called when this window's timeout has been reached.
bool NetworkCompanyIsPassworded(CompanyID company_id)
Check if the company we want to join requires a password.
void StartNewGameWithoutGUI(uint32 seed)
Start a normal game without the GUI.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
int player_host_index
The line the host is on.
@ SA_HOR_CENTER
Horizontally center the text.
static const uint NETWORK_HOSTNAME_PORT_LENGTH
The maximum length of the host name + port, in bytes including '\0'. The extra six is ":" + port numb...
@ CONNECTION_TYPE_UNKNOWN
The Game Coordinator hasn't informed us yet what type of connection we have.
static const uint8 PC_GREY
Grey palette colour.
static const uint NETWORK_PASSWORD_LENGTH
The maximum length of the password, in bytes including '\0' (must be >= NETWORK_SERVER_ID_LENGTH)
NWidgetBase ** nested_array
Array of pointers into the tree. Do not access directly, use Window::GetWidget() instead.
ClientID _network_own_client_id
Our client identifier.
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
void DrawServerLine(const NetworkGameList *cur_item, uint y, bool highlight) const
Draw a single server line.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
std::string server_name
name of the server
bool NeedRebuild() const
Check if a rebuild is needed.
std::string server_connection_string
The game server we want to connect to.
CompanyID join_company
During query for company password, this stores what company we wanted to join.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
void ScrollToSelectedServer()
Scroll the list up or down to the currently selected server.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
NetworkGameList * server
Selected server.
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
Show a modal confirmation window with standard 'yes' and 'no' buttons The window is aligned to the ce...
@ SBS_DOWN
Sort ascending.
ServerGameType server_game_type
Server type: local / public / invite-only.
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
DropDownAdmin
The possibly entries in a DropDown for an admin.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static CompanyID _admin_company_id
For what company a confirmation window is open.
ServerGameType
Game type the server can be using.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
static size_t GetNumItems()
Returns number of valid items in the pool.
uint16 map_width
Map width.
void RebuildListCompany(CompanyID company_id, CompanyID client_playas)
Part of RebuildList() to create the information for a single company.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
uint line_height
Current lineheight of each entry in the matrix.
bool SetSettingValue(const IntSettingDesc *sd, int32 value, bool force_newgame)
Top function to save the new value of an element of the Settings struct.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
void DrawCompany(CompanyID company_id, uint left, uint right, uint top, uint &line) const
Draw a company and its clients on the matrix.
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
ClientListWidgets query_widget
During a query this tracks what widget caused the query.
static const uint8 PC_DARK_BLUE
Dark blue palette colour.
@ COMPANY_SPECTATOR
The client is spectating.
@ WC_NETWORK_WINDOW
Network window; Window numbers:
bool CDECL FilterFunction(const NetworkGameList * *, StringFilter &)
Signature of filter function.
void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
void CloseWindowByClass(WindowClass cls)
Close all windows of a given class.
bool use_password
Is this server passworded?
@ WC_NETWORK_STATUS_WINDOW
Network status window; Window numbers:
void ResetState()
Reset the matching state to process a new item.
void UpdateListPos()
Set this->list_pos to match this->server.
ClientNetworkCoordinatorSocketHandler _network_coordinator_client
The connection to the Game Coordinator.
Listing GetListing() const
Export current sort conditions.
@ NGLS_BANNED
You are banned from this server.
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
std::string server_password
password for joining this server
NetworkPasswordType
The type of password we're asking for.
EventState
State of handling an event.
@ NGLS_ONLINE
Server is online.
@ WC_NETWORK_ASK_RELAY
Network ask relay window; Window numbers:
bool GetState() const
Get the matching state of the current item.
@ FT_HEIGHTMAP
heightmap file
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
@ WC_MAIN_WINDOW
Main window; Window numbers:
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
@ SM_MENU
Switch to game intro menu.
static const int ACTION_CLEAR
Clear editbox.
@ CMD_COMPANY_CTRL
used in multiplayer to create a new companies etc.
int top
y position of top edge of the window
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
bool Elapsed(uint delta)
Test if a timer has elapsed.
static void AdminClientBanCallback(Window *w, bool confirmed)
Callback function for admin command to ban client.
void ShowNetworkChatQueryWindow(DestType type, int dest)
Show the chat window.
Structure with information shown in the game list (GUI)
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
bool NetworkClientConnectGame(const std::string &connection_string, CompanyID default_company, const std::string &join_server_password, const std::string &join_company_password)
Join a client to the server at with the given connection string.
@ WD_MATRIX_BOTTOM
Offset at bottom of a matrix cell.
void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width, bool instant_close)
Show a drop down list.
void ForceRebuild()
Force that a rebuild is needed.
@ SA_CENTER
Center both horizontally and vertically.
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
@ NGLS_OFFLINE
Server is offline (or cannot be queried).
#define lengthof(x)
Return the length of an fixed size array.
int width
width of the window (number of pixels to the right in x direction)
Data structure to convert between Date and triplet (year, month, and day).
Dimension warning_size
How much space to use for the warning text.
static const SpriteID SPR_FLAGS_BASE
Flags sprites (in same order as enum NetworkLanguage)
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
NetworkSettings network
settings related to the network
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
virtual void OnMouseLoop() override
Called for every mouse loop run, which is at least once per (game) tick.
int lock_offset
Left offset for lock icon.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
Scrollbar * vscroll
Vertical scrollbar of this window.
@ INVALID_COMPANY
An invalid company.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
void RebuildList()
Rebuild the list, meaning: calculate the lines needed and what buttons go on which line.
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
void NetworkUpdateServerGameType()
The setting server_game_type was updated; possibly we need to take some action.
void NetworkServerKickClient(ClientID client_id, const std::string &reason)
Kick a single client.
@ CCA_DELETE
Delete a company.
NetworkGameList * next
Next pointer to make a linked game list.
Date start_date
When the game started.
@ DESTTYPE_CLIENT
Send message/notice to only a certain client (Private)
byte landscape
The used landscape.
#define GREY_SCALE(level)
Return the colour for a particular greyscale level.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Data structure for an opened window.
void RebuildDone()
Notify the sortlist that the rebuild is done.
void QueryCallbackProc(Window *, bool)
Callback procedure for the ShowQuery method.
void RaiseWidget(byte widget_index)
Marks a widget as raised.
std::string server_name
Server name.
void DrawWidgets() const
Paint all widgets of a window.
@ ZOOM_LVL_OUT_4X
Zoomed 4 times out.
bool refreshing
Whether this server is being queried.
static const uint MAX_MAP_SIZE
Maximal map size = 4096.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
static NetworkRecvStatus SendGamePassword(const std::string &password)
Set the game password as requested.
StringList _network_host_list
The servers we know.
void OnPaint() override
The window must be repainted.
NetworkGameInfo info
The game information of this server.
byte clients_on
Current count of clients on server.
@ WN_NETWORK_STATUS_WINDOW_JOIN
Network join status.
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
@ NGLS_FULL
Server is full and cannot be queried.
void NetworkServerSetCompanyPassword(CompanyID company_id, const std::string &password, bool already_hashed)
Set/Reset a company password on the server end.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Specification of a rectangle with absolute coordinates of all edges.
Point pos
logical mouse position
static const int CLIENT_OFFSET_LEFT
Offset of client entries compared to company entries.
std::string _network_server_invite_code
Our invite code as indicated by the Game Coordinator.
void NetworkGameListRemoveItem(NetworkGameList *remove)
Remove an item from the gamelist linked list.
#define lastof(x)
Get the last element of an fixed size array.
GRFConfig * grfconfig
List of NewGRF files used.
void SetDParamMaxDigits(uint n, uint count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
uint32 _network_join_bytes
The number of bytes we already downloaded.
ServerListPosition list_pos
Position of the selected server.
@ WDP_CENTER
Center the window.
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
static bool NGameMapSizeSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by map size.
bool _left_button_clicked
Is left mouse button clicked?
@ TD_RTL
Text is written right-to-left by default.
TextDirection _current_text_dir
Text direction of the currently selected language.
bool _is_network_server
Does this client wants to be a network-server?
@ CS_NUMERAL
Only numeric ones.
void FindWindowPlacementAndResize(int def_width, int def_height) override
Resize window towards the default size.
Container for all information known about a client.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
bool compatible
Can we connect to this server or not? (based on server_revision and grf_match.
int flag_offset
Left offset for language flag icon.
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
uint16 map_height
Map height.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
@ NETWORK_GAME_PASSWORD
The password of the game.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
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.
uint8 max_companies
maximum amount of companies
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
NetworkGameListStatus status
Stats of the server.
void DrawCompanyIcon(CompanyID cid, int x, int y)
Draw the icon of a company.
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.