10 #include "../stdafx.h"
11 #include "../strings_func.h"
24 #include "../window_func.h"
25 #include "../gfx_func.h"
26 #include "../dropdown_type.h"
27 #include "../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 "../zoom_func.h"
36 #include "../sprite.h"
37 #include "../settings_internal.h"
38 #include "../company_cmd.h"
39 #include "../timer/timer.h"
40 #include "../timer/timer_window.h"
41 #include "../timer/timer_game_calendar.h"
42 #include "../textfile_gui.h"
44 #include "../widgets/network_widget.h"
46 #include "table/strings.h"
47 #include "../table/sprites.h"
49 #include "../stringfilter_type.h"
52 # include <emscripten.h>
55 #include "../safeguards.h"
57 static void ShowNetworkStartServerWindow();
75 list.push_back(MakeDropDownListStringItem(STR_NETWORK_SERVER_VISIBILITY_LOCAL, SERVER_GAME_TYPE_LOCAL));
76 list.push_back(MakeDropDownListStringItem(STR_NETWORK_SERVER_VISIBILITY_INVITE_ONLY, SERVER_GAME_TYPE_INVITE_ONLY));
77 list.push_back(MakeDropDownListStringItem(STR_NETWORK_SERVER_VISIBILITY_PUBLIC, SERVER_GAME_TYPE_PUBLIC));
83 typedef int ServerListPosition;
84 static const ServerListPosition SLP_INVALID = -1;
92 auto leaf = std::make_unique<NWidgetLeaf>(
WWT_PUSHTXTBTN, COLOUR_WHITE,
WID_NG_NAME, STR_NETWORK_SERVER_LIST_GAME_NAME, STR_NETWORK_SERVER_LIST_GAME_NAME_TOOLTIP);
93 leaf->SetResize(1, 0);
95 this->
Add(std::move(leaf));
97 this->
Add(std::make_unique<NWidgetLeaf>(
WWT_PUSHTXTBTN, COLOUR_WHITE,
WID_NG_CLIENTS, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION_TOOLTIP));
98 this->
Add(std::make_unique<NWidgetLeaf>(
WWT_PUSHTXTBTN, COLOUR_WHITE,
WID_NG_MAPSIZE, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION_TOOLTIP));
99 this->
Add(std::make_unique<NWidgetLeaf>(
WWT_PUSHTXTBTN, COLOUR_WHITE,
WID_NG_DATE, STR_NETWORK_SERVER_LIST_DATE_CAPTION, STR_NETWORK_SERVER_LIST_DATE_CAPTION_TOOLTIP));
100 this->
Add(std::make_unique<NWidgetLeaf>(
WWT_PUSHTXTBTN, COLOUR_WHITE,
WID_NG_YEARS, STR_NETWORK_SERVER_LIST_PLAY_TIME_CAPTION, STR_NETWORK_SERVER_LIST_PLAY_TIME_CAPTION_TOOLTIP));
102 leaf = std::make_unique<NWidgetLeaf>(
WWT_PUSHTXTBTN, COLOUR_WHITE,
WID_NG_INFO, STR_EMPTY, STR_NETWORK_SERVER_LIST_INFO_ICONS_TOOLTIP);
104 this->
Add(std::move(leaf));
116 for (
const auto &child_wid : this->
children) {
117 child_wid->SetupSmallestSize(w);
118 this->
smallest_y = std::max(this->
smallest_y, child_wid->smallest_y + child_wid->padding.Vertical());
122 for (
const auto &child_wid : this->children) {
123 child_wid->current_x = child_wid->smallest_x;
127 this->
smallest_x = this->children.front()->smallest_x + this->children.back()->smallest_x;
128 this->ApplyAspectRatio();
140 given_width -= this->
children.back()->smallest_x;
143 auto first = std::next(std::begin(this->
children));
144 auto last = std::prev(std::end(this->
children));
145 for (
auto it = first; it != last; ++it) {
146 auto &child_wid = *it;
148 given_width -= child_wid->smallest_x;
149 child_wid->current_x = child_wid->smallest_x;
151 child_wid->current_x = 0;
157 this->
children.front()->current_x = given_width;
161 auto assign_position = [&](
const std::unique_ptr<NWidgetBase> &child_wid) {
162 if (child_wid->current_x != 0) {
163 child_wid->AssignSizePosition(sizing, x + position, y, child_wid->current_x, this->current_y, rtl);
164 position += child_wid->current_x;
169 std::for_each(std::rbegin(this->
children), std::rend(this->
children), assign_position);
171 std::for_each(std::begin(this->
children), std::end(this->
children), assign_position);
182 static const std::initializer_list<GUIGameServerList::SortFunction * const> sorter_funcs;
183 static const std::initializer_list<GUIGameServerList::FilterFunction * const> filter_funcs;
207 this->servers.clear();
209 bool found_current_server =
false;
210 bool found_last_joined =
false;
212 this->servers.push_back(ngl);
213 if (ngl == this->server) {
214 found_current_server =
true;
216 if (ngl == this->last_joined) {
217 found_last_joined =
true;
221 if (!found_last_joined) {
222 this->last_joined =
nullptr;
224 if (!found_current_server) {
225 this->server =
nullptr;
226 this->list_pos = SLP_INVALID;
241 this->vscroll->
SetCount(this->servers.size());
244 this->servers.
Sort();
328 this->list_pos = SLP_INVALID;
329 for (uint i = 0; i != this->servers.size(); i++) {
330 if (this->servers[i] == this->server) {
339 assert(item !=
nullptr);
340 assert((*item) !=
nullptr);
343 sf.
AddLine((*item)->info.server_name);
355 Rect name = this->GetWidget<NWidgetBase>(
WID_NG_NAME)->GetCurrentRect();
356 Rect info = this->GetWidget<NWidgetBase>(
WID_NG_INFO)->GetCurrentRect();
360 Rect r = {std::min(name.left, info.left), y, std::max(name.right, info.right), y + (int)this->
resize.
step_height - 1};
374 Rect clients = nwid->GetCurrentRect();
379 DrawString(clients.left, clients.right, y + text_y_offset, STR_NETWORK_SERVER_LIST_GENERAL_ONLINE, TC_FROMSTRING,
SA_HOR_CENTER);
384 Rect mapsize = nwid->GetCurrentRect();
387 DrawString(mapsize.left, mapsize.right, y + text_y_offset, STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT, TC_FROMSTRING,
SA_HOR_CENTER);
392 Rect date = nwid->GetCurrentRect();
400 Rect years = nwid->GetCurrentRect();
404 DrawString(years.left, years.right, y + text_y_offset, STR_NETWORK_SERVER_LIST_PLAY_TIME_SHORT, TC_BLACK,
SA_HOR_CENTER);
418 DrawSpriteIgnorePadding(SPR_BLOT, pal, info.
WithWidth(this->blot.width, !rtl),
SA_CENTER);
431 if (this->list_pos == SLP_INVALID)
return;
438 this->list_pos = SLP_INVALID;
439 this->server =
nullptr;
456 #ifdef __EMSCRIPTEN__
457 EM_ASM(
if (window[
"openttd_server_list"]) openttd_server_list());
464 this->servers.
SetSortFuncs(NetworkGameWindow::sorter_funcs);
471 this->last_sorting = this->servers.
GetListing();
485 fill.height =
resize.height;
486 size.height = 12 *
resize.height;
494 size.width = NWidgetScrollbar::GetVerticalDimension().width;
526 size.height = std::max(this->lock.height, this->blot.height) + padding.height;
531 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
538 for (
auto it = first; it != last; ++it) {
541 y += this->resize.step_height;
548 if (this->last_joined !=
nullptr) this->
DrawServerLine(this->last_joined, r.top, this->last_joined == this->server);
552 this->DrawDetails(r);
588 bool changed =
false;
596 #ifdef __EMSCRIPTEN__
608 if (this->server ==
nullptr)
return STR_NETWORK_SERVER_LIST_GAME_INFO;
609 switch (this->server->
status) {
610 case NGLS_OFFLINE:
return STR_NETWORK_SERVER_LIST_SERVER_OFFLINE;
611 case NGLS_ONLINE:
return STR_NETWORK_SERVER_LIST_GAME_INFO;
612 case NGLS_FULL:
return STR_NETWORK_SERVER_LIST_SERVER_FULL;
613 case NGLS_BANNED:
return STR_NETWORK_SERVER_LIST_SERVER_BANNED;
614 case NGLS_TOO_OLD:
return STR_NETWORK_SERVER_LIST_SERVER_TOO_OLD;
615 default: NOT_REACHED();
619 void DrawDetails(
const Rect &r)
const
624 StringID header_msg = this->GetHeaderString();
631 tr.top += header_height;
637 if (sel ==
nullptr)
return;
660 StringID invite_or_address = sel->
connection_string.starts_with(
"+") ? STR_NETWORK_SERVER_LIST_INVITE_CODE : STR_NETWORK_SERVER_LIST_SERVER_ADDRESS;
693 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
708 if (this->list_pos != SLP_INVALID) this->list_pos = (ServerListPosition)this->servers.size() - this->list_pos - 1;
720 this->server = (it != this->servers.end()) ? *it :
nullptr;
721 this->list_pos = (
server ==
nullptr) ? SLP_INVALID : it - this->servers.begin();
730 if (this->last_joined !=
nullptr) {
746 this->searched_internet =
true;
757 STR_NETWORK_SERVER_LIST_ENTER_SERVER_ADDRESS,
763 ShowNetworkStartServerWindow();
767 if (this->server !=
nullptr) {
791 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
797 EventState OnKeyPress([[maybe_unused]] char32_t key, uint16_t keycode)
override
803 if (this->list_pos == SLP_INVALID)
return ES_HANDLED;
805 this->server = this->servers[this->
list_pos];
815 if (this->server !=
nullptr) {
816 if (keycode == WKC_DELETE) {
818 if (this->server == this->last_joined) this->last_joined =
nullptr;
819 this->server =
nullptr;
820 this->list_pos = SLP_INVALID;
827 void OnEditboxChanged(
WidgetID wid)
override
846 void OnQueryTextFinished(std::optional<std::string> str)
override
848 if (!str.has_value() || str->empty())
return;
852 NetworkRebuildHostList();
862 if (!this->searched_internet)
return;
868 Listing NetworkGameWindow::last_sorting = {
false, 5};
869 const std::initializer_list<GUIGameServerList::SortFunction * const> NetworkGameWindow::sorter_funcs = {
873 &NGameCalendarDateSorter,
874 &NGameTicksPlayingSorter,
878 const std::initializer_list<GUIGameServerList::FilterFunction * const> NetworkGameWindow::filter_funcs = {
882 static std::unique_ptr<NWidgetBase> MakeResizableHeader()
884 return std::make_unique<NWidgetServerListHeader>();
887 static constexpr
NWidgetPart _nested_network_game_widgets[] = {
902 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
917 SetDataTip(0x0, STR_NETWORK_SERVER_LIST_CLICK_TO_SELECT_LAST),
928 SetDataTip(STR_NETWORK_SERVER_LIST_PLAYER_NAME_OSKTITLE, STR_NETWORK_SERVER_LIST_ENTER_NAME_TOOLTIP),
969 _nested_network_game_widgets
972 void ShowNetworkGameWindow()
974 static bool first =
true;
1003 void SetStringParameters(
WidgetID widget)
const override
1025 size.width += padding.width;
1026 size.height += padding.height;
1031 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
1040 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1044 ShowNetworkGameWindow();
1064 default: NOT_REACHED();
1089 if (!CheckServerName())
return;
1099 if (!CheckServerName())
return;
1105 if (!CheckServerName())
return;
1111 if (!CheckServerName())
return;
1118 void OnDropdownSelect(
WidgetID widget,
int index)
override
1131 bool CheckServerName()
1133 std::string str = this->name_editbox.text.
buf;
1145 void OnQueryTextFinished(std::optional<std::string> str)
override
1147 if (!str.has_value())
return;
1152 int32_t value = atoi(str->c_str());
1154 switch (this->widget_id) {
1155 default: NOT_REACHED();
1165 static constexpr
NWidgetPart _nested_network_start_server_window_widgets[] = {
1232 static WindowDesc _network_start_server_window_desc(
1236 _nested_network_start_server_window_widgets
1239 static void ShowNetworkStartServerWindow()
1253 static constexpr
NWidgetPart _nested_client_list_widgets[] = {
1265 NWidget(
WWT_TEXT, COLOUR_GREY,
WID_CL_SERVER_NAME),
SetFill(1, 0),
SetResize(1, 0),
SetDataTip(STR_JUST_RAW_STRING, STR_NETWORK_CLIENT_LIST_SERVER_NAME_TOOLTIP),
SetAlignment(
SA_VERT_CENTER |
SA_RIGHT),
1276 NWidget(
WWT_TEXT, COLOUR_GREY,
WID_CL_SERVER_INVITE_CODE),
SetFill(1, 0),
SetResize(1, 0),
SetDataTip(STR_JUST_RAW_STRING, STR_NETWORK_CLIENT_LIST_SERVER_INVITE_CODE_TOOLTIP),
SetAlignment(
SA_VERT_CENTER |
SA_RIGHT),
1280 NWidget(
WWT_TEXT, COLOUR_GREY,
WID_CL_SERVER_CONNECTION_TYPE),
SetFill(1, 0),
SetResize(1, 0),
SetDataTip(STR_JUST_STRING, STR_NETWORK_CLIENT_LIST_SERVER_CONNECTION_TYPE_TOOLTIP),
SetAlignment(
SA_VERT_CENTER |
SA_RIGHT),
1288 NWidget(
WWT_TEXT, COLOUR_GREY,
WID_CL_CLIENT_NAME),
SetFill(1, 0),
SetResize(1, 0),
SetDataTip(STR_JUST_RAW_STRING, STR_NETWORK_CLIENT_LIST_PLAYER_NAME_TOOLTIP),
SetAlignment(
SA_VERT_CENTER |
SA_RIGHT),
1295 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),
1300 NWidget(
WWT_TEXT, COLOUR_GREY,
WID_CL_CLIENT_COMPANY_COUNT),
SetFill(1, 0),
SetResize(1, 0),
SetPadding(
WidgetDimensions::unscaled.framerect),
SetAlignment(
SA_CENTER),
SetDataTip(STR_NETWORK_CLIENT_LIST_CLIENT_COMPANY_COUNT, STR_NETWORK_CLIENT_LIST_CLIENT_COMPANY_COUNT_TOOLTIP),
1307 WDP_AUTO,
"list_clients", 220, 300,
1310 _nested_client_list_widgets
1318 DD_CLIENT_ADMIN_KICK,
1319 DD_CLIENT_ADMIN_BAN,
1320 DD_COMPANY_ADMIN_RESET,
1390 template<
typename T>
1403 assert(
proc !=
nullptr);
1410 this->
proc(w, pt, this->
id);
1434 std::map<uint, std::vector<std::unique_ptr<ButtonCommon>>>
buttons;
1482 list.push_back(MakeDropDownListStringItem(STR_NETWORK_CLIENT_LIST_ADMIN_CLIENT_KICK, DD_CLIENT_ADMIN_KICK));
1483 list.push_back(MakeDropDownListStringItem(STR_NETWORK_CLIENT_LIST_ADMIN_CLIENT_BAN, DD_CLIENT_ADMIN_BAN));
1486 wi_rect.left = pt.x;
1487 wi_rect.right = pt.x;
1489 wi_rect.bottom = pt.y;
1491 w->dd_client_id = client_id;
1504 list.push_back(MakeDropDownListStringItem(STR_NETWORK_CLIENT_LIST_ADMIN_COMPANY_RESET, DD_COMPANY_ADMIN_RESET,
NetworkCompanyHasClients(company_id)));
1507 wi_rect.left = pt.x;
1508 wi_rect.right = pt.x;
1510 wi_rect.bottom = pt.y;
1512 w->dd_company_id = company_id;
1543 this->buttons[
line_count].emplace_back(chat_button);
1546 this->line_count += 1;
1548 bool has_players =
false;
1550 if (ci->client_playas != company_id)
continue;
1555 if (
_network_own_client_id != ci->client_id && client_playas !=
COMPANY_SPECTATOR && !ci->CanJoinCompany(client_playas)) this->buttons[
line_count].push_back(std::make_unique<ClientButton>(SPR_JOIN, STR_NETWORK_CLIENT_LIST_COMPANY_AUTHORIZE_TOOLTIP, COLOUR_GREEN, ci->client_id, &NetworkClientListWindow::OnClickClientAuthorize));
1563 this->line_count += 1;
1567 chat_button->
disabled = !has_players;
1578 this->buttons.clear();
1579 this->line_count = 0;
1580 this->player_host_index = -1;
1581 this->player_self_index = -1;
1586 this->line_count += 1;
1595 if (c->index == client_playas)
continue;
1603 this->vscroll->
SetCount(this->line_count);
1617 uint x = rtl ? matrix.left : matrix.right;
1620 auto button_find = this->buttons.find(index);
1621 if (button_find == this->buttons.end())
return nullptr;
1624 for (
auto &button : button_find->second) {
1625 uint
left = rtl ? x : x - button->width;
1626 uint right = rtl ? x + button->width : x;
1629 return button.get();
1657 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
1678 size.width = std::min(size.width,
static_cast<uint
>(
ScaleGUITrad(200)));
1683 size.width += padding.width;
1684 size.height += padding.height;
1695 size.height = std::max(size.height, 5 * this->line_height);
1706 void SetStringParameters(
WidgetID widget)
const override
1718 static std::string empty = {};
1741 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1767 if (button ==
nullptr)
break;
1775 bool OnTooltip([[maybe_unused]]
Point pt,
WidgetID widget, TooltipCloseCondition close_cond)
override
1791 uint player_icon_x = rtl ? text_right - offset_x - d2.width : text_left + offset_x;
1793 if (
IsInsideMM(pt.x, player_icon_x, player_icon_x + d2.width)) {
1794 if (index == this->player_self_index) {
1795 GuiShowTooltips(
this, STR_NETWORK_CLIENT_LIST_PLAYER_ICON_SELF_TOOLTIP, close_cond);
1797 }
else if (index == this->player_host_index) {
1798 GuiShowTooltips(
this, STR_NETWORK_CLIENT_LIST_PLAYER_ICON_HOST_TOOLTIP, close_cond);
1804 if (button ==
nullptr)
return false;
1822 void OnDropdownSelect(
WidgetID widget,
int index)
override
1837 case DD_CLIENT_ADMIN_KICK:
1839 text = STR_NETWORK_CLIENT_LIST_ASK_CLIENT_KICK;
1844 case DD_CLIENT_ADMIN_BAN:
1846 text = STR_NETWORK_CLIENT_LIST_ASK_CLIENT_BAN;
1851 case DD_COMPANY_ADMIN_RESET:
1853 text = STR_NETWORK_CLIENT_LIST_ASK_COMPANY_RESET;
1862 assert(text != STR_NULL);
1863 assert(callback !=
nullptr);
1866 ShowQuery(STR_NETWORK_CLIENT_LIST_ASK_CAPTION, text,
this, callback);
1878 void OnQueryTextFinished(std::optional<std::string> str)
override
1880 if (!str.has_value())
return;
1882 switch (this->query_widget) {
1883 default: NOT_REACHED();
1915 for (
auto &button :
buttons) {
1918 int offset = (this->line_height - button->height) / 2;
1919 r.left = rtl ? x : x - button->width + 1;
1920 r.right = rtl ? x + button->width - 1 : x;
1922 r.bottom = r.top + button->height - 1;
1926 if (button->disabled) {
1947 int offset =
CenterBounds(0, this->line_height, d.height);
1950 uint line_end = line_start + this->vscroll->
GetCapacity();
1952 uint y = r.top + (this->line_height * (line - line_start));
1955 if (
IsInsideMM(line, line_start, line_end)) {
1956 int icon_left = r.
WithWidth(d.width, rtl).left;
1958 int &x = rtl ? tr.left : tr.right;
1961 auto button_find = this->buttons.find(line);
1962 if (button_find != this->buttons.end()) {
1967 DrawSprite(SPR_COMPANY_ICON, PALETTE_TO_GREY, icon_left, y + offset);
1968 DrawString(tr.left, tr.right, y + text_y_offset, STR_NETWORK_CLIENT_LIST_SPECTATORS, TC_SILVER);
1970 DrawSprite(SPR_COMPANY_ICON, PALETTE_TO_GREY, icon_left, y + offset);
1971 DrawString(tr.left, tr.right, y + text_y_offset, STR_NETWORK_CLIENT_LIST_NEW_COMPANY, TC_WHITE);
1977 DrawString(tr.left, tr.right, y + text_y_offset, STR_COMPANY_NAME, TC_SILVER);
1985 if (ci->client_playas != company_id)
continue;
1988 if (
IsInsideMM(line, line_start, line_end)) {
1992 auto button_find = this->buttons.find(line);
1993 if (button_find != this->buttons.end()) {
1994 int &x = rtl ? tr.left : tr.right;
2000 player_icon = SPR_PLAYER_SELF;
2002 player_icon = SPR_PLAYER_HOST;
2005 if (player_icon != 0) {
2007 int offset_y =
CenterBounds(0, this->line_height, d2.height);
2008 DrawSprite(player_icon, PALETTE_TO_GREY, rtl ? tr.right - d2.width : tr.left, y + offset_y);
2013 DrawString(tr.left, tr.right, y + text_y_offset, STR_JUST_RAW_STRING, TC_BLACK);
2021 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
2028 if (this->hover_index >= 0) {
2045 if (client_playas == c->index)
continue;
2057 void OnMouseOver([[maybe_unused]]
Point pt,
WidgetID widget)
override
2060 if (this->hover_index != -1) {
2061 this->hover_index = -1;
2066 if (index != this->hover_index) {
2067 this->hover_index = index;
2074 void ShowClientList()
2076 AllocateWindowDescFront<NetworkClientListWindow>(_client_list_desc, 0);
2085 std::shared_ptr<NetworkAuthenticationPasswordRequest> request;
2093 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
2102 case NETWORK_JOIN_STATUS_CONNECTING:
2103 case NETWORK_JOIN_STATUS_AUTHORIZING:
2104 case NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO:
2107 case NETWORK_JOIN_STATUS_WAITING:
2110 case NETWORK_JOIN_STATUS_DOWNLOADING:
2128 case NETWORK_JOIN_STATUS_WAITING:
2132 case NETWORK_JOIN_STATUS_DOWNLOADING:
2149 for (uint i = 0; i < NETWORK_JOIN_STATUS_END; i++) {
2170 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
2175 ShowNetworkGameWindow();
2179 void OnQueryTextFinished(std::optional<std::string> str)
override
2181 if (!str.has_value() || str->empty() || this->request ==
nullptr) {
2186 this->request->Reply(*str);
2190 static constexpr
NWidgetPart _nested_network_join_status_window_widgets[] = {
2201 static WindowDesc _network_join_status_window_desc(
2205 _nested_network_join_status_window_widgets
2208 void ShowJoinStatusWindow()
2214 void ShowNetworkNeedPassword(std::shared_ptr<NetworkAuthenticationPasswordRequest> request)
2217 if (w ==
nullptr)
return;
2218 w->request = request;
2254 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
2261 void FindWindowPlacementAndResize([[maybe_unused]]
int def_width, [[maybe_unused]]
int def_height)
override
2269 void SetStringParameters(
WidgetID widget)
const override
2279 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
2301 static constexpr
NWidgetPart _nested_network_ask_relay_widgets[] = {
2322 _nested_network_ask_relay_widgets
2331 void ShowNetworkAskRelay(
const std::string &server_connection_string,
const std::string &relay_connection_string,
const std::string &token)
2336 new NetworkAskRelayWindow(_network_ask_relay_desc, parent, server_connection_string, relay_connection_string, token);
2357 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
2364 void FindWindowPlacementAndResize([[maybe_unused]]
int def_width, [[maybe_unused]]
int def_height)
override
2372 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
2376 ShowSurveyResultTextfileWindow();
2396 static constexpr
NWidgetPart _nested_network_ask_survey_widgets[] = {
2420 _nested_network_ask_survey_widgets
2429 if constexpr (!NetworkSurveyHandler::IsSurveyPossible())
return;
2443 this->ConstructWindow();
2451 void ShowSurveyResultTextfileWindow()
void ConnectFailure(const std::string &token, uint8_t tracking_number)
Callback from a Connecter to let the Game Coordinator know the connection failed.
void GetListing()
Request a listing of all public servers.
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
void RebuildDone()
Notify the sortlist that the rebuild is done.
void SetListing(Listing l)
Import sort conditions.
void SetFilterState(bool state)
Enable or disable the filter.
bool IsDescSortOrder() const
Check if the sort order is descending.
void ToggleSortOrder()
Toggle the sort order Since that is the worst condition for the sort function reverse the list here.
void SetFilterFuncs(std::span< FilterFunction *const > n_funcs)
Hand the filter function pointers to the GUIList.
bool NeedRebuild() const
Check if a rebuild is needed.
void ForceRebuild()
Force that a rebuild is needed.
bool Sort(Comp compare)
Sort the list.
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
uint8_t SortType() const
Get the sorttype of the list.
Listing GetListing() const
Export current sort conditions.
void SetSortFuncs(std::span< SortFunction *const > n_funcs)
Hand the sort function pointers to the GUIList.
bool NeedResort()
Check if a resort is needed next loop If used the resort timer will decrease every call till 0.
void SetSortType(uint8_t n_type)
Set the sorttype of the list.
void OnPaint() override
The window must be repainted.
static bool NGameClientSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by the amount of clients online on a server.
static bool NGameMapSizeSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by map size.
QueryString filter_editbox
Editbox for filter on servers.
Scrollbar * vscroll
Vertical scrollbar of the list of servers.
NetworkGameList * last_joined
The last joined server.
static bool NGameAllowedSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by joinability.
NetworkGameList * server
Selected server.
void BuildGUINetworkGameList()
Dimension of compatibility icon.
void UpdateListPos()
Set this->list_pos to match this->server.
IntervalTimer< TimerWindow > refresh_interval
Refresh the online servers on a regular interval.
void OnInit() override
Notification that the nested widget tree gets initialized.
static bool NGameNameSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by name.
void DrawServerLine(const NetworkGameList *cur_item, int y, bool highlight) const
Draw a single server line.
static bool NGameCalendarDateSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by calendar date.
void OnResize() override
Called after the window got resized.
void ScrollToSelectedServer()
Scroll the list up or down to the currently selected server.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
ServerListPosition list_pos
Position of the selected server.
static bool NGameTicksPlayingSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by the number of ticks the game is running.
void SortNetworkGameList()
Sort the server list.
Dimension blot
Dimension of lock icon.
GUIGameServerList servers
List with game servers.
bool searched_internet
Did we ever press "Search Internet" button?
QueryString name_editbox
Client name editbox.
@ PREVIEW
User is previewing the survey result.
static constexpr TimerGameTick::Ticks TICKS_PER_SECOND
Estimation of how many ticks fit in a single second.
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
CompanyID _current_company
Company currently doing an action.
@ CCA_DELETE
Delete a company.
@ CCA_NEW
Create a new company.
@ CALCA_ADD
Create a public key.
Owner
Enum for all companies/owners.
@ INVALID_COMPANY
An invalid company.
@ COMPANY_SPECTATOR
The client is spectating.
@ COMPANY_NEW_COMPANY
The client wants a new company.
@ MAX_COMPANIES
Maximum number of companies.
@ CRR_NONE
Dummy reason for actions that don't need one.
@ CRR_MANUAL
The company is manually removed.
static const uint NETWORK_CLIENT_NAME_LENGTH
The maximum length of a client's name, in bytes including '\0'.
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...
static const uint NETWORK_NAME_LENGTH
The maximum length of the server name and map name, in bytes including '\0'.
static const std::string NETWORK_SURVEY_DETAILS_LINK
Link with more details & privacy statement of the survey.
static const uint NETWORK_PASSWORD_LENGTH
The maximum length of the password, in bytes including '\0'.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close, bool persist)
Show a drop down list.
void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, WidgetID button, Rect wi_rect, Colours wi_colour, bool instant_close, bool persist)
Show a drop down list.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
@ FT_SCENARIO
old or new scenario
@ FT_HEIGHTMAP
heightmap file
@ FT_SAVEGAME
old or new savegame
@ SLO_LOAD
File is being loaded.
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
static const uint32_t GENERATE_NEW_SEED
Create a new random seed.
void StartNewGameWithoutGUI(uint32_t seed)
Start a normal game without the GUI.
void ShowGenerateLandscape()
Start with a normal game.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
bool _ctrl_pressed
Is Ctrl pressed?
bool _left_button_clicked
Is left mouse button clicked?
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.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Dimension GetScaledSpriteSize(SpriteID sprid)
Scale sprite size for GUI.
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
@ SA_RIGHT
Right align the text (must be a single bit).
@ SA_HOR_CENTER
Horizontally center the text.
@ SA_CENTER
Center both horizontally and vertically.
@ SA_VERT_CENTER
Vertically center the text.
@ FS_NORMAL
Index of the normal font in the font tables.
uint32_t PaletteID
The number of the palette.
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
static const uint MAX_MAP_SIZE
Maximal map size = 4096.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
void GuiShowTooltips(Window *parent, StringID str, TooltipCloseCondition close_tooltip, uint paramcount)
Shows a tooltip.
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback, bool focus)
Show a confirmation window with standard 'yes' and 'no' buttons The window is aligned to the centre o...
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
bool _is_network_server
Does this client wants to be a network-server?
StringList _network_host_list
The servers we know.
void NetworkQueryServer(const std::string &connection_string)
Query a server to fetch the game-info.
void NetworkDisconnect(bool close_admins)
We want to disconnect from the host/clients.
bool _network_server
network-server is active
ClientID _network_own_client_id
Our client identifier.
bool NetworkClientConnectGame(const std::string &connection_string, CompanyID default_company, const std::string &join_server_password)
Join a client to the server at with the given connection string.
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.
void NetworkUpdateServerGameType()
The setting server_game_type was updated; possibly we need to take some action.
bool NetworkValidateServerName(std::string &server_name)
Trim the given server name in place, i.e.
Basic functions/variables used all over the place.
Base core network types and some helper functions to access them.
void ShowNetworkChatQueryWindow(DestType type, int dest)
Show the chat window.
bool NetworkValidateOurClientName()
Convenience method for NetworkValidateClientName on _settings_client.network.client_name.
bool NetworkMaxCompaniesReached()
Check if max_companies has been reached on the server (local check only).
uint NetworkMaxCompaniesAllowed()
Get the maximum number of companies that are allowed by the server.
std::string _network_server_name
The current name of the server you are on.
void NetworkClientRequestMove(CompanyID company_id)
Notify the server of this client wanting to be moved to another company.
Client part of the network protocol.
Part of the network protocol handling content distribution.
ConnectionType _network_server_connection_type
What type of connection the Game Coordinator detected we are on.
ClientNetworkCoordinatorSocketHandler _network_coordinator_client
The connection to the Game Coordinator.
std::string _network_server_invite_code
Our invite code as indicated by the Game Coordinator.
Part of the network protocol handling Game Coordinator requests.
uint NetworkServerKickOrBanIP(ClientID client_id, bool ban, const std::string &reason)
Ban, or kick, everyone joined from the given client's IP.
void NetworkServerKickClient(ClientID client_id, const std::string &reason)
Kick a single client.
void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
Handle the tid-bits of moving a client from one company to another.
bool NetworkCompanyHasClients(CompanyID company)
Check whether a particular company has clients.
void NetworkGameListRemoveItem(NetworkGameList *remove)
Remove an item from the gamelist linked list.
NetworkGameList * _network_game_list
Game list of this client.
Handling of the list of games.
@ NGLS_ONLINE
Server is online.
@ NGLS_FULL
Server is full and cannot be queried.
@ NGLS_TOO_OLD
Server is too old to query.
@ NGLS_OFFLINE
Server is offline (or cannot be queried).
@ NGLS_BANNED
You are banned from this server.
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.
static void AdminCompanyResetCallback(Window *, bool confirmed)
Callback function for admin command to reset company.
NetworkJoinStatus _network_join_status
The status of joining.
static void AdminClientKickCallback(Window *, bool confirmed)
Callback function for admin command to kick client.
void UpdateNetworkGameWindow()
Update the network new window because a new server is found on the network.
uint8_t _network_join_waiting
The number of clients waiting in front of us.
static void AdminClientBanCallback(Window *, bool confirmed)
Callback function for admin command to ban client.
void DrawCompanyIcon(CompanyID cid, int x, int y)
Draw the icon of a company.
DropDownAdmin
The possibly entries in a DropDown for an admin.
uint32_t _network_join_bytes_total
The total number of bytes to download.
uint32_t _network_join_bytes
The number of bytes we already downloaded.
void ShowNetworkAskSurvey()
Show a modal confirmation window with "no" / "preview" / "yes" buttons.
static CompanyID _admin_company_id
For what company a confirmation window is open.
static ClientID _admin_client_id
For what client a confirmation window is open.
GUIs related to networking.
@ NRWCD_UNHANDLED
Relay request is unhandled.
@ NRWCD_HANDLED
Relay request is handled, either by user or by timeout.
NetworkJoinStatus
Status of the clients during joining.
Server part of the network protocol.
Part of the network protocol handling opt-in survey.
@ DESTTYPE_CLIENT
Send message/notice to only a certain client (Private)
@ DESTTYPE_TEAM
Send message/notice to everyone playing the same company (Team)
static const uint MAX_CLIENTS
How many clients can we have.
ClientID
'Unique' identifier to be given to clients
@ INVALID_CLIENT_ID
Client is not part of anything.
@ CLIENT_ID_SERVER
Servers always have this ID.
ServerGameType
Game type the server can be using.
void NetworkUDPSearchGame()
Find all servers.
Sending and receiving UDP messages.
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
void ShowMissingContentWindow(const GRFConfig *list)
Show the content list window with all missing grfs from the given list.
@ SM_MENU
Switch to game intro menu.
uint8_t GetColourGradient(Colours colour, ColourShade shade)
Get colour gradient palette index.
static const uint8_t PC_GREY
Grey palette colour.
static const uint8_t PC_DARK_BLUE
Dark blue palette colour.
#define GREY_SCALE(level)
Return the colour for a particular greyscale level.
static const SettingDesc * GetSettingFromName(const std::string_view name, const SettingTable &settings)
Given a name of setting, return a setting description from the table.
bool SetSettingValue(const IntSettingDesc *sd, int32_t value, bool force_newgame)
Top function to save the new value of an element of the Settings struct.
ClientSettings _settings_client
The current settings for this game.
int StrNaturalCompare(std::string_view s1, std::string_view s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
@ CS_NUMERAL
Only numeric ones.
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
void SetDParamMaxValue(size_t n, uint64_t max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
TextDirection _current_text_dir
Text direction of the currently selected language.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
void SetDParamMaxDigits(size_t n, uint count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
@ TD_RTL
Text is written right-to-left by default.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
NetworkSettings network
settings related to the network
Dimensions (a width and height) of a rectangle in 2D.
Information about GRF, used in the game and (part of it) in savegames.
Data structure describing how to show the list (what sort direction and criteria).
Window used for asking the user if he is okay using a relay server.
std::string relay_connection_string
The relay server we want to connect to.
std::string token
The token for this connection.
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
std::string server_connection_string
The game server we want to connect to.
Window used for asking if the user wants to participate in the automated survey.
Container for all information known about a client.
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
CompanyID client_playas
As which company is this client playing (CompanyID)
std::string client_name
Name of the client.
std::string public_key
The public key of the client.
Main handle for clientlist.
static void OnClickCompanyJoin([[maybe_unused]] NetworkClientListWindow *w, [[maybe_unused]] Point pt, CompanyID company_id)
Join button on a Company is clicked.
Scrollbar * vscroll
Vertical scrollbar of this window.
static void OnClickCompanyAdmin([[maybe_unused]] NetworkClientListWindow *w, [[maybe_unused]] Point pt, CompanyID company_id)
Admin button on a Company is clicked.
void OnResize() override
Called after the window got resized.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
uint line_count
Amount of lines in the matrix.
std::map< uint, std::vector< std::unique_ptr< ButtonCommon > > > buttons
Per line which buttons are available.
ClientListWidgets query_widget
During a query this tracks what widget caused the query.
CompanyID dd_company_id
During admin dropdown, track which company this was for.
static void OnClickCompanyNew([[maybe_unused]] NetworkClientListWindow *w, [[maybe_unused]] Point pt, CompanyID)
Crete new company button is clicked.
int hover_index
Index of the current line we are hovering over, or -1 if none.
static void OnClickClientChat([[maybe_unused]] NetworkClientListWindow *w, [[maybe_unused]] Point pt, ClientID client_id)
Chat button on a Client is clicked.
void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close) override
A dropdown window associated to this window has been closed.
static void OnClickClientAdmin([[maybe_unused]] NetworkClientListWindow *w, [[maybe_unused]] Point pt, ClientID client_id)
Admin button on a Client is clicked.
uint line_height
Current lineheight of each entry in the matrix.
void OnInit() override
Notification that the nested widget tree gets initialized.
ClientID dd_client_id
During admin dropdown, track which client this was for.
void RebuildListCompany(CompanyID company_id, CompanyID client_playas, bool can_join_company)
Part of RebuildList() to create the information for a single company.
int player_self_index
The line the current player is on.
void DrawCompany(CompanyID company_id, const Rect &r, uint &line) const
Draw a company and its clients on the matrix.
int player_host_index
The line the host is on.
ButtonCommon * GetButtonAtPoint(Point pt)
Get the button at a specific point on the WID_CL_MATRIX.
static void OnClickCompanyChat([[maybe_unused]] NetworkClientListWindow *w, [[maybe_unused]] Point pt, CompanyID company_id)
Chat button on a Company is clicked.
void RebuildList()
Rebuild the list, meaning: calculate the lines needed and what buttons go on which line.
void DrawButtons(int &x, uint y, const std::vector< std::unique_ptr< ButtonCommon >> &buttons) const
Draw the buttons for a single line in the matrix.
bool version_compatible
Can we connect to this server or not? (based on server_revision)
bool compatible
Can we connect to this server or not? (based on server_revision and grf_match.
Structure with information shown in the game list (GUI)
std::string connection_string
Address of the server.
bool refreshing
Whether this server is being queried.
NetworkGameList * next
Next pointer to make a linked game list.
NetworkGameListStatus status
Stats of the server.
NetworkGameInfo info
The game information of this server.
TimerGameCalendar::Date calendar_start
When the game started.
std::string server_revision
The version number the server is using (e.g.: 'r304' or 0.5.0)
bool use_password
Is this server passworded?
uint8_t clients_max
Max clients allowed on server.
uint16_t map_height
Map height.
std::string server_name
Server name.
uint16_t map_width
Map width.
TimerGameTick::TickCounter ticks_playing
Amount of ticks the game has been running unpaused.
GRFConfig * grfconfig
List of NewGRF files used.
uint8_t landscape
The used landscape.
uint8_t companies_max
Max companies allowed on server.
std::string gamescript_name
Name of the gamescript.
TimerGameCalendar::Date calendar_date
Current calendar date.
int gamescript_version
Version of the gamescript.
uint8_t companies_on
How many started companies do we have.
uint8_t clients_on
Current count of clients on server.
uint8_t max_clients
maximum amount of clients
uint8_t max_companies
maximum amount of companies
std::string client_name
name of the player (as client)
ServerGameType server_game_type
Server type: local / public / invite-only.
UseRelayService use_relay_service
Use relay service?
std::string connect_to_ip
default for the "Add server" query
std::string last_joined
Last joined server.
std::string server_name
name of the server
std::string server_password
password for joining this server
ParticipateSurvey participate_survey
Participate in the automated survey.
WidgetID widget_id
The widget that has the pop-up input menu.
QueryString name_editbox
Server name editbox.
void OnTimeout() override
Called when this window's timeout has been reached.
Coordinates of a point in 2D.
static Titem * Get(size_t index)
Returns Titem with given index.
static size_t GetNumItems()
Returns number of valid items in the pool.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Data stored about a string that can be modified in the GUI.
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
static const int ACTION_CLEAR
Clear editbox.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Specification of a rectangle with absolute coordinates of all edges.
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
int Width() const
Get width of Rect.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
uint step_height
Step-size of height resize changes.
bool IsEmpty() const
Check whether any filter words were entered.
void SetFilterTerm(const char *str)
Set the term to filter on.
void ResetState()
Reset the matching state to process a new item.
void AddLine(const char *str)
Pass another text line from the current item to the filter.
bool GetState() const
Get the matching state of the current item.
Window for displaying the textfile of a survey result.
const GRFConfig * grf_config
View the textfile of this GRFConfig.
void Assign(StringID string)
Render a string into the textbuffer.
char *const buf
buffer in which text is saved
Window for displaying a textfile.
void LoadText(std::string_view buf)
Load a text into the textfile viewer.
TextfileType file_type
Type of textfile to view.
High level window description.
Data structure for an opened window.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
void DrawWidgets() const
Paint all widgets of a window.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Window * parent
Parent window.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
uint8_t timeout_timer
Timer value of the WF_TIMEOUT for flags.
void DrawSortButtonState(WidgetID widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
ResizeInfo resize
Resize information.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
virtual void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close)
A dropdown window associated to this window has been closed.
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
int left
x position of left edge of the window
void RaiseWidgetsWhenLowered(Args... widgets)
Raises the widgets and sets widgets dirty that are lowered.
int top
y position of top edge of the window
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
int GetRowFromWidget(int clickpos, WidgetID widget, int padding, int line_height=-1) const
Compute the row of a widget that a user clicked in.
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
WindowFlags flags
Window flags.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
int height
Height of the window (number of pixels down in y direction)
int width
width of the window (number of pixels to the right in x direction)
WindowNumber window_number
Window number within the window class.
@ CONNECTION_TYPE_UNKNOWN
The Game Coordinator hasn't informed us yet what type of connection we have.
void QueryCallbackProc(Window *, bool)
Callback procedure for the ShowQuery method.
@ QSF_ACCEPT_UNCHANGED
return success even when the text didn't change
@ QSF_LEN_IN_CHARS
the length of the string is counted in characters
TextfileType
Additional text files accompanying Tar archives.
@ TFT_SURVEY_RESULT
Survey result (preview)
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Window * GetMainWindow()
Get the main window, i.e.
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-...
@ SBS_DOWN
Sort ascending.
@ WF_TIMEOUT
Window timeout counter.
@ FR_BORDERONLY
Draw border only, no background.
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
@ WDF_MODAL
The window is a modal child of some other window, meaning the parent is 'inactive'.
@ WDP_CENTER
Center the window.
@ WDP_AUTO
Find a place automatically.
@ WN_NETWORK_STATUS_WINDOW_JOIN
Network join status.
@ WN_NETWORK_WINDOW_GAME
Network game window.
@ WN_NETWORK_WINDOW_START
Network start server.
int32_t WindowNumber
Number to differentiate different windows of the same class.
EventState
State of handling an event.
@ ES_HANDLED
The passed event is handled.
@ ES_NOT_HANDLED
The passed event is not handled.
@ WC_NETWORK_ASK_RELAY
Network ask relay window; Window numbers:
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ WC_CLIENT_LIST
Client list; Window numbers:
@ WC_NETWORK_WINDOW
Network window; Window numbers:
@ WC_TEXTFILE
textfile; Window numbers:
@ WC_NETWORK_STATUS_WINDOW
Network status window; Window numbers:
@ WC_NETWORK_ASK_SURVEY
Network ask survey window; Window numbers:
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.