Selecting objects in custom inventory

Started by Goot, Thu 17/06/2004 19:06:05

Previous topic - Next topic

Goot

I have made a custom inventory GUI. It works fine except if you click between two objects, no matter how close to the one on the right, the one on the left is always selected. If you miss an inventory item by a pixel to the left, the one next to it is selected. It works the same with examining and interacting (I've added interact to the inventory) Is there a way to make it like the built in inventory, where each inventory item has its own little box (shown by the yellow square popping up) It would also be nice if I could have the yellow square effect or something similar to show which inventroy item will be selected if you click at the current coordinates.
Please help if you can. Thanks.

Ashen

Just to get the obvious things out of the way:

1. The 'Outline GUI objects for easy location' check box should do the yellow box thing you want. Is this what you meant?

2. About the click selecting wrong item: With the outline on, make sure the button is the same size as the graphic (e.g. if button image is 30 by 25, make sure the button isn't 40 x 30) - it could be that the 'space' between your buttons is actually PART of one of the buttons.

Sorry if this doesn't help, it's just best to check the obvious stuff first, as it can be the easiest to overlook.
I know what you're thinking ... Don't think that.

Goot

I don't think you understood the question. I'll try restating it better. In the custom inventory window, when you hover the mouse over an inventory item, a yellow box appears around it. That part I don't really need but it would be good if someone knows how to do it. The main problem is the clicking between inventory items and always having the one on the left be selected. The inventory items aren't on buttons, so I can't resize the buttons to have them not overlap each other. I think this might be a question for advanced technical questions, so if no one hear knows, I'll try posting there.
Thanks for any help you can give.

Ashen

Sorry, totally misunderstood the problem.

To answer the second question first:
I think the problem is actually similar to what I said before. The inventory items are given a default size (40 x 22, unless you change it with SetInvDimentions), and are displayed right next to each other - any space you can see to the left of an item is actually a 'blank' part of the item before it, which is why that item is selected. Does that make any sense? Think of the items as being on buttons, with no space between them.

So, one answer to the first question might be to draw all your inventory item sprites IN boxes, and use SetInvDimentions to space them correctly, but maybe more experienced AGSers could come up with a better way.
I know what you're thinking ... Don't think that.

Goot

Thanks. That worked, but now they're all really close together. Is there a way to space them out more, so that there's a certain amount of space between each one, without having to re-import all the inventory sprites so they're in the middle of a box?

Scorpiorus

#5
I built up a little test game to demonstrate how the inventory items are arranged and why you got the effect you told us about. It also shows how a selector like that in the build-in inventory dialog can be implemented.
To understand what the SetInvDimentions function does try changing item_width and item_height variables in the global script. As far as I know, there is currently no way to centre an item within its slot. That's why it could be a good idea to have all the items having the same size.

http://www.geocities.com/scorpiorus82/invtest.zip (Copy & Paste it to the address bar!)

EDIT: to add a copy&paste note.

Goot

Ok, well, I'll just have to import them all in little boxes. Is there any way to do the yellow square thing? When you move the mouse over an inventory item, the pic. changes to the item with the square. How do you script that?

Scorpiorus

#7
Take a look into the template I posted, it has such yellow square selector implemented. ;)

EDIT: if the link doesn't work - copy & paste it to the address bar.

SMF spam blocked by CleanTalk