When I press the F5 button, a custom GUI pops up. The problem is, I can still press and interact with persons and objects in the game world when clicking outside this GUI. How do I make a GUI stay on top blocking all other GUIs? ???
The same problem goes for when another GUI pops up:
(http://img208.exs.cx/img208/200/untitled8uo.jpg) (http://www.imageshack.us)
I can still click the buttons on the GUI "below" it! >:(
Set the other GUIs to disabled (SetGUIEnabled (num, 0)).
Or, hide them.
Or, make your topmost GUI big enough to fill the entire screen.
I tried the SetGUIEnabled thing, but the script manager won't recognize it... Are you sure you wrote it correctly?
Edit: I've looked through the manual, but couldn't find anything I could use... Unless I've overlooked something?
No :)
but a manual search should turn it up.
Maybe it was SetGUIDisabled. Or SetGUIClickable. But there's a page with all functions relating to GUIs, and there aren't that many of them.
QuoteThe problem is, I can still press and interact with persons and objects in the game world when clicking outside this GUI.
And to prevent the player from interacting with the game game world set the GUI visible property to
Popup Modal -- this will pause the game.
NOW BFAQed: http://bfaq.terran-x.com/#guis13
This question has just been B-FAQed, though it seems it wasn't even the solution.
Funny that two of you should mention the Popup Modal thing, as it doesn't change anything. I can still click the GUIs underneath them. As for Radiants suggestion, I still can't find anything of use in the manual that's helpful...
So, is this solved, or not?
I think Radiant's sugestion was to use SetGUIClickable (GUI, clickable) to deactivate the other onscreen GUIs. If so, it might work, but it'd be a bit cumbersome, IMO. (If that wasn't it - Sorry Radiant.)
What if you add something to on_mouse_click to make it ignore off-GUI clicks, like this:
function on_mouse_click(int button) {
// called when a mouse button is clicked. button is either LEFT or RIGHT
if (IsGamePaused() == 1) {
// Game is paused, so do nothing (ie. don't allow mouse click)
}
else if ((IsGUIOn (GUINAME)) && (GetGuiAt (mouse.x, mouse.y) != GUINAME)) {
// GUI is open, but hasn't been clicked on, so do nothing
}
// could add more 'else if's if you have this problem with other GUIs
else if (button == LEFT) {
// etc ....
LENGTHY EDIT:
(I know it's been a while, but I had computer problems, and only just found this thread again. That's why I'm editing, rather than making a new post.)
I think this is about the first time I've posted something I wasn't totally sure of without bothering to test it, and look what happens...
I think the basic idea can be salvaged though, if you forget on_mouse_click, and edit interface_click:
function interface_click(int interface, int button) {
if (IsGUIOn (QUITGUI) == 1){
if (interface == QUITGUI) {
if (button == 1) QuitGame (0);
else GUIOff (QUITGUI);
}
}
else {
//all other GUI scripts
//only runs when QUITGUI isn't on
}
}
I've tested this version, and it works fine except with buttons set to 'Set Cursor Mode', which don't use interface_click. I'm also not sure how it'd work in OO scripting, since interface_click is now obsolete.
Quote from: LeChuck on Mon 14/02/2005 16:26:39Funny that two of you should mention the Popup Modal thing, as it doesn't change anything. I can still click the GUIs underneath them. As for Radiants suggestion, I still can't find anything of use in the manual that's helpful...
Yeah, with the popup modal GUI you're still able to click other GUI controls. I meant that making it popup modal should be one more additional step to what Radiant already suggested.
So a straightforward solution is:
- make that custom GUI Popup modal
- when turn it on set all other visible GUI unclickable. i.e.
SetGUIClickable(GUI1, 0);
SetGUIClickable(GUI2, 0);
etc.
- when you close it, restore other GUIs' clickable property:
SetGUIClickable(GUI1, 1);
SetGUIClickable(GUI2, 1);
You should make it popup modal to ensure the game is then paused and thus the player is unable to control the character or interact with the rest of game world.
Ashen's second suggestion could also logically work but unfortunetely AGS doesn't invoke the on_mouse_click function on clicks over GUIs. There is though a possiblity to change that behaviour by handling GUI clicks manually, i.e. by having your own interface_click function and check for GUI clicks via the on_even function but such approach would also introduce several problems to deal with.
UPDATED BFAQ ENTRY: http://bfaq.terran-x.com/#guis13 :P
I don't understand how I could've had so much trouble getting a simple command like the SetGUIClickable working correctly. It's almost embarrasing. Consider it SOLVED. ::)