Custom Quit GUI problem (Solved)

Started by strazer, Sun 01/02/2004 21:31:08

Previous topic - Next topic

strazer

I have a problem with my custom quit gui. It displays like it should, but a click on either button or the GUI (!) quits the  game. ???
I've posted my entire interface_click function, maybe it helps. Quit gui code is at the bottom (--- added for indentation):

(Code removed to conserve bandwidth)

GUI number is correct (5) and button (object) numbers are correct (1 and 2). GUI is "Popup modal" and buttons are "Run Script".
I'm clueless.

Ishmael

#1
If you try this little change:

----------if (button == 1) { // quit button
--------------------QuitGame(0);
----------}

And see if it helps... also, though I doubt it's about it, are both buttons set to "Run script" letf click action?
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

strazer

No change.  :(

Quoteare both buttons set to "Run script" letf click action

Yep, as stated above.

Thanks for the reply though!

Scummbuddy

Maybe switch them around a bit. ???

--if (interface == 5) // click on quit gui
{
----------if (button == 2)  // play button
           {
--------------------GUIOn(0); // turn on hotspot description
--------------------GUIOn(2); // turn on inventory gui
--------------------GUIOff(5); // turn off quit gui
--------------------SetDefaultCursor();
           }
----------else if (button == 1) // quit button
           {
--------------------QuitGame(0);
           }
}
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

strazer

No change. :(

But in a strange way it pleases me that it baffles the elders as much as me. ;D

I read a post of Spyros where he mentioned he uses UltraEdit to check brackets, so I downloaded the trial version and checked the entire global script. Everything seems to be in order.

I'll recreate the gui and see if it helps.

Gilbert

Try changing the line to QuitGame(1); and see if that quitting game behaviour was indeed caused by executing that line.

strazer

QuoteTry changing the line to QuitGame(1); and see if that quitting game behaviour was indeed caused by executing that line.

I assumed it was since it was quitting without any message at all, but yes, QuitGame(1); confirms it is that line that gets executed.

I've just tried it with a new gui, same settings, except I forgot to set the buttons to "Run Script" at first, but they executed the line anyway. ???

It's a simple gui, one label (object 0), two buttons (1 and 2), that's all.
I don't get it...

Gilbert

Did the if (button==2) part ever got executed when clicking button 2?

strazer

Nope, nothing happens if I comment out QuitGame(0); and put a Display("test"); in the other button's script.
It's so strange since everything else works perfectly fine.

Gilbert

hmmm it sounds real strange, are you sure that the size of button won't cover up the whole GUI?

If all attempts failed, maybe you can zip the files and upload them for us to check it for you (just the 3 files editor.dat, acsprset.spr and ac2game.dta are enough I think)

strazer

Quoteare you sure that the size of button won't cover up the whole GUI?

Absolutely, the buttons are the default ones, nothing changed.

QuoteIf all attempts failed, maybe you can zip the files and upload them for us to check it for you (just the 3 files editor.dat, acsprset.spr and ac2game.dta are enough I think)

That would be great. Get it here.

Thanks a lot!

strazer

For everyone who took a look at it, ignore the "if (interface == 9)" it was from my testing.
Anyway, I've found the culprit myself:

on_event function
if (event==GUI_MUP)
interface_click (data,GUIButton);

I don't know where this came from, it was from fooling around earlier I guess, it doesn't even make sense...  :P

So thanks everybody for listening, but deleting this part helped.

Gilbert

#12
Okay, I know what happened now.

Edit your global script, hit Ctrl-F, type in interface_click and hit return, the editor will find the text, it should be a line inside on_mouse_click() finction in a comment following the else if (button==RIGHTINV)... part. Delete that interface_click text, save and test again (you may need to change that interface==9 back to 5, etc).

I'd never seen this kind of things, so probably no one reported it, and I'll consider it as an AGS bug (but probably not easy to fix), so blame CJ...

I found it because as I click the "edit script" button in GUI tab of the editor, the script was empty, but when I checked the whole global script, the interface_click function was there, so I did little research, and found out that when you "edit scripts" in AGS GUI, INV, etc tabs, it did a search for the function name and treats whatever comes up first as the content of the script. So if the text interface_click appears somewhere before the real declaration of the function, AGS would incorrectly refer the former as the position of the script. It shouldn't happen normally, as you cant do forward reference, unless it's not in the code part (such as inside a string or in a comment).

I'll post it as a bug report in the technical forum for CJ to see, and would you mind keeping that zip file in the webspace briefly so CJ can download it and see for himself what happened?

EDIT:
Okay, in case you didn't notice, it's now posted in the tech forum as a bug report:
http://www.agsforums.com/yabb/index.php?board=2;action=display;threadid=11488

strazer

I've upped the file again, and you're right, correcting that comment helped.

However, I'm not sure the line I posted above is not somehow to blame too. Looking deeper into my script (which has been put together from various posts and whatnot), I'm not quite convinced the behavior wasn't due to some fault of mine.

But, who am I to argue? ;)

Gilbert

Well, of course, it's rare that someone would ever put up an internal function name in a comment, but since no one really knew something will go wrong in doing this, I don't think you should be blamed.

So just blame CJ himself! What's better is that he's currently absent from technical support, so we have someone to blame at least a few days more! ;D

Spoiler

Heh okay I lied, CJ is always cool for making this great programme, so no one should be blamed actually.
[close]

strazer

While the problem may be related, I think

interface_click (data,GUIButton);

was the bad line here though. You see, pressing the left mouse button sets GUIButton to 1. Since the interface_click function has the parameters GUI and BUTTON (not MOUSE button, but object number), it's reasonable to assume this has something to do with it.
I'm in the middle of rewriting this whole part, so I can't make certain, but maybe your bug report was a bit premature.
I don't like bothering CJ with stuff that is most likely not his fault because I know the feeling. :)
So sorry CJ if this turns out to be my bad.

Gilbert

Heh yeah you're right, the codes work again if i uncomment that GUIbutton=... line and comment out the left/right thingie, but still there's a problem in detecting the right codes in the editor, I'll modify the post in tech forum.

strazer

#17
I've remembered I put that line there because the right-mouse-button-cycles-cursor-modes had to work with the inventory too.

My on_event function just looks like this now:

 if (event==GUI_MDOWN) {
  if (IsButtonDown(RIGHT)==1)
     myInterfaceClick(data,GetGUIObjectAt(mouse.x,mouse.y),2); // call custom interfaceclick function
  else if (IsButtonDown(LEFT)==1)
     myInterfaceClick(data,GetGUIObjectAt(mouse.x,mouse.y),1); // call custom interfaceclick function
 }

Basically I've removed the normal interface_click function and replaced it with my own myInterfaceClick.
The important thing is, the on_event function is called by inventory items and the inventory area as well, so this approach now works across the whole gui.
Man, I'm happy the way it turned out.  :D

Scummbuddy

I'm happy the problem was all sorted out.  Hope we all helped, especially Gilbot
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

strazer

QuoteHope we all helped, especially Gilbot.

Yeah, I really appreciate it! Thank you!

SMF spam blocked by CleanTalk