QTfrontend/hwform.cpp
changeset 4509 816a0bff5019
parent 4433 e0092290b7c5
child 4511 df827e70ae63
equal deleted inserted replaced
4508:2a14477d1d15 4509:816a0bff5019
    33 #include <QTimer>
    33 #include <QTimer>
    34 #include <QScrollBar>
    34 #include <QScrollBar>
    35 #include <QDataWidgetMapper>
    35 #include <QDataWidgetMapper>
    36 #include <QTableView>
    36 #include <QTableView>
    37 #include <QCryptographicHash>
    37 #include <QCryptographicHash>
       
    38 #include <QSignalMapper>
    38 
    39 
    39 #include "hwform.h"
    40 #include "hwform.h"
    40 #include "game.h"
    41 #include "game.h"
    41 #include "team.h"
    42 #include "team.h"
    42 #include "namegen.h"
    43 #include "namegen.h"
   106 
   107 
   107     UpdateTeamsLists();
   108     UpdateTeamsLists();
   108     UpdateCampaignPage(0);
   109     UpdateCampaignPage(0);
   109     UpdateWeapons();
   110     UpdateWeapons();
   110 
   111 
       
   112     pageSwitchMapper = new QSignalMapper(this);
       
   113     connect(pageSwitchMapper, SIGNAL(mapped(int)), this, SLOT(GoToPage(int)));
       
   114 
   111     connect(config, SIGNAL(frontendFullscreen(bool)), this, SLOT(onFrontendFullscreen(bool)));
   115     connect(config, SIGNAL(frontendFullscreen(bool)), this, SLOT(onFrontendFullscreen(bool)));
   112     onFrontendFullscreen(config->isFrontendFullscreen());
   116     onFrontendFullscreen(config->isFrontendFullscreen());
   113 
   117 
   114     connect(ui.pageMain->BtnSinglePlayer, SIGNAL(clicked()), this, SLOT(GoToSinglePlayer()));
   118     connect(ui.pageMain->BtnSinglePlayer, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
   115     connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), this, SLOT(GoToSetup()));
   119     pageSwitchMapper->setMapping(ui.pageMain->BtnSinglePlayer, ID_PAGE_SINGLEPLAYER);
       
   120 
       
   121     connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
       
   122     pageSwitchMapper->setMapping(ui.pageMain->BtnSetup, ID_PAGE_SETUP);
       
   123     
   116     connect(ui.pageMain->BtnNet, SIGNAL(clicked()), this, SLOT(GoToNetType()));
   124     connect(ui.pageMain->BtnNet, SIGNAL(clicked()), this, SLOT(GoToNetType()));
   117     connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), this, SLOT(GoToInfo()));
   125     connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
       
   126     pageSwitchMapper->setMapping(ui.pageMain->BtnInfo, ID_PAGE_INFO);
       
   127 
   118     connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed()));
   128     connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed()));
   119     connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked()));
   129     connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked()));
   120 
   130 
   121     connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave()));
   131     connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave()));
   122     connect(ui.pageEditTeam->BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard()));
   132     connect(ui.pageEditTeam->BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard()));
   177     connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
   187     connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
   178 
   188 
   179     connect(ui.pageGameStats->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
   189     connect(ui.pageGameStats->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
   180 
   190 
   181     connect(ui.pageSinglePlayer->BtnSimpleGamePage, SIGNAL(clicked()), this, SLOT(SimpleGame()));
   191     connect(ui.pageSinglePlayer->BtnSimpleGamePage, SIGNAL(clicked()), this, SLOT(SimpleGame()));
   182     connect(ui.pageSinglePlayer->BtnTrainPage, SIGNAL(clicked()), this, SLOT(GoToTraining()));
   192     connect(ui.pageSinglePlayer->BtnTrainPage, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
   183     connect(ui.pageSinglePlayer->BtnCampaignPage, SIGNAL(clicked()), this, SLOT(GoToCampaign()));
   193     pageSwitchMapper->setMapping(ui.pageSinglePlayer->BtnTrainPage, ID_PAGE_TRAINING);
       
   194     
       
   195     connect(ui.pageSinglePlayer->BtnCampaignPage, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
       
   196     pageSwitchMapper->setMapping(ui.pageSinglePlayer->BtnCampaignPage, ID_PAGE_CAMPAIGN);
       
   197 
   184     connect(ui.pageSinglePlayer->BtnMultiplayer, SIGNAL(clicked()), this, SLOT(GoToMultiplayer()));
   198     connect(ui.pageSinglePlayer->BtnMultiplayer, SIGNAL(clicked()), this, SLOT(GoToMultiplayer()));
   185     connect(ui.pageSinglePlayer->BtnLoad, SIGNAL(clicked()), this, SLOT(GoToSaves()));
   199     connect(ui.pageSinglePlayer->BtnLoad, SIGNAL(clicked()), this, SLOT(GoToSaves()));
   186     connect(ui.pageSinglePlayer->BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos()));
   200     connect(ui.pageSinglePlayer->BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos()));
   187     connect(ui.pageSinglePlayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
   201     connect(ui.pageSinglePlayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
   188 
   202 
   207     connect(ui.pageAdmin->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
   221     connect(ui.pageAdmin->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
   208 
   222 
   209     connect(ui.pageNetType->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
   223     connect(ui.pageNetType->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
   210     connect(ui.pageNetType->BtnLAN, SIGNAL(clicked()), this, SLOT(GoToNet()));
   224     connect(ui.pageNetType->BtnLAN, SIGNAL(clicked()), this, SLOT(GoToNet()));
   211     connect(ui.pageNetType->BtnOfficialServer, SIGNAL(clicked()), this, SLOT(NetConnectOfficialServer()));
   225     connect(ui.pageNetType->BtnOfficialServer, SIGNAL(clicked()), this, SLOT(NetConnectOfficialServer()));
       
   226 
   212 
   227 
   213 
   228 
   214     ammoSchemeModel = new AmmoSchemeModel(this, cfgdir->absolutePath() + "/schemes.ini");
   229     ammoSchemeModel = new AmmoSchemeModel(this, cfgdir->absolutePath() + "/schemes.ini");
   215     ui.pageScheme->setModel(ammoSchemeModel);
   230     ui.pageScheme->setModel(ammoSchemeModel);
   216     ui.pageMultiplayer->gameCFG->GameSchemes->setModel(ammoSchemeModel);
   231     ui.pageMultiplayer->gameCFG->GameSchemes->setModel(ammoSchemeModel);
   341     ui.pageOptions->CBTeamName->addItems(teamslist);
   356     ui.pageOptions->CBTeamName->addItems(teamslist);
   342     ui.pageCampaign->CBTeam->clear();
   357     ui.pageCampaign->CBTeam->clear();
   343     ui.pageCampaign->CBTeam->addItems(teamslist);
   358     ui.pageCampaign->CBTeam->addItems(teamslist);
   344 }
   359 }
   345 
   360 
   346 void HWForm::GoToMain()
       
   347 {
       
   348     GoToPage(ID_PAGE_MAIN);
       
   349 }
       
   350 
       
   351 void HWForm::GoToSinglePlayer()
       
   352 {
       
   353     GoToPage(ID_PAGE_SINGLEPLAYER);
       
   354 }
       
   355 
       
   356 void HWForm::GoToTraining()
       
   357 {
       
   358     GoToPage(ID_PAGE_TRAINING);
       
   359 }
       
   360 
       
   361 void HWForm::GoToCampaign()
       
   362 {
       
   363     GoToPage(ID_PAGE_CAMPAIGN);
       
   364 }
       
   365 
       
   366 void HWForm::GoToSetup()
       
   367 {
       
   368     GoToPage(ID_PAGE_SETUP);
       
   369 }
       
   370 
       
   371 void HWForm::GoToSelectNewWeapon()
   361 void HWForm::GoToSelectNewWeapon()
   372 {
   362 {
   373     ui.pageSelectWeapon->pWeapons->newWeaponsName();
   363     ui.pageSelectWeapon->pWeapons->newWeaponsName();
   374     GoToPage(ID_PAGE_SELECTWEAPON);
   364     GoToPage(ID_PAGE_SELECTWEAPON);
   375 }
   365 }
   382 
   372 
   383 void HWForm::GoToSelectWeaponSet(int index)
   373 void HWForm::GoToSelectWeaponSet(int index)
   384 {
   374 {
   385     ui.pageSelectWeapon->selectWeaponSet->setCurrentIndex(index);
   375     ui.pageSelectWeapon->selectWeaponSet->setCurrentIndex(index);
   386     GoToPage(ID_PAGE_SELECTWEAPON);
   376     GoToPage(ID_PAGE_SELECTWEAPON);
   387 }
       
   388 
       
   389 void HWForm::GoToInfo()
       
   390 {
       
   391     GoToPage(ID_PAGE_INFO);
       
   392 }
   377 }
   393 
   378 
   394 void HWForm::GoToMultiplayer()
   379 void HWForm::GoToMultiplayer()
   395 {
   380 {
   396     GoToPage(ID_PAGE_MULTIPLAYER);
   381     GoToPage(ID_PAGE_MULTIPLAYER);
   518         }
   503         }
   519         ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text());
   504         ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text());
   520     }
   505     }
   521 }
   506 }
   522 
   507 
   523 void HWForm::GoToPage(quint8 id)
   508 void HWForm::GoToPage(int id)
   524 {
   509 {
   525     quint8 lastid = ui.Pages->currentIndex();
   510     int lastid = ui.Pages->currentIndex();
   526     PagesStack.push(ui.Pages->currentIndex());
   511     PagesStack.push(ui.Pages->currentIndex());
   527     OnPageShown(id, lastid);
   512     OnPageShown(id, lastid);
   528     ui.Pages->setCurrentIndex(id);
   513     ui.Pages->setCurrentIndex(id);
   529 }
   514 }
   530 
   515 
   531 void HWForm::GoBack()
   516 void HWForm::GoBack()
   532 {
   517 {
   533     quint8 id = PagesStack.isEmpty() ? ID_PAGE_MAIN : PagesStack.pop();
   518     int id = PagesStack.isEmpty() ? ID_PAGE_MAIN : PagesStack.pop();
   534     quint8 curid = ui.Pages->currentIndex();
   519     int curid = ui.Pages->currentIndex();
   535     ui.Pages->setCurrentIndex(id);
   520     ui.Pages->setCurrentIndex(id);
   536     OnPageShown(id, curid);
   521     OnPageShown(id, curid);
   537 
   522 
   538     if (id == ID_PAGE_CONNECTING)
   523     if (id == ID_PAGE_CONNECTING)
   539         GoBack();
   524         GoBack();