180 connect(ui.pageOptions->BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam())); |
180 connect(ui.pageOptions->BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam())); |
181 connect(ui.pageOptions->BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam())); |
181 connect(ui.pageOptions->BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam())); |
182 connect(ui.pageOptions->BtnDeleteTeam, SIGNAL(clicked()), this, SLOT(DeleteTeam())); |
182 connect(ui.pageOptions->BtnDeleteTeam, SIGNAL(clicked()), this, SLOT(DeleteTeam())); |
183 connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions())); |
183 connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions())); |
184 connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), this, SLOT(GoBack())); |
184 connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), this, SLOT(GoBack())); |
185 #ifndef __APPLE__ |
|
186 connect(ui.pageOptions->BtnAssociateFiles, SIGNAL(clicked()), this, SLOT(AssociateFiles())); |
185 connect(ui.pageOptions->BtnAssociateFiles, SIGNAL(clicked()), this, SLOT(AssociateFiles())); |
187 #endif |
|
188 |
186 |
189 connect(ui.pageOptions->WeaponEdit, SIGNAL(clicked()), this, SLOT(GoToSelectWeapon())); |
187 connect(ui.pageOptions->WeaponEdit, SIGNAL(clicked()), this, SLOT(GoToSelectWeapon())); |
190 connect(ui.pageOptions->WeaponNew, SIGNAL(clicked()), this, SLOT(GoToSelectNewWeapon())); |
188 connect(ui.pageOptions->WeaponNew, SIGNAL(clicked()), this, SLOT(GoToSelectNewWeapon())); |
191 connect(ui.pageOptions->WeaponDelete, SIGNAL(clicked()), this, SLOT(DeleteWeaponSet())); |
189 connect(ui.pageOptions->WeaponDelete, SIGNAL(clicked()), this, SLOT(DeleteWeaponSet())); |
192 connect(ui.pageOptions->SchemeEdit, SIGNAL(clicked()), this, SLOT(GoToEditScheme())); |
190 connect(ui.pageOptions->SchemeEdit, SIGNAL(clicked()), this, SLOT(GoToEditScheme())); |
458 void HWForm::OnPageShown(quint8 id, quint8 lastid) |
456 void HWForm::OnPageShown(quint8 id, quint8 lastid) |
459 { |
457 { |
460 #ifdef USE_XFIRE |
458 #ifdef USE_XFIRE |
461 updateXfire(); |
459 updateXfire(); |
462 #endif |
460 #endif |
463 if(id == ID_PAGE_DRAWMAP) |
461 if (id == ID_PAGE_DRAWMAP) { |
464 { |
|
465 DrawMapScene * scene; |
462 DrawMapScene * scene; |
466 if(lastid == ID_PAGE_MULTIPLAYER) |
463 if(lastid == ID_PAGE_MULTIPLAYER) |
467 scene = ui.pageMultiplayer->gameCFG->pMapContainer->getDrawMapScene(); |
464 scene = ui.pageMultiplayer->gameCFG->pMapContainer->getDrawMapScene(); |
468 else |
465 else |
469 scene = ui.pageNetGame->pGameCFG->pMapContainer->getDrawMapScene(); |
466 scene = ui.pageNetGame->pGameCFG->pMapContainer->getDrawMapScene(); |
470 |
467 |
471 ui.pageDrawMap->drawMapWidget->setScene(scene); |
468 ui.pageDrawMap->drawMapWidget->setScene(scene); |
472 } |
469 } |
473 if(lastid == ID_PAGE_DRAWMAP) |
470 |
474 { |
471 if (lastid == ID_PAGE_DRAWMAP) { |
475 if(id == ID_PAGE_MULTIPLAYER) |
472 if (id == ID_PAGE_MULTIPLAYER) |
476 ui.pageMultiplayer->gameCFG->pMapContainer->mapDrawingFinished(); |
473 ui.pageMultiplayer->gameCFG->pMapContainer->mapDrawingFinished(); |
477 else |
474 else |
478 ui.pageNetGame->pGameCFG->pMapContainer->mapDrawingFinished(); |
475 ui.pageNetGame->pGameCFG->pMapContainer->mapDrawingFinished(); |
479 } |
476 } |
480 |
477 |
485 ui.pageOptions->BtnEditTeam->setVisible(false); |
482 ui.pageOptions->BtnEditTeam->setVisible(false); |
486 ui.pageOptions->BtnDeleteTeam->setVisible(false); |
483 ui.pageOptions->BtnDeleteTeam->setVisible(false); |
487 ui.pageOptions->CBTeamName->setVisible(false); |
484 ui.pageOptions->CBTeamName->setVisible(false); |
488 ui.pageOptions->LblNoEditTeam->setVisible(true); |
485 ui.pageOptions->LblNoEditTeam->setVisible(true); |
489 |
486 |
490 if(id == ID_PAGE_MULTIPLAYER) { |
487 if (id == ID_PAGE_MULTIPLAYER) { |
491 curTeamSelWidget = ui.pageMultiplayer->teamsSelect; |
488 curTeamSelWidget = ui.pageMultiplayer->teamsSelect; |
492 } else { |
489 } else { |
493 curTeamSelWidget = ui.pageNetGame->pNetTeamsWidget; |
490 curTeamSelWidget = ui.pageNetGame->pNetTeamsWidget; |
494 } |
491 } |
495 |
492 |
496 QList<HWTeam> teamsList; |
493 QList<HWTeam> teamsList; |
497 for(QStringList::iterator it = tmNames.begin(); it != tmNames.end(); it++) { |
494 for (QStringList::iterator it = tmNames.begin(); it != tmNames.end(); it++) { |
498 HWTeam team(*it); |
495 HWTeam team(*it); |
499 team.LoadFromFile(); |
496 team.LoadFromFile(); |
500 teamsList.push_back(team); |
497 teamsList.push_back(team); |
501 } |
498 } |
502 |
499 |
503 if(lastid == ID_PAGE_SETUP || lastid == ID_PAGE_DRAWMAP) { // _TEAM |
500 if (lastid == ID_PAGE_SETUP || lastid == ID_PAGE_DRAWMAP) { // _TEAM |
504 if (editedTeam) { |
501 if (editedTeam) { |
505 curTeamSelWidget->addTeam(*editedTeam); |
502 curTeamSelWidget->addTeam(*editedTeam); |
506 } |
503 } |
507 } else if(lastid != ID_PAGE_GAMESTATS |
504 } else if (lastid != ID_PAGE_GAMESTATS |
508 && lastid != ID_PAGE_INGAME |
505 && lastid != ID_PAGE_INGAME |
509 && lastid != ID_PAGE_SCHEME |
506 && lastid != ID_PAGE_SCHEME |
510 && lastid != ID_PAGE_SELECTWEAPON) { |
507 && lastid != ID_PAGE_SELECTWEAPON) { |
511 curTeamSelWidget->resetPlayingTeams(teamsList); |
508 curTeamSelWidget->resetPlayingTeams(teamsList); |
512 } |
509 } |
513 } else |
510 } else |
514 if (id == ID_PAGE_GAMESTATS) |
511 if (id == ID_PAGE_GAMESTATS) { |
515 { |
512 ui.pageGameStats->renderStats(); |
516 ui.pageGameStats->renderStats(); |
513 } |
517 } |
514 |
518 |
515 if (id == ID_PAGE_MAIN) { |
519 if(id == ID_PAGE_MAIN) |
|
520 { |
|
521 ui.pageOptions->BtnNewTeam->setVisible(true); |
516 ui.pageOptions->BtnNewTeam->setVisible(true); |
522 ui.pageOptions->BtnEditTeam->setVisible(true); |
517 ui.pageOptions->BtnEditTeam->setVisible(true); |
523 ui.pageOptions->BtnDeleteTeam->setVisible(true); |
518 ui.pageOptions->BtnDeleteTeam->setVisible(true); |
524 ui.pageOptions->CBTeamName->setVisible(true); |
519 ui.pageOptions->CBTeamName->setVisible(true); |
525 ui.pageOptions->LblNoEditTeam->setVisible(false); |
520 ui.pageOptions->LblNoEditTeam->setVisible(false); |
526 } |
521 } |
527 |
522 |
528 // load and save ignore/friends lists |
523 // load and save ignore/friends lists |
529 if(lastid == ID_PAGE_NETGAME) // leaving a room |
524 if (lastid == ID_PAGE_NETGAME) // leaving a room |
530 ui.pageNetGame->pChatWidget->saveLists(ui.pageOptions->editNetNick->text()); |
525 ui.pageNetGame->pChatWidget->saveLists(ui.pageOptions->editNetNick->text()); |
531 else if(lastid == ID_PAGE_ROOMSLIST) // leaving the lobby |
526 else if(lastid == ID_PAGE_ROOMSLIST) // leaving the lobby |
532 ui.pageRoomsList->chatWidget->saveLists(ui.pageOptions->editNetNick->text()); |
527 ui.pageRoomsList->chatWidget->saveLists(ui.pageOptions->editNetNick->text()); |
533 |
528 |
534 if(id == ID_PAGE_NETGAME) // joining a room |
529 if (id == ID_PAGE_NETGAME) // joining a room |
535 ui.pageNetGame->pChatWidget->loadLists(ui.pageOptions->editNetNick->text()); |
530 ui.pageNetGame->pChatWidget->loadLists(ui.pageOptions->editNetNick->text()); |
536 // joining the lobby |
531 // joining the lobby |
537 else if(id == ID_PAGE_ROOMSLIST) { |
532 else if (id == ID_PAGE_ROOMSLIST) { |
538 if ( hwnet && game && game->gameState == gsStarted) { // abnormal exit - kick or room destruction - send kills. |
533 if (hwnet && game && game->gameState == gsStarted) { // abnormal exit - kick or room destruction - send kills. |
539 game->netSuspend = true; |
534 game->netSuspend = true; |
540 game->KillAllTeams(); |
535 game->KillAllTeams(); |
541 } |
536 } |
542 ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text()); |
537 ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text()); |
543 } |
538 } |
711 { |
706 { |
712 QMessageBox::critical(this, |
707 QMessageBox::critical(this, |
713 tr("Error"), |
708 tr("Error"), |
714 tr("Please select record from the list above"), |
709 tr("Please select record from the list above"), |
715 tr("OK")); |
710 tr("OK")); |
716 return ; |
711 return; |
717 } |
712 } |
718 CreateGame(0, 0, 0); |
713 CreateGame(0, 0, 0); |
719 game->PlayDemo(curritem->data(Qt::UserRole).toString()); |
714 game->PlayDemo(curritem->data(Qt::UserRole).toString()); |
|
715 } |
|
716 |
|
717 void HWForm::PlayDemoQuick(const QString & demofilename) |
|
718 { |
|
719 if (game && game->gameState == gsStarted) return; |
|
720 GoBack(); //needed to cleanly disconnect from netgame |
|
721 GoToPage(ID_PAGE_MAIN); |
|
722 CreateGame(0, 0, 0); |
|
723 game->PlayDemo(demofilename); |
720 } |
724 } |
721 |
725 |
722 void HWForm::NetConnectServer(const QString & host, quint16 port) |
726 void HWForm::NetConnectServer(const QString & host, quint16 port) |
723 { |
727 { |
724 _NetConnect(host, port, ui.pageOptions->editNetNick->text().trimmed()); |
728 _NetConnect(host, port, ui.pageOptions->editNetNick->text().trimmed()); |
1251 registry_hkcr.setValue("Hedgewars.Demo/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwdfile.ico\",0"); |
1255 registry_hkcr.setValue("Hedgewars.Demo/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwdfile.ico\",0"); |
1252 registry_hkcr.setValue("Hedgewars.Save/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwsfile.ico\",0"); |
1256 registry_hkcr.setValue("Hedgewars.Save/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwsfile.ico\",0"); |
1253 registry_hkcr.setValue("Hedgewars.Demo/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + cfgdir->absolutePath().replace("/","\\") + "\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" --set-everything "+arguments); |
1257 registry_hkcr.setValue("Hedgewars.Demo/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + cfgdir->absolutePath().replace("/","\\") + "\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" --set-everything "+arguments); |
1254 registry_hkcr.setValue("Hedgewars.Save/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + cfgdir->absolutePath().replace("/","\\") + "\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" --set-everything "+arguments); |
1258 registry_hkcr.setValue("Hedgewars.Save/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + cfgdir->absolutePath().replace("/","\\") + "\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" --set-everything "+arguments); |
1255 #elif defined __APPLE__ |
1259 #elif defined __APPLE__ |
1256 success = false; |
1260 // only useful when other apps have taken precedence over our file extensions and you want to reset it |
1257 // TODO; also enable button in pages.cpp and signal in hwform.cpp |
1261 system("defaults write com.apple.LaunchServices LSHandlers -array-add '<dict><key>LSHandlerContentTag</key><string>hwd</string><key>LSHandlerContentTagClass</key><string>public.filename-extension</string><key>LSHandlerRoleAll</key><string>org.hedgewars.desktop</string></dict>'"); |
|
1262 system("defaults write com.apple.LaunchServices LSHandlers -array-add '<dict><key>LSHandlerContentTag</key><string>hws</string><key>LSHandlerContentTagClass</key><string>public.filename-extension</string><key>LSHandlerRoleAll</key><string>org.hedgewars.desktop</string></dict>'"); |
|
1263 system("/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -domain local -domain system -domain user"); |
1258 #else |
1264 #else |
1259 // this is a little silly due to all the system commands below anyway - just use mkdir -p ? Does have the advantage of the alert I guess |
1265 // this is a little silly due to all the system commands below anyway - just use mkdir -p ? Does have the advantage of the alert I guess |
1260 if (success) success = checkForDir(QDir::home().absolutePath() + "/.local"); |
1266 if (success) success = checkForDir(QDir::home().absolutePath() + "/.local"); |
1261 if (success) success = checkForDir(QDir::home().absolutePath() + "/.local/share"); |
1267 if (success) success = checkForDir(QDir::home().absolutePath() + "/.local/share"); |
1262 if (success) success = checkForDir(QDir::home().absolutePath() + "/.local/share/mime"); |
1268 if (success) success = checkForDir(QDir::home().absolutePath() + "/.local/share/mime"); |