[aseprite] 257/308: Add initial support to Steam API (just inform to Steam that we're running)
Tobias Hansen
thansen at moszumanska.debian.org
Tue Mar 8 02:45:17 UTC 2016
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit 5dd2d8119b961ae78c1a6fd0d00bd661d7c2b089
Author: David Capello <davidcapello at gmail.com>
Date: Wed Feb 24 13:21:37 2016 -0300
Add initial support to Steam API (just inform to Steam that we're running)
---
CMakeLists.txt | 1 +
src/CMakeLists.txt | 4 +++
src/app/CMakeLists.txt | 5 +++
src/app/app.cpp | 8 +++++
src/steam/CMakeLists.txt | 5 +++
src/steam/LICENSE.txt | 20 ++++++++++++
src/steam/README.md | 9 ++++++
src/steam/steam.cpp | 79 ++++++++++++++++++++++++++++++++++++++++++++++++
src/steam/steam.h | 25 +++++++++++++++
9 files changed, 156 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e561c52..5eeea21 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3c03912..b7e6d43 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -116,6 +116,10 @@ if(ENABLE_WEBSERVER)
add_subdirectory(webserver)
endif()
+if(ENABLE_STEAM)
+ add_subdirectory(steam)
+endif()
+
add_subdirectory(app)
######################################################################
diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt
index cbbed1f..bb99fb6 100644
--- a/src/app/CMakeLists.txt
+++ b/src/app/CMakeLists.txt
@@ -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()
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 22c67ab..b729889 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -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(
diff --git a/src/steam/CMakeLists.txt b/src/steam/CMakeLists.txt
new file mode 100644
index 0000000..f51ff67
--- /dev/null
+++ b/src/steam/CMakeLists.txt
@@ -0,0 +1,5 @@
+# Aseprite
+# Copyright (C) 2016 David Capello
+
+add_library(steam-lib steam.cpp)
+target_link_libraries(steam-lib base-lib)
diff --git a/src/steam/LICENSE.txt b/src/steam/LICENSE.txt
new file mode 100644
index 0000000..9a182c0
--- /dev/null
+++ b/src/steam/LICENSE.txt
@@ -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.
diff --git a/src/steam/README.md b/src/steam/README.md
new file mode 100644
index 0000000..0abdf98
--- /dev/null
+++ b/src/steam/README.md
@@ -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).
diff --git a/src/steam/steam.cpp b/src/steam/steam.cpp
new file mode 100644
index 0000000..89ebd15
--- /dev/null
+++ b/src/steam/steam.cpp
@@ -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
diff --git a/src/steam/steam.h b/src/steam/steam.h
new file mode 100644
index 0000000..907eee5
--- /dev/null
+++ b/src/steam/steam.h
@@ -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
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list