Prepares for steamworks api integration
This commit is contained in:
parent
c23927c4fa
commit
9ae383b34e
|
@ -6,5 +6,7 @@
|
||||||
/data.pack
|
/data.pack
|
||||||
/.vs/
|
/.vs/
|
||||||
/.data.db
|
/.data.db
|
||||||
|
/steamworks_c_wrapper/_build
|
||||||
|
/steamworks_c_wrapper/sdk
|
||||||
*.swp
|
*.swp
|
||||||
*~
|
*~
|
||||||
|
|
|
@ -25,6 +25,14 @@ configure_file(
|
||||||
"${PROJECT_BINARY_DIR}/config.h"
|
"${PROJECT_BINARY_DIR}/config.h"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (EXISTS "${PROJECT_SOURCE_DIR}/steamworks_c_wrapper/sdk")
|
||||||
|
set(STEAM 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (STEAM)
|
||||||
|
add_subdirectory(steamworks_c_wrapper)
|
||||||
|
endif()
|
||||||
|
|
||||||
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
|
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
|
||||||
set(CLANG 1)
|
set(CLANG 1)
|
||||||
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
|
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
|
||||||
|
@ -123,6 +131,9 @@ if (NOT MSVC)
|
||||||
endif (NOT MSVC)
|
endif (NOT MSVC)
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
|
||||||
|
if (STEAM)
|
||||||
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSTEAM_BUILD")
|
||||||
|
endif ()
|
||||||
if (NOT MSVC)
|
if (NOT MSVC)
|
||||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D__FNAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D__FNAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
|
||||||
else (NOT MSVC)
|
else (NOT MSVC)
|
||||||
|
@ -195,6 +206,12 @@ target_link_libraries(breakhack
|
||||||
${SDL2_MIXER_LIBRARY}
|
${SDL2_MIXER_LIBRARY}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (STEAM)
|
||||||
|
target_link_libraries(breakhack
|
||||||
|
steamworks_c_wrapper
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
if (NOT PHYSFS_FOUND)
|
if (NOT PHYSFS_FOUND)
|
||||||
target_link_libraries(breakhack
|
target_link_libraries(breakhack
|
||||||
physfs-static
|
physfs-static
|
||||||
|
@ -301,6 +318,12 @@ if (WIN32)
|
||||||
${CMAKE_SOURCE_DIR}/bin/SDL2_ttf.dll
|
${CMAKE_SOURCE_DIR}/bin/SDL2_ttf.dll
|
||||||
${CMAKE_SOURCE_DIR}/bin/zlib1.dll
|
${CMAKE_SOURCE_DIR}/bin/zlib1.dll
|
||||||
)
|
)
|
||||||
|
if (STEAM)
|
||||||
|
SET(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS
|
||||||
|
${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
|
||||||
|
${STEAMWORKS_LIBRARY}
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
endif (WIN32)
|
endif (WIN32)
|
||||||
include(InstallRequiredSystemLibraries)
|
include(InstallRequiredSystemLibraries)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* BreakHack - A dungeone crawler RPG
|
||||||
|
* Copyright (C) 2018 Linus Probert <linus.probert@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <steam_api.h>
|
||||||
|
#include "steamworks_api_wrapper.h"
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* BreakHack - A dungeone crawler RPG
|
||||||
|
* Copyright (C) 2018 Linus Probert <linus.probert@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
cmake_minimum_required(VERSION 3.1)
|
||||||
|
project(steamworks_c_wrapper)
|
||||||
|
|
||||||
|
if (NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
include(cmake/FindSTEAMWORKS.cmake)
|
||||||
|
|
||||||
|
if (BIT_32)
|
||||||
|
MESSAGE("COMPILING 32 BIT")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -m32")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_DEBUG} -m32")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set (Windows 0)
|
||||||
|
set (Apple 0)
|
||||||
|
if (WIN32)
|
||||||
|
set(Windows 1)
|
||||||
|
elseif (APPLE)
|
||||||
|
set(Apple 1)
|
||||||
|
else()
|
||||||
|
#Linux
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
include_directories(${STEAMWORKS_INCLUDE_DIR})
|
||||||
|
|
||||||
|
add_library(steamworks_c_wrapper
|
||||||
|
src/steamworks_c_wrapper
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(steamworks_c_wrapper ${STEAMWORKS_LIBRARY})
|
|
@ -0,0 +1,32 @@
|
||||||
|
# - Try to find the steamworks library
|
||||||
|
#
|
||||||
|
# Once done, this will define:
|
||||||
|
#
|
||||||
|
# STEAMWORKS_INCLUDE_DIR - the Steamworks include directory
|
||||||
|
# STEAMWORKS_LIBRARIES - The libraries needed to use Steamworks
|
||||||
|
|
||||||
|
find_path(STEAMWORKS_INCLUDE_DIR
|
||||||
|
NAMES
|
||||||
|
steam_api.h
|
||||||
|
PATHS
|
||||||
|
${PROJECT_SOURCE_DIR}/sdk/public/steam/
|
||||||
|
)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
find_library(STEAMWORKS_LIBRARY
|
||||||
|
NAMES
|
||||||
|
steam_api
|
||||||
|
PATHS
|
||||||
|
${PROJECT_SOURCE_DIR}/sdk/redistributable_bin/
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
find_library(STEAMWORKS_LIBRARY
|
||||||
|
NAMES
|
||||||
|
steam_api
|
||||||
|
PATHS
|
||||||
|
${PROJECT_SOURCE_DIR}/sdk/redistributable_bin/linux64/
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(STEAMWORKS DEFAULT_MSG STEAMWORKS_INCLUDE_DIR STEAMWORKS_LIBRARY)
|
|
@ -0,0 +1,25 @@
|
||||||
|
#include <steam_api.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "steamworks_c_wrapper.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void c_SteamAPI_Init()
|
||||||
|
{
|
||||||
|
SteamAPI_Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void c_SteamAPI_Shutdown()
|
||||||
|
{
|
||||||
|
SteamAPI_Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" bool c_SteamUserStats_RequestCurrentStats()
|
||||||
|
{
|
||||||
|
return SteamUserStats()->RequestCurrentStats();
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" bool c_SteamUserStats_SetAchievement(const char *pchName)
|
||||||
|
{
|
||||||
|
return SteamUserStats()->SetAchievement(pchName);
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
enum Achievements
|
||||||
|
{
|
||||||
|
ACH_BAD_DOG = 0,
|
||||||
|
ACH_THE_DOCTOR_IS_OUT = 1,
|
||||||
|
ACH_LIGHTS_ON = 2,
|
||||||
|
ACH_BACK_TO_WORK = 5,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Achievement
|
||||||
|
{
|
||||||
|
Achievements m_eAchievementID;
|
||||||
|
const char *m_pchAchievementID;
|
||||||
|
char m_rgchName[128];
|
||||||
|
char m_rgchDescription[256];
|
||||||
|
bool m_bAchieved;
|
||||||
|
int m_iIconImage;
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
c_SteamAPI_Init();
|
||||||
|
|
||||||
|
bool
|
||||||
|
c_steam_request_stats();
|
||||||
|
|
||||||
|
bool
|
||||||
|
c_steam_set_achievement(const char *id);
|
||||||
|
|
||||||
|
void
|
||||||
|
c_SteamAPI_Shutdown();
|
Loading…
Reference in New Issue