Adventure Game Studio

AGS Support => Modules, Plugins & Tools => Topic started by: eri0o on Sun 26/02/2023 19:49:20

Title: PLUGIN: AgsAppOpenURL 0.1.0
Post by: eri0o on Sun 26/02/2023 19:49:20
A small plugin to open URL in a browser, made for AGS 3.6.0 and beyond. (the plugin uses SDL2, so if you are using a previous version of ags, you have to add SDL2 somewhere)

agsappopenurl_windows.zip (https://github.com/ericoporto/agsappopenurl/releases/download/v.0.1.0/agsappopenurl_windows.zip) | agsappopenurl_linux.tar.gz (https://github.com/ericoporto/agsappopenurl/releases/download/v.0.1.0/agsappopenurl_linux.tar.gz) |  agsappopenurl_macos.zip (https://github.com/ericoporto/agsappopenurl/releases/download/v.0.1.0/agsappopenurl_macos.zip)

You call it like this:

AppOpenURL(eAUrlProto_https, "itch.io");
And it should open the itch website in a browser tab.

The idea is to use this plugin instead of the agsshell plugin - for safety reasons and better cross-platform support. It uses SDL2 behind the scenes, so it can't run in older versions of AGS. (well you would have to add SDL2 somewhere if using an old ags version)
Title: Re: PLUGIN: AgsAppOpenURL 0.1.0
Post by: Crimson Wizard on Sun 26/02/2023 20:10:47
Quote from: eri0o on Sun 26/02/2023 19:49:20It uses SDL2 behind the scenes, so it can't run in older versions of AGS.

I think it should be possible to load SDL if it was not loaded yet, and thus support both engine with SDL and one without?
Title: Re: PLUGIN: AgsAppOpenURL 0.1.0
Post by: eri0o on Sun 26/02/2023 22:09:18
theoretically yes, but hopefully people can move to ags 3.6.0. But like, if SDL2.dll is on the same directory it should work already, at least on Windows.

And I had made a mistake on the original release, but made a quick fix and reuploaded things.
Title: Re: PLUGIN: AgsAppOpenURL 0.1.0
Post by: CaptainD on Mon 27/02/2023 13:25:59
Works fine, many thanks for this!  ;-D

(Well it works unless you're stupid like me and accidentally put the full URL inside the ""...)
Title: Re: PLUGIN: AgsAppOpenURL 0.1.0
Post by: eri0o on Mon 27/02/2023 16:44:54
That's good! For now I am logging the messages that says why something fails - perhaps I could span error messages, at least until some logging feature makes into the Editor.

I believe until next weekend I can make some prebuilt binaries to be available beyond the Windows one and then need to setup CI in the project to automate the builds of the plugin.

I am forcing the protocol selection through enum to enforce using it to open webpages, and maybe if someone makes a case for other specific protocol we may allow or not - of course there's nothing blocking someone from modifying the plugin source to do whatever.
Title: Re: PLUGIN: AgsAppOpenURL 0.1.0
Post by: CaptainD on Mon 27/02/2023 17:01:40
As you predicted there is no delay whilst the page loads as per AGS Shell, so people should definitely add a Wait command to avoid multiple tabs of a page opening from a single click (or use some other method of avoiding this happening).

I had pondered whether it would be good to force the link to open in the Steam client itself, but not sure how useful that would be in truth as the main use is probably linking to the Steam Page from a demo, which is quite likely to have been opened from the Steam client anyway.
Title: Re: PLUGIN: AgsAppOpenURL 0.1.0
Post by: eri0o on Mon 27/02/2023 18:08:33
Ahn, maybe I totally misunderstood the question you sent me. Is the delay in the plugin something we want or not?  :-\

About the Steam mention, does this need some special Steam specific protocol (steam:// ??) or is just a link to the store steampowered website?
Title: Re: PLUGIN: AgsAppOpenURL 0.1.0
Post by: Crimson Wizard on Mon 27/02/2023 18:20:52
Quote from: CaptainD on Mon 27/02/2023 17:01:40As you predicted there is no delay whilst the page loads as per AGS Shell, so people should definitely add a Wait command to avoid multiple tabs of a page opening from a single click (or use some other method of avoiding this happening).

Why would this happen in the first place? Button's click event is only sent once per click, same is for object interaction events. So I'd imagine such behavior may occur only if you call the function in repeatedly_execute, where you check for mouse button down state?
Title: Re: PLUGIN: AgsAppOpenURL 0.1.0
Post by: CaptainD on Mon 27/02/2023 18:53:12
@eriOo - no confusion apart from any I've caused, it works exactly as you described whereas the Shell command only worked once the previous request had been fully processed by the browser. CW has me bang to rights, in this particular instance I have code in Repeatedly_Execute which is why I need to add the Wait() command.

Basically, your mod does exactly what it says on the tin, just a weird thing I'm doing in that particular room causing the issue I mentioned. Thanks again!
Title: Re: PLUGIN: AgsAppOpenURL 0.1.0
Post by: eri0o on Sat 11/03/2023 20:12:39
Hey! I am re-releasing this plug-in.

Added new download links at the top, now Linux and macOS builds are also included!

I have added a CI environment to my repository, hopefully with automated builds means anything that comes up will be easy to fix and produce a new release.

Edit: seconds after I noticed I made a small mistake in the code in the original version... I have remade the release and re-re-released! It only took me 50 commits in 6 hours to get this right  8-)
Title: Re: PLUGIN: AgsAppOpenURL 0.1.0
Post by: Manu on Tue 14/03/2023 13:11:35
Would it be possible to use the plugin to make an http request and get the result, instead of showing the page?
Something like: String str = AppOpenURL(eAUrlProto_https, "itch.io");
Title: Re: PLUGIN: AgsAppOpenURL 0.1.0
Post by: eri0o on Tue 14/03/2023 14:34:26
No, this would be an entirely different plugin. It would be something based in libcurl and need to be an unblocking request. I have thought about this in the past, what exactly you are trying to accomplish?
Title: Re: PLUGIN: AgsAppOpenURL 0.1.0
Post by: Manu on Tue 14/03/2023 16:11:32
Quote from: eri0o on Tue 14/03/2023 14:34:26I have thought about this in the past, what exactly you are trying to accomplish?

I wanted to create an online hi-score chart.

I would create an API to post the score, like https:/// something.com/postscore.php?score=XXXX&user=USER (PUT possibly, not GET). This will be called when the user completes the game.
Then, the game can call another API to get the top 10, like https:// something.com/gethiscore.php (result can be in CSV or json, not sure what is better). And the game will show the best scores.

Of course, once you have the curl, you can use it for many other things (loading user-generated levels for example). Or simply ask the server if there is a new version of the game.




Title: Re: PLUGIN: AgsAppOpenURL 0.1.0
Post by: Manu on Fri 17/03/2023 09:42:40
I'm thinking that I can implement the online high score chart with the current plugin. I can simply use:

AppOpenURL(eAUrlProto_https, "mysite.com/score.php?score=12121&user=USER");
this will post the score and show the current chart on the browser tab. I won't be able to show the chart in a game room, only on the browser, but it should be fine.

Do you see problems if I pass some parameters in get in AppOpenURL?