|
@@ -668,53 +668,49 @@ public:
|
|
|
|
|
|
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
|
|
|
case NGWW_CLIENTS: // Sort by connected clients
|
|
|
case NGWW_MAPSIZE: // Sort by map size
|
|
|
case NGWW_DATE: // Sort by date
|
|
|
case NGWW_YEARS: // Sort by years
|
|
|
case NGWW_INFO: // Connectivity (green dot)
|
|
|
if (this->servers.SortType() == widget - NGWW_NAME) {
|
|
|
this->servers.ToggleSortOrder();
|
|
|
if (this->list_pos != SLP_INVALID) this->list_pos = this->servers.Length() - this->list_pos - 1;
|
|
|
} else {
|
|
|
this->servers.SetSortType(widget - NGWW_NAME);
|
|
|
this->servers.ForceResort();
|
|
|
this->SortNetworkGameList();
|
|
|
}
|
|
|
this->ScrollToSelectedServer();
|
|
|
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();
|
|
|
|
|
|
uint id_v = this->vscroll.GetScrolledRowFromWidget(pt.y, this, NGWW_MATRIX);
|
|
|
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 (click_count > 1 && !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 */
|
|
@@ -1149,51 +1145,49 @@ struct NetworkStartServerWindow : public
|
|
|
} 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, 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;
|
|
|
|
|
|
case NSSW_SELMAP: { // Select map
|
|
|
int y = (pt.y - this->GetWidget<NWidgetBase>(NSSW_SELMAP)->pos_y - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL;
|
|
|
|
|
|
y += this->vscroll.GetPosition();
|
|
|
int y = this->vscroll.GetScrolledRowFromWidget(pt.y, this, NSSW_SELMAP, WD_FRAMERECT_TOP, FONT_HEIGHT_NORMAL);
|
|
|
if (y >= this->vscroll.GetCount()) return;
|
|
|
|
|
|
this->map = (y == 0) ? NULL : _fios_items.Get(y - 1);
|
|
|
this->SetDirty();
|
|
|
} break;
|
|
|
|
|
|
case NSSW_CONNTYPE_BTN: // Connection type
|
|
|
ShowDropDownMenu(this, _connection_types_dropdown, _settings_client.network.server_advertise, NSSW_CONNTYPE_BTN, 0, 0); // do it for widget NSSW_CONNTYPE_BTN
|
|
|
break;
|
|
|
|
|
|
case NSSW_CLIENTS_BTND: case NSSW_CLIENTS_BTNU: // Click on up/down button for number of clients
|
|
|
case NSSW_COMPANIES_BTND: case NSSW_COMPANIES_BTNU: // Click on up/down button for number of companies
|
|
|
case NSSW_SPECTATORS_BTND: case NSSW_SPECTATORS_BTNU: // Click on up/down button for number of spectators
|
|
|
/* Don't allow too fast scrolling */
|
|
|
if ((this->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
|
|
|
this->HandleButtonClick(widget);
|
|
|
this->SetDirty();
|
|
|
switch (widget) {
|
|
|
default: NOT_REACHED();
|
|
|
case NSSW_CLIENTS_BTND: case NSSW_CLIENTS_BTNU:
|
|
|
_settings_client.network.max_clients = Clamp(_settings_client.network.max_clients + widget - NSSW_CLIENTS_TXT, 2, MAX_CLIENTS);
|
|
|
break;
|
|
|
case NSSW_COMPANIES_BTND: case NSSW_COMPANIES_BTNU:
|
|
|
_settings_client.network.max_companies = Clamp(_settings_client.network.max_companies + widget - NSSW_COMPANIES_TXT, 1, MAX_COMPANIES);
|
|
@@ -1610,53 +1604,49 @@ struct NetworkLobbyWindow : public Windo
|
|
|
SetDParam(4, this->company_info[this->company].num_vehicle[NETWORK_VEH_PLANE]);
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_GAME_LOBBY_VEHICLES); // vehicles
|
|
|
y += FONT_HEIGHT_NORMAL;
|
|
|
|
|
|
SetDParam(0, this->company_info[this->company].num_station[NETWORK_VEH_TRAIN]);
|
|
|
SetDParam(1, this->company_info[this->company].num_station[NETWORK_VEH_LORRY]);
|
|
|
SetDParam(2, this->company_info[this->company].num_station[NETWORK_VEH_BUS]);
|
|
|
SetDParam(3, this->company_info[this->company].num_station[NETWORK_VEH_SHIP]);
|
|
|
SetDParam(4, this->company_info[this->company].num_station[NETWORK_VEH_PLANE]);
|
|
|
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, 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();
|
|
|
uint id_v = this->vscroll.GetScrolledRowFromWidget(pt.y, this, NLWW_MATRIX);
|
|
|
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 (click_count > 1 && !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 */
|