diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a0a456..697fe7b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,11 @@ set (PB_VERSION_PATCH 0) set (PB_VERSION_EXTRA "") set (PB_PRODUCT_NAME "Planet Blupi") set (PB_PACKAGE_NAME "planetblupi") -set (PB_DESCRIPTION "Planet Blupi - A delerious spell-binding game") +set (PB_EXEC "planetblupi") +set (PB_ICON_REF "blupi") +set (PB_DESCRIPTION "Planet Blupi - A delirious spell-binding game") + +option (PB_HTTP_VERSION_CHECK "Run a version check over HTTP (with CURL)" OFF) configure_file ( "${PROJECT_SOURCE_DIR}/src/config.h.in" @@ -32,6 +36,14 @@ if (APPIMAGE_APPRUN_PROGRAM AND APPIMAGE_ASSISTANT_PROGRAM) set (USE_APPIMAGE ON) endif () +if (NOT USE_APPIMAGE) + configure_file ( + "${PROJECT_SOURCE_DIR}/resources/linux/application.desktop.in" + "${CMAKE_CURRENT_BINARY_DIR}/${PB_PACKAGE_NAME}.desktop" + @ONLY + ) +endif () + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -L${CMAKE_INSTALL_PREFIX}/lib") endif () @@ -115,7 +127,10 @@ find_package (PkgConfig REQUIRED) pkg_search_module (SDL2 REQUIRED sdl2) pkg_search_module (SDL2_MIXER REQUIRED SDL2_mixer) pkg_search_module (SDL2_IMAGE REQUIRED SDL2_image) -pkg_search_module (CURL REQUIRED libcurl) +if (${PB_HTTP_VERSION_CHECK}) + pkg_search_module (CURL REQUIRED libcurl) + add_definitions (-DUSE_CURL) +endif () if ("${STATIC_BUILD}") pkg_search_module (PNG REQUIRED libpng) @@ -131,7 +146,9 @@ if ("${STATIC_BUILD}") pkg_search_module (PULSE REQUIRED libpulse) endif () - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCURL_STATICLIB") + if (${PB_HTTP_VERSION_CHECK}) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCURL_STATICLIB") + endif () endif () ########################### @@ -147,7 +164,6 @@ if ("${STATIC_BUILD}") ${SDL2_STATIC_LIBRARIES} ${SDL2_MIXER_STATIC_LIBRARIES} ${SDL2_IMAGE_STATIC_LIBRARIES} - ${CURL_STATIC_LIBRARIES} ${SDLKitchensink_STATIC_LIBRARIES} ${PNG_STATIC_LIBRARIES} ${AVCODEC_STATIC_LIBRARIES} @@ -157,6 +173,12 @@ if ("${STATIC_BUILD}") ${SWRESAMPLE_STATIC_LIBRARIES} ) + if (${PB_HTTP_VERSION_CHECK}) + list (APPEND planetblupi_DEPS + ${CURL_STATIC_LIBRARIES} + ) + endif () + if (UNIX AND NOT APPLE) list (APPEND planetblupi_DEPS ${ALSA_STATIC_LIBRARIES} @@ -173,6 +195,12 @@ else () ${SDLKitchensink_LIBRARIES} pthread ) + + if (${PB_HTTP_VERSION_CHECK}) + list (APPEND planetblupi_DEPS + ${CURL_LIBRARIES} + ) + endif () endif () target_link_libraries (planetblupi PUBLIC ${planetblupi_DEPS}) @@ -243,6 +271,13 @@ if (UNIX AND NOT APPLE) install (DIRECTORY resources/icon/hicolor DESTINATION share/icons) endif () +if (NOT USE_APPIMAGE) + install ( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${PB_PACKAGE_NAME}.desktop + DESTINATION share/applications + ) +endif () + # Copy libwinpthread-1.dll which seems not be linkable statically if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows" AND MINGW) execute_process (COMMAND cygpath.exe --windows /mingw64 OUTPUT_VARIABLE MINGW64_PATH) @@ -270,7 +305,7 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND "${STATIC_BUILD}") if (USE_APPIMAGE) include (LinuxAppImageBuild) set (CMAKE_PACKAGED_OUTPUT_PREFIX ${CMAKE_INSTALL_PREFIX}) - APPIMAGE_PACKAGE (planetblupi ${PB_PACKAGE_NAME} ${PB_PRODUCT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/resources/linux" "${CMAKE_BINARY_DIR}/share" "" "" "blupi") + APPIMAGE_PACKAGE (planetblupi ${PB_PACKAGE_NAME} ${PB_PRODUCT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/resources/linux" "${CMAKE_BINARY_DIR}/share" "" "" ${PB_ICON_REF}) elseif (MINGW) set (INSTALLER_FILE_NAME "${PB_PACKAGE_NAME}-${PB_VERSION_MAJOR}.${PB_VERSION_MINOR}.${PB_VERSION_PATCH}${PB_VERSION_EXTRA}") set (CPACK_PACKAGE_FILE_NAME "${INSTALLER_FILE_NAME}") diff --git a/resources/linux/application.desktop.in b/resources/linux/application.desktop.in index 038b99c..cda0397 100644 --- a/resources/linux/application.desktop.in +++ b/resources/linux/application.desktop.in @@ -3,8 +3,8 @@ Version=1.0 Type=Application Name=@PB_PRODUCT_NAME@ GenericName=Video Game -Comment=@CPACK_PACKAGE_DESCRIPTION_SUMMARY@ -Exec=@APPIMAGE_EXEC@ -StartupWMClass=@APPIMAGE_EXEC_WM@ +Comment=@PB_DESCRIPTION@ +Exec=@PB_EXEC@ +StartupWMClass=@PB_EXEC@ Icon=@APPIMAGE_ICON_REF@ -Categories=Game; +Categories=Game;StrategyGame; diff --git a/src/blupi.cxx b/src/blupi.cxx index bcf87e8..a93f2bf 100644 --- a/src/blupi.cxx +++ b/src/blupi.cxx @@ -30,7 +30,9 @@ #include #include +#ifdef USE_CURL #include +#endif /* USE_CURL */ #include "json/json.hpp" @@ -81,11 +83,13 @@ bool g_bTermInit = false; // initialisation en cours Uint32 g_lastPhase = 999; static bool g_pause; +#ifdef USE_CURL struct url_data { CURLcode status; char * buffer; size_t size; }; +#endif template static void @@ -458,6 +462,7 @@ InitFail (const char * msg) FinishObjects (); } +#ifdef USE_CURL static size_t updateCallback (void * ptr, size_t size, size_t nmemb, void * data) { @@ -475,10 +480,12 @@ updateCallback (void * ptr, size_t size, size_t nmemb, void * data) return realsize; } +#endif /* USE_CURL */ static void CheckForUpdates () { +#ifdef USE_CURL url_data chunk; chunk.buffer = nullptr; /* we expect realloc(NULL, size) to work */ @@ -515,6 +522,7 @@ CheckForUpdates () free (chunk.buffer); curl_easy_cleanup (curl); +#endif /* USE_CURL */ } static int diff --git a/src/button.cxx b/src/button.cxx index 1ae2e48..7247a63 100644 --- a/src/button.cxx +++ b/src/button.cxx @@ -155,7 +155,7 @@ CButton::Draw () rect.right = m_pos.x + m_dim.x; rect.top = m_pos.y; rect.bottom = m_pos.y + m_dim.y; - m_pPixmap->DrawPart (-1, CHBACK, m_pos, rect, 1); // dessine le fond + m_pPixmap->DrawPart (-1, CHBACK, m_pos, rect); // dessine le fond return; } diff --git a/src/decor.cxx b/src/decor.cxx index 106451d..2770f4d 100644 --- a/src/decor.cxx +++ b/src/decor.cxx @@ -684,7 +684,7 @@ CDecor::BuildMoveFloor (Sint32 x, Sint32 y, Point pos, Sint32 rank) m_move[rank].maskChannel, icon, m_move[rank].channel, m_move[rank].icon, 0); - m_pPixmap->DrawIcon (-1, m_move[rank].channel, 0, pos, true); + m_pPixmap->DrawIcon (-1, m_move[rank].channel, 0, pos); } else { diff --git a/src/decstat.cxx b/src/decstat.cxx index 89fafab..057d916 100644 --- a/src/decstat.cxx +++ b/src/decstat.cxx @@ -693,7 +693,7 @@ CDecor::StatisticDraw () rect.top = pos.y; rect.bottom = pos.y + DIMSTATY; - m_pPixmap->DrawPart (-1, CHBACK, pos, rect, 1); // dessine le fond + m_pPixmap->DrawPart (-1, CHBACK, pos, rect); // dessine le fond if (rank == 0 && m_bStatUp) { @@ -768,7 +768,7 @@ CDecor::StatisticDraw () rect.right = pos.x + POSDRAWX; rect.top = pos.y; rect.bottom = pos.y + 16; - m_pPixmap->DrawPart (-1, CHBACK, pos, rect, 1); // dessine le fond + m_pPixmap->DrawPart (-1, CHBACK, pos, rect); // dessine le fond if (strlen (textRes)) { diff --git a/src/event.cxx b/src/event.cxx index 1cb0c6f..f0dac34 100644 --- a/src/event.cxx +++ b/src/event.cxx @@ -2181,7 +2181,7 @@ CEvent::DrawButtons () rect.right = pos.x + 20; rect.top = pos.y; rect.bottom = pos.y + 15; - m_pPixmap->DrawPart (-1, CHBACK, pos, rect, 1); // dessine le fond + m_pPixmap->DrawPart (-1, CHBACK, pos, rect); // dessine le fond if (m_speed > 1) { snprintf (res, sizeof (res), "x%d", m_speed); @@ -2199,7 +2199,7 @@ CEvent::DrawButtons () rect.right = POSDRAWX + DIMDRAWX; rect.top = 0; rect.bottom = lg; - m_pPixmap->DrawPart (-1, CHBACK, pos, rect, 1); + m_pPixmap->DrawPart (-1, CHBACK, pos, rect); pos.x = POSDRAWX; pos.y = lg; @@ -2207,7 +2207,7 @@ CEvent::DrawButtons () rect.right = POSDRAWX + DIMDRAWX; rect.top = 0; rect.bottom = POSDRAWY; - m_pPixmap->DrawPart (-1, CHBACK, pos, rect, 1); + m_pPixmap->DrawPart (-1, CHBACK, pos, rect); pos.x = POSDRAWX + 20; pos.y = POSDRAWY + 4; diff --git a/src/pixmap.cxx b/src/pixmap.cxx index 803b8d7..349f466 100644 --- a/src/pixmap.cxx +++ b/src/pixmap.cxx @@ -469,8 +469,7 @@ CPixmap::IsIconPixel (size_t channel, Sint32 rank, Point pos) // Les modes sont 0=transparent, 1=opaque. bool -CPixmap::DrawIcon ( - Sint32 chDst, size_t channel, Sint32 rank, Point pos, bool bMask) +CPixmap::DrawIcon (Sint32 chDst, size_t channel, Sint32 rank, Point pos) { Sint32 nbx, nby; Rect rect; @@ -507,8 +506,7 @@ CPixmap::DrawIcon ( // 33,48 35,49 bool -CPixmap::DrawIconDemi ( - Sint32 chDst, size_t channel, Sint32 rank, Point pos, bool bMask) +CPixmap::DrawIconDemi (Sint32 chDst, size_t channel, Sint32 rank, Point pos) { Sint32 nbx, nby; Rect rect; @@ -541,7 +539,7 @@ CPixmap::DrawIconDemi ( bool CPixmap::DrawIconPart ( Sint32 chDst, size_t channel, Sint32 rank, Point pos, Sint32 startY, - Sint32 endY, bool bMask) + Sint32 endY) { Sint32 nbx, nby; Rect rect; @@ -573,8 +571,7 @@ CPixmap::DrawIconPart ( // Dessine une partie d'image n'importe o�. bool -CPixmap::DrawPart ( - Sint32 chDst, size_t channel, Point dest, Rect rect, bool bMask) +CPixmap::DrawPart (Sint32 chDst, size_t channel, Point dest, Rect rect) { if (m_SDLTextureInfo.find (channel) == m_SDLTextureInfo.end ()) return false; diff --git a/src/pixmap.h b/src/pixmap.h index 9a5c369..c066b91 100644 --- a/src/pixmap.h +++ b/src/pixmap.h @@ -72,15 +72,12 @@ public: bool IsIconPixel (size_t channel, Sint32 rank, Point pos); - bool DrawIcon ( - Sint32 chDst, size_t channel, Sint32 rank, Point pos, bool bMask = false); - bool DrawIconDemi ( - Sint32 chDst, size_t channel, Sint32 rank, Point pos, bool bMask = false); + bool DrawIcon (Sint32 chDst, size_t channel, Sint32 rank, Point pos); + bool DrawIconDemi (Sint32 chDst, size_t channel, Sint32 rank, Point pos); bool DrawIconPart ( Sint32 chDst, size_t channel, Sint32 rank, Point pos, Sint32 startY, - Sint32 endY, bool bMask = false); - bool DrawPart ( - Sint32 chDst, size_t channel, Point dest, Rect rect, bool bMask = false); + Sint32 endY); + bool DrawPart (Sint32 chDst, size_t channel, Point dest, Rect rect); bool DrawImage (Sint32 chDst, size_t channel, Rect rect); bool BuildIconMask ( diff --git a/src/progress.cxx b/src/progress.cxx index b464b7d..6b131aa 100644 --- a/src/progress.cxx +++ b/src/progress.cxx @@ -72,7 +72,7 @@ CJauge::Draw () rect.right = m_pos.x + m_dim.x; rect.top = m_pos.y; rect.bottom = m_pos.y + m_dim.y; - m_pPixmap->DrawPart (-1, CHBACK, m_pos, rect, 1); // dessine le fond + m_pPixmap->DrawPart (-1, CHBACK, m_pos, rect); // dessine le fond return; }