Graphics Windows for Glulx

I’ve just uploaded to Inform’s extension page a couple of new extensions: “Simple Graphics Window”, which allows the author to create a single graphical window, and “Location Images”, a much smaller item which uses this ability to illustrate rooms automatically as the player moves through them (assuming the author has assigned an image to each room).

There’s a lot more that Glulx could do that these extensions don’t address — you can’t have multiple graphics windows, and there’s no provision for additional text windows or for mouse clicks in the graphics area or hyperlinks or any of a number of other things. I am still hoping and expecting that eventually there will be an I7 interface for GWindows — this is a large wheel to try to reinvent. But in the meantime, these extensions cover some simple things that people ask about quite often.

Here are a couple of screenshots of the results:

A sample with Location Images running under Spatterlight:
Spatterlight Thumbnail

And the same thing running under Inform for Mac:
Inform thumbnail

Source code for this sample:

Include Location Images by Emily Short.

Figure of Shadefruit is the file “SmallShadefruit.jpg”.
Figure of Frostweed is the file “Smallfrostweed.jpg”.

Frosty Ground is a room. “Tiny-thorned black twigs grow as ground cover here, flowering in white puffs. Otherwise, the ground is too packed and cold to support any kind of plant life. Pawprints hardened into the soil lead away to the north and east.

Rock steps descend to the west, heading towards warmer climes.” The room illustration is Figure of Frostweed.

Shaded Area is west of Frosty Ground. The room illustration is Figure of Shadefruit.


A sample of a left-side window with an image tiled inside rather than being centered:
Wallflower image

And the code for this:

“Wallflower”

Include Simple Graphical Window by Emily Short.

Victorian Room is a room.

Figure of Spirals is the file “GreenSpirally.png”.

The graphics window proportion is 30. The graphics window position is g-left.

Rule for starting the virtual machine:
now the currently shown picture is the figure of spirals;
now the current graphics drawing rule is the tiled drawing rule.


And an image centered over a tiled background:

center-tiled

With source:

“Wallflower”

Include Simple Graphical Window by Emily Short.

Victorian Room is a room.

Figure of Spirals is the file “GreenSpirally.png”.
Figure of Band is the file “band.jpg”.

The graphics window proportion is 30. The graphics window position is g-left.

Rule for starting the virtual machine:
now the currently shown picture is the figure of spirals;
now the current graphics drawing rule is the new drawing rule.

This is the new drawing rule:
now the currently shown picture is the figure of spirals;
follow the tiled drawing rule;
now the currently shown picture is the figure of band;
follow the centered scaled drawing rule.

