Problems with GUIOff (SOLVED)

Started by Nine Toes, Fri 14/01/2005 00:02:55

Previous topic - Next topic

Nine Toes

I'm having a problem with the GUIOff command... basically... it isn't working...

Here's the script:
Code: ags
  
if (interface == PROFILE) { // clicked a button on the PROFILE GUI
    if (button == 0) { // click "Exit" button
      GUIOff(2); // profile menu off
      SetDefaultCursor();
      }
    if (button == 2) { //click "Journal" button
      GUIOff(2); // profile menu off
      GUIOn(3); // journal on
      SetCursorMode(6);
      }
    if (button == 3) { // click "Bestiary" button
      GUIOff(2); // profile menu off
      GUIOn(4); // bestiary on
      SetCursorMode(6);
      }
    } // end interface PROFILE


every time I click one of the buttons on the Profile GUI, it doesn't respond, and I'm at a loss for an explaination.  I'm pretty sure I scripted it right...

For example, I click the Exit button, and nothing happens.  Same with the Journal, and Bestiary buttons; when you click those buttons, it's supposed to turn off the Profile GUI, and turn on the Journal or Bestiary GUI (respectively).

Can someone offer me some words of wisdom?

I guess while I'm at it, I just wanted to make sure of something: A GUI can be as big as you want it to be, right?  If you want, it can take up the whole screen, right?

Thanks in advance.
Watch, I just killed this topic...

dreammaster

First of all, yes a GUI can take up the entire screen if you want it to.

As to your problem, are you putting the script in the interface_click method of the global script? From the sounds of it, your script isn't getting called at all. What you could is put a debug message at the start of interface click to display the interface and button values, to make sure you've got them correct.

Finally, when using the GUIOn and GUIOff methods, it would probably be better to use the names of the GUI rather than the direct number, as it makes your code clearer, and less likely to get gui's mixed up.

Gilbert

Also, check that the button actions on the GUI were set to Run Script, not otherwise.

Goot

I'm not sure if GUIOff and GUIOn work. InterfaceOn and InterfaceOff are how I do it.

Necro

I belive theese are the same commands, in an older version the command was InterfaceOn/InterfaceOff , then in a more updated version these got changed to GUIon/GUIoff , however CJ seldom removes old commands to allow games made with previous version to be compatable.

So either way is fine , though in the current version of AGS i woulf of though GUIon/GUIoff is A) Shorter to type , plus the GUI editor refers to everything as GUI's and not INTERFACES to avoid confusion.

You can also referto them by name so for example if you name your GUI 3 as MAINGUI you could do either:

Code: ags

GUIon(3);

or

GUIon(MAINGUI);

Nine Toes

#5
Code: ags

#sectionstart interface_clickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button) {
Ã,  if (interface == ICONBAR) {
Ã,  Ã,  if (button == 0) {Ã,  // click "Actions"
Ã,  Ã,  Ã,  SetButtonPic (0,0,1,31);
Ã,  Ã,  Ã,  SetButtonPic (0,1,1,33);
Ã,  Ã,  Ã,  }
Ã,  Ã,  if (button == 1) {Ã,  // click "5 Senses"
Ã,  Ã,  Ã,  SetButtonPic (0,0,1,30);
Ã,  Ã,  Ã,  SetButtonPic (0,1,1,34);
Ã,  Ã,  Ã,  }
Ã,  Ã,  if (button == 2) {Ã,  // show inventory
Ã,  Ã,  Ã,  show_inventory_window();
Ã,  Ã,  }
Ã,  Ã,  if (button == 3) {Ã,  // click "Menu"
Ã,  Ã,  Ã,  GUIOn(2);
Ã,  Ã,  Ã,  SetCursorMode(6);
Ã,  Ã,  Ã,  }
//Ã,  Ã,  else if (button == 7) {Ã,  Ã, // use selected inventory
//Ã,  Ã,  Ã,  if (character[ GetPlayerCharacter() ].activeinv >= 0)
//Ã,  Ã,  Ã,  Ã,  SetCursorMode(4);
//Ã,  Ã,  } 
Ã,  Ã,  else if (button == 4)Ã,  Ã, // save game
Ã,  Ã,  Ã,  SaveGameDialog();
Ã,  Ã,  else if (button == 5)Ã,  Ã, // load game
Ã,  Ã,  Ã,  RestoreGameDialog();
Ã,  Ã,  else if (button == 6)Ã,  Ã, // quit
Ã,  Ã,  Ã,  QuitGame(1);
Ã,  }Ã,  // end if interface ICONBAR

