Changeset View
Changeset View
Standalone View
Standalone View
ksirk/GameLogic/onu.cpp
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | |||||
66 | #pragma message("port to qt5") | 66 | #pragma message("port to qt5") | ||
67 | #if 0 | 67 | #if 0 | ||
68 | if (m_automaton->pixmapCache().timestamp() < qfi.lastModified().toSecsSinceEpoch()) | 68 | if (m_automaton->pixmapCache().timestamp() < qfi.lastModified().toSecsSinceEpoch()) | ||
69 | { | 69 | { | ||
70 | m_automaton->pixmapCache().discard(); | 70 | m_automaton->pixmapCache().discard(); | ||
71 | } | 71 | } | ||
72 | #endif | 72 | #endif | ||
73 | m_font.family = "URW Chancery L"; | 73 | m_font.family = "URW Chancery L"; | ||
74 | m_font.size = (uint)(13*m_zoom); | 74 | m_font.size = (int)(13*m_zoom); | ||
75 | m_font.weight = QFont::Bold; | 75 | m_font.weight = QFont::Bold; | ||
76 | m_font.italic = true; | 76 | m_font.italic = true; | ||
77 | m_font.foregroundColor = "black"; | 77 | m_font.foregroundColor = "black"; | ||
78 | m_font.backgroundColor = "white"; | 78 | m_font.backgroundColor = "white"; | ||
79 | 79 | | |||
80 | m_timerFast=new QTimer(this); //instanciation of the timer | 80 | m_timerFast=new QTimer(this); //instanciation of the timer | ||
81 | QObject::connect(m_timerFast,&QTimer::timeout, this, &ONU::changingZoom); //connect the timer to the good slot | 81 | QObject::connect(m_timerFast,&QTimer::timeout, this, &ONU::changingZoom); //connect the timer to the good slot | ||
82 | 82 | | |||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Line(s) | |||||
217 | // Sprites::SkinSpritesData::changeable().strData("exploding-id", config.group("exploding").readEntry("id")); | 217 | // Sprites::SkinSpritesData::changeable().strData("exploding-id", config.group("exploding").readEntry("id")); | ||
218 | Sprites::SkinSpritesData::changeable().intData("exploding-width", config.group("exploding").readEntry("width",0)); | 218 | Sprites::SkinSpritesData::changeable().intData("exploding-width", config.group("exploding").readEntry("width",0)); | ||
219 | Sprites::SkinSpritesData::changeable().intData("exploding-height", config.group("cannon").readEntry("height",0)); | 219 | Sprites::SkinSpritesData::changeable().intData("exploding-height", config.group("cannon").readEntry("height",0)); | ||
220 | Sprites::SkinSpritesData::changeable().intData("exploding-frames", config.group("exploding").readEntry("frames",0)); | 220 | Sprites::SkinSpritesData::changeable().intData("exploding-frames", config.group("exploding").readEntry("frames",0)); | ||
221 | Sprites::SkinSpritesData::changeable().intData("exploding-versions", config.group("exploding").readEntry("versions",0)); | 221 | Sprites::SkinSpritesData::changeable().intData("exploding-versions", config.group("exploding").readEntry("versions",0)); | ||
222 | 222 | | |||
223 | KConfigGroup fontgroup = config.group("font"); | 223 | KConfigGroup fontgroup = config.group("font"); | ||
224 | m_font.family = fontgroup.readEntry("family","URW Chancery L"); | 224 | m_font.family = fontgroup.readEntry("family","URW Chancery L"); | ||
225 | m_font.size = fontgroup.readEntry("size",(uint)(13*m_zoom)); | 225 | m_font.size = fontgroup.readEntry("size",(int)(13*m_zoom)); | ||
226 | QString w = fontgroup.readEntry("weight", "bold");; | 226 | QString w = fontgroup.readEntry("weight", "bold");; | ||
227 | if (w == "normal") | 227 | if (w == "normal") | ||
228 | { | 228 | { | ||
229 | m_font.weight = QFont::Normal; | 229 | m_font.weight = QFont::Normal; | ||
230 | } | 230 | } | ||
231 | else if (w == "light") | 231 | else if (w == "light") | ||
232 | { | 232 | { | ||
233 | m_font.weight = QFont::Light; | 233 | m_font.weight = QFont::Light; | ||
▲ Show 20 Lines • Show All 401 Lines • ▼ Show 20 Line(s) | |||||
635 | { | 635 | { | ||
636 | /** Zoom 1: First method (take a long time to zoom) : | 636 | /** Zoom 1: First method (take a long time to zoom) : | ||
637 | */ | 637 | */ | ||
638 | // qCDebug(KSIRK_LOG) << "zoomFactor=" << zoomFactor << "old zoom=" << m_zoom; | 638 | // qCDebug(KSIRK_LOG) << "zoomFactor=" << zoomFactor << "old zoom=" << m_zoom; | ||
639 | // qCDebug(KSIRK_LOG) << "new zoom=" << m_zoom; | 639 | // qCDebug(KSIRK_LOG) << "new zoom=" << m_zoom; | ||
640 | 640 | | |||
641 | m_zoom *= zoomFactor; | 641 | m_zoom *= zoomFactor; | ||
642 | 642 | | |||
643 | //m_font.size = (unsigned int)(m_font.size*m_zoom); | 643 | //m_font.size = (int)(m_font.size*m_zoom); | ||
644 | //m_width = (unsigned int)(m_width *m_zoom); | 644 | //m_width = (unsigned int)(m_width *m_zoom); | ||
645 | //m_height = (unsigned int)(m_height *m_zoom); | 645 | //m_height = (unsigned int)(m_height *m_zoom); | ||
646 | 646 | | |||
647 | buildMap(); | 647 | buildMap(); | ||
648 | 648 | | |||
649 | foreach (Country* country, countries) | 649 | foreach (Country* country, countries) | ||
650 | { | 650 | { | ||
651 | country->createArmiesSprites(); | 651 | country->createArmiesSprites(); | ||
652 | } | 652 | } | ||
653 | 653 | | |||
654 | } | 654 | } | ||
655 | 655 | | |||
656 | void ONU::applyZoomFactorFast(qreal zoomFactor) //benj | 656 | void ONU::applyZoomFactorFast(qreal zoomFactor) //benj | ||
657 | { | 657 | { | ||
658 | 658 | | |||
659 | /** Zoom 2 : Second method , Very performent. Carefull ! Can cause the game to lag. | 659 | /** Zoom 2 : Second method , Very performent. Carefull ! Can cause the game to lag. | ||
660 | To try this, comment all the first method and uncomment these lines | 660 | To try this, comment all the first method and uncomment these lines | ||
661 | */ | 661 | */ | ||
662 | qCDebug(KSIRK_LOG) << "zoomFactor FASTTTTTTT"<<endl; | 662 | qCDebug(KSIRK_LOG) << "zoomFactor FASTTTTTTT"<<endl; | ||
663 | int nbLimitZooms = 6; | 663 | int nbLimitZooms = 6; | ||
664 | 664 | | |||
665 | //Application of zoom | 665 | //Application of zoom | ||
666 | if (zoomFactor > 1 && m_nbZooms < nbLimitZooms) | 666 | if (zoomFactor > 1 && m_nbZooms < nbLimitZooms) | ||
667 | { | 667 | { | ||
668 | m_font.size = (unsigned int)(m_font.size*zoomFactor); | 668 | m_font.size = (int)(m_font.size*zoomFactor); | ||
669 | m_width = (unsigned int)(m_width *zoomFactor); | 669 | m_width = (unsigned int)(m_width *zoomFactor); | ||
670 | m_height = (unsigned int)(m_height *zoomFactor); | 670 | m_height = (unsigned int)(m_height *zoomFactor); | ||
671 | 671 | | |||
672 | m_nbZooms++; // zoom forward | 672 | m_nbZooms++; // zoom forward | ||
673 | m_automaton->game()->frame()->scale(zoomFactor, zoomFactor); | 673 | m_automaton->game()->frame()->scale(zoomFactor, zoomFactor); | ||
674 | m_zoomFactorFinal *= zoomFactor; | 674 | m_zoomFactorFinal *= zoomFactor; | ||
675 | 675 | | |||
676 | //starting timer | 676 | //starting timer | ||
677 | /*if (m_timerFast->isActive()) | 677 | /*if (m_timerFast->isActive()) | ||
678 | { | 678 | { | ||
679 | m_timerFast->stop(); | 679 | m_timerFast->stop(); | ||
680 | } | 680 | } | ||
681 | m_timerFast->start(4000); | 681 | m_timerFast->start(4000); | ||
682 | m_timerFast->setSingleShot(true);*/ | 682 | m_timerFast->setSingleShot(true);*/ | ||
683 | 683 | | |||
684 | } | 684 | } | ||
685 | else if (zoomFactor < 1 && m_nbZooms > -nbLimitZooms) | 685 | else if (zoomFactor < 1 && m_nbZooms > -nbLimitZooms) | ||
686 | { | 686 | { | ||
687 | m_font.size = (unsigned int)(m_font.size*zoomFactor); | 687 | m_font.size = (int)(m_font.size*zoomFactor); | ||
688 | m_width = (unsigned int)(m_width *zoomFactor); | 688 | m_width = (unsigned int)(m_width *zoomFactor); | ||
689 | m_height = (unsigned int)(m_height *zoomFactor); | 689 | m_height = (unsigned int)(m_height *zoomFactor); | ||
690 | 690 | | |||
691 | m_nbZooms--; // zoom backward | 691 | m_nbZooms--; // zoom backward | ||
692 | m_automaton->game()->frame()->scale(zoomFactor, zoomFactor); | 692 | m_automaton->game()->frame()->scale(zoomFactor, zoomFactor); | ||
693 | m_zoomFactorFinal *= zoomFactor; | 693 | m_zoomFactorFinal *= zoomFactor; | ||
694 | 694 | | |||
695 | //starting timer | 695 | //starting timer | ||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |