Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSoC Midterm Evaluation: Steam Workshop SDK/Third Party Integration #2343

Closed
wants to merge 94 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
abaf735
add Steamworks extension prototypes and SOG tests
k0T0z Apr 2, 2023
7e85d8c
add debugging hook
k0T0z Apr 6, 2023
90ee0b7
setup project structure
May 20, 2023
4411149
setup
May 20, 2023
bdcec06
Merge branch 'enigma-dev:master' into steam-sdk-integration
k0T0z May 27, 2023
cdf2f1b
enhancing initial code (doesn't work)
Jun 5, 2023
3350b13
fixed exceptions wall
Jun 5, 2023
77caed6
fixed deleted file
Jun 5, 2023
f2d96c8
improves provided
Jun 5, 2023
ff7e84a
improved tests
Jun 5, 2023
cc2494c
implemented some of general API user functions, added the testing exa…
Jun 7, 2023
d193016
modifying game example
Jun 8, 2023
01bf091
improved example game to be now ready for testing functions, implemen…
Jun 16, 2023
a249a0e
bug fixes and few improvements
Jun 17, 2023
58cd5e4
adding linux support in Makefile
k0T0z Jun 19, 2023
b5638a5
adding linux support in Makefile
k0T0z Jun 19, 2023
c8aaa0d
Merge branch 'steam-sdk-integration' of https://github.com/k0T0z/enig…
k0T0z Jun 19, 2023
fd2267f
implemented another 2 user functions, fixed ABI issue by moving to li…
k0T0z Jun 20, 2023
723509e
creating architecture instead of a wrapper, clean files, bug fixes
k0T0z Jun 24, 2023
44a5e39
bug fixes
k0T0z Jun 25, 2023
31cfd1d
fixed example game, fixed overlay activated callback, implemented 2 m…
k0T0z Jun 26, 2023
b648f16
calling steam_init() automatically, bug fixes, few improvements
k0T0z Jun 30, 2023
44f9b02
bug fixes
k0T0z Jun 30, 2023
03c2277
implemented 2 user functions in overlay
k0T0z Jul 2, 2023
65ff597
bug fixes
k0T0z Jul 2, 2023
bab0841
overlay API done, fixed example game
k0T0z Jul 2, 2023
f0b8e01
bug fixes, added achievements API
k0T0z Jul 2, 2023
9c727e9
fix naming, update readme
k0T0z Jul 2, 2023
5ad6468
bug fixes
k0T0z Jul 2, 2023
a609e0c
adding dlls, fixing output messages
k0T0z Jul 2, 2023
55c9c87
few improvements
k0T0z Jul 2, 2023
c8934cc
few improvements
k0T0z Jul 3, 2023
e8e3ebd
few improvements
k0T0z Jul 5, 2023
0605d59
started implementing Stats and Achievements API, bug fixes
k0T0z Jul 5, 2023
9be4767
bug fixes
k0T0z Jul 5, 2023
b07a455
add Steamworks extension prototypes and SOG tests
k0T0z Apr 2, 2023
87a94e4
add debugging hook
k0T0z Apr 6, 2023
e7c39f9
setup project structure
May 20, 2023
5576b7e
setup
May 20, 2023
8b9140d
enhancing initial code (doesn't work)
Jun 5, 2023
9b7f8a6
fixed exceptions wall
Jun 5, 2023
b1a1e7f
fixed deleted file
Jun 5, 2023
c9a93e2
improves provided
Jun 5, 2023
b2f4289
improved tests
Jun 5, 2023
53fe0af
implemented some of general API user functions, added the testing exa…
Jun 7, 2023
854c24f
modifying game example
Jun 8, 2023
055662d
improved example game to be now ready for testing functions, implemen…
Jun 16, 2023
a5aeed1
bug fixes and few improvements
Jun 17, 2023
80bca61
adding linux support in Makefile
k0T0z Jun 19, 2023
4fd96e8
implemented another 2 user functions, fixed ABI issue by moving to li…
k0T0z Jun 20, 2023
51e5ab3
creating architecture instead of a wrapper, clean files, bug fixes
k0T0z Jun 24, 2023
ba00ec9
bug fixes
k0T0z Jun 25, 2023
4502fd8
fixed example game, fixed overlay activated callback, implemented 2 m…
k0T0z Jun 26, 2023
12bb0fa
calling steam_init() automatically, bug fixes, few improvements
k0T0z Jun 30, 2023
5b8c18c
bug fixes
k0T0z Jun 30, 2023
048dce5
implemented 2 user functions in overlay
k0T0z Jul 2, 2023
349c42e
bug fixes
k0T0z Jul 2, 2023
a4591df
overlay API done, fixed example game
k0T0z Jul 2, 2023
62b1c6b
bug fixes, added achievements API
k0T0z Jul 2, 2023
3be9a6f
fix naming, update readme
k0T0z Jul 2, 2023
1ae41e3
bug fixes
k0T0z Jul 2, 2023
0185ddf
adding dlls, fixing output messages
k0T0z Jul 2, 2023
28e2170
few improvements
k0T0z Jul 2, 2023
3019ef4
few improvements
k0T0z Jul 3, 2023
61a573f
few improvements
k0T0z Jul 5, 2023
aa43d17
started implementing Stats and Achievements API, bug fixes
k0T0z Jul 5, 2023
f054304
bug fixes
k0T0z Jul 5, 2023
a837a59
Merge branch 'steam-sdk-integration' of https://github.com/k0T0z/enig…
k0T0z Jul 5, 2023
83e679f
bug fixes
k0T0z Jul 5, 2023
15a9124
bug fixes, implemented 3 more user functions, achievements are now wo…
k0T0z Jul 6, 2023
90973fb
few improvements, implemented most of the achievements API
k0T0z Jul 6, 2023
769c63c
achievements api done, bug fixes
k0T0z Jul 7, 2023
8311de5
add steam logo
k0T0z Jul 7, 2023
16ea047
clean files, add leaderboard starter code
k0T0z Jul 11, 2023
b03fffd
clean files, bug fixes, started implementing Leaderboards API
k0T0z Jul 11, 2023
351445f
adding Async support inside Steamworks ENIGMA extension
k0T0z Jul 13, 2023
9e9a901
adding CMakeLists.txt file
k0T0z Jul 13, 2023
145076e
adding CMakeLists.txt file
k0T0z Jul 13, 2023
088f8b4
bug fixes, few improvements, changing the way Async work in ENIGMA
k0T0z Jul 15, 2023
17b593a
changing the way Async works
k0T0z Jul 17, 2023
69d01bf
bug fixes
k0T0z Jul 18, 2023
c4144ad
Merge remote-tracking branch 'upstream/master' into steam-sdk-integra…
k0T0z Jul 19, 2023
db840d4
bug fixes, updating the new Async system
k0T0z Jul 19, 2023
ab58d54
fixing .ignore file
k0T0z Jul 22, 2023
5007221
bug fixes, implementing using the old Async system for now
k0T0z Jul 22, 2023
5ea8902
new Async system: trial 3
k0T0z Jul 22, 2023
bc3fbdd
Fixing the new Async system done
k0T0z Jul 23, 2023
d363b46
bug fixs
k0T0z Jul 25, 2023
6f6216e
game client documentation done
k0T0z Jul 26, 2023
150eea7
APIs documentation done
k0T0z Jul 26, 2023
bba3b36
Removing example game from git for midterm review, bug fixes, and doc…
k0T0z Jul 26, 2023
0d71898
bug fixes
k0T0z Jul 26, 2023
e3bcb12
bug fixes
k0T0z Jul 26, 2023
9db0e8f
new project structure
k0T0z Jul 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
/CompilerSource/stupidity-buffer/obj
/ENIGMAsystem/SHELL/.vs/*
/ENIGMAsystem/SHELL/.vscode/*
/.vscode/*
/CMakeFiles/*
/ENIGMAsystem/SHELL/.build/*
CMakeCache
.DS_Store

enigma-launch.bat
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

is_initialized = steam_initialised();

gtest_assert_eq(is_initialized, true);
54 changes: 54 additions & 0 deletions ENIGMAsystem/SHELL/Platforms/General/PFmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,28 @@
#include "Universal_System/roomsystem.h"
#include "Universal_System/mathnc.h" // enigma_user::clamp

#include "Universal_System/Extensions/DataStructures/include.h"
#include "Universal_System/Instances/instance.h"

#include "Universal_System/Extensions/Steamworks/implement.h" // The implement.h file is responsible for implementing extension_steamworks struct.

#include <chrono> // std::chrono::microseconds
#include <thread> // sleep_for

namespace enigma {

namespace extension_cast {
extension_steamworks* as_extension_steamworks(object_basic*);
}

} // namespace enigma

namespace enigma {

std::queue<std::map<std::string, variant>> posted_async_events;

int extension_steamworks_mutex {1}; // Must be initialized to 1.

std::vector<std::function<void()> > extension_update_hooks;

bool game_isending = false;
Expand Down Expand Up @@ -166,7 +183,40 @@ int updateTimer() {
return 0;
}

void wait(int* mutex) {
while (*mutex <= 0);
(*mutex)--;
}

void signal(int* mutex) {
(*mutex)++;
}

void fireEventsFromQueue(int* mutex) {
// wait(mutex);
while (!posted_async_events.empty()) {
enigma_user::ds_map_clear(enigma_user::async_load);

std::map<std::string, variant> event = posted_async_events.front();

posted_async_events.pop();

for (auto& [key, value] : event) {
enigma_user::ds_map_add(enigma_user::async_load, key, value);
}

instance_event_iterator = &dummy_event_iterator;
for (iterator it = instance_list_first(); it; ++it) {
object_basic* const inst = ((object_basic*)*it);
extension_steamworks* const inst_steamworks = extension_cast::as_extension_steamworks(inst);
inst_steamworks->myevent_steam();
}
}
}

int enigma_main(int argc, char** argv) {
enigma_user::async_load = enigma_user::ds_map_create();

// Initialize directory globals
initialize_directory_globals();

Expand Down Expand Up @@ -201,6 +251,8 @@ int enigma_main(int argc, char** argv) {
for (auto update_hook : extension_update_hooks)
update_hook();

fireEventsFromQueue(&extension_steamworks_mutex);

ENIGMA_events();
handleInput();
}
Expand All @@ -215,6 +267,8 @@ int enigma_main(int argc, char** argv) {

namespace enigma_user {

int async_load;

const int os_browser = browser_not_a_browser;
std::string working_directory = "";
std::string program_directory = "";
Expand Down
17 changes: 17 additions & 0 deletions ENIGMAsystem/SHELL/Platforms/General/PFmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#define ENIGMA_PLATFORM_MAIN

#include <string>
#include <queue>
#include <map>

#include "Universal_System/var4.h"

namespace enigma {
extern bool game_isending;
Expand All @@ -32,6 +36,16 @@ namespace enigma {
extern unsigned long current_time_mcs;
extern bool game_window_focused;

// This queue will contain any event that will be fired inside the main loop.
extern std::queue<std::map<std::string, variant>> posted_async_events;

// The following semaphore code is for the new Async system to protect the posted_async_events queue
// from reading and writing at the same time. Steamworks extension writes to the queue.
// mutex to protect the async queue from race conditions when the Steamworks extension is writing into it.
extern int extension_steamworks_mutex;
void wait(int* mutex);
void signal(int* mutex);

int enigma_main(int argc, char** argv);
int game_ending();
void Sleep(int ms);
Expand All @@ -58,6 +72,9 @@ extern double fps;
extern unsigned long delta_time;
extern unsigned long current_time;

// When firing any event inside posted_async_events queue, this variable will contain the data that will be sent to the game.
extern int async_load;

void sleep(int ms);
unsigned long get_timer(); // number of microseconds since the game started
void game_end();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
############################################################################
# Copyright (C) 2023-2024 Saif Kandil
#
# This file is a part of the ENIGMA Development Environment.
#
# ENIGMA 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, version 3 of the license or any later version.
#
# This application and its source code is distributed AS-IS, 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 code. If not, see <http://www.gnu.org/licenses/>
############################################################################

/.vs/*
/.vscode/*

# gb stands for Global Backup and it shouldn't be committed to git
# gb is auto-generated by the example game
/*.gb*/*

# This is only temporary, it will be removed once the Midterm review is done.
/example/*
15 changes: 15 additions & 0 deletions ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/About.ey
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%e-yaml
---

Name: Steamworks
Identifier: Steamworks
Author: Saif Kandil (https://k0t0z.github.io)
Description: Steamworks is a set of tools and services that help game developers and publishers build their games and get the most out of distributing on Steam.
Default: false
Icon: steam.svg

Depends:
Extensions: DataStructures
Dependencies: None
Implement: extension_steamworks
Init: extension_steamworks_init
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
############################################################################
# Copyright (C) 2023-2024 Saif Kandil
#
# This file is a part of the ENIGMA Development Environment.
#
# ENIGMA 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, version 3 of the license or any later version.
#
# This application and its source code is distributed AS-IS, 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 code. If not, see <http://www.gnu.org/licenses/>
############################################################################

############################################################################
# Note that this file isn't tested yet as ENIGMA's engine still works with
# the old build system.
############################################################################

cmake_minimum_required(VERSION 3.5)

project(steamworks VERSION 0.1 LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(PROJECT_SOURCES
main.cpp
)

add_library(steamapi STATIC IMPORTED GLOBAL
redistributable_bin/steam_api.lib
)

set_property(TARGET steamapi APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(steamapi PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
IMPORTED_LOCATION_DEBUG "${CMAKE_SOURCE_DIR}/redistributable_bin/steam_api.lib")

add_executable(steamworks
${PROJECT_SOURCES}
)

target_link_libraries(steamworks
steamapi
)
44 changes: 44 additions & 0 deletions ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
############################################################################
# Copyright (C) 2023-2024 Saif Kandil
#
# This file is a part of the ENIGMA Development Environment.
#
# ENIGMA 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, version 3 of the license or any later version.
#
# This application and its source code is distributed AS-IS, 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 code. If not, see <http://www.gnu.org/licenses/>
############################################################################

SOURCES += $(wildcard Universal_System/Extensions/Steamworks/*.cpp) \
$(wildcard Universal_System/Extensions/Steamworks/game_client/*.cpp)

# defining directory of steam header files
override CXXFLAGS += -I$(ENIGMA_ROOT)/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/game_client/Steamv157/sdk/public/

ifeq ($(TARGET-PLATFORM), Windows)

# defining directory of 64-bit lib file
override LDFLAGS += -L$(ENIGMA_ROOT)/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/game_client/Steamv157/sdk/redistributable_bin/win64/

# check https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html#:~:text=Static%20Library%20vs.%20Shared%20Library
# adding 64-bit lib file
# this is static linking (maybe)
override LDLIBS += -lsteam_api64

else ifeq ($(TARGET-PLATFORM), Linux)

# defining directory of 64-bit lib file
override LDFLAGS += -L$(ENIGMA_ROOT)/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/game_client/Steamv157/sdk/redistributable_bin/linux64

# check https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html#:~:text=Static%20Library%20vs.%20Shared%20Library
# adding 64-bit lib file
override LDLIBS += -lsteam_api

endif