Contents
Back
Forward

32. Boxes, menus and drawings

Yes, all right, I won't do the menu... I don't think you realise how long it takes to do the menu, but no, it doesn't matter, I'll hang the picture now. If the menus are late for lunch it doesn't matter, the guests can all come and look at the picture till they are ready, right?

...John Cleese and Connie Booth, Fawlty Towers

One harmless effect, though not very special, is to ask the player a yes/no question. To do this, print up the question and then call the library routine YesOrNo, which returns true/false accordingly.

The status line is perhaps the most distinctive feature of Infocom games in play. This is the (usually highlighted) bar across the top of the screen. Usually, the game automatically prints the current game location, and either the time or the score and number of turns taken. It has the score/turns format unless the directive

Statusline time;
has been written in the program, in which case the game's 24-hour clock is displayed.

/\ If you want to change this, just Replace the parser's private DrawStatusLine routine. This requires a little assembly language: see the next section for numerous examples.

About character graphic drawings: on some machines, text will by default be displayed in a proportional font (i.e., one in which the width of a letter depends on what it is, so that for example an 'i' will be narrower than an 'm'). If you want to display a diagram made up of letters, such as a map, the spacing may then be wrong. The statement font off ensures that any fancy font is switched off and that a fixed-pitch one is being used: after this, font on restores the usual state.

!!WARNING:
Don't turn the font on and off in the middle of a line; this doesn't look right on some machines.

/\ When trying to produce a character-graphics drawing, you sometimes want to produce the \ character, one of the four "escape characters'' which can't normally be included in text. A double @ sign followed by a number includes the character with that ASCII code; thus:
@@64 produces the literal character @
@@92 produces \ @@94 produces ^ @@126 produces ~

/\/\ Some interpreters are capable of much better character graphics (those equipped to run the Infocom game 'Beyond Zork', for instance). There is a way to find out if this feature is provided and to make use of it: see the Z-Machine Standards Document.

/\/\ A single @ sign is also an escape character. It must be followed by a 2-digit decimal number between 0 and 31 (for instance, @05). What this prints is the n-th 'variable string'. This feature is not as useful as it looks, since the only legal values for such a variable string are strings declared in advance by a LowString directive. The String statement then sets the n-th variable string. For details and an example, see the answer to the east-west reversal exercise in Section 10.

A distinctive feature of later Infocom games was their use of epigrams. The assembly language required to produce this effect is easy but a nuisance, so there is an Inform statement to do it, box. For example,

box "I might repeat to myself, slowly and soothingly,"
    "a list of quotations beautiful from minds profound;"
    "if I can remember any of the damn things."
    ""
    "-- Dorothy Parker";
Note that a list of one or more lines is given (without intervening commas) and that a blank line is given by a null string. Remember that the text cannot be too wide or it will look awful on a small screen. Inform will automatically insert the boxed text into the game transcript, if one is being made. The author takes the view that this device is amusing for irrelevant quotations but irritating when it conveys vital information (such as "Beware of the Dog"). Also, some people might be running your game on a laptop with a vertically challenged screen, so it is polite to provide a "quotes off'' verb.

A snag with printing boxes is that if you do it in the middle of a turn then it will probably scroll half-off the screen by the time the game finishes printing for the turn. The right time to do so is just after the prompt (usually >) is printed, when the screen will definitely scroll no more. You could use the Prompt: slot in LibraryMessages to achieve this, but a more convenient way is to put your box-printing into the entry point AfterPrompt (called at this time each turn).

??EXERCISE 88:
(link to
the answer)
Implement a routine Quote(n) which will arrange for the n-th quotation (where 0 <= n <= 49 ) to be displayed at the end of this turn, provided it hasn't been quoted before.

Sometimes one would like to provide a menu of text options (for instance, when producing instructions which have several topics, or when giving clues). This can be done with the DoMenu routine, which imitates the traditional "Invisiclues'' style. By setting pretty_flag=0 you can make a simple text version instead; a good idea for machines with very small screens. Here is a typical call to DoMenu:

DoMenu("There is information provided on the following:^
        ^     Instructions for playing
        ^     The history of this game
        ^     Credits^",
        HelpMenu, HelpInfo);
Note the layout, and especially the carriage returns. The second and third arguments are themselves routines. (Actually the first argument can also be a routine to print a string instead of the string itself, which might be useful for adaptive hints.) The HelpMenu routine is supposed to look at the variable menu_item. In the case when this is zero, it should return the number of entries in the menu (3 in the example). In any case it should set item_name to the title for the page of information for that item; and item_width to half its length in characters (this is used to centre titles on the screen). In the case of item 0, the title should be that for the whole menu.

The second routine, HelpInfo above, should simply look at menu_item (1 to 3 above) and print the text for that selection. After this returns, normally the game prints "Press [Space] to return to menu'' but if the value 2 is returned it doesn't wait, and if the value 3 is returned it automatically quits the menu as if Q had been pressed. This is useful for juggling submenus about.

Menu items can safely launch whole new menus, and it is easy to make a tree of these (which will be needed when it comes to providing hints across any size of game).

??EXERCISE 89:
(link to
the answer)
Code an "Invisiclues''-style sequence of hints for a puzzle, revealed one at a time, as a menu item.

Finally, you can change the text style. The statement for this is style and its effects are loosely modelled on the VT100 (design of terminal). The style can be style roman, style bold, style reverse or style underline. Again, poor terminals may not be able to display these, so you shouldn't hide crucial information in them.

*REFERENCES:
'Advent' contains a menu much like that above.
The "Infoclues'' utility program translates UHS format hints (a standard, easy to read and write layout) into an Inform file of calls to DoMenu which can simply be included into a game; this saves a good deal of trouble.

Contents / Back / Forward
Chapter I / Chapter II / Chapter III / Chapter IV / Chapter V / Chapter VI / Appendix
Mechanically translated to HTML from third edition as revised 16 May 1997. Copyright © Graham Nelson 1993, 1994, 1995, 1996, 1997: all rights reserved.