Ã,  else if (interface == INVENTORY) {
Ã,  Ã,  // They clicked a button on the Inventory GUI
Ã,  Ã,  
Ã,  Ã,  if (button == 1) {
Ã,  Ã,  Ã,  // They pressed SELECT, so switch to the Get cursor
Ã,  Ã,  Ã,  SetCursorMode (MODE_USE);
Ã,  Ã,  Ã,  // But, override the appearance to look like the arrow
Ã,  Ã,  Ã,  SetMouseCursor (6);
Ã,  Ã,  }
Ã,  Ã,  
Ã,  Ã,  if (button == 2) {
Ã,  Ã,  Ã,  // They pressed LOOK, so switch to that mode
Ã,  Ã,  Ã,  SetActiveInventory(-1);
Ã,  Ã,  Ã,  SetCursorMode(MODE_LOOK);Ã,  
Ã,  Ã,  }
Ã,  Ã,  if (button == 3) {
Ã,  Ã,  Ã,  // They pressed the OK button, close the GUI
Ã,  Ã,  Ã,  GUIOff (INVENTORY);
Ã,  Ã,  Ã,  SetDefaultCursor();
Ã,  Ã,  }

Ã,  Ã,  if ((button == 4) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed)) {
Ã,  Ã,  Ã,  // scroll down
Ã,  Ã,  Ã,  game.top_inv_item = game.top_inv_item + game.items_per_line;
Ã,  Ã,  }
Ã,  Ã,  if ((button == 5) && (game.top_inv_item > 0)){
Ã,  Ã,  Ã,  // scroll up
Ã,  Ã,  Ã,  game.top_inv_item = game.top_inv_item - game.items_per_line;
Ã,  Ã,  } // end interface INVENTORY
Ã,  Ã,  
*    else if (interface == PROFILE) { // clicked a button on the PROFILE GUI
*Ã,  Ã,  if (button == 0) { // click "Exit" button
*Ã,  Ã,  Ã,  GUIOff(PROFILE); // turn off menu
* Ã,  Ã,  SetDefaultCursor();
*Ã,  Ã,  Ã,  }
*Ã,  Ã,  else if (button == 2) { //click "Journal" button
*Ã,  Ã,  Ã,  GUIOn(JOURNAL);
*Ã,  Ã,  Ã,  GUIOff(PROFILE);
*Ã,  Ã,  Ã,  SetCursorMode(6);
*Ã,  Ã,  Ã,  }
*Ã,  Ã,  else if (button == 3) { // click "Bestiary" button
*Ã,  Ã,  Ã,  GUIOn(BESTIARY);
*Ã,  Ã,  Ã,  GUIOff(PROFILE);
*Ã,  Ã,  Ã,  SetCursorMode(6);
*Ã,  Ã,  Ã,  }
*Ã,  Ã,  } // end interface PROFILE
Ã,  }
}
#sectionend interface_clickÃ,  // DO NOT EDIT OR REMOVE THIS LINE


This is it... it still won't work.

- I'm positive I've got the button numbers correct, though I will try Dreammaster's suggestion with the debug message.
- I'm positive I've got all the buttons' left click reactions set to "Run Script"

No idea...
Watch, I just killed this topic...

strazer

if ((button == 5) && (game.top_inv_item > 0)){
      // scroll up
      game.top_inv_item = game.top_inv_item - game.items_per_line;
    } // end interface INVENTORY

// This last line doesn't end the (interface == INVENTORY) part:

// (...)
   
  } // <- This does. Put your PROFILE code after this.
}
#sectionend interface_click  // DO NOT EDIT OR REMOVE THIS LINE

Nine Toes

 :-[  I knew that it was going to be something small and stupid that I overlooked... again...

Well, it works just peachy-keen, now.

Thanks for the help, Strazer, and everyone else who took a stab at it.
Watch, I just killed this topic...

SMF spam blocked by CleanTalk