OpenTTD Source  1.11.2
network_gui.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "../stdafx.h"
11 #include "../strings_func.h"
12 #include "../date_func.h"
13 #include "../fios.h"
14 #include "network_client.h"
15 #include "network_gui.h"
16 #include "network_gamelist.h"
17 #include "network.h"
18 #include "network_base.h"
19 #include "network_content.h"
20 #include "../gui.h"
21 #include "network_udp.h"
22 #include "../window_func.h"
23 #include "../gfx_func.h"
24 #include "../widgets/dropdown_func.h"
25 #include "../querystring_gui.h"
26 #include "../sortlist_type.h"
27 #include "../company_func.h"
28 #include "../core/geometry_func.hpp"
29 #include "../genworld.h"
30 #include "../map_type.h"
31 #include "../guitimer_func.h"
32 #include "../zoom_func.h"
33 
34 #include "../widgets/network_widget.h"
35 
36 #include "table/strings.h"
37 #include "../table/sprites.h"
38 
39 #include "../stringfilter_type.h"
40 
41 #include "../safeguards.h"
42 
43 #ifdef __EMSCRIPTEN__
44 # include <emscripten.h>
45 #endif
46 
47 static void ShowNetworkStartServerWindow();
48 static void ShowNetworkLobbyWindow(NetworkGameList *ngl);
49 
54  STR_NETWORK_START_SERVER_UNADVERTISED,
55  STR_NETWORK_START_SERVER_ADVERTISED,
57 };
58 
59 static std::vector<StringID> _language_dropdown;
60 
61 void SortNetworkLanguages()
62 {
63  /* Init the strings */
64  if (_language_dropdown.empty()) {
65  for (int i = 0; i < NETLANG_COUNT; i++) _language_dropdown.emplace_back(STR_NETWORK_LANG_ANY + i);
66  _language_dropdown.emplace_back(INVALID_STRING_ID);
67  }
68 
69  /* Sort the strings (we don't move 'any' and the 'invalid' one) */
70  std::sort(_language_dropdown.begin() + 1, _language_dropdown.end() - 1, StringIDSorter);
71 }
72 
78 {
80 }
81 
83 typedef uint16 ServerListPosition;
84 static const ServerListPosition SLP_INVALID = 0xFFFF;
85 
88  static const uint MINIMUM_NAME_WIDTH_BEFORE_NEW_HEADER = 150;
89  bool visible[6];
90 public:
92  {
93  NWidgetLeaf *leaf = new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_NAME, STR_NETWORK_SERVER_LIST_GAME_NAME, STR_NETWORK_SERVER_LIST_GAME_NAME_TOOLTIP);
94  leaf->SetResize(1, 0);
95  leaf->SetFill(1, 0);
96  this->Add(leaf);
97 
98  this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_CLIENTS, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION_TOOLTIP));
99  this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_MAPSIZE, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION_TOOLTIP));
100  this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_DATE, STR_NETWORK_SERVER_LIST_DATE_CAPTION, STR_NETWORK_SERVER_LIST_DATE_CAPTION_TOOLTIP));
101  this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_YEARS, STR_NETWORK_SERVER_LIST_YEARS_CAPTION, STR_NETWORK_SERVER_LIST_YEARS_CAPTION_TOOLTIP));
102 
103  leaf = new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_INFO, STR_EMPTY, STR_NETWORK_SERVER_LIST_INFO_ICONS_TOOLTIP);
104  leaf->SetMinimalSize(14 + GetSpriteSize(SPR_LOCK).width + GetSpriteSize(SPR_BLOT).width + GetSpriteSize(SPR_FLAGS_BASE).width, 12);
105  leaf->SetFill(0, 1);
106  this->Add(leaf);
107 
108  /* First and last are always visible, the rest is implicitly zeroed */
109  this->visible[0] = true;
110  *lastof(this->visible) = true;
111  }
112 
113  void SetupSmallestSize(Window *w, bool init_array) override
114  {
115  /* Oh yeah, we ought to be findable! */
116  w->nested_array[WID_NG_HEADER] = this;
117 
118  this->smallest_y = 0; // Biggest child.
119  this->fill_x = 1;
120  this->fill_y = 0;
121  this->resize_x = 1; // We only resize in this direction
122  this->resize_y = 0; // We never resize in this direction
123 
124  /* First initialise some variables... */
125  for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
126  child_wid->SetupSmallestSize(w, init_array);
127  this->smallest_y = std::max(this->smallest_y, child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom);
128  }
129 
130  /* ... then in a second pass make sure the 'current' sizes are set. Won't change for most widgets. */
131  for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
132  child_wid->current_x = child_wid->smallest_x;
133  child_wid->current_y = this->smallest_y;
134  }
135 
136  this->smallest_x = this->head->smallest_x + this->tail->smallest_x; // First and last are always shown, rest not
137  }
138 
139  void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
140  {
141  assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
142 
143  this->pos_x = x;
144  this->pos_y = y;
145  this->current_x = given_width;
146  this->current_y = given_height;
147 
148  given_width -= this->tail->smallest_x;
149  NWidgetBase *child_wid = this->head->next;
150  /* The first and last widget are always visible, determine which other should be visible */
151  for (uint i = 1; i < lengthof(this->visible) - 1; i++) {
152  if (given_width > MINIMUM_NAME_WIDTH_BEFORE_NEW_HEADER + child_wid->smallest_x && this->visible[i - 1]) {
153  this->visible[i] = true;
154  given_width -= child_wid->smallest_x;
155  } else {
156  this->visible[i] = false;
157  }
158  child_wid = child_wid->next;
159  }
160 
161  /* All remaining space goes to the first (name) widget */
162  this->head->current_x = given_width;
163 
164  /* Now assign the widgets to their rightful place */
165  uint position = 0; // Place to put next child relative to origin of the container.
166  uint i = rtl ? lengthof(this->visible) - 1 : 0;
167  child_wid = rtl ? this->tail : this->head;
168  while (child_wid != nullptr) {
169  if (this->visible[i]) {
170  child_wid->AssignSizePosition(sizing, x + position, y, child_wid->current_x, this->current_y, rtl);
171  position += child_wid->current_x;
172  }
173 
174  child_wid = rtl ? child_wid->prev : child_wid->next;
175  i += rtl ? -1 : 1;
176  }
177  }
178 
179  void Draw(const Window *w) override
180  {
181  int i = 0;
182  for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
183  if (!this->visible[i++]) continue;
184 
185  child_wid->Draw(w);
186  }
187  }
188 
189  NWidgetCore *GetWidgetFromPos(int x, int y) override
190  {
191  if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return nullptr;
192 
193  int i = 0;
194  for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
195  if (!this->visible[i++]) continue;
196  NWidgetCore *nwid = child_wid->GetWidgetFromPos(x, y);
197  if (nwid != nullptr) return nwid;
198  }
199  return nullptr;
200  }
201 
208  {
209  assert((uint)(widget - WID_NG_NAME) < lengthof(this->visible));
210  return this->visible[widget - WID_NG_NAME];
211  }
212 };
213 
214 class NetworkGameWindow : public Window {
215 protected:
216  /* Runtime saved values */
217  static Listing last_sorting;
218 
219  /* Constants for sorting servers */
220  static GUIGameServerList::SortFunction * const sorter_funcs[];
221  static GUIGameServerList::FilterFunction * const filter_funcs[];
222 
226  ServerListPosition list_pos;
231 
235 
242  {
243  if (!this->servers.NeedRebuild()) return;
244 
245  /* Create temporary array of games to use for listing */
246  this->servers.clear();
247 
248  for (NetworkGameList *ngl = _network_game_list; ngl != nullptr; ngl = ngl->next) {
249  this->servers.push_back(ngl);
250  }
251 
252  /* Apply the filter condition immediately, if a search string has been provided. */
253  StringFilter sf;
254  sf.SetFilterTerm(this->filter_editbox.text.buf);
255 
256  if (!sf.IsEmpty()) {
257  this->servers.SetFilterState(true);
258  this->servers.Filter(sf);
259  } else {
260  this->servers.SetFilterState(false);
261  }
262 
263  this->servers.shrink_to_fit();
264  this->servers.RebuildDone();
265  this->vscroll->SetCount((int)this->servers.size());
266 
267  /* Sort the list of network games as requested. */
268  this->servers.Sort();
269  this->UpdateListPos();
270  }
271 
273  static bool NGameNameSorter(NetworkGameList * const &a, NetworkGameList * const &b)
274  {
275  int r = strnatcmp(a->info.server_name, b->info.server_name, true); // Sort by name (natural sorting).
276  return r == 0 ? a->address.CompareTo(b->address) < 0: r < 0;
277  }
278 
284  static bool NGameClientSorter(NetworkGameList * const &a, NetworkGameList * const &b)
285  {
286  /* Reverse as per default we are interested in most-clients first */
287  int r = a->info.clients_on - b->info.clients_on;
288 
289  if (r == 0) r = a->info.clients_max - b->info.clients_max;
290  if (r == 0) return NGameNameSorter(a, b);
291 
292  return r < 0;
293  }
294 
296  static bool NGameMapSizeSorter(NetworkGameList * const &a, NetworkGameList * const &b)
297  {
298  /* Sort by the area of the map. */
299  int r = (a->info.map_height) * (a->info.map_width) - (b->info.map_height) * (b->info.map_width);
300 
301  if (r == 0) r = a->info.map_width - b->info.map_width;
302  return (r != 0) ? r < 0 : NGameClientSorter(a, b);
303  }
304 
306  static bool NGameDateSorter(NetworkGameList * const &a, NetworkGameList * const &b)
307  {
308  int r = a->info.game_date - b->info.game_date;
309  return (r != 0) ? r < 0 : NGameClientSorter(a, b);
310  }
311 
313  static bool NGameYearsSorter(NetworkGameList * const &a, NetworkGameList * const &b)
314  {
315  int r = a->info.game_date - a->info.start_date - b->info.game_date + b->info.start_date;
316  return (r != 0) ? r < 0: NGameDateSorter(a, b);
317  }
318 
323  static bool NGameAllowedSorter(NetworkGameList * const &a, NetworkGameList * const &b)
324  {
325  /* The servers we do not know anything about (the ones that did not reply) should be at the bottom) */
327 
328  /* Reverse default as we are interested in version-compatible clients first */
329  if (r == 0) r = b->info.version_compatible - a->info.version_compatible;
330  /* The version-compatible ones are then sorted with NewGRF compatible first, incompatible last */
331  if (r == 0) r = b->info.compatible - a->info.compatible;
332  /* Passworded servers should be below unpassworded servers */
333  if (r == 0) r = a->info.use_password - b->info.use_password;
334 
335  /* Finally sort on the number of clients of the server in reverse order. */
336  return (r != 0) ? r < 0 : NGameClientSorter(b, a);
337  }
338 
341  {
342  if (this->servers.Sort()) this->UpdateListPos();
343  }
344 
347  {
348  this->list_pos = SLP_INVALID;
349  for (uint i = 0; i != this->servers.size(); i++) {
350  if (this->servers[i] == this->server) {
351  this->list_pos = i;
352  break;
353  }
354  }
355  }
356 
357  static bool CDECL NGameSearchFilter(NetworkGameList * const *item, StringFilter &sf)
358  {
359  assert(item != nullptr);
360  assert((*item) != nullptr);
361 
362  sf.ResetState();
363  sf.AddLine((*item)->info.server_name);
364  return sf.GetState();
365  }
366 
373  void DrawServerLine(const NetworkGameList *cur_item, uint y, bool highlight) const
374  {
375  const NWidgetBase *nwi_name = this->GetWidget<NWidgetBase>(WID_NG_NAME);
376  const NWidgetBase *nwi_info = this->GetWidget<NWidgetBase>(WID_NG_INFO);
377 
378  /* show highlighted item with a different colour */
379  if (highlight) GfxFillRect(nwi_name->pos_x + 1, y + 1, nwi_info->pos_x + nwi_info->current_x - 2, y + this->resize.step_height - 2, PC_GREY);
380 
381  /* offsets to vertically centre text and icons */
382  int text_y_offset = (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2 + 1;
383  int icon_y_offset = (this->resize.step_height - GetSpriteSize(SPR_BLOT).height) / 2;
384  int lock_y_offset = (this->resize.step_height - GetSpriteSize(SPR_LOCK).height) / 2;
385 
386  DrawString(nwi_name->pos_x + WD_FRAMERECT_LEFT, nwi_name->pos_x + nwi_name->current_x - WD_FRAMERECT_RIGHT, y + text_y_offset, cur_item->info.server_name, TC_BLACK);
387 
388  /* only draw details if the server is online */
389  if (cur_item->online) {
390  const NWidgetServerListHeader *nwi_header = this->GetWidget<NWidgetServerListHeader>(WID_NG_HEADER);
391 
392  if (nwi_header->IsWidgetVisible(WID_NG_CLIENTS)) {
393  const NWidgetBase *nwi_clients = this->GetWidget<NWidgetBase>(WID_NG_CLIENTS);
394  SetDParam(0, cur_item->info.clients_on);
395  SetDParam(1, cur_item->info.clients_max);
396  SetDParam(2, cur_item->info.companies_on);
397  SetDParam(3, cur_item->info.companies_max);
398  DrawString(nwi_clients->pos_x, nwi_clients->pos_x + nwi_clients->current_x - 1, y + text_y_offset, STR_NETWORK_SERVER_LIST_GENERAL_ONLINE, TC_FROMSTRING, SA_HOR_CENTER);
399  }
400 
401  if (nwi_header->IsWidgetVisible(WID_NG_MAPSIZE)) {
402  /* map size */
403  const NWidgetBase *nwi_mapsize = this->GetWidget<NWidgetBase>(WID_NG_MAPSIZE);
404  SetDParam(0, cur_item->info.map_width);
405  SetDParam(1, cur_item->info.map_height);
406  DrawString(nwi_mapsize->pos_x, nwi_mapsize->pos_x + nwi_mapsize->current_x - 1, y + text_y_offset, STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT, TC_FROMSTRING, SA_HOR_CENTER);
407  }
408 
409  if (nwi_header->IsWidgetVisible(WID_NG_DATE)) {
410  /* current date */
411  const NWidgetBase *nwi_date = this->GetWidget<NWidgetBase>(WID_NG_DATE);
412  YearMonthDay ymd;
413  ConvertDateToYMD(cur_item->info.game_date, &ymd);
414  SetDParam(0, ymd.year);
415  DrawString(nwi_date->pos_x, nwi_date->pos_x + nwi_date->current_x - 1, y + text_y_offset, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER);
416  }
417 
418  if (nwi_header->IsWidgetVisible(WID_NG_YEARS)) {
419  /* number of years the game is running */
420  const NWidgetBase *nwi_years = this->GetWidget<NWidgetBase>(WID_NG_YEARS);
421  YearMonthDay ymd_cur, ymd_start;
422  ConvertDateToYMD(cur_item->info.game_date, &ymd_cur);
423  ConvertDateToYMD(cur_item->info.start_date, &ymd_start);
424  SetDParam(0, ymd_cur.year - ymd_start.year);
425  DrawString(nwi_years->pos_x, nwi_years->pos_x + nwi_years->current_x - 1, y + text_y_offset, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER);
426  }
427 
428  /* draw a lock if the server is password protected */
429  if (cur_item->info.use_password) DrawSprite(SPR_LOCK, PAL_NONE, nwi_info->pos_x + this->lock_offset, y + lock_y_offset);
430 
431  /* draw red or green icon, depending on compatibility with server */
432  DrawSprite(SPR_BLOT, (cur_item->info.compatible ? PALETTE_TO_GREEN : (cur_item->info.version_compatible ? PALETTE_TO_YELLOW : PALETTE_TO_RED)), nwi_info->pos_x + this->blot_offset, y + icon_y_offset + 1);
433 
434  /* draw flag according to server language */
435  DrawSprite(SPR_FLAGS_BASE + cur_item->info.server_lang, PAL_NONE, nwi_info->pos_x + this->flag_offset, y + (this->resize.step_height - GetSpriteSize(SPR_FLAGS_BASE + cur_item->info.server_lang).height) / 2);
436  }
437  }
438 
447  {
448  if (this->list_pos == SLP_INVALID) return; // no server selected
449  this->vscroll->ScrollTowards(this->list_pos);
450  }
451 
452 public:
454  {
455  this->list_pos = SLP_INVALID;
456  this->server = nullptr;
457 
458  this->lock_offset = 5;
459  this->blot_offset = this->lock_offset + 3 + GetSpriteSize(SPR_LOCK).width;
460  this->flag_offset = this->blot_offset + 2 + GetSpriteSize(SPR_BLOT).width;
461 
462  this->CreateNestedTree();
463  this->vscroll = this->GetScrollbar(WID_NG_SCROLLBAR);
465 
466  this->querystrings[WID_NG_CLIENT] = &this->name_editbox;
467  this->name_editbox.text.Assign(_settings_client.network.client_name);
468 
469  this->querystrings[WID_NG_FILTER] = &this->filter_editbox;
470  this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;
472 
473  /* As the master-server doesn't support "websocket" servers yet, we
474  * let "os/emscripten/pre.js" hardcode a list of servers people can
475  * join. This means the serverlist is curated for now, but it is the
476  * best we can offer. */
477 #ifdef __EMSCRIPTEN__
478  EM_ASM(if (window["openttd_server_list"]) openttd_server_list());
479 #endif
480 
482  this->server = this->last_joined;
483  if (this->last_joined != nullptr) NetworkUDPQueryServer(this->last_joined->address);
484 
485  this->requery_timer.SetInterval(MILLISECONDS_PER_TICK);
486 
487  this->servers.SetListing(this->last_sorting);
488  this->servers.SetSortFuncs(this->sorter_funcs);
489  this->servers.SetFilterFuncs(this->filter_funcs);
490  this->servers.ForceRebuild();
491  }
492 
494  {
495  this->last_sorting = this->servers.GetListing();
496  }
497 
498  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
499  {
500  switch (widget) {
501  case WID_NG_MATRIX:
502  resize->height = WD_MATRIX_TOP + std::max(GetSpriteSize(SPR_BLOT).height, (uint)FONT_HEIGHT_NORMAL) + WD_MATRIX_BOTTOM;
503  fill->height = resize->height;
504  size->height = 12 * resize->height;
505  break;
506 
507  case WID_NG_LASTJOINED:
508  size->height = WD_MATRIX_TOP + std::max(GetSpriteSize(SPR_BLOT).height, (uint)FONT_HEIGHT_NORMAL) + WD_MATRIX_BOTTOM;
509  break;
510 
512  size->width = NWidgetScrollbar::GetVerticalDimension().width;
513  break;
514 
515  case WID_NG_NAME:
516  size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow
517  break;
518 
519  case WID_NG_CLIENTS:
520  size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow
525  *size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_GENERAL_ONLINE));
526  break;
527 
528  case WID_NG_MAPSIZE:
529  size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow
532  *size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT));
533  break;
534 
535  case WID_NG_DATE:
536  case WID_NG_YEARS:
537  size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow
538  SetDParamMaxValue(0, 5);
539  *size = maxdim(*size, GetStringBoundingBox(STR_JUST_INT));
540  break;
541  }
542  }
543 
544  void DrawWidget(const Rect &r, int widget) const override
545  {
546  switch (widget) {
547  case WID_NG_MATRIX: {
548  uint16 y = r.top;
549 
550  const int max = std::min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (int)this->servers.size());
551 
552  for (int i = this->vscroll->GetPosition(); i < max; ++i) {
553  const NetworkGameList *ngl = this->servers[i];
554  this->DrawServerLine(ngl, y, ngl == this->server);
555  y += this->resize.step_height;
556  }
557  break;
558  }
559 
560  case WID_NG_LASTJOINED:
561  /* Draw the last joined server, if any */
562  if (this->last_joined != nullptr) this->DrawServerLine(this->last_joined, r.top, this->last_joined == this->server);
563  break;
564 
565  case WID_NG_DETAILS:
566  this->DrawDetails(r);
567  break;
568 
569  case WID_NG_NAME:
570  case WID_NG_CLIENTS:
571  case WID_NG_MAPSIZE:
572  case WID_NG_DATE:
573  case WID_NG_YEARS:
574  case WID_NG_INFO:
575  if (widget - WID_NG_NAME == this->servers.SortType()) this->DrawSortButtonState(widget, this->servers.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
576  break;
577  }
578  }
579 
580 
581  void OnPaint() override
582  {
583  if (this->servers.NeedRebuild()) {
584  this->BuildGUINetworkGameList();
585  }
586  if (this->servers.NeedResort()) {
587  this->SortNetworkGameList();
588  }
589 
590  NetworkGameList *sel = this->server;
591  /* 'Refresh' button invisible if no server selected */
592  this->SetWidgetDisabledState(WID_NG_REFRESH, sel == nullptr);
593  /* 'Join' button disabling conditions */
594  this->SetWidgetDisabledState(WID_NG_JOIN, sel == nullptr || // no Selected Server
595  !sel->online || // Server offline
596  sel->info.clients_on >= sel->info.clients_max || // Server full
597  !sel->info.compatible); // Revision mismatch
598 
599  /* 'NewGRF Settings' button invisible if no NewGRF is used */
600  this->GetWidget<NWidgetStacked>(WID_NG_NEWGRF_SEL)->SetDisplayedPlane(sel == nullptr || !sel->online || sel->info.grfconfig == nullptr);
601  this->GetWidget<NWidgetStacked>(WID_NG_NEWGRF_MISSING_SEL)->SetDisplayedPlane(sel == nullptr || !sel->online || sel->info.grfconfig == nullptr || !sel->info.version_compatible || sel->info.compatible);
602 
603 #ifdef __EMSCRIPTEN__
606  this->SetWidgetDisabledState(WID_NG_ADD, true);
608 #endif
609 
610  this->DrawWidgets();
611  }
612 
613  void DrawDetails(const Rect &r) const
614  {
615  NetworkGameList *sel = this->server;
616 
617  const int detail_height = 6 + 8 + 6 + 3 * FONT_HEIGHT_NORMAL;
618 
619  /* Draw the right menu */
620  GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.top + detail_height - 1, PC_DARK_BLUE);
621  if (sel == nullptr) {
622  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + 6 + 4 + FONT_HEIGHT_NORMAL, STR_NETWORK_SERVER_LIST_GAME_INFO, TC_FROMSTRING, SA_HOR_CENTER);
623  } else if (!sel->online) {
624  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + 6 + 4 + FONT_HEIGHT_NORMAL, sel->info.server_name, TC_ORANGE, SA_HOR_CENTER); // game name
625 
626  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + detail_height + 4, STR_NETWORK_SERVER_LIST_SERVER_OFFLINE, TC_FROMSTRING, SA_HOR_CENTER); // server offline
627  } else { // show game info
628 
629  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + 6, STR_NETWORK_SERVER_LIST_GAME_INFO, TC_FROMSTRING, SA_HOR_CENTER);
630  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + 6 + 4 + FONT_HEIGHT_NORMAL, sel->info.server_name, TC_ORANGE, SA_HOR_CENTER); // game name
631  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + 6 + 8 + 2 * FONT_HEIGHT_NORMAL, sel->info.map_name, TC_BLACK, SA_HOR_CENTER); // map name
632 
633  uint16 y = r.top + detail_height + 4;
634 
635  SetDParam(0, sel->info.clients_on);
636  SetDParam(1, sel->info.clients_max);
637  SetDParam(2, sel->info.companies_on);
638  SetDParam(3, sel->info.companies_max);
639  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_CLIENTS);
640  y += FONT_HEIGHT_NORMAL;
641 
642  SetDParam(0, STR_NETWORK_LANG_ANY + sel->info.server_lang);
643  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_LANGUAGE); // server language
644  y += FONT_HEIGHT_NORMAL;
645 
646  SetDParam(0, STR_CHEAT_SWITCH_CLIMATE_TEMPERATE_LANDSCAPE + sel->info.map_set);
647  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_LANDSCAPE); // landscape
648  y += FONT_HEIGHT_NORMAL;
649 
650  SetDParam(0, sel->info.map_width);
651  SetDParam(1, sel->info.map_height);
652  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_MAP_SIZE); // map size
653  y += FONT_HEIGHT_NORMAL;
654 
656  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_SERVER_VERSION); // server version
657  y += FONT_HEIGHT_NORMAL;
658 
659  char network_addr_buffer[NETWORK_HOSTNAME_LENGTH + 6 + 7];
660  sel->address.GetAddressAsString(network_addr_buffer, lastof(network_addr_buffer));
661  SetDParamStr(0, network_addr_buffer);
662  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_SERVER_ADDRESS); // server address
663  y += FONT_HEIGHT_NORMAL;
664 
665  SetDParam(0, sel->info.start_date);
666  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_START_DATE); // start date
667  y += FONT_HEIGHT_NORMAL;
668 
669  SetDParam(0, sel->info.game_date);
670  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_CURRENT_DATE); // current date
671  y += FONT_HEIGHT_NORMAL;
672 
673  y += WD_PAR_VSEP_NORMAL;
674 
675  if (!sel->info.compatible) {
676  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, sel->info.version_compatible ? STR_NETWORK_SERVER_LIST_GRF_MISMATCH : STR_NETWORK_SERVER_LIST_VERSION_MISMATCH, TC_FROMSTRING, SA_HOR_CENTER); // server mismatch
677  } else if (sel->info.clients_on == sel->info.clients_max) {
678  /* Show: server full, when clients_on == max_clients */
679  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_SERVER_FULL, TC_FROMSTRING, SA_HOR_CENTER); // server full
680  } else if (sel->info.use_password) {
681  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_PASSWORD, TC_FROMSTRING, SA_HOR_CENTER); // password warning
682  }
683  }
684  }
685 
686  void OnClick(Point pt, int widget, int click_count) override
687  {
688  switch (widget) {
689  case WID_NG_CANCEL: // Cancel button
691  break;
692 
693  case WID_NG_NAME: // Sort by name
694  case WID_NG_CLIENTS: // Sort by connected clients
695  case WID_NG_MAPSIZE: // Sort by map size
696  case WID_NG_DATE: // Sort by date
697  case WID_NG_YEARS: // Sort by years
698  case WID_NG_INFO: // Connectivity (green dot)
699  if (this->servers.SortType() == widget - WID_NG_NAME) {
700  this->servers.ToggleSortOrder();
701  if (this->list_pos != SLP_INVALID) this->list_pos = (ServerListPosition)this->servers.size() - this->list_pos - 1;
702  } else {
703  this->servers.SetSortType(widget - WID_NG_NAME);
704  this->servers.ForceResort();
705  this->SortNetworkGameList();
706  }
707  this->ScrollToSelectedServer();
708  this->SetDirty();
709  break;
710 
711  case WID_NG_MATRIX: { // Show available network games
712  uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NG_MATRIX);
713  this->server = (id_v < this->servers.size()) ? this->servers[id_v] : nullptr;
714  this->list_pos = (server == nullptr) ? SLP_INVALID : id_v;
715  this->SetDirty();
716 
717  /* FIXME the disabling should go into some InvalidateData, which is called instead of the SetDirty */
718  if (click_count > 1 && !this->IsWidgetDisabled(WID_NG_JOIN)) this->OnClick(pt, WID_NG_JOIN, 1);
719  break;
720  }
721 
722  case WID_NG_LASTJOINED: {
723  if (this->last_joined != nullptr) {
724  this->server = this->last_joined;
725 
726  /* search the position of the newly selected server */
727  this->UpdateListPos();
728  this->ScrollToSelectedServer();
729  this->SetDirty();
730 
731  /* FIXME the disabling should go into some InvalidateData, which is called instead of the SetDirty */
732  if (click_count > 1 && !this->IsWidgetDisabled(WID_NG_JOIN)) this->OnClick(pt, WID_NG_JOIN, 1);
733  }
734  break;
735  }
736 
739  break;
740 
741  case WID_NG_SEARCH_LAN:
743  break;
744 
745  case WID_NG_ADD: // Add a server
748  STR_JUST_RAW_STRING,
749  STR_NETWORK_SERVER_LIST_ENTER_IP,
750  NETWORK_HOSTNAME_LENGTH, // maximum number of characters including '\0'
752  break;
753 
754  case WID_NG_START: // Start server
755  ShowNetworkStartServerWindow();
756  break;
757 
758  case WID_NG_JOIN: // Join Game
759  if (this->server != nullptr) {
760  seprintf(_settings_client.network.last_host, lastof(_settings_client.network.last_host), "%s", this->server->address.GetHostname());
762  ShowNetworkLobbyWindow(this->server);
763  }
764  break;
765 
766  case WID_NG_REFRESH: // Refresh
767  if (this->server != nullptr) NetworkUDPQueryServer(this->server->address);
768  break;
769 
770  case WID_NG_NEWGRF: // NewGRF Settings
771  if (this->server != nullptr) ShowNewGRFSettings(false, false, false, &this->server->info.grfconfig);
772  break;
773 
774  case WID_NG_NEWGRF_MISSING: // Find missing content online
775  if (this->server != nullptr) ShowMissingContentWindow(this->server->info.grfconfig);
776  break;
777  }
778  }
779 
785  void OnInvalidateData(int data = 0, bool gui_scope = true) override
786  {
787  this->servers.ForceRebuild();
788  this->SetDirty();
789  }
790 
791  EventState OnKeyPress(WChar key, uint16 keycode) override
792  {
793  EventState state = ES_NOT_HANDLED;
794 
795  /* handle up, down, pageup, pagedown, home and end */
796  if (keycode == WKC_UP || keycode == WKC_DOWN || keycode == WKC_PAGEUP || keycode == WKC_PAGEDOWN || keycode == WKC_HOME || keycode == WKC_END) {
797  if (this->servers.size() == 0) return ES_HANDLED;
798  switch (keycode) {
799  case WKC_UP:
800  /* scroll up by one */
801  if (this->list_pos == SLP_INVALID) return ES_HANDLED;
802  if (this->list_pos > 0) this->list_pos--;
803  break;
804  case WKC_DOWN:
805  /* scroll down by one */
806  if (this->list_pos == SLP_INVALID) return ES_HANDLED;
807  if (this->list_pos < this->servers.size() - 1) this->list_pos++;
808  break;
809  case WKC_PAGEUP:
810  /* scroll up a page */
811  if (this->list_pos == SLP_INVALID) return ES_HANDLED;
812  this->list_pos = (this->list_pos < this->vscroll->GetCapacity()) ? 0 : this->list_pos - this->vscroll->GetCapacity();
813  break;
814  case WKC_PAGEDOWN:
815  /* scroll down a page */
816  if (this->list_pos == SLP_INVALID) return ES_HANDLED;
817  this->list_pos = std::min(this->list_pos + this->vscroll->GetCapacity(), (int)this->servers.size() - 1);
818  break;
819  case WKC_HOME:
820  /* jump to beginning */
821  this->list_pos = 0;
822  break;
823  case WKC_END:
824  /* jump to end */
825  this->list_pos = (ServerListPosition)this->servers.size() - 1;
826  break;
827  default: NOT_REACHED();
828  }
829 
830  this->server = this->servers[this->list_pos];
831 
832  /* Scroll to the new server if it is outside the current range. */
833  this->ScrollToSelectedServer();
834 
835  /* redraw window */
836  this->SetDirty();
837  return ES_HANDLED;
838  }
839 
840  if (this->server != nullptr) {
841  if (keycode == WKC_DELETE) { // Press 'delete' to remove servers
842  NetworkGameListRemoveItem(this->server);
843  if (this->server == this->last_joined) this->last_joined = nullptr;
844  this->server = nullptr;
845  this->list_pos = SLP_INVALID;
846  }
847  }
848 
849  return state;
850  }
851 
852  void OnEditboxChanged(int wid) override
853  {
854  switch (wid) {
855  case WID_NG_FILTER: {
856  this->servers.ForceRebuild();
857  this->BuildGUINetworkGameList();
858  this->ScrollToSelectedServer();
859  this->SetDirty();
860  break;
861  }
862 
863  case WID_NG_CLIENT:
864  /* Make sure the name does not start with a space, so TAB completion works */
865  if (!StrEmpty(this->name_editbox.text.buf) && this->name_editbox.text.buf[0] != ' ') {
867  } else {
869  }
870  break;
871  }
872  }
873 
874  void OnQueryTextFinished(char *str) override
875  {
876  if (!StrEmpty(str)) NetworkAddServer(str);
877  }
878 
879  void OnResize() override
880  {
881  this->vscroll->SetCapacityFromWidget(this, WID_NG_MATRIX);
882  }
883 
884  void OnRealtimeTick(uint delta_ms) override
885  {
886  if (!this->requery_timer.Elapsed(delta_ms)) return;
887  this->requery_timer.SetInterval(MILLISECONDS_PER_TICK);
888 
890  }
891 };
892 
893 Listing NetworkGameWindow::last_sorting = {false, 5};
894 GUIGameServerList::SortFunction * const NetworkGameWindow::sorter_funcs[] = {
895  &NGameNameSorter,
896  &NGameClientSorter,
897  &NGameMapSizeSorter,
898  &NGameDateSorter,
899  &NGameYearsSorter,
900  &NGameAllowedSorter
901 };
902 
903 GUIGameServerList::FilterFunction * const NetworkGameWindow::filter_funcs[] = {
904  &NGameSearchFilter
905 };
906 
907 static NWidgetBase *MakeResizableHeader(int *biggest_index)
908 {
909  *biggest_index = std::max<int>(*biggest_index, WID_NG_INFO);
910  return new NWidgetServerListHeader();
911 }
912 
913 static const NWidgetPart _nested_network_game_widgets[] = {
914  /* TOP */
916  NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE),
917  NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_NETWORK_SERVER_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
918  NWidget(WWT_DEFSIZEBOX, COLOUR_LIGHT_BLUE),
919  EndContainer(),
920  NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NG_MAIN),
921  NWidget(NWID_VERTICAL), SetPIP(10, 7, 0),
922  NWidget(NWID_HORIZONTAL), SetPIP(10, 7, 10),
923  /* LEFT SIDE */
924  NWidget(NWID_VERTICAL), SetPIP(0, 7, 0),
925  NWidget(NWID_HORIZONTAL), SetPIP(0, 7, 0),
926  NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NG_FILTER_LABEL), SetDataTip(STR_LIST_FILTER_TITLE, STR_NULL),
927  NWidget(WWT_EDITBOX, COLOUR_LIGHT_BLUE, WID_NG_FILTER), SetMinimalSize(251, 12), SetFill(1, 0), SetResize(1, 0),
928  SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
929  EndContainer(),
932  NWidgetFunction(MakeResizableHeader),
933  NWidget(WWT_MATRIX, COLOUR_LIGHT_BLUE, WID_NG_MATRIX), SetResize(1, 1), SetFill(1, 0),
934  SetMatrixDataTip(1, 0, STR_NETWORK_SERVER_LIST_CLICK_GAME_TO_SELECT), SetScrollbar(WID_NG_SCROLLBAR),
935  EndContainer(),
936  NWidget(NWID_VSCROLLBAR, COLOUR_LIGHT_BLUE, WID_NG_SCROLLBAR),
937  EndContainer(),
939  NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NG_LASTJOINED_LABEL), SetFill(1, 0),
940  SetDataTip(STR_NETWORK_SERVER_LIST_LAST_JOINED_SERVER, STR_NULL), SetResize(1, 0),
942  NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NG_LASTJOINED), SetFill(1, 0), SetResize(1, 0),
943  SetDataTip(0x0, STR_NETWORK_SERVER_LIST_CLICK_TO_SELECT_LAST),
944  EndContainer(),
945  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_NG_LASTJOINED_SPACER), SetFill(0, 0),
946  EndContainer(),
947  EndContainer(),
948  EndContainer(),
949  /* RIGHT SIDE */
950  NWidget(NWID_VERTICAL), SetPIP(0, 7, 0),
951  NWidget(NWID_HORIZONTAL), SetPIP(0, 7, 0),
952  NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NG_CLIENT_LABEL), SetDataTip(STR_NETWORK_SERVER_LIST_PLAYER_NAME, STR_NULL),
953  NWidget(WWT_EDITBOX, COLOUR_LIGHT_BLUE, WID_NG_CLIENT), SetMinimalSize(151, 12), SetFill(1, 0), SetResize(1, 0),
954  SetDataTip(STR_NETWORK_SERVER_LIST_PLAYER_NAME_OSKTITLE, STR_NETWORK_SERVER_LIST_ENTER_NAME_TOOLTIP),
955  EndContainer(),
956  NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NG_DETAILS),
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), // Make sure it's at least this wide
961  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_NEWGRF_MISSING), SetFill(1, 0), SetDataTip(STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON, STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP),
962  NWidget(NWID_SPACER), SetFill(1, 0),
963  EndContainer(),
964  EndContainer(),
966  NWidget(NWID_SPACER), SetFill(1, 0),
967  NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NG_NEWGRF_SEL),
968  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_NEWGRF), SetFill(1, 0), SetDataTip(STR_INTRO_NEWGRF_SETTINGS, STR_NULL),
969  NWidget(NWID_SPACER), SetFill(1, 0),
970  EndContainer(),
971  EndContainer(),
973  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_JOIN), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_JOIN_GAME, STR_NULL),
974  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_REFRESH), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_REFRESH, STR_NETWORK_SERVER_LIST_REFRESH_TOOLTIP),
975  EndContainer(),
976  EndContainer(),
977  EndContainer(),
978  EndContainer(),
979  EndContainer(),
980  /* BOTTOM */
984  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_SEARCH_INTERNET), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_SEARCH_SERVER_INTERNET, STR_NETWORK_SERVER_LIST_SEARCH_SERVER_INTERNET_TOOLTIP),
985  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_SEARCH_LAN), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_SEARCH_SERVER_LAN, STR_NETWORK_SERVER_LIST_SEARCH_SERVER_LAN_TOOLTIP),
986  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_ADD), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_ADD_SERVER, STR_NETWORK_SERVER_LIST_ADD_SERVER_TOOLTIP),
987  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_START), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_START_SERVER, STR_NETWORK_SERVER_LIST_START_SERVER_TOOLTIP),
988  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_CANCEL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
989  EndContainer(),
990  NWidget(NWID_SPACER), SetMinimalSize(0, 6), SetResize(1, 0), SetFill(1, 0),
991  EndContainer(),
993  NWidget(NWID_SPACER), SetFill(0, 1),
994  NWidget(WWT_RESIZEBOX, COLOUR_LIGHT_BLUE),
995  EndContainer(),
996  EndContainer(),
997  EndContainer(),
998  EndContainer(),
999 };
1000 
1001 static WindowDesc _network_game_window_desc(
1002  WDP_CENTER, "list_servers", 1000, 730,
1004  0,
1005  _nested_network_game_widgets, lengthof(_nested_network_game_widgets)
1006 );
1007 
1008 void ShowNetworkGameWindow()
1009 {
1010  static bool first = true;
1013 
1014  /* Only show once */
1015  if (first) {
1016  first = false;
1017  /* Add all servers from the config file to our list. */
1018  for (const auto &iter : _network_host_list) {
1019  NetworkAddServer(iter.c_str());
1020  }
1021  }
1022 
1023  new NetworkGameWindow(&_network_game_window_desc);
1024 }
1025 
1027  byte widget_id;
1029 
1031  {
1033 
1034  this->querystrings[WID_NSS_GAMENAME] = &this->name_editbox;
1035  this->name_editbox.text.Assign(_settings_client.network.server_name);
1036 
1038  }
1039 
1040  void SetStringParameters(int widget) const override
1041  {
1042  switch (widget) {
1043  case WID_NSS_CONNTYPE_BTN:
1045  break;
1046 
1047  case WID_NSS_CLIENTS_TXT:
1049  break;
1050 
1051  case WID_NSS_COMPANIES_TXT:
1053  break;
1054 
1057  break;
1058 
1059  case WID_NSS_LANGUAGE_BTN:
1060  SetDParam(0, STR_NETWORK_LANG_ANY + _settings_client.network.server_lang);
1061  break;
1062  }
1063  }
1064 
1065  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1066  {
1067  switch (widget) {
1068  case WID_NSS_CONNTYPE_BTN:
1070  size->width += padding.width;
1071  size->height += padding.height;
1072  break;
1073  }
1074  }
1075 
1076  void DrawWidget(const Rect &r, int widget) const override
1077  {
1078  switch (widget) {
1079  case WID_NSS_SETPWD:
1080  /* If password is set, draw red '*' next to 'Set password' button. */
1081  if (!StrEmpty(_settings_client.network.server_password)) DrawString(r.right + WD_FRAMERECT_LEFT, this->width - WD_FRAMERECT_RIGHT, r.top, "*", TC_RED);
1082  }
1083  }
1084 
1085  void OnClick(Point pt, int widget, int click_count) override
1086  {
1087  switch (widget) {
1088  case WID_NSS_CANCEL: // Cancel button
1089  ShowNetworkGameWindow();
1090  break;
1091 
1092  case WID_NSS_SETPWD: // Set password button
1093  this->widget_id = WID_NSS_SETPWD;
1095  ShowQueryString(STR_JUST_RAW_STRING, STR_NETWORK_START_SERVER_SET_PASSWORD, 20, this, CS_ALPHANUMERAL, QSF_NONE);
1096  break;
1097 
1098  case WID_NSS_CONNTYPE_BTN: // Connection type
1099  ShowDropDownMenu(this, _connection_types_dropdown, _settings_client.network.server_advertise, WID_NSS_CONNTYPE_BTN, 0, 0); // do it for widget WID_NSS_CONNTYPE_BTN
1100  break;
1101 
1102  case WID_NSS_CLIENTS_BTND: case WID_NSS_CLIENTS_BTNU: // Click on up/down button for number of clients
1103  case WID_NSS_COMPANIES_BTND: case WID_NSS_COMPANIES_BTNU: // Click on up/down button for number of companies
1104  case WID_NSS_SPECTATORS_BTND: case WID_NSS_SPECTATORS_BTNU: // Click on up/down button for number of spectators
1105  /* Don't allow too fast scrolling. */
1106  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
1107  this->HandleButtonClick(widget);
1108  this->SetDirty();
1109  switch (widget) {
1110  default: NOT_REACHED();
1113  break;
1116  break;
1119  break;
1120  }
1121  }
1122  _left_button_clicked = false;
1123  break;
1124 
1125  case WID_NSS_CLIENTS_TXT: // Click on number of clients
1126  this->widget_id = WID_NSS_CLIENTS_TXT;
1128  ShowQueryString(STR_JUST_INT, STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS, 4, this, CS_NUMERAL, QSF_NONE);
1129  break;
1130 
1131  case WID_NSS_COMPANIES_TXT: // Click on number of companies
1132  this->widget_id = WID_NSS_COMPANIES_TXT;
1134  ShowQueryString(STR_JUST_INT, STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES, 3, this, CS_NUMERAL, QSF_NONE);
1135  break;
1136 
1137  case WID_NSS_SPECTATORS_TXT: // Click on number of spectators
1138  this->widget_id = WID_NSS_SPECTATORS_TXT;
1140  ShowQueryString(STR_JUST_INT, STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS, 4, this, CS_NUMERAL, QSF_NONE);
1141  break;
1142 
1143  case WID_NSS_LANGUAGE_BTN: { // Language
1144  uint sel = 0;
1145  for (uint i = 0; i < _language_dropdown.size() - 1; i++) {
1146  if (_language_dropdown[i] == STR_NETWORK_LANG_ANY + _settings_client.network.server_lang) {
1147  sel = i;
1148  break;
1149  }
1150  }
1151  ShowDropDownMenu(this, _language_dropdown.data(), sel, WID_NSS_LANGUAGE_BTN, 0, 0);
1152  break;
1153  }
1154 
1155  case WID_NSS_GENERATE_GAME: // Start game
1156  _is_network_server = true;
1157  if (_ctrl_pressed) {
1159  } else {
1161  }
1162  break;
1163 
1164  case WID_NSS_LOAD_GAME:
1165  _is_network_server = true;
1167  break;
1168 
1169  case WID_NSS_PLAY_SCENARIO:
1170  _is_network_server = true;
1172  break;
1173 
1175  _is_network_server = true;
1177  break;
1178  }
1179  }
1180 
1181  void OnDropdownSelect(int widget, int index) override
1182  {
1183  switch (widget) {
1184  case WID_NSS_CONNTYPE_BTN:
1185  _settings_client.network.server_advertise = (index != 0);
1186  break;
1187  case WID_NSS_LANGUAGE_BTN:
1188  _settings_client.network.server_lang = _language_dropdown[index] - STR_NETWORK_LANG_ANY;
1189  break;
1190  default:
1191  NOT_REACHED();
1192  }
1193 
1194  this->SetDirty();
1195  }
1196 
1197  void OnEditboxChanged(int wid) override
1198  {
1199  if (wid == WID_NSS_GAMENAME) {
1201  }
1202  }
1203 
1204  void OnTimeout() override
1205  {
1207  for (const int *widget = raise_widgets; *widget != WIDGET_LIST_END; widget++) {
1208  if (this->IsWidgetLowered(*widget)) {
1209  this->RaiseWidget(*widget);
1210  this->SetWidgetDirty(*widget);
1211  }
1212  }
1213  }
1214 
1215  void OnQueryTextFinished(char *str) override
1216  {
1217  if (str == nullptr) return;
1218 
1219  if (this->widget_id == WID_NSS_SETPWD) {
1221  } else {
1222  int32 value = atoi(str);
1223  this->SetWidgetDirty(this->widget_id);
1224  switch (this->widget_id) {
1225  default: NOT_REACHED();
1229  }
1230  }
1231 
1232  this->SetDirty();
1233  }
1234 };
1235 
1236 static const NWidgetPart _nested_network_start_server_window_widgets[] = {
1238  NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE),
1239  NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_NETWORK_START_SERVER_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1240  EndContainer(),
1241  NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NSS_BACKGROUND),
1242  NWidget(NWID_VERTICAL), SetPIP(10, 6, 10),
1244  NWidget(NWID_VERTICAL), SetPIP(0, 1, 0),
1245  /* Game name widgets */
1246  NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NSS_GAMENAME_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_NEW_GAME_NAME, STR_NULL),
1247  NWidget(WWT_EDITBOX, COLOUR_LIGHT_BLUE, WID_NSS_GAMENAME), SetMinimalSize(10, 12), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_NEW_GAME_NAME_OSKTITLE, STR_NETWORK_START_SERVER_NEW_GAME_NAME_TOOLTIP),
1248  EndContainer(),
1249  EndContainer(),
1250 
1252  NWidget(NWID_VERTICAL), SetPIP(0, 1, 0),
1253  NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NSS_CONNTYPE_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_ADVERTISED_LABEL, STR_NULL),
1254  NWidget(WWT_DROPDOWN, COLOUR_LIGHT_BLUE, WID_NSS_CONNTYPE_BTN), SetFill(1, 0), SetDataTip(STR_BLACK_STRING, STR_NETWORK_START_SERVER_ADVERTISED_TOOLTIP),
1255  EndContainer(),
1256  NWidget(NWID_VERTICAL), SetPIP(0, 1, 0),
1257  NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NSS_LANGUAGE_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_LANGUAGE_SPOKEN, STR_NULL),
1258  NWidget(WWT_DROPDOWN, COLOUR_LIGHT_BLUE, WID_NSS_LANGUAGE_BTN), SetFill(1, 0), SetDataTip(STR_BLACK_STRING, STR_NETWORK_START_SERVER_LANGUAGE_TOOLTIP),
1259  EndContainer(),
1260  NWidget(NWID_VERTICAL), SetPIP(0, 1, 0),
1261  NWidget(NWID_SPACER), SetFill(1, 1),
1262  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NSS_SETPWD), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_SET_PASSWORD, STR_NETWORK_START_SERVER_PASSWORD_TOOLTIP),
1263  EndContainer(),
1264  EndContainer(),
1265 
1267  NWidget(NWID_VERTICAL), SetPIP(0, 1, 0),
1268  NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NSS_CLIENTS_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS, STR_NULL),
1270  NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, WID_NSS_CLIENTS_BTND), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_DOWN, STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS_TOOLTIP),
1271  NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_NSS_CLIENTS_TXT), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_CLIENTS_SELECT, STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS_TOOLTIP),
1272  NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, WID_NSS_CLIENTS_BTNU), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_UP, STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS_TOOLTIP),
1273  EndContainer(),
1274  EndContainer(),
1275 
1276  NWidget(NWID_VERTICAL), SetPIP(0, 1, 0),
1277  NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NSS_COMPANIES_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES, STR_NULL),
1279  NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, WID_NSS_COMPANIES_BTND), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_DOWN, STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES_TOOLTIP),
1280  NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_NSS_COMPANIES_TXT), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_COMPANIES_SELECT, STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES_TOOLTIP),
1281  NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, WID_NSS_COMPANIES_BTNU), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_UP, STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES_TOOLTIP),
1282  EndContainer(),
1283  EndContainer(),
1284 
1285  NWidget(NWID_VERTICAL), SetPIP(0, 1, 0),
1286  NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NSS_SPECTATORS_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS, STR_NULL),
1288  NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, WID_NSS_SPECTATORS_BTND), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_DOWN, STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS_TOOLTIP),
1289  NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_NSS_SPECTATORS_TXT), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_SPECTATORS_SELECT, STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS_TOOLTIP),
1290  NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, WID_NSS_SPECTATORS_BTNU), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_UP, STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS_TOOLTIP),
1291  EndContainer(),
1292  EndContainer(),
1293  EndContainer(),
1294 
1295  /* 'generate game' and 'load game' buttons */
1297  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NSS_GENERATE_GAME), SetDataTip(STR_INTRO_NEW_GAME, STR_INTRO_TOOLTIP_NEW_GAME), SetFill(1, 0),
1298  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NSS_LOAD_GAME), SetDataTip(STR_INTRO_LOAD_GAME, STR_INTRO_TOOLTIP_LOAD_GAME), SetFill(1, 0),
1299  EndContainer(),
1300 
1301  /* 'play scenario' and 'play heightmap' buttons */
1303  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NSS_PLAY_SCENARIO), SetDataTip(STR_INTRO_PLAY_SCENARIO, STR_INTRO_TOOLTIP_PLAY_SCENARIO), SetFill(1, 0),
1304  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NSS_PLAY_HEIGHTMAP), SetDataTip(STR_INTRO_PLAY_HEIGHTMAP, STR_INTRO_TOOLTIP_PLAY_HEIGHTMAP), SetFill(1, 0),
1305  EndContainer(),
1306 
1308  NWidget(NWID_SPACER), SetFill(1, 0),
1309  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NSS_CANCEL), SetDataTip(STR_BUTTON_CANCEL, STR_NULL), SetMinimalSize(128, 12),
1310  NWidget(NWID_SPACER), SetFill(1, 0),
1311  EndContainer(),
1312  EndContainer(),
1313  EndContainer(),
1314 };
1315 
1316 static WindowDesc _network_start_server_window_desc(
1317  WDP_CENTER, nullptr, 0, 0,
1319  0,
1320  _nested_network_start_server_window_widgets, lengthof(_nested_network_start_server_window_widgets)
1321 );
1322 
1323 static void ShowNetworkStartServerWindow()
1324 {
1327 
1328  new NetworkStartServerWindow(&_network_start_server_window_desc);
1329 }
1330 
1331 struct NetworkLobbyWindow : public Window {
1334  NetworkCompanyInfo company_info[MAX_COMPANIES];
1335  Scrollbar *vscroll;
1336 
1338  Window(desc), company(INVALID_COMPANY), server(ngl)
1339  {
1340  this->CreateNestedTree();
1341  this->vscroll = this->GetScrollbar(WID_NL_SCROLLBAR);
1343  }
1344 
1345  CompanyID NetworkLobbyFindCompanyIndex(byte pos) const
1346  {
1347  /* Scroll through all this->company_info and get the 'pos' item that is not empty. */
1348  for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
1349  if (!StrEmpty(this->company_info[i].company_name)) {
1350  if (pos-- == 0) return i;
1351  }
1352  }
1353 
1354  return COMPANY_FIRST;
1355  }
1356 
1357  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1358  {
1359  switch (widget) {
1360  case WID_NL_HEADER:
1362  break;
1363 
1364  case WID_NL_MATRIX:
1365  resize->height = WD_MATRIX_TOP + std::max<uint>(std::max(GetSpriteSize(SPR_LOCK).height, GetSpriteSize(SPR_PROFIT_LOT).height), FONT_HEIGHT_NORMAL) + WD_MATRIX_BOTTOM;
1366  size->height = 10 * resize->height;
1367  break;
1368 
1369  case WID_NL_DETAILS:
1370  size->height = 30 + 11 * FONT_HEIGHT_NORMAL;
1371  break;
1372  }
1373  }
1374 
1375  void SetStringParameters(int widget) const override
1376  {
1377  switch (widget) {
1378  case WID_NL_TEXT:
1379  SetDParamStr(0, this->server->info.server_name);
1380  break;
1381  }
1382  }
1383 
1384  void DrawWidget(const Rect &r, int widget) const override
1385  {
1386  switch (widget) {
1387  case WID_NL_DETAILS:
1388  this->DrawDetails(r);
1389  break;
1390 
1391  case WID_NL_MATRIX:
1392  this->DrawMatrix(r);
1393  break;
1394  }
1395  }
1396 
1397  void OnPaint() override
1398  {
1399  const NetworkGameInfo *gi = &this->server->info;
1400 
1401  /* Join button is disabled when no company is selected and for AI companies. */
1402  this->SetWidgetDisabledState(WID_NL_JOIN, this->company == INVALID_COMPANY || GetLobbyCompanyInfo(this->company)->ai);
1403  /* Cannot start new company if there are too many. */
1405  /* Cannot spectate if there are too many spectators. */
1407 
1408  this->vscroll->SetCount(gi->companies_on);
1409 
1410  /* Draw window widgets */
1411  this->DrawWidgets();
1412  }
1413 
1414  void DrawMatrix(const Rect &r) const
1415  {
1416  bool rtl = _current_text_dir == TD_RTL;
1417  uint left = r.left + WD_FRAMERECT_LEFT;
1418  uint right = r.right - WD_FRAMERECT_RIGHT;
1419  uint text_offset = (this->resize.step_height - WD_MATRIX_TOP - WD_MATRIX_BOTTOM - FONT_HEIGHT_NORMAL) / 2 + WD_MATRIX_TOP;
1420 
1421  Dimension lock_size = GetSpriteSize(SPR_LOCK);
1422  int lock_width = lock_size.width;
1423  int lock_y_offset = (this->resize.step_height - WD_MATRIX_TOP - WD_MATRIX_BOTTOM - lock_size.height) / 2 + WD_MATRIX_TOP;
1424 
1425  Dimension profit_size = GetSpriteSize(SPR_PROFIT_LOT);
1426  int profit_width = lock_size.width;
1427  int profit_y_offset = (this->resize.step_height - WD_MATRIX_TOP - WD_MATRIX_BOTTOM - profit_size.height) / 2 + WD_MATRIX_TOP;
1428 
1429  uint text_left = left + (rtl ? lock_width + profit_width + 4 : 0);
1430  uint text_right = right - (rtl ? 0 : lock_width + profit_width + 4);
1431  uint profit_left = rtl ? left : right - profit_width;
1432  uint lock_left = rtl ? left + profit_width + 2 : right - profit_width - lock_width - 2;
1433 
1434  int y = r.top;
1435  /* Draw company list */
1436  int pos = this->vscroll->GetPosition();
1437  while (pos < this->server->info.companies_on) {
1438  byte company = NetworkLobbyFindCompanyIndex(pos);
1439  bool income = false;
1440  if (this->company == company) {
1441  GfxFillRect(r.left + WD_BEVEL_LEFT, y + 1, r.right - WD_BEVEL_RIGHT, y + this->resize.step_height - 2, PC_GREY); // show highlighted item with a different colour
1442  }
1443 
1444  DrawString(text_left, text_right, y + text_offset, this->company_info[company].company_name, TC_BLACK);
1445  if (this->company_info[company].use_password != 0) DrawSprite(SPR_LOCK, PAL_NONE, lock_left, y + lock_y_offset);
1446 
1447  /* If the company's income was positive puts a green dot else a red dot */
1448  if (this->company_info[company].income >= 0) income = true;
1449  DrawSprite(income ? SPR_PROFIT_LOT : SPR_PROFIT_NEGATIVE, PAL_NONE, profit_left, y + profit_y_offset);
1450 
1451  pos++;
1452  y += this->resize.step_height;
1453  if (pos >= this->vscroll->GetPosition() + this->vscroll->GetCapacity()) break;
1454  }
1455  }
1456 
1457  void DrawDetails(const Rect &r) const
1458  {
1459  const int detail_height = 12 + FONT_HEIGHT_NORMAL + 12;
1460  /* Draw info about selected company when it is selected in the left window. */
1461  GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.top + detail_height - 1, PC_DARK_BLUE);
1462  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + 12, STR_NETWORK_GAME_LOBBY_COMPANY_INFO, TC_FROMSTRING, SA_HOR_CENTER);
1463 
1464  if (this->company == INVALID_COMPANY || StrEmpty(this->company_info[this->company].company_name)) return;
1465 
1466  int y = r.top + detail_height + 4;
1467  const NetworkGameInfo *gi = &this->server->info;
1468 
1469  SetDParam(0, gi->clients_on);
1470  SetDParam(1, gi->clients_max);
1471  SetDParam(2, gi->companies_on);
1472  SetDParam(3, gi->companies_max);
1473  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_CLIENTS);
1474  y += FONT_HEIGHT_NORMAL;
1475 
1476  SetDParamStr(0, this->company_info[this->company].company_name);
1477  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_GAME_LOBBY_COMPANY_NAME);
1478  y += FONT_HEIGHT_NORMAL;
1479 
1480  SetDParam(0, this->company_info[this->company].inaugurated_year);
1481  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_GAME_LOBBY_INAUGURATION_YEAR); // inauguration year
1482  y += FONT_HEIGHT_NORMAL;
1483 
1484  SetDParam(0, this->company_info[this->company].company_value);
1485  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_GAME_LOBBY_VALUE); // company value
1486  y += FONT_HEIGHT_NORMAL;
1487 
1488  SetDParam(0, this->company_info[this->company].money);
1489  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_GAME_LOBBY_CURRENT_BALANCE); // current balance
1490  y += FONT_HEIGHT_NORMAL;
1491 
1492  SetDParam(0, this->company_info[this->company].income);
1493  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_GAME_LOBBY_LAST_YEARS_INCOME); // last year's income
1494  y += FONT_HEIGHT_NORMAL;
1495 
1496  SetDParam(0, this->company_info[this->company].performance);
1497  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_GAME_LOBBY_PERFORMANCE); // performance
1498  y += FONT_HEIGHT_NORMAL;
1499 
1500  SetDParam(0, this->company_info[this->company].num_vehicle[NETWORK_VEH_TRAIN]);
1501  SetDParam(1, this->company_info[this->company].num_vehicle[NETWORK_VEH_LORRY]);
1502  SetDParam(2, this->company_info[this->company].num_vehicle[NETWORK_VEH_BUS]);
1503  SetDParam(3, this->company_info[this->company].num_vehicle[NETWORK_VEH_SHIP]);
1504  SetDParam(4, this->company_info[this->company].num_vehicle[NETWORK_VEH_PLANE]);
1505  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_GAME_LOBBY_VEHICLES); // vehicles
1506  y += FONT_HEIGHT_NORMAL;
1507 
1508  SetDParam(0, this->company_info[this->company].num_station[NETWORK_VEH_TRAIN]);
1509  SetDParam(1, this->company_info[this->company].num_station[NETWORK_VEH_LORRY]);
1510  SetDParam(2, this->company_info[this->company].num_station[NETWORK_VEH_BUS]);
1511  SetDParam(3, this->company_info[this->company].num_station[NETWORK_VEH_SHIP]);
1512  SetDParam(4, this->company_info[this->company].num_station[NETWORK_VEH_PLANE]);
1513  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_GAME_LOBBY_STATIONS); // stations
1514  y += FONT_HEIGHT_NORMAL;
1515 
1516  SetDParamStr(0, this->company_info[this->company].clients);
1517  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_GAME_LOBBY_PLAYERS); // players
1518  }
1519 
1520  void OnClick(Point pt, int widget, int click_count) override
1521  {
1522  switch (widget) {
1523  case WID_NL_CANCEL: // Cancel button
1524  ShowNetworkGameWindow();
1525  break;
1526 
1527  case WID_NL_MATRIX: { // Company list
1528  uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NL_MATRIX);
1529  this->company = (id_v >= this->server->info.companies_on) ? INVALID_COMPANY : NetworkLobbyFindCompanyIndex(id_v);
1530  this->SetDirty();
1531 
1532  /* FIXME the disabling should go into some InvalidateData, which is called instead of the SetDirty */
1533  if (click_count > 1 && !this->IsWidgetDisabled(WID_NL_JOIN)) this->OnClick(pt, WID_NL_JOIN, 1);
1534  break;
1535  }
1536 
1537  case WID_NL_JOIN: // Join company
1538  /* Button can be clicked only when it is enabled. */
1539  NetworkClientConnectGame(_settings_client.network.last_host, _settings_client.network.last_port, this->company);
1540  break;
1541 
1542  case WID_NL_NEW: // New company
1544  break;
1545 
1546  case WID_NL_SPECTATE: // Spectate game
1548  break;
1549 
1550  case WID_NL_REFRESH: // Refresh
1553  /* Clear the information so removed companies don't remain */
1554  for (auto &company : this->company_info) company = {};
1555  break;
1556  }
1557  }
1558 
1559  void OnResize() override
1560  {
1561  this->vscroll->SetCapacityFromWidget(this, WID_NL_MATRIX);
1562  }
1563 };
1564 
1565 static const NWidgetPart _nested_network_lobby_window_widgets[] = {
1567  NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE),
1568  NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_NETWORK_GAME_LOBBY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1569  EndContainer(),
1570  NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NL_BACKGROUND),
1571  NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NL_TEXT), SetDataTip(STR_NETWORK_GAME_LOBBY_PREPARE_TO_JOIN, STR_NULL), SetResize(1, 0), SetPadding(10, 10, 0, 10),
1573  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 10),
1574  /* Company list. */
1576  NWidget(WWT_PANEL, COLOUR_WHITE, WID_NL_HEADER), SetMinimalSize(146, 0), SetResize(1, 0), SetFill(1, 0), EndContainer(),
1577  NWidget(WWT_MATRIX, COLOUR_LIGHT_BLUE, WID_NL_MATRIX), SetMinimalSize(146, 0), SetResize(1, 1), SetFill(1, 1), SetMatrixDataTip(1, 0, STR_NETWORK_GAME_LOBBY_COMPANY_LIST_TOOLTIP), SetScrollbar(WID_NL_SCROLLBAR),
1578  EndContainer(),
1579  NWidget(NWID_VSCROLLBAR, COLOUR_LIGHT_BLUE, WID_NL_SCROLLBAR),
1581  /* Company info. */
1582  NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NL_DETAILS), SetMinimalSize(232, 0), SetResize(1, 1), SetFill(1, 1), EndContainer(),
1583  EndContainer(),
1585  /* Buttons. */
1588  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NL_JOIN), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_GAME_LOBBY_JOIN_COMPANY, STR_NETWORK_GAME_LOBBY_JOIN_COMPANY_TOOLTIP),
1589  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NL_NEW), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_GAME_LOBBY_NEW_COMPANY, STR_NETWORK_GAME_LOBBY_NEW_COMPANY_TOOLTIP),
1590  EndContainer(),
1592  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NL_SPECTATE), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_GAME_LOBBY_SPECTATE_GAME, STR_NETWORK_GAME_LOBBY_SPECTATE_GAME_TOOLTIP),
1593  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NL_REFRESH), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_REFRESH, STR_NETWORK_SERVER_LIST_REFRESH_TOOLTIP),
1594  EndContainer(),
1596  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NL_CANCEL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
1597  NWidget(NWID_SPACER), SetFill(1, 1),
1598  EndContainer(),
1599  EndContainer(),
1601  EndContainer(),
1602 };
1603 
1604 static WindowDesc _network_lobby_window_desc(
1605  WDP_CENTER, nullptr, 0, 0,
1607  0,
1608  _nested_network_lobby_window_widgets, lengthof(_nested_network_lobby_window_widgets)
1609 );
1610 
1616 {
1619 
1622 
1623  new NetworkLobbyWindow(&_network_lobby_window_desc, ngl);
1624 }
1625 
1632 {
1634  return (lobby != nullptr && company < MAX_COMPANIES) ? &lobby->company_info[company] : nullptr;
1635 }
1636 
1637 /* The window below gives information about the connected clients
1638  * and also makes able to kick them (if server) and stuff like that. */
1639 
1640 extern void DrawCompanyIcon(CompanyID cid, int x, int y);
1641 
1647 
1648 static const NWidgetPart _nested_client_list_popup_widgets[] = {
1649  NWidget(WWT_PANEL, COLOUR_GREY, WID_CLP_PANEL), EndContainer(),
1650 };
1651 
1652 static WindowDesc _client_list_popup_desc(
1653  WDP_AUTO, nullptr, 0, 0,
1655  0,
1656  _nested_client_list_popup_widgets, lengthof(_nested_client_list_popup_widgets)
1657 );
1658 
1659 /* Here we start to define the options out of the menu */
1660 static void ClientList_Kick(const NetworkClientInfo *ci)
1661 {
1662  NetworkServerKickClient(ci->client_id, nullptr);
1663 }
1664 
1665 static void ClientList_Ban(const NetworkClientInfo *ci)
1666 {
1667  NetworkServerKickOrBanIP(ci->client_id, true, nullptr);
1668 }
1669 
1670 static void ClientList_SpeakToClient(const NetworkClientInfo *ci)
1671 {
1673 }
1674 
1675 static void ClientList_SpeakToCompany(const NetworkClientInfo *ci)
1676 {
1678 }
1679 
1680 static void ClientList_SpeakToAll(const NetworkClientInfo *ci)
1681 {
1683 }
1684 
1691  };
1692 
1693  uint sel_index;
1694  ClientID client_id;
1695  Point desired_location;
1696  std::vector<ClientListAction> actions;
1697 
1703  inline void AddAction(StringID name, ClientList_Action_Proc *proc)
1704  {
1705  this->actions.push_back({name, proc});
1706  }
1707 
1708  NetworkClientListPopupWindow(WindowDesc *desc, int x, int y, ClientID client_id) :
1709  Window(desc),
1710  sel_index(0), client_id(client_id)
1711  {
1712  this->desired_location.x = x;
1713  this->desired_location.y = y;
1714 
1715  const NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(client_id);
1716 
1717  if (_network_own_client_id != ci->client_id) {
1718  this->AddAction(STR_NETWORK_CLIENTLIST_SPEAK_TO_CLIENT, &ClientList_SpeakToClient);
1719  }
1720 
1722  this->AddAction(STR_NETWORK_CLIENTLIST_SPEAK_TO_COMPANY, &ClientList_SpeakToCompany);
1723  }
1724  this->AddAction(STR_NETWORK_CLIENTLIST_SPEAK_TO_ALL, &ClientList_SpeakToAll);
1725 
1726  /* A server can kick clients (but not himself). */
1728  this->AddAction(STR_NETWORK_CLIENTLIST_KICK, &ClientList_Kick);
1729  this->AddAction(STR_NETWORK_CLIENTLIST_BAN, &ClientList_Ban);
1730  }
1731 
1732  this->InitNested(client_id);
1733  CLRBITS(this->flags, WF_WHITE_BORDER);
1734  }
1735 
1736  Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
1737  {
1738  return this->desired_location;
1739  }
1740 
1741  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1742  {
1743  Dimension d = *size;
1744  for (const ClientListAction &action : this->actions) {
1745  d = maxdim(GetStringBoundingBox(action.name), d);
1746  }
1747 
1748  d.height *= (uint)this->actions.size();
1750  d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
1751  *size = d;
1752  }
1753 
1754  void DrawWidget(const Rect &r, int widget) const override
1755  {
1756  /* Draw the actions */
1757  int sel = this->sel_index;
1758  int y = r.top + WD_FRAMERECT_TOP;
1759  for (const ClientListAction &action : this->actions) {
1760  TextColour colour;
1761  if (sel-- == 0) { // Selected item, highlight it
1762  GfxFillRect(r.left + 1, y, r.right - 1, y + FONT_HEIGHT_NORMAL - 1, PC_BLACK);
1763  colour = TC_WHITE;
1764  } else {
1765  colour = TC_BLACK;
1766  }
1767 
1768  DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, action.name, colour);
1769  y += FONT_HEIGHT_NORMAL;
1770  }
1771  }
1772 
1773  void OnMouseLoop() override
1774  {
1775  /* We selected an action */
1776  uint index = (_cursor.pos.y - this->top - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL;
1777 
1778  if (_left_button_down) {
1779  if (index == this->sel_index || index >= this->actions.size()) return;
1780 
1781  this->sel_index = index;
1782  this->SetDirty();
1783  } else {
1784  if (index < this->actions.size() && _cursor.pos.y >= this->top) {
1785  const NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(this->client_id);
1786  if (ci != nullptr) this->actions[index].proc(ci);
1787  }
1788 
1790  }
1791  }
1792 };
1793 
1797 static void PopupClientList(ClientID client_id, int x, int y)
1798 {
1800 
1801  if (NetworkClientInfo::GetByClientID(client_id) == nullptr) return;
1802 
1803  new NetworkClientListPopupWindow(&_client_list_popup_desc, x, y, client_id);
1804 }
1805 
1806 static const NWidgetPart _nested_client_list_widgets[] = {
1808  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
1809  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_NETWORK_COMPANY_LIST_CLIENT_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1810  NWidget(WWT_STICKYBOX, COLOUR_GREY),
1811  EndContainer(),
1813 };
1814 
1815 static WindowDesc _client_list_desc(
1816  WDP_AUTO, "list_clients", 0, 0,
1818  0,
1819  _nested_client_list_widgets, lengthof(_nested_client_list_widgets)
1820 );
1821 
1826  int selected_item;
1827 
1828  uint server_client_width;
1829  uint line_height;
1830 
1831  Dimension icon_size;
1832 
1834  Window(desc),
1835  selected_item(-1)
1836  {
1837  this->InitNested(window_number);
1838  }
1839 
1844  {
1845  int num = 0;
1846 
1847  /* Should be replaced with a loop through all clients */
1848  for (const NetworkClientInfo *ci : NetworkClientInfo::Iterate()) {
1849  if (ci->client_playas != COMPANY_INACTIVE_CLIENT) num++;
1850  }
1851 
1852  num *= this->line_height;
1853 
1854  int diff = (num + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM) - (this->GetWidget<NWidgetBase>(WID_CL_PANEL)->current_y);
1855  /* If height is changed */
1856  if (diff != 0) {
1857  ResizeWindow(this, 0, diff, false);
1858  return false;
1859  }
1860  return true;
1861  }
1862 
1863  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1864  {
1865  if (widget != WID_CL_PANEL) return;
1866 
1867  this->server_client_width = std::max(GetStringBoundingBox(STR_NETWORK_SERVER).width, GetStringBoundingBox(STR_NETWORK_CLIENT).width) + WD_FRAMERECT_RIGHT;
1868  this->icon_size = GetSpriteSize(SPR_COMPANY_ICON);
1869  this->line_height = std::max(this->icon_size.height + 2U, (uint)FONT_HEIGHT_NORMAL);
1870 
1871  uint width = 100; // Default width
1872  for (const NetworkClientInfo *ci : NetworkClientInfo::Iterate()) {
1873  width = std::max(width, GetStringBoundingBox(ci->client_name).width);
1874  }
1875 
1876  size->width = WD_FRAMERECT_LEFT + this->server_client_width + this->icon_size.width + WD_FRAMERECT_LEFT + width + WD_FRAMERECT_RIGHT;
1877  }
1878 
1879  void OnPaint() override
1880  {
1881  /* Check if we need to reset the height */
1882  if (!this->CheckClientListHeight()) return;
1883 
1884  this->DrawWidgets();
1885  }
1886 
1887  void DrawWidget(const Rect &r, int widget) const override
1888  {
1889  if (widget != WID_CL_PANEL) return;
1890 
1891  bool rtl = _current_text_dir == TD_RTL;
1892  int icon_offset = (this->line_height - icon_size.height) / 2;
1893  int text_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
1894 
1895  uint y = r.top + WD_FRAMERECT_TOP;
1896  uint left = r.left + WD_FRAMERECT_LEFT;
1897  uint right = r.right - WD_FRAMERECT_RIGHT;
1898  uint type_icon_width = this->server_client_width + this->icon_size.width + WD_FRAMERECT_LEFT;
1899 
1900 
1901  uint type_left = rtl ? right - this->server_client_width : left;
1902  uint type_right = rtl ? right : left + this->server_client_width - 1;
1903  uint icon_left = rtl ? right - type_icon_width + WD_FRAMERECT_LEFT : left + this->server_client_width;
1904  uint name_left = rtl ? left : left + type_icon_width;
1905  uint name_right = rtl ? right - type_icon_width : right;
1906 
1907  int i = 0;
1908  for (const NetworkClientInfo *ci : NetworkClientInfo::Iterate()) {
1909  TextColour colour;
1910  if (this->selected_item == i++) { // Selected item, highlight it
1911  GfxFillRect(r.left + 1, y, r.right - 1, y + this->line_height - 1, PC_BLACK);
1912  colour = TC_WHITE;
1913  } else {
1914  colour = TC_BLACK;
1915  }
1916 
1917  if (ci->client_id == CLIENT_ID_SERVER) {
1918  DrawString(type_left, type_right, y + text_offset, STR_NETWORK_SERVER, colour);
1919  } else {
1920  DrawString(type_left, type_right, y + text_offset, STR_NETWORK_CLIENT, colour);
1921  }
1922 
1923  /* Filter out spectators */
1924  if (Company::IsValidID(ci->client_playas)) DrawCompanyIcon(ci->client_playas, icon_left, y + icon_offset);
1925 
1926  DrawString(name_left, name_right, y + text_offset, ci->client_name, colour);
1927 
1928  y += line_height;
1929  }
1930  }
1931 
1932  void OnClick(Point pt, int widget, int click_count) override
1933  {
1934  /* Show the popup with option */
1935  if (this->selected_item != -1) {
1936  int client_no = this->selected_item;
1938  if (client_no == 0) {
1939  PopupClientList(ci->client_id, pt.x + this->left, pt.y + this->top);
1940  break;
1941  }
1942  client_no--;
1943  }
1944  }
1945  }
1946 
1947  void OnMouseOver(Point pt, int widget) override
1948  {
1949  /* -1 means we left the current window */
1950  if (pt.y == -1) {
1951  this->selected_item = -1;
1952  this->SetDirty();
1953  return;
1954  }
1955 
1956  /* Find the new selected item (if any) */
1957  pt.y -= this->GetWidget<NWidgetBase>(WID_CL_PANEL)->pos_y;
1958  int item = -1;
1960  item = (pt.y - WD_FRAMERECT_TOP) / this->line_height;
1961  }
1962 
1963  /* It did not change.. no update! */
1964  if (item == this->selected_item) return;
1965  this->selected_item = item;
1966 
1967  /* Repaint */
1968  this->SetDirty();
1969  }
1970 };
1971 
1972 void ShowClientList()
1973 {
1974  AllocateWindowDescFront<NetworkClientListWindow>(&_client_list_desc, 0);
1975 }
1976 
1981 
1983  NetworkPasswordType password_type;
1984 
1986  {
1989  }
1990 
1991  void DrawWidget(const Rect &r, int widget) const override
1992  {
1993  if (widget != WID_NJS_BACKGROUND) return;
1994 
1995  uint8 progress; // used for progress bar
1996  DrawString(r.left + 2, r.right - 2, r.top + 20, STR_NETWORK_CONNECTING_1 + _network_join_status, TC_FROMSTRING, SA_HOR_CENTER);
1997  switch (_network_join_status) {
1998  case NETWORK_JOIN_STATUS_CONNECTING: case NETWORK_JOIN_STATUS_AUTHORIZING:
1999  case NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO:
2000  progress = 10; // first two stages 10%
2001  break;
2002  case NETWORK_JOIN_STATUS_WAITING:
2004  DrawString(r.left + 2, r.right - 2, r.top + 20 + FONT_HEIGHT_NORMAL, STR_NETWORK_CONNECTING_WAITING, TC_FROMSTRING, SA_HOR_CENTER);
2005  progress = 15; // third stage is 15%
2006  break;
2007  case NETWORK_JOIN_STATUS_DOWNLOADING:
2010  DrawString(r.left + 2, r.right - 2, r.top + 20 + FONT_HEIGHT_NORMAL, _network_join_bytes_total == 0 ? STR_NETWORK_CONNECTING_DOWNLOADING_1 : STR_NETWORK_CONNECTING_DOWNLOADING_2, TC_FROMSTRING, SA_HOR_CENTER);
2011  if (_network_join_bytes_total == 0) {
2012  progress = 15; // We don't have the final size yet; the server is still compressing!
2013  break;
2014  }
2015  FALLTHROUGH;
2016 
2017  default: // Waiting is 15%, so the resting receivement of map is maximum 70%
2018  progress = 15 + _network_join_bytes * (100 - 15) / _network_join_bytes_total;
2019  }
2020 
2021  /* Draw nice progress bar :) */
2022  DrawFrameRect(r.left + 20, r.top + 5, (int)((this->width - 20) * progress / 100), r.top + 15, COLOUR_MAUVE, FR_NONE);
2023  }
2024 
2025  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
2026  {
2027  if (widget != WID_NJS_BACKGROUND) return;
2028 
2029  size->height = 25 + 2 * FONT_HEIGHT_NORMAL;
2030 
2031  /* Account for the statuses */
2032  uint width = 0;
2033  for (uint i = 0; i < NETWORK_JOIN_STATUS_END; i++) {
2034  width = std::max(width, GetStringBoundingBox(STR_NETWORK_CONNECTING_1 + i).width);
2035  }
2036 
2037  /* For the number of waiting (other) players */
2039  width = std::max(width, GetStringBoundingBox(STR_NETWORK_CONNECTING_WAITING).width);
2040 
2041  /* Account for downloading ~ 10 MiB */
2042  SetDParamMaxDigits(0, 8);
2043  SetDParamMaxDigits(1, 8);
2044  width = std::max(width, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_1).width);
2045  width = std::max(width, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_2).width);
2046 
2047  /* Give a bit more clearing for the widest strings than strictly needed */
2048  size->width = width + WD_FRAMERECT_LEFT + WD_FRAMERECT_BOTTOM + 10;
2049  }
2050 
2051  void OnClick(Point pt, int widget, int click_count) override
2052  {
2053  if (widget == WID_NJS_CANCELOK) { // Disconnect button
2055  SwitchToMode(SM_MENU);
2056  ShowNetworkGameWindow();
2057  }
2058  }
2059 
2060  void OnQueryTextFinished(char *str) override
2061  {
2062  if (StrEmpty(str)) {
2064  ShowNetworkGameWindow();
2065  return;
2066  }
2067 
2068  switch (this->password_type) {
2071  default: NOT_REACHED();
2072  }
2073  }
2074 };
2075 
2076 static const NWidgetPart _nested_network_join_status_window_widgets[] = {
2077  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_NETWORK_CONNECTING_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
2078  NWidget(WWT_PANEL, COLOUR_GREY),
2079  NWidget(WWT_EMPTY, COLOUR_GREY, WID_NJS_BACKGROUND),
2081  NWidget(NWID_SPACER), SetMinimalSize(75, 0), SetFill(1, 0),
2082  NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NJS_CANCELOK), SetMinimalSize(101, 12), SetDataTip(STR_NETWORK_CONNECTION_DISCONNECT, STR_NULL),
2083  NWidget(NWID_SPACER), SetMinimalSize(75, 0), SetFill(1, 0),
2084  EndContainer(),
2086  EndContainer(),
2087 };
2088 
2089 static WindowDesc _network_join_status_window_desc(
2090  WDP_CENTER, nullptr, 0, 0,
2092  WDF_MODAL,
2093  _nested_network_join_status_window_widgets, lengthof(_nested_network_join_status_window_widgets)
2094 );
2095 
2096 void ShowJoinStatusWindow()
2097 {
2099  new NetworkJoinStatusWindow(&_network_join_status_window_desc);
2100 }
2101 
2102 void ShowNetworkNeedPassword(NetworkPasswordType npt)
2103 {
2105  if (w == nullptr) return;
2106  w->password_type = npt;
2107 
2108  StringID caption;
2109  switch (npt) {
2110  default: NOT_REACHED();
2111  case NETWORK_GAME_PASSWORD: caption = STR_NETWORK_NEED_GAME_PASSWORD_CAPTION; break;
2112  case NETWORK_COMPANY_PASSWORD: caption = STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION; break;
2113  }
2115 }
2116 
2120 
2121  NetworkCompanyPasswordWindow(WindowDesc *desc, Window *parent) : Window(desc), password_editbox(lengthof(_settings_client.network.default_company_pass))
2122  {
2123  this->InitNested(0);
2124  this->UpdateWarningStringSize();
2125 
2126  this->parent = parent;
2128  this->password_editbox.cancel_button = WID_NCP_CANCEL;
2129  this->password_editbox.ok_button = WID_NCP_OK;
2131  }
2132 
2133  void UpdateWarningStringSize()
2134  {
2135  assert(this->nested_root->smallest_x > 0);
2137  this->warning_size.height = GetStringHeight(STR_WARNING_PASSWORD_SECURITY, this->warning_size.width);
2138  this->warning_size.height += WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
2139 
2140  this->ReInit();
2141  }
2142 
2143  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
2144  {
2145  if (widget == WID_NCP_WARNING) {
2146  *size = this->warning_size;
2147  }
2148  }
2149 
2150  void DrawWidget(const Rect &r, int widget) const override
2151  {
2152  if (widget != WID_NCP_WARNING) return;
2153 
2155  r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM,
2156  STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING, SA_CENTER);
2157  }
2158 
2159  void OnOk()
2160  {
2163  }
2164 
2165  NetworkChangeCompanyPassword(_local_company, this->password_editbox.text.buf);
2166  }
2167 
2168  void OnClick(Point pt, int widget, int click_count) override
2169  {
2170  switch (widget) {
2171  case WID_NCP_OK:
2172  this->OnOk();
2173  FALLTHROUGH;
2174 
2175  case WID_NCP_CANCEL:
2176  delete this;
2177  break;
2178 
2181  this->SetDirty();
2182  break;
2183  }
2184  }
2185 };
2186 
2187 static const NWidgetPart _nested_network_company_password_window_widgets[] = {
2189  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
2190  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_COMPANY_PASSWORD_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
2191  EndContainer(),
2192  NWidget(WWT_PANEL, COLOUR_GREY, WID_NCP_BACKGROUND),
2193  NWidget(NWID_VERTICAL), SetPIP(5, 5, 5),
2194  NWidget(NWID_HORIZONTAL), SetPIP(5, 5, 5),
2195  NWidget(WWT_TEXT, COLOUR_GREY, WID_NCP_LABEL), SetDataTip(STR_COMPANY_VIEW_PASSWORD, STR_NULL),
2196  NWidget(WWT_EDITBOX, COLOUR_GREY, WID_NCP_PASSWORD), SetFill(1, 0), SetMinimalSize(194, 12), SetDataTip(STR_COMPANY_VIEW_SET_PASSWORD, STR_NULL),
2197  EndContainer(),
2198  NWidget(NWID_HORIZONTAL), SetPIP(5, 0, 5),
2199  NWidget(NWID_SPACER), SetFill(1, 0),
2201  SetDataTip(STR_COMPANY_PASSWORD_MAKE_DEFAULT, STR_COMPANY_PASSWORD_MAKE_DEFAULT_TOOLTIP),
2202  EndContainer(),
2203  EndContainer(),
2204  EndContainer(),
2205  NWidget(WWT_PANEL, COLOUR_GREY, WID_NCP_WARNING), EndContainer(),
2207  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NCP_CANCEL), SetFill(1, 0), SetDataTip(STR_BUTTON_CANCEL, STR_COMPANY_PASSWORD_CANCEL),
2208  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NCP_OK), SetFill(1, 0), SetDataTip(STR_BUTTON_OK, STR_COMPANY_PASSWORD_OK),
2209  EndContainer(),
2210 };
2211 
2212 static WindowDesc _network_company_password_window_desc(
2213  WDP_AUTO, nullptr, 0, 0,
2215  0,
2216  _nested_network_company_password_window_widgets, lengthof(_nested_network_company_password_window_widgets)
2217 );
2218 
2219 void ShowNetworkCompanyPasswordWindow(Window *parent)
2220 {
2222 
2223  new NetworkCompanyPasswordWindow(&_network_company_password_window_desc, parent);
2224 }
NWidgetServerListHeader::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: network_gui.cpp:189
ShowNewGRFSettings
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
Definition: newgrf_gui.cpp:1994
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:718
network_content.h
NetworkGameWindow::NGameAllowedSorter
static bool NGameAllowedSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by joinability.
Definition: network_gui.cpp:323
WID_NL_JOIN
@ WID_NL_JOIN
'Join company' button.
Definition: network_widget.h:93
_network_join_bytes_total
uint32 _network_join_bytes_total
The total number of bytes to download.
Definition: network_gui.cpp:1980
NetworkGameInfo
The game information that is sent from the server to the clients.
Definition: game_info.h:71
WD_FRAMERECT_TOP
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:62
NetworkGameWindow::name_editbox
QueryString name_editbox
Client name editbox.
Definition: network_gui.cpp:228
NetworkSettings::client_name
char client_name[NETWORK_CLIENT_NAME_LENGTH]
name of the player (as client)
Definition: settings_type.h:270
InvalidateWindowData
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-...
Definition: window.cpp:3321
WID_NSS_CLIENTS_TXT
@ WID_NSS_CLIENTS_TXT
'Max clients' text.
Definition: network_widget.h:63
WID_NG_REFRESH
@ WID_NG_REFRESH
'Refresh server' button.
Definition: network_widget.h:40
NetworkGameWindow
Definition: network_gui.cpp:214
NetworkTCPQueryServer
void NetworkTCPQueryServer(NetworkAddress address)
Query a server to fetch his game-info.
Definition: network.cpp:581
NWidgetFunction
static NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition: widget_type.h:1155
WID_NSS_CANCEL
@ WID_NSS_CANCEL
'Cancel' button.
Definition: network_widget.h:82
FT_SCENARIO
@ FT_SCENARIO
old or new scenario
Definition: fileio_type.h:19
WID_NSS_GAMENAME
@ WID_NSS_GAMENAME
Background for editbox to set game name.
Definition: network_widget.h:57
GUIList::SortType
uint8 SortType() const
Get the sorttype of the list.
Definition: sortlist_type.h:93
NWidgetServerListHeader::MINIMUM_NAME_WIDTH_BEFORE_NEW_HEADER
static const uint MINIMUM_NAME_WIDTH_BEFORE_NEW_HEADER
Minimum width before adding a new header.
Definition: network_gui.cpp:88
QueryString::ok_button
int ok_button
Widget button of parent window to simulate when pressing OK in OSK.
Definition: querystring_gui.h:27
Window::timeout_timer
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
Definition: window_gui.h:315
WChar
char32_t WChar
Type for wide characters, i.e.
Definition: string_type.h:35
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1104
NetworkSettings::max_spectators
uint8 max_spectators
maximum amount of spectators
Definition: settings_type.h:280
QSF_PASSWORD
@ QSF_PASSWORD
password entry box, show warning about password security
Definition: textbuf_gui.h:23
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
Scrollbar::GetCapacity
uint16 GetCapacity() const
Gets the number of visible elements of the scrollbar.
Definition: widget_type.h:631
Window::DrawSortButtonState
void DrawSortButtonState(int widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
Definition: widget.cpp:636
Window::nested_root
NWidgetBase * nested_root
Root of the nested tree.
Definition: window_gui.h:330
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:64
SetPadding
static NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1055
GUIList::Sort
bool Sort(Comp compare)
Sort the list.
Definition: sortlist_type.h:247
Window::GetScrollbar
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:309
NetworkGameInfo::companies_max
byte companies_max
Max companies allowed on server.
Definition: game_info.h:88
NetworkClientListPopupWindow::ClientListAction
Container for actions that can be executed.
Definition: network_gui.cpp:1688
NetworkGameWindow::UpdateWidgetSize
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.
Definition: network_gui.cpp:498
NetworkGameWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: network_gui.cpp:879
_network_join_waiting
uint8 _network_join_waiting
The number of clients waiting in front of us.
Definition: network_gui.cpp:1978
QSF_ACCEPT_UNCHANGED
@ QSF_ACCEPT_UNCHANGED
return success even when the text didn't change
Definition: textbuf_gui.h:20
NetworkGameWindow::vscroll
Scrollbar * vscroll
vertical scrollbar of the list of servers
Definition: network_gui.cpp:227
NetworkClientListWindow::UpdateWidgetSize
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.
Definition: network_gui.cpp:1863
StringFilter::IsEmpty
bool IsEmpty() const
Check whether any filter words were entered.
Definition: stringfilter_type.h:59
_left_button_down
bool _left_button_down
Is left mouse button pressed?
Definition: gfx.cpp:38
NetworkSettings::max_clients
uint8 max_clients
maximum amount of clients
Definition: settings_type.h:279
NetworkLobbyWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: network_gui.cpp:1520
Window::ReInit
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:995
WID_NL_MATRIX
@ WID_NL_MATRIX
List of companies.
Definition: network_widget.h:90
WID_NG_NEWGRF_MISSING
@ WID_NG_NEWGRF_MISSING
'Find missing NewGRF online' button.
Definition: network_widget.h:43
NetworkSettings::server_lang
uint8 server_lang
language of the server
Definition: settings_type.h:283
NWidgetContainer::Add
void Add(NWidgetBase *wid)
Append widget wid to container.
Definition: widget.cpp:951
StringFilter::SetFilterTerm
void SetFilterTerm(const char *str)
Set the term to filter on.
Definition: stringfilter.cpp:27
_connection_types_dropdown
static const StringID _connection_types_dropdown[]
Advertisement options in the start server window.
Definition: network_gui.cpp:53
NETWORK_NAME_LENGTH
static const uint NETWORK_NAME_LENGTH
The maximum length of the server name and map name, in bytes including '\0'.
Definition: config.h:40
NetworkClientInfo::client_playas
CompanyID client_playas
As which company is this client playing (CompanyID)
Definition: network_base.h:28
WD_MATRIX_TOP
@ WD_MATRIX_TOP
Offset at top of a matrix cell.
Definition: window_gui.h:78
NetworkStartServerWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: network_gui.cpp:1076
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
Scrollbar::ScrollTowards
void ScrollTowards(int position)
Scroll towards the given position; if the item is visible nothing happens, otherwise it will be shown...
Definition: widget_type.h:740
NetworkSettings::connect_to_ip
char connect_to_ip[NETWORK_HOSTNAME_LENGTH]
default for the "Add server" query
Definition: settings_type.h:272
WID_NSS_SPECTATORS_BTNU
@ WID_NSS_SPECTATORS_BTNU
'Max spectators' uparrow.
Definition: network_widget.h:72
WID_NSS_GAMENAME_LABEL
@ WID_NSS_GAMENAME_LABEL
Label for the game name.
Definition: network_widget.h:56
Scrollbar::GetScrolledRowFromWidget
int GetScrolledRowFromWidget(int clickpos, const Window *const w, int widget, int padding=0, int line_height=-1) const
Compute the row of a scrolled widget that a user clicked in.
Definition: widget.cpp:1972
NetworkGameWindow::OnKeyPress
EventState OnKeyPress(WChar key, uint16 keycode) override
A key has been pressed.
Definition: network_gui.cpp:791
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:50
NetworkGameWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: network_gui.cpp:785
GUIList< NetworkGameList *, StringFilter & >
WID_NJS_CANCELOK
@ WID_NJS_CANCELOK
Cancel / OK button.
Definition: network_widget.h:113
_network_server
bool _network_server
network-server is active
Definition: network.cpp:53
Textbuf::Assign
void Assign(StringID string)
Render a string into the textbuffer.
Definition: textbuf.cpp:396
NetworkGameWidgets
NetworkGameWidgets
Widgets of the NetworkGameWindow class.
Definition: network_widget.h:14
NetworkGameListAddItem
NetworkGameList * NetworkGameListAddItem(NetworkAddress address)
Add a new item to the linked gamelist.
Definition: network_gamelist.cpp:71
NetworkGameWindow::SortNetworkGameList
void SortNetworkGameList()
Sort the server list.
Definition: network_gui.cpp:340
WID_NG_CANCEL
@ WID_NG_CANCEL
'Cancel' button.
Definition: network_widget.h:50
NetworkClientInfo::client_name
char client_name[NETWORK_CLIENT_NAME_LENGTH]
Name of the client.
Definition: network_base.h:26
ShowNetworkLobbyWindow
static void ShowNetworkLobbyWindow(NetworkGameList *ngl)
Show the networklobbywindow with the selected server.
Definition: network_gui.cpp:1615
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:63
WC_CLIENT_LIST
@ WC_CLIENT_LIST
Client list; Window numbers:
Definition: window_type.h:472
Window::CreateNestedTree
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1832
WC_COMPANY_PASSWORD_WINDOW
@ WC_COMPANY_PASSWORD_WINDOW
Company password query; Window numbers:
Definition: window_type.h:497
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
NetworkGameWindow::servers
GUIGameServerList servers
list with game servers.
Definition: network_gui.cpp:225
NetworkJoinStatus
NetworkJoinStatus
Status of the clients during joining.
Definition: network_internal.h:53
WID_NG_LASTJOINED_LABEL
@ WID_NG_LASTJOINED_LABEL
Label "Last joined server:".
Definition: network_widget.h:33
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:57
NetworkCompanyPasswordWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: network_gui.cpp:2150
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1133
NetworkServerGameInfo::map_name
char map_name[NETWORK_NAME_LENGTH]
Map which is played ["random" for a randomized map].
Definition: game_info.h:64
NetworkGameWindow::NGameNameSorter
static bool NGameNameSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by name.
Definition: network_gui.cpp:273
NetworkClientListPopupWindow::actions
std::vector< ClientListAction > actions
Actions to execute.
Definition: network_gui.cpp:1696
WID_NSS_COMPANIES_BTND
@ WID_NSS_COMPANIES_BTND
'Max companies' downarrow.
Definition: network_widget.h:66
WC_CLIENT_LIST_POPUP
@ WC_CLIENT_LIST_POPUP
Popup for the client list; Window numbers:
Definition: window_type.h:478
NetworkClientListPopupWindow::UpdateWidgetSize
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.
Definition: network_gui.cpp:1741
ShowMissingContentWindow
void ShowMissingContentWindow(const GRFConfig *list)
Show the content list window with all missing grfs from the given list.
Definition: newgrf_gui.cpp:1543
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:679
NetworkCompanyPasswordWindow::password_editbox
QueryString password_editbox
Password editbox.
Definition: network_gui.cpp:2118
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:35
MAX_CLIENTS
static const uint MAX_CLIENTS
How many clients can we have.
Definition: network_type.h:16
NetworkGameInfo::use_password
bool use_password
Is this server passworded?
Definition: game_info.h:83
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:250
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:939
NetworkJoinStatusWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: network_gui.cpp:1991
NWidgetLeaf
Leaf widget.
Definition: widget_type.h:779
WID_NL_TEXT
@ WID_NL_TEXT
Heading text.
Definition: network_widget.h:88
NetworkGameWindow::OnEditboxChanged
void OnEditboxChanged(int wid) override
The text in an editbox has been edited.
Definition: network_gui.cpp:852
WD_FRAMETEXT_TOP
@ WD_FRAMETEXT_TOP
Top offset of the text of the frame.
Definition: window_gui.h:72
WID_NSS_BACKGROUND
@ WID_NSS_BACKGROUND
Background of the window.
Definition: network_widget.h:55
DESTTYPE_TEAM
@ DESTTYPE_TEAM
Send message/notice to everyone playing the same company (Team)
Definition: network_type.h:83
WID_NG_NEWGRF_MISSING_SEL
@ WID_NG_NEWGRF_MISSING_SEL
Selection widget for the above button.
Definition: network_widget.h:44
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:79
DrawString
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.
Definition: gfx.cpp:640
UpdateNetworkGameWindow
void UpdateNetworkGameWindow()
Update the network new window because a new server is found on the network.
Definition: network_gui.cpp:77
NetworkUDPSearchGame
void NetworkUDPSearchGame()
Find all servers.
Definition: network_udp.cpp:478
WID_NG_FILTER
@ WID_NG_FILTER
Panel with the edit box to enter the search text.
Definition: network_widget.h:20
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
DeleteWindowByClass
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
Definition: window.cpp:1178
StringFilter::AddLine
void AddLine(const char *str)
Pass another text line from the current item to the filter.
Definition: stringfilter.cpp:104
network_gui.h
NetworkGameInfo::map_width
uint16 map_width
Map width.
Definition: game_info.h:75
NetworkCompanyPasswordWindow
Definition: network_gui.cpp:2117
_network_join_status
NetworkJoinStatus _network_join_status
The status of joining.
Definition: network_gui.cpp:1977
WindowNumber
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:711
WID_CLP_PANEL
@ WID_CLP_PANEL
Panel of the window.
Definition: network_widget.h:107
WID_NG_MAPSIZE
@ WID_NG_MAPSIZE
'Map size' button.
Definition: network_widget.h:25
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition: gfx_func.h:106
NetworkGameList::address
NetworkAddress address
The connection info of the game server.
Definition: network_gamelist.h:20
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_func.h:97
NetworkGameWindow::NGameClientSorter
static bool NGameClientSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by the amount of clients online on a server.
Definition: network_gui.cpp:284
GUIList::SetSortType
void SetSortType(uint8 n_type)
Set the sorttype of the list.
Definition: sortlist_type.h:103
Window::HandleButtonClick
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
Definition: window.cpp:635
NETWORK_CLIENT_NAME_LENGTH
static const uint NETWORK_CLIENT_NAME_LENGTH
The maximum length of a client's name, in bytes including '\0'.
Definition: config.h:47
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
NWidgetBase::smallest_y
uint smallest_y
Smallest vertical size of the widget in a filled window.
Definition: widget_type.h:180
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:598
WD_FRAMETEXT_LEFT
@ WD_FRAMETEXT_LEFT
Left offset of the text of the frame.
Definition: window_gui.h:70
NetworkGameInfo::version_compatible
bool version_compatible
Can we connect to this server or not? (based on server_revision)
Definition: game_info.h:81
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1871
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:199
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:919
GENERATE_NEW_SEED
static const uint32 GENERATE_NEW_SEED
Create a new random seed.
Definition: genworld.h:24
NetworkStartServerWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: network_gui.cpp:1040
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1023
NetworkLobbyWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: network_gui.cpp:1384
QueryString
Data stored about a string that can be modified in the GUI.
Definition: querystring_gui.h:20
WID_NCP_SAVE_AS_DEFAULT_PASSWORD
@ WID_NCP_SAVE_AS_DEFAULT_PASSWORD
Toggle 'button' for saving the current password as default password.
Definition: network_widget.h:121
NetworkLobbyWindow::server
NetworkGameList * server
Selected server.
Definition: network_gui.cpp:1333
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:842
GUIList::SetFilterFuncs
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
Definition: sortlist_type.h:341
WID_NSS_LANGUAGE_LABEL
@ WID_NSS_LANGUAGE_LABEL
Label for 'language spoken'.
Definition: network_widget.h:74
Textbuf::buf
char *const buf
buffer in which text is saved
Definition: textbuf_type.h:32
Window::querystrings
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition: window_gui.h:329
network_base.h
WID_NSS_CLIENTS_BTNU
@ WID_NSS_CLIENTS_BTNU
'Max clients' uparrow.
Definition: network_widget.h:64
NWidgetServerListHeader
Full blown container to make it behave exactly as we want :)
Definition: network_gui.cpp:87
DrawStringMultiLine
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.
Definition: gfx.cpp:763
WID_NSS_SPECTATORS_BTND
@ WID_NSS_SPECTATORS_BTND
'Max spectators' downarrow.
Definition: network_widget.h:70
WID_NG_SCROLLBAR
@ WID_NG_SCROLLBAR
Scrollbar of matrix.
Definition: network_widget.h:31
_network_game_list
NetworkGameList * _network_game_list
Game list of this client.
Definition: network_gamelist.cpp:23
WID_NG_MAIN
@ WID_NG_MAIN
Main panel.
Definition: network_widget.h:15
NetworkLobbyWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: network_gui.cpp:1375
IsInsideMM
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
Definition: math_func.hpp:204
NetworkStartServerWindow::OnEditboxChanged
void OnEditboxChanged(int wid) override
The text in an editbox has been edited.
Definition: network_gui.cpp:1197
NWidgetBase::prev
NWidgetBase * prev
Pointer to previous widget in container. Managed by parent container widget.
Definition: widget_type.h:189
WID_NSS_PLAY_SCENARIO
@ WID_NSS_PLAY_SCENARIO
Play scenario button.
Definition: network_widget.h:79
NetworkGameWindow::OnRealtimeTick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition: network_gui.cpp:884
WID_NSS_CONNTYPE_BTN
@ WID_NSS_CONNTYPE_BTN
'Connection type' droplist button.
Definition: network_widget.h:60
WindowDesc
High level window description.
Definition: window_gui.h:166
NetworkUDPQueryServer
void NetworkUDPQueryServer(NetworkAddress address, bool manually)
Query a specific server.
Definition: network_udp.cpp:112
NetworkJoinStatusWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: network_gui.cpp:2051
WID_NL_NEW
@ WID_NL_NEW
'New company' button.
Definition: network_widget.h:94
COMPANY_FIRST
@ COMPANY_FIRST
First company, same as owner.
Definition: company_type.h:22
NetworkLobbyWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: network_gui.cpp:1559
WID_NG_CLIENTS
@ WID_NG_CLIENTS
'Clients' button.
Definition: network_widget.h:24
NetworkClientInfo::GetByClientID
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
Definition: network.cpp:111
NetworkGameWindow::last_joined
NetworkGameList * last_joined
the last joined server
Definition: network_gui.cpp:224
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:438
WID_NG_ADD
@ WID_NG_ADD
'Add server' button.
Definition: network_widget.h:48
NWidgetServerListHeader::AssignSizePosition
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
Definition: network_gui.cpp:139
GUITimer
Definition: guitimer_func.h:13
NetworkGameInfo::start_date
Date start_date
When the game started.
Definition: game_info.h:73
GUIList::IsDescSortOrder
bool IsDescSortOrder() const
Check if the sort order is descending.
Definition: sortlist_type.h:223
COMPANY_NEW_COMPANY
@ COMPANY_NEW_COMPANY
The client wants a new company.
Definition: company_type.h:34
WID_NSS_COMPANIES_BTNU
@ WID_NSS_COMPANIES_BTNU
'Max companies' uparrow.
Definition: network_widget.h:68
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:154
NetworkStartServerWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: network_gui.cpp:1215
Listing
Data structure describing how to show the list (what sort direction and criteria).
Definition: sortlist_type.h:30
GUIList::SetFilterState
void SetFilterState(bool state)
Enable or disable the filter.
Definition: sortlist_type.h:302
SLO_LOAD
@ SLO_LOAD
File is being loaded.
Definition: fileio_type.h:49
NetworkGameInfo::server_lang
byte server_lang
Language of the server (we should make a nice table for this)
Definition: game_info.h:85
NetworkSettings::server_password
char server_password[NETWORK_PASSWORD_LENGTH]
password for joining this server
Definition: settings_type.h:266
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:323
NetworkUDPQueryMasterServer
void NetworkUDPQueryMasterServer()
Request the the server-list from the master server.
Definition: network_udp.cpp:462
NetworkClientListWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: network_gui.cpp:1879
NetworkClientListWindow
Main handle for clientlist.
Definition: network_gui.cpp:1825
NetworkSettings::last_host
char last_host[NETWORK_HOSTNAME_LENGTH]
IP address of the last joined server.
Definition: settings_type.h:285
NWidgetContainer::tail
NWidgetBase * tail
Pointer to last widget in container.
Definition: widget_type.h:392
NetworkLobbyWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: network_gui.cpp:1397
ShowGenerateLandscape
void ShowGenerateLandscape()
Start with a normal game.
Definition: genworld_gui.cpp:1000
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1861
WWT_EDITBOX
@ WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:69
NWidgetServerListHeader::SetupSmallestSize
void SetupSmallestSize(Window *w, bool init_array) override
Definition: network_gui.cpp:113
NetworkStartServerWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: network_gui.cpp:1181
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:321
WN_NETWORK_WINDOW_START
@ WN_NETWORK_WINDOW_START
Network start server.
Definition: window_type.h:30
NetworkStartServerWindow::name_editbox
QueryString name_editbox
Server name editbox.
Definition: network_gui.cpp:1028
NetworkGameInfo::companies_on
byte companies_on
How many started companies do we have.
Definition: game_info.h:87
WF_WHITE_BORDER
@ WF_WHITE_BORDER
Window white border counter bit mask.
Definition: window_gui.h:240
NetworkLobbyWindow::company
CompanyID company
Selected company.
Definition: network_gui.cpp:1332
GUIList< NetworkGameList *, StringFilter & >::SortFunction
bool SortFunction(const NetworkGameList * &, const NetworkGameList * &)
Signature of sort function.
Definition: sortlist_type.h:48
NWidgetResizeBase::SetResize
void SetResize(uint resize_x, uint resize_y)
Set resize step of the widget.
Definition: widget.cpp:848
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:984
GUIList::SetListing
void SetListing(Listing l)
Import sort conditions.
Definition: sortlist_type.h:130
NWidgetBase::smallest_x
uint smallest_x
Smallest horizontal size of the widget in a filled window.
Definition: widget_type.h:179
WD_FRAMERECT_LEFT
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:60
WID_NSS_SPECTATORS_TXT
@ WID_NSS_SPECTATORS_TXT
'Max spectators' text.
Definition: network_widget.h:71
NWidgetBase::AssignSizePosition
virtual void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)=0
NetworkGameWindow::NGameDateSorter
static bool NGameDateSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by current date.
Definition: network_gui.cpp:306
IsInsideBS
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.
Definition: math_func.hpp:188
NetworkSettings::default_company_pass
char default_company_pass[NETWORK_PASSWORD_LENGTH]
default password for new companies in encrypted form
Definition: settings_type.h:271
ClientID
ClientID
'Unique' identifier to be given to clients
Definition: network_type.h:39
WID_NCP_WARNING
@ WID_NCP_WARNING
Warning text about password security.
Definition: network_widget.h:122
WD_PAR_VSEP_NORMAL
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
Definition: window_gui.h:137
WD_FRAMERECT_RIGHT
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:61
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:719
WD_FRAMERECT_BOTTOM
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:63
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:102
NetworkClientListWindow::OnMouseOver
void OnMouseOver(Point pt, int widget) override
The mouse is currently moving over the window or has just moved outside of the window.
Definition: network_gui.cpp:1947
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:124
WID_NG_MATRIX
@ WID_NG_MATRIX
Panel with list of games.
Definition: network_widget.h:30
WD_FRAMETEXT_BOTTOM
@ WD_FRAMETEXT_BOTTOM
Bottom offset of the text of the frame.
Definition: window_gui.h:73
NetworkGameWindow::filter_editbox
QueryString filter_editbox
Editbox for filter on servers.
Definition: network_gui.cpp:229
NetworkGameWindow::NGameYearsSorter
static bool NGameYearsSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by the number of days the game is running.
Definition: network_gui.cpp:313
NetworkClientListPopupWindow::ClientListAction::proc
ClientList_Action_Proc * proc
Action to execute.
Definition: network_gui.cpp:1690
NetworkGameWindow::requery_timer
GUITimer requery_timer
Timer for network requery.
Definition: network_gui.cpp:230
WID_NG_HEADER
@ WID_NG_HEADER
Header container of the matrix.
Definition: network_widget.h:22
SetMatrixDataTip
static NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1041
WID_NSS_CONNTYPE_LABEL
@ WID_NSS_CONNTYPE_LABEL
Label for 'connection type'.
Definition: network_widget.h:59
WID_NSS_GENERATE_GAME
@ WID_NSS_GENERATE_GAME
New game button.
Definition: network_widget.h:77
NetworkAddress::GetPort
uint16 GetPort() const
Get the port.
Definition: address.cpp:35
ConvertDateToYMD
void ConvertDateToYMD(Date date, YearMonthDay *ymd)
Converts a Date to a Year, Month & Day.
Definition: date.cpp:94
WID_NG_NEWGRF
@ WID_NG_NEWGRF
'NewGRF Settings' button.
Definition: network_widget.h:41
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:393
Window::parent
Window * parent
Parent window.
Definition: window_gui.h:338
MAX_COMPANIES
@ MAX_COMPANIES
Maximum number of companies.
Definition: company_type.h:23
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
WID_NG_CLIENT
@ WID_NG_CLIENT
Panel with editbox to set client name.
Definition: network_widget.h:18
NetworkCompanyPasswordWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: network_gui.cpp:2168
WID_NJS_BACKGROUND
@ WID_NJS_BACKGROUND
Background of the window.
Definition: network_widget.h:112
NETWORK_COMPANY_PASSWORD
@ NETWORK_COMPANY_PASSWORD
The password of the company.
Definition: network_type.h:74
NetworkDisconnect
void NetworkDisconnect(bool blocking, bool close_admins)
We want to disconnect from the host/clients.
Definition: network.cpp:800
ShowQueryString
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
Definition: misc_gui.cpp:1141
Window::left
int left
x position of left edge of the window
Definition: window_gui.h:318
WID_NCP_CANCEL
@ WID_NCP_CANCEL
Close the window without changing anything.
Definition: network_widget.h:123
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:311
COMPANY_INACTIVE_CLIENT
@ COMPANY_INACTIVE_CLIENT
The client is joining.
Definition: company_type.h:33
NWidgetServerListHeader::IsWidgetVisible
bool IsWidgetVisible(NetworkGameWidgets widget) const
Checks whether the given widget is actually visible.
Definition: network_gui.cpp:207
WF_TIMEOUT
@ WF_TIMEOUT
Window timeout counter.
Definition: window_gui.h:232
CLIENT_ID_SERVER
@ CLIENT_ID_SERVER
Servers always have this ID.
Definition: network_type.h:41
WN_NETWORK_WINDOW_GAME
@ WN_NETWORK_WINDOW_GAME
Network game window.
Definition: window_type.h:27
WID_NCP_LABEL
@ WID_NCP_LABEL
Label in front of the password field.
Definition: network_widget.h:119
NetworkGameWindow::blot_offset
int blot_offset
Left offset for green/yellow/red compatibility icon.
Definition: network_gui.cpp:233
NetworkClientListWindow::CheckClientListHeight
bool CheckClientListHeight()
Finds the amount of clients and set the height correct.
Definition: network_gui.cpp:1843
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:60
NetworkSettings::last_port
uint16 last_port
port of the last joined server
Definition: settings_type.h:286
NetworkGameWindow::BuildGUINetworkGameList
void BuildGUINetworkGameList()
(Re)build the GUI network game list (a.k.a.
Definition: network_gui.cpp:241
NetworkStartServerWindow::widget_id
byte widget_id
The widget that has the pop-up input menu.
Definition: network_gui.cpp:1027
WID_NSS_LANGUAGE_BTN
@ WID_NSS_LANGUAGE_BTN
'Language spoken' droplist button.
Definition: network_widget.h:75
DrawSprite
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:978
WDF_MODAL
@ WDF_MODAL
The window is a modal child of some other window, meaning the parent is 'inactive'.
Definition: window_gui.h:209
network_client.h
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
NetworkSettings::server_name
char server_name[NETWORK_NAME_LENGTH]
name of the server
Definition: settings_type.h:265
ShowDropDownMenu
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width)
Show a dropdown menu window near a widget of the parent window.
Definition: dropdown.cpp:488
NWidgetContainer::head
NWidgetBase * head
Pointer to first widget in container.
Definition: widget_type.h:391
NetworkStartServerWindow::UpdateWidgetSize
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.
Definition: network_gui.cpp:1065
PopupClientList
static void PopupClientList(ClientID client_id, int x, int y)
Show the popup (action list)
Definition: network_gui.cpp:1797
WID_NG_YEARS
@ WID_NG_YEARS
'Years' button.
Definition: network_widget.h:27
WD_FRAMETEXT_RIGHT
@ WD_FRAMETEXT_RIGHT
Right offset of the text of the frame.
Definition: window_gui.h:71
NetworkGameInfo::server_name
char server_name[NETWORK_NAME_LENGTH]
Server name.
Definition: game_info.h:77
Window::SetFocusedWidget
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
Definition: window.cpp:495
ShowSaveLoadDialog
void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Launch save/load dialog in the given mode.
Definition: fios_gui.cpp:920
FT_SAVEGAME
@ FT_SAVEGAME
old or new savegame
Definition: fileio_type.h:18
PC_BLACK
static const uint8 PC_BLACK
Black palette colour.
Definition: gfx_func.h:206
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:313
GfxFillRect
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.
Definition: gfx.cpp:114
ResizeInfo::step_height
uint step_height
Step-size of height resize changes.
Definition: window_gui.h:218
GUIList::ToggleSortOrder
void ToggleSortOrder()
Toggle the sort order Since that is the worst condition for the sort function reverse the list here.
Definition: sortlist_type.h:233
GUIList::NeedResort
bool NeedResort()
Check if a resort is needed next loop If used the resort timer will decrease every call till 0.
Definition: sortlist_type.h:199
CS_ALPHANUMERAL
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
Definition: string_type.h:27
NetworkStartServerWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: network_gui.cpp:1204
NWidgetBase::current_y
uint current_y
Current vertical size (after resizing).
Definition: widget_type.h:183
WID_NL_CANCEL
@ WID_NL_CANCEL
'Cancel' button.
Definition: network_widget.h:97
WID_NSS_PLAY_HEIGHTMAP
@ WID_NSS_PLAY_HEIGHTMAP
Play heightmap button.
Definition: network_widget.h:80
StartNewGameWithoutGUI
void StartNewGameWithoutGUI(uint32 seed)
Start a normal game without the GUI.
Definition: genworld_gui.cpp:1021
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
NetworkClientInfo::client_id
ClientID client_id
Client identifier (same as ClientState->client_id)
Definition: network_base.h:25
WID_NG_DATE
@ WID_NG_DATE
'Date' button.
Definition: network_widget.h:26
PC_GREY
static const uint8 PC_GREY
Grey palette colour.
Definition: gfx_func.h:208
NETWORK_PASSWORD_LENGTH
static const uint NETWORK_PASSWORD_LENGTH
The maximum length of the password, in bytes including '\0' (must be >= NETWORK_SERVER_ID_LENGTH)
Definition: config.h:45
NWidgetBase::next
NWidgetBase * next
Pointer to next widget in container. Managed by parent container widget.
Definition: widget_type.h:188
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
WID_NL_SCROLLBAR
@ WID_NL_SCROLLBAR
Scroll bar.
Definition: network_widget.h:91
Window::nested_array
NWidgetBase ** nested_array
Array of pointers into the tree. Do not access directly, use Window::GetWidget() instead.
Definition: window_gui.h:331
NWidgetResizeBase::SetFill
void SetFill(uint fill_x, uint fill_y)
Set the filling of the widget from initial size.
Definition: widget.cpp:837
WID_NL_HEADER
@ WID_NL_HEADER
Header above list of companies.
Definition: network_widget.h:89
NetworkClientListPopupWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: network_gui.cpp:1754
_network_own_client_id
ClientID _network_own_client_id
Our client identifier.
Definition: network.cpp:58
GetStringHeight
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition: gfx.cpp:689
NetworkSettings::server_advertise
bool server_advertise
advertise the server to the masterserver
Definition: settings_type.h:269
NetworkGameWindow::DrawServerLine
void DrawServerLine(const NetworkGameList *cur_item, uint y, bool highlight) const
Draw a single server line.
Definition: network_gui.cpp:373
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:913
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:66
GUIList::NeedRebuild
bool NeedRebuild() const
Check if a rebuild is needed.
Definition: sortlist_type.h:362
NetworkClientListPopupWindow::OnInitialPosition
Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
Compute the initial position of the window.
Definition: network_gui.cpp:1736
NetworkServerKickClient
void NetworkServerKickClient(ClientID client_id, const char *reason)
Kick a single client.
Definition: network_server.cpp:2108
WID_NG_INFO
@ WID_NG_INFO
Third button in the game list panel.
Definition: network_widget.h:28
WID_NSS_CLIENTS_LABEL
@ WID_NSS_CLIENTS_LABEL
Label for 'max clients'.
Definition: network_widget.h:61
YearMonthDay::year
Year year
Year (0...)
Definition: date_type.h:104
NetworkJoinStatusWindow::UpdateWidgetSize
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.
Definition: network_gui.cpp:2025
NetworkGameWindow::ScrollToSelectedServer
void ScrollToSelectedServer()
Scroll the list up or down to the currently selected server.
Definition: network_gui.cpp:446
WID_NCP_BACKGROUND
@ WID_NCP_BACKGROUND
Background of the window.
Definition: network_widget.h:118
NetworkGameWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: network_gui.cpp:544
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
NetworkGameWindow::server
NetworkGameList * server
selected server
Definition: network_gui.cpp:223
WID_NG_NEWGRF_SEL
@ WID_NG_NEWGRF_SEL
Selection 'widget' to hide the NewGRF settings.
Definition: network_widget.h:42
NWidgetBase::fill_y
uint fill_y
Vertical fill stepsize (from initial size, 0 means not resizable).
Definition: widget_type.h:173
SBS_DOWN
@ SBS_DOWN
Sort ascending.
Definition: window_gui.h:224
QueryString::cancel_button
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
Definition: querystring_gui.h:28
NetworkAddress
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
Definition: address.h:29
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1008
WID_NG_SEARCH_LAN
@ WID_NG_SEARCH_LAN
'Search LAN server' button.
Definition: network_widget.h:47
WID_NL_REFRESH
@ WID_NL_REFRESH
'Refresh server' button.
Definition: network_widget.h:96
WID_NG_LASTJOINED
@ WID_NG_LASTJOINED
Info about the last joined server.
Definition: network_widget.h:34
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:77
Pool::PoolItem<&_networkclientinfo_pool >::Iterate
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:378
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
DeleteWindowById
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1165
NetworkStartServerWindow
Definition: network_gui.cpp:1026
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:185
NetworkGameInfo::clients_max
byte clients_max
Max clients allowed on server.
Definition: game_info.h:86
WIDGET_LIST_END
static const int WIDGET_LIST_END
indicate the end of widgets' list for vararg functions
Definition: widget_type.h:20
network_udp.h
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:56
WD_BEVEL_RIGHT
@ WD_BEVEL_RIGHT
Width of right bevel border.
Definition: window_gui.h:55
NetworkStartServerWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: network_gui.cpp:1085
WID_NCP_PASSWORD
@ WID_NCP_PASSWORD
Input field for the password.
Definition: network_widget.h:120
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:179
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1123
PC_DARK_BLUE
static const uint8 PC_DARK_BLUE
Dark blue palette colour.
Definition: gfx_func.h:226
COMPANY_SPECTATOR
@ COMPANY_SPECTATOR
The client is spectating.
Definition: company_type.h:35
NWidgetBase::fill_x
uint fill_x
Horizontal fill stepsize (from initial size, 0 means not resizable).
Definition: widget_type.h:172
WC_NETWORK_WINDOW
@ WC_NETWORK_WINDOW
Network window; Window numbers:
Definition: window_type.h:466
GUIList< NetworkGameList *, StringFilter & >::FilterFunction
bool CDECL FilterFunction(const NetworkGameList * *, StringFilter &)
Signature of filter function.
Definition: sortlist_type.h:49
WID_NG_SEARCH_INTERNET
@ WID_NG_SEARCH_INTERNET
'Search internet server' button.
Definition: network_widget.h:46
SetDParamMaxValue
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.
Definition: strings.cpp:104
WID_NL_DETAILS
@ WID_NL_DETAILS
Company details.
Definition: network_widget.h:92
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:956
NetworkServerKickOrBanIP
uint NetworkServerKickOrBanIP(ClientID client_id, bool ban, const char *reason)
Ban, or kick, everyone joined from the given client's IP.
Definition: network_server.cpp:2120
WC_NETWORK_STATUS_WINDOW
@ WC_NETWORK_STATUS_WINDOW
Network status window; Window numbers:
Definition: window_type.h:485
StringFilter::ResetState
void ResetState()
Reset the matching state to process a new item.
Definition: stringfilter.cpp:88
NWidgetServerListHeader::visible
bool visible[6]
The visible headers.
Definition: network_gui.cpp:89
WID_NSS_COMPANIES_LABEL
@ WID_NSS_COMPANIES_LABEL
Label for 'max companies'.
Definition: network_widget.h:65
NetworkGameWindow::UpdateListPos
void UpdateListPos()
Set this->list_pos to match this->server.
Definition: network_gui.cpp:346
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
ClientList_Action_Proc
void ClientList_Action_Proc(const NetworkClientInfo *ci)
Prototype for ClientList actions.
Definition: network_gui.cpp:1646
NetworkLobbyWindow::UpdateWidgetSize
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.
Definition: network_gui.cpp:1357
WID_NG_NAME
@ WID_NG_NAME
'Name' button.
Definition: network_widget.h:23
GUIList::GetListing
Listing GetListing() const
Export current sort conditions.
Definition: sortlist_type.h:116
NetworkClientListPopupWindow
Popup selection window to chose an action to perform.
Definition: network_gui.cpp:1686
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:175
Window::IsWidgetLowered
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:494
NetworkAddress::CompareTo
int CompareTo(NetworkAddress &address)
Compare the address of this class with the address of another.
Definition: address.h:130
NetworkPasswordType
NetworkPasswordType
The type of password we're asking for.
Definition: network_type.h:72
EventState
EventState
State of handling an event.
Definition: window_type.h:717
WID_NG_JOIN
@ WID_NG_JOIN
'Join game' button.
Definition: network_widget.h:39
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:640
ClientNetworkGameSocketHandler::SendCompanyPassword
static NetworkRecvStatus SendCompanyPassword(const char *password)
Set the company password as requested.
Definition: network_client.cpp:395
StringFilter::GetState
bool GetState() const
Get the matching state of the current item.
Definition: stringfilter_type.h:69
WID_NSS_SETPWD
@ WID_NSS_SETPWD
'Set password' button.
Definition: network_widget.h:58
seprintf
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Definition: string.cpp:460
FT_HEIGHTMAP
@ FT_HEIGHTMAP
heightmap file
Definition: fileio_type.h:20
WID_NSS_CLIENTS_BTND
@ WID_NSS_CLIENTS_BTND
'Max clients' downarrow.
Definition: network_widget.h:62
GUIList::Filter
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
Definition: sortlist_type.h:318
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1848
WID_NG_START
@ WID_NG_START
'Start server' button.
Definition: network_widget.h:49
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
NWidgetServerListHeader::Draw
void Draw(const Window *w) override
Definition: network_gui.cpp:179
SM_MENU
@ SM_MENU
Switch to game intro menu.
Definition: openttd.h:31
QueryString::ACTION_CLEAR
static const int ACTION_CLEAR
Clear editbox.
Definition: querystring_gui.h:24
NWidgetContainer
Baseclass for container widgets.
Definition: widget_type.h:377
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:319
NetworkGameInfo::game_date
Date game_date
Current date.
Definition: game_info.h:74
GUIList::ForceResort
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
Definition: sortlist_type.h:213
NC_NONE
@ NC_NONE
All flags cleared.
Definition: widget_type.h:437
GUITimer::Elapsed
bool Elapsed(uint delta)
Test if a timer has elapsed.
Definition: guitimer_func.h:55
ShowNetworkChatQueryWindow
void ShowNetworkChatQueryWindow(DestType type, int dest)
Show the chat window.
Definition: network_chat_gui.cpp:553
DrawFrameRect
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition: widget.cpp:175
NetworkGameList
Structure with information shown in the game list (GUI)
Definition: network_gamelist.h:18
network.h
NetworkChangeCompanyPassword
const char * NetworkChangeCompanyPassword(CompanyID company_id, const char *password)
Change the company password of a given company.
Definition: network.cpp:154
NetworkGameListRequery
void NetworkGameListRequery()
Requeries the (game) servers we have not gotten a reply from.
Definition: network_gamelist.cpp:140
WD_BEVEL_LEFT
@ WD_BEVEL_LEFT
Width of left bevel border.
Definition: window_gui.h:54
WD_MATRIX_BOTTOM
@ WD_MATRIX_BOTTOM
Offset at bottom of a matrix cell.
Definition: window_gui.h:79
MILLISECONDS_PER_TICK
static const uint MILLISECONDS_PER_TICK
The number of milliseconds per game tick.
Definition: gfx_type.h:310
GUIList::ForceRebuild
void ForceRebuild()
Force that a rebuild is needed.
Definition: sortlist_type.h:370
Window::ToggleWidgetLoweredState
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
Definition: window_gui.h:464
WID_NG_CLIENT_LABEL
@ WID_NG_CLIENT_LABEL
Label in front of client name edit box.
Definition: network_widget.h:17
WID_NL_BACKGROUND
@ WID_NL_BACKGROUND
Background of the window.
Definition: network_widget.h:87
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:369
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:320
YearMonthDay
Data structure to convert between Date and triplet (year, month, and day).
Definition: date_type.h:103
NetworkGameInfo::server_revision
char server_revision[NETWORK_REVISION_LENGTH]
The version number the server is using (e.g.: 'r304' or 0.5.0)
Definition: game_info.h:79
NetworkCompanyPasswordWindow::warning_size
Dimension warning_size
How much space to use for the warning text.
Definition: network_gui.cpp:2119
SPR_FLAGS_BASE
static const SpriteID SPR_FLAGS_BASE
Flags sprites (in same order as enum NetworkLanguage)
Definition: sprites.h:291
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, int widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition: widget.cpp:1986
ClientSettings::network
NetworkSettings network
settings related to the network
Definition: settings_type.h:582
Window::SortButtonWidth
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
Definition: widget.cpp:656
WN_NETWORK_WINDOW_LOBBY
@ WN_NETWORK_WINDOW_LOBBY
Network lobby window.
Definition: window_type.h:28
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1085
NetworkGameWindow::lock_offset
int lock_offset
Left offset for lock icon.
Definition: network_gui.cpp:232
WID_NSS_COMPANIES_TXT
@ WID_NSS_COMPANIES_TXT
'Max companies' text.
Definition: network_widget.h:67
DESTTYPE_BROADCAST
@ DESTTYPE_BROADCAST
Send message/notice to all clients (All)
Definition: network_type.h:82
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:186
INVALID_COMPANY
@ INVALID_COMPANY
An invalid company.
Definition: company_type.h:30
NetworkClientListWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: network_gui.cpp:1932
NETWORK_HOSTNAME_LENGTH
static const uint NETWORK_HOSTNAME_LENGTH
The maximum length of the host name, in bytes including '\0'.
Definition: config.h:42
strnatcmp
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
Definition: string.cpp:643
NetworkGameInfo::spectators_on
byte spectators_on
How many spectators do we have?
Definition: game_info.h:89
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:992
NetworkGameList::next
NetworkGameList * next
Next pointer to make a linked game list.
Definition: network_gamelist.h:24
network_gamelist.h
DESTTYPE_CLIENT
@ DESTTYPE_CLIENT
Send message/notice to only a certain client (Private)
Definition: network_type.h:84
Window
Data structure for an opened window.
Definition: window_gui.h:277
GUIList::RebuildDone
void RebuildDone()
Notify the sortlist that the rebuild is done.
Definition: sortlist_type.h:380
SizingType
SizingType
Different forms of sizing nested widgets, using NWidgetBase::AssignSizePosition()
Definition: widget_type.h:109
WID_NCP_OK
@ WID_NCP_OK
Safe the password etc.
Definition: network_widget.h:124
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:318
Window::RaiseWidget
void RaiseWidget(byte widget_index)
Marks a widget as raised.
Definition: window_gui.h:484
WID_NSS_LOAD_GAME
@ WID_NSS_LOAD_GAME
Load game button.
Definition: network_widget.h:78
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:602
MAX_MAP_SIZE
static const uint MAX_MAP_SIZE
Maximal map size = 4096.
Definition: map_type.h:66
_network_host_list
StringList _network_host_list
The servers we know.
Definition: network.cpp:63
NetworkGameWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: network_gui.cpp:581
NetworkGameInfo::map_height
uint16 map_height
Map height.
Definition: game_info.h:76
NetworkGameList::info
NetworkGameInfo info
The game information of this server.
Definition: network_gamelist.h:19
NetworkServerGameInfo::clients_on
byte clients_on
Current count of clients on server.
Definition: game_info.h:65
SBS_UP
@ SBS_UP
Sort descending.
Definition: window_gui.h:225
strecpy
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
Definition: string.cpp:112
WN_NETWORK_STATUS_WINDOW_JOIN
@ WN_NETWORK_STATUS_WINDOW_JOIN
Network join status.
Definition: window_type.h:32
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:78
Window::IsWidgetDisabled
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
Definition: window_gui.h:422
NWidgetCore
Base class for a 'real' widget.
Definition: widget_type.h:292
Window::SetWidgetDirty
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:597
NetworkGameInfo::grfconfig
GRFConfig * grfconfig
List of NewGRF files used.
Definition: game_info.h:72
NetworkGameWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: network_gui.cpp:686
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
CursorVars::pos
Point pos
logical mouse position
Definition: gfx_type.h:117
WID_NG_DETAILS
@ WID_NG_DETAILS
Panel with game details.
Definition: network_widget.h:37
NWidgetBase::resize_x
uint resize_x
Horizontal resize step (0 means not resizable).
Definition: widget_type.h:174
NetworkCompanyInfo
Company information stored at the client side.
Definition: network_gui.h:28
WID_NG_FILTER_LABEL
@ WID_NG_FILTER_LABEL
Label in front of the filter/search edit box.
Definition: network_widget.h:19
NetworkGameListRemoveItem
void NetworkGameListRemoveItem(NetworkGameList *remove)
Remove an item from the gamelist linked list.
Definition: network_gamelist.cpp:110
NetworkJoinStatusWindow
Definition: network_gui.cpp:1982
NetworkClientListPopupWindow::OnMouseLoop
void OnMouseLoop() override
Called for every mouse loop run, which is at least once per (game) tick.
Definition: network_gui.cpp:1773
CLRBITS
#define CLRBITS(x, y)
Clears several bits in a variable.
Definition: bitmath_func.hpp:166
NetworkClientListPopupWindow::AddAction
void AddAction(StringID name, ClientList_Action_Proc *proc)
Add an action to the list of actions to execute.
Definition: network_gui.cpp:1703
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:182
NetworkGameList::online
bool online
False if the server did not respond (default status)
Definition: network_gamelist.h:21
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:385
SetDParamMaxDigits
void SetDParamMaxDigits(uint n, uint count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
Definition: strings.cpp:120
NetworkJoinStatusWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: network_gui.cpp:2060
NWidgetResizeBase::SetMinimalSize
void SetMinimalSize(uint min_x, uint min_y)
Set minimal size of the widget.
Definition: widget.cpp:815
_network_join_bytes
uint32 _network_join_bytes
The number of bytes we already downloaded.
Definition: network_gui.cpp:1979
WID_CL_PANEL
@ WID_CL_PANEL
Panel of the window.
Definition: network_widget.h:102
NetworkGameWindow::list_pos
ServerListPosition list_pos
position of the selected server
Definition: network_gui.cpp:226
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition: window_gui.h:155
WID_NSS_SPECTATORS_LABEL
@ WID_NSS_SPECTATORS_LABEL
Label for 'max spectators'.
Definition: network_widget.h:69
WID_NG_LASTJOINED_SPACER
@ WID_NG_LASTJOINED_SPACER
Spacer after last joined server panel.
Definition: network_widget.h:35
NetworkGameWindow::NGameMapSizeSorter
static bool NGameMapSizeSorter(NetworkGameList *const &a, NetworkGameList *const &b)
Sort servers by map size.
Definition: network_gui.cpp:296
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition: gfx.cpp:39
NWidgetCore::GetWidgetFromPos
NWidgetCore * GetWidgetFromPos(int x, int y) override
Definition: widget.cpp:912
TD_RTL
@ TD_RTL
Text is written right-to-left by default.
Definition: strings_type.h:24
_current_text_dir
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:48
NetworkAddress::GetAddressAsString
void GetAddressAsString(char *buffer, const char *last, bool with_family=true)
Get the address as a string, e.g.
Definition: address.cpp:77
_is_network_server
bool _is_network_server
Does this client wants to be a network-server?
Definition: network.cpp:56
CS_NUMERAL
@ CS_NUMERAL
Only numeric ones.
Definition: string_type.h:28
NetworkClientInfo
Container for all information known about a client.
Definition: network_base.h:24
NetworkClientListWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: network_gui.cpp:1887
NetworkGameInfo::compatible
bool compatible
Can we connect to this server or not? (based on server_revision and grf_match.
Definition: game_info.h:82
NetworkLobbyWindow
Definition: network_gui.cpp:1331
StringFilter
String filter and state.
Definition: stringfilter_type.h:31
NetworkGameWindow::flag_offset
int flag_offset
Left offset for language flag icon.
Definition: network_gui.cpp:234
SetDParamStr
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Definition: strings.cpp:286
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:53
WID_NL_SPECTATE
@ WID_NL_SPECTATE
'Spectate game' button.
Definition: network_widget.h:95
INVALID_STRING_ID
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17
GetLobbyCompanyInfo
NetworkCompanyInfo * GetLobbyCompanyInfo(CompanyID company)
Get the company information of a given company to fill for the lobby.
Definition: network_gui.cpp:1631
NetworkClientListPopupWindow::ClientListAction::name
StringID name
Name of the action to execute.
Definition: network_gui.cpp:1689
NETWORK_GAME_PASSWORD
@ NETWORK_GAME_PASSWORD
The password of the game.
Definition: network_type.h:73
NetworkGameWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: network_gui.cpp:874
SetMinimalTextLines
static NWidgetPart SetMinimalTextLines(uint8 lines, uint8 spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition: widget_type.h:974
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:68
ClientNetworkGameSocketHandler::SendGamePassword
static NetworkRecvStatus SendGamePassword(const char *password)
Set the game password as requested.
Definition: network_client.cpp:383
GUIList::SetSortFuncs
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
Definition: sortlist_type.h:270
NetworkGameInfo::spectators_max
byte spectators_max
Max spectators allowed on server.
Definition: game_info.h:90
NetworkSettings::max_companies
uint8 max_companies
maximum amount of companies
Definition: settings_type.h:278
NetworkCompanyPasswordWindow::UpdateWidgetSize
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.
Definition: network_gui.cpp:2143
ResizeWindow
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
Resize the window.
Definition: window.cpp:2153
DrawCompanyIcon
void DrawCompanyIcon(CompanyID cid, int x, int y)
Draw the icon of a company.
Definition: company_cmd.cpp:143
NetworkGameInfo::map_set
byte map_set
Graphical set.
Definition: game_info.h:91
WID_NG_DETAILS_SPACER
@ WID_NG_DETAILS_SPACER
Spacer for game actual details.
Definition: network_widget.h:38