PurpleKingdomGames / indigo

An FP game engine for Scala.
https://indigoengine.io/
MIT License
648 stars 60 forks source link

Plugin: Allow users to supply custom HTML templates #695

Closed davesmith00000 closed 7 months ago

davesmith00000 commented 9 months ago

Suggestion from @hobnob which seems very sensible now I think about it. We've talked about it before but I think it's more achievable following the recent plugin improvements.

Context

Indigo is a Scala.js game, and whether it runs in a browser, or desktop via Electron, or mobile with Cordova, it needs an HTML harness / page to run inside of. Currently we generate that page for you, and it comes with a few small JS scripts and some CSS to glue it all together. It isn't complicated, but it is necessary.

Proposal

The idea is to allow users to supply their own custom HTML/CSS/JS page harness via the build config. I'd suggest the work is done as follows:

Step 1 - Split builds by target platform.

At the moment, whether you're building for web, desktop, or mobile, you get all the same stuff. It's just that some of it is ignored.

So step 1 would be to change that so that there are settings for each target platform, and the generate slightly different things.

This would be good to do regardless.

Step 2 - Allow custom a harness/template

Per platform, the user supplies (perhaps) a path to a directory that contains all the files they want to use for the template. If that dir is defined, then instead of generating the files, we just copy them over instead.

Getting the wiring right is up to the user, but we might need to provide some mechanism for injecting values, unless we just rely on conventions?