QTfrontend/hwform.cpp
changeset 660 7c155e849602
parent 659 5eafb20566f1
child 661 0523b15353a2
equal deleted inserted replaced
659:5eafb20566f1 660:7c155e849602
   363 		hwnet=0;
   363 		hwnet=0;
   364 	}
   364 	}
   365 	ui.pageNetGame->pChatWidget->clear();
   365 	ui.pageNetGame->pChatWidget->clear();
   366 	hwnet = new HWNewNet(config, ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget);
   366 	hwnet = new HWNewNet(config, ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget);
   367 
   367 
   368 	connect(hwnet, SIGNAL(GameStateChanged(GameState)), this, SLOT(NetGameStateChanged(GameState)));
   368 	connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame()));
   369 	connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter()));
   369 	connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter()));
   370 	connect(hwnet, SIGNAL(AddNetTeam(const HWTeam&)), this, SLOT(AddNetTeam(const HWTeam&)));
   370 	connect(hwnet, SIGNAL(AddNetTeam(const HWTeam&)), this, SLOT(AddNetTeam(const HWTeam&)));
   371 
   371 
   372 	connect(hwnet, SIGNAL(chatStringFromNet(const QStringList&)),
   372 	connect(hwnet, SIGNAL(chatStringFromNet(const QStringList&)),
   373 		ui.pageNetGame->pChatWidget, SLOT(onChatStringFromNet(const QStringList&)));
   373 		ui.pageNetGame->pChatWidget, SLOT(onChatStringFromNet(const QStringList&)));
   443     hwnet->Disconnect();
   443     hwnet->Disconnect();
   444     delete hwnet;
   444     delete hwnet;
   445     hwnet=0;
   445     hwnet=0;
   446   }
   446   }
   447   if(pnetserver) {
   447   if(pnetserver) {
   448     pRegisterServer->unregister();
   448     if (pRegisterServer)
   449     pRegisterServer = 0;
   449     {
       
   450       pRegisterServer->unregister();
       
   451       pRegisterServer = 0;
       
   452     }
   450 
   453 
   451     pnetserver->StopServer();
   454     pnetserver->StopServer();
   452     delete pnetserver;
   455     delete pnetserver;
   453     pnetserver=0;
   456     pnetserver=0;
   454   }
   457   }
   488 	CreateGame(ui.pageMultiplayer->gameCFG, ui.pageMultiplayer->teamsSelect);
   491 	CreateGame(ui.pageMultiplayer->gameCFG, ui.pageMultiplayer->teamsSelect);
   489 
   492 
   490 	game->StartLocal();
   493 	game->StartLocal();
   491 }
   494 }
   492 
   495 
   493 void HWForm::NetGameStateChanged(GameState __attribute__((unused)) gameState)
       
   494 {
       
   495   ui.pageNetGame->BtnGo->setText(QPushButton::tr("Go!"));
       
   496   ui.pageNetGame->BtnGo->setEnabled(true);
       
   497 }
       
   498 
       
   499 void HWForm::GameStateChanged(GameState gameState)
   496 void HWForm::GameStateChanged(GameState gameState)
   500 {
   497 {
   501 	switch(gameState) {
   498 	switch(gameState) {
   502 		case gsStarted: {
   499 		case gsStarted: {
   503 			ui.pageGameStats->labelGameStats->setText("");
   500 			ui.pageGameStats->labelGameStats->setText("");
   508 			break;
   505 			break;
   509 		}
   506 		}
   510 		default: ;
   507 		default: ;
   511 	}
   508 	}
   512 
   509 
       
   510 	if (hwnet)
       
   511 	{
       
   512 		ui.pageNetGame->BtnGo->setText(QPushButton::tr("Go!"));
       
   513 		ui.pageNetGame->BtnGo->setEnabled(true);
       
   514 	}
   513 }
   515 }
   514 
   516 
   515 void HWForm::AddStatText(const QString & msg)
   517 void HWForm::AddStatText(const QString & msg)
   516 {
   518 {
   517 	ui.pageGameStats->labelGameStats->setText(
   519 	ui.pageGameStats->labelGameStats->setText(
   587 {
   589 {
   588 	CreateGame(0, 0);
   590 	CreateGame(0, 0);
   589 
   591 
   590 	game->StartTraining();
   592 	game->StartTraining();
   591 }
   593 }
       
   594 
       
   595 void HWForm::CreateNetGame()
       
   596 {
       
   597 	CreateGame(ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget);
       
   598 
       
   599 	connect(game, SIGNAL(SendNet(const QByteArray &)), hwnet, SLOT(SendNet(const QByteArray &)));
       
   600 	connect(hwnet, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &)));
       
   601 
       
   602 	game->StartNet();
       
   603 }