Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Paul Franzen on Mon 20/06/2016 03:52:26

Title: Confirmation screen when clicking X to close game?
Post by: Paul Franzen on Mon 20/06/2016 03:52:26
This feels like the dumbest question in the world, but I've searched every permutation of "click X" and "exit game confirmation" that I can think of, and still, no dice.

Right now, if you click the exit button on my game's main menu, or on the in-game navigational bar, a GUI pops up asking "Are you sure you want to quit?". Is there any way to achieve a similar effect, when the user clicks the X button on the upper-right corner of the window?

Or, in other words: Is there a way to define what happens when the user clicks X, so that I can bring up the confirmation GUI, instead of having the game close automatically?
Title: Re: Confirmation screen when clicking X to close game?
Post by: Slasher on Mon 20/06/2016 05:21:53
You could have a button displaying X  or something positioned on the gui and use options below (Use Buttons properties panel to add script);
Code (ags) Select

function BQuit_OnClick(GUIControl *control, MouseButton button) // BQuit is example button name
{
// On clicking BQuit button options

QuitGame(0);// Will exit game
QuitGame(1); // Will bring up confirmation gui
{
Title: Re: Confirmation screen when clicking X to close game?
Post by: Gilbert on Mon 20/06/2016 06:46:20
Read the OP more carefully though, it's about the close button on the Window border, not within the game screen.
I haven't followed the recent changes of the engine, but the answer is probably 'no', or at least there is no trivial way to do this (yet).
Title: Re: Confirmation screen when clicking X to close game?
Post by: Danvzare on Mon 20/06/2016 10:23:49
Like Gilbert said, to my knowledge there's nothing that allows you to do this.

If you're really worried that someone will accidentally turn the game off by pressing the X in the upper right corner though, just make the game start in fullscreen. Anyone who is smart enough to make the game windowed, will certainly be smart enough to not accidentally turn the game off by pressing that X button.
Title: Re: Confirmation screen when clicking X to close game?
Post by: Crimson Wizard on Mon 20/06/2016 12:11:13
AGS does not support this at the moment.
Same with Alt+F4 Windows combination, or right-clicking on task bar and choosing "Close window".
Title: Re: Confirmation screen when clicking X to close game?
Post by: Paul Franzen on Mon 20/06/2016 17:02:12
Ah well, one less thing to code, at least. Thanks for the responses, everyone!