Advanced graphics for Inform 7

UPDATE 11/3/2011: Glimmr Form Fields is now available in release 3 of the full Glimmr release zip archive, as well as at the Inform 7 extensions library.

I’ve finally come to the end of a rather quixotic quest. A strange bug bit me while I was finishing up the main Glimmr package a few months back: I wanted to leverage Glimmr’s capabilities to create a relatively easy way for authors to offer HTML-style form fields within an IF game. Why on earth did I want to do that? Not for any good reason; in fact, I still haven’t come up with a practical IF-related use for it that would justify the hours it eventually took from me! Other than perhaps to remake Bureaucracy (see image below for a form from that game).

Screenshot of color picker

A simple RGB color calculator made with Glimmr Form Fields

In the end, I had to create two extensions to accomplish this goal: Glimmr Form Fields and Glulx Input Loops. (If you’re curious about the form fields, you can download compiled example games here; this will let you see how it works without firing up Inform 7, installing dependencies–of which there are many–etc. See the note about interpreters below.) A short discussion of how the one led to the other follows.

The basic mechanics for graphic form fields were easy and I was able to put a prototype together in just a few hours. I had good, general-purpose yet customizable ways to control text entry into the field, the backspace key, moving the cursor within the field, and so on. This rested (and still rests) on a couple of subterfuges: First, of course, the “text” in the form fields is not actually text but individual letterform graphics strung together to form words. Second, one doesn’t type really anything “into” the text fields; instead, we are receiving per-character input in the main text window and converting that for display in the graphics window.

Pre-HTML form fields from Infocom's Bureaucracy, by Douglas Adams (screenshot by Moby Games user Belboz)

It was the latter that caused me real headaches. Not because it was difficult to create something basic, but because I wanted the user (player) to be able to interact with multiple fields, clicking on one to type and then clicking on another to enter text there. Inform’s built-in input routines are very simply structured, and this turned out to be a sticky problem: Multiple fields easily led to nested loops that would quickly crash the program, or lead to other difficulties.

So, I had to make a bit of detour, and get an education in the finer points of Glulx input and Inform 7‘s (and Inform 6’s) implementation of input (special thanks to Zarf, the creator of Glulx, for his help–and patience). In the end, I decided to more or less rewrite the library input routines. Without going into great detail, the Glulx Input Loops extension gives the author many more hooks for decision-making within the overall “loop” of input to action-processing. It also introduces named input loops, as well as the idea of the “secondary” input loop, which shares input-handling with the “primary” loop; this goes a good way toward preventing the kinds of nasty nesting problems that can result when some types of input spawn new requests for input.

A diagram of primary vs secondary input loops

A (perhaps somewhat cryptic to the uninitiated) flowchart showing the relationship between primary and secondary input loops as defined in the Glulx Input Loops extension.

The new hooks provided by Glulx Input Loops let me complete Glimmr Form Fields as I wanted, avoiding the issues with event nesting. Glulx Input Loops also resulted in the keystroke input experiment I posted a month or so back. I hope that it proves to be a useful extension, and I think it will, particularly to those experimenting with alternate input paradigms.

I’m still asking myself why I dedicated myself to implementing form fields, though. The end result is pretty neat, but its neatness is not really IF-related… Who knows, maybe someone will think of something to do with it; the tool is there, at least. In the meantime, if you have your any ideas for using Glimmr Form Fields in IF, please feel free to leave a comment below–I’d love to hear that someone might actually get some use out of it!

A note for Mac users who might want to check out the Glimmr Form Fields compiled examples: If you are using a Mac, you probably default to using Zoom or Spatterlight as your interpreter of choice. Neither is a good fit for Glimmr, however. The current version of Zoom (1.1.4.1) has a few bugs that impact heavily on Glimmr games, while Spatterlight is too old to have taken advantage of recent advances in speed (or bugfixes). Please consider downloading Gargoyle instead. (Gargoyle is also recommended for Linux and Windows users, though the latter have the option of Windows Glulxe/Windows Git.)

A minimalist exercise with Glimmr Form Fields, showing just one field.

A minimal implementation of Glimmr Form Fields.

Advertisements

Comments on: "New Releases: Glimmr Form Fields and Glulx Input Loops" (4)

  1. That! is hardcore.

    Also, pretty blog.

  2. I still haven’t come up with a practical IF-related use for it

    Character creation? I have a fantasy of a roguelike about maneuvering around a party, which would start with selecting character stats by filling out an online dating profile.

    • I like the online dating profile! I suppose any game that begins with questions (What is your name? Are you male or female? etc.) could take advantage of form fields, as long as that would be appropriate to the feel of the game.

      (I suppose this is a good time to note that the visual presentation of Glimmr form fields is much more flexible than it might seem from the screenshots above–any graphic image can in principle be a field. So even if the design I used here isn’t a good match for your game, you can design the form fields interface any way you want.)

  3. […] Comments While working on another project, I found that I really needed much more control over Inform’s input loops. I put together an […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: