Inform - Support - Patches

About Patches  

Compiler  
Library  

DM4 Errata  

Issue L61007

Colors incorrect after RESTORE/UNDO
Submitted by: Adam Cadre     Appeared in: Libraries long ago     Fixed in: Library 6/11
Problem

Let's say that in the game you're writing, you want the color set to change at some point: maybe Scene One is black-on-white and Scene Two is white-on-blue, for instance. This is easy enough to pull off, thanks to @set_colour. But then let's say that the player wants to UNDO upon reaching the new scene (forgot to bring her hat, or some such), or later on wants to restore a saved game from Scene One. Unless a few lines in the library are tweaked, the original color set will not be restored: Scene One will be in white-on-blue. Eeeagh!

Solution

First, you need to make sure you're keeping track of your color changes. Create three global variables:

  Global fg;     ! foreground color
  Global bg;     ! background color
  Global clr_on; ! is there color?

Many interpreters have a hard time with color, so it's a very good idea to ask the player whether to use color or not. Place the following at the beginning of Initialise:

  @erase_window -1;
  print "^^^Would you like color? ";
  clr_on = YesOrNo();

And, just for convenience, let's make a routine for setting the color variables and the screen colors at once:

  [ Color f b;
    if (clr_on) { fg = f; bg = b; @set_colour f b; }
  ];

Now, to restore the color upon a restore, go to VerbLibm.h and replace SaveSub with the following:

  [ SaveSub flag;
    @save -> flag;
    switch (flag) {
     0: L__M(##Save, 1);
     1: L__M(##Save, 2);
     2: if (clr_on) {
           @set_colour fg bg;
           @erase_window -1;
        }
        L__M(##Restore, 2);
    }
  ];

Restoring color upon an undo is slightly trickier. Load up Parserm.h, look for the comment that says "Undo handling", and then find the part that looks like the following and add the specified lines:

  if (i==2)
  {
     if (clr_on) {          ! add this
        @set_colour fg bg;  ! add this
        @erase_window -1;   ! add this
     }                      ! add this
     style bold;
     print (name) location, "^";
     style roman;
     L__M(##Miscellany,13);
     just_undone=1;
     jump FreshInput;
  }


Last updated 17 April 2013. This site is no longer supported; information may be out of date.
Maintained as a historical archive by the Interactive Fiction Technology Foundation. Copyright 1993-2018 IFTF, CC-BY-SA unless otherwise noted.
This page was originally managed by Roger Firth.