QTfrontend/hwform.cpp
changeset 4430 cacda05a053e
parent 4429 f9a949ef955b
child 4431 a5827e0e5e0b
equal deleted inserted replaced
4429:f9a949ef955b 4430:cacda05a053e
   511     if(id == ID_PAGE_NETGAME) // joining a room
   511     if(id == ID_PAGE_NETGAME) // joining a room
   512         ui.pageNetGame->pChatWidget->loadLists(ui.pageOptions->editNetNick->text());
   512         ui.pageNetGame->pChatWidget->loadLists(ui.pageOptions->editNetNick->text());
   513 // joining the lobby 
   513 // joining the lobby 
   514     else if(id == ID_PAGE_ROOMSLIST) {
   514     else if(id == ID_PAGE_ROOMSLIST) {
   515         if ( hwnet && game && game->gameState == gsStarted) { // abnormal exit - kick or room destruction - send kills.
   515         if ( hwnet && game && game->gameState == gsStarted) { // abnormal exit - kick or room destruction - send kills.
       
   516             game->netSuspend = true;
   516             game->KillAllTeams();
   517             game->KillAllTeams();
   517         }
   518         }
   518         ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text());
   519         ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text());
   519     }
   520     }
   520 }
   521 }
   936     game->StartLocal();
   937     game->StartLocal();
   937 }
   938 }
   938 
   939 
   939 void HWForm::GameStateChanged(GameState gameState)
   940 void HWForm::GameStateChanged(GameState gameState)
   940 {
   941 {
       
   942     quint8 id = ui.Pages->currentIndex();
   941     switch(gameState) {
   943     switch(gameState) {
   942         case gsStarted: {
   944         case gsStarted: {
   943             Music(false);
   945             Music(false);
   944             if (wBackground) wBackground->stopAnimation();
   946             if (wBackground) wBackground->stopAnimation();
   945             if (!hwnet || (!hwnet->isRoomChief() || !hwnet->isInRoom())) GoToPage(ID_PAGE_INGAME);
   947             if (!hwnet || (!hwnet->isRoomChief() || !hwnet->isInRoom())) GoToPage(ID_PAGE_INGAME);
   954             break;
   956             break;
   955         }
   957         }
   956         case gsFinished: {
   958         case gsFinished: {
   957             //setVisible(true);
   959             //setVisible(true);
   958             setFocusPolicy(Qt::StrongFocus);
   960             setFocusPolicy(Qt::StrongFocus);
   959             if (!hwnet || (!hwnet->isRoomChief() || !hwnet->isInRoom())) GoBack();
   961             if (id == ID_PAGE_INGAME) GoBack();
   960             Music(ui.pageOptions->CBEnableFrontendMusic->isChecked());
   962             Music(ui.pageOptions->CBEnableFrontendMusic->isChecked());
   961             if (wBackground) wBackground->startAnimation();
   963             if (wBackground) wBackground->startAnimation();
   962             GoToPage(ID_PAGE_GAMESTATS);
   964             GoToPage(ID_PAGE_GAMESTATS);
   963             if (hwnet) hwnet->gameFinished();
   965             if (hwnet && (!game || !game->netSuspend)) hwnet->gameFinished();
       
   966             if (game) game->netSuspend = false;
   964             break;
   967             break;
   965         }
   968         }
   966         default: {
   969         default: {
   967             //setVisible(true);
   970             //setVisible(true);
   968             setFocusPolicy(Qt::StrongFocus);
   971             setFocusPolicy(Qt::StrongFocus);
   969             quint8 id = ui.Pages->currentIndex();
   972             quint8 id = ui.Pages->currentIndex();
   970             if (id == ID_PAGE_INGAME ||
   973             if (id == ID_PAGE_INGAME ||
   971 // was room chief and the game was aborted
   974 // was room chief and the game was aborted
   972                 (hwnet && hwnet->isRoomChief() && hwnet->isInRoom() && 
   975                 (hwnet && hwnet->isRoomChief() && hwnet->isInRoom() && 
   973                     (gameState == gsInterrupted || gameState == gsStopped || gameState == gsDestroyed))) {
   976                     (gameState == gsInterrupted || gameState == gsStopped || gameState == gsDestroyed))) {
   974                 if (!hwnet || (!hwnet->isRoomChief() || !hwnet->isInRoom())) GoBack();
   977                 if (id == ID_PAGE_INGAME) GoBack();
   975                 Music(ui.pageOptions->CBEnableFrontendMusic->isChecked());
   978                 Music(ui.pageOptions->CBEnableFrontendMusic->isChecked());
   976                 if (wBackground) wBackground->startAnimation();
   979                 if (wBackground) wBackground->startAnimation();
   977                 if (hwnet) hwnet->gameFinished();
   980                 if (hwnet) hwnet->gameFinished();
   978             }
   981             }
   979         };
   982         };