Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Akril15 on Wed 18/11/2015 00:32:58

Title: "Pause game when shown" GUIs suddenly behaving like "always shown" GUIs (SOLVED)
Post by: Akril15 on Wed 18/11/2015 00:32:58
I've discovered a problem with my game's save/restore, quit, and similar GUIs: they're supposed to pause the game when they're visible, but now, for some reason, if I click outside their windows, the game acts as if it isn't paused and react as if the GUI wasn't there, by running an interaction associated with whatever part of the screen the mouse was over when I clicked. The GUI either temporarily disappears while the interaction runs or stays gone permanently. Initially, it would run a "touch" interaction response, which I tried to get around by removing all instances of me changing the mouse to use the touch mode when one of those GUIs was opened, but now it acts like the walk cursor whenever I click outside the window, making the main character walk to the point nearest to the spot I clicked (this also happens when I close a GUI window).

I've looked at the old versions of this game that I've saved over the past few months and found a version when this didn't happen, but I've compared both this and the version I saved immediately after it, and I can't find any significant differences between the two games' general settings, unhandled_event, repeatedly_execute, repeatedly_execute_always, on_mouse_click, game_start or on_event sections (the GUIs are identical as well). I do have one section of script that closes the inventory window if the player clicks outside it, but the code for this is identical in both versions.

Is there anything else that I might have overlooked?
Title: Re: "Pause game when shown" GUIs suddenly behaving like "always shown" GUIs
Post by: Retro Wolf on Wed 18/11/2015 04:33:16
Perhaps something toggled in the general settings tab?
Title: Re: "Pause game when shown" GUIs suddenly behaving like "always shown" GUIs
Post by: Akril15 on Wed 18/11/2015 08:08:06
Quote from: Retro Wolf on Wed 18/11/2015 04:33:16
Perhaps something toggled in the general settings tab?
I checked the general settings for both versions, and there are no differences.
Title: Re: "Pause game when shown" GUIs suddenly behaving like "always shown" GUIs
Post by: Slasher on Wed 18/11/2015 12:48:49
QuoteI've discovered a problem with my game's save/restore, quit, and similar GUIs: they're supposed to pause the game when they're visible

have you added any scripting that affects these gui's?

if you have please would you post your code.
Title: Re: "Pause game when shown" GUIs suddenly behaving like "always shown" GUIs
Post by: Akril15 on Wed 18/11/2015 20:04:00
Quote from: slasher on Wed 18/11/2015 12:48:49
have you added any scripting that affects these gui's?

if you have please would you post your code.
If I have, I have no idea what it could be. I've been looking through both versions trying to find some code that might cause problems with the GUIs, but I haven't been able to find anything.

Also, which code specifically do you want? This game is pretty big; there are over 8000 lines of code in the global script alone.

EDIT: I've gone through the global scripts for both versions again and tried copy+pasting scripts from the old version into the new one. Even when I tried copy+pasting the entire global script, the new version still had the same problem, and all the GUIs I mentioned earlier seem to have the exact same settings.
Title: Re: "Pause game when shown" GUIs suddenly behaving like "always shown" GUIs
Post by: Akril15 on Sun 22/11/2015 20:05:59
Sorry for bumping the thread, but does anyone have any idea what might be going on here, and how to fix it?
Title: Re: "Pause game when shown" GUIs suddenly behaving like "always shown" GUIs
Post by: Slasher on Sun 22/11/2015 20:29:58
food for thought

i generally make all these type of gui's full screen size with transparent background and border so you see the background around the gui.  Make sure it's 'clickable' so you can't click underneath the gui therefore won't set off any events.

worth a try.
Title: Re: "Pause game when shown" GUIs suddenly behaving like "always shown" GUIs
Post by: Khris on Sun 22/11/2015 21:15:44
It is important to note that pausing the game will not stop all script functions dead in their tracks.
The game still has to implement part of the fact that it's paused manually, for instance by exiting the on_mouse_click function, or not processing clicks if (IsGamePaused()).

The default game does this:
  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button == eMouseLeft) {
  ...


If somehow the logic got changed, mouse clicks are processed as usual even if the game is technically paused.
Title: Re: "Pause game when shown" GUIs suddenly behaving like "always shown" GUIs
Post by: MiteWiseacreLives! on Sun 22/11/2015 23:06:01
I make a little function that iterates through hotspots characters and objects and sets them to clickable = false
And then run it when opening a GUI and again when closing one. It works, maybe it's hacky I don't know. I can post the script when I get to my comp if you like.
Title: Re: "Pause game when shown" GUIs suddenly behaving like "always shown" GUIs
Post by: Khris on Sun 22/11/2015 23:27:37
One can also turn on a transparent, clickable GUI that covers the screen and catches all clicks.
Or, one can fix the actual problem instead of writing awkward code to work around the symptoms.
Title: Re: "Pause game when shown" GUIs suddenly behaving like "always shown" GUIs
Post by: Akril15 on Mon 23/11/2015 17:32:19
The full-screen transparent GUI sounds like a good idea, but won't that make the game lag? I recall trying something like this before to get around a similar problem with a previous game (true-color 640x480, like this one), and I remember a lot of lag happening.

(I can't access my game right now so I can't test anything else just yet.)
Title: Re: "Pause game when shown" GUIs suddenly behaving like "always shown" GUIs
Post by: Slasher on Mon 23/11/2015 17:41:37
i've never had that issue...
Title: Re: "Pause game when shown" GUIs suddenly behaving like "always shown" GUIs
Post by: Akril15 on Wed 25/11/2015 08:40:54
Quote from: Khris on Sun 22/11/2015 21:15:44
It is important to note that pausing the game will not stop all script functions dead in their tracks.
The game still has to implement part of the fact that it's paused manually, for instance by exiting the on_mouse_click function, or not processing clicks if (IsGamePaused()).

The default game does this:
  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button == eMouseLeft) {
  ...


If somehow the logic got changed, mouse clicks are processed as usual even if the game is technically paused.
This is strange -- my game's current on_mouse_click section has been changed, but the on_mouse_click section from the earlier version of the game where this problem didn't happen is the virtually identical. Still, I managed to fix the problem by moving the IsGamePaused section to the top. My inventory was broken for a little while, but I managed to fix it by moving the scripting for it above IsGamePaused.

Thank you very much for the help, everyone!