mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Add initial support to Steam API (just inform to Steam that we're running)
This commit is contained in:
parent
d2f1e2b6d2
commit
5dd2d8119b
@ -54,6 +54,7 @@ option(ENABLE_MEMLEAK "Enable memory-leaks detector (only for developers)" o
|
||||
option(ENABLE_UPDATER "Enable automatic check for updates" on)
|
||||
option(ENABLE_WEBSERVER "Enable support to run a webserver (for HTML5 gamedev)" off)
|
||||
option(ENABLE_TRIAL_MODE "Compile the trial version" off)
|
||||
option(ENABLE_STEAM "Compile with Steam library" off)
|
||||
option(FULLSCREEN_PLATFORM "Enable fullscreen by default" off)
|
||||
set(CUSTOM_WEBSITE_URL "" CACHE STRING "Enable custom local webserver to check updates")
|
||||
|
||||
|
@ -116,6 +116,10 @@ if(ENABLE_WEBSERVER)
|
||||
add_subdirectory(webserver)
|
||||
endif()
|
||||
|
||||
if(ENABLE_STEAM)
|
||||
add_subdirectory(steam)
|
||||
endif()
|
||||
|
||||
add_subdirectory(app)
|
||||
|
||||
######################################################################
|
||||
|
@ -454,3 +454,8 @@ endif()
|
||||
if(ENABLE_WEBSERVER)
|
||||
target_link_libraries(app-lib webserver-lib)
|
||||
endif()
|
||||
|
||||
if(ENABLE_STEAM)
|
||||
add_definitions(-DENABLE_STEAM)
|
||||
target_link_libraries(app-lib steam-lib)
|
||||
endif()
|
||||
|
@ -76,6 +76,10 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#ifdef ENABLE_STEAM
|
||||
#include "steam/steam.h"
|
||||
#endif
|
||||
|
||||
namespace app {
|
||||
|
||||
using namespace ui;
|
||||
@ -600,6 +604,10 @@ void App::run()
|
||||
{
|
||||
// Run the GUI
|
||||
if (isGui()) {
|
||||
#ifdef ENABLE_STEAM
|
||||
steam::SteamAPI steam;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_UPDATER
|
||||
// Launch the thread to check for updates.
|
||||
app::CheckUpdateThreadLauncher checkUpdate(
|
||||
|
5
src/steam/CMakeLists.txt
Normal file
5
src/steam/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
# Aseprite
|
||||
# Copyright (C) 2016 David Capello
|
||||
|
||||
add_library(steam-lib steam.cpp)
|
||||
target_link_libraries(steam-lib base-lib)
|
20
src/steam/LICENSE.txt
Normal file
20
src/steam/LICENSE.txt
Normal file
@ -0,0 +1,20 @@
|
||||
Copyright (c) 2016 David Capello
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
9
src/steam/README.md
Normal file
9
src/steam/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Aseprite Steam Wrapper
|
||||
*Copyright (C) 2016 David Capello*
|
||||
|
||||
> Distributed under [MIT license](LICENSE.txt)
|
||||
|
||||
This is a way to use the Steam API without linking to the static
|
||||
`.lib`, so we can avoid including the official `steam_api.dll` in our
|
||||
own packages (e.g. when we distribute our game outside the Steam
|
||||
store).
|
79
src/steam/steam.cpp
Normal file
79
src/steam/steam.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
// Aseprite Steam Wrapper
|
||||
// Copyright (c) 2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "steam/steam.h"
|
||||
|
||||
#include "base/dll.h"
|
||||
#include "base/string.h"
|
||||
|
||||
namespace steam {
|
||||
|
||||
typedef bool (*SteamAPI_Init_Func)();
|
||||
typedef void (*SteamAPI_Shutdown_Func)();
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _WIN64
|
||||
#define STEAM_API_DLL_FILENAME "steam_api64.dll"
|
||||
#else
|
||||
#define STEAM_API_DLL_FILENAME "steam_api.dll"
|
||||
#endif
|
||||
#elif defined(__APPLE__)
|
||||
#define STEAM_API_DLL_FILENAME "libsteam_api.dylib"
|
||||
#else
|
||||
#define STEAM_API_DLL_FILENAME "libsteam_api.so"
|
||||
#endif
|
||||
|
||||
class SteamAPI::Impl {
|
||||
public:
|
||||
Impl() {
|
||||
m_steamLib = base::load_dll(STEAM_API_DLL_FILENAME);
|
||||
if (!m_steamLib)
|
||||
return;
|
||||
|
||||
auto SteamAPI_Init = base::get_dll_proc<SteamAPI_Init_Func>(m_steamLib, "SteamAPI_Init");
|
||||
if (!SteamAPI_Init)
|
||||
return;
|
||||
|
||||
if (!SteamAPI_Init()) {
|
||||
LOG("Steam is not initialized...\n");
|
||||
return;
|
||||
}
|
||||
|
||||
LOG("Steam initialized...\n");
|
||||
}
|
||||
|
||||
~Impl() {
|
||||
if (!m_steamLib)
|
||||
return;
|
||||
|
||||
auto SteamAPI_Shutdown = base::get_dll_proc<SteamAPI_Shutdown_Func>(m_steamLib, "SteamAPI_Shutdown");
|
||||
if (SteamAPI_Shutdown) {
|
||||
LOG("Steam shutdown...\n");
|
||||
SteamAPI_Shutdown();
|
||||
}
|
||||
|
||||
base::unload_dll(m_steamLib);
|
||||
}
|
||||
|
||||
private:
|
||||
base::dll m_steamLib;
|
||||
};
|
||||
|
||||
SteamAPI::SteamAPI()
|
||||
: m_impl(new Impl)
|
||||
{
|
||||
}
|
||||
|
||||
SteamAPI::~SteamAPI()
|
||||
{
|
||||
delete m_impl;
|
||||
}
|
||||
|
||||
} // namespace steam
|
25
src/steam/steam.h
Normal file
25
src/steam/steam.h
Normal file
@ -0,0 +1,25 @@
|
||||
// Aseprite Steam Wrapper
|
||||
// Copyright (c) 2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
||||
#ifndef STEAM_STEAM_H_INCLUDED
|
||||
#define STEAM_STEAM_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
namespace steam {
|
||||
|
||||
class SteamAPI {
|
||||
public:
|
||||
SteamAPI();
|
||||
~SteamAPI();
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
Impl* m_impl;
|
||||
};
|
||||
|
||||
} // namespace steam
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user