1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00

Merge branch 'master' into wip/landscape

This commit is contained in:
Mathieu Schroeter 2017-10-21 10:52:54 +02:00
commit 56af742d0a
10 changed files with 68 additions and 31 deletions

View File

@ -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}")

View File

@ -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;

View File

@ -30,7 +30,9 @@
#include <SDL2/SDL_image.h>
#include <argagg/argagg.hpp>
#ifdef USE_CURL
#include <curl/curl.h>
#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 <typename Out>
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

View File

@ -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;
}

View File

@ -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
{

View File

@ -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))
{

View File

@ -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;

View File

@ -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;

View File

@ -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 (

View File

@ -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;
}