[SOLVED] SetGUIObjectSize doesn't work for inventory?

Started by stryker, Fri 23/07/2004 13:42:11

Previous topic - Next topic

stryker

Hi!
I used to write on these forum long time ago, when I was developing Opensource Discworld Interaction System (ODIS, maybe someone remembers it). Now i'm back and i'm working on a new version, even more similar to the original Discworld system.
I'm very glad SetGUIObjectSize has been added to ags, because it is indispensable to crate a resizable inventory like the one in Discworld.
The problem is: it doesn't work for the inventory windows.
I mean, i wrote all the code to do a resizable inventory GUI (that includes may gui objects, like the inventory itself, the status bar etc), and it works fine. The other objects in the GUI resizes as well, so you can se, just like in the normal windows in Windows (heh), the GUI itself changing size as you drag the bottom-right corner, and the various object in it following the resize. TheÃ,  only object that wont resize is the inventory.
To be more specific: the inventory resizes, but the inv objects in it stays in the same position, they don't reposition to fit the new inventory size, so the resize is totally futile. Even if you resize the inventory to be very small, you can still see all the inv objects, just you can't click the ones out of the inventory.

So, is there a way to resize the inventory AND make the inv objects in it "recognize" the new size?

I'll past the code I used (even I'm pretty sure it is not a code error).


Ã,  if (resize == 1) {
Ã,  Ã,  SetGUISize(INVENTORYA,mouse.x-guix,mouse.y-guiy);
Ã,  Ã,  SetGUISize(INVENTORYB,mouse.x-guix,mouse.y-guiy);
Ã,  Ã,  SetGUIObjectPosition(INVENTORYA,2,mouse.x-guix+10,mouse.y-guiy+10);
Ã,  Ã,  SetGUIObjectSize(INVENTORYA,0,mouse.x-guix+2,17);
Ã,  Ã,  SetGUIObjectSize(INVENTORYA,1,mouse.x-guix+15,mouse.x-guix+15);
Ã,  Ã,  }


resize == 1 is when the handle in the bottom-right corner is pressed
guix and guiy are the coordinates for the top left corner of the GUI
obj 0 is the status bar
obj 1 is the inventory
obj 2 is the bottom-right handle


Thankyou and sorry for the crappy english


ps: RefreshInventory doesn't slove it.

Download Discworld Template ODIS ver1.2
(right-click and "save as")

Radiant

How about turning the relevant GUI off, then on again?

stryker

No way. When you pop it up again it is still buggy.

AND the scrolling arrows for the inventory, perfectly working before resizing, they don't work anymore once the inventory has been resized using the SetGUIObjectSize handle.

Download Discworld Template ODIS ver1.2
(right-click and "save as")

Ashen

You need a SetInvDimensions(x, y); line in there, to resize the inventory objects to fit the new window. I think that should fix the scroll arrows as well.

BUT: This doesn't change the size of the objects, just the space between them.  The only way I can think of to do that is to actually make different sized sprites and change them using SetInvItemPic(item, sprite); to fit the size of the GUI. That would need a lot of coding, though, so it might not be worth it.
I know what you're thinking ... Don't think that.

stryker

The resize feature would be useless if the objects inside the inventory will grow bigger or smaller, instead of changing their disposition.
The thing I'm expecting from the resizing of the inventory is that all the objects inside it will dispose to fit the new size. So, if I reduce the width of the inventory, the objects should dispose on more rows. If I reduce the height they should dispose on more columns. Just like the icons in a window once you select "automatic position" in Windows.

Let me show it under a different point of view: if you resize the inventory window from the AGS client, the inv objects will re-position automatically at the game start, dpending on the size you give to the inventory. But if you resize the inventory with the command in question (SetGUIObjectSize), the objects in it will just stay as they are, and that's the problem!
If the command really doesn't work for inventory windows, it's pretty useless, because 90% of the resizable GUIs I can think of have inventory windows.

Download Discworld Template ODIS ver1.2
(right-click and "save as")

stryker

Anyone who can tell me if it's an AGS bug or a fault of mine? Or give me some trick to get accross it? CJ?

Download Discworld Template ODIS ver1.2
(right-click and "save as")

SSH

Have you tried modifying game.items_per_line  ?
12

stryker

That's it!!! Thankyou SSH! Now it works fine!

Now the problem is getting work the scrolling arrows. Here's the code I wrote for the resizing inventory (this code is within the "resizing function", that is called whenever the inventory GUI is resized; guix and guiy are the coordinates of the upper left corner of the inventory GUI):

Ã,  Ã,  game.items_per_line = ((mouse.x-guix)/32);
Ã,  Ã,  game.num_inv_displayed = ((mouse.y-guiy)/32)*game.items_per_line;



And here's the arrows code, that I didn't wrote but stealed somewhere from the forums:

Ã,  if (interface==INVENTORYA) {
Ã,  Ã,  if (button == 3) {
Ã,  Ã,  Ã,  if (game.top_inv_item > 0) game.top_inv_item = game.top_inv_item-game.items_per_line;
Ã,  Ã,  Ã,  }

Ã,  Ã,  if (button == 4) {
Ã,  Ã,  Ã,  if (game.top_inv_item < game.num_inv_items-game.num_inv_displayed)
Ã,  Ã,  Ã,  game.top_inv_item = game.top_inv_item+game.items_per_line;
Ã,  Ã,  Ã,  }

I should get the arrows code working for the resizing inventory (first of all, I should understand why the arrow code don't work for the resizing inventory).

Oh, and one last question: in the AGS help I read that the bold game. functions where "read only", but game.items_per_line and game.num_inv_displayed, even being bold, are NOT read only, because I can succesfully modify them in the script! Why?

Thankyou again!

Download Discworld Template ODIS ver1.2
(right-click and "save as")

stryker

Ooops, my fault. It was just a problem with the GUIs.

Download Discworld Template ODIS ver1.2
(right-click and "save as")

SSH

Read only means, I think, "If you modify this variable you can seriously screw  things up" rather than ACTUALLY being read only.  ;)
12

Radiant

In that case I wonder what would happen if I'd change system.screenwidth (sp?)  to 410 :)

SSH

12

Pumaman

There is a bug here, yes, in that SetGUIObjectSize doesn't handle inventory windows so it doesn't recalculate the relevant variables. I'll add it to my list.

SMF spam blocked by CleanTalk