Inventory/Container GUI

Everything about development and the OpenMW source code.
User avatar
gus
Posts: 390
Joined: 11 Aug 2011, 15:41

Re: Inventory/Container GUI

Post by gus »

As anyone following what's happening on git knows, scrawl pretty much finished the inventory task :)
(Friday afternoon, he just told me he was bored and wanted to have a look at my branch, and when i came back one Monday, it was nearly finished^^ Anyway, that's great, because it's exam time for me!)
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory/Container GUI

Post by Zini »

Great!

However the use implementation is completely wrong and the equip implementation is at least very incomplete.

First, equipping does not tie in with activation. If you equip or use an item, this does not go through the regular activation sequence. Especially it does not affect OnActivate.

Instead, both equipping and using go through OnPCEquip. I think the sequence is somewhat similar to activation, but not identical. I am not sure about all the details.

You definitely need to take out the call to executeActionScript from onAvatarClicked (btw. the ActionScript name is misleading, because there are no action scripts).

Then I suggest to unify use and equip. Implement use functions in equippable classes and return an equip action.

After that you can look into implementing OnPCEquip or we can make that a separate task.
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Inventory/Container GUI

Post by scrawl »

Oh. I didn't know that, I thought it would use the same scripts as activating (for example as with the Bitter Cup)
Then I suggest to unify use and equip. Implement use functions in equippable classes and return an equip action.
Sounds like some unnecessary work right now, until I got it working. (The same with scripts, actually)

Here's the status about equipping / a question: when you start dragging an object, it gets inserted into a seperate ContainerStore (that belongs to the DragAndDrop class) in order to un-stack among other things. Then, when you drop it on the player avatar (=equip it) it first has to be re-inserted into the player inventory before it can be equipped. Now my problem is, that I can re-insert it just fine, but then I don't have a ContainerStoreIterator to the object in the inventory, so I can't set the equipped slot correctly. So, what I think has to be done, is that ContainerStore::add returns a ContainerStoreIterator to the object that was just inserted. I have implemented this for the case where the item gets stacked (which was easy) but I don't know how to do it for the other case. Could you have a look at it?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory/Container GUI

Post by Zini »

That is problematic at best. Even without the problem you mentioned, your approach will get you into trouble with script execution sooner or later (there might be scripts running on the object in the store and when you move it to a different store and then back, it won't be the same object anymore).

I think it would be a lot easier, if you don't remove the object from the container store on a drag. Instead mark it as being dragged in the GUI class and filter it out of the view. And then only remove it, when it is actually dropped into a different container or onto the ground.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory/Container GUI

Post by Zini »

Sounds like some unnecessary work right now, until I got it working. (The same with scripts, actually)
Okay. So make make that a separate task then.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory/Container GUI

Post by Zini »

btw. I just started working on container capacity (should be finished soon).

I think that needs to be considered for the UI too. First you need to adjust the encumbrance bar. And then you have to reject drags into containers (but not player inventory) that exceed the capacity limit.
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Inventory/Container GUI

Post by scrawl »

Zini wrote:That is problematic at best. Even without the problem you mentioned, your approach will get you into trouble with script execution sooner or later (there might be scripts running on the object in the store and when you move it to a different store and then back, it won't be the same object anymore).
But wouldn't that issue still be existent, when you move an item from your inventory into a container and back?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory/Container GUI

Post by Zini »

No. When you actually move the object out of the container, it becomes a new object for MW and the old one is deleted. MW does not have move-semantics.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory/Container GUI

Post by Zini »

Zini wrote:btw. I just started working on container capacity (should be finished soon).

I think that needs to be considered for the UI too. First you need to adjust the encumbrance bar. And then you have to reject drags into containers (but not player inventory) that exceed the capacity limit.
That went even faster than I expected. I finished the task and merged into master. Please merge my master into your inventoryGUI branch and see if you can do anything with it (2 new functions in MWWorld::Class).
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Inventory/Container GUI

Post by scrawl »

I just did what you suggested (with the drag&drop) and equipping works - but only for items that are in the player's inventory. What doesn't work is dragging an object from a different container directly onto the player avatar. In that case it has to be moved into the player's inventory first, and that means it becomes a new object and I don't have a pointer to it anymore. Any ideas on that one?

In the meantime, I'll do encumbrance&weight.

Edit: is there a way to subscribe to changes of capacity/weight or am i supposed to do it every frame?
Post Reply