Provides a graphics window in one part of the screen, in which the author can place images; with provision for scaling, tiling, or centering images automatically, as well as setting a background color. Glulx only.
Simple Graphical Window builds on Flexible Windows to provide some rules for different ways of drawing in graphics windows. This extension creates a window called the graphics window, which may be positioned as usual per Flexible Windows. **** Rules for drawing in windows **** Whenever Inform needs to re-fill the window -- at the start of the game, or when a saved game is restored, or when the player resizes the window manually -- Simple Graphical Window will follow a rule that varies, the "current graphics drawing rule". The author may set this to any of the following: (1) (The default) The bland graphics drawing rule. Blanks the window to the background color and does nothing else. (2) The standard placement rule. The standard placement rule fills the window with a background color, then draws "the currently shown picture" (a figure-name that varies, and which the author can reset during the game). The picture is centered in the available screen space, unless it is too large, in which case it is scaled down proportionally to fit. A picture is never scaled up, on the grounds that upscaling images usually produces unattractively fuzzy results. Note that this and rules 2-4 will all behave incorrectly if we don't have at least one figure defined in our game source. In that case, see rule 5. (3) The centered scaled drawing rule. Same as the standard placement rule, except that it does not fill the window with a background color first. This means that if there is something previously printed in the graphics window, this may overlap it. (4) The fully scaled drawing rule. Fills the window completely with the currently shown picture, regardless of proportion. This is unlikely to look good with images of any complexity, but is included for the sake of completeness. (5) The tiled drawing rule. Tiles the currently shown picture to fill the available space horizontally and vertically. To set this rule at the beginning, we would write a before starting the virtual machine rule: Before starting the virtual machine: now the current graphics drawing rule is the bland graphics drawing rule; It is important to use the "starting the virtual machine" activity because this occurs before the first window drawing happens; where as a "when play begins" may run after the graphics window has already been opened. If we need to redraw the image in the window, we can write follow the current graphics drawing rule; For instance if we were adding an image to the screen every time the player moved, we might write something like Carry out looking: now currently shown picture is the room illustration of the location; follow the current graphics drawing rule; ... where the room illustration is defined for each room in the game. (The extension "Location Images" implements this idea in full.) The author may also create other drawing rules of his own devising and make any of these the current graphics drawing rule, as needed. It will probably be necessary to specify graphics drawing rules in Inform 6 unless the author intends a fairly simple combination of the rules already provided here; for more information about graphics drawing in Glulx, see http://adamcadre.ac/gull/ In writing these rules, it's worth bearing in mind that the rule should be able to reconstruct the entire contents of the graphics window every time it is called, rather than relying on things drawn there during previous moves; otherwise, the graphics window will not redraw properly when the game is reloaded or a turn is undone. Example: * Mondrian - A strip of randomly varying color along the left edge of the screen *: "Mondrian" Include Simple Graphical Window by Emily Short. Stark Room is a room. The measurement of the graphics window is 10. The position of the graphics window is g-placeleft. Before starting the virtual machine: now the current graphics drawing rule is the bland graphics drawing rule. Table of Common Color Values name value "red" "$0000FF" "green" "$00FF00" "yellow" "$00FFFF" "cyan" "$FFFF00" "magenta" "$FF00FF" "blue" "$FF0000" "royal blue" "$AA0000" Every turn: if glulx graphics is supported: choose a random row in the Table of Common Color Values; now the background color of the graphics window is the value entry; follow the current graphics drawing rule. Test me with "z / z / z / z / z / z".