PLUGIN: AgsAppOpenURL 0.1.0

Started by eri0o, Sun 26/02/2023 19:49:20

Previous topic - Next topic

eri0o

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 | agsappopenurl_linux.tar.gzagsappopenurl_macos.zip

You call it like this:

Code: ags
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)

Crimson Wizard

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?

eri0o

#2
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.

CaptainD

Works fine, many thanks for this!  ;-D

(Well it works unless you're stupid like me and accidentally put the full URL inside the ""...)
 

eri0o

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.

CaptainD

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.
 

eri0o

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?

Crimson Wizard

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?

CaptainD

@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!
 

eri0o

#9
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-)

Manu

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");

eri0o

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?

Manu

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.





Manu

I'm thinking that I can implement the online high score chart with the current plugin. I can simply use:

Code: ags
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?

SMF spam blocked by CleanTalk