|
@@ -649,25 +649,25 @@ public:
|
|
|
|
|
|
if (!sel->info.compatible) {
|
|
|
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_CENTER); // server mismatch
|
|
|
} else if (sel->info.clients_on == sel->info.clients_max) {
|
|
|
/* Show: server full, when clients_on == max_clients */
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_SERVER_FULL, TC_FROMSTRING, SA_CENTER); // server full
|
|
|
} else if (sel->info.use_password) {
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_PASSWORD, TC_FROMSTRING, SA_CENTER); // password warning
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
|
|
{
|
|
|
this->field = widget;
|
|
|
switch (widget) {
|
|
|
case NGWW_CANCEL: // Cancel button
|
|
|
DeleteWindowById(WC_NETWORK_WINDOW, 0);
|
|
|
break;
|
|
|
|
|
|
case NGWW_CONN_BTN: // 'Connection' droplist
|
|
|
ShowDropDownMenu(this, _lan_internet_types_dropdown, _settings_client.network.lan_internet, NGWW_CONN_BTN, 0, 0); // do it for widget NSSW_CONN_BTN
|
|
|
break;
|
|
|
|
|
|
case NGWW_NAME: // Sort by name
|
|
@@ -688,40 +688,46 @@ public:
|
|
|
this->SetDirty();
|
|
|
break;
|
|
|
|
|
|
case NGWW_MATRIX: { // Matrix to show networkgames
|
|
|
uint32 id_v = (pt.y - this->GetWidget<NWidgetBase>(NGWW_MATRIX)->pos_y) / this->resize.step_height;
|
|
|
|
|
|
if (id_v >= this->vscroll.GetCapacity()) return; // click out of bounds
|
|
|
id_v += this->vscroll.GetPosition();
|
|
|
|
|
|
this->server = (id_v < this->servers.Length()) ? this->servers[id_v] : NULL;
|
|
|
this->list_pos = (server == NULL) ? SLP_INVALID : id_v;
|
|
|
this->SetDirty();
|
|
|
|
|
|
/* FIXME the disabling should go into some InvalidateData, which is called instead of the SetDirty */
|
|
|
if (!this->IsWidgetDisabled(NGWW_JOIN)) this->OnClick(pt, NGWW_JOIN, 1);
|
|
|
} break;
|
|
|
|
|
|
case NGWW_LASTJOINED: {
|
|
|
NetworkGameList *last_joined = NetworkGameListAddItem(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port));
|
|
|
if (last_joined != NULL) {
|
|
|
this->server = last_joined;
|
|
|
|
|
|
/* search the position of the newly selected server */
|
|
|
for (uint i = 0; i < this->servers.Length(); i++) {
|
|
|
if (this->servers[i] == this->server) {
|
|
|
this->list_pos = i;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
this->ScrollToSelectedServer();
|
|
|
this->SetDirty();
|
|
|
|
|
|
/* FIXME the disabling should go into some InvalidateData, which is called instead of the SetDirty */
|
|
|
if (!this->IsWidgetDisabled(NGWW_JOIN)) this->OnClick(pt, NGWW_JOIN, 1);
|
|
|
}
|
|
|
} break;
|
|
|
|
|
|
case NGWW_FIND: // Find server automatically
|
|
|
switch (_settings_client.network.lan_internet) {
|
|
|
case 0: NetworkUDPSearchGame(); break;
|
|
|
case 1: NetworkUDPQueryMasterServer(); break;
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case NGWW_ADD: // Add a server
|
|
|
SetDParamStr(0, _settings_client.network.connect_to_ip);
|
|
@@ -746,32 +752,24 @@ public:
|
|
|
break;
|
|
|
|
|
|
case NGWW_REFRESH: // Refresh
|
|
|
if (this->server != NULL) NetworkUDPQueryServer(this->server->address);
|
|
|
break;
|
|
|
|
|
|
case NGWW_NEWGRF: // NewGRF Settings
|
|
|
if (this->server != NULL) ShowNewGRFSettings(false, false, false, &this->server->info.grfconfig);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnDoubleClick(Point pt, int widget)
|
|
|
{
|
|
|
if (widget == NGWW_MATRIX || widget == NGWW_LASTJOINED) {
|
|
|
/* is the Join button enabled? */
|
|
|
if (!this->IsWidgetDisabled(NGWW_JOIN)) this->OnClick(pt, NGWW_JOIN);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnDropdownSelect(int widget, int index)
|
|
|
{
|
|
|
switch (widget) {
|
|
|
case NGWW_CONN_BTN:
|
|
|
_settings_client.network.lan_internet = index;
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
NOT_REACHED();
|
|
|
}
|
|
|
|
|
|
this->SetDirty();
|
|
@@ -1148,25 +1146,25 @@ struct NetworkStartServerWindow : public
|
|
|
|
|
|
if (pos == 0) {
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_START_SERVER_SERVER_RANDOM_GAME, TC_DARK_GREEN);
|
|
|
} else {
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, item->title, _fios_colours[item->type] );
|
|
|
}
|
|
|
y += FONT_HEIGHT_NORMAL;
|
|
|
|
|
|
if (y >= this->vscroll.GetCapacity() * FONT_HEIGHT_NORMAL + r.top) break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
|
|
{
|
|
|
this->field = widget;
|
|
|
switch (widget) {
|
|
|
case NSSW_CANCEL: // Cancel button
|
|
|
ShowNetworkGameWindow();
|
|
|
break;
|
|
|
|
|
|
case NSSW_SETPWD: // Set password button
|
|
|
this->widget_id = NSSW_SETPWD;
|
|
|
SetDParamStr(0, _settings_client.network.server_password);
|
|
|
ShowQueryString(STR_JUST_RAW_STRING, STR_NETWORK_START_SERVER_SET_PASSWORD, 20, 250, this, CS_ALPHANUMERAL, QSF_NONE);
|
|
|
break;
|
|
@@ -1612,71 +1610,66 @@ struct NetworkLobbyWindow : public Windo
|
|
|
y += FONT_HEIGHT_NORMAL;
|
|
|
|
|
|
for (uint i = 0; i < lengthof(this->company_info[this->company].num_station); i++) {
|
|
|
SetDParam(i, this->company_info[this->company].num_station[i]);
|
|
|
}
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_GAME_LOBBY_STATIONS); // stations
|
|
|
y += FONT_HEIGHT_NORMAL;
|
|
|
|
|
|
SetDParamStr(0, this->company_info[this->company].clients);
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_GAME_LOBBY_PLAYERS); // players
|
|
|
}
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
|
|
{
|
|
|
switch (widget) {
|
|
|
case NLWW_CANCEL: // Cancel button
|
|
|
ShowNetworkGameWindow();
|
|
|
break;
|
|
|
|
|
|
case NLWW_MATRIX: { // Company list
|
|
|
uint32 id_v = (pt.y - this->GetWidget<NWidgetBase>(NLWW_MATRIX)->pos_y) / this->resize.step_height;
|
|
|
|
|
|
if (id_v >= this->vscroll.GetCapacity()) break;
|
|
|
|
|
|
id_v += this->vscroll.GetPosition();
|
|
|
this->company = (id_v >= this->server->info.companies_on) ? INVALID_COMPANY : NetworkLobbyFindCompanyIndex(id_v);
|
|
|
this->SetDirty();
|
|
|
|
|
|
/* FIXME the disabling should go into some InvalidateData, which is called instead of the SetDirty */
|
|
|
if (!this->IsWidgetDisabled(NLWW_JOIN)) this->OnClick(pt, NLWW_JOIN, 1);
|
|
|
} break;
|
|
|
|
|
|
case NLWW_JOIN: // Join company
|
|
|
/* Button can be clicked only when it is enabled */
|
|
|
NetworkClientConnectGame(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port), this->company);
|
|
|
break;
|
|
|
|
|
|
case NLWW_NEW: // New company
|
|
|
NetworkClientConnectGame(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port), COMPANY_NEW_COMPANY);
|
|
|
break;
|
|
|
|
|
|
case NLWW_SPECTATE: // Spectate game
|
|
|
NetworkClientConnectGame(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port), COMPANY_SPECTATOR);
|
|
|
break;
|
|
|
|
|
|
case NLWW_REFRESH: // Refresh
|
|
|
NetworkTCPQueryServer(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port)); // company info
|
|
|
NetworkUDPQueryServer(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port)); // general data
|
|
|
/* Clear the information so removed companies don't remain */
|
|
|
memset(this->company_info, 0, sizeof(this->company_info));
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnDoubleClick(Point pt, int widget)
|
|
|
{
|
|
|
if (widget == NLWW_MATRIX) {
|
|
|
/* is the Join button enabled? */
|
|
|
if (!this->IsWidgetDisabled(NLWW_JOIN)) this->OnClick(pt, NLWW_JOIN);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnResize()
|
|
|
{
|
|
|
this->vscroll.SetCapacityFromWidget(this, NLWW_MATRIX);
|
|
|
this->GetWidget<NWidgetCore>(NLWW_MATRIX)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
static const NWidgetPart _nested_network_lobby_window_widgets[] = {
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE),
|
|
|
NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_NETWORK_GAME_LOBBY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
|
|
EndContainer(),
|
|
@@ -2076,25 +2069,25 @@ struct NetworkClientListWindow : Window
|
|
|
DrawString(type_left, type_right, y, STR_NETWORK_CLIENT, colour);
|
|
|
}
|
|
|
|
|
|
/* Filter out spectators */
|
|
|
if (Company::IsValidID(ci->client_playas)) DrawCompanyIcon(ci->client_playas, icon_left, y + icon_y_offset);
|
|
|
|
|
|
DrawString(name_left, name_right, y, ci->client_name, colour);
|
|
|
|
|
|
y += FONT_HEIGHT_NORMAL;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
|
|
{
|
|
|
/* Show the popup with option */
|
|
|
if (this->selected_item != -1) {
|
|
|
PopupClientList(this->selected_item, pt.x + this->left, pt.y + this->top);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnMouseOver(Point pt, int widget)
|
|
|
{
|
|
|
/* -1 means we left the current window */
|
|
|
if (pt.y == -1) {
|
|
|
this->selected_item = -1;
|
|
@@ -2209,25 +2202,25 @@ struct NetworkJoinStatusWindow : Window
|
|
|
SetDParam(0, 255);
|
|
|
width = max(width, GetStringBoundingBox(STR_NETWORK_CONNECTING_WAITING).width);
|
|
|
|
|
|
/* Account for downloading ~ 10 MiB */
|
|
|
SetDParam(0, 10000000);
|
|
|
SetDParam(1, 10000000);
|
|
|
width = max(width, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING).width);
|
|
|
|
|
|
/* Give a bit more clearing for the widest strings than strictly needed */
|
|
|
size->width = width + WD_FRAMERECT_LEFT + WD_FRAMERECT_BOTTOM + 10;
|
|
|
}
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
|
|
{
|
|
|
if (widget == NJSW_CANCELOK) { // Disconnect button
|
|
|
NetworkDisconnect();
|
|
|
SwitchToMode(SM_MENU);
|
|
|
ShowNetworkGameWindow();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnQueryTextFinished(char *str)
|
|
|
{
|
|
|
if (StrEmpty(str)) {
|
|
|
NetworkDisconnect();
|
|
@@ -2295,25 +2288,25 @@ struct NetworkCompanyPasswordWindow : pu
|
|
|
/* empty password is a '*' because of console argument */
|
|
|
if (StrEmpty(this->edit_str_buf)) snprintf(this->edit_str_buf, this->edit_str_size, "*");
|
|
|
char *password = this->edit_str_buf;
|
|
|
NetworkChangeCompanyPassword(1, &password);
|
|
|
}
|
|
|
|
|
|
virtual void OnPaint()
|
|
|
{
|
|
|
this->DrawWidgets();
|
|
|
this->DrawEditBox(NCPWW_PASSWORD);
|
|
|
}
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
|
|
{
|
|
|
switch (widget) {
|
|
|
case NCPWW_OK:
|
|
|
this->OnOk();
|
|
|
|
|
|
/* FALL THROUGH */
|
|
|
case NCPWW_CANCEL:
|
|
|
delete this;
|
|
|
break;
|
|
|
|
|
|
case NCPWW_SAVE_AS_DEFAULT_PASSWORD:
|
|
|
this->ToggleWidgetLoweredState(NCPWW_SAVE_AS_DEFAULT_PASSWORD);
|