hey folks, here I am again.
I was working on my game, trying to modify the gui. it was pretty simple so far, until I wanted to change major things.
So what I wanna do is therotecly simple.
I used the gui from a standard-AGS-Game. not when you move ypur cursor to the top of the screen, the ICONBAR will appear. but, I don't really need the iconbar for my game cuz, I have attached the INVENTORY-BAR to the bottom of the screen but I need the iconbar for options like "save","load","exit" etc.
So what I want, is that the iconbar pops up into as a small window, wenn the player clicks on an "option-button" on my (always visible) Inventory bar.
But it is the other way round. I can let the Inventory-window appear by clicking on a button in the iconbar. But, as I said, I want the (smaller) Iconbar appear, when the player clicks on a button in my "inventory-bar".
Everything I tried so far, failed.
I read a bunch of tutorials for making gui's but, they don't handle those kind of function.
has anybody an idea?
It just has to be something like
if (interface == IVENTORY) {
if (button == 2) { // show iconbar
show_iconbar_window();
But that didn't work out. Where do I have to declare the "show_iconbar_window-function"???
I really need some help.
Anywhere in the global script, provided it's outside of any other function. But, actually, it's simpler than that:
if (interface == INVENTORY) {
if (button == 2) { // show iconbar
GUIOn (ICONBAR); // or whatever name/number your icon GUI is
}
// Other INVENTORY button scripting
}
Unless, of course, you need to have it do something else (e.g. change the cursor mode or graphic), but you can just add that after the GUIOn (); command.
The show_inventory_window(); function - which I guess is what confused you - is just there to make it easier for novice scripters to see which code to change to use their own Inventory GUI. You could create a show_iconbar_window(); function if you wanted, using show_inventory_window(); as a template, but it really isn't needed.
heh thx, but I tried that already. but then the modyfied iconbar pops up an none of the buttons are workeable
here is the script.
function interface_click(int interface, int button) {
if (interface == INVENTORY) {
// They clicked a button on the Inventory GUI
if (button == 2) { // show inventory
GUIOn (ICONBAR);
}
if ((button == 3) && (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 == 4) && (game.top_inv_item > 0)){
// scroll up
game.top_inv_item = game.top_inv_item - game.items_per_line;
}
if (interface == ICONBAR) {
if (button == 0) // save game
SaveGameDialog();
if (button == 1) // load game
RestoreGameDialog();
if (button == 2) // quit
QuitGame(1);
if (button == 5) // look away
GUIOff(ICONBAR);
} // end if interface ICONBAR
Do you have an idea whats wrong with it?
it must be something with my order cause, no matter what bar I put first
(after "function interface_click(int interface, int button) {") that one works.
If I put the iconbar right after that function-call it works but can't be opened by the click on the option-button and if I put the inventory-bar first I can use the option-button to make the iconbar popup, but then the iconbar is useless, cause none of the buttons work. they're just like static.
hmmm, I simply restarted the ags and now everything works fine. I hate those errors!!!
Glad you've sorted it, but I noticed this, might as well post it anyway:
Check your braces ('{' and '}'). They need to match:
function interface_click(int interface, int button) {
if (interface == INVENTORY) {
// They clicked a button on the Inventory GUI
if (button == 2) { // show inventory
GUIOn (ICONBAR);
}
if ((button == 3) && (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 == 4) && (game.top_inv_item > 0)){
// scroll up
game.top_inv_item = game.top_inv_item - game.items_per_line;
}
} //end if interface INVENTORY.
//You were missing this one, so everything after was counted as still part of INVENTORY
if (interface == ICONBAR) {
if (button == 0) // save game
SaveGameDialog();
if (button == 1) // load game
RestoreGameDialog();
if (button == 2) // quit
QuitGame(1);
if (button == 5) // look away
GUIOff(ICONBAR);
} // end if interface ICONBAR
// any other interfaces
} // End of interface_click
You can use Ctrl-B in the script editor to check whether braces match up, rather than having to wade through the code yourself.
Don't know if this was the problem, but it's worth keeping an eye out for.
hey just another short one:
my GUI's work all fine now, but when I enter (on mouse over) the INVENTORY-bar, the cursor should switch to pointer-mode (cursor mode 6)
I tried :
if (interface == INVENTORY) {
SetCursorMode(6);
etc.....
but now the cursor only switches to the pointer-mode if a button was clicked. how can I define, that it should swich as soon as the player moves the mouse over the inventory-bar?
You could put cursor changing code in rep_ex_always, for instance (if GetGUIAt (mouse.x,mouse.y) == INVENTORY ... )
hmm, first of all: thx a lot. You seem to know what you're talking about. I'm not quite sure if I could follow.
I added the following
function repeatedly_execute() {
if GetGUIAt (mouse.100,mouse.100 == INVENTORY)
SetCursorMode (MODE_USE);
SetMouseCursor (6);
}
but as you probably know (cuz you just read this messy party of my script) it didn't work.
what is wrong?
BRACES
function repeatedly_execute()
{
Ã, if GetGUIAt (mouse.100,mouse.100 == INVENTORY)
{
Ã, SetCursorMode (MODE_USE);
SetMouseCursor (6);
}
}
thx for the help but it still wont work, it says there is an error in the script : expected "("
???
mouse.100? Where did that come from, I'm pretty sure I wrote mouse.x and mouse.y
You forgot a lot of parentheses:
if ( GetGUIAt (mouse.x, mouse.y ) == INVENTORY)
function repeatedly_execute() {
if GetGUIAt ([b]mouse.x,mouse.y[/b]) == INVENTORY) {
SetCursorMode (MODE_USE);
SetMouseCursor (6);
}
}
Translation: If your mouse is over the GUI, INENTORY, set the cursor mode to MODE_USE, but make it appear like a pointer.
Bold letter reference (This can be found in the manual):
Quote
mouse.x Mouse X co-ordinate when the script was started (0-319)
mouse.y Mouse Y co-ordinate when the script was started (0-199)
if (interface == INVENTORY) {
SetCursorMode(MODE_USE);
SetMouseCursor(6);
...
}
Translation: Since you added this to the function,
interface_click, it can only work if you click on the interface. If you
click on the GUI, INVENTORY, set the cursor mode to MODE_USE, but make it appear like a pointer.
Bold letter reference (This can be found in the manual):
Quote
interface_click (int interface, int button)
Called when the player clicks on a button on an interface which has its action set as "Run script". INTERFACE is the number of the GUI which they clicked on. BUTTON is the object number of the button within this GUI.
Do you understand?