Inventory/Container GUI

Everything about development and the OpenMW source code.
User avatar
hircine
Posts: 157
Joined: 06 Aug 2011, 07:18

Inventory/Container GUI

Post by hircine »

Hey Guys, I started work on the container GUI recently. made a few bits of progress amidst no knowledge of the codebase, no experience with C++ (i have been spoilt with C#, I must admit)

here is a screeny :)

Image

You can activate containers and a window pops up with its name.
(I'll see if I can get sounds working too)

I also have the function that can add new items(test items, same functionality as the console command additem) into the container.
I haven't yet gotten that visualised other than showing weight in the container. (I added 200 Fur Cuirass' into it) :D

One thing I will need to find out how to do (help would be cool) is working with the container store iterator. Its a bit gnarly and my current attempts to do so make it that I have to change the scope of some var's from private to public to get it to work. (I'm most definitely doing it wrong).
Attachments
screenshot000.png
Last edited by hircine on 29 Mar 2012, 10:15, edited 1 time in total.
Reason: HOLY SCREENSHOTS MAN DRESSED LIKE A BAT.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory/Container GUI

Post by Zini »

I also have the function that can add new items(test items, same functionality as the console command additem) into the container.
That is actually of limited use (maybe as a private helper function). Each frame while a container GUI is open, you should check if the content of the container has changed. If that has happened, you need to iterate over the content of the iterator and update the GUI accordingly.
One thing I will need to find out how to do (help would be cool) is working with the container store iterator. Its a bit gnarly and my current attempts to do so make it that I have to change the scope of some var's from private to public to get it to work. (I'm most definitely doing it wrong).
Yes, you are. But I can't tell from your problem description what the problem is. You need to iterate over the container and change what is displayed in the GUI accordingly (wiping the GUI completely and then filling it back should be sufficient for a start). The container iterator is more or less a standard iterator like you find it in the STL. If you can use these, you should also be able to use the container iterators.
User avatar
gus
Posts: 390
Joined: 11 Aug 2011, 15:41

Re: Inventory/Container GUI

Post by gus »

I'm helping hircine with this task. For now, i mostly took his code and corrected it.
Right now, you can open an container and see what's inside with nice icons and item stacking.

I'm working on the player inventory, and hircine is working on xml files/good look stuff.
User avatar
gus
Posts: 390
Joined: 11 Aug 2011, 15:41

Re: Inventory/Container GUI

Post by gus »

Is there a proper way to remove an object from a containerStore?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory/Container GUI

Post by Zini »

Set the count to 0.
User avatar
gus
Posts: 390
Joined: 11 Aug 2011, 15:41

Re: Inventory/Container GUI

Post by gus »

Thanks!
User avatar
gus
Posts: 390
Joined: 11 Aug 2011, 15:41

Re: Inventory/Container GUI

Post by gus »

One more question: (related to the previous one)
How to move a Ptr from one container to another?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory/Container GUI

Post by Zini »

You can't. Copy and delete instead. Use the add function of the destination container and then set the count of the original item to 0.
User avatar
gus
Posts: 390
Joined: 11 Aug 2011, 15:41

Re: Inventory/Container GUI

Post by gus »

I was trying t do that but i must do something wrong.

Here is what i'm doing:

Code: Select all

Container1Iterator iter = blabla;
iter->getRefData().setCount(0);
Ptr item = *iter;// the object we want to copy. But this does not create a new ptr...
Container2->add(item);
But that seems a little stupid, as *iter and Item are still pointing toward the same object... Also, this lead to an instant crash.

So how do i do a real copy of a ptr?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory/Container GUI

Post by Zini »

What you should do: copy and delete.

What you have done: delete and copy. Not very surprising that it doesn't work.
So how do i do a real copy of a ptr?
That is not what you want. Copying a Ptr does not create a new object. It just creates a new pointer to the old object.

What you want is to create a copy of the object that the pointer is pointing to. The add function takes care of that.
Post Reply