Custom GUI buttons not responding.

Started by James Kay, Sun 25/01/2004 07:58:20

Previous topic - Next topic

James Kay

I've created a custom "quit, yes/no" GUI box, in stead of the standard "press Y/N" one. Basically a window with two buttons, one for yes and one for no.

It's a pop-up model, made clickable. Two objects (0 and 1) which are the cancel and ok buttons respectively.

Changed the line in the ICONBAR Gui for quit to:
   else if (button == 6) {  // quit
     GUIOff (ICONBAR);
     GUIOn (CONFIRMEXIT);
     SetCursorMode(6);
     }


which brings up the new GUI, no problem, and I've added this script in the gui_click script section:
if (interface == CONFIRMEXIT) {  
   if (button == 0) {
     GUIOff (CONFIRMEXIT);
     GUIOn(ICONBAR);
     SetDefaultCursor();
     }
   else if (button == 1) {
     QuitGame(0);
     }
   }


The two buttons have "Left Click: Run Script" enabled.

However, though the GUI appears when I press the quit button, it doesn't actually work. The button rollovers are there, but neither button responds.
What am I doing wrong??

J

Kweepa

Post the entire interface_click script, and maybe something will reveal itself.
Still waiting for Purity of the Surf II

James Kay

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 (button==LEFT) {
   ProcessClick(mouse.x, mouse.y, GetCursorMode() );
 }
 else {   // right-click, so cycle cursor
   if (character[GetPlayerCharacter()].room!=50){
   SetNextCursorMode();
   }
 }
}

function interface_click(int interface, int button) {
 if (interface == ICONBAR) {
   if (button == 4) {  // show inventory
     show_inventory_window();
   }
   else if (button == 4) {   // use selected inventory
     if (character[ GetPlayerCharacter() ].activeinv >= 0)
       SetCursorMode(4);
   }
   else if (button == 5)    // save game
     RestoreGameDialog();
   else if (button == 6) {  // quit
     //QuitGame(1);
     GUIOff (ICONBAR);
     GUIOn (CONFIRMEXIT);
     SetCursorMode(6);
     }
   else if (button == 7)    // about
     Display("Adventure Game Studio v2 run-time engine[Copyright (c) 1999-2003 Chris Jones");
 }  // end if interface ICONBAR





 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 (interface == CONFIRMEXIT) {  
   if (button == 0) {
     GUIOff (CONFIRMEXIT);
     GUIOn(ICONBAR);
     SetDefaultCursor();
     }
   else if (button == 1) {
     QuitGame(0);
     }
   }
 
 

 }
}

Scorpiorus

function interface_click(int interface, int button) {

. . . .
. . . .
. . . .


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();
}

} // end of INVENTORY interface

if (interface == CONFIRMEXIT) {
if (button == 0) {
GUIOff (CONFIRMEXIT);
GUIOn(ICONBAR);
SetDefaultCursor();
}
else if (button == 1) {
QuitGame(0);
}
} // end of CONFIRMEXITinterface


} // end of interface_click function

James Kay

Scorpiorus, you're a genius! Cheers!

Steve, why can't you be as helpful as Scorpiorus? Useless....  ;D

Scorpiorus

Were I responding the first I'd ask the same question as Steve did ;D

Kweepa

So James,
Logos and Confirm Quit dialogs?
Can we expect a release any time soon?
Still waiting for Purity of the Surf II

James Kay

Ha...no. I want to finish off all GUI stuff so I don't have to worry about that anymore. After that, I still have to script 2/3 of the game, but at least that will be rote scripting and no new funny stuff. If I get this GUI stuff sorted now, all my scripting woes should be over.  I rather have that sorted now than having to deal with possible impossibilities after having invested hours and hours into the actual gameplay stuff.

Speaking of which;
I also have an Options GUI with a button which toggles sound on/off. I recon I can script the function, but if the sound is off I want to use a different button and button mouseover graphic than when it's sound on. I have no idea how to start scripting that. Any thoughts? My first instinct is to just have two seperate GUIs, but that sounds, well, crap.

Scorpiorus

You can put in use the SetButtonPic() script function. It allows to change both button normal picture and mouse-over picture as well as button pushed picture. Just replace all the button graphics when the sound is off and restore the old pictures when it's on.



James Kay

Yet again I am entirely in your debt! Thanks!

SMF spam blocked by CleanTalk