Hey
I was wondering if (or how) it s possible to specifiy a GUI and only a button graphics for the engine too look.
I don't want to specify a exact button, but only the NORMAL GRAPHICS parameter !
I have a custom gui, and inventory slots will be actual buttons, as there are many inventory items available in random order to pick up (so button one can be a BUCKET, STICK, or anything else), i want to make script shorter, so i want for AGS to only look for specific button graphics not the button name.
hope this makes any sense :)
Quote from: Sektor 13 on Tue 15/07/2008 20:03:08
Hey
I was wondering if (or how) it s possible to specifiy a GUI and only a button graphics for the engine too look.
I don't want to specify a exact button, but only the NORMAL GRAPHICS parameter !
I have a custom gui, and inventory slots will be actual buttons, as there are many inventory items available in random order to pick up (so button one can be a BUCKET, STICK, or anything else), i want to make script shorter, so i want for AGS to only look for specific button graphics not the button name.
hope this makes any sense :)
I don't understand what you are trying to say, but a button's graphics can be accessed through bButton.NormalGraphic, bButton.MouseOverGraphic and bButton.PushedGraphic. But, for inventory items, you don't have to make a lot of buttons. You can just draw a inventory window (the last button in the GUI toolbar, with a cup icon) and tell it to show the player's character (-1) or whoever you want. Then you can define each interaction for each item when clicking it on the inventory, and even tell AGS to manage then automatically (left click on use mode = select item, right click = look)
Anyway, if you want to cycle through all the buttons in a GUI and check its normal graphic, you can do this (let's imagine you want to check for the graphic 5):
int i = 0;
while (gYourGUI.Controls[i] != null)
{
GUIControl *control = gYourGUI.Controls[i];
if (control.AsButton != null)
if (control.AsButton.Normalgraphic = 5)
{
//What to do if so
}
i++;
}
I'm not pretty sure this is 100% right
Gah. Don't quote the whole previous post!
Sektor wants to use buttons instead of an inventory window.
Here's the functions:
Button*GetFromSlot(int slot) {
GUI*ig = gInvGui; // replace with the name of your GUI
Button*b;
int c;
while(c<ig.ControlCount) {
b = ig.Controls[c].AsButton;
if (b != null && b.NormalGraphic == slot) c = ig.ControlCount;
c++;
}
return b;
}
int GetIDFromSlot(int slot) {
Button*b = GetFromSlot(slot);
if (b != null) return b.ID;
return -1;
}
Tested and working.
(GetFromSlot will return the first match, or null if there's no match.)
Hey thanks KhrisMUC, i'll try it out.
Baro:
I know all about inventory window, but it is limited for some things, so i must make my own...