Inventory/Container GUI

Everything about development and the OpenMW source code.
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Inventory/Container GUI

Post by scrawl »

Btw, there was a typo in the getCapacity method name. You can cherry-pick e9ea1fba4e85ab99fc030ace36512f64d1140d9c from my branch (or we just wait until it's in master)
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory/Container GUI

Post by Zini »

Oops. I'll wait. Doesn't look like the GUI will take much longer anyway.
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Inventory/Container GUI

Post by scrawl »

Haven't you seen my previous post or do you have no idea about it?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory/Container GUI

Post by Zini »

Thinking ... Doesn't work instantly; unfortunately. And then something else got in the way. Sorry.

First the easy one:
Edit: is there a way to subscribe to changes of capacity/weight or am i supposed to do it every frame?
No. There isn't. You need to check it every frame.
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?
The idea about moving it into the player's inventory first is correct. Guess we need to change the add function to return an iterator after all. You will have to add a new private constructor to ContainerStoreIterator, since the existing constructors only provide begin and end iterators. And this will need to be a template, which takes the container store, the type (to store in mType) and ESMS::CellRefList<X, RefData>::List::iterator to initialise one of the internal iterators as arguments.
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Inventory/Container GUI

Post by scrawl »

Ok, that was basically my idea as well, though I'm a bit scared of using templates.. but we'll see.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory/Container GUI

Post by Zini »

Actually. Forgot about the templates. Add one constructor for each type that can go into a container. You need to handle each of these cases with separate code anyway and doing it without template specialisation will be much shorter and more simple too.
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Inventory/Container GUI

Post by scrawl »

And that constructor will always return the last iterator of the specified type?

Edit: I think I got what you mean.. so one of the constructors would look like so?


ContainerStoreIterator (ContainerStore *container, ESMS::CellRefList<ESM::Potion, RefData>::List::iterator);
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory/Container GUI

Post by Zini »

Not entirely sure what you mean. Constructors don't return anything.

If you meant what the newly constructed iterator is set to, then no. The function signature should not change from the template version I proposed first. You can't rely on that the new object will always be at the end of the iterator. Could be stacked, after all.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory/Container GUI

Post by Zini »

About your edit: That looks right.
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Inventory/Container GUI

Post by scrawl »

Awesome, working.
Post Reply