From 8fc08800a48970248ca80f48c4a5a7f28c548663 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Thu, 12 Jun 2014 23:47:01 +0200 Subject: [PATCH 01/36] CPack generator; removed old prepareMacRelease.sh By now tested on OSX only --- CMakeLists.txt | 42 +++++++++++++++++++++++++++ prepareMacRelease.sh | 67 -------------------------------------------- 2 files changed, 42 insertions(+), 67 deletions(-) delete mode 100644 prepareMacRelease.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c3219cc..b0e779fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,11 +68,51 @@ set(CMAKE_AUTOMOC TRUE) # Find other needed libraries FIND_PACKAGE(Protobuf REQUIRED) +# Package builder +set(CPACK_PACKAGE_CONTACT "Daenyth+github@gmail.com") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_NAME}) +set(CPACK_PACKAGE_VENDOR "Cockatrice Development Team") +set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") +set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") +set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") + +if(UNIX) + if(APPLE) + set(CPACK_GENERATOR DragNDrop ${CPACK_GENERATOR}) + set(CPACK_GENERATOR "DragNDrop") + set(CPACK_DMG_FORMAT "UDBZ") + set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME}") + set(CPACK_SYSTEM_NAME "OSX") + set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}") + set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/cockatrice/resources/appicon.icns") + else() + # linux + set(CPACK_GENERATOR DEB ${CPACK_GENERATOR}) + set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}/${PROJECT_VERSION}") + set(CPACK_STRIP_FILES "bin/${PROJECT_NAME}") + set(CPACK_SOURCE_STRIP_FILES "") + endif() +elseif(WIN32) + set(CPACK_GENERATOR NSIS ${CPACK_GENERATOR}) + set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}\\\\${PROJECT_VERSION}") + set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\${PROJECT_NAME}.exe") + set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}") + set(CPACK_NSIS_HELP_LINK "https://github.com/Daenyth/Cockatrice") + set(CPACK_NSIS_URL_INFO_ABOUT "https://github.com/Daenyth/Cockatrice") + set(CPACK_NSIS_CONTACT "Daenyth+github@gmail.com") + set(CPACK_NSIS_MODIFY_PATH ON) +endif() + +include(CPack) + # Compile servatrice (default off) option(WITH_SERVER "build servatrice" OFF) add_subdirectory(common) if(WITH_SERVER) add_subdirectory(servatrice) + SET(CPACK_INSTALL_CMAKE_PROJECTS "servatrice;servatrice;ALL;/" ${CPACK_INSTALL_CMAKE_PROJECTS}) endif() # Compile cockatrice (default on) @@ -81,12 +121,14 @@ if(WITH_CLIENT) add_subdirectory(cockatrice) add_subdirectory(sounds) add_subdirectory(zonebg) + SET(CPACK_INSTALL_CMAKE_PROJECTS "cockatrice;cockatrice;ALL;/" ${CPACK_INSTALL_CMAKE_PROJECTS}) endif() # Compile oracle (default on) option(WITH_ORACLE "build oracle" ON) if(WITH_ORACLE) add_subdirectory(oracle) + SET(CPACK_INSTALL_CMAKE_PROJECTS "release/oracle.app;oracle;ALL;/" ${CPACK_INSTALL_CMAKE_PROJECTS}) endif() # Compile testclient (default off) diff --git a/prepareMacRelease.sh b/prepareMacRelease.sh deleted file mode 100644 index d1f58e26..00000000 --- a/prepareMacRelease.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh - -FRAMEWORKS="Core Gui Multimedia Network Svg Xml" -DATE=`date '+%Y%m%d'` -#QTDIR="/Users/brukie/QtSDK/Desktop/Qt/474/gcc" -QTLIB="/Users/brukie/qt_leopard/lib" -QTPLUGINS="/Users/brukie/qt_leopard/plugins" -PROTOBUF="/Users/brukie/protobuf_leopard" -DIR=cockatrice_mac_$DATE -if [ -d $DIR ]; then echo "delete old dir first"; exit 1; fi - -mkdir $DIR - -cp -R build/cockatrice/cockatrice.app $DIR -cp -R build/oracle/oracle.app $DIR -mkdir $DIR/Frameworks -cp -R sounds zonebg $DIR -mkdir $DIR/translations -cp build/cockatrice/*.qm $DIR/translations -cp -R $QTPLUGINS $DIR/PlugIns -for f in $FRAMEWORKS; do - cp -R $QTLIB/Qt"$f".framework $DIR/Frameworks -done -find $DIR/Frameworks -name '*debug*'|xargs -n 1 rm -f -find $DIR/Frameworks -name 'Headers'|xargs -n 1 rm -rf -find $DIR/PlugIns -name '*debug*'|xargs -n 1 rm -f -cp $PROTOBUF/lib/libprotobuf.7.dylib $DIR/Frameworks - -cd $DIR -for f in $FRAMEWORKS; do - echo "Framework $f" - echo "step 1" - install_name_tool -id @executable_path/../../../Frameworks/Qt"$f".framework/Versions/4/Qt"$f" Frameworks/Qt"$f".framework/Versions/4/Qt"$f" - for g in $FRAMEWORKS; do - install_name_tool -change $QTLIB/Qt"$f".framework/Versions/4/Qt"$f" @executable_path/../../../Frameworks/Qt"$f".framework/Versions/4/Qt"$f" Frameworks/Qt"$g".framework/Versions/4/Qt"$g" - done - echo "step 2" - for g in cockatrice oracle; do - install_name_tool -change $QTLIB/Qt"$f".framework/Versions/4/Qt"$f" @executable_path/../../../Frameworks/Qt"$f".framework/Versions/4/Qt"$f" "$g".app/Contents/MacOS/$g - done - echo "step 3" - for g in `find . -name '*.dylib'`; do - install_name_tool -change $QTLIB/Qt"$f".framework/Versions/4/Qt"$f" @executable_path/../../../Frameworks/Qt"$f".framework/Versions/4/Qt"$f" "$g" - done -done - -install_name_tool -id @executable_path/../../../libprotobuf.7.dylib Frameworks/libprotobuf.7.dylib -install_name_tool -change $PROTOBUF/lib/libprotobuf.7.dylib @executable_path/../../../Frameworks/libprotobuf.7.dylib cockatrice.app/Contents/MacOS/cockatrice - -cd .. - -VOL=cockatrice_mac_${DATE} -DMG="tmp-$VOL.dmg" - -SIZE=`du -sk $DIR | cut -f1` -SIZE=$((${SIZE}/1000+10)) -hdiutil create "$DMG" -megabytes ${SIZE} -ov -type UDIF -fs HFS+ -volname "$VOL" - -hdid "$DMG" -cp -R "${DIR}" "/Volumes/$VOL" -hdiutil detach "/Volumes/$VOL" -#osascript -e "tell application "Finder" to eject disk "$VOL"" && - -# convert to compressed image, delete temp image -rm -f "${VOL}.dmg" -hdiutil convert "$DMG" -format UDZO -o "${VOL}.dmg" -rm -f "$DMG" From 501ef1306b0b03a411013e0fad8ce4765454def7 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 21 Jun 2014 16:59:31 +0200 Subject: [PATCH 02/36] Workaround permission problem in ixup_bundle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this change, make install and make package would require “sudo” under osx --- cockatrice/CMakeLists.txt | 1 + oracle/CMakeLists.txt | 1 + servatrice/CMakeLists.txt | 1 + 3 files changed, 3 insertions(+) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 499836dd..c0cb4768 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -206,6 +206,7 @@ Plugins = Plugins\") install(CODE " file(GLOB_RECURSE QTPLUGINS \"${plugin_dest_dir}/*.dylib\") + set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities) fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/cockatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") " COMPONENT Runtime) diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index 2eada38c..d9b5df75 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -71,6 +71,7 @@ Plugins = Plugins\") install(CODE " file(GLOB_RECURSE QTPLUGINS \"${plugin_dest_dir}/*.dylib\") + set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities) fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/oracle.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") " COMPONENT Runtime) diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index 799cecbd..19575ca1 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -78,6 +78,7 @@ Plugins = Plugins\") install(CODE " file(GLOB_RECURSE QTPLUGINS \"${plugin_dest_dir}/*.dylib\") + set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities) fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/servatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") " COMPONENT Runtime) From 87d4309aaa51796fe47ead153cc4a31223a63e8e Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 21 Jun 2014 17:28:27 +0200 Subject: [PATCH 03/36] Fix qt.conf file creation for "make package" --- cockatrice/CMakeLists.txt | 4 +++- oracle/CMakeLists.txt | 4 +++- servatrice/CMakeLists.txt | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index c0cb4768..535c5ac3 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -183,8 +183,10 @@ add_custom_command( ) if(APPLE) + # this needs to be relative set(plugin_dest_dir ./cockatrice.app/Contents/Plugins) - set(qtconf_dest_dir ./cockatrice.app/Contents/Resources) + # instead, this needs an absolute path (for make package to work) + set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/cockatrice.app/Contents/Resources) # note: no codecs in qt5 # note: phonon_backend => mediaservice diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index d9b5df75..46502cc4 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -48,8 +48,10 @@ IF (NOT WIN32 AND NOT APPLE) ENDIF (NOT WIN32 AND NOT APPLE) if(APPLE) + # this needs to be relative set(plugin_dest_dir ./oracle.app/Contents/Plugins) - set(qtconf_dest_dir ./oracle.app/Contents/Resources) + # instead, this needs an absolute path (for make) + set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/oracle.app/Contents/Resources) # note: no codecs in qt5 # note: phonon_backend => mediaservice diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index 19575ca1..9a66fe3b 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -55,8 +55,10 @@ elseif(WIN32) endif() if(APPLE) + # this needs to be relative set(plugin_dest_dir ./servatrice.app/Contents/Plugins) - set(qtconf_dest_dir ./servatrice.app/Contents/Resources) + # instead, this needs an absolute path (for make) + set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/servatrice.app/Contents/Resources) # note: no codecs in qt5 # note: phonon_backend => mediaservice From d74703f7af3edfaf78a98ae9524d607981ac43e4 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 21 Jun 2014 17:28:58 +0200 Subject: [PATCH 04/36] osx: install sounds and zonebg as cockatrice's resources --- sounds/CMakeLists.txt | 2 +- zonebg/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sounds/CMakeLists.txt b/sounds/CMakeLists.txt index e38c9090..cd9f6c33 100644 --- a/sounds/CMakeLists.txt +++ b/sounds/CMakeLists.txt @@ -6,7 +6,7 @@ FILE(GLOB sounds "${CMAKE_CURRENT_SOURCE_DIR}/*.raw") if(UNIX) if(APPLE) - INSTALL(FILES ${sounds} DESTINATION sounds/) + INSTALL(FILES ${sounds} DESTINATION cockatrice.app/Contents/Resources/sounds/) else() # Assume linux INSTALL(FILES ${sounds} DESTINATION share/cockatrice/sounds/) diff --git a/zonebg/CMakeLists.txt b/zonebg/CMakeLists.txt index 961c4e12..e2904502 100644 --- a/zonebg/CMakeLists.txt +++ b/zonebg/CMakeLists.txt @@ -6,7 +6,7 @@ FILE(GLOB zonebg "${CMAKE_CURRENT_SOURCE_DIR}/*.*") if(UNIX) if(APPLE) - INSTALL(FILES ${zonebg} DESTINATION zonebg/) + INSTALL(FILES ${zonebg} DESTINATION cockatrice.app/Contents/Resources/zonebg/) else() # Assume linux INSTALL(FILES ${zonebg} DESTINATION share/cockatrice/zonebg/) From b743ba4e6e0e7cf7c4bf67c2fb76be1d88cebd9b Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 21 Jun 2014 18:15:27 +0200 Subject: [PATCH 05/36] Partially revert previous commits; ensure the bundle is fixed up correctly --- cockatrice/CMakeLists.txt | 4 +--- oracle/CMakeLists.txt | 4 +--- servatrice/CMakeLists.txt | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 535c5ac3..4303f567 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -183,9 +183,7 @@ add_custom_command( ) if(APPLE) - # this needs to be relative - set(plugin_dest_dir ./cockatrice.app/Contents/Plugins) - # instead, this needs an absolute path (for make package to work) + set(plugin_dest_dir ${CMAKE_INSTALL_PREFIX}/cockatrice.app/Contents/Plugins) set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/cockatrice.app/Contents/Resources) # note: no codecs in qt5 diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index 46502cc4..e42b154b 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -48,9 +48,7 @@ IF (NOT WIN32 AND NOT APPLE) ENDIF (NOT WIN32 AND NOT APPLE) if(APPLE) - # this needs to be relative - set(plugin_dest_dir ./oracle.app/Contents/Plugins) - # instead, this needs an absolute path (for make) + set(plugin_dest_dir ${CMAKE_INSTALL_PREFIX}/oracle.app/Contents/Plugins) set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/oracle.app/Contents/Resources) # note: no codecs in qt5 diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index 9a66fe3b..5b65c2f9 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -55,9 +55,7 @@ elseif(WIN32) endif() if(APPLE) - # this needs to be relative - set(plugin_dest_dir ./servatrice.app/Contents/Plugins) - # instead, this needs an absolute path (for make) + set(plugin_dest_dir ${CMAKE_INSTALL_PREFIX}/servatrice.app/Contents/Plugins) set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/servatrice.app/Contents/Resources) # note: no codecs in qt5 From f9554267d41c52d0262594739e90034d190043a7 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 21 Jun 2014 19:04:42 +0200 Subject: [PATCH 06/36] This finally fixes both make install and make package --- cockatrice/CMakeLists.txt | 15 +++++++++------ oracle/CMakeLists.txt | 9 ++++++--- servatrice/CMakeLists.txt | 9 ++++++--- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 4303f567..f6066926 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -183,8 +183,10 @@ add_custom_command( ) if(APPLE) - set(plugin_dest_dir ${CMAKE_INSTALL_PREFIX}/cockatrice.app/Contents/Plugins) - set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/cockatrice.app/Contents/Resources) + # this needs to be relative + set(plugin_dest_dir cockatrice.app/Contents/Plugins) + # instead, this needs an absolute path (for make package to work) + set(qtconf_dest_dir cockatrice.app/Contents/Resources) # note: no codecs in qt5 # note: phonon_backend => mediaservice @@ -199,13 +201,14 @@ if(APPLE) endif() install(CODE " - file(WRITE \"${qtconf_dest_dir}/qt.conf\" \"[Paths] -Plugins = Plugins\") - " COMPONENT Runtime) + file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] +Plugins = Plugins +Translations = Resources/translations\") + " COMPONENT Runtime) install(CODE " file(GLOB_RECURSE QTPLUGINS - \"${plugin_dest_dir}/*.dylib\") + \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\") set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities) fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/cockatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index e42b154b..55b63050 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -48,7 +48,9 @@ IF (NOT WIN32 AND NOT APPLE) ENDIF (NOT WIN32 AND NOT APPLE) if(APPLE) - set(plugin_dest_dir ${CMAKE_INSTALL_PREFIX}/oracle.app/Contents/Plugins) + # this needs to be relative + set(plugin_dest_dir oracle.app/Contents/Plugins) + # instead, this needs an absolute path (for make) set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/oracle.app/Contents/Resources) # note: no codecs in qt5 @@ -65,12 +67,13 @@ if(APPLE) install(CODE " file(WRITE \"${qtconf_dest_dir}/qt.conf\" \"[Paths] -Plugins = Plugins\") +Plugins = Plugins +Translations = Resources/translations\") " COMPONENT Runtime) install(CODE " file(GLOB_RECURSE QTPLUGINS - \"${plugin_dest_dir}/*.dylib\") + \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\") set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities) fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/oracle.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index 5b65c2f9..8c44c05b 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -55,7 +55,9 @@ elseif(WIN32) endif() if(APPLE) - set(plugin_dest_dir ${CMAKE_INSTALL_PREFIX}/servatrice.app/Contents/Plugins) + # this needs to be relative + set(plugin_dest_dir servatrice.app/Contents/Plugins) + # instead, this needs an absolute path (for make) set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/servatrice.app/Contents/Resources) # note: no codecs in qt5 @@ -72,12 +74,13 @@ if(APPLE) install(CODE " file(WRITE \"${qtconf_dest_dir}/qt.conf\" \"[Paths] -Plugins = Plugins\") +Plugins = Plugins +Translations = Resources/translations\") " COMPONENT Runtime) install(CODE " file(GLOB_RECURSE QTPLUGINS - \"${plugin_dest_dir}/*.dylib\") + \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\") set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities) fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/servatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") From e39cfb7968fc2f8ebd33e46d852fb4820b07b591 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 21 Jun 2014 19:09:41 +0200 Subject: [PATCH 07/36] Osx: removed plugins path detection and fixed translation path detection --- cockatrice/src/main.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index ef57655a..4c953e51 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -80,15 +80,6 @@ int main(int argc, char *argv[]) if (app.arguments().contains("--debug-output")) qInstallMsgHandler(myMessageOutput); -#ifdef Q_OS_MAC - QDir baseDir(app.applicationDirPath()); - baseDir.cdUp(); - baseDir.cdUp(); - baseDir.cdUp(); - QDir pluginsDir = baseDir; - pluginsDir.cd("PlugIns"); - app.addLibraryPath(pluginsDir.absolutePath()); -#endif #ifdef Q_OS_WIN app.addLibraryPath(app.applicationDirPath() + "/plugins"); #endif @@ -100,11 +91,12 @@ int main(int argc, char *argv[]) if (translationPath.isEmpty()) { #ifdef Q_OS_MAC - QDir translationsDir = baseDir; + QDir translationsDir = app.applicationDirPath(); + translationsDir.cd(".."); + translationsDir.cd("Resources"); translationsDir.cd("translations"); translationPath = translationsDir.absolutePath(); -#endif -#ifdef Q_OS_WIN +#elif Q_OS_WIN translationPath = app.applicationDirPath() + "/translations"; #endif } From 8305927fa2f7337a7d8f80830f03d13cc7157081 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 22 Jun 2014 21:11:39 +0200 Subject: [PATCH 08/36] Port "make package" fix to oracle and servatrice --- cockatrice/CMakeLists.txt | 3 +-- oracle/CMakeLists.txt | 9 ++++----- servatrice/CMakeLists.txt | 7 +++---- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index f6066926..170721b4 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -183,9 +183,8 @@ add_custom_command( ) if(APPLE) - # this needs to be relative + # these needs to be relative to CMAKE_INSTALL_PREFIX set(plugin_dest_dir cockatrice.app/Contents/Plugins) - # instead, this needs an absolute path (for make package to work) set(qtconf_dest_dir cockatrice.app/Contents/Resources) # note: no codecs in qt5 diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index 55b63050..05bcd494 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -48,10 +48,9 @@ IF (NOT WIN32 AND NOT APPLE) ENDIF (NOT WIN32 AND NOT APPLE) if(APPLE) - # this needs to be relative + # these needs to be relative to CMAKE_INSTALL_PREFIX set(plugin_dest_dir oracle.app/Contents/Plugins) - # instead, this needs an absolute path (for make) - set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/oracle.app/Contents/Resources) + set(qtconf_dest_dir oracle.app/Contents/Resources) # note: no codecs in qt5 # note: phonon_backend => mediaservice @@ -66,10 +65,10 @@ if(APPLE) endif() install(CODE " - file(WRITE \"${qtconf_dest_dir}/qt.conf\" \"[Paths] + file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] Plugins = Plugins Translations = Resources/translations\") - " COMPONENT Runtime) + " COMPONENT Runtime) install(CODE " file(GLOB_RECURSE QTPLUGINS diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index 8c44c05b..c1aefed1 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -55,10 +55,9 @@ elseif(WIN32) endif() if(APPLE) - # this needs to be relative + # these needs to be relative to CMAKE_INSTALL_PREFIX set(plugin_dest_dir servatrice.app/Contents/Plugins) - # instead, this needs an absolute path (for make) - set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/servatrice.app/Contents/Resources) + set(qtconf_dest_dir servatrice.app/Contents/Resources) # note: no codecs in qt5 # note: phonon_backend => mediaservice @@ -73,7 +72,7 @@ if(APPLE) endif() install(CODE " - file(WRITE \"${qtconf_dest_dir}/qt.conf\" \"[Paths] + file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] Plugins = Plugins Translations = Resources/translations\") " COMPONENT Runtime) From 2b371fd96b8b61a237405b32a22a768de93f3974 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 22 Jun 2014 21:19:10 +0200 Subject: [PATCH 09/36] OSX: get translation path from qt.conf instead of hardcoding it --- cockatrice/src/main.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index 84975fb1..18c8b56e 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -91,11 +91,7 @@ int main(int argc, char *argv[]) if (translationPath.isEmpty()) { #ifdef Q_OS_MAC - QDir translationsDir = app.applicationDirPath(); - translationsDir.cd(".."); - translationsDir.cd("Resources"); - translationsDir.cd("translations"); - translationPath = translationsDir.absolutePath(); + translationPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); #elif Q_OS_WIN translationPath = app.applicationDirPath() + "/translations"; #endif From 45c71c09cd8274eec7bf3ed183ce99b8f9bf0205 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 22 Jun 2014 23:21:29 +0200 Subject: [PATCH 10/36] OSX: Handle zonebg for first time installations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If none of the gameboard images is set and and the user’s data directory doesn’t contain a “zonebg” directory, create the directory, copy contents from cockatrice’s app bundle and sets the config accordingly. --- cockatrice/CMakeLists.txt | 3 ++- cockatrice/src/main.cpp | 22 ++++++++++++++++++++++ cockatrice/src/settingscache.cpp | 26 ++++++++++++++++++++++++++ cockatrice/src/settingscache.h | 1 + 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 170721b4..8cfca257 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -202,7 +202,8 @@ if(APPLE) install(CODE " file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] Plugins = Plugins -Translations = Resources/translations\") +Translations = Resources/translations +Data = Resources\") " COMPONENT Runtime) install(CODE " diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index 18c8b56e..f3e2ad16 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -126,6 +126,28 @@ int main(int argc, char *argv[]) QDir().mkpath(dataDir + "/pics"); settingsCache->setPicsPath(dataDir + "/pics"); } +#ifdef Q_OS_MAC + if(settingsCache->getHandBgPath().isEmpty() && + settingsCache->getStackBgPath().isEmpty() && + settingsCache->getTableBgPath().isEmpty() && + settingsCache->getPlayerBgPath().isEmpty()) + { + QString srcDir = QLibraryInfo::location(QLibraryInfo::DataPath); + QString destDir = dataDir + "/zonebg"; + QDir tmpDir(destDir); + if(!tmpDir.exists()) + { + // try to install the default images for the current user and set the settigs value + settingsCache->copyPath(srcDir + "/zonebg", destDir); + + settingsCache->setHandBgPath(destDir + "/fabric_green.png"); + settingsCache->setStackBgPath(destDir + "/fabric_red.png"); + settingsCache->setTableBgPath(destDir + "/fabric_blue.png"); + settingsCache->setPlayerBgPath(destDir + "/fabric_gray.png"); + } + } +#endif + if (!db->getLoadSuccess() || !QDir(settingsCache->getDeckPath()).exists() || settingsCache->getDeckPath().isEmpty() || settingsCache->getPicsPath().isEmpty() || !QDir(settingsCache->getPicsPath()).exists()) { DlgSettings dlgSettings; dlgSettings.show(); diff --git a/cockatrice/src/settingscache.cpp b/cockatrice/src/settingscache.cpp index ac5c130f..ee4fc635 100644 --- a/cockatrice/src/settingscache.cpp +++ b/cockatrice/src/settingscache.cpp @@ -1,5 +1,6 @@ #include "settingscache.h" #include +#include SettingsCache::SettingsCache() { @@ -256,3 +257,28 @@ void SettingsCache::setMainWindowGeometry(const QByteArray &_mainWindowGeometry) mainWindowGeometry = _mainWindowGeometry; settings->setValue("interface/main_window_geometry", mainWindowGeometry); } + +void SettingsCache::copyPath(const QString &src, const QString &dst) +{ + // test source && return if inexistent + QDir dir(src); + if (! dir.exists()) + return; + // test destination && create if inexistent + QDir tmpDir(dst); + if (!tmpDir.exists()) + { + tmpDir.setPath(QDir::rootPath()); + tmpDir.mkdir(dst); + } + + foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { + QString dst_path = dst + QDir::separator() + d; + dir.mkpath(dst_path); + copyPath(src+ QDir::separator() + d, dst_path); + } + + foreach (QString f, dir.entryList(QDir::Files)) { + QFile::copy(src + QDir::separator() + f, dst + QDir::separator() + f); + } +} diff --git a/cockatrice/src/settingscache.h b/cockatrice/src/settingscache.h index 5156772d..5ae11c9e 100644 --- a/cockatrice/src/settingscache.h +++ b/cockatrice/src/settingscache.h @@ -89,6 +89,7 @@ public: bool getIgnoreUnregisteredUsers() const { return ignoreUnregisteredUsers; } QString getPicUrl() const { return picUrl; } QString getPicUrlHq() const { return picUrlHq; } + void copyPath(const QString &src, const QString &dst); public slots: void setMainWindowGeometry(const QByteArray &_mainWindowGeometry); void setLang(const QString &_lang); From d396b3dfacd6a46b62adcef00be9adae5bb6c28f Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 22 Jun 2014 23:24:44 +0200 Subject: [PATCH 11/36] Zonebg: avoid installing the CMakeLists.txt file --- zonebg/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zonebg/CMakeLists.txt b/zonebg/CMakeLists.txt index e2904502..b250a44b 100644 --- a/zonebg/CMakeLists.txt +++ b/zonebg/CMakeLists.txt @@ -2,7 +2,7 @@ # # Installs default "zone background" files -FILE(GLOB zonebg "${CMAKE_CURRENT_SOURCE_DIR}/*.*") +FILE(GLOB zonebg "${CMAKE_CURRENT_SOURCE_DIR}/*.png" "${CMAKE_CURRENT_SOURCE_DIR}/*.jpg") if(UNIX) if(APPLE) From fef005d0422031b35578182ada78a8939dfe6620 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 22 Jun 2014 23:29:42 +0200 Subject: [PATCH 12/36] OSX: Handle sounds for first time installations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the sounds path is unset in the settings and a “sounds” directory doesn’t exists in the user’s data directory, install the sounds files and set the settings value accordingly --- cockatrice/src/main.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index f3e2ad16..bce3075c 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -146,6 +146,20 @@ int main(int argc, char *argv[]) settingsCache->setPlayerBgPath(destDir + "/fabric_gray.png"); } } + + if(settingsCache->getSoundPath().isEmpty()) + { + QString srcDir = QLibraryInfo::location(QLibraryInfo::DataPath); + QString destDir = dataDir + "/sounds"; + QDir tmpDir(destDir); + if(!tmpDir.exists()) + { + // try to install the default sounds for the current user and set the settigs value + settingsCache->copyPath(srcDir + "/sounds", destDir); + + settingsCache->setSoundPath(destDir); + } + } #endif if (!db->getLoadSuccess() || !QDir(settingsCache->getDeckPath()).exists() || settingsCache->getDeckPath().isEmpty() || settingsCache->getPicsPath().isEmpty() || !QDir(settingsCache->getPicsPath()).exists()) { From 377433b5cc0b465ba2a50e0062fa2284b8f48052 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Thu, 12 Jun 2014 23:47:01 +0200 Subject: [PATCH 13/36] CPack generator; removed old prepareMacRelease.sh By now tested on OSX only --- CMakeLists.txt | 42 +++++++++++++++++++++++++++ prepareMacRelease.sh | 67 -------------------------------------------- 2 files changed, 42 insertions(+), 67 deletions(-) delete mode 100644 prepareMacRelease.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index c8756e90..2791a0ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,11 +79,51 @@ set(CMAKE_AUTOMOC TRUE) # Find other needed libraries FIND_PACKAGE(Protobuf REQUIRED) +# Package builder +set(CPACK_PACKAGE_CONTACT "Daenyth+github@gmail.com") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_NAME}) +set(CPACK_PACKAGE_VENDOR "Cockatrice Development Team") +set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") +set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") +set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") + +if(UNIX) + if(APPLE) + set(CPACK_GENERATOR DragNDrop ${CPACK_GENERATOR}) + set(CPACK_GENERATOR "DragNDrop") + set(CPACK_DMG_FORMAT "UDBZ") + set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME}") + set(CPACK_SYSTEM_NAME "OSX") + set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}") + set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/cockatrice/resources/appicon.icns") + else() + # linux + set(CPACK_GENERATOR DEB ${CPACK_GENERATOR}) + set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}/${PROJECT_VERSION}") + set(CPACK_STRIP_FILES "bin/${PROJECT_NAME}") + set(CPACK_SOURCE_STRIP_FILES "") + endif() +elseif(WIN32) + set(CPACK_GENERATOR NSIS ${CPACK_GENERATOR}) + set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}\\\\${PROJECT_VERSION}") + set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\${PROJECT_NAME}.exe") + set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}") + set(CPACK_NSIS_HELP_LINK "https://github.com/Daenyth/Cockatrice") + set(CPACK_NSIS_URL_INFO_ABOUT "https://github.com/Daenyth/Cockatrice") + set(CPACK_NSIS_CONTACT "Daenyth+github@gmail.com") + set(CPACK_NSIS_MODIFY_PATH ON) +endif() + +include(CPack) + # Compile servatrice (default off) option(WITH_SERVER "build servatrice" OFF) add_subdirectory(common) if(WITH_SERVER) add_subdirectory(servatrice) + SET(CPACK_INSTALL_CMAKE_PROJECTS "servatrice;servatrice;ALL;/" ${CPACK_INSTALL_CMAKE_PROJECTS}) endif() # Compile cockatrice (default on) @@ -92,12 +132,14 @@ if(WITH_CLIENT) add_subdirectory(cockatrice) add_subdirectory(sounds) add_subdirectory(zonebg) + SET(CPACK_INSTALL_CMAKE_PROJECTS "cockatrice;cockatrice;ALL;/" ${CPACK_INSTALL_CMAKE_PROJECTS}) endif() # Compile oracle (default on) option(WITH_ORACLE "build oracle" ON) if(WITH_ORACLE) add_subdirectory(oracle) + SET(CPACK_INSTALL_CMAKE_PROJECTS "release/oracle.app;oracle;ALL;/" ${CPACK_INSTALL_CMAKE_PROJECTS}) endif() # Compile testclient (default off) diff --git a/prepareMacRelease.sh b/prepareMacRelease.sh deleted file mode 100644 index d1f58e26..00000000 --- a/prepareMacRelease.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh - -FRAMEWORKS="Core Gui Multimedia Network Svg Xml" -DATE=`date '+%Y%m%d'` -#QTDIR="/Users/brukie/QtSDK/Desktop/Qt/474/gcc" -QTLIB="/Users/brukie/qt_leopard/lib" -QTPLUGINS="/Users/brukie/qt_leopard/plugins" -PROTOBUF="/Users/brukie/protobuf_leopard" -DIR=cockatrice_mac_$DATE -if [ -d $DIR ]; then echo "delete old dir first"; exit 1; fi - -mkdir $DIR - -cp -R build/cockatrice/cockatrice.app $DIR -cp -R build/oracle/oracle.app $DIR -mkdir $DIR/Frameworks -cp -R sounds zonebg $DIR -mkdir $DIR/translations -cp build/cockatrice/*.qm $DIR/translations -cp -R $QTPLUGINS $DIR/PlugIns -for f in $FRAMEWORKS; do - cp -R $QTLIB/Qt"$f".framework $DIR/Frameworks -done -find $DIR/Frameworks -name '*debug*'|xargs -n 1 rm -f -find $DIR/Frameworks -name 'Headers'|xargs -n 1 rm -rf -find $DIR/PlugIns -name '*debug*'|xargs -n 1 rm -f -cp $PROTOBUF/lib/libprotobuf.7.dylib $DIR/Frameworks - -cd $DIR -for f in $FRAMEWORKS; do - echo "Framework $f" - echo "step 1" - install_name_tool -id @executable_path/../../../Frameworks/Qt"$f".framework/Versions/4/Qt"$f" Frameworks/Qt"$f".framework/Versions/4/Qt"$f" - for g in $FRAMEWORKS; do - install_name_tool -change $QTLIB/Qt"$f".framework/Versions/4/Qt"$f" @executable_path/../../../Frameworks/Qt"$f".framework/Versions/4/Qt"$f" Frameworks/Qt"$g".framework/Versions/4/Qt"$g" - done - echo "step 2" - for g in cockatrice oracle; do - install_name_tool -change $QTLIB/Qt"$f".framework/Versions/4/Qt"$f" @executable_path/../../../Frameworks/Qt"$f".framework/Versions/4/Qt"$f" "$g".app/Contents/MacOS/$g - done - echo "step 3" - for g in `find . -name '*.dylib'`; do - install_name_tool -change $QTLIB/Qt"$f".framework/Versions/4/Qt"$f" @executable_path/../../../Frameworks/Qt"$f".framework/Versions/4/Qt"$f" "$g" - done -done - -install_name_tool -id @executable_path/../../../libprotobuf.7.dylib Frameworks/libprotobuf.7.dylib -install_name_tool -change $PROTOBUF/lib/libprotobuf.7.dylib @executable_path/../../../Frameworks/libprotobuf.7.dylib cockatrice.app/Contents/MacOS/cockatrice - -cd .. - -VOL=cockatrice_mac_${DATE} -DMG="tmp-$VOL.dmg" - -SIZE=`du -sk $DIR | cut -f1` -SIZE=$((${SIZE}/1000+10)) -hdiutil create "$DMG" -megabytes ${SIZE} -ov -type UDIF -fs HFS+ -volname "$VOL" - -hdid "$DMG" -cp -R "${DIR}" "/Volumes/$VOL" -hdiutil detach "/Volumes/$VOL" -#osascript -e "tell application "Finder" to eject disk "$VOL"" && - -# convert to compressed image, delete temp image -rm -f "${VOL}.dmg" -hdiutil convert "$DMG" -format UDZO -o "${VOL}.dmg" -rm -f "$DMG" From 99f3519da579b07005141635252238a62e068888 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 21 Jun 2014 16:59:31 +0200 Subject: [PATCH 14/36] Workaround permission problem in ixup_bundle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this change, make install and make package would require “sudo” under osx --- cockatrice/CMakeLists.txt | 1 + oracle/CMakeLists.txt | 1 + servatrice/CMakeLists.txt | 1 + 3 files changed, 3 insertions(+) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 499836dd..c0cb4768 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -206,6 +206,7 @@ Plugins = Plugins\") install(CODE " file(GLOB_RECURSE QTPLUGINS \"${plugin_dest_dir}/*.dylib\") + set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities) fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/cockatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") " COMPONENT Runtime) diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index 2eada38c..d9b5df75 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -71,6 +71,7 @@ Plugins = Plugins\") install(CODE " file(GLOB_RECURSE QTPLUGINS \"${plugin_dest_dir}/*.dylib\") + set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities) fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/oracle.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") " COMPONENT Runtime) diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index 799cecbd..19575ca1 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -78,6 +78,7 @@ Plugins = Plugins\") install(CODE " file(GLOB_RECURSE QTPLUGINS \"${plugin_dest_dir}/*.dylib\") + set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities) fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/servatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") " COMPONENT Runtime) From 41c7ce8022f5714628095524b68d660fcfdfc262 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 21 Jun 2014 17:28:27 +0200 Subject: [PATCH 15/36] Fix qt.conf file creation for "make package" --- cockatrice/CMakeLists.txt | 4 +++- oracle/CMakeLists.txt | 4 +++- servatrice/CMakeLists.txt | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index c0cb4768..535c5ac3 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -183,8 +183,10 @@ add_custom_command( ) if(APPLE) + # this needs to be relative set(plugin_dest_dir ./cockatrice.app/Contents/Plugins) - set(qtconf_dest_dir ./cockatrice.app/Contents/Resources) + # instead, this needs an absolute path (for make package to work) + set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/cockatrice.app/Contents/Resources) # note: no codecs in qt5 # note: phonon_backend => mediaservice diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index d9b5df75..46502cc4 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -48,8 +48,10 @@ IF (NOT WIN32 AND NOT APPLE) ENDIF (NOT WIN32 AND NOT APPLE) if(APPLE) + # this needs to be relative set(plugin_dest_dir ./oracle.app/Contents/Plugins) - set(qtconf_dest_dir ./oracle.app/Contents/Resources) + # instead, this needs an absolute path (for make) + set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/oracle.app/Contents/Resources) # note: no codecs in qt5 # note: phonon_backend => mediaservice diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index 19575ca1..9a66fe3b 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -55,8 +55,10 @@ elseif(WIN32) endif() if(APPLE) + # this needs to be relative set(plugin_dest_dir ./servatrice.app/Contents/Plugins) - set(qtconf_dest_dir ./servatrice.app/Contents/Resources) + # instead, this needs an absolute path (for make) + set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/servatrice.app/Contents/Resources) # note: no codecs in qt5 # note: phonon_backend => mediaservice From 1b2c839ff03d9b248575361f5ab95218bb4b0f32 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 21 Jun 2014 17:28:58 +0200 Subject: [PATCH 16/36] osx: install sounds and zonebg as cockatrice's resources --- sounds/CMakeLists.txt | 2 +- zonebg/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sounds/CMakeLists.txt b/sounds/CMakeLists.txt index e38c9090..cd9f6c33 100644 --- a/sounds/CMakeLists.txt +++ b/sounds/CMakeLists.txt @@ -6,7 +6,7 @@ FILE(GLOB sounds "${CMAKE_CURRENT_SOURCE_DIR}/*.raw") if(UNIX) if(APPLE) - INSTALL(FILES ${sounds} DESTINATION sounds/) + INSTALL(FILES ${sounds} DESTINATION cockatrice.app/Contents/Resources/sounds/) else() # Assume linux INSTALL(FILES ${sounds} DESTINATION share/cockatrice/sounds/) diff --git a/zonebg/CMakeLists.txt b/zonebg/CMakeLists.txt index 961c4e12..e2904502 100644 --- a/zonebg/CMakeLists.txt +++ b/zonebg/CMakeLists.txt @@ -6,7 +6,7 @@ FILE(GLOB zonebg "${CMAKE_CURRENT_SOURCE_DIR}/*.*") if(UNIX) if(APPLE) - INSTALL(FILES ${zonebg} DESTINATION zonebg/) + INSTALL(FILES ${zonebg} DESTINATION cockatrice.app/Contents/Resources/zonebg/) else() # Assume linux INSTALL(FILES ${zonebg} DESTINATION share/cockatrice/zonebg/) From 6d1de0c61797b10a26314ececee44e4a36e35d35 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 21 Jun 2014 18:15:27 +0200 Subject: [PATCH 17/36] Partially revert previous commits; ensure the bundle is fixed up correctly --- cockatrice/CMakeLists.txt | 4 +--- oracle/CMakeLists.txt | 4 +--- servatrice/CMakeLists.txt | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 535c5ac3..4303f567 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -183,9 +183,7 @@ add_custom_command( ) if(APPLE) - # this needs to be relative - set(plugin_dest_dir ./cockatrice.app/Contents/Plugins) - # instead, this needs an absolute path (for make package to work) + set(plugin_dest_dir ${CMAKE_INSTALL_PREFIX}/cockatrice.app/Contents/Plugins) set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/cockatrice.app/Contents/Resources) # note: no codecs in qt5 diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index 46502cc4..e42b154b 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -48,9 +48,7 @@ IF (NOT WIN32 AND NOT APPLE) ENDIF (NOT WIN32 AND NOT APPLE) if(APPLE) - # this needs to be relative - set(plugin_dest_dir ./oracle.app/Contents/Plugins) - # instead, this needs an absolute path (for make) + set(plugin_dest_dir ${CMAKE_INSTALL_PREFIX}/oracle.app/Contents/Plugins) set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/oracle.app/Contents/Resources) # note: no codecs in qt5 diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index 9a66fe3b..5b65c2f9 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -55,9 +55,7 @@ elseif(WIN32) endif() if(APPLE) - # this needs to be relative - set(plugin_dest_dir ./servatrice.app/Contents/Plugins) - # instead, this needs an absolute path (for make) + set(plugin_dest_dir ${CMAKE_INSTALL_PREFIX}/servatrice.app/Contents/Plugins) set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/servatrice.app/Contents/Resources) # note: no codecs in qt5 From b44365b73c63f6029074b7e338502b769239f2a2 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 21 Jun 2014 19:04:42 +0200 Subject: [PATCH 18/36] This finally fixes both make install and make package --- cockatrice/CMakeLists.txt | 15 +++++++++------ oracle/CMakeLists.txt | 9 ++++++--- servatrice/CMakeLists.txt | 9 ++++++--- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 4303f567..f6066926 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -183,8 +183,10 @@ add_custom_command( ) if(APPLE) - set(plugin_dest_dir ${CMAKE_INSTALL_PREFIX}/cockatrice.app/Contents/Plugins) - set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/cockatrice.app/Contents/Resources) + # this needs to be relative + set(plugin_dest_dir cockatrice.app/Contents/Plugins) + # instead, this needs an absolute path (for make package to work) + set(qtconf_dest_dir cockatrice.app/Contents/Resources) # note: no codecs in qt5 # note: phonon_backend => mediaservice @@ -199,13 +201,14 @@ if(APPLE) endif() install(CODE " - file(WRITE \"${qtconf_dest_dir}/qt.conf\" \"[Paths] -Plugins = Plugins\") - " COMPONENT Runtime) + file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] +Plugins = Plugins +Translations = Resources/translations\") + " COMPONENT Runtime) install(CODE " file(GLOB_RECURSE QTPLUGINS - \"${plugin_dest_dir}/*.dylib\") + \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\") set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities) fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/cockatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index e42b154b..55b63050 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -48,7 +48,9 @@ IF (NOT WIN32 AND NOT APPLE) ENDIF (NOT WIN32 AND NOT APPLE) if(APPLE) - set(plugin_dest_dir ${CMAKE_INSTALL_PREFIX}/oracle.app/Contents/Plugins) + # this needs to be relative + set(plugin_dest_dir oracle.app/Contents/Plugins) + # instead, this needs an absolute path (for make) set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/oracle.app/Contents/Resources) # note: no codecs in qt5 @@ -65,12 +67,13 @@ if(APPLE) install(CODE " file(WRITE \"${qtconf_dest_dir}/qt.conf\" \"[Paths] -Plugins = Plugins\") +Plugins = Plugins +Translations = Resources/translations\") " COMPONENT Runtime) install(CODE " file(GLOB_RECURSE QTPLUGINS - \"${plugin_dest_dir}/*.dylib\") + \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\") set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities) fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/oracle.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index 5b65c2f9..8c44c05b 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -55,7 +55,9 @@ elseif(WIN32) endif() if(APPLE) - set(plugin_dest_dir ${CMAKE_INSTALL_PREFIX}/servatrice.app/Contents/Plugins) + # this needs to be relative + set(plugin_dest_dir servatrice.app/Contents/Plugins) + # instead, this needs an absolute path (for make) set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/servatrice.app/Contents/Resources) # note: no codecs in qt5 @@ -72,12 +74,13 @@ if(APPLE) install(CODE " file(WRITE \"${qtconf_dest_dir}/qt.conf\" \"[Paths] -Plugins = Plugins\") +Plugins = Plugins +Translations = Resources/translations\") " COMPONENT Runtime) install(CODE " file(GLOB_RECURSE QTPLUGINS - \"${plugin_dest_dir}/*.dylib\") + \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\") set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities) fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/servatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") From 2a5f6181aa0996bd3b143f15bdf6f0d83433d7bc Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 21 Jun 2014 19:09:41 +0200 Subject: [PATCH 19/36] Osx: removed plugins path detection and fixed translation path detection --- cockatrice/src/main.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index d0664bf9..0ac4042a 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -88,15 +88,6 @@ int main(int argc, char *argv[]) if (app.arguments().contains("--debug-output")) qInstallMsgHandler(myMessageOutput); -#ifdef Q_OS_MAC - QDir baseDir(app.applicationDirPath()); - baseDir.cdUp(); - baseDir.cdUp(); - baseDir.cdUp(); - QDir pluginsDir = baseDir; - pluginsDir.cd("PlugIns"); - app.addLibraryPath(pluginsDir.absolutePath()); -#endif #ifdef Q_OS_WIN app.addLibraryPath(app.applicationDirPath() + "/plugins"); #endif @@ -108,11 +99,12 @@ int main(int argc, char *argv[]) if (translationPath.isEmpty()) { #ifdef Q_OS_MAC - QDir translationsDir = baseDir; + QDir translationsDir = app.applicationDirPath(); + translationsDir.cd(".."); + translationsDir.cd("Resources"); translationsDir.cd("translations"); translationPath = translationsDir.absolutePath(); -#endif -#ifdef Q_OS_WIN +#elif Q_OS_WIN translationPath = app.applicationDirPath() + "/translations"; #endif } From 2eebddea9a070234091284ab33516c22eda02f62 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 22 Jun 2014 21:11:39 +0200 Subject: [PATCH 20/36] Port "make package" fix to oracle and servatrice --- cockatrice/CMakeLists.txt | 3 +-- oracle/CMakeLists.txt | 9 ++++----- servatrice/CMakeLists.txt | 7 +++---- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index f6066926..170721b4 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -183,9 +183,8 @@ add_custom_command( ) if(APPLE) - # this needs to be relative + # these needs to be relative to CMAKE_INSTALL_PREFIX set(plugin_dest_dir cockatrice.app/Contents/Plugins) - # instead, this needs an absolute path (for make package to work) set(qtconf_dest_dir cockatrice.app/Contents/Resources) # note: no codecs in qt5 diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index 55b63050..05bcd494 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -48,10 +48,9 @@ IF (NOT WIN32 AND NOT APPLE) ENDIF (NOT WIN32 AND NOT APPLE) if(APPLE) - # this needs to be relative + # these needs to be relative to CMAKE_INSTALL_PREFIX set(plugin_dest_dir oracle.app/Contents/Plugins) - # instead, this needs an absolute path (for make) - set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/oracle.app/Contents/Resources) + set(qtconf_dest_dir oracle.app/Contents/Resources) # note: no codecs in qt5 # note: phonon_backend => mediaservice @@ -66,10 +65,10 @@ if(APPLE) endif() install(CODE " - file(WRITE \"${qtconf_dest_dir}/qt.conf\" \"[Paths] + file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] Plugins = Plugins Translations = Resources/translations\") - " COMPONENT Runtime) + " COMPONENT Runtime) install(CODE " file(GLOB_RECURSE QTPLUGINS diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index 8c44c05b..c1aefed1 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -55,10 +55,9 @@ elseif(WIN32) endif() if(APPLE) - # this needs to be relative + # these needs to be relative to CMAKE_INSTALL_PREFIX set(plugin_dest_dir servatrice.app/Contents/Plugins) - # instead, this needs an absolute path (for make) - set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/servatrice.app/Contents/Resources) + set(qtconf_dest_dir servatrice.app/Contents/Resources) # note: no codecs in qt5 # note: phonon_backend => mediaservice @@ -73,7 +72,7 @@ if(APPLE) endif() install(CODE " - file(WRITE \"${qtconf_dest_dir}/qt.conf\" \"[Paths] + file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] Plugins = Plugins Translations = Resources/translations\") " COMPONENT Runtime) From 55c4c464e4a27d1f216415f2608dd7ba4b28ebfb Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 22 Jun 2014 21:19:10 +0200 Subject: [PATCH 21/36] OSX: get translation path from qt.conf instead of hardcoding it --- cockatrice/src/main.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index 0ac4042a..e6d16c34 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -99,11 +99,7 @@ int main(int argc, char *argv[]) if (translationPath.isEmpty()) { #ifdef Q_OS_MAC - QDir translationsDir = app.applicationDirPath(); - translationsDir.cd(".."); - translationsDir.cd("Resources"); - translationsDir.cd("translations"); - translationPath = translationsDir.absolutePath(); + translationPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); #elif Q_OS_WIN translationPath = app.applicationDirPath() + "/translations"; #endif From 0b4701c42fe21cbec6366190985e619297516954 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 22 Jun 2014 23:21:29 +0200 Subject: [PATCH 22/36] OSX: Handle zonebg for first time installations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If none of the gameboard images is set and and the user’s data directory doesn’t contain a “zonebg” directory, create the directory, copy contents from cockatrice’s app bundle and sets the config accordingly. --- cockatrice/CMakeLists.txt | 3 ++- cockatrice/src/main.cpp | 23 +++++++++++++++++++++++ cockatrice/src/settingscache.cpp | 26 ++++++++++++++++++++++++++ cockatrice/src/settingscache.h | 1 + 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 170721b4..8cfca257 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -202,7 +202,8 @@ if(APPLE) install(CODE " file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] Plugins = Plugins -Translations = Resources/translations\") +Translations = Resources/translations +Data = Resources\") " COMPONENT Runtime) install(CODE " diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index e6d16c34..130fea52 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -133,6 +133,29 @@ int main(int argc, char *argv[]) QDir().mkpath(dataDir + "/pics"); settingsCache->setPicsPath(dataDir + "/pics"); } + +#ifdef Q_OS_MAC + if(settingsCache->getHandBgPath().isEmpty() && + settingsCache->getStackBgPath().isEmpty() && + settingsCache->getTableBgPath().isEmpty() && + settingsCache->getPlayerBgPath().isEmpty()) + { + QString srcDir = QLibraryInfo::location(QLibraryInfo::DataPath); + QString destDir = dataDir + "/zonebg"; + QDir tmpDir(destDir); + if(!tmpDir.exists()) + { + // try to install the default images for the current user and set the settigs value + settingsCache->copyPath(srcDir + "/zonebg", destDir); + + settingsCache->setHandBgPath(destDir + "/fabric_green.png"); + settingsCache->setStackBgPath(destDir + "/fabric_red.png"); + settingsCache->setTableBgPath(destDir + "/fabric_blue.png"); + settingsCache->setPlayerBgPath(destDir + "/fabric_gray.png"); + } + } +#endif + if (!settingsValid() || db->getLoadStatus() != Ok) { qDebug("main(): invalid settings or load status"); DlgSettings dlgSettings; diff --git a/cockatrice/src/settingscache.cpp b/cockatrice/src/settingscache.cpp index ac5c130f..ee4fc635 100644 --- a/cockatrice/src/settingscache.cpp +++ b/cockatrice/src/settingscache.cpp @@ -1,5 +1,6 @@ #include "settingscache.h" #include +#include SettingsCache::SettingsCache() { @@ -256,3 +257,28 @@ void SettingsCache::setMainWindowGeometry(const QByteArray &_mainWindowGeometry) mainWindowGeometry = _mainWindowGeometry; settings->setValue("interface/main_window_geometry", mainWindowGeometry); } + +void SettingsCache::copyPath(const QString &src, const QString &dst) +{ + // test source && return if inexistent + QDir dir(src); + if (! dir.exists()) + return; + // test destination && create if inexistent + QDir tmpDir(dst); + if (!tmpDir.exists()) + { + tmpDir.setPath(QDir::rootPath()); + tmpDir.mkdir(dst); + } + + foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { + QString dst_path = dst + QDir::separator() + d; + dir.mkpath(dst_path); + copyPath(src+ QDir::separator() + d, dst_path); + } + + foreach (QString f, dir.entryList(QDir::Files)) { + QFile::copy(src + QDir::separator() + f, dst + QDir::separator() + f); + } +} diff --git a/cockatrice/src/settingscache.h b/cockatrice/src/settingscache.h index 5156772d..5ae11c9e 100644 --- a/cockatrice/src/settingscache.h +++ b/cockatrice/src/settingscache.h @@ -89,6 +89,7 @@ public: bool getIgnoreUnregisteredUsers() const { return ignoreUnregisteredUsers; } QString getPicUrl() const { return picUrl; } QString getPicUrlHq() const { return picUrlHq; } + void copyPath(const QString &src, const QString &dst); public slots: void setMainWindowGeometry(const QByteArray &_mainWindowGeometry); void setLang(const QString &_lang); From d06d64537e38365a4ee1f1786daa261b3e26f517 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 22 Jun 2014 23:24:44 +0200 Subject: [PATCH 23/36] Zonebg: avoid installing the CMakeLists.txt file --- zonebg/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zonebg/CMakeLists.txt b/zonebg/CMakeLists.txt index e2904502..b250a44b 100644 --- a/zonebg/CMakeLists.txt +++ b/zonebg/CMakeLists.txt @@ -2,7 +2,7 @@ # # Installs default "zone background" files -FILE(GLOB zonebg "${CMAKE_CURRENT_SOURCE_DIR}/*.*") +FILE(GLOB zonebg "${CMAKE_CURRENT_SOURCE_DIR}/*.png" "${CMAKE_CURRENT_SOURCE_DIR}/*.jpg") if(UNIX) if(APPLE) From 66c87a1ee62add27f4a967ed3150bfe5068d012f Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 22 Jun 2014 23:29:42 +0200 Subject: [PATCH 24/36] OSX: Handle sounds for first time installations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the sounds path is unset in the settings and a “sounds” directory doesn’t exists in the user’s data directory, install the sounds files and set the settings value accordingly --- cockatrice/src/main.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index 130fea52..370c1b1a 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -154,6 +154,20 @@ int main(int argc, char *argv[]) settingsCache->setPlayerBgPath(destDir + "/fabric_gray.png"); } } + + if(settingsCache->getSoundPath().isEmpty()) + { + QString srcDir = QLibraryInfo::location(QLibraryInfo::DataPath); + QString destDir = dataDir + "/sounds"; + QDir tmpDir(destDir); + if(!tmpDir.exists()) + { + // try to install the default sounds for the current user and set the settigs value + settingsCache->copyPath(srcDir + "/sounds", destDir); + + settingsCache->setSoundPath(destDir); + } + } #endif if (!settingsValid() || db->getLoadStatus() != Ok) { From c54f7b9245bf86c4961517dea6b0c75dafa77ede Mon Sep 17 00:00:00 2001 From: Daenyth Date: Sun, 22 Jun 2014 20:14:22 -0400 Subject: [PATCH 25/36] Log on failed path copy --- cockatrice/src/settingscache.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/settingscache.cpp b/cockatrice/src/settingscache.cpp index ee4fc635..ccd65845 100644 --- a/cockatrice/src/settingscache.cpp +++ b/cockatrice/src/settingscache.cpp @@ -269,7 +269,10 @@ void SettingsCache::copyPath(const QString &src, const QString &dst) if (!tmpDir.exists()) { tmpDir.setPath(QDir::rootPath()); - tmpDir.mkdir(dst); + if (!tmpDir.mkdir(dst) && !tmpDir.exists()) { + // TODO: this is probably not good. + qDebug() << "copyPath(): Failed to create dir: " << dst; + } } foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { From d811fee2f3f168434576abcba6182819894f8109 Mon Sep 17 00:00:00 2001 From: Daenyth Date: Wed, 25 Jun 2014 00:11:55 -0400 Subject: [PATCH 26/36] Include missing qdebug Dunno how I missed that. Fix #128 --- cockatrice/src/settingscache.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cockatrice/src/settingscache.cpp b/cockatrice/src/settingscache.cpp index 13615039..892630f5 100644 --- a/cockatrice/src/settingscache.cpp +++ b/cockatrice/src/settingscache.cpp @@ -1,5 +1,6 @@ #include "settingscache.h" #include +#include #include SettingsCache::SettingsCache() From 0b8782149730e70f14ed66d7ac3122960c39b530 Mon Sep 17 00:00:00 2001 From: Daenyth Date: Wed, 25 Jun 2014 00:58:58 -0400 Subject: [PATCH 27/36] Add rough draft for .travis.yml --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..3dfa5f1b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: cpp +compiler: + - gcc + - clang +script: mkdir build && cd build && cmake .. && make From 0dd4661b7ca460fe0448535b691493449d968b89 Mon Sep 17 00:00:00 2001 From: Daenyth Date: Wed, 25 Jun 2014 01:14:43 -0400 Subject: [PATCH 28/36] Add travis build icon to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 957a0249..ca8796b4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Cockatrice +[![Build Status](https://travis-ci.org/Daenyth/Cockatrice.svg?branch=master)](https://travis-ci.org/Daenyth/Cockatrice) + Cockatrice is an open-source multiplatform software for playing card games, such as Magic: The Gathering, over a network. It is fully client-server based to prevent any kind of cheating, though it supports single-player games without From 478c7f234fd6180a8469726ea0b7c6a4d4b49b97 Mon Sep 17 00:00:00 2001 From: Daenyth Date: Wed, 25 Jun 2014 01:17:12 -0400 Subject: [PATCH 29/36] Set up dependencies for travis --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3dfa5f1b..65f86165 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,3 +3,6 @@ compiler: - gcc - clang script: mkdir build && cd build && cmake .. && make +before_install: + - sudo apt-get update -qq + - sudo apt-get install -y qtmobility-dev libprotobuf-dev protobuf-compiler From ba1fc86f29d8c1e3babb48994871c45679f4904d Mon Sep 17 00:00:00 2001 From: Daenyth Date: Wed, 25 Jun 2014 01:18:52 -0400 Subject: [PATCH 30/36] Install qt dep for travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 65f86165..0475769d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,4 +5,4 @@ compiler: script: mkdir build && cd build && cmake .. && make before_install: - sudo apt-get update -qq - - sudo apt-get install -y qtmobility-dev libprotobuf-dev protobuf-compiler + - sudo apt-get install -y qtmobility-dev libprotobuf-dev protobuf-compiler libqt4-dev From 44445704e74ee146881235688732f24ba9796a05 Mon Sep 17 00:00:00 2001 From: Daenyth Date: Wed, 25 Jun 2014 01:21:24 -0400 Subject: [PATCH 31/36] Install qt-multimedia-dev for travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0475769d..4affbd71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,4 +5,4 @@ compiler: script: mkdir build && cd build && cmake .. && make before_install: - sudo apt-get update -qq - - sudo apt-get install -y qtmobility-dev libprotobuf-dev protobuf-compiler libqt4-dev + - sudo apt-get install -y qtmobility-dev libprotobuf-dev protobuf-compiler libqt4-dev qtmultimedia-dev From 8a331e30c67e8a5ec63abbb9ca0a746427e011a3 Mon Sep 17 00:00:00 2001 From: Daenyth Date: Wed, 25 Jun 2014 01:24:14 -0400 Subject: [PATCH 32/36] Don't install qtmultimedia - not needed --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4affbd71..0475769d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,4 +5,4 @@ compiler: script: mkdir build && cd build && cmake .. && make before_install: - sudo apt-get update -qq - - sudo apt-get install -y qtmobility-dev libprotobuf-dev protobuf-compiler libqt4-dev qtmultimedia-dev + - sudo apt-get install -y qtmobility-dev libprotobuf-dev protobuf-compiler libqt4-dev From 5ea59908a8b0ccf7562dffca3bee391904b8481d Mon Sep 17 00:00:00 2001 From: Daenyth Date: Wed, 25 Jun 2014 01:29:06 -0400 Subject: [PATCH 33/36] Cache apt for travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 0475769d..378c7e48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,3 +6,4 @@ script: mkdir build && cd build && cmake .. && make before_install: - sudo apt-get update -qq - sudo apt-get install -y qtmobility-dev libprotobuf-dev protobuf-compiler libqt4-dev +cache: apt From 0eb00fe39caf6054a7c2f11e61eb3e143d91f4f4 Mon Sep 17 00:00:00 2001 From: Daenyth Date: Wed, 25 Jun 2014 01:31:43 -0400 Subject: [PATCH 34/36] Add build-essential to travis cfg This can't be causing the failure can it? It can't find QtMultimedia.. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 378c7e48..07f05b95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,5 +5,5 @@ compiler: script: mkdir build && cd build && cmake .. && make before_install: - sudo apt-get update -qq - - sudo apt-get install -y qtmobility-dev libprotobuf-dev protobuf-compiler libqt4-dev + - sudo apt-get install -y qtmobility-dev libprotobuf-dev protobuf-compiler libqt4-dev build-essential cache: apt From 1c9540befab7523b4941c5b8b9e60e6ab7bf957f Mon Sep 17 00:00:00 2001 From: Daenyth Date: Wed, 25 Jun 2014 01:48:30 -0400 Subject: [PATCH 35/36] Set cmake module path to local for findqtmobility --- cockatrice/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 8cfca257..b4de656a 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -126,6 +126,7 @@ if(APPLE) ENDIF(APPLE) if (NOT QT_QTMULTIMEDIA_FOUND) + SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) FIND_PACKAGE(QtMobility REQUIRED) endif (NOT QT_QTMULTIMEDIA_FOUND) From aee86ce45a4d30fcca4d4d1879b67bd46eacce9e Mon Sep 17 00:00:00 2001 From: Daenyth Date: Wed, 25 Jun 2014 01:53:19 -0400 Subject: [PATCH 36/36] Mark QGraphicsItem for AbstractGraphicsItem --- cockatrice/src/abstractgraphicsitem.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cockatrice/src/abstractgraphicsitem.h b/cockatrice/src/abstractgraphicsitem.h index 83cbf0db..f838dcd3 100644 --- a/cockatrice/src/abstractgraphicsitem.h +++ b/cockatrice/src/abstractgraphicsitem.h @@ -14,6 +14,7 @@ enum GraphicsItemType { class AbstractGraphicsItem : public QObject, public QGraphicsItem { Q_OBJECT + Q_INTERFACES(QGraphicsItem) protected: void paintNumberEllipse(int number, int radius, const QColor &color, int position, int count, QPainter *painter); public: