Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: TheMagician on Sun 05/10/2003 18:16:16

Title: My menu bar GUI vanishes
Post by: TheMagician on Sun 05/10/2003 18:16:16
Hi everyone,

I use a custom menu bar in my game. It pops up as soon as the player moves the mouse to the upper screen edge. I also use the default "save game" gui.

Now here is the problem: after moving the mouse to the upper screen to open the menu bar I open the save game gui (by clicking on the save-button in the menu bar) and I save my progress. However, after closing the save gui my menu bar has vanished and I can't get it back by moving the mouse to the screen edge. I have to restart my game to get it back.

Any ideas?
Thanks in advance

Stefan
Title: Re:My menu bar GUI vanishes
Post by: Pumaman on Sun 05/10/2003 23:56:48
How are you popping up the menu bar? With the GUI "Mouse Ypos" setting or with some manual scripting?
Title: Re:My menu bar GUI vanishes
Post by: TheMagician on Mon 06/10/2003 16:33:52
Well, I use the setting in the editor: "Mouse YPos" (no scripting).

I use the newest version of AGS and - if you need that information - i renamed my gui from the default GUI1 to MEN.

I use a custom inventory GUI, custom Quit box and custom menu bar. Only save and load are default.
Title: Re:My menu bar GUI vanishes
Post by: a-v-o on Mon 06/10/2003 18:38:25
Do you use any GUI-commands in any of your sripts?
If yes, then put display-commands with different texts (e.g. function name and a number) before each command.
Then test the game and note which commands are executed after you click on the save button of your menu bar.
This way you can find out if any of the GUI-commands is responsible for the vanishing.
Title: Re:My menu bar GUI vanishes
Post by: TheMagician on Mon 06/10/2003 20:41:27
Thanks for the tip a-v-o.

I use gui scripting sometimes in my global script. However I looked through it very carefully and couldn't find anything.

But I will definitely try your methode.
Title: Re:My menu bar GUI vanishes
Post by: Pumaman on Mon 06/10/2003 22:06:24
Are you calling  GUIOff  in your interface_click for when they press the save button? If you do, that will disable the menu bar.
Title: Re:My menu bar GUI vanishes
Post by: TheMagician on Tue 07/10/2003 11:31:08
After messing around quite a bit I found the solution to the problem.

My original code was:

function interface_click(int interface, int button) {
 if (interface == MEN) {
   if ((button == 0) && (IsGUIOn(INV)==0)) {   // see inventory
     SetGlobalInt(13,character[EGO].activeinv);
     GUIOff(MEN);
     character[EGO].activeinv=-1;
     GUIOn (INV);
     SetButtonPic(INV,2,1,72);
     SetCursorMode (2);
     SetMouseCursor (6);
     }
   if ((button == 0) && (IsGUIOn(INV)==1)) {
     }
   if (button == 2)    // save game
     SaveGameDialog();
   if (button == 1)   // load game
     RestoreGameDialog();
   if (button == 3)   // quit
     GUIOn(QUIT);
     GUIOff(MEN);
 }

Because there where now errors while compiling the script I thought it would be ok. However I had to add braces like this:

function interface_click(int interface, int button) {
 if (interface == MEN) {
   if ((button == 0) && (IsGUIOn(INV)==0)) {   // see inventory
     SetGlobalInt(13,character[EGO].activeinv);
     GUIOff(MEN);
     character[EGO].activeinv=-1;
     GUIOn (INV);
     SetButtonPic(INV,2,1,72);
     SetCursorMode (2);
     SetMouseCursor (6);
     }
   if ((button == 0) && (IsGUIOn(INV)==1)) {
     }
   if (button == 2) {   // save game with braces added
     SaveGameDialog();
     }
   if (button == 1) {  // load game with braces added
     RestoreGameDialog();
     }
   if (button == 3) {  // quit with braces added
     GUIOn(QUIT);
     GUIOff(MEN);
     }
 }

Now it works. Can you help me understand my fault?
Title: Re:My menu bar GUI vanishes
Post by: Gilbert on Tue 07/10/2003 11:53:12
Because at least the two lines:
GUIOn(QUIT);
GUIOff(MEN);
should run ONLY when button 3 is pressed, if you didn't enbrace them in that if statement, that GUIOff(MEM); line will always be executed whenever a button is pressed.


For the error you got, well I'm not sure, but probably it's because those // comments terminated the lines while the compiler didn't expect. I think the following may also work:

blah bla bla...
if (button == 2) SaveGameDialog(); // save game
if (button == 1) RestoreGameDialog(); // load game
if (button == 3) {// quit
GUIOn(QUIT);
GUIOff(MEN);
}
}


Title: Re:My menu bar GUI vanishes
Post by: TheMagician on Tue 07/10/2003 14:58:55
Thanks everyone!

To Gilbot: I had a misspelling in my last post: there were no errors when compiling the script.

Thanks for helping me solve and understand the problem.

Stefan