Adventure Game Studio | Forums

AGS Support => Modules, Plugins & Tools => Topic started by: monkey0506 on Sun 19/07/2015 19:49:14

Title: PLUGIN INTERFACE: AGS2Client - Common interface for Steam, GOG Galaxy, etc.
Post by: monkey0506 on Sun 19/07/2015 19:49:14
This may be fairly mundane, but I have created a common interface for client plugins that AGS can use to communicate with clients like Steam and GOG Galaxy. In fact, those are the only two clients I know of presently that offer the whole game-library-with-achievements-and-so-forth type of "client", but it's always possible that others will rise up.

In related news, this does mean that I am working on a GOG Galaxy plugin! Hopefully that should be made available soon. As far as I know, the GOG Galaxy SDK is open source, so that plugin will also be fully open-sourced, unlike AGSteam. The official stub source code for AGSteam (https://github.com/monkey0506/agsteamstub) will later be updated to this much improved interface as well.

I created a demo project to show how this interface can be used to stub these client plugins rather simply. You can grab the source for that at the link below (the interface itself is a referenced submodule in a separate repo):

https://github.com/monkey0506/ags2client_demo

P.S. Additionally, this common interface should make it relatively simple for AGS devs to implement Steam and Galaxy features in a uniform fashion. That seems like it would be appreciated. ;)

P.S.S. The Visual Studio solution files I provided for the demo are VS 2013 solution files, and the interface does make use of C++11 features. The demo was tested with AGS 3.4.0.5 and gave me no issues.
Title: Re: PLUGIN INTERFACE: AGS2Client - Common interface for Steam, GOG Galaxy, etc.
Post by: Dualnames on Sun 19/07/2015 20:28:24
I may be incredibly dumb right now, but i don't understand what exactly this does.
Title: Re: PLUGIN INTERFACE: AGS2Client - Common interface for Steam, GOG Galaxy, etc.
Post by: Crimson Wizard on Sun 19/07/2015 20:52:23
Quote from: Dualnames on Sun 19/07/2015 20:28:24
I may be incredibly dumb right now, but i don't understand what exactly this does.
If I understand correctly, this is a uniform script header for all possible client plugins released in future.

Write game script 1 time, then just replace client plugin dll in your game (from Steam to GoG and whatnot), and it will work.
Title: Re: PLUGIN INTERFACE: AGS2Client - Common interface for Steam, GOG Galaxy, etc.
Post by: monkey0506 on Mon 20/07/2015 06:04:38
That's the general idea, yes. I don't foresee any need to have the Steam plugin pushed out over GOG Galaxy, for example, so there's a good chance that most of the function calls could be set up in a synonymous way.

The source code for the various client plugins can reference this interface to reduce code duplication. Some minimal defaults are already in-place, so things like registering the script header and the various functions can largely be handled by the AGS2Client interface. New (common) features (if any) could also be implemented at the interface level, and perpetuated to the client plugins by updating the git submodule (as opposed to having to recreate the changes for each plugin).

This probably won't be widely useful to most people. But in theory it allows me to maintain both plugins in a user-friendly and open-source way while supporting closed-source frameworks like Steamworks with relatively little unseen/private code. This also is an effort to make sure that the client plugins may be properly stubbed for platforms that the client doesn't yet support.
Title: Re: PLUGIN INTERFACE: AGS2Client - Common interface for Steam, GOG Galaxy, etc.
Post by: monkey0506 on Thu 07/01/2016 20:24:17
Now that I've finally gotten around to finishing the GOG plugin and updated the Steam plugin, I made a sample project that shows how you can set up your achievement code once in AGS and not have to worry about duplicating the code.

Downloads and such (https://bitbucket.org/monkey0506/ags2client/downloads)

To set up your game (using the Steam+Galaxy project), there are only a few things that need to be done:

1) Make sure that on the Steam and GOG backend websites, your achievements are set up with exactly the same API names (this is the name you use to set the achievements from AGS).
2) Replace the contents of "steam_appid.txt" in your Compiled folder with your Steam game's app ID. For release builds, you can delete this file entirely, but you don't have to.
3) In the Achievements script header, add your GOG Galaxy client ID and client secret.
4) In the Achievements script header, create friendly enum names for each achievement.
5) In the Achievements script file, set the API name that corresponds to each enum'd achievement.
6) In the Achievements script file, modify or remove the on_key_press function to match your game's needs. Call Achievements.Set as needed (instead of AGS2Client.SetAchievement!) and you will also be able to build with both plugins disabled.
7) Make sure you have the appropriate plugin enabled for the release you want to build (if any), and "Rebuild all files" (trust me, it's for the best when changing plugins).
8) For release, make sure to remove the Steam- or GOG-specific plugins from your Compiled folder.

