Gui Problem.

Started by Phemar, Sun 08/02/2004 13:54:40

Previous topic - Next topic

Phemar


All you people out there are probably going "NOOO! Not another post about the blady GUI's!". All I've got to offer are my apologies.

You see, I have a probelm, well I've always had a problem but thats beside the point. THE BUTTONS ON MY GUI WILL NOT WORK!.

You're probably thinking to yourself right now "Switch it to RUN SCRIPT!"

Fact is, been there, done that, smelt the cheese. It still does not work.

My Script looks loke this:

 if (interface == SETTINGS) {
   if (button == 0) {
     SaveGameDialog ();
     }
   if (button == 1) {
     RestoreGameDialog ();
     }
   if (button == 2) {
     QuitGame (1);
     }
   if (button == 3) {
     Display ("   IDENTITY Demo Version 1.1[[Copyright 2004 Zor Productions[  Written by Zor.");
     }
   if (button == 4) {
     Display("Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2003 Chris Jones");
     }
   if (button == 8) {
     GUIOff (INVENTORY);
     }
   if (button == 6) SetGameSpeed(GetSliderValue(SETTINGS, 6));
   
   if (button == 7) SetMusicMasterVolume(GetSliderValue(SETTINGS, 7));
     }
   }
 }

Kairus

#1
Are you sure the interface is set to "clickable"?

Are you sure there's no other interface above it that could catch the attention of the cursor instead of the "settings" interface?

I've had the same sort of problems when coding the GUI and it's always because of those two reasons or the Run-Script thing. ;D

EDIT:
I have read your script more carefully and I've noticed one of the buttons goes "GUIOff (INVENTORY)". Is the inventory interface on when you're using this settings interface? Maybe that's causing the problem...
Download Garfield today!

DOWNLOADINFOWEBSITE

Phemar


Nope, still doesn't work and thanks for pointing out that inventory thing. It is SUPPOSED to be settings

Pumaman

Is it just this one GUI that doesn't work, or do none of them?

Check your braces in the interface_click function - it could be that accidentally all your SETTINGS code is in fact inside another "if" statement for a differnet GUI. Could you post the complete interface_click function to be sure.

Also, what is the "Visible" setting for the GUI set to?

strazer

Ok, braces check: :)

if (interface == SETTINGS) {
if (button == 0) {
SaveGameDialog ();
}
if (button == 1) {
RestoreGameDialog ();
}
if (button == 2) {
QuitGame (1);
}
if (button == 3) {
Display (" IDENTITY Demo Version 1.1{<{Copyright 2004 Zor Productions[ Written by Zor.");
}
if (button == 4) {
Display("Adventure Game Studio v2 run-time engine{<{Copyright (c) 1999-2003 Chris Jones");
}
if (button == 8 ) {
GUIOff (INVENTORY);
}
if (button == 6) SetGameSpeed(GetSliderValue(SETTINGS, 6));

if (button == 7) SetMusicMasterVolume(GetSliderValue(SETTINGS, 7));
}
} <- interface_click?
} <- ???

Maybe it has something to do with the braces in

Display("Adventure Game Studio v2 run-time engine{<{Copyright (c) 1999-2003 Chris Jones");

? What does {<{ do?

Phemar

#5
It is set to popup modal
{<{ is what the forum replaces double [. i am going to place double [ now and it magically changes into [[
Anyway, here's the script:

function interface_click(int interface, int button) {
if (interface == ICONBAR) {
   if (button == 0) {
     CentreGUI (3);
     GUIOn (3);
     }
   if (button == 5) {
     InventoryScreen ();
     }
   }
 
 
 

 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;
   }
 if (interface == SETTINGS) {
   if (button == 0) {
     SaveGameDialog ();
     }
   if (button == 1) {
     RestoreGameDialog ();
     }
   if (button == 2) {
     QuitGame (1);
     }
   if (button == 3) {
     Display ("   IDENTITY Demo Version 1.1[[Copyright 2004 Zor Productions[  Written by Zor.");
     }
   if (button == 4) {
     Display("Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2003 Chris Jones");
     }
   if (button == 8) {
     GUIOff (SETTINGS);
     }
   if (button == 6) SetGameSpeed(GetSliderValue(SETTINGS, 6));
   
   if (button == 7) SetMusicMasterVolume(GetSliderValue(SETTINGS, 7));
     }
   }
 

 
}







strazer

Try this

...
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;
}
}

if (interface == SETTINGS) {
if (button == 0) {
SaveGameDialog ();
}
if (button == 1) {
RestoreGameDialog ();
}
...

and remove one brace from the end.

Phemar


WOW! You're a genius! I bow down to you and kiss your feet oh mighty Strazer!


Thanks a million guys!

strazer

Hehe, you're welcome. :)
I always seperate each segment of my script with at least one line. Makes the script longer, but better to read and therefore avoids problems such as this.

SMF spam blocked by CleanTalk