QTfrontend/hwform.cpp
changeset 5255 947025eeb5dc
parent 5252 ded882439548
child 5567 44c9a577b082
equal deleted inserted replaced
5254:f04327ab2dd6 5255:947025eeb5dc
   456 void HWForm::OnPageShown(quint8 id, quint8 lastid)
   456 void HWForm::OnPageShown(quint8 id, quint8 lastid)
   457 {
   457 {
   458 #ifdef USE_XFIRE
   458 #ifdef USE_XFIRE
   459     updateXfire();
   459     updateXfire();
   460 #endif
   460 #endif
   461     if(id == ID_PAGE_DRAWMAP)
   461     if (id == ID_PAGE_DRAWMAP) {
   462     {
       
   463         DrawMapScene * scene;
   462         DrawMapScene * scene;
   464         if(lastid == ID_PAGE_MULTIPLAYER)
   463         if(lastid == ID_PAGE_MULTIPLAYER)
   465             scene = ui.pageMultiplayer->gameCFG->pMapContainer->getDrawMapScene();
   464             scene = ui.pageMultiplayer->gameCFG->pMapContainer->getDrawMapScene();
   466         else
   465         else
   467             scene = ui.pageNetGame->pGameCFG->pMapContainer->getDrawMapScene();
   466             scene = ui.pageNetGame->pGameCFG->pMapContainer->getDrawMapScene();
   468 
   467 
   469         ui.pageDrawMap->drawMapWidget->setScene(scene);
   468         ui.pageDrawMap->drawMapWidget->setScene(scene);
   470     }
   469     }
   471     if(lastid == ID_PAGE_DRAWMAP)
   470 
   472     {
   471     if (lastid == ID_PAGE_DRAWMAP) {
   473         if(id == ID_PAGE_MULTIPLAYER)
   472         if (id == ID_PAGE_MULTIPLAYER)
   474             ui.pageMultiplayer->gameCFG->pMapContainer->mapDrawingFinished();
   473             ui.pageMultiplayer->gameCFG->pMapContainer->mapDrawingFinished();
   475         else
   474         else
   476             ui.pageNetGame->pGameCFG->pMapContainer->mapDrawingFinished();
   475             ui.pageNetGame->pGameCFG->pMapContainer->mapDrawingFinished();
   477     }
   476     }
   478 
   477 
   483         ui.pageOptions->BtnEditTeam->setVisible(false);
   482         ui.pageOptions->BtnEditTeam->setVisible(false);
   484         ui.pageOptions->BtnDeleteTeam->setVisible(false);
   483         ui.pageOptions->BtnDeleteTeam->setVisible(false);
   485         ui.pageOptions->CBTeamName->setVisible(false);
   484         ui.pageOptions->CBTeamName->setVisible(false);
   486         ui.pageOptions->LblNoEditTeam->setVisible(true);
   485         ui.pageOptions->LblNoEditTeam->setVisible(true);
   487 
   486 
   488         if(id == ID_PAGE_MULTIPLAYER) {
   487         if (id == ID_PAGE_MULTIPLAYER) {
   489           curTeamSelWidget = ui.pageMultiplayer->teamsSelect;
   488             curTeamSelWidget = ui.pageMultiplayer->teamsSelect;
   490         } else {
   489         } else {
   491           curTeamSelWidget = ui.pageNetGame->pNetTeamsWidget;
   490             curTeamSelWidget = ui.pageNetGame->pNetTeamsWidget;
   492         }
   491         }
   493 
   492 
   494         QList<HWTeam> teamsList;
   493         QList<HWTeam> teamsList;
   495         for(QStringList::iterator it = tmNames.begin(); it != tmNames.end(); it++) {
   494         for (QStringList::iterator it = tmNames.begin(); it != tmNames.end(); it++) {
   496           HWTeam team(*it);
   495             HWTeam team(*it);
   497           team.LoadFromFile();
   496             team.LoadFromFile();
   498           teamsList.push_back(team);
   497             teamsList.push_back(team);
   499         }
   498         }
   500 
   499 
   501         if(lastid == ID_PAGE_SETUP || lastid == ID_PAGE_DRAWMAP) { // _TEAM
   500         if (lastid == ID_PAGE_SETUP || lastid == ID_PAGE_DRAWMAP) { // _TEAM
   502           if (editedTeam) {
   501             if (editedTeam) {
   503             curTeamSelWidget->addTeam(*editedTeam);
   502                 curTeamSelWidget->addTeam(*editedTeam);
   504           }
   503             }
   505         } else if(lastid != ID_PAGE_GAMESTATS
   504         } else if (lastid != ID_PAGE_GAMESTATS
   506                 && lastid != ID_PAGE_INGAME
   505                 && lastid != ID_PAGE_INGAME
   507                 && lastid != ID_PAGE_SCHEME
   506                 && lastid != ID_PAGE_SCHEME
   508                 && lastid != ID_PAGE_SELECTWEAPON) {
   507                 && lastid != ID_PAGE_SELECTWEAPON) {
   509             curTeamSelWidget->resetPlayingTeams(teamsList);
   508             curTeamSelWidget->resetPlayingTeams(teamsList);
   510         }
   509         }
   511     } else
   510     } else
   512     if (id == ID_PAGE_GAMESTATS)
   511         if (id == ID_PAGE_GAMESTATS) {
   513     {
   512             ui.pageGameStats->renderStats();
   514         ui.pageGameStats->renderStats();
   513         }
   515     }
   514 
   516 
   515     if (id == ID_PAGE_MAIN) {
   517     if(id == ID_PAGE_MAIN)
       
   518     {
       
   519         ui.pageOptions->BtnNewTeam->setVisible(true);
   516         ui.pageOptions->BtnNewTeam->setVisible(true);
   520         ui.pageOptions->BtnEditTeam->setVisible(true);
   517         ui.pageOptions->BtnEditTeam->setVisible(true);
   521         ui.pageOptions->BtnDeleteTeam->setVisible(true);
   518         ui.pageOptions->BtnDeleteTeam->setVisible(true);
   522         ui.pageOptions->CBTeamName->setVisible(true);
   519         ui.pageOptions->CBTeamName->setVisible(true);
   523         ui.pageOptions->LblNoEditTeam->setVisible(false);
   520         ui.pageOptions->LblNoEditTeam->setVisible(false);
   524     }
   521     }
   525 
   522 
   526     // load and save ignore/friends lists
   523     // load and save ignore/friends lists
   527     if(lastid == ID_PAGE_NETGAME) // leaving a room
   524     if (lastid == ID_PAGE_NETGAME) // leaving a room
   528         ui.pageNetGame->pChatWidget->saveLists(ui.pageOptions->editNetNick->text());
   525         ui.pageNetGame->pChatWidget->saveLists(ui.pageOptions->editNetNick->text());
   529     else if(lastid == ID_PAGE_ROOMSLIST) // leaving the lobby
   526     else if(lastid == ID_PAGE_ROOMSLIST) // leaving the lobby
   530         ui.pageRoomsList->chatWidget->saveLists(ui.pageOptions->editNetNick->text());
   527         ui.pageRoomsList->chatWidget->saveLists(ui.pageOptions->editNetNick->text());
   531 
   528 
   532     if(id == ID_PAGE_NETGAME) // joining a room
   529     if (id == ID_PAGE_NETGAME) // joining a room
   533         ui.pageNetGame->pChatWidget->loadLists(ui.pageOptions->editNetNick->text());
   530         ui.pageNetGame->pChatWidget->loadLists(ui.pageOptions->editNetNick->text());
   534 // joining the lobby 
   531 // joining the lobby 
   535     else if(id == ID_PAGE_ROOMSLIST) {
   532     else if (id == ID_PAGE_ROOMSLIST) {
   536         if ( hwnet && game && game->gameState == gsStarted) { // abnormal exit - kick or room destruction - send kills.
   533         if (hwnet && game && game->gameState == gsStarted) { // abnormal exit - kick or room destruction - send kills.
   537             game->netSuspend = true;
   534             game->netSuspend = true;
   538             game->KillAllTeams();
   535             game->KillAllTeams();
   539         }
   536         }
   540         ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text());
   537         ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text());
   541     }
   538     }
   717     game->PlayDemo(curritem->data(Qt::UserRole).toString());
   714     game->PlayDemo(curritem->data(Qt::UserRole).toString());
   718 }
   715 }
   719 
   716 
   720 void HWForm::PlayDemoQuick(const QString & demofilename)
   717 void HWForm::PlayDemoQuick(const QString & demofilename)
   721 {
   718 {
       
   719     if (game && game->gameState == gsStarted) return;
       
   720     GoBack(); //needed to cleanly disconnect from netgame
       
   721     GoToPage(ID_PAGE_MAIN);
   722     CreateGame(0, 0, 0);
   722     CreateGame(0, 0, 0);
   723     game->PlayDemo(demofilename);
   723     game->PlayDemo(demofilename);
   724 }
   724 }
   725 
   725 
   726 void HWForm::NetConnectServer(const QString & host, quint16 port)
   726 void HWForm::NetConnectServer(const QString & host, quint16 port)