Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Edwin Xie on Thu 26/08/2004 07:08:03

Title: Crazy GUI
Post by: Edwin Xie on Thu 26/08/2004 07:08:03
In the gui script for game there was a script for a button that closes the gui:

if (button == 11) InterfaceOff (3);

Makes the player to to room 100 (the screen where it says load/play/quit). What is wrong with that (button 11 is the button where it closes the window and Interface (or gui) 3 is the controls gui window)?
Title: Re: Crazy GUI
Post by: Gilbert on Thu 26/08/2004 07:09:57
Probably you didn't setup the if-else clauses properly (like misplacements of braces, etc.), you may post the whole interface_click() content here for investment.
Title: Re: Crazy GUI
Post by: Edwin Xie on Thu 26/08/2004 07:14:05
THanks the pormt reply and here is the script for the GUI

CentreGUI(3);
  if (interface == 3){
    if (button == 8) SetGameSpeed(GetSliderValue(3,8));
    else if (button == 9) SetMusicMasterVolume(GetSliderValue(3,9));
    else if (button == 10) game.text_speed = GetSliderValue(3,10);
    else {
    if (button == 0) SaveGameDialog();
    if (button == 1) RestoreGameDialog();
    if (button == 2) QuitGame(1);
    if (button == 3) SetCursorMode(6);
    RestartGame();
    if (button == 4)
    Display("The Adventures of Bob I [[Made with Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2004 Chris Jones");
    }
  if (button == 11){
    GUIOff (3);
    SetDefaultCursor();
    }
  }
Title: Re: Crazy GUI
Post by: Jay on Thu 26/08/2004 07:20:29
Did you mean for button 3 to restart the game? You need brackets after it, like this:


CentreGUI(3);
  if (interface == 3){
    if (button == Cool SetGameSpeed(GetSliderValue(3,8));
    else if (button == 9) SetMusicMasterVolume(GetSliderValue(3,9));
    else if (button == 10) game.text_speed = GetSliderValue(3,10);
    else {
    if (button == 0) SaveGameDialog();
    if (button == 1) RestoreGameDialog();
    if (button == 2) QuitGame(1);
    if (button == 3) {
       SetCursorMode(6);
       RestartGame();
       }
    if (button == 4)
    Display("The Adventures of Bob I [[Made with Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2004 Chris Jones");
    }
  if (button == 11){
    GUIOff (3);
    SetDefaultCursor();
    }
  }


But I'm not sure why you would change the cursor mode before restarting the game, so I'm probably wrong. Hopefully this leads you in the right direction.
Title: Re: Crazy GUI
Post by: Gilbert on Thu 26/08/2004 07:28:28
Yeah jayssite got it, as that RestartGame() line wasn't inside any of the conditions, it would be executed when you click any button on that GUI, just follow his fix.

One thing I didn't understand was whay did you put a "CentreGUI(3);" within interface_click();

Seeing that interface_click() would only be executed when you click on a GUI button, that means you want to centre the GUI when you click on it?
I think that is redundant.
You should probably place that line in the codes for enabling that GUI instead.
Title: Re: Crazy GUI
Post by: Edwin Xie on Thu 26/08/2004 07:31:25
:O I think that may be the main problem why! Then the buttons after will restart the game.... Just wait a second so I can try it
....
....
....
....
....
Oh, wait I need to put in interface on for the icon bar and make the cursor regular....

Yep, works.

EDIT:
While I was posting this you replied so I didn't reply to your message but, if I place CentreGUI (); in the interface code it would center only if I click on the window.
Title: Re: Crazy GUI
Post by: Gilbert on Thu 26/08/2004 07:37:45
Quote from: Edwinxie on Thu 26/08/2004 07:31:25
... if I place CentreGUI (); in the interface code it would center only if I click on the window.
That's what you're really doing with your codes, unless you really wanted it to behave like that.