// *************************************************************************** void CSheetManager::loadAllSheetNoPackedSheet(NLMISC::IProgressCallback &callBack, const std::vector<std::string> &extensions, const std::string &wildcardFilter) { callBack.progress (0); callBack.pushCropedValues (0, 0.5f); // load all forms ::loadFormNoPackedSheet(extensions, _EntitySheetContainer, wildcardFilter); // callBack.popCropedValues(); }
//----------------------------------------------- // loadAllSheet : // Load all sheets. //----------------------------------------------- void CSheetManager::loadAllSheet(NLMISC::IProgressCallback &callBack, bool updatePackedSheet, bool needComputeVS, bool dumpVSIndex, bool forceRecompute /*= false*/, const std::vector<std::string> *userExtensions /*= NULL*/) { callBack.progress (0); callBack.pushCropedValues (0, 0.5f); // Get some informations from typ files. loadTyp(); // prepare a list of sheets extension to load. vector<string> extensions; uint sizeTypeVersion = sizeof(TypeVersion); uint sizeCTypeVersion = sizeof(CTypeVersion); uint nb = sizeTypeVersion/sizeCTypeVersion; { if (!userExtensions) { _EntitySheetContainer.clear(); } TEntitySheetMap entitySheetContainer; for(uint i=0; i<nb; ++i) { // see if extension is wanted bool found = false; if (userExtensions) { for(uint l = 0; l < userExtensions->size(); ++l) { if (stricmp((*userExtensions)[l].c_str(), TypeVersion[i].Type.c_str()) == 0) { found = true; } } } else { found = true; } if (found) { entitySheetContainer.clear(); extensions.clear(); extensions.push_back(TypeVersion[i].Type); CSheetManagerEntry::setVersion(TypeVersion[i].Version); string path = CPath::lookup(TypeVersion[i].Type + ".packed_sheets", false); if (forceRecompute && !path.empty()) { // delete previous packed sheets NLMISC::CFile::deleteFile(path); path.clear(); } if(path.empty()) path = "../../client/data/" + TypeVersion[i].Type + ".packed_sheets"; ::loadForm(extensions, path, entitySheetContainer, updatePackedSheet); TEntitySheetMap::iterator it = entitySheetContainer.begin(); while(it != entitySheetContainer.end()) { _EntitySheetContainer[(*it).first] = (*it).second; (*it).second.EntitySheet = 0; // Next ++it; } } } } // Re-compute Visual Slot if(needComputeVS) computeVS(); // Compute Visual Slots { for(uint i=0; i<SLOTTYPE::NB_SLOT; ++i) _VisualSlots[i].resize(CVisualSlotManager::getInstance()->getNbIndex((SLOTTYPE::EVisualSlot)i)+1, 0); // Nb Index +1 because index 0 is reserve for empty. // TEntitySheetMap::iterator it = _EntitySheetContainer.begin(); while(it != _EntitySheetContainer.end()) { std::vector<CVisualSlotManager::TIdxbyVS> result; CVisualSlotManager::getInstance()->sheet2Index((*it).first, result); for(uint i=0; i<result.size(); ++i) { if(dynamic_cast<CItemSheet *>((*it).second.EntitySheet)) { _SheetToVS[dynamic_cast<CItemSheet *>((*it).second.EntitySheet)].push_back(std::make_pair(result[i].VisualSlot, result[i].Index)); _VisualSlots[result[i].VisualSlot][result[i].Index] = dynamic_cast<CItemSheet *>((*it).second.EntitySheet); } } ++it; } } // Dump visual slots // nb : if a new visual_slot.tab has just been generated don't forget // to move it in data_common before dump. if(dumpVSIndex) dumpVisualSlotsIndex(); // callBack.popCropedValues(); }// loadAllSheet //
void CCDBStructNodeBranch::init( xmlNodePtr node, NLMISC::IProgressCallback &progressCallBack ) { xmlNodePtr child; // look for other branches within this branch uint countNode = CIXml::countChildren (node, "branch") + CIXml::countChildren (node, "leaf"); uint nodeId = 0; for (child = CIXml::getFirstChildNode (node, "branch"); child; child = CIXml::getNextChildNode (child, "branch")) { // Progress bar progressCallBack.progress ((float)nodeId/(float)countNode); progressCallBack.pushCropedValues ((float)nodeId/(float)countNode, (float)(nodeId+1)/(float)countNode); CXMLAutoPtr name((const char*)xmlGetProp (child, (xmlChar*)"name")); CXMLAutoPtr count((const char*)xmlGetProp (child, (xmlChar*)"count")); CXMLAutoPtr bank((const char*)xmlGetProp (child, (xmlChar*)"bank")); CXMLAutoPtr atom((const char*)xmlGetProp (child, (xmlChar*)"atom")); CXMLAutoPtr clientonly((const char*)xmlGetProp (child, (xmlChar*)"clientonly")); string sBank, sAtom, sClientonly; if ( bank ) sBank = bank.getDatas(); if ( atom ) sAtom = atom.getDatas(); if ( clientonly ) sClientonly = clientonly.getDatas(); nlassert((const char *) name != NULL); if ((const char *) count != NULL) { // dealing with an array of entries uint countAsInt; NLMISC::fromString(count, countAsInt); nlassert((const char *) count != NULL); for (uint i=0; i<countAsInt; i++) { // Progress bar progressCallBack.progress ((float)i/(float)countAsInt); progressCallBack.pushCropedValues ((float)i/(float)countAsInt, (float)(i+1)/(float)countAsInt); // nlinfo("+ %s%d",name,i); addNode( new CCDBStructNodeBranch, string(name.getDatas())+toString(i), this, _Names, _Nodes, _Index, child, sBank.c_str(), sAtom=="1", sClientonly=="1", progressCallBack ); /* _Names.push_back(string(name)+toString(i)); _Index.insert(make_pair(string(name)+toString(i),_Nodes.size())); _Nodes.push_back(new CCDBStructNodeBranch); _Nodes.back()->setParent(this); _Nodes.back()->init(child); */ // nlinfo("-"); // Progress bar progressCallBack.popCropedValues (); } } else { // dealing with a single entry // nlinfo("+ %s",name); addNode( new CCDBStructNodeBranch, string(name.getDatas()), this, _Names, _Nodes, _Index, child, sBank.c_str(), sAtom=="1", sClientonly=="1", progressCallBack ); /* _Names.push_back(name); _Index.insert(make_pair(name,_Nodes.size())); _Nodes.push_back(new CCDBStructNodeBranch); _Nodes.back()->setParent(this); _Nodes.back()->init(child); */ // nlinfo("-"); } // Progress bar progressCallBack.popCropedValues (); nodeId++; } // look for leaves of this branch for (child = CIXml::getFirstChildNode (node, "leaf"); child; child = CIXml::getNextChildNode (child, "leaf")) { // Progress bar progressCallBack.progress ((float)nodeId/(float)countNode); progressCallBack.pushCropedValues ((float)nodeId/(float)countNode, (float)(nodeId+1)/(float)countNode); CXMLAutoPtr name((const char*)xmlGetProp (child, (xmlChar*)"name")); CXMLAutoPtr count((const char*)xmlGetProp (child, (xmlChar*)"count")); CXMLAutoPtr bank((const char*)xmlGetProp (child, (xmlChar*)"bank")); string sBank; if ( bank ) sBank = bank.getDatas(); nlassert((const char *) name != NULL); if ((const char *) count != NULL) { // dealing with an array of entries uint countAsInt; NLMISC::fromString(count, countAsInt); nlassert((const char *) count != NULL); for (uint i=0; i<countAsInt; i++) { // Progress bar progressCallBack.progress ((float)i/(float)countAsInt); progressCallBack.pushCropedValues ((float)i/(float)countAsInt, (float)(i+1)/(float)countAsInt); // nlinfo(" %s%d",name,i); addNode( new CCDBStructNodeLeaf, string(name.getDatas())+toString(i), this, _Names, _Nodes, _Index, child, sBank.c_str(), false, false, progressCallBack ); /* _Names.push_back(string(name)+toString(i)); _Index.insert(make_pair(string(name)+toString(i),_Nodes.size())); _Nodes.push_back(new CCDBStructNodeLeaf); _Nodes.back()->setParent(this); _Nodes.back()->init(child); */ // Progress bar progressCallBack.popCropedValues (); } } else { // nlinfo(" %s",name); addNode( new CCDBStructNodeLeaf, string(name.getDatas()), this, _Names, _Nodes, _Index, child, sBank.c_str(), false, false, progressCallBack ); /* _Names.push_back(name); _Index.insert(make_pair(name,_Nodes.size())); _Nodes.push_back(new CCDBStructNodeLeaf); _Nodes.back()->setParent(this); _Nodes.back()->init(child); */ } // Progress bar progressCallBack.popCropedValues (); nodeId++; } calcIdBits(); }