From 6f25e0913242e30e5564878b753bef06edf6b80d Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Fri, 10 Oct 2014 14:12:30 +0200 Subject: [PATCH 01/13] Deploy openssl libraries under win32 They are needed to fetch prices from deckbrew and possibly, in the future, for ssl server connections --- CMakeLists.txt | 7 ++++- cmake/FindWin32SslRuntime.cmake | 52 +++++++++++++++++++++++++++++++++ cockatrice/CMakeLists.txt | 4 +++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 cmake/FindWin32SslRuntime.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 414df9f8..3cd770d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,6 +158,11 @@ set(CMAKE_AUTOMOC TRUE) # Find other needed libraries FIND_PACKAGE(Protobuf REQUIRED) +#Find OpenSSL +IF(WIN32) + FIND_PACKAGE(Win32SslRuntime) +ENDIF() + # Package builder set(CPACK_PACKAGE_CONTACT "Daenyth+github@gmail.com") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_NAME}) @@ -198,7 +203,7 @@ endif() include(CPack) # Compile servatrice (default off) -option(WITH_SERVER "build servatrice" OFF) +option(WITH_SERVER "build servatrice" ON) add_subdirectory(common) if(WITH_SERVER) add_subdirectory(servatrice) diff --git a/cmake/FindWin32SslRuntime.cmake b/cmake/FindWin32SslRuntime.cmake new file mode 100644 index 00000000..616ca83e --- /dev/null +++ b/cmake/FindWin32SslRuntime.cmake @@ -0,0 +1,52 @@ +# Find the openssl runtime libraries (.dll) for windows that +# will be needed by Qt in order to access https urls. + +if (WIN32) + # Get standatds instalaltion paths for openssl under windos + + # http://www.slproweb.com/products/Win32OpenSSL.html + set(_OPENSSL_ROOT_HINTS + ${OPENSSL_ROOT_DIR} + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]" + ENV OPENSSL_ROOT_DIR + ) + file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles) + set(_OPENSSL_ROOT_PATHS + "${_programfiles}/OpenSSL" + "${_programfiles}/OpenSSL-Win32" + "${_programfiles}/OpenSSL-Win64" + "C:/OpenSSL/" + "C:/OpenSSL-Win32/" + "C:/OpenSSL-Win64/" + ) + unset(_programfiles) +else () + set(_OPENSSL_ROOT_HINTS + ${OPENSSL_ROOT_DIR} + ENV OPENSSL_ROOT_DIR + ) +endif () + +set(_OPENSSL_ROOT_HINTS_AND_PATHS + HINTS ${_OPENSSL_ROOT_HINTS} + PATHS ${_OPENSSL_ROOT_PATHS} + ) + +FIND_FILE(WIN32SSLRUNTIME_LIBEAY NAMES libeay32.dll ${_OPENSSL_ROOT_HINTS_AND_PATHS}) +FIND_FILE(WIN32SSLRUNTIME_SSLEAY NAMES ssleay32.dll ${_OPENSSL_ROOT_HINTS_AND_PATHS}) + + +IF(WIN32SSLRUNTIME_LIBEAY AND WIN32SSLRUNTIME_SSLEAY) + SET(WIN32SSLRUNTIME_LIBRARIES "${WIN32SSLRUNTIME_LIBEAY}" "${WIN32SSLRUNTIME_SSLEAY}") + SET(WIN32SSLRUNTIME_FOUND "YES") + message(STATUS "Found OpenSSL ${WIN32SSLRUNTIME_LIBRARIES}") +ELSE() + SET(WIN32SSLRUNTIME_FOUND "NO") + message(WARNING "Could not find OpenSSL runtime libraries. They are not required for compiling, but needs to be available at runtime.") +ENDIF() + +MARK_AS_ADVANCED( + WIN32SSLRUNTIME_LIBEAY + WIN32SSLRUNTIME_SSLEAY + ) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 454f1a1f..ed50c41d 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -321,4 +321,8 @@ Data = Resources\") include(BundleUtilities) fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/cockatrice.exe\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") " COMPONENT Runtime) + + if(WIN32SSLRUNTIME_FOUND) + install(FILES ${WIN32SSLRUNTIME_LIBRARIES} DESTINATION "${CMAKE_INSTALL_PREFIX}") + endif() endif() \ No newline at end of file From 90e90b59a318c74e1c5672d7171e7c2d7a7d06ed Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Fri, 10 Oct 2014 14:23:31 +0200 Subject: [PATCH 02/13] Reverted WITH_SERVER to OFF --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cd770d6..33c45867 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,7 +203,7 @@ endif() include(CPack) # Compile servatrice (default off) -option(WITH_SERVER "build servatrice" ON) +option(WITH_SERVER "build servatrice" OFF) add_subdirectory(common) if(WITH_SERVER) add_subdirectory(servatrice) From ef7fc01f0820b81673de916726ebb8cacc566d89 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Fri, 10 Oct 2014 14:26:52 +0200 Subject: [PATCH 03/13] Fix typos --- cmake/FindWin32SslRuntime.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/FindWin32SslRuntime.cmake b/cmake/FindWin32SslRuntime.cmake index 616ca83e..4b0fafa5 100644 --- a/cmake/FindWin32SslRuntime.cmake +++ b/cmake/FindWin32SslRuntime.cmake @@ -1,8 +1,8 @@ -# Find the openssl runtime libraries (.dll) for windows that +# Find the OpenSSL runtime libraries (.dll) for Windows that # will be needed by Qt in order to access https urls. if (WIN32) - # Get standatds instalaltion paths for openssl under windos + # Get standard installation paths for OpenSSL under Windows # http://www.slproweb.com/products/Win32OpenSSL.html set(_OPENSSL_ROOT_HINTS From dfb8be79cfc35c3a26f185b49f5104166dc736c9 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Fri, 10 Oct 2014 17:22:29 +0200 Subject: [PATCH 04/13] Fix installation of libeay32.dll, ssleay32.dll while compiling the PACKAGE target --- cockatrice/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index ed50c41d..e3bcd8fa 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -323,6 +323,6 @@ Data = Resources\") " COMPONENT Runtime) if(WIN32SSLRUNTIME_FOUND) - install(FILES ${WIN32SSLRUNTIME_LIBRARIES} DESTINATION "${CMAKE_INSTALL_PREFIX}") + install(FILES ${WIN32SSLRUNTIME_LIBRARIES} DESTINATION ./) endif() endif() \ No newline at end of file From ea622a7302edef33b26a8f9ee742288b014e4f9a Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Fri, 10 Oct 2014 17:22:39 +0200 Subject: [PATCH 05/13] NSIS: uninstall openssl libraries --- cmake/NSIS.template.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/NSIS.template.in b/cmake/NSIS.template.in index 093d6caa..f8fbd920 100644 --- a/cmake/NSIS.template.in +++ b/cmake/NSIS.template.in @@ -80,6 +80,8 @@ Section Uninstall Delete "$INSTDIR\libprotobuf.lib" Delete "$INSTDIR\Qt*.dll" Delete "$INSTDIR\icu*.dll" + Delete "$INSTDIR\libeay32.dll" + Delete "$INSTDIR\ssleay32.dll" Delete "$INSTDIR\qt.conf" Delete "$INSTDIR\qdebug.txt" Delete "$INSTDIR\servatrice.sql" From c0abb347ac1b4a7a81a1f43f15b6ed4189615702 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 11 Oct 2014 13:37:52 +0200 Subject: [PATCH 06/13] Servatrice: Install icons and desktop file under linux --- servatrice/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index 4d719f6b..83fc7900 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -77,6 +77,10 @@ endif() SET(QT_DONT_USE_QTGUI TRUE) +# Declare path variables +set(ICONDIR share/icons CACHE STRING "icon dir") +set(DESKTOPDIR share/applications CACHE STRING "desktop file destination") + # Include directories INCLUDE_DIRECTORIES(../common) INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR}) @@ -112,6 +116,10 @@ if(UNIX) INSTALL(TARGETS servatrice RUNTIME DESTINATION bin/) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/servatrice.ini.example DESTINATION share/servatice/) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/servatrice.sql DESTINATION share/servatice/) + + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/servatrice.png DESTINATION ${ICONDIR}/hicolor/48x48/apps) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/servatrice.svg DESTINATION ${ICONDIR}/hicolor/scalable/apps) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/servatrice.desktop DESTINATION ${DESKTOPDIR}) endif() elseif(WIN32) INSTALL(TARGETS servatrice RUNTIME DESTINATION ./) From 754b97f2123d59c460458c6fb9867c74c5ab6a67 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 11 Oct 2014 13:38:07 +0200 Subject: [PATCH 07/13] Servatrice: open in a terminal window when started from the menu --- servatrice/servatrice.desktop | 2 ++ 1 file changed, 2 insertions(+) diff --git a/servatrice/servatrice.desktop b/servatrice/servatrice.desktop index 635afe6b..7149284b 100644 --- a/servatrice/servatrice.desktop +++ b/servatrice/servatrice.desktop @@ -6,3 +6,5 @@ Name=Servatrice Exec=servatrice Icon=servatrice Categories=Game;CardGame; +Terminal=true +Comment=Game server for Cockatrice From a26d4078ccdd3f7d2d06ae39fc1d704d22e7e988 Mon Sep 17 00:00:00 2001 From: Gavin Bisesi Date: Tue, 14 Oct 2014 11:28:30 -0400 Subject: [PATCH 08/13] Revert "Find cards by prefix" --- cockatrice/src/carddatabase.cpp | 29 +++++------------------------ cockatrice/src/carddatabase.h | 8 +------- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/cockatrice/src/carddatabase.cpp b/cockatrice/src/carddatabase.cpp index 59f1ca17..cdacf008 100644 --- a/cockatrice/src/carddatabase.cpp +++ b/cockatrice/src/carddatabase.cpp @@ -263,14 +263,14 @@ void PictureLoader::picDownloadFinished(QNetworkReply *reply) const QByteArray &picData = reply->peek(reply->size()); //peek is used to keep the data in the buffer for use by QImageReader QImage testImage; - + QImageReader imgReader; imgReader.setDecideFormatFromContent(true); imgReader.setDevice(reply); QString extension = "." + imgReader.format(); //the format is determined prior to reading the QImageReader data into a QImage object, as that wipes the QImageReader buffer if (extension == ".jpeg") extension = ".jpg"; - + if (imgReader.read(&testImage)) { QString setName = cardBeingDownloaded.getSetName(); if(!setName.isEmpty()) @@ -493,7 +493,7 @@ void CardInfo::updatePixmapCache() qDebug() << "Updating pixmap cache for" << name; clearPixmapCache(); loadPixmap(); - + emit pixmapUpdated(); } @@ -605,7 +605,7 @@ CardDatabase::~CardDatabase() { clear(); delete noCard; - + pictureLoader->deleteLater(); pictureLoaderThread->wait(); delete pictureLoaderThread; @@ -619,7 +619,7 @@ void CardDatabase::clear() delete setIt.value(); } sets.clear(); - + QHashIterator i(cards); while (i.hasNext()) { i.next(); @@ -770,30 +770,11 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens) } } -CardInfo *CardNameMap::findByPrefix(const std::string &prefix) { - int count = 0; - CardInfo *found; - - for (CardNameMap::iterator it = this->begin(); it != this->end(); ++it) { - if (std::mismatch(prefix.begin(), prefix.end(), - it.key().toStdString().begin()).first == prefix.end()) { - count++; - found = it.value(); - } - } - - return (count == 1 ? found : NULL); -} - CardInfo *CardDatabase::getCardFromMap(CardNameMap &cardMap, const QString &cardName, bool createIfNotFound) { - CardInfo *foundCard; - if (cardName.isEmpty()) return noCard; else if (cardMap.contains(cardName)) return cardMap.value(cardName); - else if ((foundCard = cardMap.findByPrefix(cardName.toStdString()))) - return foundCard; else if (createIfNotFound) { CardInfo *newCard = new CardInfo(this, cardName, true); newCard->addToSet(getSet("TK")); diff --git a/cockatrice/src/carddatabase.h b/cockatrice/src/carddatabase.h index 68732a4d..cbb25f3e 100644 --- a/cockatrice/src/carddatabase.h +++ b/cockatrice/src/carddatabase.h @@ -180,13 +180,7 @@ signals: enum LoadStatus { Ok, VersionTooOld, Invalid, NotLoaded, FileError, NoCards }; - -class CardNameMap: public QHash -{ - public: - CardInfo *findByPrefix(const std::string &prefix); -}; - +typedef QHash CardNameMap; typedef QHash SetNameMap; class CardDatabase : public QObject { From 9ef4d79c33535623e4ec9581ed064cce2424d861 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Tue, 14 Oct 2014 21:13:04 +0200 Subject: [PATCH 09/13] Install the audio/* plugins under windows and osx --- cockatrice/CMakeLists.txt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index e3bcd8fa..af031ab0 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -263,15 +263,16 @@ if(APPLE) set(qtconf_dest_dir cockatrice.app/Contents/Resources) # note: no codecs in qt5 - # note: phonon_backend => mediaservice + # note: phonon_backend => audio | mediaservice # note: needs platform on osx if (CMAKE_BUILD_TYPE STREQUAL "Debug") install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime - FILES_MATCHING REGEX "(codecs|iconengines|imageformats|mediaservice|phonon_backend|platforms)/.*_debug\\.dylib") + FILES_MATCHING REGEX "(audio|codecs|iconengines|imageformats|mediaservice|phonon_backend|platforms)/.*_debug\\.dylib") else() install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime - FILES_MATCHING REGEX "(codecs|iconengines|imageformats|mediaservice|phonon_backend|platforms)/[^_]*\\.dylib") + FILES_MATCHING REGEX "(audio|codecs|iconengines|imageformats|mediaservice|phonon_backend|platforms)/.*\\.dylib" + REGEX ".*_debug\\.dylib" EXCLUDE) endif() install(CODE " @@ -296,15 +297,15 @@ if(WIN32) set(qtconf_dest_dir .) # note: no codecs in qt5 - # note: phonon_backend => mediaservice + # note: phonon_backend => audio | mediaservice # note: needs platform on osx if (CMAKE_BUILD_TYPE STREQUAL "Debug") install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime - FILES_MATCHING REGEX "(codecs|iconengines|imageformats|mediaservice|phonon_backend|platforms)/.*d\\.dll") + FILES_MATCHING REGEX "(audio|codecs|iconengines|imageformats|mediaservice|phonon_backend|platforms)/.*d\\.dll") else() install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime - FILES_MATCHING REGEX "(codecs|iconengines|imageformats|mediaservice|phonon_backend|platforms)/.*[^d]\\.dll") + FILES_MATCHING REGEX "(audio|codecs|iconengines|imageformats|mediaservice|phonon_backend|platforms)/.*[^d]\\.dll") endif() install(CODE " From 82a3deec30b5a903d4863e6f85da558ffa6db42b Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Tue, 14 Oct 2014 21:13:16 +0200 Subject: [PATCH 10/13] Add a button in the sounds settings to play a test sound --- cockatrice/src/dlg_settings.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index 414550a9..0a9fe61a 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -25,6 +25,7 @@ #include "main.h" #include "settingscache.h" #include "priceupdater.h" +#include "soundengine.h" GeneralSettingsPage::GeneralSettingsPage() { @@ -503,6 +504,8 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage() connect(soundPathClearButton, SIGNAL(clicked()), this, SLOT(soundPathClearButtonClicked())); QPushButton *soundPathButton = new QPushButton("..."); connect(soundPathButton, SIGNAL(clicked()), this, SLOT(soundPathButtonClicked())); + QPushButton *soundTestButton = new QPushButton(QString("Play test sound")); + connect(soundTestButton, SIGNAL(clicked()), soundEngine, SLOT(cuckoo())); QGridLayout *soundGrid = new QGridLayout; soundGrid->addWidget(soundEnabledCheckBox, 0, 0, 1, 4); @@ -510,6 +513,7 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage() soundGrid->addWidget(soundPathEdit, 1, 1); soundGrid->addWidget(soundPathClearButton, 1, 2); soundGrid->addWidget(soundPathButton, 1, 3); + soundGrid->addWidget(soundTestButton, 1, 4); soundGroupBox = new QGroupBox; soundGroupBox->setLayout(soundGrid); From e0d76b60d0d060a91480a76ea85c3a9d77f199a4 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Tue, 14 Oct 2014 22:02:42 +0200 Subject: [PATCH 11/13] Change button label and made it translatable --- cockatrice/src/dlg_settings.cpp | 5 +++-- cockatrice/src/dlg_settings.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index 0a9fe61a..ae7e4cc2 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -504,7 +504,7 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage() connect(soundPathClearButton, SIGNAL(clicked()), this, SLOT(soundPathClearButtonClicked())); QPushButton *soundPathButton = new QPushButton("..."); connect(soundPathButton, SIGNAL(clicked()), this, SLOT(soundPathButtonClicked())); - QPushButton *soundTestButton = new QPushButton(QString("Play test sound")); + soundTestButton = new QPushButton(); connect(soundTestButton, SIGNAL(clicked()), soundEngine, SLOT(cuckoo())); QGridLayout *soundGrid = new QGridLayout; @@ -513,7 +513,7 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage() soundGrid->addWidget(soundPathEdit, 1, 1); soundGrid->addWidget(soundPathClearButton, 1, 2); soundGrid->addWidget(soundPathButton, 1, 3); - soundGrid->addWidget(soundTestButton, 1, 4); + soundGrid->addWidget(soundTestButton, 2, 1); soundGroupBox = new QGroupBox; soundGroupBox->setLayout(soundGrid); @@ -542,6 +542,7 @@ void UserInterfaceSettingsPage::retranslateUi() tapAnimationCheckBox->setText(tr("&Tap/untap animation")); soundEnabledCheckBox->setText(tr("Enable &sounds")); soundPathLabel->setText(tr("Path to sounds directory:")); + soundTestButton->setText(tr("Test system sound engine")); } void UserInterfaceSettingsPage::soundPathClearButtonClicked() diff --git a/cockatrice/src/dlg_settings.h b/cockatrice/src/dlg_settings.h index 0303ceef..de46f1b1 100644 --- a/cockatrice/src/dlg_settings.h +++ b/cockatrice/src/dlg_settings.h @@ -92,6 +92,7 @@ private: QLabel *soundPathLabel; QLineEdit *soundPathEdit; QGroupBox *generalGroupBox, *animationGroupBox, *soundGroupBox; + QPushButton *soundTestButton; public: UserInterfaceSettingsPage(); void retranslateUi(); From 03f79887c42f278a96f886e46d6dc9cad83221b7 Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Sat, 11 Oct 2014 00:22:49 +0200 Subject: [PATCH 12/13] Updated Hand image Looking at the client I saw the cockatrice was still on the card back. I have now removed it. --- cockatrice/resources/hand.svg | 229 +--------------------------------- 1 file changed, 5 insertions(+), 224 deletions(-) diff --git a/cockatrice/resources/hand.svg b/cockatrice/resources/hand.svg index 7c34d7cc..11113d0f 100644 --- a/cockatrice/resources/hand.svg +++ b/cockatrice/resources/hand.svg @@ -3420,12 +3420,12 @@ inkscape:cx="275.81007" inkscape:cy="262.51751" inkscape:document-units="px" - inkscape:current-layer="g4178-7" + inkscape:current-layer="g4178" showgrid="false" - inkscape:window-width="1920" - inkscape:window-height="1028" - inkscape:window-x="-8" - inkscape:window-y="-8" + inkscape:window-width="1600" + inkscape:window-height="1178" + inkscape:window-x="1912" + inkscape:window-y="227" inkscape:window-maximized="1" /> @@ -3700,79 +3700,6 @@ style="fill:url(#linearGradient5324-8-6-42-9-8-1);fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-opacity:0;display:inline" sodipodi:type="arc" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 80fd0fbcf3526643af26d0b197d644327b8d0c6d Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Fri, 17 Oct 2014 00:17:44 +0200 Subject: [PATCH 13/13] Removed inline logic Removed inline logic to static variable, slight performance increase. --- cockatrice/src/abstractcarddragitem.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/abstractcarddragitem.cpp b/cockatrice/src/abstractcarddragitem.cpp index 14724db3..acc73532 100644 --- a/cockatrice/src/abstractcarddragitem.cpp +++ b/cockatrice/src/abstractcarddragitem.cpp @@ -4,6 +4,9 @@ #include #include +static const float CARD_WIDTH_HALF = CARD_WIDTH / 2; +static const float CARD_HEIGHT_HALF = CARD_HEIGHT / 2; + AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item, const QPointF &_hotSpot, AbstractCardDragItem *parentDrag) : QGraphicsItem(), item(_item), hotSpot(_hotSpot) { @@ -22,7 +25,7 @@ AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item, const QPoint setZValue(2000000007); } if (item->getTapped()) - setTransform(QTransform().translate((float) CARD_WIDTH / 2, (float) CARD_HEIGHT / 2).rotate(90).translate((float) -CARD_WIDTH / 2, (float) -CARD_HEIGHT / 2)); + setTransform(QTransform().translate(CARD_WIDTH_HALF, CARD_HEIGHT_HALF).rotate(90).translate(-CARD_WIDTH_HALF, -CARD_HEIGHT_HALF)); setCacheMode(DeviceCoordinateCache); }