branch | webgl |
changeset 8444 | 75db7bb8dce8 |
parent 8330 | aaefa587e277 |
parent 8436 | b89aacebb9db |
child 8833 | c13ebed437cb |
8340:46a9fde631f4 | 8444:75db7bb8dce8 |
---|---|
19 #include <QDir> |
19 #include <QDir> |
20 #include <QFile> |
20 #include <QFile> |
21 #include <QTextStream> |
21 #include <QTextStream> |
22 #include <QMessageBox> |
22 #include <QMessageBox> |
23 #include <QPushButton> |
23 #include <QPushButton> |
24 #include <QSpinBox> |
|
24 #include <QListWidget> |
25 #include <QListWidget> |
25 #include <QStackedLayout> |
26 #include <QStackedLayout> |
26 #include <QLineEdit> |
27 #include <QLineEdit> |
27 #include <QLabel> |
28 #include <QLabel> |
28 #include <QRadioButton> |
29 #include <QRadioButton> |
70 #include "pageoptions.h" |
71 #include "pageoptions.h" |
71 #include "pageeditteam.h" |
72 #include "pageeditteam.h" |
72 #include "pagemultiplayer.h" |
73 #include "pagemultiplayer.h" |
73 #include "pagenet.h" |
74 #include "pagenet.h" |
74 #include "pagemain.h" |
75 #include "pagemain.h" |
75 #include "pagefeedback.h" |
|
76 #include "pagenetserver.h" |
76 #include "pagenetserver.h" |
77 #include "pagedrawmap.h" |
77 #include "pagedrawmap.h" |
78 #include "pagegamestats.h" |
78 #include "pagegamestats.h" |
79 #include "pageplayrecord.h" |
79 #include "pageplayrecord.h" |
80 #include "pagedata.h" |
80 #include "pagedata.h" |
93 #include "drawmapwidget.h" |
93 #include "drawmapwidget.h" |
94 #include "mouseoverfilter.h" |
94 #include "mouseoverfilter.h" |
95 #include "roomslistmodel.h" |
95 #include "roomslistmodel.h" |
96 #include "recorder.h" |
96 #include "recorder.h" |
97 #include "playerslistmodel.h" |
97 #include "playerslistmodel.h" |
98 |
98 #include "feedbackdialog.h" |
99 |
|
100 #include "MessageDialog.h" |
|
99 #include "DataManager.h" |
101 #include "DataManager.h" |
100 #include "AutoUpdater.h" |
102 #include "AutoUpdater.h" |
101 |
103 |
102 #ifdef Q_WS_WIN |
104 #ifdef Q_WS_WIN |
103 #define WINVER 0x0500 |
105 #define WINVER 0x0500 |
153 playerHash = QString(QCryptographicHash::hash(config->value("net/nick","").toString().toUtf8(), QCryptographicHash::Md5).toHex()); |
155 playerHash = QString(QCryptographicHash::hash(config->value("net/nick","").toString().toUtf8(), QCryptographicHash::Md5).toHex()); |
154 |
156 |
155 ui.pageRoomsList->setSettings(config); |
157 ui.pageRoomsList->setSettings(config); |
156 ui.pageNetGame->chatWidget->setSettings(config); |
158 ui.pageNetGame->chatWidget->setSettings(config); |
157 ui.pageRoomsList->chatWidget->setSettings(config); |
159 ui.pageRoomsList->chatWidget->setSettings(config); |
160 ui.pageOptions->setConfig(config); |
|
158 #ifdef VIDEOREC |
161 #ifdef VIDEOREC |
159 ui.pageVideos->init(config); |
162 ui.pageVideos->init(config); |
160 ui.pageOptions->setConfig(config); |
|
161 #endif |
163 #endif |
162 |
164 |
163 #ifdef __APPLE__ |
165 #ifdef __APPLE__ |
164 AutoUpdater* updater = NULL; |
166 AutoUpdater* updater = NULL; |
165 if (config->isAutoUpdateEnabled()) |
167 if (config->isAutoUpdateEnabled()) |
211 pageSwitchMapper->setMapping(ui.pageMain->BtnSinglePlayer, ID_PAGE_SINGLEPLAYER); |
213 pageSwitchMapper->setMapping(ui.pageMain->BtnSinglePlayer, ID_PAGE_SINGLEPLAYER); |
212 |
214 |
213 connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
215 connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
214 pageSwitchMapper->setMapping(ui.pageMain->BtnSetup, ID_PAGE_SETUP); |
216 pageSwitchMapper->setMapping(ui.pageMain->BtnSetup, ID_PAGE_SETUP); |
215 |
217 |
216 connect(ui.pageMain->BtnFeedback, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
218 connect(ui.pageMain->BtnFeedback, SIGNAL(clicked()), this, SLOT(showFeedbackDialog())); |
217 pageSwitchMapper->setMapping(ui.pageMain->BtnFeedback, ID_PAGE_FEEDBACK); |
|
218 |
219 |
219 connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
220 connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
220 pageSwitchMapper->setMapping(ui.pageMain->BtnInfo, ID_PAGE_INFO); |
221 pageSwitchMapper->setMapping(ui.pageMain->BtnInfo, ID_PAGE_INFO); |
221 |
222 |
222 connect(ui.pageMain->BtnDataDownload, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
223 connect(ui.pageMain->BtnDataDownload, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
228 pageSwitchMapper->setMapping(ui.pageMain->BtnVideos, ID_PAGE_VIDEOS); |
229 pageSwitchMapper->setMapping(ui.pageMain->BtnVideos, ID_PAGE_VIDEOS); |
229 #endif |
230 #endif |
230 |
231 |
231 //connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed())); |
232 //connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed())); |
232 //connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked())); |
233 //connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked())); |
233 |
|
234 connect(ui.pageFeedback->BtnSend, SIGNAL(clicked()), this, SLOT(SendFeedback())); |
|
235 |
234 |
236 connect(ui.pageEditTeam, SIGNAL(goBack()), this, SLOT(AfterTeamEdit())); |
235 connect(ui.pageEditTeam, SIGNAL(goBack()), this, SLOT(AfterTeamEdit())); |
237 |
236 |
238 connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame())); |
237 connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame())); |
239 connect(ui.pageMultiplayer->teamsSelect, SIGNAL(setEnabledGameStart(bool)), |
238 connect(ui.pageMultiplayer->teamsSelect, SIGNAL(setEnabledGameStart(bool)), |
349 widgets.at(i)->installEventFilter(filter); |
348 widgets.at(i)->installEventFilter(filter); |
350 } |
349 } |
351 } |
350 } |
352 |
351 |
353 PagesStack.push(ID_PAGE_MAIN); |
352 PagesStack.push(ID_PAGE_MAIN); |
353 ((AbstractPage*)ui.Pages->widget(ID_PAGE_MAIN))->triggerPageEnter(); |
|
354 GoBack(); |
354 GoBack(); |
355 } |
355 } |
356 |
356 |
357 #ifdef USE_XFIRE |
357 #ifdef USE_XFIRE |
358 void HWForm::updateXfire(void) |
358 void HWForm::updateXfire(void) |
551 void HWForm::GoToVideos() |
551 void HWForm::GoToVideos() |
552 { |
552 { |
553 GoToPage(ID_PAGE_VIDEOS); |
553 GoToPage(ID_PAGE_VIDEOS); |
554 } |
554 } |
555 |
555 |
556 //TODO: maybe find a better place for this? |
|
557 QString HWForm::stringifyPageId(quint32 id) |
|
558 { |
|
559 QString pageName; |
|
560 switch (id) |
|
561 { |
|
562 case ID_PAGE_SETUP_TEAM : pageName = "PAGE_SETUP_TEAM"; break; |
|
563 case ID_PAGE_SETUP : pageName = "PAGE_SETUP"; break; |
|
564 case ID_PAGE_MULTIPLAYER : pageName = "PAGE_MULTIPLAYER"; break; |
|
565 case ID_PAGE_DEMOS : pageName = "PAGE_DEMOS"; break; |
|
566 case ID_PAGE_NET : pageName = "PAGE_NET"; break; |
|
567 case ID_PAGE_NETGAME : pageName = "PAGE_NETGAME"; break; |
|
568 case ID_PAGE_INFO : pageName = "PAGE_INFO"; break; |
|
569 case ID_PAGE_MAIN : pageName = "PAGE_MAIN"; break; |
|
570 case ID_PAGE_GAMESTATS : pageName = "PAGE_GAMESTATS"; break; |
|
571 case ID_PAGE_SINGLEPLAYER : pageName = "PAGE_SINGLEPLAYER"; break; |
|
572 case ID_PAGE_TRAINING : pageName = "PAGE_TRAINING"; break; |
|
573 case ID_PAGE_SELECTWEAPON : pageName = "PAGE_SELECTWEAPON"; break; |
|
574 case ID_PAGE_NETSERVER : pageName = "PAGE_NETSERVER"; break; |
|
575 case ID_PAGE_INGAME : pageName = "PAGE_INGAME"; break; |
|
576 case ID_PAGE_ROOMSLIST : pageName = "PAGE_ROOMSLIST"; break; |
|
577 case ID_PAGE_CONNECTING : pageName = "PAGE_CONNECTING"; break; |
|
578 case ID_PAGE_SCHEME : pageName = "PAGE_SCHEME"; break; |
|
579 case ID_PAGE_ADMIN : pageName = "PAGE_ADMIN"; break; |
|
580 case ID_PAGE_CAMPAIGN : pageName = "PAGE_CAMPAIGN"; break; |
|
581 case ID_PAGE_DRAWMAP : pageName = "PAGE_DRAWMAP"; break; |
|
582 case ID_PAGE_DATADOWNLOAD : pageName = "PAGE_DATADOWNLOAD"; break; |
|
583 case ID_PAGE_VIDEOS : pageName = "PAGE_VIDEOS"; break; |
|
584 case MAX_PAGE : pageName = "MAX_PAGE"; break; |
|
585 default : pageName = "UNKNOWN_PAGE"; break; |
|
586 } |
|
587 return pageName; |
|
588 } |
|
589 |
|
556 void HWForm::OnPageShown(quint8 id, quint8 lastid) |
590 void HWForm::OnPageShown(quint8 id, quint8 lastid) |
557 { |
591 { |
558 #ifdef USE_XFIRE |
592 #ifdef USE_XFIRE |
559 updateXfire(); |
593 updateXfire(); |
560 #endif |
594 #endif |
561 |
595 |
562 QString openPrefix = "Debug: (PAGE_OPENED: "; |
596 qDebug("Leaving %s, entering %s", qPrintable(stringifyPageId(lastid)), qPrintable(stringifyPageId(id))); |
563 QString openSuffix = ")"; |
597 |
564 QString closePrefix = "Debug: (PAGE_LEFT: "; |
598 // pageEnter and pageLeave events |
565 QString closeSuffix = ")"; |
599 ((AbstractPage*)ui.Pages->widget(lastid))->triggerPageLeave(); |
566 |
600 ((AbstractPage*)ui.Pages->widget(id))->triggerPageEnter(); |
567 switch (lastid) { //Print the id of the page we're leaving |
|
568 case ID_PAGE_SETUP_TEAM : qDebug("%sPAGE_SETUP_TEAM%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
569 case ID_PAGE_SETUP : qDebug("%sPAGE_SETUP%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
570 case ID_PAGE_MULTIPLAYER : qDebug("%sPAGE_MULTIPLAYER%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
571 case ID_PAGE_DEMOS : qDebug("%sPAGE_DEMOS%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
572 case ID_PAGE_NET : qDebug("%sPAGE_NET%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
573 case ID_PAGE_NETGAME : qDebug("%sPAGE_NETGAME%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
574 case ID_PAGE_INFO : qDebug("%sPAGE_INFO%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
575 case ID_PAGE_MAIN : qDebug("%sPAGE_MAIN%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
576 case ID_PAGE_GAMESTATS : qDebug("%sPAGE_GAMESTATS%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
577 case ID_PAGE_SINGLEPLAYER : qDebug("%sPAGE_SINGLEPLAYER%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
578 case ID_PAGE_TRAINING : qDebug("%sPAGE_TRAINING%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
579 case ID_PAGE_SELECTWEAPON : qDebug("%sPAGE_SELECTWEAPON%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
580 case ID_PAGE_NETSERVER : qDebug("%sPAGE_NETSERVER%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
581 case ID_PAGE_INGAME : qDebug("%sPAGE_INGAME%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
582 case ID_PAGE_ROOMSLIST : qDebug("%sPAGE_ROOMSLIST%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
583 case ID_PAGE_CONNECTING : qDebug("%sPAGE_CONNECTING%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
584 case ID_PAGE_SCHEME : qDebug("%sPAGE_SCHEME%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
585 case ID_PAGE_ADMIN : qDebug("%sPAGE_ADMIN%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
586 case ID_PAGE_CAMPAIGN : qDebug("%sPAGE_CAMPAIGN%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
587 case ID_PAGE_DRAWMAP : qDebug("%sPAGE_DRAWMAP%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
588 case ID_PAGE_DATADOWNLOAD : qDebug("%sPAGE_DATADOWNLOAD%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
589 case ID_PAGE_FEEDBACK : qDebug("%sPAGE_FEEDBACK%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
590 case ID_PAGE_VIDEOS : qDebug("%sPAGE_VIDEOS%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
591 case MAX_PAGE : qDebug("%sMAX_PAGE%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
592 default : qDebug("%sUNKNOWN PAGE%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; |
|
593 } //end switch(lastid) |
|
594 switch (id) { //Print the id of the opened page |
|
595 case ID_PAGE_SETUP_TEAM : qDebug("%sPAGE_SETUP_TEAM%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
596 case ID_PAGE_SETUP : qDebug("%sPAGE_SETUP%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
597 case ID_PAGE_MULTIPLAYER : qDebug("%sPAGE_MULTIPLAYER%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
598 case ID_PAGE_DEMOS : qDebug("%sPAGE_DEMOS%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
599 case ID_PAGE_NET : qDebug("%sPAGE_NET%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
600 case ID_PAGE_NETGAME : qDebug("%sPAGE_NETGAME%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
601 case ID_PAGE_INFO : qDebug("%sPAGE_INFO%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
602 case ID_PAGE_MAIN : qDebug("%sPAGE_MAIN%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
603 case ID_PAGE_GAMESTATS : qDebug("%sPAGE_GAMESTATS%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
604 case ID_PAGE_SINGLEPLAYER : qDebug("%sPAGE_SINGLEPLAYER%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
605 case ID_PAGE_TRAINING : qDebug("%sPAGE_TRAINING%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
606 case ID_PAGE_SELECTWEAPON : qDebug("%sPAGE_SELECTWEAPON%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
607 case ID_PAGE_NETSERVER : qDebug("%sPAGE_NETSERVER%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
608 case ID_PAGE_INGAME : qDebug("%sPAGE_INGAME%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
609 case ID_PAGE_ROOMSLIST : qDebug("%sPAGE_ROOMSLIST%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
610 case ID_PAGE_CONNECTING : qDebug("%sPAGE_CONNECTING%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
611 case ID_PAGE_SCHEME : qDebug("%sPAGE_SCHEME%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
612 case ID_PAGE_ADMIN : qDebug("%sPAGE_ADMIN%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
613 case ID_PAGE_CAMPAIGN : qDebug("%sPAGE_CAMPAIGN%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
614 case ID_PAGE_DRAWMAP : qDebug("%sPAGE_DRAWMAP%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
615 case ID_PAGE_DATADOWNLOAD : qDebug("%sPAGE_DATADOWNLOAD%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
616 case ID_PAGE_FEEDBACK : qDebug("%sPAGE_FEEDBACK%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
617 case ID_PAGE_VIDEOS : qDebug("%sPAGE_VIDEOS%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
618 case MAX_PAGE : qDebug("%sMAX_PAGE%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
619 default : qDebug("%sUNKNOWN PAGE%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; |
|
620 } //end switch(id) |
|
621 |
601 |
622 if (id == ID_PAGE_DATADOWNLOAD) |
602 if (id == ID_PAGE_DATADOWNLOAD) |
623 { |
603 { |
624 ui.pageDataDownload->fetchList(); |
604 ui.pageDataDownload->fetchList(); |
625 } |
605 } |
688 && lastid != ID_PAGE_SELECTWEAPON) |
668 && lastid != ID_PAGE_SELECTWEAPON) |
689 { |
669 { |
690 curTeamSelWidget->resetPlayingTeams(teamsList); |
670 curTeamSelWidget->resetPlayingTeams(teamsList); |
691 } |
671 } |
692 } |
672 } |
693 else if (id == ID_PAGE_GAMESTATS) |
|
694 { |
|
695 ui.pageGameStats->renderStats(); |
|
696 } |
|
697 |
673 |
698 if (id == ID_PAGE_MAIN) |
674 if (id == ID_PAGE_MAIN) |
699 { |
675 { |
700 ui.pageOptions->setTeamOptionsEnabled(true); |
676 ui.pageOptions->setTeamOptionsEnabled(true); |
701 } |
|
702 |
|
703 if (id == ID_PAGE_FEEDBACK) |
|
704 { |
|
705 ui.pageFeedback->LoadCaptchaImage(); |
|
706 } |
677 } |
707 } |
678 } |
708 |
679 |
709 void HWForm::GoToPage(int id) |
680 void HWForm::GoToPage(int id) |
710 { |
681 { |
720 /* if (id == ID_PAGE_DRAWMAP || id == ID_PAGE_GAMESTATS) |
691 /* if (id == ID_PAGE_DRAWMAP || id == ID_PAGE_GAMESTATS) |
721 stopAnim = true; |
692 stopAnim = true; |
722 This were disabled due to broken flake animations. I believe the more general problems w/ opacity that forced its disable makes blocking these |
693 This were disabled due to broken flake animations. I believe the more general problems w/ opacity that forced its disable makes blocking these |
723 unnecessary. |
694 unnecessary. |
724 */ |
695 */ |
696 |
|
725 |
697 |
726 #if (QT_VERSION >= 0x040600) |
698 #if (QT_VERSION >= 0x040600) |
727 if (!stopAnim) |
699 if (!stopAnim) |
728 { |
700 { |
729 /**Start animation :**/ |
701 /**Start animation :**/ |
788 { |
760 { |
789 bool stopAnim = false; |
761 bool stopAnim = false; |
790 int curid = ui.Pages->currentIndex(); |
762 int curid = ui.Pages->currentIndex(); |
791 if (curid == ID_PAGE_MAIN) |
763 if (curid == ID_PAGE_MAIN) |
792 { |
764 { |
765 ((AbstractPage*)ui.Pages->widget(ID_PAGE_MAIN))->triggerPageLeave(); |
|
793 if (!ui.pageVideos->tryQuit(this)) |
766 if (!ui.pageVideos->tryQuit(this)) |
794 return; |
767 return; |
795 stopAnim = true; |
768 stopAnim = true; |
796 exit(); |
769 exit(); |
797 } |
770 } |
973 } |
946 } |
974 |
947 |
975 |
948 |
976 void HWForm::DeleteTeam(const QString & teamName) |
949 void HWForm::DeleteTeam(const QString & teamName) |
977 { |
950 { |
978 QMessageBox reallyDeleteMsg(this); |
951 ui.pageEditTeam->deleteTeam(teamName); |
979 reallyDeleteMsg.setIcon(QMessageBox::Question); |
952 UpdateTeamsLists(); |
980 reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Teams - Are you sure?")); |
|
981 reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the team '%1'?").arg(teamName)); |
|
982 reallyDeleteMsg.setWindowModality(Qt::WindowModal); |
|
983 reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); |
|
984 |
|
985 if (reallyDeleteMsg.exec() == QMessageBox::Ok) |
|
986 { |
|
987 ui.pageEditTeam->deleteTeam(teamName); |
|
988 UpdateTeamsLists(); |
|
989 } |
|
990 } |
953 } |
991 |
954 |
992 void HWForm::DeleteScheme() |
955 void HWForm::DeleteScheme() |
993 { |
956 { |
994 ui.pageScheme->selectScheme->setCurrentIndex(ui.pageOptions->SchemesName->currentIndex()); |
957 ui.pageScheme->selectScheme->setCurrentIndex(ui.pageOptions->SchemesName->currentIndex()); |
995 if (ui.pageOptions->SchemesName->currentIndex() < ammoSchemeModel->numberOfDefaultSchemes) |
958 if (ui.pageOptions->SchemesName->currentIndex() < ammoSchemeModel->numberOfDefaultSchemes) |
996 { |
959 { |
997 ShowErrorMessage(QMessageBox::tr("Cannot delete default scheme '%1'!").arg(ui.pageOptions->SchemesName->currentText())); |
960 MessageDialog::ShowErrorMessage(QMessageBox::tr("Cannot delete default scheme '%1'!").arg(ui.pageOptions->SchemesName->currentText()), this); |
998 } |
961 } |
999 else |
962 else |
1000 { |
963 { |
1001 ui.pageScheme->deleteRow(); |
964 ui.pageScheme->deleteRow(); |
1002 ammoSchemeModel->Save(); |
965 ammoSchemeModel->Save(); |
1018 void HWForm::PlayDemo() |
981 void HWForm::PlayDemo() |
1019 { |
982 { |
1020 QListWidgetItem * curritem = ui.pagePlayDemo->DemosList->currentItem(); |
983 QListWidgetItem * curritem = ui.pagePlayDemo->DemosList->currentItem(); |
1021 if (!curritem) |
984 if (!curritem) |
1022 { |
985 { |
1023 ShowErrorMessage(QMessageBox::tr("Please select a record from the list")); |
986 MessageDialog::ShowErrorMessage(QMessageBox::tr("Please select a record from the list"), this); |
1024 return; |
987 return; |
1025 } |
988 } |
1026 CreateGame(0, 0, 0); |
989 CreateGame(0, 0, 0); |
1027 game->PlayDemo(curritem->data(Qt::UserRole).toString(), ui.pagePlayDemo->isSave()); |
990 game->PlayDemo(curritem->data(Qt::UserRole).toString(), ui.pagePlayDemo->isSave()); |
1028 } |
991 } |
1046 NetConnectServer("netserver.hedgewars.org", 46631); |
1009 NetConnectServer("netserver.hedgewars.org", 46631); |
1047 } |
1010 } |
1048 |
1011 |
1049 void HWForm::NetPassword(const QString & nick) |
1012 void HWForm::NetPassword(const QString & nick) |
1050 { |
1013 { |
1014 Q_UNUSED(nick); |
|
1051 //Get hashes |
1015 //Get hashes |
1052 QString hash = config->passwordHash(); |
1016 QString hash = config->passwordHash(); |
1053 QString temphash = config->tempHash(); |
1017 QString temphash = config->tempHash(); |
1054 |
1018 |
1055 //Check them |
1019 //Check them |
1102 NetPassword(nick); |
1066 NetPassword(nick); |
1103 } |
1067 } |
1104 |
1068 |
1105 void HWForm::NetNickNotRegistered(const QString & nick) |
1069 void HWForm::NetNickNotRegistered(const QString & nick) |
1106 { |
1070 { |
1071 Q_UNUSED(nick); |
|
1072 |
|
1107 QMessageBox noRegMsg(this); |
1073 QMessageBox noRegMsg(this); |
1108 noRegMsg.setIcon(QMessageBox::Information); |
1074 noRegMsg.setIcon(QMessageBox::Information); |
1109 noRegMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Nick not registered")); |
1075 noRegMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Nick not registered")); |
1110 noRegMsg.setWindowModality(Qt::WindowModal); |
1076 noRegMsg.setWindowModality(Qt::WindowModal); |
1111 noRegMsg.setText(tr("Your nickname is not registered.\nTo prevent someone else from using it,\nplease register it at www.hedgewars.org")); |
1077 noRegMsg.setText(tr("Your nickname is not registered.\nTo prevent someone else from using it,\nplease register it at www.hedgewars.org")); |
1131 { |
1097 { |
1132 //ForcedDisconnect(tr("No nickname supplied.")); |
1098 //ForcedDisconnect(tr("No nickname supplied.")); |
1133 bool retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied.")); |
1099 bool retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied.")); |
1134 GoBack(); |
1100 GoBack(); |
1135 if (retry) { |
1101 if (retry) { |
1136 NetConnectOfficialServer(); |
1102 NetConnectOfficialServer(); |
1137 } |
1103 } |
1138 return; |
1104 return; |
1139 } |
1105 } |
1140 |
1106 |
1141 hwnet->NewNick(newNick); |
1107 hwnet->NewNick(newNick); |
1192 void HWForm::NetError(const QString & errmsg) |
1158 void HWForm::NetError(const QString & errmsg) |
1193 { |
1159 { |
1194 switch (ui.Pages->currentIndex()) |
1160 switch (ui.Pages->currentIndex()) |
1195 { |
1161 { |
1196 case ID_PAGE_INGAME: |
1162 case ID_PAGE_INGAME: |
1197 ShowErrorMessage(errmsg); |
1163 MessageDialog::ShowErrorMessage(errmsg, this); |
1198 // no break |
1164 // no break |
1199 case ID_PAGE_NETGAME: |
1165 case ID_PAGE_NETGAME: |
1200 ui.pageNetGame->displayError(errmsg); |
1166 ui.pageNetGame->displayError(errmsg); |
1201 break; |
1167 break; |
1202 default: |
1168 default: |
1212 ui.pageRoomsList->displayWarning(wrnmsg); |
1178 ui.pageRoomsList->displayWarning(wrnmsg); |
1213 } |
1179 } |
1214 |
1180 |
1215 void HWForm::_NetConnect(const QString & hostName, quint16 port, QString nick) |
1181 void HWForm::_NetConnect(const QString & hostName, quint16 port, QString nick) |
1216 { |
1182 { |
1183 Q_UNUSED(nick); |
|
1184 |
|
1217 if(hwnet) |
1185 if(hwnet) |
1218 { |
1186 { |
1219 hwnet->Disconnect(); |
1187 hwnet->Disconnect(); |
1220 delete hwnet; |
1188 delete hwnet; |
1221 hwnet=0; |
1189 hwnet=0; |
1289 hwnet, SLOT(banPlayer(const QString&))); |
1257 hwnet, SLOT(banPlayer(const QString&))); |
1290 connect(ui.pageNetGame->chatWidget, SIGNAL(info(const QString&)), |
1258 connect(ui.pageNetGame->chatWidget, SIGNAL(info(const QString&)), |
1291 hwnet, SLOT(infoPlayer(const QString&))); |
1259 hwnet, SLOT(infoPlayer(const QString&))); |
1292 connect(ui.pageNetGame->chatWidget, SIGNAL(follow(const QString&)), |
1260 connect(ui.pageNetGame->chatWidget, SIGNAL(follow(const QString&)), |
1293 hwnet, SLOT(followPlayer(const QString&))); |
1261 hwnet, SLOT(followPlayer(const QString&))); |
1262 connect(ui.pageNetGame->chatWidget, SIGNAL(consoleCommand(const QString&)), |
|
1263 hwnet, SLOT(consoleCommand(const QString&))); |
|
1294 connect(ui.pageRoomsList->chatWidget, SIGNAL(kick(const QString&)), |
1264 connect(ui.pageRoomsList->chatWidget, SIGNAL(kick(const QString&)), |
1295 hwnet, SLOT(kickPlayer(const QString&))); |
1265 hwnet, SLOT(kickPlayer(const QString&))); |
1296 connect(ui.pageRoomsList->chatWidget, SIGNAL(ban(const QString&)), |
1266 connect(ui.pageRoomsList->chatWidget, SIGNAL(ban(const QString&)), |
1297 hwnet, SLOT(banPlayer(const QString&))); |
1267 hwnet, SLOT(banPlayer(const QString&))); |
1298 connect(ui.pageRoomsList->chatWidget, SIGNAL(info(const QString&)), |
1268 connect(ui.pageRoomsList->chatWidget, SIGNAL(info(const QString&)), |
1299 hwnet, SLOT(infoPlayer(const QString&))); |
1269 hwnet, SLOT(infoPlayer(const QString&))); |
1300 connect(ui.pageRoomsList->chatWidget, SIGNAL(follow(const QString&)), |
1270 connect(ui.pageRoomsList->chatWidget, SIGNAL(follow(const QString&)), |
1301 hwnet, SLOT(followPlayer(const QString&))); |
1271 hwnet, SLOT(followPlayer(const QString&))); |
1272 connect(ui.pageRoomsList->chatWidget, SIGNAL(consoleCommand(const QString&)), |
|
1273 hwnet, SLOT(consoleCommand(const QString&))); |
|
1302 |
1274 |
1303 // chatting |
1275 // chatting |
1304 connect(ui.pageRoomsList->chatWidget, SIGNAL(chatLine(const QString&)), |
1276 connect(ui.pageRoomsList->chatWidget, SIGNAL(chatLine(const QString&)), |
1305 hwnet, SLOT(chatLineToLobby(const QString&))); |
1277 hwnet, SLOT(chatLineToLobby(const QString&))); |
1306 connect(hwnet, SIGNAL(chatStringLobby(const QString&)), |
1278 connect(hwnet, SIGNAL(chatStringLobby(const QString&)), |
1365 QString hash = config->passwordHash(); |
1337 QString hash = config->passwordHash(); |
1366 QString temphash = config->tempHash(); |
1338 QString temphash = config->tempHash(); |
1367 QString nickname = config->value("net/nick", "").toString(); |
1339 QString nickname = config->value("net/nick", "").toString(); |
1368 QString password; |
1340 QString password; |
1369 |
1341 |
1370 if (nickname.isEmpty() || hash.isEmpty()) { //if something from login is missing, start dialog loop |
1342 //if something from login is missing, start dialog loop |
1371 |
1343 if (nickname.isEmpty() || hash.isEmpty()) |
1344 { |
|
1372 while (nickname.isEmpty() || (hash.isEmpty() && temphash.isEmpty())) //while a nickname, or both hashes are missing |
1345 while (nickname.isEmpty() || (hash.isEmpty() && temphash.isEmpty())) //while a nickname, or both hashes are missing |
1373 { |
1346 { |
1374 //open dialog |
1347 //open dialog |
1375 HWPasswordDialog * pwDialog = new HWPasswordDialog(this); |
1348 HWPasswordDialog * pwDialog = new HWPasswordDialog(this); |
1349 // make the "new account" button dialog open a browser with the registration page |
|
1350 connect(pwDialog->pbNewAccount, SIGNAL(clicked()), this, SLOT(openRegistrationPage())); |
|
1376 pwDialog->cbSave->setChecked(config->value("net/savepassword", true).toBool()); |
1351 pwDialog->cbSave->setChecked(config->value("net/savepassword", true).toBool()); |
1377 |
1352 |
1378 //if nickname is present, put it into the field |
1353 //if nickname is present, put it into the field |
1379 if (!nickname.isEmpty()) { |
1354 if (!nickname.isEmpty()) { |
1380 pwDialog->leNickname->setText(nickname); |
1355 pwDialog->leNickname->setText(nickname); |
1381 pwDialog->lePassword->setFocus(); |
1356 pwDialog->lePassword->setFocus(); |
1382 } |
1357 } |
1383 |
1358 |
1384 //if dialog close, create an error message |
1359 //if dialog close, create an error message |
1385 if (pwDialog->exec() != QDialog::Accepted) { |
1360 if (pwDialog->exec() != QDialog::Accepted) { |
1361 delete pwDialog; |
|
1362 GoBack(); |
|
1363 return; |
|
1364 } |
|
1365 |
|
1366 //set nick and pass from the dialog |
|
1367 nickname = pwDialog->leNickname->text(); |
|
1368 password = pwDialog->lePassword->text(); |
|
1369 |
|
1370 //check the nickname variable |
|
1371 if (nickname.isEmpty()) { |
|
1372 int retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied.")); |
|
1373 GoBack(); |
|
1374 delete pwDialog; |
|
1375 if (retry) { |
|
1376 NetConnectOfficialServer(); |
|
1377 } |
|
1378 return; |
|
1379 } |
|
1380 |
|
1381 if (!password.isEmpty()) { |
|
1382 //calculate temphash and set it into config |
|
1383 temphash = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Md5).toHex(); |
|
1384 config->setTempHash(temphash); |
|
1385 |
|
1386 //if user wants to save password |
|
1387 bool save = pwDialog->cbSave->isChecked(); |
|
1388 config->setValue("net/savepassword", save); |
|
1389 if (save) // user wants to save password |
|
1390 { |
|
1391 ui.pageOptions->CBSavePassword->setChecked(true); |
|
1392 config->setPasswordHash(temphash); |
|
1393 } |
|
1394 } |
|
1395 else { |
|
1396 delete pwDialog; |
|
1397 config->setValue("net/nick", nickname); |
|
1398 config->updNetNick(); |
|
1399 config->clearPasswordHash(); |
|
1400 break; |
|
1401 } |
|
1402 |
|
1386 delete pwDialog; |
1403 delete pwDialog; |
1387 GoBack(); |
1404 |
1388 return; |
1405 //update nickname |
1389 } |
|
1390 |
|
1391 //set nick and pass from the dialog |
|
1392 nickname = pwDialog->leNickname->text(); |
|
1393 password = pwDialog->lePassword->text(); |
|
1394 |
|
1395 //check the nickname variable |
|
1396 if (nickname.isEmpty()) { |
|
1397 int retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied.")); |
|
1398 GoBack(); |
|
1399 delete pwDialog; |
|
1400 if (retry) { |
|
1401 NetConnectOfficialServer(); |
|
1402 } |
|
1403 return; |
|
1404 } |
|
1405 |
|
1406 if (!password.isEmpty()) { |
|
1407 //calculate temphash and set it into config |
|
1408 temphash = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Md5).toHex(); |
|
1409 config->setTempHash(temphash); |
|
1410 |
|
1411 //if user wants to save password |
|
1412 bool save = pwDialog->cbSave->isChecked(); |
|
1413 config->setValue("net/savepassword", save); |
|
1414 if (save) // user wants to save password |
|
1415 { |
|
1416 config->setPasswordHash(temphash); |
|
1417 } |
|
1418 } |
|
1419 else { |
|
1420 delete pwDialog; |
|
1421 config->setValue("net/nick", nickname); |
1406 config->setValue("net/nick", nickname); |
1422 config->updNetNick(); |
1407 config->updNetNick(); |
1423 config->clearPasswordHash(); |
1408 |
1424 break; |
1409 //and all the variables |
1425 } |
1410 hash = config->passwordHash(); |
1426 |
1411 temphash = config->tempHash(); |
1427 delete pwDialog; |
1412 nickname = config->value("net/nick", "").toString(); |
1428 |
|
1429 //update nickname |
|
1430 config->setValue("net/nick", nickname); |
|
1431 config->updNetNick(); |
|
1432 |
|
1433 //and all the variables |
|
1434 hash = config->passwordHash(); |
|
1435 temphash = config->tempHash(); |
|
1436 nickname = config->value("net/nick", "").toString(); |
|
1437 } |
1413 } |
1438 } |
1414 } |
1439 |
1415 |
1440 ui.pageRoomsList->setUser(nickname); |
1416 ui.pageRoomsList->setUser(nickname); |
1441 ui.pageNetGame->setUser(nickname); |
1417 ui.pageNetGame->setUser(nickname); |
1467 config->SaveOptions(); |
1443 config->SaveOptions(); |
1468 |
1444 |
1469 pnetserver = new HWNetServer; |
1445 pnetserver = new HWNetServer; |
1470 if (!pnetserver->StartServer(ui.pageNetServer->sbPort->value())) |
1446 if (!pnetserver->StartServer(ui.pageNetServer->sbPort->value())) |
1471 { |
1447 { |
1472 ShowErrorMessage(QMessageBox::tr("Unable to start server")); |
1448 MessageDialog::ShowErrorMessage(QMessageBox::tr("Unable to start server"), this); |
1473 |
1449 |
1474 delete pnetserver; |
1450 delete pnetserver; |
1475 pnetserver = 0; |
1451 pnetserver = 0; |
1476 return; |
1452 return; |
1477 } |
1453 } |
1526 if (pnetserver) |
1502 if (pnetserver) |
1527 return; // we have server - let it care of all things |
1503 return; // we have server - let it care of all things |
1528 if (hwnet) |
1504 if (hwnet) |
1529 { |
1505 { |
1530 QString errorStr = QMessageBox::tr("Connection to server is lost") + (reason.isEmpty()?"":("\n\n" + HWNewNet::tr("Quit reason: ") + '"' + reason +'"')); |
1506 QString errorStr = QMessageBox::tr("Connection to server is lost") + (reason.isEmpty()?"":("\n\n" + HWNewNet::tr("Quit reason: ") + '"' + reason +'"')); |
1531 ShowErrorMessage(errorStr); |
1507 MessageDialog::ShowErrorMessage(errorStr, this); |
1532 } |
1508 } |
1533 |
1509 |
1534 while (ui.Pages->currentIndex() != ID_PAGE_NET |
1510 while (ui.Pages->currentIndex() != ID_PAGE_NET |
1535 && ui.Pages->currentIndex() != ID_PAGE_MAIN) |
1511 && ui.Pages->currentIndex() != ID_PAGE_MAIN) |
1536 { |
1512 { |
1632 connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); |
1608 connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); |
1633 connect(game, SIGNAL(HaveRecord(RecordType, const QByteArray &)), this, SLOT(GetRecord(RecordType, const QByteArray &))); |
1609 connect(game, SIGNAL(HaveRecord(RecordType, const QByteArray &)), this, SLOT(GetRecord(RecordType, const QByteArray &))); |
1634 m_lastDemo = QByteArray(); |
1610 m_lastDemo = QByteArray(); |
1635 } |
1611 } |
1636 |
1612 |
1637 void HWForm::ShowErrorMessage(const QString & msg) |
|
1638 { |
|
1639 QMessageBox msgMsg(this); |
|
1640 msgMsg.setIcon(QMessageBox::Warning); |
|
1641 msgMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Error")); |
|
1642 msgMsg.setText(msg); |
|
1643 msgMsg.setWindowModality(Qt::WindowModal); |
|
1644 msgMsg.exec(); |
|
1645 } |
|
1646 |
|
1647 void HWForm::GetRecord(RecordType type, const QByteArray & record) |
1613 void HWForm::GetRecord(RecordType type, const QByteArray & record) |
1648 { |
1614 { |
1649 if (type != rtNeither) |
1615 if (type != rtNeither) |
1650 { |
1616 { |
1651 QString filename; |
1617 QString filename; |
1674 filename = cfgdir->absolutePath() + "/Saves/" + recordFileName + "." + *cProtoVer + ".hws"; |
1640 filename = cfgdir->absolutePath() + "/Saves/" + recordFileName + "." + *cProtoVer + ".hws"; |
1675 } |
1641 } |
1676 |
1642 |
1677 QFile demofile(filename); |
1643 QFile demofile(filename); |
1678 if (!demofile.open(QIODevice::WriteOnly)) |
1644 if (!demofile.open(QIODevice::WriteOnly)) |
1679 ShowErrorMessage(tr("Cannot save record to file %1").arg(filename)); |
1645 MessageDialog::ShowErrorMessage(tr("Cannot save record to file %1").arg(filename), this); |
1680 else |
1646 else |
1681 { |
1647 { |
1682 demofile.write(demo); |
1648 demofile.write(demo); |
1683 demofile.close(); |
1649 demofile.close(); |
1684 } |
1650 } |
1745 SDLInteraction::instance().stopMusic(); |
1711 SDLInteraction::instance().stopMusic(); |
1746 } |
1712 } |
1747 |
1713 |
1748 void HWForm::NetGameChangeStatus(bool isMaster) |
1714 void HWForm::NetGameChangeStatus(bool isMaster) |
1749 { |
1715 { |
1750 ui.pageNetGame->pGameCFG->setEnabled(isMaster); |
1716 ui.pageNetGame->pGameCFG->setMaster(isMaster); |
1751 ui.pageNetGame->pNetTeamsWidget->setInteractivity(isMaster); |
1717 ui.pageNetGame->pNetTeamsWidget->setInteractivity(isMaster); |
1752 |
1718 |
1753 if (isMaster) |
1719 if (isMaster) |
1754 NetGameMaster(); |
1720 NetGameMaster(); |
1755 else |
1721 else |
1760 { |
1726 { |
1761 ui.pageNetGame->setMasterMode(true); |
1727 ui.pageNetGame->setMasterMode(true); |
1762 ui.pageNetGame->restrictJoins->setChecked(false); |
1728 ui.pageNetGame->restrictJoins->setChecked(false); |
1763 ui.pageNetGame->restrictTeamAdds->setChecked(false); |
1729 ui.pageNetGame->restrictTeamAdds->setChecked(false); |
1764 ui.pageNetGame->pGameCFG->GameSchemes->setModel(ammoSchemeModel); |
1730 ui.pageNetGame->pGameCFG->GameSchemes->setModel(ammoSchemeModel); |
1765 ui.pageNetGame->pGameCFG->setEnabled(true); |
1731 ui.pageNetGame->pGameCFG->setMaster(true); |
1766 ui.pageNetGame->pNetTeamsWidget->setInteractivity(true); |
1732 ui.pageNetGame->pNetTeamsWidget->setInteractivity(true); |
1767 |
1733 |
1768 if (hwnet) |
1734 if (hwnet) |
1769 { |
1735 { |
1770 // disconnect connections first to ensure their inexistance and not to connect twice |
1736 // disconnect connections first to ensure their inexistance and not to connect twice |
1771 ui.pageNetGame->BtnStart->disconnect(hwnet); |
1737 ui.pageNetGame->BtnStart->disconnect(this); |
1772 ui.pageNetGame->BtnUpdate->disconnect(hwnet); |
1738 ui.pageNetGame->BtnUpdate->disconnect(hwnet); |
1739 ui.pageNetGame->leRoomName->disconnect(hwnet); |
|
1773 ui.pageNetGame->restrictJoins->disconnect(hwnet); |
1740 ui.pageNetGame->restrictJoins->disconnect(hwnet); |
1774 ui.pageNetGame->restrictTeamAdds->disconnect(hwnet); |
1741 ui.pageNetGame->restrictTeamAdds->disconnect(hwnet); |
1775 ui.pageNetGame->disconnect(hwnet, SLOT(updateRoomName(const QString&))); |
1742 ui.pageNetGame->disconnect(hwnet, SLOT(updateRoomName(const QString&))); |
1776 |
1743 |
1777 ui.pageNetGame->setRoomName(hwnet->getRoom()); |
1744 ui.pageNetGame->setRoomName(hwnet->getRoom()); |
1778 |
1745 |
1779 connect(ui.pageNetGame->BtnStart, SIGNAL(clicked()), hwnet, SLOT(startGame())); |
1746 connect(ui.pageNetGame->BtnStart, SIGNAL(clicked()), this, SLOT(startGame())); |
1780 connect(ui.pageNetGame, SIGNAL(askForUpdateRoomName(const QString &)), hwnet, SLOT(updateRoomName(const QString &))); |
1747 connect(ui.pageNetGame, SIGNAL(askForUpdateRoomName(const QString &)), hwnet, SLOT(updateRoomName(const QString &))); |
1781 connect(ui.pageNetGame->restrictJoins, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictJoins())); |
1748 connect(ui.pageNetGame->restrictJoins, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictJoins())); |
1782 connect(ui.pageNetGame->restrictTeamAdds, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictTeamAdds())); |
1749 connect(ui.pageNetGame->restrictTeamAdds, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictTeamAdds())); |
1783 connect(ui.pageNetGame->pGameCFG->GameSchemes->model(), |
1750 connect(ui.pageNetGame->pGameCFG->GameSchemes->model(), |
1784 SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), |
1751 SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), |
1788 } |
1755 } |
1789 } |
1756 } |
1790 |
1757 |
1791 void HWForm::NetGameSlave() |
1758 void HWForm::NetGameSlave() |
1792 { |
1759 { |
1793 ui.pageNetGame->pGameCFG->setEnabled(false); |
1760 ui.pageNetGame->pGameCFG->setMaster(false); |
1794 ui.pageNetGame->pNetTeamsWidget->setInteractivity(false); |
1761 ui.pageNetGame->pNetTeamsWidget->setInteractivity(false); |
1795 |
1762 |
1796 if (hwnet) |
1763 if (hwnet) |
1797 { |
1764 { |
1798 NetAmmoSchemeModel * netAmmo = new NetAmmoSchemeModel(hwnet); |
1765 NetAmmoSchemeModel * netAmmo = new NetAmmoSchemeModel(hwnet); |
1799 connect(hwnet, SIGNAL(netSchemeConfig(QStringList &)), netAmmo, SLOT(setNetSchemeConfig(QStringList &))); |
1766 connect(hwnet, SIGNAL(netSchemeConfig(QStringList &)), netAmmo, SLOT(setNetSchemeConfig(QStringList &))); |
1800 ui.pageNetGame->pGameCFG->GameSchemes->setModel(netAmmo); |
1767 ui.pageNetGame->pGameCFG->GameSchemes->setModel(netAmmo); |
1768 |
|
1769 ui.pageNetGame->setRoomName(hwnet->getRoom()); |
|
1801 |
1770 |
1802 ui.pageNetGame->pGameCFG->GameSchemes->view()->disconnect(hwnet); |
1771 ui.pageNetGame->pGameCFG->GameSchemes->view()->disconnect(hwnet); |
1803 connect(hwnet, SIGNAL(netSchemeConfig(QStringList &)), |
1772 connect(hwnet, SIGNAL(netSchemeConfig(QStringList &)), |
1804 this, SLOT(selectFirstNetScheme())); |
1773 this, SLOT(selectFirstNetScheme())); |
1805 } |
1774 } |
1891 #ifdef Q_WS_WIN |
1860 #ifdef Q_WS_WIN |
1892 prefix = prefix.replace("/","\\"); |
1861 prefix = prefix.replace("/","\\"); |
1893 userPrefix = userPrefix.replace("/","\\"); |
1862 userPrefix = userPrefix.replace("/","\\"); |
1894 #endif |
1863 #endif |
1895 |
1864 |
1896 QRect resolution = config->vid_Resolution(); |
1865 std::pair<QRect, QRect> resolutions = config->vid_ResolutionPair(); |
1897 return QString("--prefix " + prefix |
1866 return QString("--prefix " + prefix |
1898 + " --user-prefix " + userPrefix |
1867 + " --user-prefix " + userPrefix |
1899 + " --width " + QString::number(resolution.width()) |
1868 + " --fullscreen-width " + QString::number(resolutions.first.width()) |
1900 + " --height " + QString::number(resolution.height()) |
1869 + " --fullscreen-height " + QString::number(resolutions.first.height()) |
1870 + " --width " + QString::number(resolutions.second.width()) |
|
1871 + " --height " + QString::number(resolutions.second.height()) |
|
1901 + " --volume " + QString::number(config->volume()) |
1872 + " --volume " + QString::number(config->volume()) |
1902 + (config->isMusicEnabled() ? "" : " --nomusic") |
1873 + (config->isMusicEnabled() ? "" : " --nomusic") |
1903 + (config->isSoundEnabled() ? "" : " --nosound") |
1874 + (config->isSoundEnabled() ? "" : " --nosound") |
1904 + " --locale " + config->language() + ".txt" |
1875 + " --locale " + config->language() + ".txt" |
1905 + (config->vid_Fullscreen() ? " --fullscreen" : "") |
1876 + (config->vid_Fullscreen() ? " --fullscreen" : "") |
1953 infoMsg.setText(QMessageBox::tr("All file associations have been set")); |
1924 infoMsg.setText(QMessageBox::tr("All file associations have been set")); |
1954 infoMsg.setWindowModality(Qt::WindowModal); |
1925 infoMsg.setWindowModality(Qt::WindowModal); |
1955 infoMsg.exec(); |
1926 infoMsg.exec(); |
1956 } |
1927 } |
1957 else |
1928 else |
1958 ShowErrorMessage(QMessageBox::tr("File association failed.")); |
1929 MessageDialog::ShowErrorMessage(QMessageBox::tr("File association failed."), this); |
1930 } |
|
1931 |
|
1932 void HWForm::openRegistrationPage() |
|
1933 { |
|
1934 QDesktopServices::openUrl(QUrl("http://www.hedgewars.org/user/register")); |
|
1959 } |
1935 } |
1960 |
1936 |
1961 void HWForm::saveDemoWithCustomName() |
1937 void HWForm::saveDemoWithCustomName() |
1962 { |
1938 { |
1963 if(!m_lastDemo.isEmpty()) |
1939 if(!m_lastDemo.isEmpty()) |
1972 { |
1948 { |
1973 QString filePath = cfgdir->absolutePath() + "/Demos/" + fileName + "." + *cProtoVer + ".hwd"; |
1949 QString filePath = cfgdir->absolutePath() + "/Demos/" + fileName + "." + *cProtoVer + ".hwd"; |
1974 QFile demofile(filePath); |
1950 QFile demofile(filePath); |
1975 ok = demofile.open(QIODevice::WriteOnly); |
1951 ok = demofile.open(QIODevice::WriteOnly); |
1976 if (!ok) |
1952 if (!ok) |
1977 ShowErrorMessage(tr("Cannot save record to file %1").arg(filePath)); |
1953 MessageDialog::ShowErrorMessage(tr("Cannot save record to file %1").arg(filePath), this); |
1978 else |
1954 else |
1979 { |
1955 { |
1980 ok = -1 != demofile.write(m_lastDemo); |
1956 ok = -1 != demofile.write(m_lastDemo); |
1981 demofile.close(); |
1957 demofile.close(); |
1982 } |
1958 } |
1984 } |
1960 } |
1985 while(!fileName.isEmpty() && !ok); |
1961 while(!fileName.isEmpty() && !ok); |
1986 } |
1962 } |
1987 } |
1963 } |
1988 |
1964 |
1989 void HWForm::SendFeedback() |
1965 |
1990 { |
1966 void HWForm::ShowErrorMessage(const QString & msg) |
1991 // Get form data |
1967 { |
1992 |
1968 MessageDialog::ShowErrorMessage(msg, this); |
1993 QString summary = ui.pageFeedback->summary->text(); |
1969 } |
1994 QString description = ui.pageFeedback->description->toPlainText(); |
1970 |
1995 QString email = ui.pageFeedback->email->text(); |
1971 void HWForm::showFeedbackDialog() |
1996 QString captchaCode = ui.pageFeedback->captcha_code->text(); |
1972 { |
1997 QString captchaID = QString::number(ui.pageFeedback->captchaID); |
1973 FeedbackDialog dialog(this); |
1998 QString version = "HedgewarsFoundation-Hedgewars-" + (cVersionString?(*cVersionString):QString("")); |
1974 dialog.exec(); |
1999 |
1975 } |
2000 if (summary.isEmpty() || description.isEmpty()) |
1976 |
2001 { |
1977 void HWForm::startGame() |
2002 ShowErrorMessage(QMessageBox::tr("Please fill out all fields. Email is optional.")); |
1978 { |
2003 return; |
1979 QMessageBox questionMsg(this); |
2004 } |
1980 questionMsg.setIcon(QMessageBox::Question); |
2005 |
1981 questionMsg.setWindowTitle(QMessageBox::tr("Not all players are ready")); |
2006 // Submit issue to PHP script |
1982 questionMsg.setText(QMessageBox::tr("Are you sure you want to start this game?\nNot all players are ready.")); |
2007 |
1983 questionMsg.setWindowModality(Qt::WindowModal); |
2008 QByteArray body; |
1984 questionMsg.addButton(QMessageBox::Yes); |
2009 body.append("captcha="); |
1985 questionMsg.addButton(QMessageBox::Cancel); |
2010 body.append(captchaID); |
1986 |
2011 body.append("&code="); |
1987 if (hwnet->allPlayersReady() || questionMsg.exec() == QMessageBox::Yes) |
2012 body.append(captchaCode); |
1988 hwnet->startGame(); |
2013 body.append("&version="); |
1989 } |
2014 body.append(QUrl::toPercentEncoding(version)); |
|
2015 body.append("&title="); |
|
2016 body.append(QUrl::toPercentEncoding(summary)); |
|
2017 body.append("&body="); |
|
2018 body.append(QUrl::toPercentEncoding(description)); |
|
2019 body.append("&email="); |
|
2020 body.append(QUrl::toPercentEncoding(email)); |
|
2021 if (ui.pageFeedback->CheckSendSpecs->isChecked()) |
|
2022 { |
|
2023 body.append("&specs="); |
|
2024 body.append(QUrl::toPercentEncoding(ui.pageFeedback->specs)); |
|
2025 } |
|
2026 |
|
2027 nam = new QNetworkAccessManager(this); |
|
2028 connect(nam, SIGNAL(finished(QNetworkReply*)), |
|
2029 this, SLOT(finishedSlot(QNetworkReply*))); |
|
2030 |
|
2031 QNetworkRequest header(QUrl("http://hedgewars.org/feedback/?submit")); |
|
2032 header.setRawHeader("Content-Length", QString::number(body.size()).toAscii()); |
|
2033 |
|
2034 nam->post(header, body); |
|
2035 } |
|
2036 |
|
2037 void HWForm::finishedSlot(QNetworkReply* reply) |
|
2038 { |
|
2039 if (reply && reply->error() == QNetworkReply::NoError) |
|
2040 { |
|
2041 QMessageBox infoMsg(this); |
|
2042 infoMsg.setIcon(QMessageBox::Information); |
|
2043 infoMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Success")); |
|
2044 infoMsg.setText(reply->readAll()); |
|
2045 infoMsg.setWindowModality(Qt::WindowModal); |
|
2046 infoMsg.exec(); |
|
2047 |
|
2048 ui.pageFeedback->summary->clear(); |
|
2049 ui.pageFeedback->email->clear(); |
|
2050 ui.pageFeedback->description->clear(); |
|
2051 ui.pageFeedback->LoadCaptchaImage(); |
|
2052 |
|
2053 return; |
|
2054 } |
|
2055 else |
|
2056 { |
|
2057 ShowErrorMessage(QString("Error: ") + reply->readAll()); |
|
2058 ui.pageFeedback->LoadCaptchaImage(); |
|
2059 } |
|
2060 } |
|
2061 |