Inventory

Everything about development and the OpenMW source code.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Inventory

Post by Zini »

Old thread: http://openmw.org/forum/viewtopic.php?f=13&t=120

Finally took a look at the inventory branch and I must say it has come a long way since I looked the last time.

Here are the things that I think need improvement:

1. The hardcoded category-system is a bit problematic, but we can address this after OpenMW 1.0 is finished. However hardcoded category names are definitely not okay. You should read them from GMSTs.

2. The refreshView function is ugly. You can replace all those for loops with a simple function call each, if you use templates. There is an example on top of apps/opeenmw/mwworld.world.cpp that shows you how to do it.

3. And please lose that C-style output. In C++ we use streams.

4. The file name does not follow our naming policies. You can look them up in the wiki (man, I am so happy that I can say that again).


I haven't taken an inventory of what features are still missing (no pun intended), but I think you should start rather sooner than later thinking about how to split up the whole thing. We need to consider how we are going to implement GUI modes with more than one container windows (for now we should focus on exchanges with other containers; we can handle NPC-trade later).
akebono
Posts: 9
Joined: 13 Aug 2011, 10:13

Re: Inventory

Post by akebono »

some thoughts on 1st and filenaming in last push. still do not understood the 2nd thing. and about printfes, well, im using it just for my debugging needs, ill try to incorporate knowledge of std::turururm cout stuff;)
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory

Post by Zini »

What exactly is your problem with #2? There is a function template at the top of the file I mentioned, that iterates over the items in a list and does something with them. The only thing you need to do is to copy it over, rename it, change the parameter list accordingly and adjust the body of the for loop.

btw. for future reference, please use the typedefs for list containers instead of the explicit type. We might change them in the future.
akebono
Posts: 9
Joined: 13 Aug 2011, 10:13

Re: Inventory

Post by akebono »

maybe it is already done? no?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory

Post by Zini »

maybe it is already done? no?
Can't follow you.
User avatar
jvoisin
Posts: 303
Joined: 11 Aug 2011, 18:47
Contact:

Re: Inventory

Post by jvoisin »

Some screenshot would be nice :)
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Inventory

Post by Zini »

Yes, but we still have those repeated for loops. They should go and being replaced by a single function call each.
akebono
Posts: 9
Joined: 13 Aug 2011, 10:13

Re: Inventory

Post by akebono »

me realize at last) but stucked in enchanting for now)
akebono
Posts: 9
Joined: 13 Aug 2011, 10:13

Re: Inventory

Post by akebono »

something wrong with:

Code: Select all

void funct(std::list<ESMS::LiveCellRef<T, MWWorld::RefData> > itemlist)
{
  MyGUI::StaticImagePtr Item;
  for(typename std::list<ESMS::LiveCellRef<T, MWWorld::RefData> >::iterator it = itemlist.begin();
  it != itemlist.end();
  it++)
  {
   Item=items->createWidget<MyGUI::StaticImage>("StaticImage",20, 20, 40, 40, MyGUI::Align::Default );
   MWWorld::Ptr ptr=MWWorld::Ptr(&*it, 0);
   Item->eventMouseButtonClick = MyGUI::newDelegate(this,&InventoryWindow::onInventoryClick);
   mItems.insert(std::make_pair(Item, ptr)); //std::map<MyGUI::WidgetPtr, MWWorld::Ptr> mItems;
 }
}

InventoryWindow::onInventoryClick(MyGUI::WidgetPtr _sender)
{
 int oldcount=mItems[_sender].getRefData().getCount();

 //getCount here returns something weird (0,1,6,7,12871293 etc.),
 // but in RefData constructor strictly :mCount(1), which getCount(){ return mCount;}
}

int oldcount=(mItems.find(_sender) != mItems.end())
  ?  &*mItems.find(_sender))->second.getRefData().getCount()
  : 800; //not helps (oldcount != 800)
// EDITED by lgro: Please use [ code] and [/ code] (without spaces inside) tags.
Post Reply