Confirmation screen when clicking X to close game?

Started by Paul Franzen, Mon 20/06/2016 03:52:26

Previous topic - Next topic

Paul Franzen

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?
The Beard in the Mirror (formerly testgame) - Out now on Steam! http://store.steampowered.com/app/385840
Other games I've worked on: http://paulmfranzen.com/games/

Slasher

#1
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

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
{

Gilbert

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).

Danvzare

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.

Crimson Wizard

AGS does not support this at the moment.
Same with Alt+F4 Windows combination, or right-clicking on task bar and choosing "Close window".

Paul Franzen

Ah well, one less thing to code, at least. Thanks for the responses, everyone!
The Beard in the Mirror (formerly testgame) - Out now on Steam! http://store.steampowered.com/app/385840
Other games I've worked on: http://paulmfranzen.com/games/

SMF spam blocked by CleanTalk