161 pageSwitchMapper->setMapping(ui.pageMain->BtnDataDownload, ID_PAGE_DATADOWNLOAD); |
168 pageSwitchMapper->setMapping(ui.pageMain->BtnDataDownload, ID_PAGE_DATADOWNLOAD); |
162 |
169 |
163 connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed())); |
170 connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed())); |
164 connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked())); |
171 connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked())); |
165 |
172 |
166 connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
167 connect(ui.pageDataDownload->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
168 |
|
169 connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave())); |
173 connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave())); |
170 connect(ui.pageEditTeam->BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard())); |
174 connect(ui.pageEditTeam->BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard())); |
171 |
175 |
172 connect(ui.pageEditTeam->signalMapper2, SIGNAL(mapped(const int &)), this, SLOT(RandomName(const int &))); |
176 connect(ui.pageEditTeam->signalMapper2, SIGNAL(mapped(const int &)), this, SLOT(RandomName(const int &))); |
173 connect(ui.pageEditTeam->randTeamButton, SIGNAL(clicked()), this, SLOT(RandomNames())); |
177 connect(ui.pageEditTeam->randTeamButton, SIGNAL(clicked()), this, SLOT(RandomNames())); |
174 |
178 |
175 connect(ui.pageMultiplayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
176 connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame())); |
179 connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame())); |
177 connect(ui.pageMultiplayer->teamsSelect, SIGNAL(setEnabledGameStart(bool)), |
180 connect(ui.pageMultiplayer->teamsSelect, SIGNAL(setEnabledGameStart(bool)), |
178 ui.pageMultiplayer->BtnStartMPGame, SLOT(setEnabled(bool))); |
181 ui.pageMultiplayer->BtnStartMPGame, SLOT(setEnabled(bool))); |
179 connect(ui.pageMultiplayer, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); |
182 connect(ui.pageMultiplayer, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); |
180 connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToSchemes(int)), this, SLOT(GoToScheme(int))); |
183 connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToSchemes(int)), this, SLOT(GoToScheme(int))); |
181 connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToWeapons(int)), this, SLOT(GoToSelectWeaponSet(int))); |
184 connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToWeapons(int)), this, SLOT(GoToSelectWeaponSet(int))); |
182 connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToDrawMap()), pageSwitchMapper, SLOT(map())); |
185 connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToDrawMap()), pageSwitchMapper, SLOT(map())); |
183 pageSwitchMapper->setMapping(ui.pageMultiplayer->gameCFG, ID_PAGE_DRAWMAP); |
186 pageSwitchMapper->setMapping(ui.pageMultiplayer->gameCFG, ID_PAGE_DRAWMAP); |
184 |
187 |
185 |
188 |
186 connect(ui.pagePlayDemo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
187 connect(ui.pagePlayDemo->BtnPlayDemo, SIGNAL(clicked()), this, SLOT(PlayDemo())); |
189 connect(ui.pagePlayDemo->BtnPlayDemo, SIGNAL(clicked()), this, SLOT(PlayDemo())); |
188 connect(ui.pagePlayDemo->DemosList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(PlayDemo())); |
190 connect(ui.pagePlayDemo->DemosList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(PlayDemo())); |
189 |
191 |
190 connect(ui.pageOptions->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
191 connect(ui.pageOptions->BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam())); |
192 connect(ui.pageOptions->BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam())); |
192 connect(ui.pageOptions->BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam())); |
193 connect(ui.pageOptions->BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam())); |
193 connect(ui.pageOptions->BtnDeleteTeam, SIGNAL(clicked()), this, SLOT(DeleteTeam())); |
194 connect(ui.pageOptions->BtnDeleteTeam, SIGNAL(clicked()), this, SLOT(DeleteTeam())); |
194 connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions())); |
195 connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions())); |
195 connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), this, SLOT(GoBack())); |
196 connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), this, SLOT(GoBack())); |
201 connect(ui.pageOptions->SchemeEdit, SIGNAL(clicked()), this, SLOT(GoToEditScheme())); |
202 connect(ui.pageOptions->SchemeEdit, SIGNAL(clicked()), this, SLOT(GoToEditScheme())); |
202 connect(ui.pageOptions->SchemeNew, SIGNAL(clicked()), this, SLOT(GoToNewScheme())); |
203 connect(ui.pageOptions->SchemeNew, SIGNAL(clicked()), this, SLOT(GoToNewScheme())); |
203 connect(ui.pageOptions->SchemeDelete, SIGNAL(clicked()), this, SLOT(DeleteScheme())); |
204 connect(ui.pageOptions->SchemeDelete, SIGNAL(clicked()), this, SLOT(DeleteScheme())); |
204 connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsChanged()), this, SLOT(UpdateWeapons())); |
205 connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsChanged()), this, SLOT(UpdateWeapons())); |
205 |
206 |
206 connect(ui.pageNet->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
207 connect(ui.pageNet->BtnSpecifyServer, SIGNAL(clicked()), this, SLOT(NetConnect())); |
207 connect(ui.pageNet->BtnSpecifyServer, SIGNAL(clicked()), this, SLOT(NetConnect())); |
208 connect(ui.pageNet->BtnNetSvrStart, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
208 connect(ui.pageNet->BtnNetSvrStart, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
209 pageSwitchMapper->setMapping(ui.pageNet->BtnNetSvrStart, ID_PAGE_NETSERVER); |
209 pageSwitchMapper->setMapping(ui.pageNet->BtnNetSvrStart, ID_PAGE_NETSERVER); |
210 |
210 |
211 connect(ui.pageNet, SIGNAL(connectClicked(const QString &, quint16)), this, SLOT(NetConnectServer(const QString &, quint16))); |
211 connect(ui.pageNet, SIGNAL(connectClicked(const QString &, quint16)), this, SLOT(NetConnectServer(const QString &, quint16))); |
212 |
212 |
213 connect(ui.pageNetServer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
214 connect(ui.pageNetServer->BtnStart, SIGNAL(clicked()), this, SLOT(NetStartServer())); |
213 connect(ui.pageNetServer->BtnStart, SIGNAL(clicked()), this, SLOT(NetStartServer())); |
215 |
214 |
216 connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
217 connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(setEnabledGameStart(bool)), |
215 connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(setEnabledGameStart(bool)), |
218 ui.pageNetGame->BtnStart, SLOT(setEnabled(bool))); |
216 ui.pageNetGame->BtnStart, SLOT(setEnabled(bool))); |
219 connect(ui.pageNetGame, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); |
217 connect(ui.pageNetGame, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); |
220 connect(ui.pageNetGame->pGameCFG, SIGNAL(goToSchemes(int)), this, SLOT(GoToScheme(int))); |
218 connect(ui.pageNetGame->pGameCFG, SIGNAL(goToSchemes(int)), this, SLOT(GoToScheme(int))); |
221 connect(ui.pageNetGame->pGameCFG, SIGNAL(goToWeapons(int)), this, SLOT(GoToSelectWeaponSet(int))); |
219 connect(ui.pageNetGame->pGameCFG, SIGNAL(goToWeapons(int)), this, SLOT(GoToSelectWeaponSet(int))); |
222 connect(ui.pageNetGame->pGameCFG, SIGNAL(goToDrawMap()), pageSwitchMapper, SLOT(map())); |
220 connect(ui.pageNetGame->pGameCFG, SIGNAL(goToDrawMap()), pageSwitchMapper, SLOT(map())); |
223 pageSwitchMapper->setMapping(ui.pageNetGame->pGameCFG, ID_PAGE_DRAWMAP); |
221 pageSwitchMapper->setMapping(ui.pageNetGame->pGameCFG, ID_PAGE_DRAWMAP); |
224 |
222 |
225 connect(ui.pageRoomsList->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
226 connect(ui.pageRoomsList->BtnAdmin, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
223 connect(ui.pageRoomsList->BtnAdmin, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
227 pageSwitchMapper->setMapping(ui.pageRoomsList->BtnAdmin, ID_PAGE_ADMIN); |
224 pageSwitchMapper->setMapping(ui.pageRoomsList->BtnAdmin, ID_PAGE_ADMIN); |
228 |
225 |
229 connect(ui.pageInfo->BtnSnapshots, SIGNAL(clicked()), this, SLOT(OpenSnapshotFolder())); |
226 connect(ui.pageInfo->BtnSnapshots, SIGNAL(clicked()), this, SLOT(OpenSnapshotFolder())); |
230 connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
227 |
231 |
|
232 connect(ui.pageGameStats->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
233 connect(ui.pageGameStats, SIGNAL(saveDemoRequested()), this, SLOT(saveDemoWithCustomName())); |
228 connect(ui.pageGameStats, SIGNAL(saveDemoRequested()), this, SLOT(saveDemoWithCustomName())); |
234 |
229 |
235 connect(ui.pageSinglePlayer->BtnSimpleGamePage, SIGNAL(clicked()), this, SLOT(SimpleGame())); |
230 connect(ui.pageSinglePlayer->BtnSimpleGamePage, SIGNAL(clicked()), this, SLOT(SimpleGame())); |
236 connect(ui.pageSinglePlayer->BtnTrainPage, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
231 connect(ui.pageSinglePlayer->BtnTrainPage, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
237 pageSwitchMapper->setMapping(ui.pageSinglePlayer->BtnTrainPage, ID_PAGE_TRAINING); |
232 pageSwitchMapper->setMapping(ui.pageSinglePlayer->BtnTrainPage, ID_PAGE_TRAINING); |
242 connect(ui.pageSinglePlayer->BtnMultiplayer, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
237 connect(ui.pageSinglePlayer->BtnMultiplayer, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
243 pageSwitchMapper->setMapping(ui.pageSinglePlayer->BtnMultiplayer, ID_PAGE_MULTIPLAYER); |
238 pageSwitchMapper->setMapping(ui.pageSinglePlayer->BtnMultiplayer, ID_PAGE_MULTIPLAYER); |
244 |
239 |
245 connect(ui.pageSinglePlayer->BtnLoad, SIGNAL(clicked()), this, SLOT(GoToSaves())); |
240 connect(ui.pageSinglePlayer->BtnLoad, SIGNAL(clicked()), this, SLOT(GoToSaves())); |
246 connect(ui.pageSinglePlayer->BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos())); |
241 connect(ui.pageSinglePlayer->BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos())); |
247 connect(ui.pageSinglePlayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
248 |
242 |
249 connect(ui.pageTraining->BtnStartTrain, SIGNAL(clicked()), this, SLOT(StartTraining())); |
243 connect(ui.pageTraining->BtnStartTrain, SIGNAL(clicked()), this, SLOT(StartTraining())); |
250 connect(ui.pageTraining->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
251 |
244 |
252 connect(ui.pageCampaign->BtnStartCampaign, SIGNAL(clicked()), this, SLOT(StartCampaign())); |
245 connect(ui.pageCampaign->BtnStartCampaign, SIGNAL(clicked()), this, SLOT(StartCampaign())); |
253 connect(ui.pageCampaign->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
254 connect(ui.pageCampaign->CBTeam, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPage(int))); |
246 connect(ui.pageCampaign->CBTeam, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPage(int))); |
255 |
247 |
256 connect(ui.pageSelectWeapon->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
257 |
248 |
258 connect(ui.pageSelectWeapon->BtnDelete, SIGNAL(clicked()), |
249 connect(ui.pageSelectWeapon->BtnDelete, SIGNAL(clicked()), |
259 ui.pageSelectWeapon->pWeapons, SLOT(deleteWeaponsName())); // executed first |
250 ui.pageSelectWeapon->pWeapons, SLOT(deleteWeaponsName())); // executed first |
260 connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()), |
251 connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()), |
261 this, SLOT(UpdateWeapons())); // executed second |
252 this, SLOT(UpdateWeapons())); // executed second |
262 //connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()), |
253 //connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()), |
263 // this, SLOT(GoBack())); // executed third |
254 // this, SLOT(GoBack())); // executed third |
264 |
255 |
265 connect(ui.pageScheme->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
256 |
266 |
|
267 connect(ui.pageAdmin->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
268 |
|
269 connect(ui.pageNetType->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
270 connect(ui.pageNetType->BtnLAN, SIGNAL(clicked()), this, SLOT(GoToNet())); |
257 connect(ui.pageNetType->BtnLAN, SIGNAL(clicked()), this, SLOT(GoToNet())); |
271 connect(ui.pageNetType->BtnOfficialServer, SIGNAL(clicked()), this, SLOT(NetConnectOfficialServer())); |
258 connect(ui.pageNetType->BtnOfficialServer, SIGNAL(clicked()), this, SLOT(NetConnectOfficialServer())); |
272 |
|
273 connect(ui.pageDrawMap->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
274 |
259 |
275 connect(ui.pageConnecting, SIGNAL(cancelConnection()), this, SLOT(GoBack())); |
260 connect(ui.pageConnecting, SIGNAL(cancelConnection()), this, SLOT(GoBack())); |
276 |
261 |
277 |
262 |
278 ammoSchemeModel = new AmmoSchemeModel(this, cfgdir->absolutePath() + "/schemes.ini"); |
263 ammoSchemeModel = new AmmoSchemeModel(this, cfgdir->absolutePath() + "/schemes.ini"); |
645 } |
630 } |
646 |
631 |
647 void HWForm::EditTeam() |
632 void HWForm::EditTeam() |
648 { |
633 { |
649 editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); |
634 editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); |
650 editedTeam->LoadFromFile(); |
635 editedTeam->loadFromFile(); |
651 editedTeam->SetToPage(this); |
636 editedTeam->SetToPage(this); |
652 GoToPage(ID_PAGE_SETUP_TEAM); |
637 GoToPage(ID_PAGE_SETUP_TEAM); |
653 } |
638 } |
654 |
639 |
655 void HWForm::DeleteTeam() |
640 void HWForm::DeleteTeam() |
656 { |
641 { |
657 QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Teams"), QMessageBox::tr("Really delete this team?"), QMessageBox::Ok | QMessageBox::Cancel); |
642 QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Teams"), QMessageBox::tr("Really delete this team?"), QMessageBox::Ok | QMessageBox::Cancel); |
658 |
643 |
659 if (reallyDelete.exec() == QMessageBox::Ok) { |
644 if (reallyDelete.exec() == QMessageBox::Ok) { |
660 editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); |
645 editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); |
661 editedTeam->DeleteFile(); |
646 editedTeam->deleteFile(); |
662 |
647 |
663 // Remove from lists |
648 // Remove from lists |
664 ui.pageOptions->CBTeamName->removeItem(ui.pageOptions->CBTeamName->currentIndex()); |
649 ui.pageOptions->CBTeamName->removeItem(ui.pageOptions->CBTeamName->currentIndex()); |
665 } |
650 } |
666 } |
651 } |
667 |
652 |
668 void HWForm::RandomNames() |
653 void HWForm::RandomNames() |
669 { |
654 { |
670 editedTeam->GetFromPage(this); |
655 editedTeam->GetFromPage(this); |
671 namegen->TeamRandomNames(editedTeam, true); |
656 namegen->teamRandomNames(*editedTeam, true); |
672 editedTeam->SetToPage(this); |
657 editedTeam->SetToPage(this); |
673 } |
658 } |
674 |
659 |
675 void HWForm::RandomName(const int &i) |
660 void HWForm::RandomName(const int &i) |
676 { |
661 { |
677 editedTeam->GetFromPage(this); |
662 editedTeam->GetFromPage(this); |
678 namegen->TeamRandomName(editedTeam,i); |
663 namegen->teamRandomName(*editedTeam,i); |
679 editedTeam->SetToPage(this); |
664 editedTeam->SetToPage(this); |
680 } |
665 } |
681 |
666 |
682 void HWForm::TeamSave() |
667 void HWForm::TeamSave() |
683 { |
668 { |
684 editedTeam->GetFromPage(this); |
669 editedTeam->GetFromPage(this); |
685 editedTeam->SaveToFile(); |
670 editedTeam->saveToFile(); |
686 delete editedTeam; |
671 delete editedTeam; |
687 editedTeam=0; |
672 editedTeam=0; |
688 UpdateTeamsLists(); |
673 UpdateTeamsLists(); |
689 GoBack(); |
674 GoBack(); |
690 } |
675 } |
751 void HWForm::NetConnectOfficialServer() |
736 void HWForm::NetConnectOfficialServer() |
752 { |
737 { |
753 NetConnectServer("netserver.hedgewars.org", 46631); |
738 NetConnectServer("netserver.hedgewars.org", 46631); |
754 } |
739 } |
755 |
740 |
756 void HWForm::_NetConnect(const QString & hostName, quint16 port, const QString & nick) |
741 void HWForm::NetPassword(const QString & nick) |
|
742 { |
|
743 bool ok = false; |
|
744 int passLength = config->value("net/passwordlength", 0).toInt(); |
|
745 QString hash = config->value("net/passwordhash", "").toString(); |
|
746 |
|
747 // If the password is blank, ask the user to enter one in |
|
748 if (passLength == 0) |
|
749 { |
|
750 QString password = QInputDialog::getText(this, tr("Password"), tr("Your nickname %1 is\nregistered on Hedgewars.org\nPlease provide your password below\nor pick another nickname in game config:").arg(nick), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0'), &ok); |
|
751 |
|
752 if (!ok) { |
|
753 ForcedDisconnect(tr("No password supplied.")); |
|
754 return; |
|
755 } |
|
756 |
|
757 hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex(); |
|
758 config->setValue("net/passwordhash", hash); |
|
759 config->setValue("net/passwordlength", password.size()); |
|
760 config->setNetPasswordLength(password.size()); |
|
761 } |
|
762 |
|
763 hwnet->SendPasswordHash(hash); |
|
764 } |
|
765 |
|
766 void HWForm::NetNickTaken(const QString & nick) |
|
767 { |
|
768 bool ok = false; |
|
769 QString newNick = QInputDialog::getText(this, tr("Nickname"), tr("Some one already uses\n your nickname %1\non the server.\nPlease pick another nickname:").arg(nick), QLineEdit::Normal, nick, &ok); |
|
770 |
|
771 if (!ok || newNick.isEmpty()) { |
|
772 ForcedDisconnect(tr("No nickname supplied.")); |
|
773 return; |
|
774 } |
|
775 |
|
776 hwnet->NewNick(newNick); |
|
777 config->setValue("net/nick", newNick); |
|
778 config->updNetNick(); |
|
779 } |
|
780 |
|
781 void HWForm::NetAuthFailed() |
|
782 { |
|
783 // Set the password blank if case the user tries to join and enter his password again |
|
784 config->setValue("net/passwordlength", 0); |
|
785 config->setNetPasswordLength(0); |
|
786 } |
|
787 |
|
788 void HWForm::NetTeamAccepted(const QString & team) |
|
789 { |
|
790 ui.pageNetGame->pNetTeamsWidget->changeTeamStatus(team); |
|
791 } |
|
792 |
|
793 void HWForm::NetError(const QString & errmsg) |
|
794 { |
|
795 switch (ui.Pages->currentIndex()) |
|
796 { |
|
797 case ID_PAGE_INGAME: |
|
798 ShowErrorMessage(errmsg); |
|
799 // no break |
|
800 case ID_PAGE_NETGAME: |
|
801 ui.pageNetGame->pChatWidget->addLine("Error",errmsg); |
|
802 break; |
|
803 default: |
|
804 ui.pageRoomsList->chatWidget->addLine("Error",errmsg); |
|
805 } |
|
806 } |
|
807 |
|
808 void HWForm::NetWarning(const QString & wrnmsg) |
|
809 { |
|
810 if (ui.Pages->currentIndex() == ID_PAGE_NETGAME || ui.Pages->currentIndex() == ID_PAGE_INGAME) |
|
811 ui.pageNetGame->pChatWidget->addLine("Warning",wrnmsg); |
|
812 else |
|
813 ui.pageRoomsList->chatWidget->addLine("Warning",wrnmsg); |
|
814 } |
|
815 |
|
816 void HWForm::_NetConnect(const QString & hostName, quint16 port, QString nick) |
757 { |
817 { |
758 if(hwnet) { |
818 if(hwnet) { |
759 hwnet->Disconnect(); |
819 hwnet->Disconnect(); |
760 delete hwnet; |
820 delete hwnet; |
761 hwnet=0; |
821 hwnet=0; |
762 } |
822 } |
763 |
823 |
764 ui.pageRoomsList->chatWidget->clear(); |
824 ui.pageRoomsList->chatWidget->clear(); |
765 |
825 |
766 hwnet = new HWNewNet(config, ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget); |
826 hwnet = new HWNewNet(); |
767 |
827 |
768 GoToPage(ID_PAGE_CONNECTING); |
828 GoToPage(ID_PAGE_CONNECTING); |
769 |
|
770 connect(hwnet, SIGNAL(showMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); |
|
771 |
829 |
772 connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame())); |
830 connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame())); |
773 connect(hwnet, SIGNAL(Connected()), this, SLOT(NetConnected())); |
831 connect(hwnet, SIGNAL(Connected()), this, SLOT(NetConnected())); |
|
832 connect(hwnet, SIGNAL(Error(const QString&)), this, SLOT(NetError(const QString&))); |
|
833 connect(hwnet, SIGNAL(Warning(const QString&)), this, SLOT(NetWarning(const QString&))); |
774 connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter())); |
834 connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter())); |
775 connect(hwnet, SIGNAL(LeftRoom()), this, SLOT(NetLeftRoom())); |
835 connect(hwnet, SIGNAL(LeftRoom(const QString&)), this, SLOT(NetLeftRoom(const QString&))); |
776 connect(hwnet, SIGNAL(AddNetTeam(const HWTeam&)), this, SLOT(AddNetTeam(const HWTeam&))); |
836 connect(hwnet, SIGNAL(AddNetTeam(const HWTeam&)), this, SLOT(AddNetTeam(const HWTeam&))); |
|
837 connect(hwnet, SIGNAL(RemoveNetTeam(const HWTeam&)), this, SLOT(RemoveNetTeam(const HWTeam&))); |
|
838 connect(hwnet, SIGNAL(TeamAccepted(const QString&)), this, SLOT(NetTeamAccepted(const QString&))); |
|
839 connect(hwnet, SIGNAL(AskForPassword(const QString&)), this, SLOT(NetPassword(const QString&))); |
|
840 connect(hwnet, SIGNAL(NickTaken(const QString&)), this, SLOT(NetNickTaken(const QString&))); |
|
841 connect(hwnet, SIGNAL(AuthFailed()), this, SLOT(NetAuthFailed())); |
777 //connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), hwnet, SLOT(partRoom())); |
842 //connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), hwnet, SLOT(partRoom())); |
778 |
843 |
779 // rooms list page stuff |
844 // rooms list page stuff |
780 connect(hwnet, SIGNAL(roomsList(const QStringList&)), |
845 connect(hwnet, SIGNAL(roomsList(const QStringList&)), |
781 ui.pageRoomsList, SLOT(setRoomsList(const QStringList&))); |
846 ui.pageRoomsList, SLOT(setRoomsList(const QStringList&))); |
874 connect(hwnet, SIGNAL(latestProtocolVar(int)), ui.pageAdmin, SLOT(protocol(int))); |
939 connect(hwnet, SIGNAL(latestProtocolVar(int)), ui.pageAdmin, SLOT(protocol(int))); |
875 connect(ui.pageAdmin, SIGNAL(setServerMessageNew(const QString&)), hwnet, SLOT(setServerMessageNew(const QString &))); |
940 connect(ui.pageAdmin, SIGNAL(setServerMessageNew(const QString&)), hwnet, SLOT(setServerMessageNew(const QString &))); |
876 connect(ui.pageAdmin, SIGNAL(setServerMessageOld(const QString&)), hwnet, SLOT(setServerMessageOld(const QString &))); |
941 connect(ui.pageAdmin, SIGNAL(setServerMessageOld(const QString&)), hwnet, SLOT(setServerMessageOld(const QString &))); |
877 connect(ui.pageAdmin, SIGNAL(setProtocol(int)), hwnet, SLOT(setLatestProtocolVar(int))); |
942 connect(ui.pageAdmin, SIGNAL(setProtocol(int)), hwnet, SLOT(setLatestProtocolVar(int))); |
878 connect(ui.pageAdmin, SIGNAL(askServerVars()), hwnet, SLOT(askServerVars())); |
943 connect(ui.pageAdmin, SIGNAL(askServerVars()), hwnet, SLOT(askServerVars())); |
879 connect(ui.pageAdmin->pbClearAccountsCache, SIGNAL(clicked()), hwnet, SLOT(clearAccountsCache())); |
944 connect(ui.pageAdmin, SIGNAL(clearAccountsCache()), hwnet, SLOT(clearAccountsCache())); |
880 |
945 |
881 // disconnect |
946 // disconnect |
882 connect(hwnet, SIGNAL(Disconnected()), this, SLOT(ForcedDisconnect()), Qt::QueuedConnection); |
947 connect(hwnet, SIGNAL(Disconnected(const QString&)), this, SLOT(ForcedDisconnect(const QString&)), Qt::QueuedConnection); |
883 |
948 |
|
949 // config stuff |
|
950 connect(hwnet, SIGNAL(paramChanged(const QString &, const QStringList &)), ui.pageNetGame->pGameCFG, SLOT(setParam(const QString &, const QStringList &))); |
|
951 connect(ui.pageNetGame->pGameCFG, SIGNAL(paramChanged(const QString &, const QStringList &)), hwnet, SLOT(onParamChanged(const QString &, const QStringList &))); |
|
952 connect(hwnet, SIGNAL(configAsked()), ui.pageNetGame->pGameCFG, SLOT(fullNetConfig())); |
|
953 |
|
954 while (nick.isEmpty()) { |
|
955 nick = QInputDialog::getText(this, |
|
956 QObject::tr("Nickname"), |
|
957 QObject::tr("Please enter your nickname"), |
|
958 QLineEdit::Normal, |
|
959 QDir::home().dirName()); |
|
960 config->setValue("net/nick",nick); |
|
961 config->updNetNick(); |
|
962 } |
884 hwnet->Connect(hostName, port, nick); |
963 hwnet->Connect(hostName, port, nick); |
885 } |
964 } |
886 |
965 |
887 void HWForm::NetConnect() |
966 void HWForm::NetConnect() |
888 { |
967 { |
1230 tmpdir.cd(cfgdir->absolutePath()); |
1313 tmpdir.cd(cfgdir->absolutePath()); |
1231 tmpdir.cd("Data/Missions/Campaign"); |
1314 tmpdir.cd("Data/Missions/Campaign"); |
1232 tmpdir.setFilter(QDir::Files); |
1315 tmpdir.setFilter(QDir::Files); |
1233 QStringList userentries = tmpdir.entryList(QStringList("*#*.lua")); |
1316 QStringList userentries = tmpdir.entryList(QStringList("*#*.lua")); |
1234 //entries.sort(); |
1317 //entries.sort(); |
1235 for(int i = 0; (i < userentries.count()) && (i <= team.CampaignProgress); i++) |
1318 unsigned int n = userentries.count(); |
|
1319 for(unsigned int i = 0; (i < n) && (i <= team.campaignProgress()); i++) |
1236 ui.pageCampaign->CBSelect->addItem(QString(userentries[i]).replace(QRegExp("^(\\d+)#(.+)\\.lua"), QComboBox::tr("Mission") + " \\1: \\2").replace("_", " "), QString(userentries[i]).replace(QRegExp("^(.*)\\.lua"), "\\1")); |
1320 ui.pageCampaign->CBSelect->addItem(QString(userentries[i]).replace(QRegExp("^(\\d+)#(.+)\\.lua"), QComboBox::tr("Mission") + " \\1: \\2").replace("_", " "), QString(userentries[i]).replace(QRegExp("^(.*)\\.lua"), "\\1")); |
1237 |
1321 |
1238 tmpdir.cd(datadir->absolutePath()); |
1322 tmpdir.cd(datadir->absolutePath()); |
1239 tmpdir.cd("Missions/Campaign"); |
1323 tmpdir.cd("Missions/Campaign"); |
1240 tmpdir.setFilter(QDir::Files); |
1324 tmpdir.setFilter(QDir::Files); |
1241 QStringList entries = tmpdir.entryList(QStringList("*#*.lua")); |
1325 QStringList entries = tmpdir.entryList(QStringList("*#*.lua")); |
1242 //entries.sort(); |
1326 //entries.sort(); |
1243 for(int i = 0; (i < entries.count()) && (i <= team.CampaignProgress); i++) { |
1327 n = entries.count(); |
|
1328 for(unsigned int i = 0; (i < n) && (i <= team.campaignProgress()); i++) { |
1244 if (userentries.contains(entries[i])) continue; |
1329 if (userentries.contains(entries[i])) continue; |
1245 ui.pageCampaign->CBSelect->addItem(QString(entries[i]).replace(QRegExp("^(\\d+)#(.+)\\.lua"), QComboBox::tr("Mission") + " \\1: \\2").replace("_", " "), QString(entries[i]).replace(QRegExp("^(.*)\\.lua"), "\\1")); |
1330 ui.pageCampaign->CBSelect->addItem(QString(entries[i]).replace(QRegExp("^(\\d+)#(.+)\\.lua"), QComboBox::tr("Mission") + " \\1: \\2").replace("_", " "), QString(entries[i]).replace(QRegExp("^(.*)\\.lua"), "\\1")); |
1246 } |
1331 } |
1247 } |
1332 } |
1248 |
1333 |