Flexible Windows

version 13/130803 by Jon Ingold

  • Home page
  • Beginning
  • Previous
  • Next



  • Section - Background colours

    Include Glulx Text Effects by Emily Short.

    Table of Common Color Values (continued)
    glulx color value  assigned number  
    g-placenullcol  0  
    g-darkgreen  25600  
    g-green  32768  
    g-lime  65280  
    g-midnightblue  1644912  
    g-steelblue  4620980  
    g-terracotta  11674146  
    g-navy  128  
    g-mediumblue  205  
    g-blue  255  
    g-indigo  4915330  
    g-cornflowerblue  6591981  
    g-mediumslateblue  8087790  
    g-maroon  8388608  
    g-red  16711680  
    g-deeppink  16716947  
    g-brown  9127187  
    g-darkviolet  9699539  
    g-khaki  12433259  
    g-silver  12632256  
    g-crimson  14423100  
    g-orangered  16729344  
    g-gold  16766720    
    g-darkorange  16747520  
    g-lavender  16773365  
    g-yellow  16776960  
    g-pink  16761035  

    A g-window has a glulx color value called back-colour. The back-colour of a g-window is usually g-placenullcol. The back-colour property translates into I6 as "back_colour".

    Before constructing when the type of the pending g-window is g-text-buffer (this is the set text-colours rule):
        set the background text-colour of the pending g-window;

    After constructing when the type of the pending g-window is g-text-buffer (this is the reset text-colours rule):
        reset the background text-colour of the pending g-window;

    After constructing when the type of the pending g-window is g-graphics (this is the colour-graphics rule):
        set the background colour of the pending g-window;

    To set the background text-colour of (g - a g-window):
    (- SetBTcol({g}); -).

    To reset the background text-colour of (g - a g-window):
    (- if ({g} has g_present) glk_window_clear({g}.ref_number);
        ResetBTCol();
    -)

    To set the background colour of (g - a g-window):
    (- if ({g} has g_present) SetBCol({g}.ref_number, {g}.back_colour);
    -).

    Include
    (-

    Constant glulx_colour_table = (+Table of Common color Values+);

    [ ColVal c i max;
        max=TableRows(glulx_colour_table);
        for ( i=1:i<=max:i++ ) {
            if (TableLookUpEntry(glulx_colour_table, 1, i) == c)
                return TableLookUpEntry(glulx_colour_table, 2, i);
        }
    ];

    [ ResetBTCol i;
    for (i = 0: i < style_NUMSTYLES : i++)
        glk_stylehint_clear(wintype_textbuffer, i, stylehint_backcolor);
    ];


    [ SetBTCol gwin col i;
    col = gwin.back_colour;
    if (col == (+g-placenullcol+)) rfalse;
    col = ColVal(col);
    for (i = 0: i < style_NUMSTYLES : i++)
    glk_stylehint_set(wintype_Textbuffer, i, stylehint_BackColor, col);
    ];

    [ SetBCol win col result;
        if (col ~= (+g-placenullcol+)) glk_window_set_background_color(win, ColVal(col));
        glk_window_clear(win);
    ];

    -)


    Include
    (-
        [ InitGlkWindow winrock i col;
            switch(winrock){
                GG_MAINWIN_ROCK:
                    if ((+main-window+).back_colour ~= (+g-placenullcol+))
                    { col = ColVal((+main-window+).back_colour);
                        for (i = 0: i < style_NUMSTYLES : i++)
                        glk_stylehint_set(wintype_TextBuffer, i, stylehint_BackColor, col);
                        if ((+main-window+).ref_number) glk_window_clear((+main-window+).ref_number);
    glk_stylehint_set(wintype_TextBuffer, style_Emphasized, stylehint_Oblique, 1);
    glk_stylehint_set(wintype_TextBuffer, style_Emphasized, stylehint_weight, 0);

                        rfalse;
                    }
                GG_STATUSWIN_ROCK:
                    if (USE_NO_STATUS_LINE == 1) rtrue; ! - Aaron Reed
            }
            
            rfalse;

        ];

    -) after "Definitions.i6t".