Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Scavenger on Mon 15/02/2016 20:29:52

Title: Is there a way to check if the Dialog GUI is visible?
Post by: Scavenger on Mon 15/02/2016 20:29:52
I'm trying to create a dialog GUI for my game, and as part of my interface I have a semitransparent black box* that underlays most GUIs. It's done with:

Code (AGS) Select
Translucence.CreateOverlay (50, dialog_bg.Graphic, 128, 1, info.X, info.Y);

and I can remove it with:

Code (AGS) Select
Translucence.DeleteOverlay (50);

I need the overlay up when the dialog options are being shown, and to be deleted when the dialog options go away, but I'm not sure how to check whether the dialog options are being shown or not. If it helps, I'm using Austauber's CustomDialogGUI module, so using the custom dialog rendering functions is no problem. Is there any way to do this, or am I stuck with putting the code to turn it off in the dialog code itself?

*Using 8-bit mode, so I can't use the standard translucency functions.
Title: Re: Is there a way to check if the Dialog GUI is visible?
Post by: monkey0506 on Wed 17/02/2016 03:41:04
There's currently no way to know if the dialog GUI is visible, except when using custom dialog rendering functions (which you said you are, via the module). I'd have to do some testing to be certain, but I believe that rep_ex_always runs each game loop before dialog_options_render. Unless I'm mistaken about that, then it would be sufficient to simply use a bool to track whether the GUI was shown, setting it to false in rep_ex_always and then to true in dialog_options_render. AGS 3.4.0 introduces dialog_options_rep_exec, which may also be of use here, but I'd have to test it out to be sure (away from AGS right now).
Title: Re: Is there a way to check if the Dialog GUI is visible?
Post by: Scavenger on Wed 17/02/2016 06:47:27
I'm using 3.2.1 at the moment, so I can't use dialog_options_rep_exec yet.

The method you supplied works, but when I enable "run game loops while dialog options are visible" in the settings, it immediately turns the translucent background off. It seems that dialog_options_render doesn't run every loop, only when the player moves over a different dialog option. I'll have to either not run game loops while the dialog is up, or think of a different way.

It does work perfectly when game loops aren't running at the same time, though!
Title: Re: Is there a way to check if the Dialog GUI is visible?
Post by: monkey0506 on Sun 21/02/2016 07:12:05
Regarding dialog_options_render not updating often enough, you could also try working with dialog_options_get_active. That has to be run every loop AFAIK. At the very least, it should be invoked any time the mouse moves, so it can update the active option ID.