tweecode/twine — pull request #86 by webbedspace (2013-10-23 08:01:43+00:00)
Title: Interface improvements + new image asset feature

Here's some more cool stuff I've been working on. Note: in addition to interface improvements and fixes, this takes the audacious step of adding a new feature: the ability to import image assets, which are stored as base64 encoded strings in "image passages", and can be transcluded into passages using the standard image syntax: [img[image passage name]].

There have been a number of proposed solutions to making Twine more image-friendly: many of them, adhering to Twine's important "all-in-one HTML file" feature, involve base64 encoding. UnstableEgghead's fork has base64 encoding performed at compile-time, based on local image file references in the code. This has a few limitations - notably, a file referenced in multiple passages will be stored multiple times in the HTML.

I believe my implementation overcomes this - the image data is stored only once in the HTML, and is transcluded into passages at runtime - and also provides the advantage of treating images as 'game assets' that are stored in the .tws, instead of being separate, loose files. The .tws can thus serve as the 'complete' source code of the game (or at least more complete than otherwise).

Images are stored in base64, even in the .tws, primarily for backwards-compatibility purposes.

Note: as of yet, there's no way for imported images to be used in CSS. I'm presently debating possible approaches to this.