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

Support Nuitka --onefile compiled application; Implement ISteamUGC/GetAppDependencies #91

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 52 additions & 2 deletions library/SteamworksPy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,20 @@ typedef void(*CreateItemResultCallback_t)(CreateItemResult_t);
typedef void(*SubmitItemUpdateResultCallback_t)(SubmitItemUpdateResult_t);
typedef void(*ItemInstalledCallback_t)(ItemInstalled_t);

struct GetAppDependenciesResult {
std::int32_t result;
std::uint64_t publishedFileId;
std::uint32_t* array_app_dependencies;
std::uint32_t array_num_app_dependencies;
std::uint32_t total_num_app_dependencies;
};

struct SubscriptionResult {
std::int32_t result;
std::uint64_t publishedFileId;
};

typedef void(*GetAppDependenciesResultCallback_t)(GetAppDependenciesResult);
typedef void(*RemoteStorageSubscribeFileResultCallback_t)(SubscriptionResult);
typedef void(*RemoteStorageUnsubscribeFileResultCallback_t)(SubscriptionResult);
typedef void(*LeaderboardFindResultCallback_t)(LeaderboardFindResult_t);
Expand All @@ -103,11 +112,13 @@ class Workshop {
CreateItemResultCallback_t _pyItemCreatedCallback;
SubmitItemUpdateResultCallback_t _pyItemUpdatedCallback;
ItemInstalledCallback_t _pyItemInstalledCallback;
GetAppDependenciesResultCallback_t _pyGetAppDependenciesCallback;
RemoteStorageSubscribeFileResultCallback_t _pyItemSubscribedCallback;
RemoteStorageUnsubscribeFileResultCallback_t _pyItemUnsubscribedCallback;

CCallResult <Workshop, CreateItemResult_t> _itemCreatedCallback;
CCallResult <Workshop, SubmitItemUpdateResult_t> _itemUpdatedCallback;
CCallResult <Workshop, GetAppDependenciesResult_t> _getAppDependenciesCallback;
CCallResult <Workshop, RemoteStorageSubscribePublishedFileResult_t> _itemSubscribedCallback;
CCallResult <Workshop, RemoteStorageUnsubscribePublishedFileResult_t> _itemUnsubscribedCallback;

Expand All @@ -131,6 +142,10 @@ class Workshop {
_pyItemInstalledCallback = nullptr;
}

void SetGetAppDependenciesResultCallback(GetAppDependenciesResultCallback_t callback) {
_pyGetAppDependenciesCallback = callback;
}

void SetItemSubscribedCallback(RemoteStorageSubscribeFileResultCallback_t callback) {
_pyItemSubscribedCallback = callback;
}
Expand All @@ -150,6 +165,11 @@ class Workshop {
_itemUpdatedCallback.Set(submitItemUpdateCall, this, &Workshop::OnItemUpdateSubmitted);
}

void GetAppDependencies(PublishedFileId_t publishedFileID) {
SteamAPICall_t getAppDependenciesCall = SteamUGC()->GetAppDependencies(publishedFileID);
_getAppDependenciesCallback.Set(getAppDependenciesCall, this, &Workshop::OnGetAppDependencies);
}

void SubscribeItem(PublishedFileId_t publishedFileID) {
SteamAPICall_t subscribeItemCall = SteamUGC()->SubscribeItem(publishedFileID);
_itemSubscribedCallback.Set(subscribeItemCall, this, &Workshop::OnItemSubscribed);
Expand Down Expand Up @@ -179,6 +199,22 @@ class Workshop {
}
}

void OnGetAppDependencies(GetAppDependenciesResult_t* getAppDependenciesResult, bool bIOFailure) {
if (_pyGetAppDependenciesCallback != nullptr) {
GetAppDependenciesResult result;
result.result = getAppDependenciesResult->m_eResult;
result.publishedFileId = getAppDependenciesResult->m_nPublishedFileId;
result.array_num_app_dependencies = getAppDependenciesResult->m_nNumAppDependencies;
result.total_num_app_dependencies = getAppDependenciesResult->m_nTotalNumAppDependencies;
result.array_app_dependencies = new std::uint32_t[result.array_num_app_dependencies];
std::copy(getAppDependenciesResult->m_rgAppIDs,
getAppDependenciesResult->m_rgAppIDs + result.array_num_app_dependencies,
result.array_app_dependencies);
_pyGetAppDependenciesCallback(result);
delete[] result.array_app_dependencies;
}
}

void OnItemSubscribed(RemoteStorageSubscribePublishedFileResult_t *itemSubscribedResult, bool bIOFailure) {
if (_pyItemSubscribedCallback != nullptr) {
SubscriptionResult result{itemSubscribedResult->m_eResult, itemSubscribedResult->m_nPublishedFileId};
Expand Down Expand Up @@ -436,7 +472,7 @@ SW_PY const char *GetAppInstallDir(AppId_t appID) {
char *buffer = new char[folderBuffer];
SteamApps()->GetAppInstallDir(appID, (char *) buffer, folderBuffer);
const char *appDir = buffer;
delete buffer;
delete[] buffer;
return appDir;
}

Expand Down Expand Up @@ -965,7 +1001,7 @@ SW_PY const char *GetUserDataFolder() {
char *buffer = new char[bufferSize];
SteamUser()->GetUserDataFolder((char *) buffer, bufferSize);
char *data_path = buffer;
delete buffer;
delete[] buffer;
return data_path;
}

Expand Down Expand Up @@ -1407,6 +1443,20 @@ SW_PY void Workshop_ClearItemInstalledCallback() {
workshop.ClearItemInstallCallback();
}

SW_PY void Workshop_GetAppDependencies(PublishedFileId_t publishedFileID) {
if(SteamUGC() == NULL){
return;
}
workshop.GetAppDependencies(publishedFileID);
}

SW_PY void Workshop_SetGetAppDependenciesResultCallback(GetAppDependenciesResultCallback_t callback) {
if (SteamUGC() == NULL) {
return;
}
workshop.SetGetAppDependenciesResultCallback(callback);
}

SW_PY void Workshop_SetItemSubscribedCallback(RemoteStorageSubscribeFileResultCallback_t callback) {
if (SteamUGC() == NULL) {
return;
Expand Down
4 changes: 0 additions & 4 deletions library/sdk/redist/.gitignore

This file was deleted.

Loading