QTfrontend/hwform.cpp
branchios-develop
changeset 13418 ba39a1d396c0
parent 13335 3f2ee2f9b51d
child 13491 4ef83bcb850b
equal deleted inserted replaced
13416:6e8b807bda4b 13418:ba39a1d396c0
    88 #include "netserverslist.h"
    88 #include "netserverslist.h"
    89 #include "netudpserver.h"
    89 #include "netudpserver.h"
    90 #include "chatwidget.h"
    90 #include "chatwidget.h"
    91 #include "input_ip.h"
    91 #include "input_ip.h"
    92 #include "input_password.h"
    92 #include "input_password.h"
    93 #include "ammoSchemeModel.h"
    93 #include "gameSchemeModel.h"
    94 #include "bgwidget.h"
    94 #include "bgwidget.h"
    95 #include "drawmapwidget.h"
    95 #include "drawmapwidget.h"
    96 #include "mouseoverfilter.h"
    96 #include "mouseoverfilter.h"
    97 #include "roomslistmodel.h"
    97 #include "roomslistmodel.h"
    98 #include "recorder.h"
    98 #include "recorder.h"
   229     for (int i = 0; i < nPages; i++)
   229     for (int i = 0; i < nPages; i++)
   230         connect(ui.Pages->widget(i), SIGNAL(goBack()), this, SLOT(GoBack()));
   230         connect(ui.Pages->widget(i), SIGNAL(goBack()), this, SLOT(GoBack()));
   231 
   231 
   232     pageSwitchMapper = new QSignalMapper(this);
   232     pageSwitchMapper = new QSignalMapper(this);
   233     connect(pageSwitchMapper, SIGNAL(mapped(int)), this, SLOT(GoToPage(int)));
   233     connect(pageSwitchMapper, SIGNAL(mapped(int)), this, SLOT(GoToPage(int)));
   234 
   234     
   235     connect(config, SIGNAL(frontendFullscreen(bool)), this, SLOT(onFrontendFullscreen(bool)));
       
   236     onFrontendFullscreen(config->isFrontendFullscreen());
       
   237 
       
   238     connect(ui.pageMain->BtnSinglePlayer, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
   235     connect(ui.pageMain->BtnSinglePlayer, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
   239     pageSwitchMapper->setMapping(ui.pageMain->BtnSinglePlayer, ID_PAGE_SINGLEPLAYER);
   236     pageSwitchMapper->setMapping(ui.pageMain->BtnSinglePlayer, ID_PAGE_SINGLEPLAYER);
   240 
   237 
   241     connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
   238     connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
   242     pageSwitchMapper->setMapping(ui.pageMain->BtnSetup, ID_PAGE_SETUP);
   239     pageSwitchMapper->setMapping(ui.pageMain->BtnSetup, ID_PAGE_SETUP);
   345     connect(ui.pageMain->BtnNetLocal, SIGNAL(clicked()), this, SLOT(GoToNet()));
   342     connect(ui.pageMain->BtnNetLocal, SIGNAL(clicked()), this, SLOT(GoToNet()));
   346     connect(ui.pageMain->BtnNetOfficial, SIGNAL(clicked()), this, SLOT(NetConnectOfficialServer()));
   343     connect(ui.pageMain->BtnNetOfficial, SIGNAL(clicked()), this, SLOT(NetConnectOfficialServer()));
   347 
   344 
   348     connect(ui.pageVideos, SIGNAL(goBack()), config, SLOT(SaveVideosOptions()));
   345     connect(ui.pageVideos, SIGNAL(goBack()), config, SLOT(SaveVideosOptions()));
   349 
   346 
   350     ammoSchemeModel = new AmmoSchemeModel(this, cfgdir->absolutePath() + "/schemes.ini");
   347     gameSchemeModel = new GameSchemeModel(this, cfgdir->absolutePath() + "/Schemes/Game");
   351     ui.pageScheme->setModel(ammoSchemeModel);
   348     ui.pageScheme->setModel(gameSchemeModel);
   352     ui.pageMultiplayer->gameCFG->GameSchemes->setModel(ammoSchemeModel);
   349     ui.pageMultiplayer->gameCFG->GameSchemes->setModel(gameSchemeModel);
   353     ui.pageOptions->SchemesName->setModel(ammoSchemeModel);
   350     ui.pageOptions->SchemesName->setModel(gameSchemeModel);
   354 
   351 
   355     wBackground = new BGWidget(this);
   352     wBackground = new BGWidget(this);
   356     wBackground->setFixedSize(this->width(), this->height());
   353     wBackground->setFixedSize(this->width(), this->height());
   357     wBackground->lower();
   354     wBackground->lower();
   358     wBackground->init();
   355     wBackground->init();
   378 
   375 
   379     ui.Pages->setCurrentIndex(ID_PAGE_INFO);
   376     ui.Pages->setCurrentIndex(ID_PAGE_INFO);
   380     PagesStack.push(ID_PAGE_MAIN);
   377     PagesStack.push(ID_PAGE_MAIN);
   381     ((AbstractPage*)ui.Pages->widget(ID_PAGE_MAIN))->triggerPageEnter();
   378     ((AbstractPage*)ui.Pages->widget(ID_PAGE_MAIN))->triggerPageEnter();
   382     GoBack();
   379     GoBack();
       
   380 
       
   381     connect(config, SIGNAL(frontendFullscreen(bool)), this, SLOT(onFrontendFullscreen(bool)));
       
   382     onFrontendFullscreen(config->isFrontendFullscreen());
   383 }
   383 }
   384 
   384 
   385 void HWForm::onFrontendFullscreen(bool value)
   385 void HWForm::onFrontendFullscreen(bool value)
   386 {
   386 {
   387     if (value)
   387     if (value)
   642 }
   642 }
   643 
   643 
   644 void HWForm::GoToVideos()
   644 void HWForm::GoToVideos()
   645 {
   645 {
   646     GoToPage(ID_PAGE_VIDEOS);
   646     GoToPage(ID_PAGE_VIDEOS);
       
   647 }
       
   648 
       
   649 void HWForm::GoToTraining()
       
   650 {
       
   651     GoToPage(ID_PAGE_TRAINING);
   647 }
   652 }
   648 
   653 
   649 //TODO: maybe find a better place for this?
   654 //TODO: maybe find a better place for this?
   650 QString HWForm::stringifyPageId(quint32 id)
   655 QString HWForm::stringifyPageId(quint32 id)
   651 {
   656 {
   912     if (curid == ID_PAGE_NETGAME && hwnet && hwnet->isInRoom()) hwnet->partRoom();
   917     if (curid == ID_PAGE_NETGAME && hwnet && hwnet->isInRoom()) hwnet->partRoom();
   913     // need to work on this, can cause invalid state for admin quit trying to prevent bad state message on kick
   918     // need to work on this, can cause invalid state for admin quit trying to prevent bad state message on kick
   914     //if (curid == ID_PAGE_NETGAME && (!game || game->gameState != gsStarted)) hwnet->partRoom();
   919     //if (curid == ID_PAGE_NETGAME && (!game || game->gameState != gsStarted)) hwnet->partRoom();
   915 
   920 
   916     if (curid == ID_PAGE_SCHEME)
   921     if (curid == ID_PAGE_SCHEME)
   917         ammoSchemeModel->Save();
   922         gameSchemeModel->Save();
   918 
   923 
   919 #if (QT_VERSION >= 0x040600)
   924 #if (QT_VERSION >= 0x040600)
   920     /**Start animation :**/
   925     /**Start animation :**/
   921     if (curid != 0 && !stopAnim)
   926     if (curid != 0 && !stopAnim)
   922     {
   927     {
  1072 }
  1077 }
  1073 
  1078 
  1074 void HWForm::DeleteScheme()
  1079 void HWForm::DeleteScheme()
  1075 {
  1080 {
  1076     ui.pageScheme->selectScheme->setCurrentIndex(ui.pageOptions->SchemesName->currentIndex());
  1081     ui.pageScheme->selectScheme->setCurrentIndex(ui.pageOptions->SchemesName->currentIndex());
  1077     if (ui.pageOptions->SchemesName->currentIndex() < ammoSchemeModel->numberOfDefaultSchemes)
  1082     if (ui.pageOptions->SchemesName->currentIndex() < gameSchemeModel->numberOfDefaultSchemes)
  1078     {
  1083     {
  1079         MessageDialog::ShowErrorMessage(QMessageBox::tr("Cannot delete default scheme '%1'!").arg(ui.pageOptions->SchemesName->currentText()), this);
  1084         MessageDialog::ShowErrorMessage(QMessageBox::tr("Cannot delete default scheme '%1'!").arg(ui.pageOptions->SchemesName->currentText()), this);
  1080     }
  1085     }
  1081     else
  1086     else
  1082     {
  1087     {
  1083         ui.pageScheme->deleteRow();
  1088         ui.pageScheme->deleteRow();
  1084         ammoSchemeModel->Save();
  1089         gameSchemeModel->Save();
  1085     }
  1090     }
  1086 }
  1091 }
  1087 
  1092 
  1088 void HWForm::DeleteWeaponSet()
  1093 void HWForm::DeleteWeaponSet()
  1089 {
  1094 {
  1892 {
  1897 {
  1893     ui.pageNetGame->setMasterMode(true);
  1898     ui.pageNetGame->setMasterMode(true);
  1894     ui.pageNetGame->restrictJoins->setChecked(false);
  1899     ui.pageNetGame->restrictJoins->setChecked(false);
  1895     ui.pageNetGame->restrictTeamAdds->setChecked(false);
  1900     ui.pageNetGame->restrictTeamAdds->setChecked(false);
  1896     ui.pageNetGame->restrictUnregistered->setChecked(false);
  1901     ui.pageNetGame->restrictUnregistered->setChecked(false);
  1897     ui.pageNetGame->pGameCFG->GameSchemes->setModel(ammoSchemeModel);
  1902     ui.pageNetGame->pGameCFG->GameSchemes->setModel(gameSchemeModel);
  1898     ui.pageNetGame->pGameCFG->setMaster(true);
  1903     ui.pageNetGame->pGameCFG->setMaster(true);
  1899     ui.pageNetGame->pNetTeamsWidget->setInteractivity(true);
  1904     ui.pageNetGame->pNetTeamsWidget->setInteractivity(true);
  1900 
  1905 
  1901     if (hwnet)
  1906     if (hwnet)
  1902     {
  1907     {
  1929     ui.pageNetGame->pGameCFG->setMaster(false);
  1934     ui.pageNetGame->pGameCFG->setMaster(false);
  1930     ui.pageNetGame->pNetTeamsWidget->setInteractivity(false);
  1935     ui.pageNetGame->pNetTeamsWidget->setInteractivity(false);
  1931 
  1936 
  1932     if (hwnet)
  1937     if (hwnet)
  1933     {
  1938     {
  1934         NetAmmoSchemeModel * netAmmo = new NetAmmoSchemeModel(hwnet);
  1939         NetGameSchemeModel * netAmmo = new NetGameSchemeModel(hwnet);
  1935         connect(hwnet, SIGNAL(netSchemeConfig(QStringList)), netAmmo, SLOT(setNetSchemeConfig(QStringList)));
  1940         connect(hwnet, SIGNAL(netSchemeConfig(QStringList)), netAmmo, SLOT(setNetSchemeConfig(QStringList)));
  1936 
  1941 
  1937         ui.pageNetGame->pGameCFG->GameSchemes->setModel(netAmmo);
  1942         ui.pageNetGame->pGameCFG->GameSchemes->setModel(netAmmo);
  1938 
  1943 
  1939         ui.pageNetGame->setRoomName(hwnet->getRoom());
  1944         ui.pageNetGame->setRoomName(hwnet->getRoom());