Adventure Game Studio

AGS Development => Editor Development => Topic started by: eri0o on Sat 30/11/2024 12:53:13

Title: [IDEA] a way to test a web game in the Browser from the Editor
Post by: eri0o on Sat 30/11/2024 12:53:13
[shadow=black,right]Open in browser button[/shadow]

motivation

The web builds from the engine produce an index.html file that has to request the necessary files for running the ags game, including the web build of the engine that is the ags.wasm file. All of these files have to be requested in a way that requires the files to be served from a server, including also safety requirements in modern web browsers. In this way, it's not possible to double-click the index.html file produced by the engine to load it in the browser.

idea

Come up with some way to serve the web files built files from the Editor. My idea is to add an entry in the build menu, right after Run without debugger entry that is Run in Web Browser. It may optionally also have an icon for this in the toolbar.

I imagine the menu entry and toolbar icon would only be enable if both: building for web is enabled in general settings and the last successful build included the web build.

problems


limitations

These are not exactly problems, but constraints from implementing this in the editor. If put in an external tool like my AGS Toolbox, it could be easier to support these stuff.


additional context

I have actually implemented this idea in a previous Game Engine Editor I made:

https://github.com/ericoporto/fgmk/blob/master/fgmk/game_server.py
The game server is linked above

The close of the tab in the browser stopping the server was implemented like this
https://github.com/ericoporto/fgmkJsEngine/blob/b40a1a173d2b4d3b8a0f25caeebe322e3b8703bc/src/bootstrap.js#L24

When the tab closed, it requested an invalid file called exit.json, and then the server would filter for this specifically and then stop it's thread when this was requested.

implementation

To make this easier to iterate on in C#, Winforms and .NET without going through building the entire AGS Editor I made a minimal prototype

MinimalWebServer.zip (https://github.com/ericoporto/ags/releases/download/3.6.1.1/MinimalWebServer.zip)

This proposal was motivated by the thread in the forums here (https://www.adventuregamestudio.co.uk/forums/index.php?topic=62091.0), I really would like to tackle but I need helping imagining the design of this, even if it's through drawings in paint and comments from other game developers.