AGS engine Web port

Started by eri0o, Wed 26/05/2021 02:45:17

Previous topic - Next topic

WHAM

Quote from: eri0o on Thu 06/06/2024 16:10:12Version?

That was the right question to ask. I wasn't on the latest version at all, but 3.6.0. After updating the editor and recompiling, the game seems to run with zero issues whatsoever.
This is, as the cool kids say, real heckin' neato! Many thanks, I will surely put this to use with my future projects as well as recompile some old ones for renewed distribution.
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

eri0o

Glad it worked! Any issues you find feel free to report. Sorry for the short question, it's just lately I don't have much time and everytime I write a lot in the answer it seems either my connection or the website bursts into flames and I lose my post. :/

AGA

Hey, @eri0o is there a way of including a .dll engine plugin in these games?  Specifically ags_agi.dll (AGS Resolution Emulation Plugin)?  I've seen a few mentions of plugins in this thread, but there don't seem to be any instructions if compiling with plugins is actually possible.

eri0o

#163
There isn't an easy way to dynamically load a wasm code in a way that would integrate with it (perhaps we could add support for pure JS plugins at some point).

Because the plugins are required to be statically built, if you are using one that isn't in the ags upstream repository, you need to fork the engine and build it with your added plugin.

I never heard about the plugin you mentioned and don't have it's source so I can't upstream it either. Here: https://github.com/adventuregamestudio/ags/tree/master/Plugins

Crimson Wizard

Quote from: AGA on Tue 06/08/2024 20:43:20Hey, @eri0o is there a way of including a .dll engine plugin in these games?  Specifically ags_agi.dll (AGS Resolution Emulation Plugin)?

AGI plugin in particular may be substituted with the existing viewport/camera feature with relative ease in modern version of AGS.
We've discussed this recently here:
https://www.adventuregamestudio.co.uk/forums/editor-development/feature-request-agi-21-aspect-ratio-support/

eri0o

@AGA are you asking about it to integrate some ags player in some website? :p (like, for playing old games)

Snarky

Quote from: eri0o on Wed 07/08/2024 01:09:10@AGA are you asking about it to integrate some ags player in some website? :p (like, for playing old games)

Do you have any thoughts on how this might work with games hosted externally, for a bunch of different games? For example, given a link to a game download as a zip file, would it be possible to offer a button that downloads, extracts and runs it in the browser?

eri0o

#167
It depends, you own the host for all games? Then the "unzipping" may be done by the protocol on request, like you serve them gzipped and they get ungzipped at transport.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding

Going through this route nothing much special has to be done. See for example how itch handles this here  https://itch.io/docs/creators/html5.amp#compression.

Now if you don't own the host of the games then I don't think it's doable very easy - people will give URL address to places where you don't get direct access to files (think like itch or gamejolt where the URL of the actual files isn't the url of the "game page"), plus not sure how to get around cors. Additionally I think in this case you can't just use protocols and would need to have something like zip reimplemented in JS so these files could be loaded.

Being the host vs depending of other hosts will entail in very different approaches I think because of CORS. Workaround CORS in JS only will mean we can "never" go multithread in the web (because the headers that one needs to serve to enable the required things restrict CORS a lot). Other approach is to download it in the backend (through php magic or something else), but then you have foreign files going in your server...

Other approach is to be a file host but restrict total size - say 25MB max, wouldn't work for a full featured game but perhaps is enough for MAGS games.

Important reminder is ags3 games have backwards compatibility as far back as around 2.5something, so you will be alright having just the latest 3.X release web port and using it to run all the games from 3.X.

AGA

Quote from: eri0o on Wed 07/08/2024 01:09:10@AGA are you asking about it to integrate some ags player in some website? :p (like, for playing old games)

That's what I'm considering; something like allowing a game author to upload a zip of their Web-compiled game, which I'd then sanitise and host myself before including in a div on the site.  I gave it a quick try with a small game that had no plugin requirements, and it seems pretty easy to do.  A few questions though...

Is my_game_files.js a full manifest of the files that are specific to the game?  Are ags.js, ags.was and index.html generic?  What filenames and types is it possible could be included in this manifest?  I appreciate GAME_NAME.ags will vary, but is it only acsetup.cfg and audio.vox that could be included?

How is acsetup.cfg used by the Web player?  It would be good if I could know the resolution each game will run at.  It will need to be a certain size to fit into the site design, so I guess knowing the aspect ratio would be best, so I can use divs of e.g. 800 x 600 for 4:3 resolutions, and scale accordingly on responsive site designs.

Rather than relying on the versions of ags.js, ags.was and index.html uploaded by the user, could I keep my own copies of these to use, rather than risking executing js files uploaded by users?  Is there any relationship between the versions of the files listed in my_game_files.js and the other files?  That is, if I use the editor to compile for Web, does it need the included versions of ags.js, ags.was and index.html, or can I always keep the most recent versions of those files to use against games that may have been bundled with different versions?

If index.html is generic, could I dynamically edit it or the other files to tell it which source files to use?  Or is that determined by my_game_files.js?  Or could we perhaps pass these values in to the URL used to access the player?  E.g. adventuregamestudio.co.uk/play/?audio=audio.vox&game=Beckett.ags&config=acsetup.cfg kind of thing.

eri0o

So, AGS has a Data dir, perhaps you can take the files from there and use your own ags.js, ags.wasm and your own html file.

The magic in the html file is pretty small, if you delete the my_game_files.js you will see the default html will instead look like something that waits the user "upload" their game files. This would trigger the code path here:

https://github.com/adventuregamestudio/ags/blob/0e7d10da6f6ad72626ac3178ae42b254b35de151/Emscripten/launcher_index.html#L539

Overall you can see I just look for any exe file that isn't the winsetup.exe or a .AGS file and try to run the ags engine passing that file specifically as the target.

The only other issue it has to solve is to create the "save dir" which in the browser is kept sync with the URL. If the URL changes the browser local storage will be different.

Itch runs the html in an iframe to prevent it "escaping" to the other things in the website.

Quote from: AGA on Wed 07/08/2024 22:01:39That is, if I use the editor to compile for Web, does it need the included versions of ags.js, ags.was and index.html, or can I always keep the most recent versions of those files to use against games that may have been bundled with different versions?

For ags3 yes that will always work, the latest ags3 will be able to run any previous ags3 that came before, it's binary compatible in a way - minus plugins because they are native language so they are out of our control.

For ags4, that is still in the alpha stage with changes happening but in principle ags4 is incompatible with ags3, so while ags4 may eventually be compatible with ags4 it's not yet and I don't know if it will but it definitely isn't going to be compatible with ags3. But I imagine one could have their own major ags4 versions pre-stored and then just run them instead.

AGA

So what I'm thinking is:

Would that work?  I guess I may need to either ask the user to confirm, or scan the source files somehow, to know which version of the engine (v3 or v4) to include?  But including the latest version of v3 or v4 should in theory work?

eri0o

That would work but there is no need to copy AGS.js AGS.wasm and whatever index.html is done, just fix the src URLs to point to the right places :)

SMF spam blocked by CleanTalk