13 thoughts on “Graphics Windows for Glulx

  1. Hi, Emily
    Sorry for “off the top”
    But im interesting is it possible to translate inform 7 to russian (using for example unicode)
    I mean the possibility to use russian names and desc. (system language may be english)
    I can offer any language help that could be needed

  2. We are not ourselves developing translated versions of Inform 7; however, some people have managed to make progress towards versions that produce output in French and Spanish, and there is discussion about how to do this at the rakontointeraktiva group:

    http://groups.google.com/group/rakontointeraktiva?lnk=rgh

    Possibly the members of that group would be able to give you some pointers on customizing a Russian version as well; I don’t know. There may be additional challenges. I7 does support unicode output, but I am not sure what the situation would be for input, and there may also be challenges about the structure of Russian (I’m not terribly familiar with Russian grammar) that would make it difficult to adapt.

    If you do have specific requests about what Inform could do to make foreign-language customization easier, please tell us about them; we’re not always very fast about accommodating such things because there is a very long list of requests and suggestions for the language, but that doesn’t mean we aren’t interested in helping where we can, when time becomes available to do so.

  3. Dear Ms Short. First of all thank you for the wonderful extension ‘Simple Graphical Window’. I always wanted to use non-scrolling images and this works great! There is one thing I just can’t figure out. I want to change the picture of a location when the player turns on the light. Something like ‘The room illustration of RmX is Figure of rmx_dark’ to ‘The room illustration of RmX is Figure of rmx_lit’ when the task of LightRmx is recorded as achieved, or when the player is turning the lightswitch. Can I do this? If so, could you please help me in the right direction? TIA, Mark

  4. Dear Ms Short,

    I have tried many things, for example this:
    ===================================================

    Include Location Images by Emily Short.

    A room has a figure-name called room illustration.

    The graphics window proportion is 60.

    The image-setting rule is listed in the carry out looking rules.

    Location Images ends here.

    Figure 1 is the file “v_day.jpg”.
    Figure 2 is the file “v_night.jpg”.
    The valley is a room.
    The room illustration is Figure 1.

    Carry out looking:
    if the player is in the valley for one turn begin;
    The room illustration is Figure 2.
    end if;
    change currently shown picture to the room illustration of the location;
    follow the current graphics drawing rule.

    ====================================================

    I always get this error-message : You wrote ‘The room illustration is Figure 2’ : but this is a phrase which I don’t recognise, etc. I am probably doing something very stupid, but I just can’t figure out what. TIA, Mark

  5. Okay, three things.

    One: “the room illustration is Figure 2” is a sentence you can use when setting up the world. (Inform calls these “assertions”.) It’s a different kind of thing from the phrases you use to *change* the state of the world during play. (There is more about this in the section on phrases.)

    Two: there isn’t just one “room illustration”; “room illustration” is a property of every room in the game. So you want to say something like “the room illustration of the valley” or “the room illustration of the location” (if you want to refer flexibly to whatever room the player is in at the moment.

    So you probably want something more like:

    if the player is in the valley for one turn begin;
    change the room illustration of the location to Figure 2;
    end if;

    Final note: if you have more Inform questions (even if they’re about specific extensions) probably the fastest and most reliable way to find out the answers is to post to rec.arts.int-fiction. (There’s a link here under “Forums” to the web interface for the forum, but if you have a newsreader, you could also use that.) If you have bugs to report, it’s best to send those straight to the author of whatever you’re using, but otherwise the rest of the IF community can probably help you.

  6. Hello,

    It’s working very well and it’s pleasant to add such features in our games.

    I wanted to add that in my game I couldn’t see the left frame at first, I had to resize the window to make it appear (either in the I7 IDE or in the final game), so I could make it work by adding :

    When play begins:
    follow the current graphics drawing rule.

    Also some authors may want to release their game both in zcode and in glulx, so it’d be a nice thing to be able to compile in zcode even without the window system when Simple Graphical Window is there.

    “You wrote ‘Include Simple Graphical Window by Emily Short’ : but my copy of Simple Graphical Window by Emily Short stipulates that it is ‘For Glulx Only’. That means it can only be used with certain of the possible compiled story file formats, and at the moment, we don’t fit the requirements.”

    In Inform 6 it was still possible to have such feature with some :

    #ifdef TARGET_ZCODE;
    ! nothing here
    #ifnot; ! TARGET_GLULX;
    ! glulx code
    #endif; !

    but I couldn’t do the same in I7 (the only workaround was to put some brackets when compiling for zcode)

  7. Actually, that is possible to arrange in Inform 7 too, if you specify the inclusion of the extension in a Glulx-only section. Here is what I mean:

    Foo is a room.

    Section 1 – Including the Window (for Glulx only)

    Include Simple Graphical Window by Emily Short.

    Section 2 – All about Bar

    Bar is a man in Foo.

    You will find this compiles for both Glulx and Z.

  8. just to tell it seems the syntax has changed a bit since this tutorial, and this part:

    [now the currently shown picture is the figure of spirals;]

    should be written instead:

    change currently shown picture to the figure of spirals;

  9. Hi Ms Short

    I’m new to learning Inform, but I’m already very impressed with all you’ve contributed to it – thank you for being such a great community member!

    I’d like to use your Location Images extension, but I’m wondering if it is incompatible with the current build of Inform (build 5Z71), since when I try to include it (just using your “Frostweed” code above as a test) the following compile error occurs, referring to line 12 of the extension:

    Problem. You wrote ‘change currently shown picture to the room illustration of the location’, but ‘Currently shown picture’ has the wrong kind of value: the name of a figure rather than an object.

    Any ideas?

    • It looks as though, rather maddeningly, 5Z71 is getting hung up on the property name “room illustration”. If you go through and swap out all instances of that for “room-illustration” (note the hyphen), it appears to work.

      I’m not sure why Inform has gotten more sensitive to this particular wording — I think I’m going to report the current compiler behavior as a bug rather than publishing a revision of the extension, especially as the extension page is between updates at the moment. But in the meantime, I’d advise tweaking the extension text.

      • Hi Emily

        Many thanks for the quick and helpful response. I’ve tried what you suggested and it seems to work fine, now. What a strange bug!

        It might interest you to know that I’ve also been looking at Jon Ingold’s Flexible Windows (separately from Simple Graphical Window; I know they’re not compatible) and Inform produced an internal error! Seems as though the current build doesn’t like extensions very much – at least the ones I’d like to use, heh.

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