philippj / SteamworksPy

A working Python API system for Valve's Steamworks.
MIT License
214 stars 40 forks source link

Added Steam Workshop (UGC) support #4

Closed peacegiverman closed 7 years ago

peacegiverman commented 7 years ago

Added support for most important Steam Workshop (ISteamUGC) methods. Supported are:

Not supported:

I would really appreciate it if you could review the code, even if you do not wish to accept the pull request. Some notes:

Callbacks

In order to get Steam's CallResult callbacks to work, I had to create a Workshop class to contain those callbacks as members. This is a limitation of the Steamworks API: it requires all callbacks to be members of a class. This also means that only one callback of the same type (e.g. CreateItemResultCallback_t) can be set at a time.

There is another way to deal with this. It is hacky, but it would be better for the users. The Steamworks.NET devs instantiate Steamworks' abstract callback class CCallbackBase and populate its vtable on the fly, thus avoiding the limitations set by Steam's children classes.

Naming

I decided to add a prefix ("Workshop_") to all Workshop-related methods, to make it easier to spot where a method belongs and to avoid any potential future conflict. Also, I've avoided using Hungarian notation as much as possible, so that people who are used to Python can glance over the C++ code more easily.

CDLL restypes and argtypes

At the moment all restypes and argtypes are being set in the Steam.Init method. I would suggest moving each of those to its own respective class and then call its own Init method. For example SteamFriends.Init should set the restypes for SteamFriends methods.

How to

I've created a small guide for using the Workshop API. You can find it here. I could also add it to the repo.

Gramps commented 7 years ago

That is fantastic work, sir! I've been meaning to get back into it and adding some stuff that I've been working on with the other Steamworks project for Godot.

I think there is a small issue with IsSubscribed that HasOtherApp resolves. They basically do the same thing but IsSubscribed often gives an error for no reason. However, it has been a bit since I've tinker with it.

I'll try to get some additional stuff added.