Glulx Status Window Control

version 1/100630 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Section - Replacement of the library's Window Color routines

    Include (-

    [ VM_SetWindowColours f b window doclear i fwd bwd swin;
    if (clr_on && f && b) {
    if (window) swin = 5-window; ! 4 for TextGrid, 3 for TextBuffer

    fwd = MakeColourWord(f);
    bwd = MakeColourWord(b);
    for (i=0 : i<style_NUMSTYLES: i++) {
    if (f == CLR_DEFAULT || b == CLR_DEFAULT) { ! remove style hints
    glk_stylehint_clear(swin, i, stylehint_TextColor);
    glk_stylehint_clear(swin, i, stylehint_BackColor);
    } else {
    glk_stylehint_set(swin, i, stylehint_TextColor, fwd);
    glk_stylehint_set(swin, i, stylehint_BackColor, bwd);
    }
    }

    ! Now re-open the windows to apply the hints
    if (gg_statuswin) glk_window_close(gg_statuswin, 0);
    gg_statuswin = 0;

    if (doclear || ( window ~= 1 && (clr_fg ~= f || clr_bg ~= b) ) ) {
    glk_window_close(gg_mainwin, 0);
    gg_mainwin = glk_window_open(0, 0, 0, wintype_TextBuffer, GG_MAINWIN_ROCK);
    if (gg_scriptstr ~= 0)
    glk_window_set_echo_stream(gg_mainwin, gg_scriptstr);
    }

    gg_statuswin = glk_window_open(gg_mainwin, statuswin_pos, statuswin_cursize, wintype_TextGrid, GG_STATUSWIN_ROCK);

    if (statuswin_current && gg_statuswin) VM_MoveCursorInStatusLine(); else VM_MainWindow();

    if (window ~= 2) {
    clr_fgstatus = f;
    clr_bgstatus = b;
    }
    if (window ~= 1) {
    clr_fg = f;
    clr_bg = b;
    }
    }
    ];

    [ VM_RestoreWindowColours; ! used after UNDO: compare I6 patch L61007
    if (clr_on) { ! check colour has been used
    VM_SetWindowColours(clr_fg, clr_bg, 2); ! make sure both sets of variables are restored
    VM_SetWindowColours(clr_fgstatus, clr_bgstatus, 1, true);
    VM_ClearScreen();
    }
    ];

    [ MakeColourWord c;
    if (c > 9) return c;
    c = c-2;
    return $ff0000*(c&1) + $ff00*(c&2 ~= 0) + $ff*(c&4 ~= 0);
    ];

    -) instead of "Window Colours" in "Glulx.i6t".