int __fastcall TItemList::GetSelected(RStringVec& items) { for (TElTreeItem* item = tvItems->GetNextSelected(0); item; item = tvItems->GetNextSelected(item)){ if (item->Hidden) continue; AnsiString nm; FHelper.MakeFullName(item,0,nm); items.push_back (nm.c_str()); } return items.size(); }
void TItemList::SaveSelection(TFormStorage* storage) { RStringVec items; if (GetSelected(items)){ storage->WriteInteger("sel_cnt",items.size()); for (RStringVecIt l_it=items.begin(); l_it!=items.end(); l_it++) storage->WriteString(AnsiString().sprintf("sel%d",l_it-items.begin()),**l_it); } // for (AStringIt s_it=last_selected_items.begin(); s_it!=last_selected_items.end(); s_it++) // storage->WriteString(AnsiString().sprintf("sel%d",s_it-last_selected_items.begin()),*s_it); }
void _SequenceToList(RStringVec& lst, LPCSTR in, char separator) { lst.clear (); int t_cnt = _GetItemCount(in,separator); xr_string T; for (int i=0; i<t_cnt; i++){ _GetItem(in,i,T,separator,0); _Trim (T); if (T.size()) lst.push_back(T.c_str()); } }
shared_str _ListToSequence(const RStringVec& lst) { xr_string out; if (lst.size()){ out = *lst.front(); for (RStringVec::const_iterator s_it=lst.begin()+1; s_it!=lst.end(); s_it++){ out += ","; out += **s_it; } } return shared_str (out.c_str()); }
void TfrmImageLib::OnCubeMapBtnClick(ButtonValue* value, bool& bModif, bool& ) { ButtonValue* B = dynamic_cast<ButtonValue*>(value); R_ASSERT(B); bModif = false; switch(B->btn_num){ case 0:{ RStringVec items; if (0!=m_ItemList->GetSelected(items)){ for (RStringVecIt it=items.begin(); it!=items.end(); it++){ AnsiString new_name = AnsiString(it->c_str())+"#small"; ImageLib.CreateSmallerCubeMap(it->c_str(),new_name.c_str()); } } }break; } }
void TItemList::GetFolders(RStringVec& folders) { for (TElTreeItem* item=tvItems->Items->GetFirstNode(); item; item=item->GetNext()){ if (FHelper.IsFolder(item)){ AnsiString nm; FHelper.MakeFullName(item,0,nm); folders.push_back (AnsiString(nm+'\\').c_str()); } } }
bool EDetailManager::Export(LPCSTR path) { AnsiString fn = AnsiString(path)+"build.details"; bool bRes=true; SPBItem* pb = UI->ProgressStart(5,"Making details..."); CMemoryWriter F; pb->Inc ("merge textures"); Fvector2Vec offsets; Fvector2Vec scales; boolVec rotated; RStringSet textures_set; RStringVec textures; U32Vec remap; U8Vec remap_object (objects.size(),u8(-1)); int slot_cnt = dtH.size_x*dtH.size_z; for (int slot_idx=0; slot_idx<slot_cnt; slot_idx++){ DetailSlot* it = &dtSlots[slot_idx]; for (int part=0; part<4; part++){ u8 id = it->r_id(part); if (id!=DetailSlot::ID_Empty) { textures_set.insert(((EDetail*)(objects[id]))->GetTextureName()); remap_object[id] = 1; } } } textures.assign (textures_set.begin(),textures_set.end()); U8It remap_object_it= remap_object.begin(); u32 new_idx = 0; for (DetailIt d_it=objects.begin(); d_it!=objects.end(); d_it++,remap_object_it++) if ((*remap_object_it==1)&&(textures_set.find(((EDetail*)(*d_it))->GetTextureName())!=textures_set.end())) *remap_object_it = (u8)new_idx++; AnsiString do_tex_name = ChangeFileExt(fn,"_details"); int res = ImageLib.CreateMergedTexture(textures,do_tex_name.c_str(),STextureParams::tfADXT1,256,1024,256,1024,offsets,scales,rotated,remap); if (1!=res) bRes=FALSE; pb->Inc ("export geometry"); // objects int object_idx = 0; if (bRes){ do_tex_name = ExtractFileName(do_tex_name); F.open_chunk (DETMGR_CHUNK_OBJECTS); for (DetailIt it=objects.begin(); it!=objects.end(); it++){ if (remap_object[it-objects.begin()]!=u8(-1)){ F.open_chunk (object_idx++); if (!((EDetail*)(*it))->m_pRefs){ ELog.DlgMsg(mtError, "Bad object or object not found '%s'.", ((EDetail*)(*it))->m_sRefs.c_str()); bRes=false; }else{ LPCSTR tex_name = ((EDetail*)(*it))->GetTextureName(); for (u32 t_idx=0; t_idx<textures.size(); t_idx++) if (textures[t_idx]==tex_name) break; VERIFY(t_idx<textures.size()); t_idx = remap[t_idx]; ((EDetail*)(*it))->Export (F,do_tex_name.c_str(),offsets[t_idx],scales[t_idx],rotated[t_idx]); } F.close_chunk (); if (!bRes) break; } } F.close_chunk (); } pb->Inc ("export slots"); // slots if (bRes){ xr_vector<DetailSlot> dt_slots(slot_cnt); dt_slots.assign(dtSlots,dtSlots+slot_cnt); for (slot_idx=0; slot_idx<slot_cnt; slot_idx++){ DetailSlot& it = dt_slots[slot_idx]; // zero colors need lighting it.c_dir = 0; it.c_hemi = 0; it.c_r = 0; it.c_g = 0; it.c_b = 0; for (int part=0; part<4; part++){ u8 id = it.r_id(part); if (id!=DetailSlot::ID_Empty) it.w_id(part,remap_object[id]); } } F.open_chunk (DETMGR_CHUNK_SLOTS); F.w (dt_slots.begin(),dtH.size_x*dtH.size_z*sizeof(DetailSlot)); F.close_chunk (); pb->Inc(); // write header dtH.version = DETAIL_VERSION; dtH.object_count= object_idx; F.w_chunk (DETMGR_CHUNK_HEADER,&dtH,sizeof(DetailHeader)); bRes = F.save_to(fn.c_str()); } pb->Inc(); UI->ProgressEnd(pb); return bRes; }