void TfrmObjectList::UpdateState() { tvItems->IsUpdating = true; tvItems->OnItemSelectedChange = 0; TElTreeItem* sel_node = 0; bool need_sort = false; for ( TElTreeItem* node = tvItems->Items->GetFirstNode(); node; node = node->GetNext()){ if (node&&(node->Level>0)){ CCustomObject* O = (CCustomObject*)node->Data; node->ParentStyle = false; node->StrikeOut = !O->Visible(); if (rgSO->ItemIndex==1) node->Hidden = !O->Visible(); else if (rgSO->ItemIndex==2)node->Hidden = O->Visible(); if (O->Visible()) node->Selected = O->Selected(); if (O->Selected()) sel_node = node; if (!node->Hidden){ if (AnsiString(node->Text)!=O->Name){ node->Text = O->Name; need_sort = true; } } } } tvItems->IsUpdating = false; if (need_sort) tvItems->Sort (true); if (sel_node) tvItems->EnsureVisible(sel_node); }
void __fastcall TfrmChoseItem::ebMultiRemoveClick(TObject *Sender) { if (tvMulti->Selected){ TElTreeItem *cur = tvMulti->Selected; TElTreeItem *node = tvItems->Items->LookForItem(0,cur->Text,0,0,false,true,false,true,true); if (node) node->Checked = false; tvMulti->Selected = cur->GetNext()?cur->GetNext():cur->GetPrev(); cur->Delete(); } }
//--------------------------------------------------------------------------- TElTreeItem* TfrmObjectList::FindObjectByType(int type, void *obj) { for ( TElTreeItem* node = tvItems->Items->GetFirstNode(); node; node = node->GetNext()) if (!node->Parent && (node->Data == (void*)type)){ for (TElTreeItem* chield = node->GetFirstChild(); chield; chield = node->GetNextChild(chield)) if (chield->Data==obj) return chield; break; } return 0; }
TElTreeItem* CFolderHelper::ExpandItem(TElTree* tv, TElTreeItem* node) { if (node){ tv->IsUpdating = true; TElTreeItem* folder = node->Parent; while(folder){ if (folder) folder->Expand(false); if (folder->Parent){ folder = folder->Parent; }else break; } tv->IsUpdating = false; } return node; }
void __fastcall TfrmChoseItem::tvItemsItemChange(TObject *Sender, TElTreeItem *Item, TItemChangeMode ItemChangeMode) { if (Item&&(ItemChangeMode==icmCheckState)){ AnsiString fn; FHelper.MakeName(Item,0,fn,false); TElTreeItem *node = tvMulti->Items->LookForItem(0,fn.c_str(),0,0,false,true,false,true,true); if (node&&!Item->Checked) node->Delete(); if (!node&&Item->Checked){ if ((tvMulti->Items->Count+1)<=iMultiSelLimit){ tvMulti->Items->AddObject(0,fn,(void*)TYPE_OBJECT); }else{ Item->Checked = false; Msg ("#Limit %d item(s).",iMultiSelLimit); } } } }
void __fastcall TfrmBonePart::ebSaveClick(TObject *Sender) { for (int k=0; k<4; k++) { if (T[k]->Items->Count&&E[k]->Text.IsEmpty()) { ELog.DlgMsg(mtError,"Verify parts name."); return; } for (int i=k-1; i>=0; i--) { if (!T[k]->Items->Count) continue; if (E[k]->Text.UpperCase()==E[i]->Text.UpperCase()) { ELog.DlgMsg(mtError,"Unique name required."); return; } } } // verify U8Vec b_use(m_EditObject->BoneCount(),0); for (k=0; k<4; k++) { if (T[k]->Items->Count) for ( TElTreeItem* node = T[k]->Items->GetFirstNode(); node; node = node->GetNext()) b_use[m_EditObject->FindBoneByNameIdx(AnsiString(node->Text).c_str())]++; } for (U8It u_it=b_use.begin(); u_it!=b_use.end(); u_it++) if (*u_it!=1) { ELog.DlgMsg (mtError,"Invalid bone part found (missing or duplicate bones)."); return; } // save m_BoneParts->clear(); for (k=0; k<4; k++) { if (T[k]->Items->Count) { m_BoneParts->push_back(SBonePart()); SBonePart& BP = m_BoneParts->back(); BP.alias = E[k]->Text.c_str(); for ( TElTreeItem* node = T[k]->Items->GetFirstNode(); node; node = node->GetNext()) BP.bones.push_back(AnsiString(node->Text).c_str()); } } ATools->OnMotionDefsModified(); Close(); ModalResult = mrOk; }
void __fastcall TfrmBonePart::ebSaveToClick(TObject *Sender) { xr_string temp_fn; if (EFS.GetSaveName( _import_, temp_fn) ) { CInifile ini (temp_fn.c_str(), FALSE, FALSE, TRUE); string64 buff; for(int i=0; i<4; ++i) { sprintf (buff,"part_%d",i); ini.w_string(buff, "partition_name", E[i]->Text.c_str()); if (T[i]->Items->Count) { for ( TElTreeItem* node = T[i]->Items->GetFirstNode(); node; node = node->GetNext()) ini.w_string(buff, AnsiString(node->Text).c_str(), NULL ); } } } }
//--------------------------------------------------------------------------- void __fastcall TfrmChoseItem::sbSelectClick(TObject *Sender) { if (m_Flags.is(cfMultiSelect)){ select_item = ""; AnsiString nm; for ( TElTreeItem* node = tvMulti->Items->GetFirstNode(); node; node = node->GetNext()){ FHelper.MakeName(node,0,nm,false); select_item += nm+AnsiString(","); } if (!select_item.IsEmpty()) select_item.Delete(select_item.Length(),1); Close(); ModalResult = mrOk; }else{ if (tvItems->Selected&&FHelper.IsObject(tvItems->Selected)){ FHelper.MakeName(tvItems->Selected,0,select_item,false); Close(); ModalResult = mrOk; }else{ Msg ("#Select item first."); } } }
void __fastcall TfrmChoseItem::ebMultiClearClick(TObject *Sender) { tvMulti->Items->Clear(); for ( TElTreeItem* node = tvItems->Items->GetFirstNode(); node; node = node->GetNext()) if (node->Checked) node->Checked=false; }
//--------------------------------------------------------------------------- TElTreeItem* TfrmObjectList::FindFolderByType(int type) { for ( TElTreeItem* node = tvItems->Items->GetFirstNode(); node; node = node->GetNext()) if (!node->Parent && (node->Data == (void*)type)) return node; return 0; }
//--------------------------------------------------------------------------- // Drag'n'Drop //--------------------------------------------------------------------------- void CFolderHelper::DragDrop(TObject *Sender, TObject* Source, int X, int Y, TOnItemRename after_drag) { R_ASSERT(after_drag); TElTree* tv = dynamic_cast<TElTree*>(Sender); VERIFY(tv); tv->IsUpdating = true; TSTItemPart IP=(TSTItemPart)0; int hc=0; TElTreeItem* tgt_folder = tv->GetItemAt(X, Y, IP, hc); if (tgt_folder&&(IsObject(tgt_folder))) tgt_folder=tgt_folder->Parent; AnsiString base_name; MakeName(tgt_folder,0,base_name,true); AnsiString cur_fld_name=base_name; TElTreeItem* cur_folder=tgt_folder; //..FS.lock_rescan(); for (ELVecIt it=drag_items.begin(); it!=drag_items.end(); it++){ TElTreeItem* item = *it; int drg_level = item->Level; bool bFolderMove = IsFolder(item); do{ // проверяем есть ли в таргете такой элемент EItemType type = EItemType(item->Data); TElTreeItem* pNode = FindItemInFolder(type,tv,cur_folder,item->Text); if (pNode&&IsObject(item)){ Msg ("#!Item '%s' already exist in folder '%s'.",AnsiString(item->Text).c_str(),AnsiString(cur_folder->Text).c_str()); item = item->GetNext(); continue; } // если нет добавляем if (!pNode){ pNode = (type==TYPE_FOLDER)?LL_CreateFolder(tv,cur_folder,item->Text,item->ForceButtons):LL_CreateObject(tv,cur_folder,item->Text); if (type==TYPE_OBJECT) pNode->Assign(item); } if (IsFolder(item)){ cur_folder = pNode; MakeName (cur_folder,0,cur_fld_name,true); item = item->GetNext(); }else{ // rename AnsiString old_name, new_name; MakeName (item,0,old_name,false); MakeName (pNode,0,new_name,false); after_drag (old_name.c_str(),new_name.c_str(),TYPE_OBJECT); TElTreeItem* parent = item->Parent; // get next item && delete existence TElTreeItem* next = item->GetNext(); item->Delete (); if (parent&&((parent->GetLastChild()==item)||(0==parent->ChildrenCount))){ // if (0==parent->ChildrenCount) parent->Delete(); cur_folder = cur_folder?cur_folder->Parent:0; } item=next; } }while(item&&(item->Level>drg_level)); // delete folders if (bFolderMove){ AnsiString old_name; MakeName (*it,0,old_name,false); after_drag (old_name.c_str(),0,TYPE_FOLDER); (*it)->Delete (); } } //..FS.unlock_rescan(); tv->IsUpdating = false; }