diff --git a/CMakeLists.txt b/CMakeLists.txt index 414df9f8..33c45867 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}) diff --git a/cmake/FindWin32SslRuntime.cmake b/cmake/FindWin32SslRuntime.cmake new file mode 100644 index 00000000..4b0fafa5 --- /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 standard installation paths for OpenSSL under Windows + + # 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/cmake/NSIS.template.in b/cmake/NSIS.template.in index 3c8514e6..2e1910f5 100644 --- a/cmake/NSIS.template.in +++ b/cmake/NSIS.template.in @@ -81,6 +81,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" diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 454f1a1f..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 " @@ -321,4 +322,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 ./) + endif() endif() \ No newline at end of file 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" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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); } 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 { diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index 414550a9..ae7e4cc2 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())); + soundTestButton = new QPushButton(); + 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, 2, 1); soundGroupBox = new QGroupBox; soundGroupBox->setLayout(soundGrid); @@ -538,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(); 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 ./) 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