QTfrontend/hwform.cpp
changeset 1800 f1df2eb32a16
parent 1797 fedd8649fdd9
child 1802 dd148e2506e2
equal deleted inserted replaced
1799:b945f4174d00 1800:f1df2eb32a16
   327 	
   327 	
   328 	if ((!hwnet) || (!hwnet->isInRoom()))
   328 	if ((!hwnet) || (!hwnet->isInRoom()))
   329 		if (id == ID_PAGE_NETGAME || id == ID_PAGE_NETGAME)
   329 		if (id == ID_PAGE_NETGAME || id == ID_PAGE_NETGAME)
   330 			GoBack();
   330 			GoBack();
   331 
   331 
   332 	if (id == ID_PAGE_NET) {
   332 	if ((id == ID_PAGE_NET) && (curid != ID_PAGE_CONNECTING)) {
   333 		if(hwnet || pnetserver) NetDisconnect();
   333 		if(hwnet || pnetserver) NetDisconnect();
   334 	}
   334 	}
   335 }
   335 }
   336 
   336 
   337 void HWForm::btnExitPressed()
   337 void HWForm::btnExitPressed()
   446 	}
   446 	}
   447 	
   447 	
   448 	ui.pageRoomsList->chatWidget->clear();
   448 	ui.pageRoomsList->chatWidget->clear();
   449 	
   449 	
   450 	hwnet = new HWNewNet(config, ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget);
   450 	hwnet = new HWNewNet(config, ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget);
       
   451 
       
   452 	{
       
   453 		GoToPage(ID_PAGE_CONNECTING);
       
   454 		connect(hwnet, SIGNAL(Connected()), this, SLOT(GoBack()));
       
   455 		connect(hwnet, SIGNAL(Disconnected()), this, SLOT(GoBack()));
       
   456 	}
   451 
   457 
   452 	connect(hwnet, SIGNAL(showMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection);
   458 	connect(hwnet, SIGNAL(showMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection);
   453 
   459 
   454 	connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame()));
   460 	connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame()));
   455 	connect(hwnet, SIGNAL(Connected()), this, SLOT(NetConnected()));
   461 	connect(hwnet, SIGNAL(Connected()), this, SLOT(NetConnected()));
   531 	connect(ui.pageNetGame->pGameCFG, SIGNAL(borderChanged(bool)), hwnet, SLOT(onBorderChanged(bool)));
   537 	connect(ui.pageNetGame->pGameCFG, SIGNAL(borderChanged(bool)), hwnet, SLOT(onBorderChanged(bool)));
   532 	connect(ui.pageNetGame->pGameCFG, SIGNAL(newWeaponScheme(const QString &, const QString &)),
   538 	connect(ui.pageNetGame->pGameCFG, SIGNAL(newWeaponScheme(const QString &, const QString &)),
   533 			hwnet, SLOT(onWeaponsNameChanged(const QString &, const QString &)));
   539 			hwnet, SLOT(onWeaponsNameChanged(const QString &, const QString &)));
   534 	connect(ui.pageNetGame->pGameCFG, SIGNAL(newTemplateFilter(int)), hwnet, SLOT(onTemplateFilterChanged(int)));
   540 	connect(ui.pageNetGame->pGameCFG, SIGNAL(newTemplateFilter(int)), hwnet, SLOT(onTemplateFilterChanged(int)));
   535 
   541 
   536 	connect(hwnet, SIGNAL(Disconnected()), this, SLOT(ForcedDisconnect()));
   542 	connect(hwnet, SIGNAL(Disconnected()), this, SLOT(ForcedDisconnect()), Qt::QueuedConnection);
   537 	connect(hwnet, SIGNAL(seedChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setSeed(const QString &)));
   543 	connect(hwnet, SIGNAL(seedChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setSeed(const QString &)));
   538 	connect(hwnet, SIGNAL(mapChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setMap(const QString &)));
   544 	connect(hwnet, SIGNAL(mapChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setMap(const QString &)));
   539 	connect(hwnet, SIGNAL(themeChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setTheme(const QString &)));
   545 	connect(hwnet, SIGNAL(themeChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setTheme(const QString &)));
   540 	connect(hwnet, SIGNAL(initHealthChanged(int)), ui.pageNetGame->pGameCFG, SLOT(setInitHealth(int)));
   546 	connect(hwnet, SIGNAL(initHealthChanged(int)), ui.pageNetGame->pGameCFG, SLOT(setInitHealth(int)));
   541 	connect(hwnet, SIGNAL(turnTimeChanged(int)), ui.pageNetGame->pGameCFG, SLOT(setTurnTime(int)));
   547 	connect(hwnet, SIGNAL(turnTimeChanged(int)), ui.pageNetGame->pGameCFG, SLOT(setTurnTime(int)));
   597 	NetConnectServer("localhost", pnetserver->getRunningPort());
   603 	NetConnectServer("localhost", pnetserver->getRunningPort());
   598 }
   604 }
   599 
   605 
   600 void HWForm::NetDisconnect()
   606 void HWForm::NetDisconnect()
   601 {
   607 {
       
   608 	qDebug("NetDisconnect");
   602 	if(hwnet) {
   609 	if(hwnet) {
   603 		hwnet->Disconnect();
   610 		hwnet->Disconnect();
   604 		delete hwnet;
   611 		delete hwnet;
   605 		hwnet = 0;
   612 		hwnet = 0;
   606 	}
   613 	}
   623 	if (hwnet) {
   630 	if (hwnet) {
   624 		hwnet->deleteLater();
   631 		hwnet->deleteLater();
   625 		hwnet = 0;
   632 		hwnet = 0;
   626 		QMessageBox::warning(this, QMessageBox::tr("Network"),
   633 		QMessageBox::warning(this, QMessageBox::tr("Network"),
   627 				QMessageBox::tr("Connection to server is lost"));
   634 				QMessageBox::tr("Connection to server is lost"));
   628 	}
   635 	
   629 	GoBack();
   636 	}
       
   637 	if (ui.Pages->currentIndex() != ID_PAGE_NET) GoBack();
   630 }
   638 }
   631 
   639 
   632 void HWForm::NetConnected()
   640 void HWForm::NetConnected()
   633 {
   641 {
   634 	GoToPage(ID_PAGE_ROOMSLIST);
   642 	GoToPage(ID_PAGE_ROOMSLIST);