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).
Inventory
Re: Inventory
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;)
Re: Inventory
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.
btw. for future reference, please use the typedefs for list containers instead of the explicit type. We might change them in the future.
Re: Inventory
Can't follow you.maybe it is already done? no?
Re: Inventory
Some screenshot would be nice :)
Re: Inventory
Yes, but we still have those repeated for loops. They should go and being replaced by a single function call each.akebono wrote:https://github.com/akebono/openmw/commi ... c82b118449
and little more compact
https://github.com/akebono/openmw/commi ... cbfecef385
Re: Inventory
me realize at last) but stucked in enchanting for now)
Re: Inventory
something wrong with:
// EDITED by lgro: Please use [ code] and [/ code] (without spaces inside) tags.
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)