Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Ghostlady on Tue 26/06/2007 03:52:09

Title: Load, Save, Quit, Gui
Post by: Ghostlady on Tue 26/06/2007 03:52:09
I am creating a load, save, quit, play gui.  I have buttons for each function.  All buttons are working fine except the quit.  The difference here is that if the quit button is clicked, a label will appear on the gui with two new buttons.  The label will ask if the player really wants to quit and then the player will select the yes or no button that appeared when they clicked the quit button. The problem is, when the quit is clicked, the gui goes away.  If you bring the gui back up again, the label is now showing with the text and the yes and no buttons are also showing.  The buttons now work.  So how do I stop the gui from shutting down when the quit button is clicked?
Title: Re: Load, Save, Quit, Gui
Post by: Buckethead on Tue 26/06/2007 08:24:09
You should use

QuitGame(0);

This quits the game at once with out asking for a confirm.
Title: Re: Load, Save, Quit, Gui
Post by: Khris on Tue 26/06/2007 11:40:10
Great advice there.

@Ghostlady:
AGS doesn't do these things automatically. I assume the QuitButton's LeftClick behavior is set to "RunScript"?
Double click the button in the GUI editor, this should bring up the global script with the cursor located at the respective function.
Check that function for a command that turns the GUI off. Or simply post the function here so we can take a look at it.
Title: Re: Load, Save, Quit, Gui
Post by: Ashen on Tue 26/06/2007 19:30:57
Mr. B's code is the way to quit the game without the in-built confirmation window, but reading your question I don't think that's what you want. As Khris said, knowing what code you're currently using would be a useful step in finding a solution.

I'd guess you need to change the button script to turn the Label and Buttons off instead of the GUI (just the same as you did to turn them on, but '= false' instead of '= true').
Title: Re: Load, Save, Quit, Gui
Post by: Ghostlady on Wed 27/06/2007 01:16:56
Here is my dilemma.  See image below.  I click on the quit button.  Here is the script for that:

#sectionstart btnIconExit_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnIconExit_Click(GUIControl *control, MouseButton button) {
 
  QuitLabel.Visible = true;
  btnIconNo.Visible = true;
  btnIconYes.Visible = true;
  gIconbar.Visible = true;
}
#sectionend btnIconExit_Click  // DO NOT EDIT OR REMOVE THIS LINE

(http://www.mysterymanor.net/Cliffhouse/cliffhousegui01.jpg)

The gui then closes down and you see this:

(http://www.mysterymanor.net/Cliffhouse/cliffhousegui02.jpg)

If I run my mouse over the top of the screen again, this pops up:

(http://www.mysterymanor.net/Cliffhouse/cliffhousegui03.jpg)

I can now execute to the "yes" or "no" button to quit or not quit the game.

I can't figure out why the second image happens and why the label doesn't appear in the gui the first time.
Title: Re: Load, Save, Quit, Gui
Post by: on Wed 27/06/2007 02:32:39
That sounds as if the confirm GUI is set to "pop up at mouse y pos", and possibly all you need to do is setting it to "popup modal". Please tell me I'm right, I love simple solutions!
Title: Re: Load, Save, Quit, Gui
Post by: Ghostlady on Wed 27/06/2007 03:12:04
I changed it from pop up at mouse y pos to popup modal and am calling it with the escape key.  It fixed the quit issue, but now, for the save and load buttons, the gui stays in the background instead of it being removed.
Title: Re: Load, Save, Quit, Gui
Post by: on Wed 27/06/2007 03:15:13
Then, upon calling the second gui, you need to make the first one invisible:

Pressing the quit button must:
- remove first gui
- call second gui

The confirmation gui might need additional code for a "no" button too, should you wish to "return" to your first gui from there. The "yes" button, of course, only needs to quit the game.
Title: Re: Load, Save, Quit, Gui
Post by: Ghostlady on Wed 27/06/2007 03:45:08
Yes, I did do that:

#sectionstart btnIconSave_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnIconSave_Click(GUIControl *control, MouseButton button) {
 
  QuitLabel.Visible = false;
  btnIconNo.Visible = false;
  btnIconYes.Visible = false;
  gIconbar.Visible = false;
  SaveGameDialog();
}
#sectionend btnIconSave_Click  // DO NOT EDIT OR REMOVE THIS LINE

The "no" button works and the "yes" button works.  The gui stays in the background for the save and load buttons and it shouldn't.
Title: Re: Load, Save, Quit, Gui
Post by: Khris on Wed 27/06/2007 04:06:07
Try putting Wait(1); after gIconbar.Visible = false; to force a screen update.
Title: Re: Load, Save, Quit, Gui
Post by: Ghostlady on Wed 27/06/2007 04:15:51
Interesting enough, that worked.  I am curious why.
Title: Re: Load, Save, Quit, Gui
Post by: Khris on Wed 27/06/2007 05:26:48
Calling SaveGameDialog() is blocking (the dialog acts like a GUI set to popup modal). AGS will draw the dialog onto the existing screen. Not until it is closed AGS gets out of btnIconSave_Click and returns to its usual "flow", updating the screen every 1/40 seconds.
But calling Wait(1) makes AGS redraw the complete screen right then, i.e. remove (or rather: not draw) gIconbar.

You could say gIconbar.Visible=false; is non-blocking and gets queued because a blocking function is called immediately afterwards.
Title: Re: Load, Save, Quit, Gui
Post by: on Wed 27/06/2007 12:20:55
Aww Kris, you're too fast!  ;) I wanted to say that! Er... possibly not in that depth, though.

Ghostlady, if you already go to all that trouble with your GUI, why not create your own Save GUI, too? Bet that would look even better- your graphics are impressive enough, why stick to AGS' built-in savegame dialog?
Title: Re: Load, Save, Quit, Gui
Post by: Ghostlady on Thu 28/06/2007 00:26:59
Thanks for the explaination.  It helps a lot to understand how everything works.

Creating my own save gui is my next step.  I have to admit from reading posts here, I am rather daunted by the whole task.  Any tutorials that anyone knows of or better yet, an already made gui/template that I can redesign with my own graphics?
Title: Re: Load, Save, Quit, Gui
Post by: Khris on Thu 28/06/2007 00:36:34
Here's a GUI/Module by Joe Carl:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=30292.0
Title: Re: Load, Save, Quit, Gui
Post by: Ghostlady on Thu 28/06/2007 00:38:17
Alright!!!  I'll give it a shot.  ;D