klembot / twinejs

Twine, a tool for telling interactive, nonlinear stories
https://twinery.org
GNU General Public License v3.0
2.01k stars 299 forks source link

A .zip format for story format #423

Open klembot opened 7 years ago

klembot commented 7 years ago

Originally reported by: Longwelwind (Bitbucket: Longwelwind, GitHub: Longwelwind)


Hi !

At the moment, all the data of a story format be contained in a single js file (HTML, CSS, images and Javascript code).

I've worked on a workaround for this limitation of Twine for Adventures by bundling all the necessary files into the HTML. For example, for images, I place a base64-encoded version of them into the CSS. The thing is that to make the theme of my story format customizable, I have to bundle dozens of images that might never be used by the user.

This makes the final index.html big (multiple MB), and thus makes the loading of the page slow.

The idea would be to allow story formats to be contained in a zip:

The additional assets (css and images) could then be loaded with normal URLs in the HTML/CSS. I'd like to use Twine as a development tools for future games, but the current limitation makes it quite hard to make a usable game when the size of assets becomes big (and I didn't even add sounds yet :P)

Would this functionality be accepted in the project ? I've checked the source code, and I think it would be possible to include this feature while still maintaining the compatibility with the older story formats, but I'd prefer to make sure that a PR would be accepted before trying to implement it. :)

Thanks in advance !


klembot commented 6 years ago

Original comment by Chris Klimas (Bitbucket: klembot, GitHub: klembot):


If we did that, we'd have to start storing formats locally, e.g. in the browser's local storage. From what I've seen, we have an upper limit of 10 MB, which seems safe enough but could quickly get cluttered.

I think it'd help me on my side to think about possible solutions if I had a better sense of the customization you're offering with your format. Could you give me an overview?

klembot commented 6 years ago

Original comment by Longwelwind (Bitbucket: Longwelwind, GitHub: Longwelwind):


Thanks for the answer.

Could it be acceptable to let users to drag & drop files into the window ? This way, they only need to download the .zip (or anything else, actually) and drag it into the modal. I think it would work both for the online version and the native version.

klembot commented 6 years ago

Original comment by Chris Klimas (Bitbucket: klembot, GitHub: klembot):


The major technical blocker here is that story formats need to be JSONP so that we can load them from the online editor, e.g. https://twinery.org/2. By using JSONP, we can bypass cross-domain restrictions.

In the past, the way people got around this was creating separate story formats. But I can imagine this could get quite burdensome depending on the level of customization.