P.S. I've also recently come across "Galaxy Crossplay". I'm not aware of any AGS games using matchmaking features (yet!), but it would be entirely possible to use both plugins simultaneously and thereby allow setting achievements in Steam to also set the achievement in GOG Galaxy. For this you would need the "non-unified" variant of the plugins. I'll work on cleaning up the project files to make more sense of this, and release appropriately named binaries.
Title: Re: PLUGIN INTERFACE: AGS2Client - Common interface for Steam, GOG Galaxy, etc.
Post by: monkey0506 on Sat 09/01/2016 02:58:47
REGARDING 'UNIFIED' CLIENT PLUGINS

The client plugins I have written (AGSteam and AGSGalaxy) now support "unified" building by default. This means that you will use "AGS2Client" in place of "AGSteam" or "AGSGalaxy" in most cases. A call such as:

Code (ags) Select
AGSGalaxy.SetAchievementAchieved("NAME");

Will instead become:

Code (ags) Select
AGS2Client.SetAchievementAchieved("NAME");

(and likewise for AGSteam)

The benefit behind this is that you can toggle between AGSGalaxy and AGSteam (or other future plugins) without having to change your game scripts. To take full advantage of the unified plugin builds, you must ensure that the "API name" (the name you call from your game scripts) is exactly the same on both the Steamworks and GOG Galaxy backend websites. This is what makes the unified build work! Once the achievements are set up properly on the backend websites, you can toggle between using the AGSteam and AGSGalaxy plugin and rebuild your game without having to change any code (or duplicate any code). For an example of this in action, see the Steam+Galaxy project (https://bitbucket.org/monkey0506/ags2client/downloads) (instructions (http://www.adventuregamestudio.co.uk/forums/index.php?topic=52432.msg636528308#msg636528308)).

Note that the unified builds replace the client-specific struct name ("AGSteam"/"AGSGalaxy") with "AGS2Client", and so the version macro is replaced with "AGS2Client_VERSION". However, to ensure that client-specific functions can still be utilized, the client-specific version macro is also defined. So the AGSteam unified plugin will define "AGS2Client_VERSION" and "AGSteam_VERSION" both with the version number of the Steam plugin. AGSGalaxy will define "AGS2Client_VERSION" and "AGSGalaxy_VERSION" both with the version number of the GOG Galaxy plugin. This is necessary in particular to initialize the GOG Galaxy plugin, which requires a client ID and client secret not required in initializing the Steam plugin. See the Steam+Galaxy project for an example of how to implement this.

You may instead choose to utilize the "disjoint" build of the plugin, which still uses "AGSteam" or "AGSGalaxy" instead of "AGS2Client", but this means you will have to use separate code for Steam and Galaxy builds. A practical reason why you might want to do this is to allow "Galaxy crossplay" builds. Essentially that means that you would include BOTH the AGSGalaxy AND AGSteam disjoint builds AT THE SAME TIME. You would initialize both client APIs, and call their respective functions separately. Doing so would allow you to have a single build of your game released on Steam and GOG Galaxy. As long as the player has both clients installed, then they can gain achievements for both clients at once. The disjoint plugin builds have "-disjoint" in the filename, but you can rename the binary (DLL) as needed for compatibility with an older game that uses client-specific game scripts.
Title: Re: PLUGIN INTERFACE: AGS2Client - Common interface for Steam, GOG Galaxy, etc.
Post by: Dave Gilbert on Mon 06/03/2017 13:48:55
Sorry to necropost, but is there any documentation for this plugin? E.g., a list of commands that you can use? I searched around the forum but I can't seem to find any anywhere.

Thanks!
Title: Re: PLUGIN INTERFACE: AGS2Client - Common interface for Steam, GOG Galaxy, etc.
Post by: monkey0506 on Sat 17/06/2017 10:41:55
There is now a wiki, which explains using AGS2Client plugins (https://bitbucket.org/monkey0506/ags2client/wiki/Using_the_plugin_interface).