Hi! I have a question about the dialogizer module. Is it possible to have buttons on a card that could be clicked while the module is running? I'm trying to find a way for the player to be able to either quit the game or mute sounds during dialogs, if possible. Thanks!
Viewing post in General Decker Question and Answer Thread
Dialogizer runs in a "blocking" manner; Decker won't process click[] events or other interactions with ordinary widgets while Dialogizer is active, so you wouldn't be able to furnish that kind of functionality with ordinary buttons on a card.
You could, however, use the animate[] event that Dialogizer continuously emits while dialog boxes are open, in combination with the Pointer interface- which provides live-updating access to the state of the user's pointing device- to explicitly detect clicks on extra buttons.
If pointer.start and pointer.pos are within a given rectangle and pointer.up is truthy, you'll know the "button" corresponding to that rectangle was clicked. You could even physically have buttons with click event handlers on the card if you want. Presuming a button called "menu", you might have an animate[] script something like:
on within pos rect do min(pos>rect.pos)&(pos<rect.pos+rect.size) end on animate do if within[pointer.start menu]&within[pointer.pos menu]&pointer.up menu.event.click end end
Make sense?
Note that this technique works best when a dd.ask[] dialog is open; ordinary dd.say[] dialogs will automatically advance for any pointer click irrespective of what else happens in animate[]. If you really want fine-grained control here you might need to make minor alterations to the dialogizer module itself. I'll ponder this kind of use-case and possibly make some enhancements to the module in the future.
Just as a followup, Decker 1.66 makes this technique a tiny bit more powerful:
By altering app.cursor it's possible for blocking scripts to override the appearance of a mouse cursor. Setting
app.cursor:"point"
While the mouse is over a clickable "button" (real or simulated) will improve the illusion that there's a real widget there.
The new gamepad interface opens up additional input options, too: the "left"/"right" directional buttons and the "cancel" button aren't used by Dialogizer, so any of them could be used to exit a game, mute sound effects, summon a menu, etc, via the keyboard or a physical game controller.