542 |
544 |
543 } |
545 } |
544 |
546 |
545 void HWForm::GoToPage(int id) |
547 void HWForm::GoToPage(int id) |
546 { |
548 { |
|
549 bool stopAnim = false; |
|
550 |
547 int lastid = ui.Pages->currentIndex(); |
551 int lastid = ui.Pages->currentIndex(); |
548 PagesStack.push(ui.Pages->currentIndex()); |
552 PagesStack.push(ui.Pages->currentIndex()); |
|
553 |
549 OnPageShown(id, lastid); |
554 OnPageShown(id, lastid); |
550 ui.Pages->setCurrentIndex(id); |
555 ui.Pages->setCurrentIndex(id); |
|
556 |
|
557 if (id == ID_PAGE_DRAWMAP) |
|
558 stopAnim = true; |
|
559 |
|
560 if (frontendEffects && !stopAnim) |
|
561 { |
|
562 /**Start animation :**/ |
|
563 |
|
564 QGraphicsOpacityEffect *effectNew = new QGraphicsOpacityEffect(ui.Pages->widget(id)); |
|
565 ui.Pages->widget(id)->setGraphicsEffect(effectNew); |
|
566 |
|
567 QGraphicsOpacityEffect *effectLast = new QGraphicsOpacityEffect(ui.Pages->widget(lastid)); |
|
568 ui.Pages->widget(lastid)->setGraphicsEffect(effectLast); |
|
569 |
|
570 //New page animation |
|
571 animationNewSlide = new QPropertyAnimation(ui.Pages->widget(id), "pos"); |
|
572 animationNewSlide->setDuration(500); |
|
573 animationNewSlide->setStartValue(QPoint(width()/2, 0)); |
|
574 animationNewSlide->setEndValue(QPoint(0, 0)); |
|
575 animationNewSlide->setEasingCurve(QEasingCurve::OutCubic); |
|
576 animationNewSlide->start(); |
|
577 |
|
578 animationNewOpacity = new QPropertyAnimation(effectNew, "opacity"); |
|
579 animationNewOpacity->setDuration(500); |
|
580 animationNewOpacity->setStartValue(0.01); |
|
581 animationNewOpacity->setEndValue(1); |
|
582 animationNewOpacity->setEasingCurve(QEasingCurve::OutCubic); |
|
583 animationNewOpacity->start(); |
|
584 |
|
585 //Last page animation |
|
586 ui.Pages->widget(lastid)->setHidden(false); |
|
587 |
|
588 animationOldSlide = new QPropertyAnimation(ui.Pages->widget(lastid), "pos"); |
|
589 animationOldSlide->setDuration(500); |
|
590 animationOldSlide->setStartValue(QPoint(0, 0)); |
|
591 animationOldSlide->setEndValue(QPoint(-width()/2, 0)); |
|
592 animationOldSlide->setEasingCurve(QEasingCurve::OutCubic); |
|
593 animationOldSlide->start(); |
|
594 |
|
595 animationOldOpacity = new QPropertyAnimation(effectLast, "opacity"); |
|
596 animationOldOpacity->setDuration(500); |
|
597 animationOldOpacity->setStartValue(1); |
|
598 animationOldOpacity->setEndValue(0.01); |
|
599 animationOldOpacity->setEasingCurve(QEasingCurve::OutCubic); |
|
600 animationOldOpacity->start(); |
|
601 |
|
602 connect(animationOldSlide, SIGNAL(finished()), ui.Pages->widget(lastid), SLOT(hide())); |
|
603 } |
551 } |
604 } |
552 |
605 |
553 void HWForm::GoBack() |
606 void HWForm::GoBack() |
554 { |
607 { |
|
608 bool stopAnim = false; |
555 int curid = ui.Pages->currentIndex(); |
609 int curid = ui.Pages->currentIndex(); |
556 if (curid == ID_PAGE_MAIN) |
610 if (curid == ID_PAGE_MAIN) |
|
611 { |
|
612 stopAnim = true; |
557 exit(); |
613 exit(); |
|
614 } |
558 |
615 |
559 int id = PagesStack.isEmpty() ? ID_PAGE_MAIN : PagesStack.pop(); |
616 int id = PagesStack.isEmpty() ? ID_PAGE_MAIN : PagesStack.pop(); |
560 ui.Pages->setCurrentIndex(id); |
617 ui.Pages->setCurrentIndex(id); |
561 OnPageShown(id, curid); |
618 OnPageShown(id, curid); |
562 |
619 |
563 if (id == ID_PAGE_CONNECTING) |
620 if (id == ID_PAGE_CONNECTING) |
|
621 { |
|
622 stopAnim = true; |
564 GoBack(); |
623 GoBack(); |
|
624 } |
565 if (id == ID_PAGE_NETSERVER) |
625 if (id == ID_PAGE_NETSERVER) |
|
626 { |
|
627 stopAnim = true; |
566 GoBack(); |
628 GoBack(); |
|
629 } |
567 if ((!hwnet) && (id == ID_PAGE_ROOMSLIST)) |
630 if ((!hwnet) && (id == ID_PAGE_ROOMSLIST)) |
|
631 { |
|
632 stopAnim = true; |
568 GoBack(); |
633 GoBack(); |
|
634 } |
|
635 if (curid == ID_PAGE_DRAWMAP) |
|
636 stopAnim = true; |
569 |
637 |
570 if ((!hwnet) || (!hwnet->isInRoom())) |
638 if ((!hwnet) || (!hwnet->isInRoom())) |
571 if (id == ID_PAGE_NETGAME || id == ID_PAGE_NETGAME) |
639 if (id == ID_PAGE_NETGAME || id == ID_PAGE_NETGAME) |
|
640 { |
|
641 stopAnim = true; |
572 GoBack(); |
642 GoBack(); |
|
643 } |
573 |
644 |
574 if (curid == ID_PAGE_ROOMSLIST || curid == ID_PAGE_CONNECTING) NetDisconnect(); |
645 if (curid == ID_PAGE_ROOMSLIST || curid == ID_PAGE_CONNECTING) NetDisconnect(); |
575 if (curid == ID_PAGE_NETGAME && hwnet && hwnet->isInRoom()) hwnet->partRoom(); |
646 if (curid == ID_PAGE_NETGAME && hwnet && hwnet->isInRoom()) hwnet->partRoom(); |
576 // need to work on this, can cause invalid state for admin quit trying to prevent bad state message on kick |
647 // need to work on this, can cause invalid state for admin quit trying to prevent bad state message on kick |
577 //if (curid == ID_PAGE_NETGAME && (!game || game->gameState != gsStarted)) hwnet->partRoom(); |
648 //if (curid == ID_PAGE_NETGAME && (!game || game->gameState != gsStarted)) hwnet->partRoom(); |
578 |
649 |
579 if (curid == ID_PAGE_SCHEME) |
650 if (curid == ID_PAGE_SCHEME) |
580 ammoSchemeModel->Save(); |
651 ammoSchemeModel->Save(); |
|
652 |
|
653 /**Start animation :**/ |
|
654 |
|
655 if (curid != 0 && frontendEffects && !stopAnim) |
|
656 { |
|
657 |
|
658 QGraphicsOpacityEffect *effectNew = new QGraphicsOpacityEffect(ui.Pages->widget(id)); |
|
659 effectNew->setOpacity(1); |
|
660 ui.Pages->widget(id)->setGraphicsEffect(effectNew); |
|
661 |
|
662 QGraphicsOpacityEffect *effectLast = new QGraphicsOpacityEffect(ui.Pages->widget(curid)); |
|
663 ui.Pages->widget(curid)->setGraphicsEffect(effectLast); |
|
664 |
|
665 //Last page animation |
|
666 animationOldSlide = new QPropertyAnimation(ui.Pages->widget(id), "pos"); |
|
667 animationOldSlide->setDuration(500); |
|
668 animationOldSlide->setStartValue(QPoint(-width()/2, 0)); |
|
669 animationOldSlide->setEndValue(QPoint(0, 0)); |
|
670 animationOldSlide->setEasingCurve(QEasingCurve::OutCubic); |
|
671 animationOldSlide->start(); |
|
672 |
|
673 animationOldOpacity = new QPropertyAnimation(effectLast, "opacity"); |
|
674 animationOldOpacity->setDuration(500); |
|
675 animationOldOpacity->setStartValue(1); |
|
676 animationOldOpacity->setEndValue(0.01); |
|
677 animationOldOpacity->setEasingCurve(QEasingCurve::OutCubic); |
|
678 animationOldOpacity->start(); |
|
679 |
|
680 //New page animation |
|
681 ui.Pages->widget(curid)->setHidden(false); |
|
682 |
|
683 animationNewSlide = new QPropertyAnimation(ui.Pages->widget(curid), "pos"); |
|
684 animationNewSlide->setDuration(500); |
|
685 animationNewSlide->setStartValue(QPoint(0, 0)); |
|
686 animationNewSlide->setEndValue(QPoint(width()/2, 0)); |
|
687 animationNewSlide->setEasingCurve(QEasingCurve::OutCubic); |
|
688 animationNewSlide->start(); |
|
689 |
|
690 animationNewOpacity = new QPropertyAnimation(effectNew, "opacity"); |
|
691 animationNewOpacity->setDuration(500); |
|
692 animationNewOpacity->setStartValue(0.01); |
|
693 animationNewOpacity->setEndValue(1); |
|
694 animationNewOpacity->setEasingCurve(QEasingCurve::OutCubic); |
|
695 animationNewOpacity->start(); |
|
696 |
|
697 connect(animationNewSlide, SIGNAL(finished()), ui.Pages->widget(curid), SLOT(hide())); |
|
698 } |
|
699 |
|
700 |
581 } |
701 } |
582 |
702 |
583 void HWForm::OpenSnapshotFolder() |
703 void HWForm::OpenSnapshotFolder() |
584 { |
704 { |
585 QString path = QDir::toNativeSeparators(cfgdir->absolutePath() + "/Screenshots"); |
705 QString path = QDir::toNativeSeparators(cfgdir->absolutePath() + "/Screenshots"); |