Glimmr Canvas Editor

version 1/100805 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter - Button animation
    [This is a customized version of the "default command replacement by graphlinks rule" from Graphic Hyperlinks for Flexible Windows extension. The only real difference is that it provides for an animation when buttons are pressed.]

    The currently depressed button is a sprite that varies. The currently depressed button is info_button.

    A clicking graphlink rule (this is the button-responsive command replacement by graphlinks rule):
        repeat through the Table of Graphlink Glulx Replacement Commands in reverse order:
            if the current graphlink window is g-win entry:
                if the current graphlink x >= p-left entry and the current graphlink x <= p-right entry and the current graphlink y >= p-top entry and the current graphlink y <= p-bottom entry:
                    cancel input in main window;
                    change the current graphlink to linkid entry;
                    change the glulx replacement command to replacement entry;
                    if the current graphlink is a button:
                        now the currently depressed button is the current graphlink;
                        now the image-ID of the currently depressed button is the active-state of the currently depressed button;
                        follow the window-drawing rules for the assigned window of the currently depressed button;
                        revert the button after 0.1500 seconds;
                    rule succeeds;
        now glulx replacement command is "";
        rule fails.

    The button-responsive command replacement by graphlinks rule is listed before the default command replacement by graphlinks rule in the clicking graphlink rules.

    A glulx timed activity rule (this is the redraw button from timer rule):
        stop the timer;
        now the image-ID of the currently depressed button is the inactive-state of the currently depressed button;
        follow the window-drawing rules for the assigned window of the currently depressed button.
        
    [The timer introduces a certain wild-card element into things. The upshot is that, when we undo, the events that happen after the timer fires are not "remembered"--so, the state of the button will still be active after we undo, and the timer event will not fire. The after undoing an action rule here requests the timer event immediately after undoing, so that the button will return to its initial state as needed. This has the added benefit of indicating to the player exactly what is being reconstructed after UNDO, the pressing of the button. This is rather primitive, in that the timer event is requested no matter the situation (i.e, regardless of whether the last turn involved a button press; however, things are structured so that this is harmless.]
        
    After undoing an action:
        revert the button after 0.1500 seconds;