Load, Save, Quit, Gui

Started by Ghostlady, Tue 26/06/2007 03:52:09

Previous topic - Next topic

Ghostlady

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?
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

Buckethead

You should use

Code: ags
QuitGame(0);


This quits the game at once with out asking for a confirm.

Khris

#2
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.

Ashen

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').
I know what you're thinking ... Don't think that.

Ghostlady

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



The gui then closes down and you see this:



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



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.
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

Ghost

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!

Ghostlady

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.
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

Ghost

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.

Ghostlady

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.
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

Khris

Try putting Wait(1); after gIconbar.Visible = false; to force a screen update.

Ghostlady

Interesting enough, that worked.  I am curious why.
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

Khris

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.

Ghost

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?

Ghostlady

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?
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse


Ghostlady

Alright!!!  I'll give it a shot.  ;D
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

SMF spam blocked by CleanTalk