Using the Flexible Windows extension, how can I depict a scaled image in my graphics window?

+1 vote
94 views
asked Jul 17 in Authoring by anonymous
edited Jul 17

My game was working fine with Flexible Windows until something, somewhere broke it (it gave me errors when running, though both the I7- and I6-compilers ran fine). I updated the plugin and, after updating loads of others (dependencies, like Glulx Text Effects), finally got the thing to compile again.

However, the plugin has been rewritten from scratch in the meantime, improving or simplifying it in some ways but also taking away some functions (such as bordered windows).

Previously, I could display figures in the main window using Inform's standard "display"action, and depict them, scaled to fit, in my graphics window using the Flexible Windows "depict" action that was in one of the examples.

That 'depict' code no longer works. When compiling, the I6 compiler gives two errors:

auto.inf(61696): Error:  No such constant as "WindowSize"
auto.inf(61717): Error:  No such constant as "ref_number"

Here is the lump of mostly I6 code that hooks into the older version of Flexible Windows, but can't anymore because it's been rewritten.

To depict (f - a figure-name):
    now the current image is f;
    follow the window-drawing rules for the graphics-window.

Window-drawing rule for the graphics-window (this is the draw scaled image rule):
    if graphics-window is g-unpresent, rule fails;
    clear the graphics-window;
    draw scaled copy of current image in graphics-window.

To draw scaled copy of (f - a figure-name) in (g - a g-window):
    (- DrawScaled({f}, {g}); -).

Include (-

    ! Doing scaling calculations in I6 lets us handle bigger numbers

    [ GetImageSize curimg index result;
        result = glk_image_get_info( ResourceIDsOfFigures-->curimg, gg_arguments, gg_arguments+WORDSIZE);
        return gg_arguments-->index;
    ];

    [ DrawScaled figure g w_total h_total graph_height graph_width w_offset h_offset;
    graph_height = WindowSize(g, 1);
    graph_width = gg_arguments-->0;
    w_total = GetImageSize(figure, 0);
    h_total = gg_arguments-->1;

    if (graph_height - h_total < 0) ! if the image won't fit, find the scaling factor
    {
        w_total = (graph_height * w_total)/h_total;
        h_total = graph_height;

    }

    if (graph_width - w_total < 0)
    {
        h_total = (graph_width * h_total)/w_total;
        w_total = graph_width;
    }

    w_offset = (graph_width - w_total)/2; if (w_offset < 0) w_offset = 0;
    h_offset = (graph_height - h_total)/2; if (h_offset < 0) h_offset = 0;

    glk_image_draw_scaled(g.ref_number, ResourceIDsOfFigures-->figure, w_offset, h_offset, w_total, h_total);
    ];

-).

Since I'm not able to write I6 code myself, my question is as follows: how do I modify this code to work with the most recent version of Flexible Windows from Github, or what different code can I use to get the same results?

1 Answer

0 votes
answered Jul 18 by Dannii (329 points)
 
Best answer

Replace WindowSize with FW_WindowSize and ref_number with (+ ref number +).

This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...